g2.setFont(getTickLabelFont(tick.getCategory())); g2.setPaint(getTickLabelPaint(tick.getCategory())); x1 = x0 - state.getMax(); Rectangle2D area = new Rectangle2D.Double(x0, y0, (x1 - x0), (y1 - y0)); if(r==null || !r.intersects(area)) { Point2D anchorPoint = RectangleAnchor.coordinates(area, position.getCategoryAnchor()); position.getLabelAnchor(), (float) anchorPoint.getX(), (float) anchorPoint.getY(), position.getAngle()); if (plotState != null && plotState.getOwner() != null) { EntityCollection entities = plotState.getOwner().getEntityCollection(); if (entities != null) { String tooltip = getCategoryLabelToolTip( r.add(r.getMaxX() + r.getWidth()/2, r.getCenterY()); r.add(r.getMinX() - r.getWidth()/2, r.getCenterY()); r.add(r.getCenterX(), r.getMinY() - r.getHeight()/2);
/** * 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); } } }
/** * Clears the information recorded by this object. */ public void clear() { this.chartArea.setRect(0.0, 0.0, 0.0, 0.0); this.plotInfo = new PlotRenderingInfo(this); if (this.entities != null) { this.entities.clear(); } }
/** * 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</code> not * permitted). * * @return The subplot index (or -1 if no subplot contains * <code>source</code>). */ public int getSubplotIndex(Point2D source) { if (source == null) { throw new IllegalArgumentException("Null 'source' argument."); } 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; }
insets.trim(plotArea); Rectangle2D originalPlotArea = (Rectangle2D) plotArea.clone(); if (info != null) { info.setPlotArea(plotArea); info.setDataArea(plotArea); Shape savedClip = g2.getClip(); g2.clip(plotArea); Rectangle2D linkAreaXX = new Rectangle2D.Double(linkX, linkY, linkW, linkH * (1 - this.depthFactor)); state.setLinkArea(linkAreaXX); g2.draw(linkAreaXX); g2.setPaint(Color.YELLOW); g2.draw(new Ellipse2D.Double(linkAreaXX.getX(), linkAreaXX.getY(), linkAreaXX.getWidth(), linkAreaXX.getHeight())); Rectangle2D explodeArea = new Rectangle2D.Double(linkX + hh / 2.0, linkY + vv / 2.0, linkW - hh, linkH - vv); = info.getOwner().getEntityCollection(); if (entities != null) { String tip = null;
dy = ((VectorXYDataset) dataset).getVectorYValue(series, item); double xx0 = domainAxis.valueToJava2D(x, dataArea, plot.getDomainAxisEdge()); double yy0 = rangeAxis.valueToJava2D(y, dataArea, plot.getRangeAxisEdge()); double xx1 = domainAxis.valueToJava2D(x + dx, dataArea, plot.getDomainAxisEdge()); double yy1 = rangeAxis.valueToJava2D(y + dy, dataArea, plot.getRangeAxisEdge()); line = new Line2D.Double(xx0, yy0, xx1, yy1); g2.setPaint(getItemPaint(series, item)); g2.setStroke(getItemStroke(series, item)); g2.draw(line); entities = info.getOwner().getEntityCollection(); if (entities != null) { addEntity(entities, line.getBounds(), dataset, series, item,
PlotOrientation orientation = plot.getOrientation(); if (orientation == PlotOrientation.HORIZONTAL) { horiz = true; entities = info.getOwner().getEntityCollection(); double yClose = highLowData.getCloseValue(series, item); RectangleEdge domainEdge = plot.getDomainAxisEdge(); double xx = domainAxis.valueToJava2D(x, dataArea, domainEdge); xxWidth = dataArea.getWidth() / itemCount; xxWidth = dataArea.getWidth(); g2.setStroke(s); g2.setPaint(getVolumePaint()); Composite originalComposite = g2.getComposite(); g2.fill(new Rectangle2D.Double(min, xx - volumeWidth / 2, zzVolume, volumeWidth)); g2.fill(new Rectangle2D.Double(xx - volumeWidth / 2, max - zzVolume, volumeWidth, zzVolume));
EntityCollection entities = null; if (info != null) { entities = info.getOwner().getEntityCollection(); double transX = domainAxis.valueToJava2D(x, dataArea, plot.getDomainAxisEdge()); double transY = rangeAxis.valueToJava2D(y, dataArea, plot.getRangeAxisEdge()); PlotOrientation orientation = plot.getOrientation(); g2.setStroke(this.guideLineStroke); g2.setPaint(this.guideLinePaint); if (orientation == PlotOrientation.HORIZONTAL) { g2.draw(new Line2D.Double(transY, dataArea.getMinY(), transY, dataArea.getMaxY())); g2.draw(new Line2D.Double(dataArea.getMinX(), transX, dataArea.getMaxX(), transX)); } else {
boolean b1 = (area.getWidth() <= MINIMUM_WIDTH_TO_DRAW); boolean b2 = (area.getHeight() <= MINIMUM_HEIGHT_TO_DRAW); if (b1 || b2) { return; state = new PlotRenderingInfo(null); state.setPlotArea(area); state.setDataArea(dataArea); createAndAddEntity((Rectangle2D) dataArea.clone(), state, null, null); y = rangeAxis.java2DToValue(anchor.getX(), dataArea, getRangeAxisEdge()); Shape savedClip = g2.getClip(); g2.clip(dataArea); boolean suppressShadow = Boolean.TRUE.equals(g2.getRenderingHint( JFreeChart.KEY_SUPPRESS_SHADOW_GENERATION)); if (this.shadowGenerator != null && !suppressShadow) { double yy; if (getOrientation() == PlotOrientation.VERTICAL) { yy = yAxis.java2DToValue(anchor.getY(), dataArea, yAxisEdge);
entities = info.getOwner().getEntityCollection(); Number yQ3Median = boxAndWhiskerData.getQ3Value(series, item); double xx = domainAxis.valueToJava2D(x.doubleValue(), dataArea, plot.getDomainAxisEdge()); double dataAreaX = dataArea.getHeight(); double maxBoxPercent = 0.1; double maxBoxWidth = dataAreaX * maxBoxPercent; g2.setPaint(getItemPaint(series, item)); Stroke s = getItemStroke(series, item); g2.setStroke(s); g2.draw(new Line2D.Double(yyMax, xx, yyQ3Median, xx)); g2.draw(new Line2D.Double(yyMax, xx - width / 2, yyMax, xx + width / 2)); box = new Rectangle2D.Double(yyQ1Median, xx - width / 2, yyQ3Median - yyQ1Median, width); box = new Rectangle2D.Double(yyQ3Median, xx - width / 2, yyQ1Median - yyQ3Median, width);
entities = info.getOwner().getEntityCollection(); - headW / 2, point.getY() - headH / 2, headW, headH); g2.setPaint(paint); g2.fill(head); g2.setStroke(outlineStroke); g2.setPaint(outlinePaint); g2.draw(head); Paint paint = new GradientPaint(new Point2D.Double(rec.getCenterX(),rec.getMinY()), startColor, new Point2D.Double(rec.getCenterX(),rec.getMaxY()), endColor); g2.setPaint(paint);
EntityCollection entities = null; if (info != null) { entities = info.getOwner().getEntityCollection(); Object antiAlias = g2.getRenderingHint(RenderingHints.KEY_ANTIALIASING); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); double transY = 0.0; double transDY = 0.0; double size = dataArea.getWidth() * this.ptSizePct; for (int k = 0; k < x.length; k++) { transX = domainAxis.valueToJava2D(x[k], dataArea, RectangleEdge.BOTTOM) - 0.5 * size; transY = rangeAxis.valueToJava2D(y[k], dataArea, RectangleEdge.LEFT) - 0.5 * size; transDX = size; g2.setPaint(colorBar.getPaint(zNumber[k].doubleValue())); g2.fill(rect);
if (displayCols > displayRows && area.getWidth() < area.getHeight()) { int temp = displayCols; displayCols = displayRows; int x = (int) area.getX(); int y = (int) area.getY(); int width = ((int) area.getWidth()) / displayCols; subinfo = new ChartRenderingInfo(); info.getOwner().getEntityCollection().addAll( subinfo.getEntityCollection()); info.addSubplotInfo(subinfo.getPlotInfo());
info.setPlotArea(area); area.setRect(area.getX() + insets.getLeft(), area.getY() + insets.getTop(), area.getWidth() - insets.getLeft() - insets.getRight(), area.getHeight() - insets.getTop() - insets.getBottom()); PlotRenderingInfo subplotInfo = null; if (info != null) { subplotInfo = new PlotRenderingInfo(info.getOwner()); info.addSubplotInfo(subplotInfo); info.setDataArea(dataArea);
g2.setFont(getTickLabelFont(tick.getCategory())); g2.setPaint(getTickLabelPaint(tick.getCategory())); x1 = x0 - state.getMax(); Rectangle2D area = new Rectangle2D.Double(x0, y0, (x1 - x0), (y1 - y0)); if(r==null || !r.intersects(area)) { Point2D anchorPoint = RectangleAnchor.coordinates(area, position.getCategoryAnchor()); position.getLabelAnchor(), (float) anchorPoint.getX(), (float) anchorPoint.getY(), position.getAngle()); if (plotState != null && plotState.getOwner() != null) { EntityCollection entities = plotState.getOwner().getEntityCollection(); if (entities != null) { String tooltip = getCategoryLabelToolTip(
boolean b1 = (area.getWidth() <= MINIMUM_WIDTH_TO_DRAW); boolean b2 = (area.getHeight() <= MINIMUM_HEIGHT_TO_DRAW); if (b1 || b2) { return; state = new PlotRenderingInfo(null); state.setPlotArea(area); this.axisOffset.trim(dataArea); state.setDataArea(dataArea); createAndAddEntity((Rectangle2D) dataArea.clone(), state, null, null); y = rangeAxis.java2DToValue(anchor.getX(), dataArea, getRangeAxisEdge()); Shape savedClip = g2.getClip(); g2.clip(dataArea); Composite originalComposite = g2.getComposite(); g2.setComposite(AlphaComposite.getInstance( AlphaComposite.SRC_OVER, getForegroundAlpha())); double yy; if (getOrientation() == PlotOrientation.VERTICAL) { yy = yAxis.java2DToValue(anchor.getY(), dataArea, yAxisEdge);
double yHigh = intervalDataset.getEndYValue(series, item); RectangleEdge xAxisLocation = plot.getDomainAxisEdge(); RectangleEdge yAxisLocation = plot.getRangeAxisEdge(); double xx = domainAxis.valueToJava2D(x, dataArea, xAxisLocation); double yyLow = rangeAxis.valueToJava2D(yLow, dataArea, yAxisLocation); double yyHigh = rangeAxis.valueToJava2D(yHigh, dataArea, yAxisLocation); PlotOrientation orientation = plot.getOrientation(); if (orientation == PlotOrientation.HORIZONTAL) { drState.lowerCoordinates.add(new double[] {yyLow, xx}); Composite originalComposite = g2.getComposite(); g2.setComposite(AlphaComposite.getInstance( AlphaComposite.SRC_OVER, this.alpha)); g2.setPaint(getItemFillPaint(series, item)); GeneralPath area = new GeneralPath(GeneralPath.WIND_NON_ZERO, drState.lowerCoordinates.size() entities = info.getOwner().getEntityCollection();
PlotRenderingInfo plotState) { if (plotState == null || plotState.getOwner() == null) { return; // no need to create entity if we can't save it anyways... hotspot = new Rectangle2D.Double(dataArea.getX(), state.getCursor(), dataArea.getWidth(), cursor - state.getCursor()); hotspot = new Rectangle2D.Double(dataArea.getX(), cursor, dataArea.getWidth(), state.getCursor() - cursor); hotspot = new Rectangle2D.Double(state.getCursor(), dataArea.getY(), cursor - state.getCursor(), dataArea.getHeight()); state.getCursor() - cursor, dataArea.getHeight()); EntityCollection e = plotState.getOwner().getEntityCollection(); if (e != null) { e.add(new AxisEntity(hotspot, this));
/** * 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); }
int rendererIndex, PlotRenderingInfo info) { anchorX = domainAxis.valueToJava2D(this.x, dataArea, domainEdge); double maxW = dataArea.getWidth(); double maxH = dataArea.getHeight(); if (this.coordinateType == XYCoordinateType.RELATIVE) { if (this.maxWidth > 0.0) { Rectangle2D titleRect = new Rectangle2D.Double(0, 0, size.width, size.height); Point2D anchorPoint = this.anchor.getAnchorPoint(titleRect); xx = xx - (float) anchorPoint.getX(); yy = yy - (float) anchorPoint.getY(); titleRect.setRect(xx, yy, titleRect.getWidth(), titleRect.getHeight()); BlockParams p = new BlockParams(); if (info != null) { if (info.getOwner().getEntityCollection() != null) { p.setGenerateEntities(true); if (result instanceof EntityBlockResult) { EntityBlockResult ebr = (EntityBlockResult) result; info.getOwner().getEntityCollection().addAll( ebr.getEntityCollection());