List of usage examples for org.jfree.data.gantt Task Task
public Task(String description, Date start, Date end)
From source file:lu.lippmann.cdb.common.gui.ts.TimeSeriesChartUtil.java
public static ChartPanel buildChartPanelForNominalAttribute(final Instances ds, final Attribute attr, final int dateIdx) { final TaskSeriesCollection localTaskSeriesCollection = new TaskSeriesCollection(); final java.util.List<String> names = new ArrayList<String>(); final Set<String> present = WekaDataStatsUtil.getPresentValuesForNominalAttribute(ds, attr.index()); for (final String pr : present) { names.add(pr);//from w w w .j av a 2s . co m localTaskSeriesCollection.add(new TaskSeries(pr)); } final Calendar cal = Calendar.getInstance(); try { for (final double[] dd : WekaTimeSeriesUtil.split(ds, attr.index())) { cal.setTimeInMillis((long) dd[0]); final Date start = cal.getTime(); cal.setTimeInMillis((long) dd[1]); final Date end = cal.getTime(); final String sd = ds.instance((int) dd[2]).stringValue(attr); localTaskSeriesCollection.getSeries(sd).add(new Task("T", start, end)); } } catch (Exception e) { e.printStackTrace(); } final XYTaskDataset localXYTaskDataset = new XYTaskDataset(localTaskSeriesCollection); localXYTaskDataset.setTransposed(true); localXYTaskDataset.setSeriesWidth(0.6D); final DateAxis localDateAxis = new DateAxis(DATE_TIME_LABEL); final SymbolAxis localSymbolAxis = new SymbolAxis("", names.toArray(new String[names.size()])); localSymbolAxis.setGridBandsVisible(false); final XYBarRenderer localXYBarRenderer = new XYBarRenderer(); localXYBarRenderer.setUseYInterval(true); localXYBarRenderer.setShadowVisible(false); final XYPlot localXYPlot = new XYPlot(localXYTaskDataset, localDateAxis, localSymbolAxis, localXYBarRenderer); final CombinedDomainXYPlot localCombinedDomainXYPlot = new CombinedDomainXYPlot( new DateAxis(DATE_TIME_LABEL)); localCombinedDomainXYPlot.add(localXYPlot); final JFreeChart localJFreeChart = new JFreeChart("", localCombinedDomainXYPlot); localJFreeChart.setBackgroundPaint(Color.white); final ChartPanel cp = new ChartPanel(localJFreeChart, true); cp.setBorder(new TitledBorder(attr.name())); return cp; }
From source file:org.jfree.data.gantt.TaskTest.java
/** * Confirm that the equals method can distinguish all the required fields. *//* w ww .jav a2 s.c o m*/ @Test 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)); }
From source file:org.jfree.data.gantt.XYTaskDatasetTest.java
/** * Some checks for the equals() method./*from w ww . j a v a 2s.c om*/ */ @Test public void testEquals() { TaskSeries s1 = new TaskSeries("Series"); s1.add(new Task("Task 1", new Date(0L), new Date(1L))); s1.add(new Task("Task 2", new Date(10L), new Date(11L))); s1.add(new Task("Task 3", new Date(20L), new Date(21L))); TaskSeriesCollection u1 = new TaskSeriesCollection(); u1.add(s1); XYTaskDataset d1 = new XYTaskDataset(u1); TaskSeries s2 = new TaskSeries("Series"); s2.add(new Task("Task 1", new Date(0L), new Date(1L))); s2.add(new Task("Task 2", new Date(10L), new Date(11L))); s2.add(new Task("Task 3", new Date(20L), new Date(21L))); TaskSeriesCollection u2 = new TaskSeriesCollection(); u2.add(s2); XYTaskDataset d2 = new XYTaskDataset(u2); assertTrue(d1.equals(d2)); d1.setSeriesWidth(0.123); assertFalse(d1.equals(d2)); d2.setSeriesWidth(0.123); assertTrue(d1.equals(d2)); d1.setTransposed(true); assertFalse(d1.equals(d2)); d2.setTransposed(true); assertTrue(d1.equals(d2)); s1.add(new Task("Task 2", new Date(10L), new Date(11L))); assertFalse(d1.equals(d2)); s2.add(new Task("Task 2", new Date(10L), new Date(11L))); assertTrue(d1.equals(d2)); }
From source file:org.jfree.data.gantt.TaskSeriesTest.java
/** * Confirm that the equals method can distinguish all the required fields. *//* w w w.ja v a 2s . c om*/ @Test public void testEquals() { TaskSeries s1 = new TaskSeries("S"); s1.add(new Task("T1", new Date(1), new Date(2))); s1.add(new Task("T2", new Date(11), new Date(22))); TaskSeries s2 = new TaskSeries("S"); s2.add(new Task("T1", new Date(1), new Date(2))); s2.add(new Task("T2", new Date(11), new Date(22))); assertTrue(s1.equals(s2)); assertTrue(s2.equals(s1)); s1.add(new Task("T3", new Date(22), new Date(33))); assertFalse(s1.equals(s2)); s2.add(new Task("T3", new Date(22), new Date(33))); assertTrue(s1.equals(s2)); }
From source file:org.jfree.data.gantt.SlidingGanttCategoryDatasetTest.java
/** * Some checks for the equals() method.//from w w w .j ava2 s . c o m */ @Test public void testEquals() { TaskSeries s1 = new TaskSeries("Series"); s1.add(new Task("Task 1", new Date(0L), new Date(1L))); s1.add(new Task("Task 2", new Date(10L), new Date(11L))); s1.add(new Task("Task 3", new Date(20L), new Date(21L))); TaskSeriesCollection u1 = new TaskSeriesCollection(); u1.add(s1); SlidingGanttCategoryDataset d1 = new SlidingGanttCategoryDataset(u1, 0, 5); TaskSeries s2 = new TaskSeries("Series"); s2.add(new Task("Task 1", new Date(0L), new Date(1L))); s2.add(new Task("Task 2", new Date(10L), new Date(11L))); s2.add(new Task("Task 3", new Date(20L), new Date(21L))); TaskSeriesCollection u2 = new TaskSeriesCollection(); u2.add(s2); SlidingGanttCategoryDataset d2 = new SlidingGanttCategoryDataset(u2, 0, 5); assertTrue(d1.equals(d2)); d1.setFirstCategoryIndex(1); assertFalse(d1.equals(d2)); d2.setFirstCategoryIndex(1); assertTrue(d1.equals(d2)); d1.setMaximumCategoryCount(99); assertFalse(d1.equals(d2)); d2.setMaximumCategoryCount(99); assertTrue(d1.equals(d2)); s1.add(new Task("Task 2", new Date(10L), new Date(11L))); assertFalse(d1.equals(d2)); s2.add(new Task("Task 2", new Date(10L), new Date(11L))); assertTrue(d1.equals(d2)); }
From source file:org.jfree.data.gantt.TaskSeriesTest.java
/** * Confirm that cloning works./*from w w w.j a v a 2 s . c o m*/ */ @Test public void testCloning() throws CloneNotSupportedException { TaskSeries s1 = new TaskSeries("S"); s1.add(new Task("T1", new Date(1), new Date(2))); s1.add(new Task("T2", new Date(11), new Date(22))); TaskSeries s2 = (TaskSeries) s1.clone(); assertTrue(s1 != s2); assertTrue(s1.getClass() == s2.getClass()); assertTrue(s1.equals(s2)); // basic check for independence s1.add(new Task("T3", new Date(22), new Date(33))); assertFalse(s1.equals(s2)); s2.add(new Task("T3", new Date(22), new Date(33))); assertTrue(s1.equals(s2)); }
From source file:org.jfree.data.gantt.TaskSeriesCollectionTest.java
/** * Creates a sample collection for testing purposes. * * @return A sample collection./* w ww . j a v a2 s.com*/ */ private TaskSeriesCollection createCollection1() { TaskSeriesCollection result = new TaskSeriesCollection(); TaskSeries s1 = new TaskSeries("S1"); s1.add(new Task("Task 1", new Date(1), new Date(2))); s1.add(new Task("Task 2", new Date(3), new Date(4))); result.add(s1); TaskSeries s2 = new TaskSeries("S2"); s2.add(new Task("Task 3", new Date(5), new Date(6))); result.add(s2); return result; }
From source file:org.jfree.data.gantt.TaskTest.java
/** * Confirm that cloning works./*from w w w . j a v a2s . c o m*/ */ @Test public void testCloning() throws CloneNotSupportedException { Task t1 = new Task("T", new Date(1), new Date(2)); Task t2 = (Task) t1.clone(); assertTrue(t1 != t2); assertTrue(t1.getClass() == t2.getClass()); assertTrue(t1.equals(t2)); }
From source file:org.endeavour.mgmt.controller.servlet.CreateProjectPlan.java
public void doGet(HttpServletRequest aRequest, HttpServletResponse aResponse) throws IOException { try {// w w w . ja v a 2 s.c o m Document theDocument = new Document(PageSize.A4.rotate()); aResponse.setContentType("application/pdf"); PdfWriter.getInstance(theDocument, aResponse.getOutputStream()); theDocument.open(); String theProjectIdValue = aRequest.getParameter(ProjectPlanMaintenance.PROJECT_ID); StringTokenizer theId = new StringTokenizer(theProjectIdValue, ":"); Integer theProjectId = new Integer(theId.nextToken()); ProjectPlanMaintenance thePlanMaintenance = new ProjectPlanMaintenance(null); List<IPlanElement> thePlanElements = thePlanMaintenance.getProjectPlanReportingData(theProjectId); Task theTask = null; IPlanElement thePlanElement = null; TaskSeries theSeries = new TaskSeries(SCHEDULED); int theDataSetIndex = 0; Date theStartDate = null; Date theEndDate = null; String theDescription = null; for (int i = 0; i < thePlanElements.size(); i++) { thePlanElement = thePlanElements.get(i); theTask = new Task(thePlanElement.getElementType() + " : " + thePlanElement.getName(), thePlanElement.getStartDate(), thePlanElement.getEndDate()); theTask.setPercentComplete(thePlanElement.getProgress() * 0.01); theSeries.add(theTask); if (i == 0) { theStartDate = thePlanElement.getStartDate(); theEndDate = thePlanElement.getEndDate(); theDescription = thePlanElement.getElementType() + " : " + thePlanElement.getName(); } theDataSetIndex++; // Each page displays up to 25 tasks before creating a new one. if (theDataSetIndex == 25) { theDataSetIndex = 0; this.createReportPage(theDocument, theSeries, theStartDate, theEndDate, theDescription); theSeries = new TaskSeries(SCHEDULED); } } this.createReportPage(theDocument, theSeries, theStartDate, theEndDate, theDescription); theDocument.close(); } catch (Exception e) { e.printStackTrace(); } }
From source file:org.jfree.data.gantt.TaskTest.java
/** * Serialize an instance, restore it, and check for equality. *//*from w w w . jav a2s.c om*/ @Test public void testSerialization() { Task t1 = new Task("T", new Date(1), new Date(2)); Task t2 = (Task) TestUtilities.serialised(t1); assertEquals(t1, t2); }