Example usage for org.jfree.data.gantt TaskSeriesCollection getSeriesCount

List of usage examples for org.jfree.data.gantt TaskSeriesCollection getSeriesCount

Introduction

In this page you can find the example usage for org.jfree.data.gantt TaskSeriesCollection getSeriesCount.

Prototype

@Override
public int getSeriesCount() 

Source Link

Document

Returns the number of series in the collection.

Usage

From source file:org.jfree.data.gantt.TaskSeriesCollectionTest.java

/**
 * A test for the getSeriesCount() method.
 */// w w w.  j  av  a  2 s.c o  m
@Test
public void testGetSeriesCount() {
    TaskSeriesCollection c = createCollection1();
    assertEquals(2, c.getSeriesCount());
}

From source file:org.jfree.data.gantt.TaskSeriesCollectionTest.java

/**
 * Some basic checks for the remove() method.
 *///from  ww w.j  a va2s  .com
@Test
public void testRemove() {
    TaskSeriesCollection c = new TaskSeriesCollection();
    TaskSeries s1 = new TaskSeries("S1");
    c.add(s1);
    assertEquals("S1", c.getSeries(0).getKey());
    c.remove(0);
    assertEquals(0, c.getSeriesCount());
    c.add(s1);

    boolean pass = false;
    try {
        c.remove(-1);
    } catch (IllegalArgumentException e) {
        pass = true;
    }
    assertTrue(pass);

    pass = false;
    try {
        c.remove(1);
    } catch (IllegalArgumentException e) {
        pass = true;
    }
    assertTrue(pass);
}

From source file:org.talend.dataprofiler.chart.TOPChartService.java

@Override
public void createAnnotOnGantt(Object chart, List<Object[]> rowList, int multiDateColumn, int nominal) {
    Map<String, RowColumPair> hightlightSeriesMap = new HashMap<String, RowColumPair>();
    CategoryPlot xyplot = (CategoryPlot) ((JFreeChart) chart).getPlot();
    CategoryTextAnnotation an;//from   w w  w  .  ja  v  a  2  s.c  o m
    for (int seriesCount = 0; seriesCount < ((TaskSeriesCollection) xyplot.getDataset())
            .getSeriesCount(); seriesCount++) {
        int indexOfRow = 0;
        int columnCount = 0;
        for (int itemCount = 0; itemCount < ((TaskSeriesCollection) xyplot.getDataset()).getSeries(seriesCount)
                .getItemCount(); itemCount++, columnCount++) {
            Task task = ((TaskSeriesCollection) xyplot.getDataset()).getSeries(seriesCount).get(itemCount);
            String taskDescription = task.getDescription();
            String[] taskArray = taskDescription.split("\\|"); //$NON-NLS-1$
            boolean isSameTime = task.getDuration().getStart().getTime() == task.getDuration().getEnd()
                    .getTime();
            if (!isSameTime && (rowList.get(indexOfRow))[multiDateColumn - 3] != null
                    && (rowList.get(indexOfRow))[multiDateColumn - 2] != null
                    && !((rowList.get(indexOfRow))[multiDateColumn]).equals(new BigDecimal(0L))) {
                RowColumPair pair = new RowColumPair();
                pair.setRow(seriesCount);
                pair.setColumn(columnCount);

                hightlightSeriesMap.put(String.valueOf(seriesCount) + String.valueOf(columnCount), pair);

                an = new CategoryTextAnnotation("#nulls = " + (rowList.get(indexOfRow))[multiDateColumn], //$NON-NLS-1$
                        taskDescription, task.getDuration().getStart().getTime());
                an.setTextAnchor(TextAnchor.CENTER_LEFT);
                an.setCategoryAnchor(CategoryAnchor.MIDDLE);
                xyplot.addAnnotation(an);
            }
            if (taskArray.length == nominal) {
                indexOfRow++;

                if (rowList.size() != indexOfRow && ((rowList.get(indexOfRow))[multiDateColumn - 3] == null
                        || (rowList.get(indexOfRow))[multiDateColumn - 2] == null)) {
                    indexOfRow++;
                }
            }
        }
    }
    CustomHideSeriesGanttRender renderer = new CustomHideSeriesGanttRender(hightlightSeriesMap);
    xyplot.setRenderer(renderer);
    renderer.setBaseToolTipGenerator(new CategoryToolTipGenerator() {

        @Override
        public String generateToolTip(CategoryDataset dataset, int row, int column) {
            TaskSeriesCollection taskSeriesColl = (TaskSeriesCollection) dataset;
            List<Task> taskList = new ArrayList<Task>();
            for (int i = 0; i < taskSeriesColl.getSeriesCount(); i++) {
                for (int j = 0; j < taskSeriesColl.getSeries(i).getItemCount(); j++) {
                    taskList.add(taskSeriesColl.getSeries(i).get(j));
                }
            }
            Task task = taskList.get(column);
            // Task task = taskSeriesColl.getSeries(row).get(column);
            String taskDescription = task.getDescription();

            Date startDate = task.getDuration().getStart();
            Date endDate = task.getDuration().getEnd();
            return taskDescription + ",     " + startDate + "---->" + endDate; //$NON-NLS-1$ //$NON-NLS-2$
            // return "this is a tooltip";
        }
    });
    xyplot.getDomainAxis().setMaximumCategoryLabelWidthRatio(10.0f);

}