org.jfree.chart.entity.XYItemEntity Java Examples

The following examples show how to use org.jfree.chart.entity.XYItemEntity. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TimePeriodChartHyperlinkProvider.java    From jasperreports with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public JRPrintHyperlink getEntityHyperlink(ChartEntity entity)
{
	JRPrintHyperlink printHyperlink = null;
	if (hasHyperlinks() && entity instanceof XYItemEntity)
	{
		XYItemEntity itemEntity = (XYItemEntity) entity;
		TimePeriodValuesCollection dataset = (TimePeriodValuesCollection) itemEntity.getDataset();
		TimePeriodValues series = dataset.getSeries(itemEntity.getSeriesIndex());
		Map<TimePeriod, JRPrintHyperlink> serieHyperlinks = itemHyperlinks.get(series.getKey());
		if (serieHyperlinks != null)
		{
			TimePeriod timePeriod = series.getTimePeriod(itemEntity.getItem());
			printHyperlink = serieHyperlinks.get(timePeriod);
		}
	}
	return printHyperlink;
}
 
Example #2
Source File: StandardXYItemRendererTest.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * A check to ensure that an item that falls outside the plot's data area
 * does NOT generate an item entity.
 */
@Test
public void testNoDisplayedItem() {
    XYSeriesCollection dataset = new XYSeriesCollection();
    XYSeries s1 = new XYSeries("S1");
    s1.add(10.0, 10.0);
    dataset.addSeries(s1);
    JFreeChart chart = ChartFactory.createXYLineChart("Title", "X", "Y",
            dataset, PlotOrientation.VERTICAL, false, true, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setRenderer(new StandardXYItemRenderer());
    NumberAxis xAxis = (NumberAxis) plot.getDomainAxis();
    xAxis.setRange(0.0, 5.0);
    NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();
    yAxis.setRange(0.0, 5.0);
    BufferedImage image = new BufferedImage(200 , 100,
            BufferedImage.TYPE_INT_RGB);
    Graphics2D g2 = image.createGraphics();
    ChartRenderingInfo info = new ChartRenderingInfo();
    chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, info);
    g2.dispose();
    EntityCollection ec = info.getEntityCollection();
    assertFalse(TestUtilities.containsInstanceOf(ec.getEntities(),
            XYItemEntity.class));
}
 
Example #3
Source File: StandardXYItemRendererTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * A check to ensure that an item that falls outside the plot's data area
 * does NOT generate an item entity.
 */
public void testNoDisplayedItem() {
    XYSeriesCollection dataset = new XYSeriesCollection();
    XYSeries s1 = new XYSeries("S1");
    s1.add(10.0, 10.0);
    dataset.addSeries(s1);
    JFreeChart chart = ChartFactory.createXYLineChart("Title", "X", "Y",
            dataset, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setRenderer(new StandardXYItemRenderer());
    NumberAxis xAxis = (NumberAxis) plot.getDomainAxis();
    xAxis.setRange(0.0, 5.0);
    NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();
    yAxis.setRange(0.0, 5.0);
    BufferedImage image = new BufferedImage(200 , 100,
            BufferedImage.TYPE_INT_RGB);
    Graphics2D g2 = image.createGraphics();
    ChartRenderingInfo info = new ChartRenderingInfo();
    chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, info);
    g2.dispose();
    EntityCollection ec = info.getEntityCollection();
    assertFalse(TestUtilities.containsInstanceOf(ec.getEntities(),
            XYItemEntity.class));
}
 
Example #4
Source File: StandardXYItemRendererTest.java    From ECG-Viewer with GNU General Public License v2.0 6 votes vote down vote up
/**
 * A check to ensure that an item that falls outside the plot's data area
 * does NOT generate an item entity.
 */
@Test
public void testNoDisplayedItem() {
    XYSeriesCollection dataset = new XYSeriesCollection();
    XYSeries s1 = new XYSeries("S1");
    s1.add(10.0, 10.0);
    dataset.addSeries(s1);
    JFreeChart chart = ChartFactory.createXYLineChart("Title", "X", "Y",
            dataset, PlotOrientation.VERTICAL, false, true, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setRenderer(new StandardXYItemRenderer());
    NumberAxis xAxis = (NumberAxis) plot.getDomainAxis();
    xAxis.setRange(0.0, 5.0);
    NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();
    yAxis.setRange(0.0, 5.0);
    BufferedImage image = new BufferedImage(200 , 100,
            BufferedImage.TYPE_INT_RGB);
    Graphics2D g2 = image.createGraphics();
    ChartRenderingInfo info = new ChartRenderingInfo();
    chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, info);
    g2.dispose();
    EntityCollection ec = info.getEntityCollection();
    assertFalse(TestUtilities.containsInstanceOf(ec.getEntities(),
            XYItemEntity.class));
}
 
Example #5
Source File: StandardXYItemRendererTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * A check to ensure that an item that falls outside the plot's data area
 * does NOT generate an item entity.
 */
public void testNoDisplayedItem() {
    XYSeriesCollection dataset = new XYSeriesCollection();
    XYSeries s1 = new XYSeries("S1");
    s1.add(10.0, 10.0);
    dataset.addSeries(s1);
    JFreeChart chart = ChartFactory.createXYLineChart("Title", "X", "Y", 
            dataset, PlotOrientation.VERTICAL, false, true, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setRenderer(new StandardXYItemRenderer());
    NumberAxis xAxis = (NumberAxis) plot.getDomainAxis();
    xAxis.setRange(0.0, 5.0);
    NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();
    yAxis.setRange(0.0, 5.0);
    BufferedImage image = new BufferedImage(200 , 100, 
            BufferedImage.TYPE_INT_RGB);
    Graphics2D g2 = image.createGraphics();
    ChartRenderingInfo info = new ChartRenderingInfo();
    chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, info);
    g2.dispose();
    EntityCollection ec = info.getEntityCollection();
    assertFalse(TestUtilities.containsInstanceOf(ec.getEntities(), 
            XYItemEntity.class));
}
 
Example #6
Source File: AbstractXYItemRenderer.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Adds an entity to the collection.
 *
 * @param entities  the entity collection being populated.
 * @param area  the entity area (if <code>null</code> a default will be
 *              used).
 * @param dataset  the dataset.
 * @param series  the series.
 * @param item  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>).
 */
protected void addEntity(EntityCollection entities, Shape area,
                         XYDataset dataset, int series, int item,
                         double entityX, double entityY) {
    if (!getItemCreateEntity(series, item)) {
        return;
    }
    if (area == null) {
        area = new Ellipse2D.Double(entityX - this.defaultEntityRadius,
                entityY - this.defaultEntityRadius,
                this.defaultEntityRadius * 2, this.defaultEntityRadius * 2);
    }
    String tip = null;
    XYToolTipGenerator generator = getToolTipGenerator(series, item);
    if (generator != null) {
        tip = generator.generateToolTip(dataset, series, item);
    }
    String url = null;
    XYURLGenerator urlster = getURLGenerator(series, item);
    if (urlster != null) {
        url = urlster.generateURL(dataset, series, item);
    }
    XYItemEntity entity = new XYItemEntity(area, dataset, series, item,
            tip, url);
    entities.add(entity);
}
 
Example #7
Source File: StandardXYItemRendererTest.java    From SIMVA-SoS with Apache License 2.0 6 votes vote down vote up
/**
 * A check to ensure that an item that falls outside the plot's data area
 * does NOT generate an item entity.
 */
@Test
public void testNoDisplayedItem() {
    XYSeriesCollection dataset = new XYSeriesCollection();
    XYSeries s1 = new XYSeries("S1");
    s1.add(10.0, 10.0);
    dataset.addSeries(s1);
    JFreeChart chart = ChartFactory.createXYLineChart("Title", "X", "Y",
            dataset, PlotOrientation.VERTICAL, false, true, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setRenderer(new StandardXYItemRenderer());
    NumberAxis xAxis = (NumberAxis) plot.getDomainAxis();
    xAxis.setRange(0.0, 5.0);
    NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();
    yAxis.setRange(0.0, 5.0);
    BufferedImage image = new BufferedImage(200 , 100,
            BufferedImage.TYPE_INT_RGB);
    Graphics2D g2 = image.createGraphics();
    ChartRenderingInfo info = new ChartRenderingInfo();
    chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, info);
    g2.dispose();
    EntityCollection ec = info.getEntityCollection();
    assertFalse(TestUtilities.containsInstanceOf(ec.getEntities(),
            XYItemEntity.class));
}
 
Example #8
Source File: AbstractXYItemRenderer.java    From opensim-gui with Apache License 2.0 6 votes vote down vote up
/**
 * Adds an entity to the collection.
 * 
 * @param entities  the entity collection being populated.
 * @param area  the entity area (if <code>null</code> a default will be 
 *              used).
 * @param dataset  the dataset.
 * @param series  the series.
 * @param item  the item.
 * @param entityX  the entity's center x-coordinate in user space.
 * @param entityY  the entity's center y-coordinate in user space.
 */
protected void addEntity(EntityCollection entities, Shape area, 
                         XYDataset dataset, int series, int item,
                         double entityX, double entityY) {
    if (!getItemCreateEntity(series, item)) {
        return;
    }
    if (area == null) {
        area = new Ellipse2D.Double(entityX - this.defaultEntityRadius, 
                entityY - this.defaultEntityRadius, 
                this.defaultEntityRadius * 2, this.defaultEntityRadius * 2);
    }
    String tip = null;
    XYToolTipGenerator generator = getToolTipGenerator(series, item);
    if (generator != null) {
        tip = generator.generateToolTip(dataset, series, item);
    }
    String url = null;
    if (getURLGenerator() != null) {
        url = getURLGenerator().generateURL(dataset, series, item);
    }
    XYItemEntity entity = new XYItemEntity(area, dataset, series, item, 
            tip, url);
    entities.add(entity);
}
 
Example #9
Source File: TimeSeriesChartHyperlinkProvider.java    From jasperreports with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public JRPrintHyperlink getEntityHyperlink(ChartEntity entity)
{
	JRPrintHyperlink printHyperlink = null;
	if (hasHyperlinks() && entity instanceof XYItemEntity)
	{
		XYItemEntity itemEntity = (XYItemEntity) entity;
		TimeSeriesCollection dataset = (TimeSeriesCollection) itemEntity.getDataset();
		TimeSeries series = dataset.getSeries(itemEntity.getSeriesIndex());
		Map<RegularTimePeriod, JRPrintHyperlink> serieHyperlinks = itemHyperlinks.get(series.getKey());
		if (serieHyperlinks != null)
		{
			RegularTimePeriod timePeriod = series.getTimePeriod(itemEntity.getItem());
			printHyperlink = serieHyperlinks.get(timePeriod);
		}
	}
	return printHyperlink;
}
 
Example #10
Source File: XYChartHyperlinkProvider.java    From jasperreports with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public JRPrintHyperlink getEntityHyperlink(ChartEntity entity)
{
	JRPrintHyperlink printHyperlink = null;
	if (hasHyperlinks() && entity instanceof XYItemEntity)
	{
		XYItemEntity itemEntity = (XYItemEntity) entity;
		XYDataset dataset = itemEntity.getDataset();
		Comparable<?> serie = dataset.getSeriesKey(itemEntity.getSeriesIndex());
		Map<Pair, JRPrintHyperlink> serieHyperlinks = itemHyperlinks.get(serie);
		if (serieHyperlinks != null)
		{
			Number x = dataset.getX(itemEntity.getSeriesIndex(), itemEntity.getItem());
			Number y = dataset.getY(itemEntity.getSeriesIndex(), itemEntity.getItem());
			Pair<Number,Number> xyKey = new Pair<Number,Number>(x, y);
			printHyperlink = serieHyperlinks.get(xyKey);
		}
	}
	return printHyperlink;
}
 
Example #11
Source File: StandardXYItemRendererTest.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
/**
 * A check to ensure that an item that falls outside the plot's data area
 * does NOT generate an item entity.
 */
@Test
public void testNoDisplayedItem() {
    XYSeriesCollection dataset = new XYSeriesCollection();
    XYSeries s1 = new XYSeries("S1");
    s1.add(10.0, 10.0);
    dataset.addSeries(s1);
    JFreeChart chart = ChartFactory.createXYLineChart("Title", "X", "Y",
            dataset, PlotOrientation.VERTICAL, false, true, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setRenderer(new StandardXYItemRenderer());
    NumberAxis xAxis = (NumberAxis) plot.getDomainAxis();
    xAxis.setRange(0.0, 5.0);
    NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();
    yAxis.setRange(0.0, 5.0);
    BufferedImage image = new BufferedImage(200 , 100,
            BufferedImage.TYPE_INT_RGB);
    Graphics2D g2 = image.createGraphics();
    ChartRenderingInfo info = new ChartRenderingInfo();
    chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, info);
    g2.dispose();
    EntityCollection ec = info.getEntityCollection();
    assertFalse(TestUtilities.containsInstanceOf(ec.getEntities(),
            XYItemEntity.class));
}
 
Example #12
Source File: StandardXYItemRendererTest.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * A check to ensure that an item that falls outside the plot's data area
 * does NOT generate an item entity.
 */
@Test
public void testNoDisplayedItem() {
    XYSeriesCollection dataset = new XYSeriesCollection();
    XYSeries s1 = new XYSeries("S1");
    s1.add(10.0, 10.0);
    dataset.addSeries(s1);
    JFreeChart chart = ChartFactory.createXYLineChart("Title", "X", "Y",
            dataset, PlotOrientation.VERTICAL, false, true, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setRenderer(new StandardXYItemRenderer());
    NumberAxis xAxis = (NumberAxis) plot.getDomainAxis();
    xAxis.setRange(0.0, 5.0);
    NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();
    yAxis.setRange(0.0, 5.0);
    BufferedImage image = new BufferedImage(200 , 100,
            BufferedImage.TYPE_INT_RGB);
    Graphics2D g2 = image.createGraphics();
    ChartRenderingInfo info = new ChartRenderingInfo();
    chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, info);
    g2.dispose();
    EntityCollection ec = info.getEntityCollection();
    assertFalse(TestUtilities.containsInstanceOf(ec.getEntities(),
            XYItemEntity.class));
}
 
Example #13
Source File: DefaultPolarItemRenderer.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Adds an entity to the collection.
 *
 * @param entities  the entity collection being populated.
 * @param area  the entity area (if <code>null</code> a default will be
 *              used).
 * @param dataset  the dataset.
 * @param series  the series.
 * @param item  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>).
 */
protected void addEntity(EntityCollection entities, Shape area,
                         XYDataset dataset, int series, int item,
                         double entityX, double entityY) {
    if (!getItemCreateEntity(series, item)) {
        return;
    }
    Shape hotspot = area;
    if (hotspot == null) {
        double r = getDefaultEntityRadius();
        double w = r * 2;
        if (getPlot().getOrientation() == PlotOrientation.VERTICAL) {
            hotspot = new Ellipse2D.Double(entityX - r, entityY - r, w, w);
        }
        else {
            hotspot = new Ellipse2D.Double(entityY - r, entityX - r, w, w);
        }
    }
    String tip = null;
    XYToolTipGenerator generator = getToolTipGenerator(series, item);
    if (generator != null) {
        tip = generator.generateToolTip(dataset, series, item);
    }
    String url = null;
    if (getURLGenerator() != null) {
        url = getURLGenerator().generateURL(dataset, series, item);
    }
    XYItemEntity entity = new XYItemEntity(hotspot, dataset, series, item,
            tip, url);
    entities.add(entity);
}
 
Example #14
Source File: JFreeChartReportDrawable.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void draw( final Graphics2D graphics2D, final Rectangle2D bounds ) {
  this.bounds = (Rectangle2D) bounds.clone();
  if ( chartRenderingInfo != null ) {
    this.chartRenderingInfo.clear();
  }
  final Graphics2D g2 = (Graphics2D) graphics2D.create();
  this.chart.draw( g2, bounds, chartRenderingInfo );
  g2.dispose();

  if ( chartRenderingInfo == null || debugRendering == false ) {
    return;
  }

  graphics2D.setColor( Color.RED );
  final Rectangle2D dataArea = getDataAreaOffset();
  final EntityCollection entityCollection = chartRenderingInfo.getEntityCollection();
  for ( int i = 0; i < entityCollection.getEntityCount(); i++ ) {
    final ChartEntity chartEntity = entityCollection.getEntity( i );
    if ( chartEntity instanceof XYItemEntity ||
      chartEntity instanceof CategoryItemEntity ||
      chartEntity instanceof PieSectionEntity ) {
      final Area a = new Area( chartEntity.getArea() );
      if ( buggyDrawArea ) {
        a.transform( AffineTransform.getTranslateInstance( dataArea.getX(), dataArea.getY() ) );
      }
      a.intersect( new Area( dataArea ) );
      graphics2D.draw( a );
    } else {
      graphics2D.draw( chartEntity.getArea() );
    }
  }
}
 
Example #15
Source File: AbstractXYItemRenderer.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Adds an entity to the collection.
 *
 * @param entities  the entity collection being populated.
 * @param area  the entity area (if <code>null</code> a default will be
 *              used).
 * @param dataset  the dataset.
 * @param series  the series.
 * @param item  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>).
 */
protected void addEntity(EntityCollection entities, Shape area,
                         XYDataset dataset, int series, int item,
                         double entityX, double entityY) {
    if (!getItemCreateEntity(series, item)) {
        return;
    }
    Shape hotspot = area;
    if (hotspot == null) {
        double r = getDefaultEntityRadius();
        double w = r * 2;
        if (getPlot().getOrientation() == PlotOrientation.VERTICAL) {
            hotspot = new Ellipse2D.Double(entityX - r, entityY - r, w, w);
        }
        else {
            hotspot = new Ellipse2D.Double(entityY - r, entityX - r, w, w);
        }
    }
    String tip = null;
    XYToolTipGenerator generator = getToolTipGenerator(series, item);
    if (generator != null) {
        tip = generator.generateToolTip(dataset, series, item);
    }
    String url = null;
    if (getURLGenerator() != null) {
        url = getURLGenerator().generateURL(dataset, series, item);
    }
    XYItemEntity entity = new XYItemEntity(hotspot, dataset, series, item,
            tip, url);
    entities.add(entity);
}
 
Example #16
Source File: XYItemEntityTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Confirm that the equals method can distinguish all the required fields.
 */
public void testEquals() {
    XYItemEntity e1 = new XYItemEntity(
        new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0),
        new TimeSeriesCollection(), 1, 9, "ToolTip", "URL"
    ); 
    XYItemEntity e2 = new XYItemEntity(
        new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0),
        new TimeSeriesCollection(), 1, 9, "ToolTip", "URL"
    ); 
    assertTrue(e1.equals(e2));  
    
    e1.setArea(new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0));
    assertFalse(e1.equals(e2));
    e2.setArea(new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0));
    assertTrue(e1.equals(e2));  

    e1.setToolTipText("New ToolTip");
    assertFalse(e1.equals(e2));
    e2.setToolTipText("New ToolTip");
    assertTrue(e1.equals(e2));  

    e1.setURLText("New URL");
    assertFalse(e1.equals(e2));
    e2.setURLText("New URL");
    assertTrue(e1.equals(e2));  
    
    e1.setSeriesIndex(88);
    assertFalse(e1.equals(e2));
    e2.setSeriesIndex(88);
    assertTrue(e1.equals(e2)); 
    
    e1.setItem(88);
    assertFalse(e1.equals(e2));
    e2.setItem(88);
    assertTrue(e1.equals(e2)); 
    
}
 
Example #17
Source File: AbstractXYItemRenderer.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Adds an entity to the collection.
 *
 * @param entities  the entity collection being populated.
 * @param area  the entity area (if <code>null</code> a default will be
 *              used).
 * @param dataset  the dataset.
 * @param series  the series.
 * @param item  the item.
 * @param selected  is the item selected?
 * @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.2.0
 */
protected void addEntity(EntityCollection entities, Shape area,
        XYDataset dataset, int series, int item, boolean selected,
        double entityX, double entityY) {
    
    if (!getItemCreateEntity(series, item, selected)) {
        return;
    }
    Shape hotspot = area;
    if (hotspot == null) {
        double r = getDefaultEntityRadius();
        double w = r * 2;
        if (getPlot().getOrientation() == PlotOrientation.VERTICAL) {
            hotspot = new Ellipse2D.Double(entityX - r, entityY - r, w, w);
        }
        else {
            hotspot = new Ellipse2D.Double(entityY - r, entityX - r, w, w);
        }
    }
    String tip = null;
    XYToolTipGenerator generator = getToolTipGenerator(series, item,
            selected);
    if (generator != null) {
        tip = generator.generateToolTip(dataset, series, item);
    }
    String url = null;
    XYURLGenerator urlster = getURLGenerator(series, item, selected);
    if (urlster != null) {
        url = urlster.generateURL(dataset, series, item);
    }
    XYItemEntity entity = new XYItemEntity(hotspot, dataset, series, item,
            tip, url);
    entities.add(entity);
}
 
Example #18
Source File: DefaultPolarItemRenderer.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Adds an entity to the collection.
 *
 * @param entities  the entity collection being populated.
 * @param area  the entity area (if <code>null</code> a default will be
 *              used).
 * @param dataset  the dataset.
 * @param series  the series.
 * @param item  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>).
 */
protected void addEntity(EntityCollection entities, Shape area,
                         XYDataset dataset, int series, int item,
                         double entityX, double entityY) {
    if (!getItemCreateEntity(series, item)) {
        return;
    }
    Shape hotspot = area;
    if (hotspot == null) {
        double r = getDefaultEntityRadius();
        double w = r * 2;
        if (getPlot().getOrientation() == PlotOrientation.VERTICAL) {
            hotspot = new Ellipse2D.Double(entityX - r, entityY - r, w, w);
        }
        else {
            hotspot = new Ellipse2D.Double(entityY - r, entityX - r, w, w);
        }
    }
    String tip = null;
    XYToolTipGenerator generator = getToolTipGenerator(series, item);
    if (generator != null) {
        tip = generator.generateToolTip(dataset, series, item);
    }
    String url = null;
    if (getURLGenerator() != null) {
        url = getURLGenerator().generateURL(dataset, series, item);
    }
    XYItemEntity entity = new XYItemEntity(hotspot, dataset, series, item,
            tip, url);
    entities.add(entity);
}
 
Example #19
Source File: AbstractXYItemRenderer.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Adds an entity to the collection.
 *
 * @param entities  the entity collection being populated.
 * @param area  the entity area (if <code>null</code> a default will be
 *              used).
 * @param dataset  the dataset.
 * @param series  the series.
 * @param item  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>).
 */
protected void addEntity(EntityCollection entities, Shape area,
                         XYDataset dataset, int series, int item,
                         double entityX, double entityY) {
    if (!getItemCreateEntity(series, item)) {
        return;
    }
    Shape hotspot = area;
    if (hotspot == null) {
        double r = getDefaultEntityRadius();
        double w = r * 2;
        if (getPlot().getOrientation() == PlotOrientation.VERTICAL) {
            hotspot = new Ellipse2D.Double(entityX - r, entityY - r, w, w);
        }
        else {
            hotspot = new Ellipse2D.Double(entityY - r, entityX - r, w, w);
        }
    }
    String tip = null;
    XYToolTipGenerator generator = getToolTipGenerator(series, item);
    if (generator != null) {
        tip = generator.generateToolTip(dataset, series, item);
    }
    String url = null;
    if (getURLGenerator() != null) {
        url = getURLGenerator().generateURL(dataset, series, item);
    }
    XYItemEntity entity = new XYItemEntity(hotspot, dataset, series, item,
            tip, url);
    entities.add(entity);
}
 
Example #20
Source File: DefaultPolarItemRenderer.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Adds an entity to the collection.
 *
 * @param entities  the entity collection being populated.
 * @param area  the entity area (if <code>null</code> a default will be
 *              used).
 * @param dataset  the dataset.
 * @param series  the series.
 * @param item  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>).
 */
protected void addEntity(EntityCollection entities, Shape area,
                         XYDataset dataset, int series, int item,
                         double entityX, double entityY) {
    if (!getItemCreateEntity(series, item)) {
        return;
    }
    Shape hotspot = area;
    if (hotspot == null) {
        double r = getDefaultEntityRadius();
        double w = r * 2;
        if (getPlot().getOrientation() == PlotOrientation.VERTICAL) {
            hotspot = new Ellipse2D.Double(entityX - r, entityY - r, w, w);
        }
        else {
            hotspot = new Ellipse2D.Double(entityY - r, entityX - r, w, w);
        }
    }
    String tip = null;
    XYToolTipGenerator generator = getToolTipGenerator(series, item);
    if (generator != null) {
        tip = generator.generateToolTip(dataset, series, item);
    }
    String url = null;
    if (getURLGenerator() != null) {
        url = getURLGenerator().generateURL(dataset, series, item);
    }
    XYItemEntity entity = new XYItemEntity(hotspot, dataset, series, item,
            tip, url);
    entities.add(entity);
}
 
Example #21
Source File: MultiAxisChartHyperlinkProvider.java    From jasperreports with GNU Lesser General Public License v3.0 5 votes vote down vote up
protected Dataset getEntityDataset(ChartEntity entity)
{
	Dataset dataset = null;
	if (entity instanceof CategoryItemEntity)
	{
		dataset = ((CategoryItemEntity) entity).getDataset();
	}
	else if (entity instanceof XYItemEntity)
	{
		dataset = ((XYItemEntity) entity).getDataset();
	}
	return dataset;
}
 
Example #22
Source File: AbstractXYItemRenderer.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Adds an entity to the collection.
 *
 * @param entities  the entity collection being populated.
 * @param area  the entity area (if <code>null</code> a default will be
 *              used).
 * @param dataset  the dataset.
 * @param series  the series.
 * @param item  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>).
 */
protected void addEntity(EntityCollection entities, Shape area,
                         XYDataset dataset, int series, int item,
                         double entityX, double entityY) {
    if (!getItemCreateEntity(series, item)) {
        return;
    }
    Shape hotspot = area;
    if (hotspot == null) {
        double r = getDefaultEntityRadius();
        double w = r * 2;
        if (getPlot().getOrientation() == PlotOrientation.VERTICAL) {
            hotspot = new Ellipse2D.Double(entityX - r, entityY - r, w, w);
        }
        else {
            hotspot = new Ellipse2D.Double(entityY - r, entityX - r, w, w);
        }
    }
    String tip = null;
    XYToolTipGenerator generator = getToolTipGenerator(series, item);
    if (generator != null) {
        tip = generator.generateToolTip(dataset, series, item);
    }
    String url = null;
    if (getURLGenerator() != null) {
        url = getURLGenerator().generateURL(dataset, series, item);
    }
    XYItemEntity entity = new XYItemEntity(hotspot, dataset, series, item,
            tip, url);
    entities.add(entity);
}
 
Example #23
Source File: DefaultPolarItemRenderer.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Adds an entity to the collection.
 *
 * @param entities  the entity collection being populated.
 * @param area  the entity area (if <code>null</code> a default will be
 *              used).
 * @param dataset  the dataset.
 * @param series  the series.
 * @param item  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>).
 */
protected void addEntity(EntityCollection entities, Shape area,
                         XYDataset dataset, int series, int item,
                         double entityX, double entityY) {
    if (!getItemCreateEntity(series, item)) {
        return;
    }
    Shape hotspot = area;
    if (hotspot == null) {
        double r = getDefaultEntityRadius();
        double w = r * 2;
        if (getPlot().getOrientation() == PlotOrientation.VERTICAL) {
            hotspot = new Ellipse2D.Double(entityX - r, entityY - r, w, w);
        }
        else {
            hotspot = new Ellipse2D.Double(entityY - r, entityX - r, w, w);
        }
    }
    String tip = null;
    XYToolTipGenerator generator = getToolTipGenerator(series, item);
    if (generator != null) {
        tip = generator.generateToolTip(dataset, series, item);
    }
    String url = null;
    if (getURLGenerator() != null) {
        url = getURLGenerator().generateURL(dataset, series, item);
    }
    XYItemEntity entity = new XYItemEntity(hotspot, dataset, series, item,
            tip, url);
    entities.add(entity);
}
 
Example #24
Source File: ChartGesture.java    From mzmine3 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * The gesture entity type
 * 
 * @param entity
 * @return
 */
public static Entity getGestureEntity(ChartEntity entity) {
  if (entity == null)
    return NONE;
  if (entity instanceof PlotEntity)
    return PLOT;
  if (entity instanceof AxisEntity) {
    AxisEntity e = (AxisEntity) entity;
    if (e.getAxis().getPlot() instanceof XYPlot) {
      XYPlot plot = ((XYPlot) e.getAxis().getPlot());
      for (int i = 0; i < plot.getDomainAxisCount(); i++)
        if (plot.getDomainAxis(i).equals(e.getAxis()))
          return DOMAIN_AXIS;
      for (int i = 0; i < plot.getRangeAxisCount(); i++)
        if (plot.getRangeAxis(i).equals(e.getAxis()))
          return RANGE_AXIS;
    }
    // else return basic axis
    return AXIS;
  }
  if (entity instanceof LegendItemEntity)
    return LEGEND_ITEM;
  if (entity instanceof XYItemEntity)
    return XY_ITEM;
  if (entity instanceof XYAnnotationEntity)
    return XY_ANNOTATION;
  if (entity instanceof TitleEntity) {
    if (((TitleEntity) entity).getTitle() instanceof TextTitle)
      return TEXT_TITLE;
    else
      return NON_TEXT_TITLE;
  }
  if (entity instanceof JFreeChartEntity)
    return JFREECHART;
  if (entity instanceof CategoryItemEntity)
    return CATEGORY_ITEM;
  return GENERAL;
}
 
Example #25
Source File: AbstractXYItemRenderer.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Adds an entity to the collection.
 *
 * @param entities  the entity collection being populated.
 * @param area  the entity area (if <code>null</code> a default will be
 *              used).
 * @param dataset  the dataset.
 * @param series  the series.
 * @param item  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>).
 */
protected void addEntity(EntityCollection entities, Shape area,
                         XYDataset dataset, int series, int item,
                         double entityX, double entityY) {
    if (!getItemCreateEntity(series, item)) {
        return;
    }
    Shape hotspot = area;
    if (hotspot == null) {
        double r = getDefaultEntityRadius();
        double w = r * 2;
        if (getPlot().getOrientation() == PlotOrientation.VERTICAL) {
            hotspot = new Ellipse2D.Double(entityX - r, entityY - r, w, w);
        }
        else {
            hotspot = new Ellipse2D.Double(entityY - r, entityX - r, w, w);
        }
    }
    String tip = null;
    XYToolTipGenerator generator = getToolTipGenerator(series, item);
    if (generator != null) {
        tip = generator.generateToolTip(dataset, series, item);
    }
    String url = null;
    if (getURLGenerator() != null) {
        url = getURLGenerator().generateURL(dataset, series, item);
    }
    XYItemEntity entity = new XYItemEntity(hotspot, dataset, series, item,
            tip, url);
    entities.add(entity);
}
 
Example #26
Source File: DefaultPolarItemRenderer.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Adds an entity to the collection.
 *
 * @param entities  the entity collection being populated.
 * @param area  the entity area (if <code>null</code> a default will be
 *              used).
 * @param dataset  the dataset.
 * @param series  the series.
 * @param item  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>).
 */
protected void addEntity(EntityCollection entities, Shape area,
                         XYDataset dataset, int series, int item,
                         double entityX, double entityY) {
    if (!getItemCreateEntity(series, item)) {
        return;
    }
    Shape hotspot = area;
    if (hotspot == null) {
        double r = getDefaultEntityRadius();
        double w = r * 2;
        if (getPlot().getOrientation() == PlotOrientation.VERTICAL) {
            hotspot = new Ellipse2D.Double(entityX - r, entityY - r, w, w);
        }
        else {
            hotspot = new Ellipse2D.Double(entityY - r, entityX - r, w, w);
        }
    }
    String tip = null;
    XYToolTipGenerator generator = getToolTipGenerator(series, item);
    if (generator != null) {
        tip = generator.generateToolTip(dataset, series, item);
    }
    String url = null;
    if (getURLGenerator() != null) {
        url = getURLGenerator().generateURL(dataset, series, item);
    }
    XYItemEntity entity = new XYItemEntity(hotspot, dataset, series, item,
            tip, url);
    entities.add(entity);
}
 
Example #27
Source File: XYItemEntityTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Confirm that the equals method can distinguish all the required fields.
 */
public void testEquals() {
    XYItemEntity e1 = new XYItemEntity(new Rectangle2D.Double(1.0, 2.0,
            3.0, 4.0), new TimeSeriesCollection(), 1, 9, "ToolTip", "URL");
    XYItemEntity e2 = new XYItemEntity(new Rectangle2D.Double(1.0, 2.0,
            3.0, 4.0), new TimeSeriesCollection(), 1, 9, "ToolTip", "URL");
    assertTrue(e1.equals(e2));

    e1.setArea(new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0));
    assertFalse(e1.equals(e2));
    e2.setArea(new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0));
    assertTrue(e1.equals(e2));

    e1.setToolTipText("New ToolTip");
    assertFalse(e1.equals(e2));
    e2.setToolTipText("New ToolTip");
    assertTrue(e1.equals(e2));

    e1.setURLText("New URL");
    assertFalse(e1.equals(e2));
    e2.setURLText("New URL");
    assertTrue(e1.equals(e2));

    e1.setSeriesIndex(88);
    assertFalse(e1.equals(e2));
    e2.setSeriesIndex(88);
    assertTrue(e1.equals(e2));

    e1.setItem(88);
    assertFalse(e1.equals(e2));
    e2.setItem(88);
    assertTrue(e1.equals(e2));

}
 
Example #28
Source File: HighLowChartHyperlinkProvider.java    From jasperreports with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public JRPrintHyperlink getEntityHyperlink(ChartEntity entity)
{
	JRPrintHyperlink printHyperlink = null;
	if (hasHyperlinks() && entity instanceof XYItemEntity)
	{
		XYItemEntity itemEntity = (XYItemEntity) entity;
		int item = itemEntity.getItem();
		if (item >= 0 && item < itemHyperlinks.size())
		{
			printHyperlink = itemHyperlinks.get(item);
		}
	}
	return printHyperlink;
}
 
Example #29
Source File: AbstractXYItemRenderer.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Adds an entity to the collection.
 *
 * @param entities  the entity collection being populated.
 * @param area  the entity area (if <code>null</code> a default will be
 *              used).
 * @param dataset  the dataset.
 * @param series  the series.
 * @param item  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>).
 */
protected void addEntity(EntityCollection entities, Shape area,
                         XYDataset dataset, int series, int item,
                         double entityX, double entityY) {
    if (!getItemCreateEntity(series, item)) {
        return;
    }
    Shape hotspot = area;
    if (hotspot == null) {
        double r = getDefaultEntityRadius();
        double w = r * 2;
        if (getPlot().getOrientation() == PlotOrientation.VERTICAL) {
            hotspot = new Ellipse2D.Double(entityX - r, entityY - r, w, w);
        }
        else {
            hotspot = new Ellipse2D.Double(entityY - r, entityX - r, w, w);
        }
    }
    String tip = null;
    XYToolTipGenerator generator = getToolTipGenerator(series, item);
    if (generator != null) {
        tip = generator.generateToolTip(dataset, series, item);
    }
    String url = null;
    if (getURLGenerator() != null) {
        url = getURLGenerator().generateURL(dataset, series, item);
    }
    XYItemEntity entity = new XYItemEntity(hotspot, dataset, series, item,
            tip, url);
    entities.add(entity);
}
 
Example #30
Source File: DefaultPolarItemRenderer.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Adds an entity to the collection.
 *
 * @param entities  the entity collection being populated.
 * @param area  the entity area (if <code>null</code> a default will be
 *              used).
 * @param dataset  the dataset.
 * @param series  the series.
 * @param item  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>).
 */
protected void addEntity(EntityCollection entities, Shape area,
                         XYDataset dataset, int series, int item,
                         double entityX, double entityY) {
    if (!getItemCreateEntity(series, item)) {
        return;
    }
    Shape hotspot = area;
    if (hotspot == null) {
        double r = getDefaultEntityRadius();
        double w = r * 2;
        if (getPlot().getOrientation() == PlotOrientation.VERTICAL) {
            hotspot = new Ellipse2D.Double(entityX - r, entityY - r, w, w);
        }
        else {
            hotspot = new Ellipse2D.Double(entityY - r, entityX - r, w, w);
        }
    }
    String tip = null;
    XYToolTipGenerator generator = getToolTipGenerator(series, item);
    if (generator != null) {
        tip = generator.generateToolTip(dataset, series, item);
    }
    String url = null;
    if (getURLGenerator() != null) {
        url = getURLGenerator().generateURL(dataset, series, item);
    }
    XYItemEntity entity = new XYItemEntity(hotspot, dataset, series, item,
            tip, url);
    entities.add(entity);
}