@Test public void testDrawSeriesWithZeroItems() { DefaultXYDataset dataset = new DefaultXYDataset(); dataset.addSeries("Series 1", new double[][] {{1.0, 2.0}, {3.0, 4.0}}); dataset.addSeries("Series 2", new double[][] {{}, {}}); JFreeChart chart = ChartFactory.createXYLineChart("Title", "X", "Y", dataset); BufferedImage image = new BufferedImage(200 , 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null); g2.dispose(); }
@Override public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, PlotState parentState, PlotRenderingInfo info) { boolean b1 = (area.getWidth() <= MINIMUM_WIDTH_TO_DRAW); boolean b2 = (area.getHeight() <= MINIMUM_HEIGHT_TO_DRAW); if (b1 || b2) { return; } if (info != null) { info.setPlotArea(area); } RectangleInsets insets = getInsets(); insets.trim(area); AxisSpace space = calculateAxisSpace(g2, area); Rectangle2D dataArea = space.shrink(area, null); this.axisOffset.trim(dataArea); dataArea = integerise(dataArea); if (dataArea.isEmpty()) { return; } createAndAddEntity((Rectangle2D) dataArea.clone(), info, null, null); if (info != null) { info.setDataArea(dataArea); } drawBackground(g2, dataArea); Map<Axis, AxisState> axisStateMap = drawAxes(g2, area, dataArea, info); PlotOrientation orient = getOrientation(); if (anchor != null && !dataArea.contains(anchor)) { anchor = null; } CrosshairState crosshairState = new CrosshairState(); crosshairState.setCrosshairDistance(Double.POSITIVE_INFINITY); crosshairState.setAnchor(anchor); crosshairState.setAnchorX(Double.NaN); crosshairState.setAnchorY(Double.NaN); if (anchor != null) { ValueAxis domainAxis = getDomainAxis(); if (domainAxis != null) { double x; if (orient == PlotOrientation.VERTICAL) { x = domainAxis.java2DToValue(anchor.getX(), dataArea, getDomainAxisEdge()); } else { x = domainAxis.java2DToValue(anchor.getY(), dataArea, getDomainAxisEdge()); } crosshairState.setAnchorX(x); } ValueAxis rangeAxis = getRangeAxis(); if (rangeAxis != null) { double y; if (orient == PlotOrientation.VERTICAL) { y = rangeAxis.java2DToValue(anchor.getY(), dataArea, getRangeAxisEdge()); } else { y = rangeAxis.java2DToValue(anchor.getX(), dataArea, getRangeAxisEdge()); } crosshairState.setAnchorY(y); } } crosshairState.setCrosshairX(getDomainCrosshairValue()); crosshairState.setCrosshairY(getRangeCrosshairValue()); Shape originalClip = g2.getClip(); Composite originalComposite = g2.getComposite(); g2.clip(dataArea); g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, getForegroundAlpha())); AxisState domainAxisState = axisStateMap.get( getDomainAxis()); if (domainAxisState == null) { if (parentState != null) { domainAxisState = parentState.getSharedAxisStates() .get(getDomainAxis()); } } AxisState rangeAxisState = axisStateMap.get(getRangeAxis()); if (rangeAxisState == null) { if (parentState != null) { rangeAxisState = parentState.getSharedAxisStates() .get(getRangeAxis()); } } if (domainAxisState != null) { drawDomainTickBands(g2, dataArea, domainAxisState.getTicks()); } if (rangeAxisState != null) { drawRangeTickBands(g2, dataArea, rangeAxisState.getTicks()); } if (domainAxisState != null) { drawDomainGridlines(g2, dataArea, domainAxisState.getTicks()); drawZeroDomainBaseline(g2, dataArea); } if (rangeAxisState != null) { drawRangeGridlines(g2, dataArea, rangeAxisState.getTicks()); drawZeroRangeBaseline(g2, dataArea); } Graphics2D savedG2 = g2; BufferedImage dataImage = null; if (this.shadowGenerator != null) { dataImage = new BufferedImage((int) dataArea.getWidth(), (int)dataArea.getHeight(), BufferedImage.TYPE_INT_ARGB); g2 = dataImage.createGraphics(); g2.translate(-dataArea.getX(), -dataArea.getY()); g2.setRenderingHints(savedG2.getRenderingHints()); } for (int i = 0; i < this.renderers.size(); i++) { drawDomainMarkers(g2, dataArea, i, Layer.BACKGROUND); } for (int i = 0; i < this.renderers.size(); i++) { drawRangeMarkers(g2, dataArea, i, Layer.BACKGROUND); } boolean foundData = false; DatasetRenderingOrder order = getDatasetRenderingOrder(); if (order == DatasetRenderingOrder.FORWARD) { int rendererCount = this.renderers.size(); for (int i = 0; i < rendererCount; i++) { XYItemRenderer r = getRenderer(i); if (r != null) { ValueAxis domainAxis = getDomainAxisForDataset(i); ValueAxis rangeAxis = getRangeAxisForDataset(i); r.drawAnnotations(g2, dataArea, domainAxis, rangeAxis, Layer.BACKGROUND, info); } } for (int i = 0; i < getDatasetCount(); i++) { foundData = render(g2, dataArea, i, info, crosshairState) || foundData; } for (int i = 0; i < rendererCount; i++) { XYItemRenderer r = getRenderer(i); if (r != null) { ValueAxis domainAxis = getDomainAxisForDataset(i); ValueAxis rangeAxis = getRangeAxisForDataset(i); r.drawAnnotations(g2, dataArea, domainAxis, rangeAxis, Layer.FOREGROUND, info); } } } else if (order == DatasetRenderingOrder.REVERSE) { int rendererCount = this.renderers.size(); for (int i = rendererCount - 1; i >= 0; i--) { XYItemRenderer r = getRenderer(i); if (i >= getDatasetCount()) { continue; } if (r != null) { ValueAxis domainAxis = getDomainAxisForDataset(i); ValueAxis rangeAxis = getRangeAxisForDataset(i); r.drawAnnotations(g2, dataArea, domainAxis, rangeAxis, Layer.BACKGROUND, info); } } for (int i = getDatasetCount() - 1; i >= 0; i--) { foundData = render(g2, dataArea, i, info, crosshairState) || foundData; } for (int i = rendererCount - 1; i >= 0; i--) { XYItemRenderer r = getRenderer(i); if (i >= getDatasetCount()) { continue; } if (r != null) { ValueAxis domainAxis = getDomainAxisForDataset(i); ValueAxis rangeAxis = getRangeAxisForDataset(i); r.drawAnnotations(g2, dataArea, domainAxis, rangeAxis, Layer.FOREGROUND, info); } } } int datasetIndex = crosshairState.getDatasetIndex(); ValueAxis xAxis = this.getDomainAxisForDataset(datasetIndex); RectangleEdge xAxisEdge = getDomainAxisEdge(getDomainAxisIndex(xAxis)); if (!this.domainCrosshairLockedOnData && anchor != null) { double xx; if (orient == PlotOrientation.VERTICAL) { xx = xAxis.java2DToValue(anchor.getX(), dataArea, xAxisEdge); } else { xx = xAxis.java2DToValue(anchor.getY(), dataArea, xAxisEdge); } crosshairState.setCrosshairX(xx); } setDomainCrosshairValue(crosshairState.getCrosshairX(), false); if (isDomainCrosshairVisible()) { double x = getDomainCrosshairValue(); Paint paint = getDomainCrosshairPaint(); Stroke stroke = getDomainCrosshairStroke(); drawDomainCrosshair(g2, dataArea, orient, x, xAxis, stroke, paint); } ValueAxis yAxis = getRangeAxisForDataset(datasetIndex); RectangleEdge yAxisEdge = getRangeAxisEdge(getRangeAxisIndex(yAxis)); if (!this.rangeCrosshairLockedOnData && anchor != null) { double yy; if (orient == PlotOrientation.VERTICAL) { yy = yAxis.java2DToValue(anchor.getY(), dataArea, yAxisEdge); } else { yy = yAxis.java2DToValue(anchor.getX(), dataArea, yAxisEdge); } crosshairState.setCrosshairY(yy); } setRangeCrosshairValue(crosshairState.getCrosshairY(), false); if (isRangeCrosshairVisible()) { double y = getRangeCrosshairValue(); Paint paint = getRangeCrosshairPaint(); Stroke stroke = getRangeCrosshairStroke(); drawRangeCrosshair(g2, dataArea, orient, y, yAxis, stroke, paint); } if (!foundData) { drawNoDataMessage(g2, dataArea); } for (int i = 0; i < this.renderers.size(); i++) { drawDomainMarkers(g2, dataArea, i, Layer.FOREGROUND); } for (int i = 0; i < this.renderers.size(); i++) { drawRangeMarkers(g2, dataArea, i, Layer.FOREGROUND); } drawAnnotations(g2, dataArea, info); if (this.shadowGenerator != null) { BufferedImage shadowImage = this.shadowGenerator.createDropShadow(dataImage); g2 = savedG2; g2.drawImage(shadowImage, (int) dataArea.getX() + this.shadowGenerator.calculateOffsetX(), (int) dataArea.getY() + this.shadowGenerator.calculateOffsetY(), null); g2.drawImage(dataImage, (int) dataArea.getX(), (int) dataArea.getY(), null); } g2.setClip(originalClip); g2.setComposite(originalComposite); drawOutline(g2, dataArea); }
XYPlot extends Plot implements ValueAxisPlot, Pannable, Zoomable,
        RendererChangeListener, Cloneable, PublicCloneable, Serializable { @Override public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, PlotState parentState, PlotRenderingInfo info) { boolean b1 = (area.getWidth() <= MINIMUM_WIDTH_TO_DRAW); boolean b2 = (area.getHeight() <= MINIMUM_HEIGHT_TO_DRAW); if (b1 || b2) { return; } if (info != null) { info.setPlotArea(area); } RectangleInsets insets = getInsets(); insets.trim(area); AxisSpace space = calculateAxisSpace(g2, area); Rectangle2D dataArea = space.shrink(area, null); this.axisOffset.trim(dataArea); dataArea = integerise(dataArea); if (dataArea.isEmpty()) { return; } createAndAddEntity((Rectangle2D) dataArea.clone(), info, null, null); if (info != null) { info.setDataArea(dataArea); } drawBackground(g2, dataArea); Map<Axis, AxisState> axisStateMap = drawAxes(g2, area, dataArea, info); PlotOrientation orient = getOrientation(); if (anchor != null && !dataArea.contains(anchor)) { anchor = null; } CrosshairState crosshairState = new CrosshairState(); crosshairState.setCrosshairDistance(Double.POSITIVE_INFINITY); crosshairState.setAnchor(anchor); crosshairState.setAnchorX(Double.NaN); crosshairState.setAnchorY(Double.NaN); if (anchor != null) { ValueAxis domainAxis = getDomainAxis(); if (domainAxis != null) { double x; if (orient == PlotOrientation.VERTICAL) { x = domainAxis.java2DToValue(anchor.getX(), dataArea, getDomainAxisEdge()); } else { x = domainAxis.java2DToValue(anchor.getY(), dataArea, getDomainAxisEdge()); } crosshairState.setAnchorX(x); } ValueAxis rangeAxis = getRangeAxis(); if (rangeAxis != null) { double y; if (orient == PlotOrientation.VERTICAL) { y = rangeAxis.java2DToValue(anchor.getY(), dataArea, getRangeAxisEdge()); } else { y = rangeAxis.java2DToValue(anchor.getX(), dataArea, getRangeAxisEdge()); } crosshairState.setAnchorY(y); } } crosshairState.setCrosshairX(getDomainCrosshairValue()); crosshairState.setCrosshairY(getRangeCrosshairValue()); Shape originalClip = g2.getClip(); Composite originalComposite = g2.getComposite(); g2.clip(dataArea); g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, getForegroundAlpha())); AxisState domainAxisState = axisStateMap.get( getDomainAxis()); if (domainAxisState == null) { if (parentState != null) { domainAxisState = parentState.getSharedAxisStates() .get(getDomainAxis()); } } AxisState rangeAxisState = axisStateMap.get(getRangeAxis()); if (rangeAxisState == null) { if (parentState != null) { rangeAxisState = parentState.getSharedAxisStates() .get(getRangeAxis()); } } if (domainAxisState != null) { drawDomainTickBands(g2, dataArea, domainAxisState.getTicks()); } if (rangeAxisState != null) { drawRangeTickBands(g2, dataArea, rangeAxisState.getTicks()); } if (domainAxisState != null) { drawDomainGridlines(g2, dataArea, domainAxisState.getTicks()); drawZeroDomainBaseline(g2, dataArea); } if (rangeAxisState != null) { drawRangeGridlines(g2, dataArea, rangeAxisState.getTicks()); drawZeroRangeBaseline(g2, dataArea); } Graphics2D savedG2 = g2; BufferedImage dataImage = null; if (this.shadowGenerator != null) { dataImage = new BufferedImage((int) dataArea.getWidth(), (int)dataArea.getHeight(), BufferedImage.TYPE_INT_ARGB); g2 = dataImage.createGraphics(); g2.translate(-dataArea.getX(), -dataArea.getY()); g2.setRenderingHints(savedG2.getRenderingHints()); } for (int i = 0; i < this.renderers.size(); i++) { drawDomainMarkers(g2, dataArea, i, Layer.BACKGROUND); } for (int i = 0; i < this.renderers.size(); i++) { drawRangeMarkers(g2, dataArea, i, Layer.BACKGROUND); } boolean foundData = false; DatasetRenderingOrder order = getDatasetRenderingOrder(); if (order == DatasetRenderingOrder.FORWARD) { int rendererCount = this.renderers.size(); for (int i = 0; i < rendererCount; i++) { XYItemRenderer r = getRenderer(i); if (r != null) { ValueAxis domainAxis = getDomainAxisForDataset(i); ValueAxis rangeAxis = getRangeAxisForDataset(i); r.drawAnnotations(g2, dataArea, domainAxis, rangeAxis, Layer.BACKGROUND, info); } } for (int i = 0; i < getDatasetCount(); i++) { foundData = render(g2, dataArea, i, info, crosshairState) || foundData; } for (int i = 0; i < rendererCount; i++) { XYItemRenderer r = getRenderer(i); if (r != null) { ValueAxis domainAxis = getDomainAxisForDataset(i); ValueAxis rangeAxis = getRangeAxisForDataset(i); r.drawAnnotations(g2, dataArea, domainAxis, rangeAxis, Layer.FOREGROUND, info); } } } else if (order == DatasetRenderingOrder.REVERSE) { int rendererCount = this.renderers.size(); for (int i = rendererCount - 1; i >= 0; i--) { XYItemRenderer r = getRenderer(i); if (i >= getDatasetCount()) { continue; } if (r != null) { ValueAxis domainAxis = getDomainAxisForDataset(i); ValueAxis rangeAxis = getRangeAxisForDataset(i); r.drawAnnotations(g2, dataArea, domainAxis, rangeAxis, Layer.BACKGROUND, info); } } for (int i = getDatasetCount() - 1; i >= 0; i--) { foundData = render(g2, dataArea, i, info, crosshairState) || foundData; } for (int i = rendererCount - 1; i >= 0; i--) { XYItemRenderer r = getRenderer(i); if (i >= getDatasetCount()) { continue; } if (r != null) { ValueAxis domainAxis = getDomainAxisForDataset(i); ValueAxis rangeAxis = getRangeAxisForDataset(i); r.drawAnnotations(g2, dataArea, domainAxis, rangeAxis, Layer.FOREGROUND, info); } } } int datasetIndex = crosshairState.getDatasetIndex(); ValueAxis xAxis = this.getDomainAxisForDataset(datasetIndex); RectangleEdge xAxisEdge = getDomainAxisEdge(getDomainAxisIndex(xAxis)); if (!this.domainCrosshairLockedOnData && anchor != null) { double xx; if (orient == PlotOrientation.VERTICAL) { xx = xAxis.java2DToValue(anchor.getX(), dataArea, xAxisEdge); } else { xx = xAxis.java2DToValue(anchor.getY(), dataArea, xAxisEdge); } crosshairState.setCrosshairX(xx); } setDomainCrosshairValue(crosshairState.getCrosshairX(), false); if (isDomainCrosshairVisible()) { double x = getDomainCrosshairValue(); Paint paint = getDomainCrosshairPaint(); Stroke stroke = getDomainCrosshairStroke(); drawDomainCrosshair(g2, dataArea, orient, x, xAxis, stroke, paint); } ValueAxis yAxis = getRangeAxisForDataset(datasetIndex); RectangleEdge yAxisEdge = getRangeAxisEdge(getRangeAxisIndex(yAxis)); if (!this.rangeCrosshairLockedOnData && anchor != null) { double yy; if (orient == PlotOrientation.VERTICAL) { yy = yAxis.java2DToValue(anchor.getY(), dataArea, yAxisEdge); } else { yy = yAxis.java2DToValue(anchor.getX(), dataArea, yAxisEdge); } crosshairState.setCrosshairY(yy); } setRangeCrosshairValue(crosshairState.getCrosshairY(), false); if (isRangeCrosshairVisible()) { double y = getRangeCrosshairValue(); Paint paint = getRangeCrosshairPaint(); Stroke stroke = getRangeCrosshairStroke(); drawRangeCrosshair(g2, dataArea, orient, y, yAxis, stroke, paint); } if (!foundData) { drawNoDataMessage(g2, dataArea); } for (int i = 0; i < this.renderers.size(); i++) { drawDomainMarkers(g2, dataArea, i, Layer.FOREGROUND); } for (int i = 0; i < this.renderers.size(); i++) { drawRangeMarkers(g2, dataArea, i, Layer.FOREGROUND); } drawAnnotations(g2, dataArea, info); if (this.shadowGenerator != null) { BufferedImage shadowImage = this.shadowGenerator.createDropShadow(dataImage); g2 = savedG2; g2.drawImage(shadowImage, (int) dataArea.getX() + this.shadowGenerator.calculateOffsetX(), (int) dataArea.getY() + this.shadowGenerator.calculateOffsetY(), null); g2.drawImage(dataImage, (int) dataArea.getX(), (int) dataArea.getY(), null); } g2.setClip(originalClip); g2.setComposite(originalComposite); drawOutline(g2, dataArea); } }
XYPlot extends Plot implements ValueAxisPlot, Pannable, Zoomable,
        RendererChangeListener, Cloneable, PublicCloneable, Serializable { @Override public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, PlotState parentState, PlotRenderingInfo info) { boolean b1 = (area.getWidth() <= MINIMUM_WIDTH_TO_DRAW); boolean b2 = (area.getHeight() <= MINIMUM_HEIGHT_TO_DRAW); if (b1 || b2) { return; } if (info != null) { info.setPlotArea(area); } RectangleInsets insets = getInsets(); insets.trim(area); AxisSpace space = calculateAxisSpace(g2, area); Rectangle2D dataArea = space.shrink(area, null); this.axisOffset.trim(dataArea); dataArea = integerise(dataArea); if (dataArea.isEmpty()) { return; } createAndAddEntity((Rectangle2D) dataArea.clone(), info, null, null); if (info != null) { info.setDataArea(dataArea); } drawBackground(g2, dataArea); Map<Axis, AxisState> axisStateMap = drawAxes(g2, area, dataArea, info); PlotOrientation orient = getOrientation(); if (anchor != null && !dataArea.contains(anchor)) { anchor = null; } CrosshairState crosshairState = new CrosshairState(); crosshairState.setCrosshairDistance(Double.POSITIVE_INFINITY); crosshairState.setAnchor(anchor); crosshairState.setAnchorX(Double.NaN); crosshairState.setAnchorY(Double.NaN); if (anchor != null) { ValueAxis domainAxis = getDomainAxis(); if (domainAxis != null) { double x; if (orient == PlotOrientation.VERTICAL) { x = domainAxis.java2DToValue(anchor.getX(), dataArea, getDomainAxisEdge()); } else { x = domainAxis.java2DToValue(anchor.getY(), dataArea, getDomainAxisEdge()); } crosshairState.setAnchorX(x); } ValueAxis rangeAxis = getRangeAxis(); if (rangeAxis != null) { double y; if (orient == PlotOrientation.VERTICAL) { y = rangeAxis.java2DToValue(anchor.getY(), dataArea, getRangeAxisEdge()); } else { y = rangeAxis.java2DToValue(anchor.getX(), dataArea, getRangeAxisEdge()); } crosshairState.setAnchorY(y); } } crosshairState.setCrosshairX(getDomainCrosshairValue()); crosshairState.setCrosshairY(getRangeCrosshairValue()); Shape originalClip = g2.getClip(); Composite originalComposite = g2.getComposite(); g2.clip(dataArea); g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, getForegroundAlpha())); AxisState domainAxisState = axisStateMap.get( getDomainAxis()); if (domainAxisState == null) { if (parentState != null) { domainAxisState = parentState.getSharedAxisStates() .get(getDomainAxis()); } } AxisState rangeAxisState = axisStateMap.get(getRangeAxis()); if (rangeAxisState == null) { if (parentState != null) { rangeAxisState = parentState.getSharedAxisStates() .get(getRangeAxis()); } } if (domainAxisState != null) { drawDomainTickBands(g2, dataArea, domainAxisState.getTicks()); } if (rangeAxisState != null) { drawRangeTickBands(g2, dataArea, rangeAxisState.getTicks()); } if (domainAxisState != null) { drawDomainGridlines(g2, dataArea, domainAxisState.getTicks()); drawZeroDomainBaseline(g2, dataArea); } if (rangeAxisState != null) { drawRangeGridlines(g2, dataArea, rangeAxisState.getTicks()); drawZeroRangeBaseline(g2, dataArea); } Graphics2D savedG2 = g2; BufferedImage dataImage = null; if (this.shadowGenerator != null) { dataImage = new BufferedImage((int) dataArea.getWidth(), (int)dataArea.getHeight(), BufferedImage.TYPE_INT_ARGB); g2 = dataImage.createGraphics(); g2.translate(-dataArea.getX(), -dataArea.getY()); g2.setRenderingHints(savedG2.getRenderingHints()); } for (int i = 0; i < this.renderers.size(); i++) { drawDomainMarkers(g2, dataArea, i, Layer.BACKGROUND); } for (int i = 0; i < this.renderers.size(); i++) { drawRangeMarkers(g2, dataArea, i, Layer.BACKGROUND); } boolean foundData = false; DatasetRenderingOrder order = getDatasetRenderingOrder(); if (order == DatasetRenderingOrder.FORWARD) { int rendererCount = this.renderers.size(); for (int i = 0; i < rendererCount; i++) { XYItemRenderer r = getRenderer(i); if (r != null) { ValueAxis domainAxis = getDomainAxisForDataset(i); ValueAxis rangeAxis = getRangeAxisForDataset(i); r.drawAnnotations(g2, dataArea, domainAxis, rangeAxis, Layer.BACKGROUND, info); } } for (int i = 0; i < getDatasetCount(); i++) { foundData = render(g2, dataArea, i, info, crosshairState) || foundData; } for (int i = 0; i < rendererCount; i++) { XYItemRenderer r = getRenderer(i); if (r != null) { ValueAxis domainAxis = getDomainAxisForDataset(i); ValueAxis rangeAxis = getRangeAxisForDataset(i); r.drawAnnotations(g2, dataArea, domainAxis, rangeAxis, Layer.FOREGROUND, info); } } } else if (order == DatasetRenderingOrder.REVERSE) { int rendererCount = this.renderers.size(); for (int i = rendererCount - 1; i >= 0; i--) { XYItemRenderer r = getRenderer(i); if (i >= getDatasetCount()) { continue; } if (r != null) { ValueAxis domainAxis = getDomainAxisForDataset(i); ValueAxis rangeAxis = getRangeAxisForDataset(i); r.drawAnnotations(g2, dataArea, domainAxis, rangeAxis, Layer.BACKGROUND, info); } } for (int i = getDatasetCount() - 1; i >= 0; i--) { foundData = render(g2, dataArea, i, info, crosshairState) || foundData; } for (int i = rendererCount - 1; i >= 0; i--) { XYItemRenderer r = getRenderer(i); if (i >= getDatasetCount()) { continue; } if (r != null) { ValueAxis domainAxis = getDomainAxisForDataset(i); ValueAxis rangeAxis = getRangeAxisForDataset(i); r.drawAnnotations(g2, dataArea, domainAxis, rangeAxis, Layer.FOREGROUND, info); } } } int datasetIndex = crosshairState.getDatasetIndex(); ValueAxis xAxis = this.getDomainAxisForDataset(datasetIndex); RectangleEdge xAxisEdge = getDomainAxisEdge(getDomainAxisIndex(xAxis)); if (!this.domainCrosshairLockedOnData && anchor != null) { double xx; if (orient == PlotOrientation.VERTICAL) { xx = xAxis.java2DToValue(anchor.getX(), dataArea, xAxisEdge); } else { xx = xAxis.java2DToValue(anchor.getY(), dataArea, xAxisEdge); } crosshairState.setCrosshairX(xx); } setDomainCrosshairValue(crosshairState.getCrosshairX(), false); if (isDomainCrosshairVisible()) { double x = getDomainCrosshairValue(); Paint paint = getDomainCrosshairPaint(); Stroke stroke = getDomainCrosshairStroke(); drawDomainCrosshair(g2, dataArea, orient, x, xAxis, stroke, paint); } ValueAxis yAxis = getRangeAxisForDataset(datasetIndex); RectangleEdge yAxisEdge = getRangeAxisEdge(getRangeAxisIndex(yAxis)); if (!this.rangeCrosshairLockedOnData && anchor != null) { double yy; if (orient == PlotOrientation.VERTICAL) { yy = yAxis.java2DToValue(anchor.getY(), dataArea, yAxisEdge); } else { yy = yAxis.java2DToValue(anchor.getX(), dataArea, yAxisEdge); } crosshairState.setCrosshairY(yy); } setRangeCrosshairValue(crosshairState.getCrosshairY(), false); if (isRangeCrosshairVisible()) { double y = getRangeCrosshairValue(); Paint paint = getRangeCrosshairPaint(); Stroke stroke = getRangeCrosshairStroke(); drawRangeCrosshair(g2, dataArea, orient, y, yAxis, stroke, paint); } if (!foundData) { drawNoDataMessage(g2, dataArea); } for (int i = 0; i < this.renderers.size(); i++) { drawDomainMarkers(g2, dataArea, i, Layer.FOREGROUND); } for (int i = 0; i < this.renderers.size(); i++) { drawRangeMarkers(g2, dataArea, i, Layer.FOREGROUND); } drawAnnotations(g2, dataArea, info); if (this.shadowGenerator != null) { BufferedImage shadowImage = this.shadowGenerator.createDropShadow(dataImage); g2 = savedG2; g2.drawImage(shadowImage, (int) dataArea.getX() + this.shadowGenerator.calculateOffsetX(), (int) dataArea.getY() + this.shadowGenerator.calculateOffsetY(), null); g2.drawImage(dataImage, (int) dataArea.getX(), (int) dataArea.getY(), null); } g2.setClip(originalClip); g2.setComposite(originalComposite); drawOutline(g2, dataArea); } XYPlot();  XYPlot(XYDataset dataset,
                  ValueAxis domainAxis,
                  ValueAxis rangeAxis,
                  XYItemRenderer renderer); }
XYPlot extends Plot implements ValueAxisPlot, Pannable, Zoomable,
        RendererChangeListener, Cloneable, PublicCloneable, Serializable { @Override public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, PlotState parentState, PlotRenderingInfo info) { boolean b1 = (area.getWidth() <= MINIMUM_WIDTH_TO_DRAW); boolean b2 = (area.getHeight() <= MINIMUM_HEIGHT_TO_DRAW); if (b1 || b2) { return; } if (info != null) { info.setPlotArea(area); } RectangleInsets insets = getInsets(); insets.trim(area); AxisSpace space = calculateAxisSpace(g2, area); Rectangle2D dataArea = space.shrink(area, null); this.axisOffset.trim(dataArea); dataArea = integerise(dataArea); if (dataArea.isEmpty()) { return; } createAndAddEntity((Rectangle2D) dataArea.clone(), info, null, null); if (info != null) { info.setDataArea(dataArea); } drawBackground(g2, dataArea); Map<Axis, AxisState> axisStateMap = drawAxes(g2, area, dataArea, info); PlotOrientation orient = getOrientation(); if (anchor != null && !dataArea.contains(anchor)) { anchor = null; } CrosshairState crosshairState = new CrosshairState(); crosshairState.setCrosshairDistance(Double.POSITIVE_INFINITY); crosshairState.setAnchor(anchor); crosshairState.setAnchorX(Double.NaN); crosshairState.setAnchorY(Double.NaN); if (anchor != null) { ValueAxis domainAxis = getDomainAxis(); if (domainAxis != null) { double x; if (orient == PlotOrientation.VERTICAL) { x = domainAxis.java2DToValue(anchor.getX(), dataArea, getDomainAxisEdge()); } else { x = domainAxis.java2DToValue(anchor.getY(), dataArea, getDomainAxisEdge()); } crosshairState.setAnchorX(x); } ValueAxis rangeAxis = getRangeAxis(); if (rangeAxis != null) { double y; if (orient == PlotOrientation.VERTICAL) { y = rangeAxis.java2DToValue(anchor.getY(), dataArea, getRangeAxisEdge()); } else { y = rangeAxis.java2DToValue(anchor.getX(), dataArea, getRangeAxisEdge()); } crosshairState.setAnchorY(y); } } crosshairState.setCrosshairX(getDomainCrosshairValue()); crosshairState.setCrosshairY(getRangeCrosshairValue()); Shape originalClip = g2.getClip(); Composite originalComposite = g2.getComposite(); g2.clip(dataArea); g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, getForegroundAlpha())); AxisState domainAxisState = axisStateMap.get( getDomainAxis()); if (domainAxisState == null) { if (parentState != null) { domainAxisState = parentState.getSharedAxisStates() .get(getDomainAxis()); } } AxisState rangeAxisState = axisStateMap.get(getRangeAxis()); if (rangeAxisState == null) { if (parentState != null) { rangeAxisState = parentState.getSharedAxisStates() .get(getRangeAxis()); } } if (domainAxisState != null) { drawDomainTickBands(g2, dataArea, domainAxisState.getTicks()); } if (rangeAxisState != null) { drawRangeTickBands(g2, dataArea, rangeAxisState.getTicks()); } if (domainAxisState != null) { drawDomainGridlines(g2, dataArea, domainAxisState.getTicks()); drawZeroDomainBaseline(g2, dataArea); } if (rangeAxisState != null) { drawRangeGridlines(g2, dataArea, rangeAxisState.getTicks()); drawZeroRangeBaseline(g2, dataArea); } Graphics2D savedG2 = g2; BufferedImage dataImage = null; if (this.shadowGenerator != null) { dataImage = new BufferedImage((int) dataArea.getWidth(), (int)dataArea.getHeight(), BufferedImage.TYPE_INT_ARGB); g2 = dataImage.createGraphics(); g2.translate(-dataArea.getX(), -dataArea.getY()); g2.setRenderingHints(savedG2.getRenderingHints()); } for (int i = 0; i < this.renderers.size(); i++) { drawDomainMarkers(g2, dataArea, i, Layer.BACKGROUND); } for (int i = 0; i < this.renderers.size(); i++) { drawRangeMarkers(g2, dataArea, i, Layer.BACKGROUND); } boolean foundData = false; DatasetRenderingOrder order = getDatasetRenderingOrder(); if (order == DatasetRenderingOrder.FORWARD) { int rendererCount = this.renderers.size(); for (int i = 0; i < rendererCount; i++) { XYItemRenderer r = getRenderer(i); if (r != null) { ValueAxis domainAxis = getDomainAxisForDataset(i); ValueAxis rangeAxis = getRangeAxisForDataset(i); r.drawAnnotations(g2, dataArea, domainAxis, rangeAxis, Layer.BACKGROUND, info); } } for (int i = 0; i < getDatasetCount(); i++) { foundData = render(g2, dataArea, i, info, crosshairState) || foundData; } for (int i = 0; i < rendererCount; i++) { XYItemRenderer r = getRenderer(i); if (r != null) { ValueAxis domainAxis = getDomainAxisForDataset(i); ValueAxis rangeAxis = getRangeAxisForDataset(i); r.drawAnnotations(g2, dataArea, domainAxis, rangeAxis, Layer.FOREGROUND, info); } } } else if (order == DatasetRenderingOrder.REVERSE) { int rendererCount = this.renderers.size(); for (int i = rendererCount - 1; i >= 0; i--) { XYItemRenderer r = getRenderer(i); if (i >= getDatasetCount()) { continue; } if (r != null) { ValueAxis domainAxis = getDomainAxisForDataset(i); ValueAxis rangeAxis = getRangeAxisForDataset(i); r.drawAnnotations(g2, dataArea, domainAxis, rangeAxis, Layer.BACKGROUND, info); } } for (int i = getDatasetCount() - 1; i >= 0; i--) { foundData = render(g2, dataArea, i, info, crosshairState) || foundData; } for (int i = rendererCount - 1; i >= 0; i--) { XYItemRenderer r = getRenderer(i); if (i >= getDatasetCount()) { continue; } if (r != null) { ValueAxis domainAxis = getDomainAxisForDataset(i); ValueAxis rangeAxis = getRangeAxisForDataset(i); r.drawAnnotations(g2, dataArea, domainAxis, rangeAxis, Layer.FOREGROUND, info); } } } int datasetIndex = crosshairState.getDatasetIndex(); ValueAxis xAxis = this.getDomainAxisForDataset(datasetIndex); RectangleEdge xAxisEdge = getDomainAxisEdge(getDomainAxisIndex(xAxis)); if (!this.domainCrosshairLockedOnData && anchor != null) { double xx; if (orient == PlotOrientation.VERTICAL) { xx = xAxis.java2DToValue(anchor.getX(), dataArea, xAxisEdge); } else { xx = xAxis.java2DToValue(anchor.getY(), dataArea, xAxisEdge); } crosshairState.setCrosshairX(xx); } setDomainCrosshairValue(crosshairState.getCrosshairX(), false); if (isDomainCrosshairVisible()) { double x = getDomainCrosshairValue(); Paint paint = getDomainCrosshairPaint(); Stroke stroke = getDomainCrosshairStroke(); drawDomainCrosshair(g2, dataArea, orient, x, xAxis, stroke, paint); } ValueAxis yAxis = getRangeAxisForDataset(datasetIndex); RectangleEdge yAxisEdge = getRangeAxisEdge(getRangeAxisIndex(yAxis)); if (!this.rangeCrosshairLockedOnData && anchor != null) { double yy; if (orient == PlotOrientation.VERTICAL) { yy = yAxis.java2DToValue(anchor.getY(), dataArea, yAxisEdge); } else { yy = yAxis.java2DToValue(anchor.getX(), dataArea, yAxisEdge); } crosshairState.setCrosshairY(yy); } setRangeCrosshairValue(crosshairState.getCrosshairY(), false); if (isRangeCrosshairVisible()) { double y = getRangeCrosshairValue(); Paint paint = getRangeCrosshairPaint(); Stroke stroke = getRangeCrosshairStroke(); drawRangeCrosshair(g2, dataArea, orient, y, yAxis, stroke, paint); } if (!foundData) { drawNoDataMessage(g2, dataArea); } for (int i = 0; i < this.renderers.size(); i++) { drawDomainMarkers(g2, dataArea, i, Layer.FOREGROUND); } for (int i = 0; i < this.renderers.size(); i++) { drawRangeMarkers(g2, dataArea, i, Layer.FOREGROUND); } drawAnnotations(g2, dataArea, info); if (this.shadowGenerator != null) { BufferedImage shadowImage = this.shadowGenerator.createDropShadow(dataImage); g2 = savedG2; g2.drawImage(shadowImage, (int) dataArea.getX() + this.shadowGenerator.calculateOffsetX(), (int) dataArea.getY() + this.shadowGenerator.calculateOffsetY(), null); g2.drawImage(dataImage, (int) dataArea.getX(), (int) dataArea.getY(), null); } g2.setClip(originalClip); g2.setComposite(originalComposite); drawOutline(g2, dataArea); } XYPlot();  XYPlot(XYDataset dataset,
                  ValueAxis domainAxis,
                  ValueAxis rangeAxis,
                  XYItemRenderer renderer); @Override String getPlotType(); @Override PlotOrientation getOrientation(); void setOrientation(PlotOrientation orientation); RectangleInsets getAxisOffset(); void setAxisOffset(RectangleInsets offset); ValueAxis getDomainAxis(); ValueAxis getDomainAxis(int index); void setDomainAxis(ValueAxis axis); void setDomainAxis(int index, ValueAxis axis); void setDomainAxis(int index, ValueAxis axis, boolean notify); void setDomainAxes(ValueAxis[] axes); AxisLocation getDomainAxisLocation(); void setDomainAxisLocation(AxisLocation location); void setDomainAxisLocation(AxisLocation location, boolean notify); RectangleEdge getDomainAxisEdge(); int getDomainAxisCount(); void clearDomainAxes(); void configureDomainAxes(); AxisLocation getDomainAxisLocation(int index); void setDomainAxisLocation(int index, AxisLocation location); void setDomainAxisLocation(int index, AxisLocation location,
            boolean notify); RectangleEdge getDomainAxisEdge(int index); ValueAxis getRangeAxis(); void setRangeAxis(ValueAxis axis); AxisLocation getRangeAxisLocation(); void setRangeAxisLocation(AxisLocation location); void setRangeAxisLocation(AxisLocation location, boolean notify); RectangleEdge getRangeAxisEdge(); ValueAxis getRangeAxis(int index); void setRangeAxis(int index, ValueAxis axis); void setRangeAxis(int index, ValueAxis axis, boolean notify); void setRangeAxes(ValueAxis[] axes); int getRangeAxisCount(); void clearRangeAxes(); void configureRangeAxes(); AxisLocation getRangeAxisLocation(int index); void setRangeAxisLocation(int index, AxisLocation location); void setRangeAxisLocation(int index, AxisLocation location,
            boolean notify); RectangleEdge getRangeAxisEdge(int index); XYDataset getDataset(); XYDataset getDataset(int index); void setDataset(XYDataset dataset); void setDataset(int index, XYDataset dataset); int getDatasetCount(); int indexOf(XYDataset dataset); void mapDatasetToDomainAxis(int index, int axisIndex); void mapDatasetToDomainAxes(int index, List<Integer> axisIndices); void mapDatasetToRangeAxis(int index, int axisIndex); void mapDatasetToRangeAxes(int index, List<Integer> axisIndices); int getRendererCount(); XYItemRenderer getRenderer(); XYItemRenderer getRenderer(int index); void setRenderer(XYItemRenderer renderer); void setRenderer(int index, XYItemRenderer renderer); void setRenderer(int index, XYItemRenderer renderer,
                            boolean notify); void setRenderers(XYItemRenderer[] renderers); DatasetRenderingOrder getDatasetRenderingOrder(); void setDatasetRenderingOrder(DatasetRenderingOrder order); SeriesRenderingOrder getSeriesRenderingOrder(); void setSeriesRenderingOrder(SeriesRenderingOrder order); int getIndexOf(XYItemRenderer renderer); XYItemRenderer getRendererForDataset(XYDataset dataset); int getWeight(); void setWeight(int weight); boolean isDomainGridlinesVisible(); void setDomainGridlinesVisible(boolean visible); boolean isDomainMinorGridlinesVisible(); void setDomainMinorGridlinesVisible(boolean visible); Stroke getDomainGridlineStroke(); void setDomainGridlineStroke(Stroke stroke); Stroke getDomainMinorGridlineStroke(); void setDomainMinorGridlineStroke(Stroke stroke); Paint getDomainGridlinePaint(); void setDomainGridlinePaint(Paint paint); Paint getDomainMinorGridlinePaint(); void setDomainMinorGridlinePaint(Paint paint); boolean isRangeGridlinesVisible(); void setRangeGridlinesVisible(boolean visible); Stroke getRangeGridlineStroke(); void setRangeGridlineStroke(Stroke stroke); Paint getRangeGridlinePaint(); void setRangeGridlinePaint(Paint paint); boolean isRangeMinorGridlinesVisible(); void setRangeMinorGridlinesVisible(boolean visible); Stroke getRangeMinorGridlineStroke(); void setRangeMinorGridlineStroke(Stroke stroke); Paint getRangeMinorGridlinePaint(); void setRangeMinorGridlinePaint(Paint paint); boolean isDomainZeroBaselineVisible(); void setDomainZeroBaselineVisible(boolean visible); Stroke getDomainZeroBaselineStroke(); void setDomainZeroBaselineStroke(Stroke stroke); Paint getDomainZeroBaselinePaint(); void setDomainZeroBaselinePaint(Paint paint); boolean isRangeZeroBaselineVisible(); void setRangeZeroBaselineVisible(boolean visible); Stroke getRangeZeroBaselineStroke(); void setRangeZeroBaselineStroke(Stroke stroke); Paint getRangeZeroBaselinePaint(); void setRangeZeroBaselinePaint(Paint paint); Paint getDomainTickBandPaint(); void setDomainTickBandPaint(Paint paint); Paint getRangeTickBandPaint(); void setRangeTickBandPaint(Paint paint); Point2D getQuadrantOrigin(); void setQuadrantOrigin(Point2D origin); Paint getQuadrantPaint(int index); void setQuadrantPaint(int index, Paint paint); void addDomainMarker(Marker marker); void addDomainMarker(Marker marker, Layer layer); void clearDomainMarkers(); void clearDomainMarkers(int key); void addDomainMarker(int index, Marker marker, Layer layer); void addDomainMarker(int index, Marker marker, Layer layer,
            boolean notify); boolean removeDomainMarker(Marker marker); boolean removeDomainMarker(Marker marker, Layer layer); boolean removeDomainMarker(int index, Marker marker, Layer layer); boolean removeDomainMarker(int index, Marker marker, Layer layer,
            boolean notify); void addRangeMarker(Marker marker); void addRangeMarker(Marker marker, Layer layer); void clearRangeMarkers(); void addRangeMarker(int index, Marker marker, Layer layer); void addRangeMarker(int index, Marker marker, Layer layer,
            boolean notify); void clearRangeMarkers(int key); boolean removeRangeMarker(Marker marker); boolean removeRangeMarker(Marker marker, Layer layer); boolean removeRangeMarker(int index, Marker marker, Layer layer); boolean removeRangeMarker(int index, Marker marker, Layer layer,
            boolean notify); void addAnnotation(XYAnnotation annotation); void addAnnotation(XYAnnotation annotation, boolean notify); boolean removeAnnotation(XYAnnotation annotation); boolean removeAnnotation(XYAnnotation annotation, boolean notify); List<XYAnnotation> getAnnotations(); void clearAnnotations(); ShadowGenerator getShadowGenerator(); void setShadowGenerator(ShadowGenerator generator); @Override void draw(Graphics2D g2, Rectangle2D area, Point2D anchor,
            PlotState parentState, PlotRenderingInfo info); @Override void drawBackground(Graphics2D g2, Rectangle2D area); void drawDomainTickBands(Graphics2D g2, Rectangle2D dataArea,
                                    List<ValueTick> ticks); void drawRangeTickBands(Graphics2D g2, Rectangle2D dataArea,
                                   List<ValueTick> ticks); boolean render(Graphics2D g2, Rectangle2D dataArea, int index,
            PlotRenderingInfo info, CrosshairState crosshairState); ValueAxis getDomainAxisForDataset(int index); ValueAxis getRangeAxisForDataset(int index); void drawAnnotations(Graphics2D g2, Rectangle2D dataArea,
                                PlotRenderingInfo info); Collection<Marker> getDomainMarkers(Layer layer); Collection<Marker> getRangeMarkers(Layer layer); Collection<Marker> getDomainMarkers(int index, Layer layer); Collection<Marker> getRangeMarkers(int index, Layer layer); @Override void handleClick(int x, int y, PlotRenderingInfo info); int getDomainAxisIndex(ValueAxis axis); int getRangeAxisIndex(ValueAxis axis); @Override Range getDataRange(ValueAxis axis); @Override void annotationChanged(AnnotationChangeEvent event); @Override void datasetChanged(DatasetChangeEvent event); @Override void rendererChanged(RendererChangeEvent event); boolean isDomainCrosshairVisible(); void setDomainCrosshairVisible(boolean flag); boolean isDomainCrosshairLockedOnData(); void setDomainCrosshairLockedOnData(boolean flag); double getDomainCrosshairValue(); void setDomainCrosshairValue(double value); void setDomainCrosshairValue(double value, boolean notify); Stroke getDomainCrosshairStroke(); void setDomainCrosshairStroke(Stroke stroke); Paint getDomainCrosshairPaint(); void setDomainCrosshairPaint(Paint paint); boolean isRangeCrosshairVisible(); void setRangeCrosshairVisible(boolean flag); boolean isRangeCrosshairLockedOnData(); void setRangeCrosshairLockedOnData(boolean flag); double getRangeCrosshairValue(); void setRangeCrosshairValue(double value); void setRangeCrosshairValue(double value, boolean notify); Stroke getRangeCrosshairStroke(); void setRangeCrosshairStroke(Stroke stroke); Paint getRangeCrosshairPaint(); void setRangeCrosshairPaint(Paint paint); AxisSpace getFixedDomainAxisSpace(); void setFixedDomainAxisSpace(AxisSpace space); void setFixedDomainAxisSpace(AxisSpace space, boolean notify); AxisSpace getFixedRangeAxisSpace(); void setFixedRangeAxisSpace(AxisSpace space); void setFixedRangeAxisSpace(AxisSpace space, boolean notify); @Override boolean isDomainPannable(); void setDomainPannable(boolean pannable); @Override boolean isRangePannable(); void setRangePannable(boolean pannable); @Override void panDomainAxes(double percent, PlotRenderingInfo info,
            Point2D source); @Override void panRangeAxes(double percent, PlotRenderingInfo info,
            Point2D source); @Override void zoomDomainAxes(double factor, PlotRenderingInfo info,
                               Point2D source); @Override void zoomDomainAxes(double factor, PlotRenderingInfo info,
                               Point2D source, boolean useAnchor); @Override void zoomDomainAxes(double lowerPercent, double upperPercent,
                               PlotRenderingInfo info, Point2D source); @Override void zoomRangeAxes(double factor, PlotRenderingInfo info,
                              Point2D source); @Override void zoomRangeAxes(double factor, PlotRenderingInfo info,
                              Point2D source, boolean useAnchor); @Override void zoomRangeAxes(double lowerPercent, double upperPercent,
                              PlotRenderingInfo info, Point2D source); @Override boolean isDomainZoomable(); @Override boolean isRangeZoomable(); int getSeriesCount(); List<LegendItem> getFixedLegendItems(); void setFixedLegendItems(List<LegendItem> items); @Override List<LegendItem> getLegendItems(); @Override boolean equals(Object obj); double getJava2dToValue(Rectangle2D rect,
                                   PlotRenderingInfo info,
                                   int select); double getValueToJava2d(double dValue,
                                   PlotRenderingInfo info); @Override Object clone(); }
XYPlot extends Plot implements ValueAxisPlot, Pannable, Zoomable,
        RendererChangeListener, Cloneable, PublicCloneable, Serializable { @Override public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, PlotState parentState, PlotRenderingInfo info) { boolean b1 = (area.getWidth() <= MINIMUM_WIDTH_TO_DRAW); boolean b2 = (area.getHeight() <= MINIMUM_HEIGHT_TO_DRAW); if (b1 || b2) { return; } if (info != null) { info.setPlotArea(area); } RectangleInsets insets = getInsets(); insets.trim(area); AxisSpace space = calculateAxisSpace(g2, area); Rectangle2D dataArea = space.shrink(area, null); this.axisOffset.trim(dataArea); dataArea = integerise(dataArea); if (dataArea.isEmpty()) { return; } createAndAddEntity((Rectangle2D) dataArea.clone(), info, null, null); if (info != null) { info.setDataArea(dataArea); } drawBackground(g2, dataArea); Map<Axis, AxisState> axisStateMap = drawAxes(g2, area, dataArea, info); PlotOrientation orient = getOrientation(); if (anchor != null && !dataArea.contains(anchor)) { anchor = null; } CrosshairState crosshairState = new CrosshairState(); crosshairState.setCrosshairDistance(Double.POSITIVE_INFINITY); crosshairState.setAnchor(anchor); crosshairState.setAnchorX(Double.NaN); crosshairState.setAnchorY(Double.NaN); if (anchor != null) { ValueAxis domainAxis = getDomainAxis(); if (domainAxis != null) { double x; if (orient == PlotOrientation.VERTICAL) { x = domainAxis.java2DToValue(anchor.getX(), dataArea, getDomainAxisEdge()); } else { x = domainAxis.java2DToValue(anchor.getY(), dataArea, getDomainAxisEdge()); } crosshairState.setAnchorX(x); } ValueAxis rangeAxis = getRangeAxis(); if (rangeAxis != null) { double y; if (orient == PlotOrientation.VERTICAL) { y = rangeAxis.java2DToValue(anchor.getY(), dataArea, getRangeAxisEdge()); } else { y = rangeAxis.java2DToValue(anchor.getX(), dataArea, getRangeAxisEdge()); } crosshairState.setAnchorY(y); } } crosshairState.setCrosshairX(getDomainCrosshairValue()); crosshairState.setCrosshairY(getRangeCrosshairValue()); Shape originalClip = g2.getClip(); Composite originalComposite = g2.getComposite(); g2.clip(dataArea); g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, getForegroundAlpha())); AxisState domainAxisState = axisStateMap.get( getDomainAxis()); if (domainAxisState == null) { if (parentState != null) { domainAxisState = parentState.getSharedAxisStates() .get(getDomainAxis()); } } AxisState rangeAxisState = axisStateMap.get(getRangeAxis()); if (rangeAxisState == null) { if (parentState != null) { rangeAxisState = parentState.getSharedAxisStates() .get(getRangeAxis()); } } if (domainAxisState != null) { drawDomainTickBands(g2, dataArea, domainAxisState.getTicks()); } if (rangeAxisState != null) { drawRangeTickBands(g2, dataArea, rangeAxisState.getTicks()); } if (domainAxisState != null) { drawDomainGridlines(g2, dataArea, domainAxisState.getTicks()); drawZeroDomainBaseline(g2, dataArea); } if (rangeAxisState != null) { drawRangeGridlines(g2, dataArea, rangeAxisState.getTicks()); drawZeroRangeBaseline(g2, dataArea); } Graphics2D savedG2 = g2; BufferedImage dataImage = null; if (this.shadowGenerator != null) { dataImage = new BufferedImage((int) dataArea.getWidth(), (int)dataArea.getHeight(), BufferedImage.TYPE_INT_ARGB); g2 = dataImage.createGraphics(); g2.translate(-dataArea.getX(), -dataArea.getY()); g2.setRenderingHints(savedG2.getRenderingHints()); } for (int i = 0; i < this.renderers.size(); i++) { drawDomainMarkers(g2, dataArea, i, Layer.BACKGROUND); } for (int i = 0; i < this.renderers.size(); i++) { drawRangeMarkers(g2, dataArea, i, Layer.BACKGROUND); } boolean foundData = false; DatasetRenderingOrder order = getDatasetRenderingOrder(); if (order == DatasetRenderingOrder.FORWARD) { int rendererCount = this.renderers.size(); for (int i = 0; i < rendererCount; i++) { XYItemRenderer r = getRenderer(i); if (r != null) { ValueAxis domainAxis = getDomainAxisForDataset(i); ValueAxis rangeAxis = getRangeAxisForDataset(i); r.drawAnnotations(g2, dataArea, domainAxis, rangeAxis, Layer.BACKGROUND, info); } } for (int i = 0; i < getDatasetCount(); i++) { foundData = render(g2, dataArea, i, info, crosshairState) || foundData; } for (int i = 0; i < rendererCount; i++) { XYItemRenderer r = getRenderer(i); if (r != null) { ValueAxis domainAxis = getDomainAxisForDataset(i); ValueAxis rangeAxis = getRangeAxisForDataset(i); r.drawAnnotations(g2, dataArea, domainAxis, rangeAxis, Layer.FOREGROUND, info); } } } else if (order == DatasetRenderingOrder.REVERSE) { int rendererCount = this.renderers.size(); for (int i = rendererCount - 1; i >= 0; i--) { XYItemRenderer r = getRenderer(i); if (i >= getDatasetCount()) { continue; } if (r != null) { ValueAxis domainAxis = getDomainAxisForDataset(i); ValueAxis rangeAxis = getRangeAxisForDataset(i); r.drawAnnotations(g2, dataArea, domainAxis, rangeAxis, Layer.BACKGROUND, info); } } for (int i = getDatasetCount() - 1; i >= 0; i--) { foundData = render(g2, dataArea, i, info, crosshairState) || foundData; } for (int i = rendererCount - 1; i >= 0; i--) { XYItemRenderer r = getRenderer(i); if (i >= getDatasetCount()) { continue; } if (r != null) { ValueAxis domainAxis = getDomainAxisForDataset(i); ValueAxis rangeAxis = getRangeAxisForDataset(i); r.drawAnnotations(g2, dataArea, domainAxis, rangeAxis, Layer.FOREGROUND, info); } } } int datasetIndex = crosshairState.getDatasetIndex(); ValueAxis xAxis = this.getDomainAxisForDataset(datasetIndex); RectangleEdge xAxisEdge = getDomainAxisEdge(getDomainAxisIndex(xAxis)); if (!this.domainCrosshairLockedOnData && anchor != null) { double xx; if (orient == PlotOrientation.VERTICAL) { xx = xAxis.java2DToValue(anchor.getX(), dataArea, xAxisEdge); } else { xx = xAxis.java2DToValue(anchor.getY(), dataArea, xAxisEdge); } crosshairState.setCrosshairX(xx); } setDomainCrosshairValue(crosshairState.getCrosshairX(), false); if (isDomainCrosshairVisible()) { double x = getDomainCrosshairValue(); Paint paint = getDomainCrosshairPaint(); Stroke stroke = getDomainCrosshairStroke(); drawDomainCrosshair(g2, dataArea, orient, x, xAxis, stroke, paint); } ValueAxis yAxis = getRangeAxisForDataset(datasetIndex); RectangleEdge yAxisEdge = getRangeAxisEdge(getRangeAxisIndex(yAxis)); if (!this.rangeCrosshairLockedOnData && anchor != null) { double yy; if (orient == PlotOrientation.VERTICAL) { yy = yAxis.java2DToValue(anchor.getY(), dataArea, yAxisEdge); } else { yy = yAxis.java2DToValue(anchor.getX(), dataArea, yAxisEdge); } crosshairState.setCrosshairY(yy); } setRangeCrosshairValue(crosshairState.getCrosshairY(), false); if (isRangeCrosshairVisible()) { double y = getRangeCrosshairValue(); Paint paint = getRangeCrosshairPaint(); Stroke stroke = getRangeCrosshairStroke(); drawRangeCrosshair(g2, dataArea, orient, y, yAxis, stroke, paint); } if (!foundData) { drawNoDataMessage(g2, dataArea); } for (int i = 0; i < this.renderers.size(); i++) { drawDomainMarkers(g2, dataArea, i, Layer.FOREGROUND); } for (int i = 0; i < this.renderers.size(); i++) { drawRangeMarkers(g2, dataArea, i, Layer.FOREGROUND); } drawAnnotations(g2, dataArea, info); if (this.shadowGenerator != null) { BufferedImage shadowImage = this.shadowGenerator.createDropShadow(dataImage); g2 = savedG2; g2.drawImage(shadowImage, (int) dataArea.getX() + this.shadowGenerator.calculateOffsetX(), (int) dataArea.getY() + this.shadowGenerator.calculateOffsetY(), null); g2.drawImage(dataImage, (int) dataArea.getX(), (int) dataArea.getY(), null); } g2.setClip(originalClip); g2.setComposite(originalComposite); drawOutline(g2, dataArea); } XYPlot();  XYPlot(XYDataset dataset,
                  ValueAxis domainAxis,
                  ValueAxis rangeAxis,
                  XYItemRenderer renderer); @Override String getPlotType(); @Override PlotOrientation getOrientation(); void setOrientation(PlotOrientation orientation); RectangleInsets getAxisOffset(); void setAxisOffset(RectangleInsets offset); ValueAxis getDomainAxis(); ValueAxis getDomainAxis(int index); void setDomainAxis(ValueAxis axis); void setDomainAxis(int index, ValueAxis axis); void setDomainAxis(int index, ValueAxis axis, boolean notify); void setDomainAxes(ValueAxis[] axes); AxisLocation getDomainAxisLocation(); void setDomainAxisLocation(AxisLocation location); void setDomainAxisLocation(AxisLocation location, boolean notify); RectangleEdge getDomainAxisEdge(); int getDomainAxisCount(); void clearDomainAxes(); void configureDomainAxes(); AxisLocation getDomainAxisLocation(int index); void setDomainAxisLocation(int index, AxisLocation location); void setDomainAxisLocation(int index, AxisLocation location,
            boolean notify); RectangleEdge getDomainAxisEdge(int index); ValueAxis getRangeAxis(); void setRangeAxis(ValueAxis axis); AxisLocation getRangeAxisLocation(); void setRangeAxisLocation(AxisLocation location); void setRangeAxisLocation(AxisLocation location, boolean notify); RectangleEdge getRangeAxisEdge(); ValueAxis getRangeAxis(int index); void setRangeAxis(int index, ValueAxis axis); void setRangeAxis(int index, ValueAxis axis, boolean notify); void setRangeAxes(ValueAxis[] axes); int getRangeAxisCount(); void clearRangeAxes(); void configureRangeAxes(); AxisLocation getRangeAxisLocation(int index); void setRangeAxisLocation(int index, AxisLocation location); void setRangeAxisLocation(int index, AxisLocation location,
            boolean notify); RectangleEdge getRangeAxisEdge(int index); XYDataset getDataset(); XYDataset getDataset(int index); void setDataset(XYDataset dataset); void setDataset(int index, XYDataset dataset); int getDatasetCount(); int indexOf(XYDataset dataset); void mapDatasetToDomainAxis(int index, int axisIndex); void mapDatasetToDomainAxes(int index, List<Integer> axisIndices); void mapDatasetToRangeAxis(int index, int axisIndex); void mapDatasetToRangeAxes(int index, List<Integer> axisIndices); int getRendererCount(); XYItemRenderer getRenderer(); XYItemRenderer getRenderer(int index); void setRenderer(XYItemRenderer renderer); void setRenderer(int index, XYItemRenderer renderer); void setRenderer(int index, XYItemRenderer renderer,
                            boolean notify); void setRenderers(XYItemRenderer[] renderers); DatasetRenderingOrder getDatasetRenderingOrder(); void setDatasetRenderingOrder(DatasetRenderingOrder order); SeriesRenderingOrder getSeriesRenderingOrder(); void setSeriesRenderingOrder(SeriesRenderingOrder order); int getIndexOf(XYItemRenderer renderer); XYItemRenderer getRendererForDataset(XYDataset dataset); int getWeight(); void setWeight(int weight); boolean isDomainGridlinesVisible(); void setDomainGridlinesVisible(boolean visible); boolean isDomainMinorGridlinesVisible(); void setDomainMinorGridlinesVisible(boolean visible); Stroke getDomainGridlineStroke(); void setDomainGridlineStroke(Stroke stroke); Stroke getDomainMinorGridlineStroke(); void setDomainMinorGridlineStroke(Stroke stroke); Paint getDomainGridlinePaint(); void setDomainGridlinePaint(Paint paint); Paint getDomainMinorGridlinePaint(); void setDomainMinorGridlinePaint(Paint paint); boolean isRangeGridlinesVisible(); void setRangeGridlinesVisible(boolean visible); Stroke getRangeGridlineStroke(); void setRangeGridlineStroke(Stroke stroke); Paint getRangeGridlinePaint(); void setRangeGridlinePaint(Paint paint); boolean isRangeMinorGridlinesVisible(); void setRangeMinorGridlinesVisible(boolean visible); Stroke getRangeMinorGridlineStroke(); void setRangeMinorGridlineStroke(Stroke stroke); Paint getRangeMinorGridlinePaint(); void setRangeMinorGridlinePaint(Paint paint); boolean isDomainZeroBaselineVisible(); void setDomainZeroBaselineVisible(boolean visible); Stroke getDomainZeroBaselineStroke(); void setDomainZeroBaselineStroke(Stroke stroke); Paint getDomainZeroBaselinePaint(); void setDomainZeroBaselinePaint(Paint paint); boolean isRangeZeroBaselineVisible(); void setRangeZeroBaselineVisible(boolean visible); Stroke getRangeZeroBaselineStroke(); void setRangeZeroBaselineStroke(Stroke stroke); Paint getRangeZeroBaselinePaint(); void setRangeZeroBaselinePaint(Paint paint); Paint getDomainTickBandPaint(); void setDomainTickBandPaint(Paint paint); Paint getRangeTickBandPaint(); void setRangeTickBandPaint(Paint paint); Point2D getQuadrantOrigin(); void setQuadrantOrigin(Point2D origin); Paint getQuadrantPaint(int index); void setQuadrantPaint(int index, Paint paint); void addDomainMarker(Marker marker); void addDomainMarker(Marker marker, Layer layer); void clearDomainMarkers(); void clearDomainMarkers(int key); void addDomainMarker(int index, Marker marker, Layer layer); void addDomainMarker(int index, Marker marker, Layer layer,
            boolean notify); boolean removeDomainMarker(Marker marker); boolean removeDomainMarker(Marker marker, Layer layer); boolean removeDomainMarker(int index, Marker marker, Layer layer); boolean removeDomainMarker(int index, Marker marker, Layer layer,
            boolean notify); void addRangeMarker(Marker marker); void addRangeMarker(Marker marker, Layer layer); void clearRangeMarkers(); void addRangeMarker(int index, Marker marker, Layer layer); void addRangeMarker(int index, Marker marker, Layer layer,
            boolean notify); void clearRangeMarkers(int key); boolean removeRangeMarker(Marker marker); boolean removeRangeMarker(Marker marker, Layer layer); boolean removeRangeMarker(int index, Marker marker, Layer layer); boolean removeRangeMarker(int index, Marker marker, Layer layer,
            boolean notify); void addAnnotation(XYAnnotation annotation); void addAnnotation(XYAnnotation annotation, boolean notify); boolean removeAnnotation(XYAnnotation annotation); boolean removeAnnotation(XYAnnotation annotation, boolean notify); List<XYAnnotation> getAnnotations(); void clearAnnotations(); ShadowGenerator getShadowGenerator(); void setShadowGenerator(ShadowGenerator generator); @Override void draw(Graphics2D g2, Rectangle2D area, Point2D anchor,
            PlotState parentState, PlotRenderingInfo info); @Override void drawBackground(Graphics2D g2, Rectangle2D area); void drawDomainTickBands(Graphics2D g2, Rectangle2D dataArea,
                                    List<ValueTick> ticks); void drawRangeTickBands(Graphics2D g2, Rectangle2D dataArea,
                                   List<ValueTick> ticks); boolean render(Graphics2D g2, Rectangle2D dataArea, int index,
            PlotRenderingInfo info, CrosshairState crosshairState); ValueAxis getDomainAxisForDataset(int index); ValueAxis getRangeAxisForDataset(int index); void drawAnnotations(Graphics2D g2, Rectangle2D dataArea,
                                PlotRenderingInfo info); Collection<Marker> getDomainMarkers(Layer layer); Collection<Marker> getRangeMarkers(Layer layer); Collection<Marker> getDomainMarkers(int index, Layer layer); Collection<Marker> getRangeMarkers(int index, Layer layer); @Override void handleClick(int x, int y, PlotRenderingInfo info); int getDomainAxisIndex(ValueAxis axis); int getRangeAxisIndex(ValueAxis axis); @Override Range getDataRange(ValueAxis axis); @Override void annotationChanged(AnnotationChangeEvent event); @Override void datasetChanged(DatasetChangeEvent event); @Override void rendererChanged(RendererChangeEvent event); boolean isDomainCrosshairVisible(); void setDomainCrosshairVisible(boolean flag); boolean isDomainCrosshairLockedOnData(); void setDomainCrosshairLockedOnData(boolean flag); double getDomainCrosshairValue(); void setDomainCrosshairValue(double value); void setDomainCrosshairValue(double value, boolean notify); Stroke getDomainCrosshairStroke(); void setDomainCrosshairStroke(Stroke stroke); Paint getDomainCrosshairPaint(); void setDomainCrosshairPaint(Paint paint); boolean isRangeCrosshairVisible(); void setRangeCrosshairVisible(boolean flag); boolean isRangeCrosshairLockedOnData(); void setRangeCrosshairLockedOnData(boolean flag); double getRangeCrosshairValue(); void setRangeCrosshairValue(double value); void setRangeCrosshairValue(double value, boolean notify); Stroke getRangeCrosshairStroke(); void setRangeCrosshairStroke(Stroke stroke); Paint getRangeCrosshairPaint(); void setRangeCrosshairPaint(Paint paint); AxisSpace getFixedDomainAxisSpace(); void setFixedDomainAxisSpace(AxisSpace space); void setFixedDomainAxisSpace(AxisSpace space, boolean notify); AxisSpace getFixedRangeAxisSpace(); void setFixedRangeAxisSpace(AxisSpace space); void setFixedRangeAxisSpace(AxisSpace space, boolean notify); @Override boolean isDomainPannable(); void setDomainPannable(boolean pannable); @Override boolean isRangePannable(); void setRangePannable(boolean pannable); @Override void panDomainAxes(double percent, PlotRenderingInfo info,
            Point2D source); @Override void panRangeAxes(double percent, PlotRenderingInfo info,
            Point2D source); @Override void zoomDomainAxes(double factor, PlotRenderingInfo info,
                               Point2D source); @Override void zoomDomainAxes(double factor, PlotRenderingInfo info,
                               Point2D source, boolean useAnchor); @Override void zoomDomainAxes(double lowerPercent, double upperPercent,
                               PlotRenderingInfo info, Point2D source); @Override void zoomRangeAxes(double factor, PlotRenderingInfo info,
                              Point2D source); @Override void zoomRangeAxes(double factor, PlotRenderingInfo info,
                              Point2D source, boolean useAnchor); @Override void zoomRangeAxes(double lowerPercent, double upperPercent,
                              PlotRenderingInfo info, Point2D source); @Override boolean isDomainZoomable(); @Override boolean isRangeZoomable(); int getSeriesCount(); List<LegendItem> getFixedLegendItems(); void setFixedLegendItems(List<LegendItem> items); @Override List<LegendItem> getLegendItems(); @Override boolean equals(Object obj); double getJava2dToValue(Rectangle2D rect,
                                   PlotRenderingInfo info,
                                   int select); double getValueToJava2d(double dValue,
                                   PlotRenderingInfo info); @Override Object clone(); static final Stroke DEFAULT_GRIDLINE_STROKE; static final Paint DEFAULT_GRIDLINE_PAINT; static final boolean DEFAULT_CROSSHAIR_VISIBLE; static final Stroke DEFAULT_CROSSHAIR_STROKE; static final Paint DEFAULT_CROSSHAIR_PAINT; }