/** * Returns the data area for the chart (the area inside the axes) with the * current scaling applied (that is, the area as it appears on screen). * * @return The scaled data area. */ public Rectangle2D getScreenDataArea() { Rectangle2D dataArea = this.info.getPlotInfo().getDataArea(); Insets insets = getInsets(); double x = dataArea.getX() * this.scaleX + insets.left; double y = dataArea.getY() * this.scaleY + insets.top; double w = dataArea.getWidth() * this.scaleX; double h = dataArea.getHeight() * this.scaleY; return new Rectangle2D.Double(x, y, w, h); }
/** * Returns the data area for the chart (the area inside the axes) with the * current scaling applied (that is, the area as it appears on screen). * * @return The scaled data area. */ public Rectangle2D getScreenDataArea() { Rectangle2D dataArea = this.info.getPlotInfo().getDataArea(); Insets insets = getInsets(); double x = dataArea.getX() * this.scaleX + insets.left; double y = dataArea.getY() * this.scaleY + insets.top; double w = dataArea.getWidth() * this.scaleX; double h = dataArea.getHeight() * this.scaleY; return new Rectangle2D.Double(x, y, w, h); }
/** * Handles a 'click' on the plot by updating the anchor values. * * @param x x-coordinate, where the click occurred. * @param y y-coordinate, where the click occurred. * @param info object containing information about the plot dimensions. */ @Override public void handleClick(int x, int y, PlotRenderingInfo info) { Rectangle2D dataArea = info.getDataArea(); if (dataArea.contains(x, y)) { for (int i = 0; i < this.subplots.size(); i++) { XYPlot subplot = (XYPlot) this.subplots.get(i); PlotRenderingInfo subplotInfo = info.getSubplotInfo(i); subplot.handleClick(x, y, subplotInfo); } } }
/** * Handles a 'click' on the plot by updating the anchor values. * * @param x x-coordinate, where the click occured. * @param y y-coordinate, where the click occured. * @param info object containing information about the plot dimensions. */ public void handleClick(int x, int y, PlotRenderingInfo info) { Rectangle2D dataArea = info.getDataArea(); if (dataArea.contains(x, y)) { for (int i = 0; i < this.subplots.size(); i++) { XYPlot subplot = (XYPlot) this.subplots.get(i); PlotRenderingInfo subplotInfo = info.getSubplotInfo(i); subplot.handleClick(x, y, subplotInfo); } } }
/** * Handles a 'click' on the plot. * * @param x x-coordinate of the click. * @param y y-coordinate of the click. * @param info information about the plot's dimensions. * */ public void handleClick(int x, int y, PlotRenderingInfo info) { Rectangle2D dataArea = info.getDataArea(); if (dataArea.contains(x, y)) { for (int i = 0; i < this.subplots.size(); i++) { CategoryPlot subplot = (CategoryPlot) this.subplots.get(i); PlotRenderingInfo subplotInfo = info.getSubplotInfo(i); subplot.handleClick(x, y, subplotInfo); } } }
/** * Handles a 'click' on the plot by updating the anchor values... * * @param x x-coordinate, where the click occured. * @param y y-coordinate, where the click occured. * @param info object containing information about the plot dimensions. */ public void handleClick(int x, int y, PlotRenderingInfo info) { Rectangle2D dataArea = info.getDataArea(); if (dataArea.contains(x, y)) { for (int i = 0; i < this.subplots.size(); i++) { XYPlot subplot = (XYPlot) this.subplots.get(i); PlotRenderingInfo subplotInfo = info.getSubplotInfo(i); subplot.handleClick(x, y, subplotInfo); } } }
/** * Handles a 'click' on the plot. * * @param x x-coordinate of the click. * @param y y-coordinate of the click. * @param info information about the plot's dimensions. * */ @Override public void handleClick(int x, int y, PlotRenderingInfo info) { Rectangle2D dataArea = info.getDataArea(); if (dataArea.contains(x, y)) { for (int i = 0; i < this.subplots.size(); i++) { CategoryPlot subplot = (CategoryPlot) this.subplots.get(i); PlotRenderingInfo subplotInfo = info.getSubplotInfo(i); subplot.handleClick(x, y, subplotInfo); } } }
/** * Handles a 'click' on the plot by updating the anchor values... * * @param x x-coordinate, where the click occured. * @param y y-coordinate, where the click occured. * @param info object containing information about the plot dimensions. */ @Override public void handleClick(int x, int y, PlotRenderingInfo info) { Rectangle2D dataArea = info.getDataArea(); if (dataArea.contains(x, y)) { for (int i = 0; i < this.subplots.size(); i++) { XYPlot subplot = (XYPlot) this.subplots.get(i); PlotRenderingInfo subplotInfo = info.getSubplotInfo(i); subplot.handleClick(x, y, subplotInfo); } } }
/** * Handles a 'click' on the plot by updating the anchor value. * * @param x x-coordinate of the click. * @param y y-coordinate of the click. * @param info information about the plot's dimensions. * */ @Override public void handleClick(int x, int y, PlotRenderingInfo info) { Rectangle2D dataArea = info.getDataArea(); if (dataArea.contains(x, y)) { for (int i = 0; i < this.subplots.size(); i++) { CategoryPlot subplot = (CategoryPlot) this.subplots.get(i); PlotRenderingInfo subplotInfo = info.getSubplotInfo(i); subplot.handleClick(x, y, subplotInfo); } } }
/** * Handles a 'click' on the plot by updating the anchor value. * * @param x x-coordinate of the click. * @param y y-coordinate of the click. * @param info information about the plot's dimensions. * */ public void handleClick(int x, int y, PlotRenderingInfo info) { Rectangle2D dataArea = info.getDataArea(); if (dataArea.contains(x, y)) { for (int i = 0; i < this.subplots.size(); i++) { CategoryPlot subplot = (CategoryPlot) this.subplots.get(i); PlotRenderingInfo subplotInfo = info.getSubplotInfo(i); subplot.handleClick(x, y, subplotInfo); } } }
/** * Multiplies the range on the range axis/axes by the specified factor. * * @param factor the zoom factor. * @param state the plot state. * @param source the source point. * @param useAnchor a flag that controls whether or not the source point * is used for the zoom anchor. * * @since 1.0.7 */ @Override public void zoomRangeAxes(double factor, PlotRenderingInfo state, Point2D source, boolean useAnchor) { double anchorY = this.getRangeAxis().java2DToValue(source.getY(), state.getDataArea(), RectangleEdge.LEFT); this.rangeAxis.resizeRange(factor, anchorY); }
/** * Multiplies the range on the range axis/axes by the specified factor. * * @param factor the zoom factor. * @param state the plot state. * @param source the source point. * @param useAnchor a flag that controls whether or not the source point * is used for the zoom anchor. * * @since 1.0.7 */ public void zoomRangeAxes(double factor, PlotRenderingInfo state, Point2D source, boolean useAnchor) { double anchorY = this.getRangeAxis().java2DToValue(source.getY(), state.getDataArea(), RectangleEdge.LEFT); this.rangeAxis.resizeRange(factor, anchorY); }
/** * Multiplies the range on the range axis by the specified factor. * * @param factor the zoom factor. * @param info the plot rendering info. * @param source the source point (in Java2D space). * @param useAnchor use source point as zoom anchor? * * @see #zoomDomainAxes(double, PlotRenderingInfo, Point2D, boolean) * * @since 1.0.7 */ @Override public void zoomRangeAxes(double factor, PlotRenderingInfo info, Point2D source, boolean useAnchor) { if (useAnchor) { // get the source coordinate - this plot has always a VERTICAL // orientation double sourceY = source.getY(); double anchorY = this.rangeAxis.java2DToValue(sourceY, info.getDataArea(), RectangleEdge.LEFT); this.rangeAxis.resizeRange2(factor, anchorY); } else { this.rangeAxis.resizeRange(factor); } }
/** * Multiplies the range on the range axis by the specified factor. * * @param factor the zoom factor. * @param info the plot rendering info. * @param source the source point (in Java2D space). * @param useAnchor use source point as zoom anchor? * * @see #zoomDomainAxes(double, PlotRenderingInfo, Point2D, boolean) * * @since 1.0.7 */ public void zoomRangeAxes(double factor, PlotRenderingInfo info, Point2D source, boolean useAnchor) { if (useAnchor) { // get the source coordinate - this plot has always a VERTICAL // orientation double sourceX = source.getX(); double anchorX = this.axis.java2DToValue(sourceX, info.getDataArea(), RectangleEdge.BOTTOM); this.axis.resizeRange(factor, anchorX); } else { this.axis.resizeRange(factor); } }
/** * Multiplies the range on the domain axis by the specified factor. * * @param factor the zoom factor. * @param info the plot rendering info. * @param source the source point (in Java2D space). * @param useAnchor use source point as zoom anchor? * * @see #zoomRangeAxes(double, PlotRenderingInfo, Point2D, boolean) * * @since 1.0.7 */ public void zoomDomainAxes(double factor, PlotRenderingInfo info, Point2D source, boolean useAnchor) { if (useAnchor) { // get the source coordinate - this plot has always a VERTICAL // orientation double sourceX = source.getX(); double anchorX = this.domainAxis.java2DToValue(sourceX, info.getDataArea(), RectangleEdge.BOTTOM); this.domainAxis.resizeRange2(factor, anchorX); } else { this.domainAxis.resizeRange(factor); } }
@Override public RepresentationResponse producePresentation(DesignOptions options) throws Exception { ChartRenderingInfo renderingInfo = new ChartRenderingInfo(new StandardEntityCollection()); String chartUrl = createChart(options, renderingInfo); Rectangle2D plotArea = renderingInfo.getPlotInfo().getDataArea(); for (Axis axis : renderer.getAxisMapping().values()) { axis.setMaxY(plotArea.getMaxY()); axis.setMinY(plotArea.getMinY()); } ImageEntity[] entities = {}; if (!this.isOverview) { LOGGER.debug("Produced EES diagram " + chartUrl); entities = createImageEntities(renderingInfo.getEntityCollection()); } else { LOGGER.debug("Produced EES Overview diagram " + chartUrl); } Bounds chartArea = new Bounds(plotArea.getMinX(), plotArea.getMaxX(), plotArea.getMinY(), plotArea.getMaxY()); return new EESDataResponse(chartUrl, options, chartArea, entities, renderer.getAxisMapping()); }
/** * Handles a 'click' on the plot by updating the anchor value. * * @param x x-coordinate of the click (in Java2D space). * @param y y-coordinate of the click (in Java2D space). * @param info information about the plot's dimensions. * */ @Override public void handleClick(int x, int y, PlotRenderingInfo info) { Rectangle2D dataArea = info.getDataArea(); if (dataArea.contains(x, y)) { // set the anchor value for the range axis... double java2D = 0.0; if (this.orientation == PlotOrientation.HORIZONTAL) { java2D = x; } else if (this.orientation == PlotOrientation.VERTICAL) { java2D = y; } RectangleEdge edge = Plot.resolveRangeAxisLocation( getRangeAxisLocation(), this.orientation); double value = getRangeAxis().java2DToValue( java2D, info.getDataArea(), edge); setAnchorValue(value); setRangeCrosshairValue(value); } }
/** * Returns the index of the subplot that contains the specified * (x, y) point (the "source" point). The source point will usually * come from a mouse click on a {@link org.jfree.chart.ChartPanel}, * and this method is then used to determine the subplot that * contains the source point. * * @param source the source point (in Java2D space, {@code null} not * permitted). * * @return The subplot index (or -1 if no subplot contains {@code source}). */ public int getSubplotIndex(Point2D source) { Args.nullNotPermitted(source, "source"); int subplotCount = getSubplotCount(); for (int i = 0; i < subplotCount; i++) { PlotRenderingInfo info = getSubplotInfo(i); Rectangle2D area = info.getDataArea(); if (area.contains(source)) { return i; } } return -1; }
/** * Returns the data area (the area inside the axes) for the plot or subplot, * with the current scaling applied. * * @param x the x-coordinate (for subplot selection). * @param y the y-coordinate (for subplot selection). * * @return The scaled data area. */ public Rectangle2D getScreenDataArea(int x, int y) { PlotRenderingInfo plotInfo = this.info.getPlotInfo(); Rectangle2D result; if (plotInfo.getSubplotCount() == 0) { result = getScreenDataArea(); } else { // get the origin of the zoom selection in the Java2D space used for // drawing the chart (that is, before any scaling to fit the panel) Point2D selectOrigin = translateScreenToJava2D(new Point(x, y)); int subplotIndex = plotInfo.getSubplotIndex(selectOrigin); if (subplotIndex == -1) { return null; } result = scale(plotInfo.getSubplotInfo(subplotIndex).getDataArea()); } return result; }
protected String getTooltipAtPoint(Point point) { XYPlot plot = (XYPlot) getChart().getPlot(); PlotRenderingInfo info = getChartRenderingInfo().getPlotInfo(); double x0 = point.getX(); double x1 = x0 - 2 * getScaleX(); double x2 = x0 + 4 * getScaleX(); ValueAxis domainAxis = plot.getDomainAxis(); Rectangle2D screenArea = scale(info.getDataArea()); double tx1 = domainAxis.java2DToValue(x1, screenArea, BOTTOM); double tx2 = domainAxis.java2DToValue(x2, screenArea, BOTTOM); for (int datasetIndex = 0; datasetIndex < plot.getDatasetCount(); datasetIndex++) { XYDataset dataset = plot.getDataset(datasetIndex); for (int seriesIndex = 0; seriesIndex < dataset.getSeriesCount(); seriesIndex++) { int itemCount = dataset.getItemCount(seriesIndex); for (int itemIndex = 0; itemIndex < itemCount; itemIndex++) { double xValue = dataset.getXValue(seriesIndex, itemIndex); if (tx1 < xValue && xValue < tx2) return toolTipGenerator.generateToolTip(dataset, seriesIndex, itemIndex); } } } return null; } }