Java Code Examples for org.jfree.chart.ChartRenderingInfo#getEntityCollection()
The following examples show how to use
org.jfree.chart.ChartRenderingInfo#getEntityCollection() .
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: TooltipHandlerFX.java From buffer_bci with GNU General Public License v3.0 | 6 votes |
/** * Returns the tooltip text. * * @param canvas the canvas that is displaying the chart. * @param x the x-coordinate of the mouse pointer. * @param y the y-coordinate of the mouse pointer. * * @return String The tooltip text (possibly <code>null</code>). */ private String getTooltipText(ChartCanvas canvas, double x, double y) { ChartRenderingInfo info = canvas.getRenderingInfo(); if (info == null) { return null; } EntityCollection entities = info.getEntityCollection(); if (entities == null) { return null; } ChartEntity entity = entities.getEntity(x, y); if (entity == null) { return null; } return entity.getToolTipText(); }
Example 2
Source File: ChartLogicsFX.java From old-mzmine3 with GNU General Public License v2.0 | 6 votes |
/** * Find chartentities like JFreeChartEntity, AxisEntity, PlotEntity, TitleEntity, XY... * * @param chart * @return */ public static ChartEntity findChartEntity(ChartCanvas chart, double mx, double my) { // TODO check if insets were needed // coordinates to find chart entities int x = (int) (mx / chart.getScaleX()); int y = (int) (my / chart.getScaleY()); ChartRenderingInfo info = chart.getRenderingInfo(); ChartEntity entity = null; if (info != null) { EntityCollection entities = info.getEntityCollection(); if (entities != null) { entity = entities.getEntity(x, y); } } return entity; }
Example 3
Source File: ChartGestureMouseAdapterFX.java From old-mzmine3 with GNU General Public License v2.0 | 6 votes |
/** * Find chartentities like JFreeChartEntity, AxisEntity, PlotEntity, TitleEntity, XY... * * @param chartPanel * @param x * @param y * @return */ private ChartEntity findChartEntity(MouseEventWrapper e) { // TODO check if insets were needed // coordinates to find chart entities int x = (int) ((e.getX()) / chartViewer.getCanvas().getScaleX()); int y = (int) ((e.getY()) / chartViewer.getCanvas().getScaleY()); if (lastEntity != null && x == lastEntityX && y == lastEntityY) return lastEntity; else { ChartRenderingInfo info = chartViewer.getCanvas().getRenderingInfo(); ChartEntity entity = null; if (info != null) { EntityCollection entities = info.getEntityCollection(); if (entities != null) { entity = entities.getEntity(x, y); } } return entity; } }
Example 4
Source File: ChartLogics.java From old-mzmine3 with GNU General Public License v2.0 | 6 votes |
/** * Find chartentities like JFreeChartEntity, AxisEntity, PlotEntity, TitleEntity, XY... * * @param chart * @param mx mouse coordinates * @param my mouse coordinates * @return */ public static ChartEntity findChartEntity(ChartPanel chart, double mx, double my) { // TODO check if insets were needed // coordinates to find chart entities Insets insets = chart.getInsets(); int x = (int) ((mx - insets.left) / chart.getScaleX()); int y = (int) ((my - insets.top) / chart.getScaleY()); ChartRenderingInfo info = chart.getChartRenderingInfo(); ChartEntity entity = null; if (info != null) { EntityCollection entities = info.getEntityCollection(); if (entities != null) { entity = entities.getEntity(x, y); } } return entity; }
Example 5
Source File: TooltipHandlerFX.java From ccu-historian with GNU General Public License v3.0 | 6 votes |
/** * Returns the tooltip text. * * @param canvas the canvas that is displaying the chart. * @param x the x-coordinate of the mouse pointer. * @param y the y-coordinate of the mouse pointer. * * @return String The tooltip text (possibly <code>null</code>). */ private String getTooltipText(ChartCanvas canvas, double x, double y) { ChartRenderingInfo info = canvas.getRenderingInfo(); if (info == null) { return null; } EntityCollection entities = info.getEntityCollection(); if (entities == null) { return null; } ChartEntity entity = entities.getEntity(x, y); if (entity == null) { return null; } return entity.getToolTipText(); }
Example 6
Source File: StandardXYItemRendererTest.java From openstock with GNU General Public License v3.0 | 6 votes |
/** * 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 7
Source File: TooltipHandlerFX.java From buffer_bci with GNU General Public License v3.0 | 6 votes |
/** * Returns the tooltip text. * * @param canvas the canvas that is displaying the chart. * @param x the x-coordinate of the mouse pointer. * @param y the y-coordinate of the mouse pointer. * * @return String The tooltip text (possibly <code>null</code>). */ private String getTooltipText(ChartCanvas canvas, double x, double y) { ChartRenderingInfo info = canvas.getRenderingInfo(); if (info == null) { return null; } EntityCollection entities = info.getEntityCollection(); if (entities == null) { return null; } ChartEntity entity = entities.getEntity(x, y); if (entity == null) { return null; } return entity.getToolTipText(); }
Example 8
Source File: StandardXYItemRendererTest.java From ECG-Viewer with GNU General Public License v2.0 | 6 votes |
/** * 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 9
Source File: ChartGestureMouseAdapterFX.java From mzmine2 with GNU General Public License v2.0 | 6 votes |
/** * Find chartentities like JFreeChartEntity, AxisEntity, PlotEntity, TitleEntity, XY... * * @param chartPanel * @param x * @param y * @return */ private ChartEntity findChartEntity(MouseEventWrapper e) { // TODO check if insets were needed // coordinates to find chart entities int x = (int) ((e.getX()) / chartViewer.getCanvas().getScaleX()); int y = (int) ((e.getY()) / chartViewer.getCanvas().getScaleY()); if (lastEntity != null && x == lastEntityX && y == lastEntityY) return lastEntity; else { ChartRenderingInfo info = chartViewer.getCanvas().getRenderingInfo(); ChartEntity entity = null; if (info != null) { EntityCollection entities = info.getEntityCollection(); if (entities != null) { entity = entities.getEntity(x, y); } } return entity; } }
Example 10
Source File: ChartLogics.java From mzmine3 with GNU General Public License v2.0 | 6 votes |
/** * Find chartentities like JFreeChartEntity, AxisEntity, PlotEntity, TitleEntity, XY... * * @param chart * @param mx mouse coordinates * @param my mouse coordinates * @return */ public static ChartEntity findChartEntity(ChartPanel chart, double mx, double my) { // TODO check if insets were needed // coordinates to find chart entities Insets insets = chart.getInsets(); int x = (int) ((mx - insets.left) / chart.getScaleX()); int y = (int) ((my - insets.top) / chart.getScaleY()); ChartRenderingInfo info = chart.getChartRenderingInfo(); ChartEntity entity = null; if (info != null) { EntityCollection entities = info.getEntityCollection(); if (entities != null) { entity = entities.getEntity(x, y); } } return entity; }
Example 11
Source File: StandardXYItemRendererTest.java From buffer_bci with GNU General Public License v3.0 | 6 votes |
/** * 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: TooltipHandlerFX.java From openstock with GNU General Public License v3.0 | 6 votes |
/** * Returns the tooltip text. * * @param canvas the canvas that is displaying the chart. * @param x the x-coordinate of the mouse pointer. * @param y the y-coordinate of the mouse pointer. * * @return String The tooltip text (possibly <code>null</code>). */ private String getTooltipText(ChartCanvas canvas, double x, double y) { ChartRenderingInfo info = canvas.getRenderingInfo(); if (info == null) { return null; } EntityCollection entities = info.getEntityCollection(); if (entities == null) { return null; } ChartEntity entity = entities.getEntity(x, y); if (entity == null) { return null; } return entity.getToolTipText(); }
Example 13
Source File: RendererState.java From buffer_bci with GNU General Public License v3.0 | 5 votes |
/** * A convenience method that returns a reference to the entity * collection (may be <code>null</code>) being used to record * chart entities. * * @return The entity collection (possibly <code>null</code>). */ public EntityCollection getEntityCollection() { EntityCollection result = null; if (this.info != null) { ChartRenderingInfo owner = this.info.getOwner(); if (owner != null) { result = owner.getEntityCollection(); } } return result; }
Example 14
Source File: RendererState.java From buffer_bci with GNU General Public License v3.0 | 5 votes |
/** * A convenience method that returns a reference to the entity * collection (may be <code>null</code>) being used to record * chart entities. * * @return The entity collection (possibly <code>null</code>). */ public EntityCollection getEntityCollection() { EntityCollection result = null; if (this.info != null) { ChartRenderingInfo owner = this.info.getOwner(); if (owner != null) { result = owner.getEntityCollection(); } } return result; }
Example 15
Source File: ImageMapUtilities.java From ECG-Viewer with GNU General Public License v2.0 | 5 votes |
/** * Creates an image map element that complies with the XHTML 1.0 * specification. * * @param name the map name (<code>null</code> not permitted). * @param info the chart rendering info (<code>null</code> not permitted). * @param toolTipTagFragmentGenerator a generator for the HTML fragment * that will contain the tooltip text (<code>null</code> not permitted * if <code>info</code> contains tooltip information). * @param urlTagFragmentGenerator a generator for the HTML fragment that * will contain the URL reference (<code>null</code> not permitted if * <code>info</code> contains URLs). * * @return The map tag. */ public static String getImageMap(String name, ChartRenderingInfo info, ToolTipTagFragmentGenerator toolTipTagFragmentGenerator, URLTagFragmentGenerator urlTagFragmentGenerator) { StringBuilder sb = new StringBuilder(); sb.append("<map id=\"").append(htmlEscape(name)); sb.append("\" name=\"").append(htmlEscape(name)).append("\">"); sb.append(StringUtils.getLineSeparator()); EntityCollection entities = info.getEntityCollection(); if (entities != null) { int count = entities.getEntityCount(); for (int i = count - 1; i >= 0; i--) { ChartEntity entity = entities.getEntity(i); if (entity.getToolTipText() != null || entity.getURLText() != null) { String area = entity.getImageMapAreaTag( toolTipTagFragmentGenerator, urlTagFragmentGenerator); if (area.length() > 0) { sb.append(area); sb.append(StringUtils.getLineSeparator()); } } } } sb.append("</map>"); return sb.toString(); }
Example 16
Source File: RendererState.java From ccu-historian with GNU General Public License v3.0 | 5 votes |
/** * A convenience method that returns a reference to the entity * collection (may be <code>null</code>) being used to record * chart entities. * * @return The entity collection (possibly <code>null</code>). */ public EntityCollection getEntityCollection() { EntityCollection result = null; if (this.info != null) { ChartRenderingInfo owner = this.info.getOwner(); if (owner != null) { result = owner.getEntityCollection(); } } return result; }
Example 17
Source File: JGenProg2017_006_t.java From coming with MIT License | 5 votes |
/** * Draws the axis label. * * @param label the label text. * @param g2 the graphics device. * @param plotArea the plot area. * @param dataArea the area inside the axes. * @param edge the location of the axis. * @param state the axis state (<code>null</code> not permitted). * @param plotState the plot state (<code>null</code> permitted). * * @return Information about the axis. */ protected AxisState drawLabel(String label, Graphics2D g2, Rectangle2D plotArea, Rectangle2D dataArea, RectangleEdge edge, AxisState state, PlotRenderingInfo plotState) { // it is unlikely that 'state' will be null, but check anyway... if (state == null) { throw new IllegalArgumentException("Null 'state' argument."); } if ((label == null) || (label.equals(""))) { return state; } Font font = getLabelFont(); RectangleInsets insets = getLabelInsets(); g2.setFont(font); g2.setPaint(getLabelPaint()); FontMetrics fm = g2.getFontMetrics(); Rectangle2D labelBounds = TextUtilities.getTextBounds(label, g2, fm); Shape hotspot = null; if (plotState != null && hotspot != null) { ChartRenderingInfo owner = plotState.getOwner(); EntityCollection entities = owner.getEntityCollection(); if (entities != null) { entities.add(new AxisLabelEntity(this, hotspot, this.labelToolTip, this.labelURL)); } } return state; }
Example 18
Source File: ImageMapUtilities.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Creates an image map element that complies with the XHTML 1.0 * specification. * * @param name the map name (<code>null</code> not permitted). * @param info the chart rendering info (<code>null</code> not permitted). * @param toolTipTagFragmentGenerator a generator for the HTML fragment * that will contain the tooltip text (<code>null</code> not permitted * if <code>info</code> contains tooltip information). * @param urlTagFragmentGenerator a generator for the HTML fragment that * will contain the URL reference (<code>null</code> not permitted if * <code>info</code> contains URLs). * * @return The map tag. */ public static String getImageMap(String name, ChartRenderingInfo info, ToolTipTagFragmentGenerator toolTipTagFragmentGenerator, URLTagFragmentGenerator urlTagFragmentGenerator) { StringBuffer sb = new StringBuffer(); sb.append("<map id=\"" + htmlEscape(name) + "\" name=\"" + htmlEscape(name) + "\">"); sb.append(StringUtilities.getLineSeparator()); EntityCollection entities = info.getEntityCollection(); if (entities != null) { int count = entities.getEntityCount(); for (int i = count - 1; i >= 0; i--) { ChartEntity entity = entities.getEntity(i); if (entity.getToolTipText() != null || entity.getURLText() != null) { String area = entity.getImageMapAreaTag( toolTipTagFragmentGenerator, urlTagFragmentGenerator); if (area.length() > 0) { sb.append(area); sb.append(StringUtilities.getLineSeparator()); } } } } sb.append("</map>"); return sb.toString(); }
Example 19
Source File: ImageMapUtilities.java From buffer_bci with GNU General Public License v3.0 | 5 votes |
/** * Creates an image map element that complies with the XHTML 1.0 * specification. * * @param name the map name (<code>null</code> not permitted). * @param info the chart rendering info (<code>null</code> not permitted). * @param toolTipTagFragmentGenerator a generator for the HTML fragment * that will contain the tooltip text (<code>null</code> not permitted * if <code>info</code> contains tooltip information). * @param urlTagFragmentGenerator a generator for the HTML fragment that * will contain the URL reference (<code>null</code> not permitted if * <code>info</code> contains URLs). * * @return The map tag. */ public static String getImageMap(String name, ChartRenderingInfo info, ToolTipTagFragmentGenerator toolTipTagFragmentGenerator, URLTagFragmentGenerator urlTagFragmentGenerator) { StringBuilder sb = new StringBuilder(); sb.append("<map id=\"").append(htmlEscape(name)); sb.append("\" name=\"").append(htmlEscape(name)).append("\">"); sb.append(StringUtils.getLineSeparator()); EntityCollection entities = info.getEntityCollection(); if (entities != null) { int count = entities.getEntityCount(); for (int i = count - 1; i >= 0; i--) { ChartEntity entity = entities.getEntity(i); if (entity.getToolTipText() != null || entity.getURLText() != null) { String area = entity.getImageMapAreaTag( toolTipTagFragmentGenerator, urlTagFragmentGenerator); if (area.length() > 0) { sb.append(area); sb.append(StringUtils.getLineSeparator()); } } } } sb.append("</map>"); return sb.toString(); }
Example 20
Source File: RendererState.java From SIMVA-SoS with Apache License 2.0 | 5 votes |
/** * A convenience method that returns a reference to the entity * collection (may be <code>null</code>) being used to record * chart entities. * * @return The entity collection (possibly <code>null</code>). */ public EntityCollection getEntityCollection() { EntityCollection result = null; if (this.info != null) { ChartRenderingInfo owner = this.info.getOwner(); if (owner != null) { result = owner.getEntityCollection(); } } return result; }