use of org.talend.dataprofiler.chart.preview.RowColumPair in project tdq-studio-se by Talend.
the class TOPChartService method createAnnotOnGantt.
// used by HideSeriesChartComposite
@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;
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();
// $NON-NLS-1$
String[] taskArray = taskDescription.split("\\|");
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 // $NON-NLS-1$
CategoryTextAnnotation(// $NON-NLS-1$
"#nulls = " + (rowList.get(indexOfRow))[multiDateColumn], 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();
// $NON-NLS-1$ //$NON-NLS-2$
return taskDescription + ", " + startDate + "---->" + endDate;
// return "this is a tooltip";
}
});
xyplot.getDomainAxis().setMaximumCategoryLabelWidthRatio(10.0f);
}
Aggregations