Java Code Examples for org.jfree.data.gantt.Task#addSubtask()

The following examples show how to use org.jfree.data.gantt.Task#addSubtask() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TaskSeriesCollectionTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a sample collection for testing purposes.
 *
 * @return A sample collection.
 */
private TaskSeriesCollection createCollection2() {
    TaskSeriesCollection result = new TaskSeriesCollection();
    TaskSeries s1 = new TaskSeries("S1");
    Task t1 = new Task("Task 1", new Date(10), new Date(20));
    t1.addSubtask(new Task("Task 1A", new Date(10), new Date(15)));
    t1.addSubtask(new Task("Task 1B", new Date(16), new Date(20)));
    t1.setPercentComplete(0.10);
    s1.add(t1);
    Task t2 = new Task("Task 2", new Date(30), new Date(40));
    t2.addSubtask(new Task("Task 2A", new Date(30), new Date(35)));
    t2.addSubtask(new Task("Task 2B", new Date(36), new Date(40)));
    t2.setPercentComplete(0.20);
    s1.add(t2);
    result.add(s1);
    TaskSeries s2 = new TaskSeries("S2");
    Task t3 = new Task("Task 3", new Date(50), new Date(60));
    t3.addSubtask(new Task("Task 3A", new Date(50), new Date(55)));
    t3.addSubtask(new Task("Task 3B", new Date(56), new Date(60)));
    t3.setPercentComplete(0.30);
    s2.add(t3);
    result.add(s2);
    return result;
}
 
Example 2
Source File: TaskSeriesCollectionTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a sample collection for testing purposes.
 * 
 * @return A sample collection.
 */
private TaskSeriesCollection createCollection2() {
    TaskSeriesCollection result = new TaskSeriesCollection();
    TaskSeries s1 = new TaskSeries("S1");
    Task t1 = new Task("Task 1", new Date(10), new Date(20));
    t1.addSubtask(new Task("Task 1A", new Date(10), new Date(15)));
    t1.addSubtask(new Task("Task 1B", new Date(16), new Date(20)));
    t1.setPercentComplete(0.10);
    s1.add(t1);
    Task t2 = new Task("Task 2", new Date(30), new Date(40));
    t2.addSubtask(new Task("Task 2A", new Date(30), new Date(35)));
    t2.addSubtask(new Task("Task 2B", new Date(36), new Date(40)));
    t2.setPercentComplete(0.20);
    s1.add(t2);
    result.add(s1);
    TaskSeries s2 = new TaskSeries("S2");
    Task t3 = new Task("Task 3", new Date(50), new Date(60));
    t3.addSubtask(new Task("Task 3A", new Date(50), new Date(55)));
    t3.addSubtask(new Task("Task 3B", new Date(56), new Date(60)));
    t3.setPercentComplete(0.30);
    s2.add(t3);
    result.add(s2);
    return result;
}
 
Example 3
Source File: TaskTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Confirm that the equals method can distinguish all the required fields.
 */
public void testEquals() {

    Task t1 = new Task("T", new Date(1), new Date(2));
    Task t2 = new Task("T", new Date(1), new Date(2));
    assertTrue(t1.equals(t2));
    assertTrue(t2.equals(t1));

    t1.setDescription("X");
    assertFalse(t1.equals(t2));
    t2.setDescription("X");
    assertTrue(t1.equals(t2));

    t1.setDuration(new SimpleTimePeriod(new Date(2), new Date(3)));
    assertFalse(t1.equals(t2));
    t2.setDuration(new SimpleTimePeriod(new Date(2), new Date(3)));
    assertTrue(t1.equals(t2));

    t1.setPercentComplete(0.5);
    assertFalse(t1.equals(t2));
    t2.setPercentComplete(0.5);
    assertTrue(t1.equals(t2));

    t1.addSubtask(new Task("T", new Date(22), new Date(33)));
    assertFalse(t1.equals(t2));
    t2.addSubtask(new Task("T", new Date(22), new Date(33)));
    assertTrue(t1.equals(t2));


}
 
Example 4
Source File: TaskTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Check the getSubTaskCount() method.
 */
public void testGetSubTaskCount() {
    Task t1 = new Task("T", new Date(100), new Date(200));
    assertEquals(0, t1.getSubtaskCount());
    t1.addSubtask(new Task("S1", new Date(100), new Date(110)));
    assertEquals(1, t1.getSubtaskCount());
    Task s2 = new Task("S2", new Date(111), new Date(120));
    t1.addSubtask(s2);
    assertEquals(2, t1.getSubtaskCount());
    t1.addSubtask(new Task("S3", new Date(121), new Date(130)));
    assertEquals(3, t1.getSubtaskCount());
    t1.removeSubtask(s2);
    assertEquals(2, t1.getSubtaskCount());
}
 
Example 5
Source File: TaskTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Confirm that the equals method can distinguish all the required fields.
 */
public void testEquals() {
    
    Task t1 = new Task("T", new Date(1), new Date(2));
    Task t2 = new Task("T", new Date(1), new Date(2));
    assertTrue(t1.equals(t2));
    assertTrue(t2.equals(t1));

    t1.setDescription("X");
    assertFalse(t1.equals(t2));
    t2.setDescription("X");
    assertTrue(t1.equals(t2));
    
    t1.setDuration(new SimpleTimePeriod(new Date(2), new Date(3)));
    assertFalse(t1.equals(t2));
    t2.setDuration(new SimpleTimePeriod(new Date(2), new Date(3)));
    assertTrue(t1.equals(t2));
    
    t1.setPercentComplete(0.5);
    assertFalse(t1.equals(t2));
    t2.setPercentComplete(0.5);
    assertTrue(t1.equals(t2));
    
    t1.addSubtask(new Task("T", new Date(22), new Date(33)));
    assertFalse(t1.equals(t2));
    t2.addSubtask(new Task("T", new Date(22), new Date(33)));
    assertTrue(t1.equals(t2));
    

}
 
Example 6
Source File: TaskTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Check the getSubTaskCount() method.
 */
public void testGetSubTaskCount() {
    Task t1 = new Task("T", new Date(100), new Date(200));
    assertEquals(0, t1.getSubtaskCount());
    t1.addSubtask(new Task("S1", new Date(100), new Date(110)));
    assertEquals(1, t1.getSubtaskCount());  
    Task s2 = new Task("S2", new Date(111), new Date(120));
    t1.addSubtask(s2);
    assertEquals(2, t1.getSubtaskCount());
    t1.addSubtask(new Task("S3", new Date(121), new Date(130)));
    assertEquals(3, t1.getSubtaskCount());
    t1.removeSubtask(s2);
    assertEquals(2, t1.getSubtaskCount());
}
 
Example 7
Source File: TaskSeriesCollectionTests.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Creates a sample collection for testing purposes.
 *
 * @return A sample collection.
 */
private TaskSeriesCollection createCollection3() {

    // define subtasks
    Task sub1 = new Task("Sub1", new Date(11), new Date(111));
    Task sub2 = new Task("Sub2", new Date(22), new Date(222));
    Task sub3 = new Task("Sub3", new Date(33), new Date(333));
    Task sub4 = new Task("Sub4", new Date(44), new Date(444));
    Task sub5 = new Task("Sub5", new Date(55), new Date(555));
    Task sub6 = new Task("Sub6", new Date(66), new Date(666));
    sub1.setPercentComplete(0.111);
    sub2.setPercentComplete(0.222);
    sub3.setPercentComplete(0.333);
    sub4.setPercentComplete(0.444);
    sub5.setPercentComplete(0.555);
    sub6.setPercentComplete(0.666);

    TaskSeries seriesA = new TaskSeries("Series A");
    Task taskA1 = new Task("Task 1", new SimpleTimePeriod(new Date(100),
            new Date(200)));
    taskA1.setPercentComplete(0.1);
    taskA1.addSubtask(sub1);
    Task taskA2 = new Task("Task 2", new SimpleTimePeriod(new Date(220),
            new Date(350)));
    taskA2.setPercentComplete(0.2);
    taskA2.addSubtask(sub2);
    taskA2.addSubtask(sub3);
    seriesA.add(taskA1);
    seriesA.add(taskA2);

    TaskSeries seriesB = new TaskSeries("Series B");
    // note that we don't define taskB1
    Task taskB2 = new Task("Task 2", new SimpleTimePeriod(new Date(2220),
            new Date(3350)));
    taskB2.setPercentComplete(0.3);
    taskB2.addSubtask(sub4);
    taskB2.addSubtask(sub5);
    taskB2.addSubtask(sub6);
    seriesB.add(taskB2);

    TaskSeriesCollection tsc = new TaskSeriesCollection();
    tsc.add(seriesA);
    tsc.add(seriesB);

    return tsc;
}
 
Example 8
Source File: TaskSeriesCollectionTests.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Creates a sample collection for testing purposes.
 * 
 * @return A sample collection.
 */
private TaskSeriesCollection createCollection3() {
    
    // define subtasks
    Task sub1 = new Task("Sub1", new Date(11), new Date(111));
    Task sub2 = new Task("Sub2", new Date(22), new Date(222));
    Task sub3 = new Task("Sub3", new Date(33), new Date(333));
    Task sub4 = new Task("Sub4", new Date(44), new Date(444));
    Task sub5 = new Task("Sub5", new Date(55), new Date(555));
    Task sub6 = new Task("Sub6", new Date(66), new Date(666));
    sub1.setPercentComplete(0.111);
    sub2.setPercentComplete(0.222);
    sub3.setPercentComplete(0.333);
    sub4.setPercentComplete(0.444);
    sub5.setPercentComplete(0.555);
    sub6.setPercentComplete(0.666);
    
    TaskSeries seriesA = new TaskSeries("Series A");
    Task taskA1 = new Task("Task 1", new SimpleTimePeriod(new Date(100), 
            new Date(200)));
    taskA1.setPercentComplete(0.1);
    taskA1.addSubtask(sub1);
    Task taskA2 = new Task("Task 2", new SimpleTimePeriod(new Date(220), 
            new Date(350)));
    taskA2.setPercentComplete(0.2);
    taskA2.addSubtask(sub2);
    taskA2.addSubtask(sub3);
    seriesA.add(taskA1);
    seriesA.add(taskA2);
     
    TaskSeries seriesB = new TaskSeries("Series B");
    // note that we don't define taskB1
    Task taskB2 = new Task("Task 2", new SimpleTimePeriod(new Date(2220), 
            new Date(3350)));
    taskB2.setPercentComplete(0.3);
    taskB2.addSubtask(sub4);
    taskB2.addSubtask(sub5);
    taskB2.addSubtask(sub6);
    seriesB.add(taskB2);

    TaskSeriesCollection tsc = new TaskSeriesCollection();
    tsc.add(seriesA);
    tsc.add(seriesB);        
    
    return tsc;
}