/** * Adds an entity with the specified hotspot. * * @param entities the entity collection. * @param dataset the dataset. * @param row the row index. * @param column the column index. * @param hotspot the hotspot. */ protected void addItemEntity(EntityCollection entities, CategoryDataset dataset, int row, int column, Shape hotspot) { String tip = null; CategoryToolTipGenerator tipster = getToolTipGenerator(row, column); if (tipster != null) { tip = tipster.generateToolTip(dataset, row, column); } String url = null; CategoryURLGenerator urlster = getItemURLGenerator(row, column); if (urlster != null) { url = urlster.generateURL(dataset, row, column); } CategoryItemEntity entity = new CategoryItemEntity(hotspot, tip, url, dataset, row, dataset.getColumnKey(column), column); entities.add(entity); }
/** * Returns the tool tip generator that should be used for the specified * item. This method looks up the generator using the "three-layer" * approach outlined in the general description of this interface. You * can override this method if you want to return a different generator per * item. * * @param row the row index (zero-based). * @param column the column index (zero-based). * * @return The generator (possibly <code>null</code>). */ @Override public CategoryToolTipGenerator getToolTipGenerator(int row, int column) { CategoryToolTipGenerator result; if (this.toolTipGenerator != null) { result = this.toolTipGenerator; } else { result = getSeriesToolTipGenerator(row); if (result == null) { result = this.baseToolTipGenerator; } } return result; }
/** * Adds an entity with the specified hotspot. * * @param entities the entity collection. * @param dataset the dataset. * @param row the row index. * @param column the column index. * @param hotspot the hotspot (<code>null</code> not permitted). */ protected void addItemEntity(EntityCollection entities, CategoryDataset dataset, int row, int column, Shape hotspot) { ParamChecks.nullNotPermitted(hotspot, "hotspot"); if (!getItemCreateEntity(row, column)) { return; } String tip = null; CategoryToolTipGenerator tipster = getToolTipGenerator(row, column); if (tipster != null) { tip = tipster.generateToolTip(dataset, row, column); } String url = null; CategoryURLGenerator urlster = getItemURLGenerator(row, column); if (urlster != null) { url = urlster.generateURL(dataset, row, column); } CategoryItemEntity entity = new CategoryItemEntity(hotspot, tip, url, dataset, dataset.getRowKey(row), dataset.getColumnKey(column)); entities.add(entity); }
/** * Adds an entity with the specified hotspot. * * @param entities the entity collection. * @param dataset the dataset. * @param row the row index. * @param column the column index. * @param hotspot the hotspot ({@code null} not permitted). */ protected void addItemEntity(EntityCollection entities, CategoryDataset dataset, int row, int column, Shape hotspot) { Args.nullNotPermitted(hotspot, "hotspot"); if (!getItemCreateEntity(row, column)) { return; } String tip = null; CategoryToolTipGenerator tipster = getToolTipGenerator(row, column); if (tipster != null) { tip = tipster.generateToolTip(dataset, row, column); } String url = null; CategoryURLGenerator urlster = getItemURLGenerator(row, column); if (urlster != null) { url = urlster.generateURL(dataset, row, column); } CategoryItemEntity entity = new CategoryItemEntity(hotspot, tip, url, dataset, dataset.getRowKey(row), dataset.getColumnKey(column)); entities.add(entity); }
/** * Adds an entity with the specified hotspot. * * @param entities the entity collection. * @param dataset the dataset. * @param row the row index. * @param column the column index. * @param hotspot the hotspot. */ protected void addItemEntity(EntityCollection entities, CategoryDataset dataset, int row, int column, Shape hotspot) { String tip = null; CategoryToolTipGenerator tipster = getToolTipGenerator(row, column); if (tipster != null) { tip = tipster.generateToolTip(dataset, row, column); } String url = null; CategoryURLGenerator urlster = getItemURLGenerator(row, column); if (urlster != null) { url = urlster.generateURL(dataset, row, column); } CategoryItemEntity entity = new CategoryItemEntity(hotspot, tip, url, dataset, dataset.getRowKey(row), dataset.getColumnKey(column)); entities.add(entity); }
/** * Adds an entity with the specified hotspot. * * @param entities the entity collection. * @param dataset the dataset. * @param row the row index. * @param column the column index. * @param hotspot the hotspot (<code>null</code> not permitted). */ protected void addItemEntity(EntityCollection entities, CategoryDataset dataset, int row, int column, Shape hotspot) { if (hotspot == null) { throw new IllegalArgumentException("Null 'hotspot' argument."); } if (!getItemCreateEntity(row, column)) { return; } String tip = null; CategoryToolTipGenerator tipster = getToolTipGenerator(row, column); if (tipster != null) { tip = tipster.generateToolTip(dataset, row, column); } String url = null; CategoryURLGenerator urlster = getItemURLGenerator(row, column); if (urlster != null) { url = urlster.generateURL(dataset, row, column); } CategoryItemEntity entity = new CategoryItemEntity(hotspot, tip, url, dataset, dataset.getRowKey(row), dataset.getColumnKey(column)); entities.add(entity); }
/** * Returns the tool tip generator that should be used for the specified item. This * method looks up the generator using the "three-layer" approach outlined in the * general description of this interface. You can override this method if you want * to return a different generator per item. * * @param row the row index (zero-based). * @param column the column index (zero-based). * * @return The generator (possibly <code>null</code>). */ public CategoryToolTipGenerator getToolTipGenerator(int row, int column) { CategoryToolTipGenerator result = null; if (this.toolTipGenerator != null) { result = this.toolTipGenerator; } else { result = getSeriesToolTipGenerator(row); if (result == null) { result = this.baseToolTipGenerator; } } return result; }
/** * Check that setting a tool tip generator for a series does override the * default generator. */ public void testSetSeriesToolTipGenerator() { CategoryPlot plot = (CategoryPlot) this.chart.getPlot(); CategoryItemRenderer renderer = plot.getRenderer(); StandardCategoryToolTipGenerator tt = new StandardCategoryToolTipGenerator(); renderer.setSeriesToolTipGenerator(0, tt); CategoryToolTipGenerator tt2 = renderer.getToolTipGenerator(0, 0); assertTrue(tt2 == tt); }
/** * Returns the tool tip generator that should be used for the specified * item. This method looks up the generator using the "three-layer" * approach outlined in the general description of this interface. You * can override this method if you want to return a different generator per * item. * * @param row the row index (zero-based). * @param column the column index (zero-based). * * @return The generator (possibly <code>null</code>). */ public CategoryToolTipGenerator getToolTipGenerator(int row, int column) { CategoryToolTipGenerator result = null; if (this.toolTipGenerator != null) { result = this.toolTipGenerator; } else { result = getSeriesToolTipGenerator(row); if (result == null) { result = this.baseToolTipGenerator; } } return result; }
/** * Check that setting a tool tip generator for a series does override the * default generator. */ @Test public void testSetSeriesToolTipGenerator() { CategoryPlot plot = (CategoryPlot) this.chart.getPlot(); CategoryItemRenderer renderer = plot.getRenderer(); StandardCategoryToolTipGenerator tt = new StandardCategoryToolTipGenerator(); renderer.setSeriesToolTipGenerator(0, tt); CategoryToolTipGenerator tt2 = renderer.getToolTipGenerator(0, 0); assertSame(tt2, tt); }
/** * Check that setting a tool tip generator for a series does override the * default generator. */ @Test public void testSetSeriesToolTipGenerator() { CategoryPlot plot = (CategoryPlot) this.chart.getPlot(); CategoryItemRenderer renderer = plot.getRenderer(); StandardCategoryToolTipGenerator tt = new StandardCategoryToolTipGenerator(); renderer.setSeriesToolTipGenerator(0, tt); CategoryToolTipGenerator tt2 = renderer.getToolTipGenerator(0, 0); assertTrue(tt2 == tt); }
/** * Creates a new renderer with no tool tip generator and no URL generator. * The defaults (no tool tip or URL generators) have been chosen to * minimise the processing required to generate a default chart. If you * require tool tips or URLs, then you can easily add the required * generators. */ protected AbstractCategoryItemRenderer() { this.itemLabelGenerator = null; this.itemLabelGeneratorMap = new HashMap<Integer, CategoryItemLabelGenerator>(); this.toolTipGenerator = null; this.toolTipGeneratorMap = new HashMap<Integer, CategoryToolTipGenerator>(); this.itemURLGenerator = null; this.itemURLGeneratorMap = new HashMap<Integer, CategoryURLGenerator>(); this.legendItemLabelGenerator = new StandardCategorySeriesLabelGenerator(); }
/** * Adds an entity to the collection. * * @param entities the entity collection being populated. * @param hotspot the entity area (if <code>null</code> a default will be * used). * @param dataset the dataset. * @param row the series. * @param column the item. * @param entityX the entity's center x-coordinate in user space (only * used if <code>area</code> is <code>null</code>). * @param entityY the entity's center y-coordinate in user space (only * used if <code>area</code> is <code>null</code>). * * @since 1.0.13 */ protected void addEntity(EntityCollection entities, Shape hotspot, CategoryDataset dataset, int row, int column, double entityX, double entityY) { if (!getItemCreateEntity(row, column)) { return; } Shape s = hotspot; if (hotspot == null) { double r = getDefaultEntityRadius(); double w = r * 2; if (getPlot().getOrientation() == PlotOrientation.VERTICAL) { s = new Ellipse2D.Double(entityX - r, entityY - r, w, w); } else { s = new Ellipse2D.Double(entityY - r, entityX - r, w, w); } } String tip = null; CategoryToolTipGenerator generator = getToolTipGenerator(row, column); if (generator != null) { tip = generator.generateToolTip(dataset, row, column); } String url = null; CategoryURLGenerator urlster = getItemURLGenerator(row, column); if (urlster != null) { url = urlster.generateURL(dataset, row, column); } CategoryItemEntity entity = new CategoryItemEntity(s, tip, url, dataset, dataset.getRowKey(row), dataset.getColumnKey(column)); entities.add(entity); }
/** * Creates a new renderer with no tool tip generator and no URL generator. * The defaults (no tool tip or URL generators) have been chosen to * minimise the processing required to generate a default chart. If you * require tool tips or URLs, then you can easily add the required * generators. */ protected AbstractCategoryItemRenderer() { this.itemLabelGeneratorMap = new HashMap<Integer, CategoryItemLabelGenerator>(); this.toolTipGeneratorMap = new HashMap<Integer, CategoryToolTipGenerator>(); this.itemURLGeneratorMap = new HashMap<Integer, CategoryURLGenerator>(); this.legendItemLabelGenerator = new StandardCategorySeriesLabelGenerator(); }