Pages

Friday, 25 July 2014

Microsoft Excel Project Management Plan and Gantt Chart Tutorial

What to expect from this tutorial.

Figure 1

Creating the Project Plan

Open excel, create a blank project then add the following headings.

Figure 2

Enter the Sample data below.

Figure 3

Calculating the duration using the “Start Date” and “End Date”.

Figure 4

Calculating the overall “Percentage Completed” for a group. 
Formula =SUM (E4:E8) / (COUNT (E4:E8)*100) *100

Figure 5

Calculating the “Percentage Completed” for a task.

Figure 6

Calculating “Current Duration” for a specific group and an individual task.

Figure 7

Calculating the “Completed” days for a group given the days completed for tasks within that group.

Figure 8

Creating the Gantt Chart

From the top menu select Insert, then in the charts section select Bar and click the Stacked Bar.

Figure 9

You now have a blank chart. To populate the chart with the data we created earlier right click and click Select Data.

Figure 10

The Select Data Source window will appear.

Figure 11

Click the Add button. The Edit Series window will appear. In the Edit Series window click the first table symbol with a red arrow called Series Name.

Figure 12

Now click the “Start Date” cell. Then click the symbol with the red arrow pointing downward in the Edit Series window.

Figure 13

In the Edit Series window click the second table symbol with a red arrow called Series Value. Click and drag to select the “Start Date” range. Once selected click the symbol with the red arrow pointing downward in the Edit Series window.

Figure 14

Figure 15

Click OK in the Edit Series window. We should now have our "Start Dates" in our Select Data Source window. Repeat the above process to add the “Current Duration” and “Completed” columns so our Legend Entries (Series) in the Select Data Source window. You can do this by clicking Add.

Figure 16

Your Legend Entries (Series) in the Select Data Source window should look something like Figure 17.

Figure 17

Now we will add our “Task ID” and “Tasks” to the Horizontal (Category) Axis Labels in the Select Data Source window.
You do this by clicking the Edit button on the right side of the Select Data Source window.
The Axis Labels window will appear click table symbol with a red arrow called Axis Label Range.
Drag and select the range from the first task id to the last task in the list. Next click the symbol with the red arrow pointing downward in the Edit Series window, click OK.

Figure 18

Your Select Data Source window should look like this.

Figure 19

Click OK
Resize the graph by dragging the edges outwards to your desired size.
Right click the Task ID and Tasks on the graph and click Format Axis.

Figure 20

Tick Categories in reverse order then click OK

Figure 21

Right click the dates in the graph and click Format Axis.
Copy the Axis Options information in the image below. Note: dates in excel are represented as numbers the formula for calculating the number of any given date is =DATEVALUE("7/7/2014"). The Major unit is the spacing between dates and this is measured in days for example below I have used 30 day gaps.

Figure 22

Click on the alignment menu in the Format Axis window. Set the Custom angle to -1 then click Close and resize your graph so that everything is displaying accurately.

Figure 23

Right click the blue section or the Start Date section of the bars in the graph and click Format Data Series. In the Format Data Series window change the Fill to No fill and the Border Color to No Line and click Close.

Figure 24

Figure 25

You can also change the colour of the “Current Duration” section of the bar by repeating the above process but this time select Solid fill and chose your desired color.

Now you Project Plan is complete and ready to use, all you have to do is enter the number of days you have spent on each task in the light green cells under the “Completed” column and the rest will update automatically.

Figure 26

Saturday, 5 April 2014

JAVA create JTable using Vector() and one class

Note: This example assumes that a connection class already exists. 

/**
 * Fields
 **/
     // Connection variables.
     Connection conn = null;
     PreparedStatement pst = null;
     static ResultSet rst = null;

     private Vector columnNames = new Vector();
     private Vector data = new Vector();
     private JTable tblData = new JTable();
     private DefaultTableModel model;
    
     private JPanel pnl_Data = new JPanel();
     …
     …                              

     …

/**
 *Constructor
 **/
public Class(){
     Connect_to_database ctb = new Connect_to_database();
     conn = ctb.ConnectDb();
    
     createTable();
     …
     …   
     …
    
     pnl_Data.setBorder(new TitledBorder(null, "Data", TitledBorder.CENTER, TitledBorder.TOP, null, Color.BLUE));
     pnl_Data.setBackground(Color.WHITE);
     pnl_Data.setBounds(570, 11, 636, 850);
     contentPane.add(pnl_Data);
}

/**
 * Load table Data Method
 **/
public void reloadData(){
     columnNames.clear();
     data.clear();
          
     try {
           String sql = "SELECT * FROM User_tb“;
          
           pst = conn.prepareStatement(sql);
           rst = pst.executeQuery();

           ResultSetMetaData md = rst.getMetaData();
           int columns = md.getColumnCount();
               
           for (int i = 1; i <= columns; i++) {
                columnNames.addElement( md.getColumnName(i) );
           } while (rst.next()) {
                Vector row = new Vector(columns);
                for (int i = 1; i <= columns; i++){
                     row.addElement( rst.getObject(i) );
                }
                data.addElement( row );
           }

           rst.close();
           pst.close();
     } catch (Exception e) {
           System.out.println("Error at reloadData()" + e);
     }
}

/**
 * Create table method
 **/
public void createTable() {
     reloadData();
               
     try {
           model = new DefaultTableModel(data, columnNames);
           tblData = new JTable(model);
                    
           tblData.setBounds(10, 829, 616, -802);
           JScrollPane scroll = new JScrollPane(tblData, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
           tblData.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
           scroll.setBorder(null);
           tblData.setBorder(null);
           scroll.setPreferredSize(new Dimension(610, 809));
           pnl_Data.add(scrollCPL);
     } catch (Exception e) {
           System.out.println("Error at createTable()" + e);
     }
}

by: Michael Lashley

Tuesday, 5 March 2013

Sum/Addition Minijava Program


//By Michael Lashley 

//The following program states what the followiing code does for example, it sums all the numbers 
//in an array and returns the overall total. 

//Class is created
class AdditionTestMini
{
    public static void main(String[] a){ 
System.out.println(((new Sum()).init()).sumAdd());
    }
}

//class is created for the sum of enteries 
class Sum
{
    int[] data;
        
    //below the line of code "getLenght" returns the length of the array (number of elements in the array).
    public int getLength()
    {
        return data.length;
    }

    //this method initials values to specific positions in the array.
    public Sum init()
    {  
        
int index;
        data = new int[5];
        data[0] = 4;
        data[1] = 6;
        data[2] = 8;
        data[3] = 12;
        data[4] = 14;
        return this;               
    }

    //this method calculates/add together the value of all elements in the array stated above.
    public int sumAdd()
    {
        int i;
        int total; 
        int current;
        current = 0;/
        total = 0;
        i = 0;

        //this while loop checks the condition, that the current position in the array is less than the length of the array.
        while (i < (data.length)){
                current = data[i];
                total = total + current;
                i = i + 1;
        }  
        return total;    
    }    
}

MiniJava Grammar


This image shows a reconstructed version of the standard mini java grammar which avoids left-recursion and ambiguity. During my Language Processors module I had the pleasure of working with this mini java grammar firstly to write a program using this grammar, secondly to complete write a .jj file which will parse a selected list of mini java programs and lastly to program a type checker and interpreter for the grammar. Compared to standard java mini java should be simpler but having learnt standard java first it was a challenge getting to grips with a this grammar, nonetheless I enjoyed every second of this module...

Friday, 15 February 2013

Functional Programming Code

 
-----------------------------------------------------------------------------
-- |
-- Module      :  MyAnimation
-- Copyright   :  (c) Michael Lashley 2012
-- License     :  NA
-- Maintainer  :  Michael Lashley
-- Stability   :  experimental
-- Portability :  portable
--
-- A animation called "The Impossible".
-- This animation is a series of squares which change scale while spining
-- around a central orbit/gravitational pull.
--
-----------------------------------------------------------------------------
 
module MyAnimation where
 
-- Import libraries functions from the Animation .hs file.
 
import Animation
 
-- The spin function takes two inputs of type int and returns an animation.
-- This function applies functions from the Animation library to each rect object created by the list in the Picture function.
 
spin :: Int -> Int -> Animation
spin i j =
  rotate (spinner k)
   (rotate (ever z)
    (translate (ever (-x/2, -x/2))
     (withGenPaint (cycleSmooth (x/10) [c, yellow, lime, purple, cyan, grey, olive]) (cycleSmooth 7 [0.2, 1])
      (rect (cycleSmooth 10 [x/2, 1.5]) (cycleSmooth 5 [6*x, 20])))))

 where
    x = fromIntegral j
    c = hsl (fromIntegral i * 45) 1 0.5
    z = fromIntegral(i `mod` 2) * 45
    k = -10 + 0.5*fromIntegral i
 
-- The picture function returns and animation.
-- This function calls the Spin function in a list compression with defined variables i and x.
 
picture :: Animation
picture =

 withPaint (ever black)
   (rect (ever 800) (ever 600)) `plus`

 translate (ever (400, 300))
 (combine [spin i x | i <- [0..16], x <- [350, 150..50]])
 
-- "test" is a function that writes/creates a .svg file when called.
-- The test.svg file invokes the Picture function there for starting the animation.
 
test :: IO ()
test = writeFile "test.svg" (svg 800 600 picture)