Search in sources :

Example 11 with CategoryURLGenerator

use of org.jfree.chart.urls.CategoryURLGenerator in project SIMVA-SoS by SESoS.

the class StackedBarChartTest method testSetSeriesURLGenerator.

/**
 * Check that setting a URL generator for a series does override the
 * default generator.
 */
@Test
public void testSetSeriesURLGenerator() {
    CategoryPlot plot = (CategoryPlot) this.chart.getPlot();
    CategoryItemRenderer renderer = plot.getRenderer();
    StandardCategoryURLGenerator url1 = new StandardCategoryURLGenerator();
    renderer.setSeriesItemURLGenerator(0, url1);
    CategoryURLGenerator url2 = renderer.getItemURLGenerator(0, 0);
    assertTrue(url2 == url1);
}
Also used : CategoryItemRenderer(org.jfree.chart.renderer.category.CategoryItemRenderer) CategoryURLGenerator(org.jfree.chart.urls.CategoryURLGenerator) StandardCategoryURLGenerator(org.jfree.chart.urls.StandardCategoryURLGenerator) StandardCategoryURLGenerator(org.jfree.chart.urls.StandardCategoryURLGenerator) CategoryPlot(org.jfree.chart.plot.CategoryPlot) Test(org.junit.Test)

Example 12 with CategoryURLGenerator

use of org.jfree.chart.urls.CategoryURLGenerator in project SIMVA-SoS by SESoS.

the class AbstractCategoryItemRenderer method addEntity.

/**
 * 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);
}
Also used : Shape(java.awt.Shape) CategoryToolTipGenerator(org.jfree.chart.labels.CategoryToolTipGenerator) CategoryURLGenerator(org.jfree.chart.urls.CategoryURLGenerator) CategoryItemEntity(org.jfree.chart.entity.CategoryItemEntity) Ellipse2D(java.awt.geom.Ellipse2D)

Aggregations

CategoryURLGenerator (org.jfree.chart.urls.CategoryURLGenerator)12 CategoryPlot (org.jfree.chart.plot.CategoryPlot)10 CategoryItemRenderer (org.jfree.chart.renderer.category.CategoryItemRenderer)10 StandardCategoryURLGenerator (org.jfree.chart.urls.StandardCategoryURLGenerator)10 Test (org.junit.Test)10 CategoryItemEntity (org.jfree.chart.entity.CategoryItemEntity)2 CategoryToolTipGenerator (org.jfree.chart.labels.CategoryToolTipGenerator)2 Shape (java.awt.Shape)1 Ellipse2D (java.awt.geom.Ellipse2D)1