List of usage examples for java.awt Graphics2D setPaint
public abstract void setPaint(Paint paint);
From source file:longMethod.jfreechart.draw.XYPolygonAnnotation.java
/** * Draws the annotation. This method is usually called by the * {@link XYPlot} class, you shouldn't need to call it directly. * * @param g2 the graphics device.//from ww w . java 2s. c o m * @param plot the plot. * @param dataArea the data area. * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param rendererIndex the renderer index. * @param info the plot rendering info. */ public void draw(Graphics2D g2, XYPlot plot, Rectangle2D dataArea, ValueAxis domainAxis, ValueAxis rangeAxis, int rendererIndex, PlotRenderingInfo info) { // if we don't have at least 2 (x, y) coordinates, just return if (this.polygon.length < 4) { return; } PlotOrientation orientation = plot.getOrientation(); RectangleEdge domainEdge = Plot.resolveDomainAxisLocation(plot.getDomainAxisLocation(), orientation); RectangleEdge rangeEdge = Plot.resolveRangeAxisLocation(plot.getRangeAxisLocation(), orientation); GeneralPath area = new GeneralPath(); double x = domainAxis.valueToJava2D(this.polygon[0], dataArea, domainEdge); double y = rangeAxis.valueToJava2D(this.polygon[1], dataArea, rangeEdge); if (orientation == PlotOrientation.HORIZONTAL) { area.moveTo((float) y, (float) x); for (int i = 2; i < this.polygon.length; i += 2) { x = domainAxis.valueToJava2D(this.polygon[i], dataArea, domainEdge); y = rangeAxis.valueToJava2D(this.polygon[i + 1], dataArea, rangeEdge); area.lineTo((float) y, (float) x); } area.closePath(); } else if (orientation == PlotOrientation.VERTICAL) { area.moveTo((float) x, (float) y); for (int i = 2; i < this.polygon.length; i += 2) { x = domainAxis.valueToJava2D(this.polygon[i], dataArea, domainEdge); y = rangeAxis.valueToJava2D(this.polygon[i + 1], dataArea, rangeEdge); area.lineTo((float) x, (float) y); } area.closePath(); } if (this.fillPaint != null) { g2.setPaint(this.fillPaint); g2.fill(area); } if (this.stroke != null && this.outlinePaint != null) { g2.setPaint(this.outlinePaint); g2.setStroke(this.stroke); g2.draw(area); } addEntity(info, area, rendererIndex, getToolTipText(), getURL()); }
From source file:edu.cuny.jfree.chart.annotations.CategoryIntervalAnnotation.java
public void draw(final Graphics2D g2, final CategoryPlot plot, final Rectangle2D dataArea, final CategoryAxis domainAxis, final ValueAxis rangeAxis) { final AlphaComposite alphaComposite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, plot.getForegroundAlpha());/*from www. j av a 2 s .c om*/ final Composite oldComposite = g2.getComposite(); g2.setComposite(alphaComposite); final CategoryDataset dataset = plot.getDataset(); final int catIndex = dataset.getColumnIndex(category); final int catCount = dataset.getColumnCount(); double lineX1 = 0.0D; double lineY = 0.0D; double lineX2 = 0.0D; final PlotOrientation orientation = plot.getOrientation(); final RectangleEdge domainEdge = Plot.resolveDomainAxisLocation(plot.getDomainAxisLocation(), orientation); final RectangleEdge rangeEdge = Plot.resolveRangeAxisLocation(plot.getRangeAxisLocation(), orientation); if (orientation == PlotOrientation.HORIZONTAL) { lineY = domainAxis.getCategoryJava2DCoordinate(CategoryAnchor.MIDDLE, catIndex, catCount, dataArea, domainEdge); lineX1 = rangeAxis.valueToJava2D(value1, dataArea, rangeEdge); lineX2 = rangeAxis.valueToJava2D(value2, dataArea, rangeEdge); } else if (orientation == PlotOrientation.VERTICAL) { lineY = rangeAxis.valueToJava2D(value1, dataArea, rangeEdge); lineX1 = domainAxis.getCategoryJava2DCoordinate(CategoryAnchor.MIDDLE, catIndex, catCount, dataArea, domainEdge); lineX2 = domainAxis.getCategoryJava2DCoordinate(CategoryAnchor.MIDDLE, catIndex, catCount, dataArea, domainEdge); } g2.setPaint(paint); g2.setStroke(stroke); g2.drawLine((int) lineX1, (int) lineY, (int) lineX2, (int) lineY); g2.setComposite(oldComposite); }
From source file:soap.ui.stats.LineAndShapeRendererMapToBar.java
public void drawItem(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryDataset dataset, int row, int column) { // nothing is drawn for null... Number v = dataset.getValue(row, column); if (v == null) return;//from w ww . j a v a 2 s .c om PlotOrientation orientation = plot.getOrientation(); // current data point which is associated to a serie... double x1 = domainAxis.getCategoryStart(column, getColumnCount(), dataArea, plot.getDomainAxisEdge()); int seriesCount = mBarRenderer.getPlot().getDataset().getRowCount(); int categoryCount = mBarRenderer.getPlot().getDataset().getColumnCount(); if (seriesCount > 1 && mNumSerie < seriesCount) { double seriesGap = dataArea.getWidth() * 0.2 / (categoryCount * (seriesCount - 1)); double seriesW = calculateSeriesWidth(dataArea.getWidth(), domainAxis, categoryCount, seriesCount); x1 = x1 + mNumSerie * (seriesW + seriesGap) + (seriesW / 2.0) - (state.getBarWidth() / 2.0); } else { x1 = domainAxis.getCategoryMiddle(column, getColumnCount(), dataArea, plot.getDomainAxisEdge()); } double value = v.doubleValue(); double y1 = rangeAxis.valueToJava2D(value, dataArea, plot.getRangeAxisEdge()); Shape shape = getItemShape(row, column); if (orientation == PlotOrientation.HORIZONTAL) { shape = createTransformedShape(shape, y1, x1); } else if (orientation == PlotOrientation.VERTICAL) { shape = createTransformedShape(shape, x1, y1); } if (isDrawShapes()) { if (getItemShapeFilled(row, column)) { g2.setPaint(getItemPaint(row, column)); g2.fill(shape); } else { g2.setPaint(getItemOutlinePaint(row, column)); g2.setStroke(getItemOutlineStroke(row, column)); g2.draw(shape); } } if (isDrawLines()) { if (column != 0) { Number previousValue = dataset.getValue(row, column - 1); if (previousValue != null) { // previous data point... double previous = previousValue.doubleValue(); double x0 = domainAxis.getCategoryStart(column - 1, getColumnCount(), dataArea, plot.getDomainAxisEdge()); // seriesCount = getRowCount(); // categoryCount = getColumnCount(); if (seriesCount > 1 && mNumSerie < seriesCount) { double seriesGap = dataArea.getWidth() * 0.2 / (categoryCount * (seriesCount - 1)); double seriesW = calculateSeriesWidth(dataArea.getWidth(), domainAxis, categoryCount, seriesCount); x0 = x0 + mNumSerie * (seriesW + seriesGap) + (seriesW / 2.0) - (state.getBarWidth() / 2.0); } else { x0 = domainAxis.getCategoryMiddle(column - 1, getColumnCount(), dataArea, plot.getDomainAxisEdge()); } double y0 = rangeAxis.valueToJava2D(previous, dataArea, plot.getRangeAxisEdge()); Line2D line = null; if (orientation == PlotOrientation.HORIZONTAL) { line = new Line2D.Double(y0, x0, y1, x1); } else if (orientation == PlotOrientation.VERTICAL) { line = new Line2D.Double(x0, y0, x1, y1); } g2.setPaint(getItemPaint(row, column)); g2.setStroke(getItemStroke(row, column)); g2.draw(line); } } } // draw the item label if there is one... if (isItemLabelVisible(row, column)) { if (orientation == PlotOrientation.HORIZONTAL) { drawItemLabel(g2, orientation, dataset, row, column, y1, x1, (value < 0.0)); } else if (orientation == PlotOrientation.VERTICAL) { drawItemLabel(g2, orientation, dataset, row, column, x1, y1, (value < 0.0)); } } // collect entity and tool tip information... if (state.getInfo() != null) { EntityCollection entities = state.getInfo().getOwner().getEntityCollection(); if (entities != null && shape != null) { String tip = null; CategoryToolTipGenerator tipster = getToolTipGenerator(row, column); if (tipster != null) { tip = tipster.generateToolTip(dataset, row, column); } String url = null; if (getItemURLGenerator(row, column) != null) { url = getItemURLGenerator(row, column).generateURL(dataset, row, column); } CategoryItemEntity entity = new CategoryItemEntity(shape, tip, url, dataset, row, dataset.getColumnKey(column), column); entities.addEntity(entity); } } }
From source file:ClipImage.java
public void drawDemo(Graphics2D g2) { if (newBufferedImage) { x = Math.random() * w;//from w w w . j a v a 2 s . com y = Math.random() * h; ew = (Math.random() * w) / 2; eh = (Math.random() * h) / 2; } x += ix; y += iy; ew += iw; eh += ih; if (ew > w / 2) { ew = w / 2; iw = Math.random() * -w / 16 - 1; } if (ew < w / 8) { ew = w / 8; iw = Math.random() * w / 16 + 1; } if (eh > h / 2) { eh = h / 2; ih = Math.random() * -h / 16 - 1; } if (eh < h / 8) { eh = h / 8; ih = Math.random() * h / 16 + 1; } if ((x + ew) > w) { x = (w - ew) - 1; ix = Math.random() * -w / 32 - 1; } if (x < 0) { x = 2; ix = Math.random() * w / 32 + 1; } if ((y + eh) > h) { y = (h - eh) - 2; iy = Math.random() * -h / 32 - 1; } if (y < 0) { y = 2; iy = Math.random() * h / 32 + 1; } ellipse.setFrame(x, y, ew, eh); g2.setClip(ellipse); rect.setRect(x + 5, y + 5, ew - 10, eh - 10); g2.clip(rect); g2.drawImage(img, 0, 0, w, h, this); p.reset(); p.moveTo(-w / 2.0f, -h / 8.0f); p.lineTo(+w / 2.0f, -h / 8.0f); p.lineTo(-w / 4.0f, +h / 2.0f); p.lineTo(+0.0f, -h / 2.0f); p.lineTo(+w / 4.0f, +h / 2.0f); p.closePath(); at.setToIdentity(); at.translate(w * .5f, h * .5f); g2.transform(at); g2.setStroke(bs); g2.setPaint(redBlend); g2.draw(p); at.setToIdentity(); g2.setTransform(at); g2.setPaint(greenBlend); for (int yy = 0; yy < h; yy += 50) { for (int xx = 0, i = 0; xx < w; i++, xx += 50) { switch (i) { case 0: arc.setArc(xx, yy, 25, 25, 45, 270, Arc2D.PIE); g2.fill(arc); break; case 1: ellipse.setFrame(xx, yy, 25, 25); g2.fill(ellipse); break; case 2: roundRect.setRoundRect(xx, yy, 25, 25, 4, 4); g2.fill(roundRect); break; case 3: rect.setRect(xx, yy, 25, 25); g2.fill(rect); i = -1; } } } }
From source file:net.sf.maltcms.chromaui.charts.FastHeatMapPlot.java
/** * Draws the gridlines for the plot, if they are visible. * * @param g2 the graphics device.// w w w. j a va 2 s. co m * @param dataArea the data area. * @param ticks the ticks. */ @Override protected void drawRangeGridlines(Graphics2D g2, Rectangle2D dataArea, List ticks) { // draw the range grid lines, if the flag says they're visible... if (isRangeGridlinesVisible()) { Iterator iterator = ticks.iterator(); while (iterator.hasNext()) { ValueTick tick = (ValueTick) iterator.next(); double v = this.rangeAxis.valueToJava2D(tick.getValue(), dataArea, RectangleEdge.LEFT); Line2D line = new Line2D.Double(dataArea.getMinX(), v, dataArea.getMaxX(), v); g2.setPaint(getRangeGridlinePaint()); g2.setStroke(getRangeGridlineStroke()); g2.draw(line); } } }
From source file:net.sf.maltcms.chromaui.charts.FastHeatMapPlot.java
/** * Draws the gridlines for the plot, if they are visible. * * @param g2 the graphics device./* www . j a va2s . co m*/ * @param dataArea the data area. * @param ticks the ticks. */ @Override protected void drawDomainGridlines(Graphics2D g2, Rectangle2D dataArea, List ticks) { // draw the domain grid lines, if the flag says they're visible... if (isDomainGridlinesVisible()) { Iterator iterator = ticks.iterator(); while (iterator.hasNext()) { ValueTick tick = (ValueTick) iterator.next(); double v = this.domainAxis.valueToJava2D(tick.getValue(), dataArea, RectangleEdge.BOTTOM); Line2D line = new Line2D.Double(v, dataArea.getMinY(), v, dataArea.getMaxY()); g2.setPaint(getDomainGridlinePaint()); g2.setStroke(getDomainGridlineStroke()); g2.draw(line); } } }
From source file:ClipImage.java
public void drawDemo(Graphics2D g2) { if (newBufferedImage) { x = Math.random() * w;/*from w ww . j ava 2 s . c o m*/ y = Math.random() * h; ew = (Math.random() * w) / 2; eh = (Math.random() * h) / 2; } x += ix; y += iy; ew += iw; eh += ih; if (ew > w / 2) { ew = w / 2; iw = Math.random() * -w / 16 - 1; } if (ew < w / 8) { ew = w / 8; iw = Math.random() * w / 16 + 1; } if (eh > h / 2) { eh = h / 2; ih = Math.random() * -h / 16 - 1; } if (eh < h / 8) { eh = h / 8; ih = Math.random() * h / 16 + 1; } if ((x + ew) > w) { x = (w - ew) - 1; ix = Math.random() * -w / 32 - 1; } if (x < 0) { x = 2; ix = Math.random() * w / 32 + 1; } if ((y + eh) > h) { y = (h - eh) - 2; iy = Math.random() * -h / 32 - 1; } if (y < 0) { y = 2; iy = Math.random() * h / 32 + 1; } ellipse.setFrame(x, y, ew, eh); g2.setClip(ellipse); rect.setRect(x + 5, y + 5, ew - 10, eh - 10); g2.clip(rect); g2.drawImage(img, 0, 0, w, h, this); p.reset(); p.moveTo(-w / 2.0f, -h / 8.0f); p.lineTo(+w / 2.0f, -h / 8.0f); p.lineTo(-w / 4.0f, +h / 2.0f); p.lineTo(+0.0f, -h / 2.0f); p.lineTo(+w / 4.0f, +h / 2.0f); p.closePath(); at.setToIdentity(); at.translate(w * .5f, h * .5f); g2.transform(at); g2.setStroke(bs); g2.setPaint(redBlend); g2.draw(p); at.setToIdentity(); g2.setTransform(at); g2.setPaint(greenBlend); for (int yy = 0; yy < h; yy += 50) { for (int xx = 0, i = 0; xx < w; i++, xx += 50) { switch (i) { case 0: arc.setArc(xx, yy, 25, 25, 45, 270, Arc2D.PIE); g2.fill(arc); break; case 1: ellipse.setFrame(xx, yy, 25, 25); g2.fill(ellipse); break; case 2: roundRect.setRoundRect(xx, yy, 25, 25, 4, 4); g2.fill(roundRect); break; case 3: rect.setRect(xx, yy, 25, 25); g2.fill(rect); i = -1; } } } }
From source file:msi.gama.outputs.layers.charts.StandardXYItemRenderer.java
/** * Draws the visual representation of a single data item. * * @param g2/*from www. j a v a 2s. c o m*/ * the graphics device. * @param state * the renderer state. * @param dataArea * the area within which the data is being drawn. * @param info * collects information about the drawing. * @param plot * the plot (can be used to obtain standard color information etc). * @param domainAxis * the domain axis. * @param rangeAxis * the range axis. * @param dataset * the dataset. * @param series * the series index (zero-based). * @param item * the item index (zero-based). * @param crosshairState * crosshair information for the plot (<code>null</code> permitted). * @param pass * the pass index. */ @Override public void drawItem(final Graphics2D g2, final XYItemRendererState state, final Rectangle2D dataArea, final PlotRenderingInfo info, final XYPlot plot, final ValueAxis domainAxis, final ValueAxis rangeAxis, final XYDataset dataset, final int series, final int item, final CrosshairState crosshairState, final int pass) { boolean itemVisible = getItemVisible(series, item); // setup for collecting optional entity info... Shape entityArea = null; EntityCollection entities = null; if (info != null) { entities = info.getOwner().getEntityCollection(); } final PlotOrientation orientation = plot.getOrientation(); final Paint paint = getItemPaint(series, item); final Stroke seriesStroke = getItemStroke(series, item); g2.setPaint(paint); g2.setStroke(seriesStroke); // get the data point... final double x1 = dataset.getXValue(series, item); final double y1 = dataset.getYValue(series, item); if (Double.isNaN(x1) || Double.isNaN(y1)) { itemVisible = false; } final RectangleEdge xAxisLocation = plot.getDomainAxisEdge(); final RectangleEdge yAxisLocation = plot.getRangeAxisEdge(); final double transX1 = domainAxis.valueToJava2D(x1, dataArea, xAxisLocation); final double transY1 = rangeAxis.valueToJava2D(y1, dataArea, yAxisLocation); if (getPlotLines()) { if (this.drawSeriesLineAsPath) { final State s = (State) state; if (s.getSeriesIndex() != series) { // we are starting a new series path s.seriesPath.reset(); s.lastPointGood = false; s.setSeriesIndex(series); } // update path to reflect latest point if (itemVisible && !Double.isNaN(transX1) && !Double.isNaN(transY1)) { float x = (float) transX1; float y = (float) transY1; if (orientation == PlotOrientation.HORIZONTAL) { x = (float) transY1; y = (float) transX1; } if (s.isLastPointGood()) { // TODO: check threshold s.seriesPath.lineTo(x, y); } else { s.seriesPath.moveTo(x, y); } s.setLastPointGood(true); } else { s.setLastPointGood(false); } if (item == dataset.getItemCount(series) - 1) { if (s.seriesIndex == series) { // draw path g2.setStroke(lookupSeriesStroke(series)); g2.setPaint(lookupSeriesPaint(series)); g2.draw(s.seriesPath); } } } else if (item != 0 && itemVisible) { // get the previous data point... final double x0 = dataset.getXValue(series, item - 1); final double y0 = dataset.getYValue(series, item - 1); if (!Double.isNaN(x0) && !Double.isNaN(y0)) { boolean drawLine = true; if (getPlotDiscontinuous()) { // only draw a line if the gap between the current and // previous data point is within the threshold final int numX = dataset.getItemCount(series); final double minX = dataset.getXValue(series, 0); final double maxX = dataset.getXValue(series, numX - 1); if (this.gapThresholdType == UnitType.ABSOLUTE) { drawLine = Math.abs(x1 - x0) <= this.gapThreshold; } else { drawLine = Math.abs(x1 - x0) <= (maxX - minX) / numX * getGapThreshold(); } } if (drawLine) { final double transX0 = domainAxis.valueToJava2D(x0, dataArea, xAxisLocation); final double transY0 = rangeAxis.valueToJava2D(y0, dataArea, yAxisLocation); // only draw if we have good values if (Double.isNaN(transX0) || Double.isNaN(transY0) || Double.isNaN(transX1) || Double.isNaN(transY1)) { return; } if (orientation == PlotOrientation.HORIZONTAL) { state.workingLine.setLine(transY0, transX0, transY1, transX1); } else if (orientation == PlotOrientation.VERTICAL) { state.workingLine.setLine(transX0, transY0, transX1, transY1); } if (state.workingLine.intersects(dataArea)) { g2.draw(state.workingLine); } } } } } // we needed to get this far even for invisible items, to ensure that // seriesPath updates happened, but now there is nothing more we need // to do for non-visible items... if (!itemVisible) { return; } if (getBaseShapesVisible()) { Shape shape = getItemShape(series, item); if (orientation == PlotOrientation.HORIZONTAL) { shape = ShapeUtilities.createTranslatedShape(shape, transY1, transX1); } else if (orientation == PlotOrientation.VERTICAL) { shape = ShapeUtilities.createTranslatedShape(shape, transX1, transY1); } if (shape.intersects(dataArea)) { if (getItemShapeFilled(series, item)) { g2.fill(shape); } else { g2.draw(shape); } } entityArea = shape; } if (getPlotImages()) { final Image image = getImage(plot, series, item, transX1, transY1); if (image != null) { final Point hotspot = getImageHotspot(plot, series, item, transX1, transY1, image); g2.drawImage(image, (int) (transX1 - hotspot.getX()), (int) (transY1 - hotspot.getY()), null); entityArea = new Rectangle2D.Double(transX1 - hotspot.getX(), transY1 - hotspot.getY(), image.getWidth(null), image.getHeight(null)); } } double xx = transX1; double yy = transY1; if (orientation == PlotOrientation.HORIZONTAL) { xx = transY1; yy = transX1; } // draw the item label if there is one... if (isItemLabelVisible(series, item)) { drawItemLabel(g2, orientation, dataset, series, item, xx, yy, y1 < 0.0); } final int domainAxisIndex = plot.getDomainAxisIndex(domainAxis); final int rangeAxisIndex = plot.getRangeAxisIndex(rangeAxis); updateCrosshairValues(crosshairState, x1, y1, domainAxisIndex, rangeAxisIndex, transX1, transY1, orientation); // add an entity for the item... if (entities != null && isPointInRect(dataArea, xx, yy)) { addEntity(entities, entityArea, dataset, series, item, xx, yy); } }
From source file:com.att.aro.ui.view.diagnostictab.CreateBarPlot.java
public XYPlot drawYIntervalPlot() { // Create the plot renderer YIntervalRenderer renderer = new YIntervalRenderer() { private static final long serialVersionUID = 1L; public void drawItem(Graphics2D g2, XYItemRendererState state, Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item, CrosshairState crosshairState, int pass) { // setup for collecting optional entity info... Shape entityArea = null; EntityCollection entities = null; if (info != null) { entities = info.getOwner().getEntityCollection(); }//from w w w . j ava 2s .c o m IntervalXYDataset intervalDataset = (IntervalXYDataset) dataset; double x = intervalDataset.getXValue(series, item); double yLow = intervalDataset.getStartYValue(series, item); 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); Paint p = getItemPaint(series, item); Stroke s = getItemStroke(series, item); Line2D line = null; PlotOrientation orientation = plot.getOrientation(); if (orientation == PlotOrientation.HORIZONTAL) { line = new Line2D.Double(yyLow, xx, yyHigh, xx); } else if (orientation == PlotOrientation.VERTICAL) { line = new Line2D.Double(xx, yyLow, xx, yyHigh); } g2.setPaint(p); g2.setStroke(s); g2.draw(line); // add an entity for the item... if (entities != null && line != null) { if (entityArea == null) { entityArea = line.getBounds(); } String tip = null; XYToolTipGenerator generator = getToolTipGenerator(series, item); if (generator != null) { tip = generator.generateToolTip(dataset, series, item); } XYItemEntity entity = new XYItemEntity(entityArea, dataset, series, item, tip, null); entities.add(entity); } } }; renderer.setAdditionalItemLabelGenerator(null); renderer.setBaseShape(new Rectangle()); renderer.setAutoPopulateSeriesShape(false); renderer.setAutoPopulateSeriesPaint(false); renderer.setBasePaint(Color.GRAY); // Create the plot XYPlot plot = new XYPlot(null, null, new NumberAxis(), renderer); plot.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT); plot.getRangeAxis().setVisible(false); return plot; }
From source file:nl.strohalm.cyclos.utils.jfreeAsymmetric.AsymmetricStatisticalLineAndShapeRenderer.java
/** * Draw a single data item./*from w w w . j av a2s .c om*/ * * @param g2 the graphics device. * @param state the renderer state. * @param dataArea the area in which the data is drawn. * @param plot the plot. * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param dataset the dataset (a {@link StatisticalCategoryDataset} is required). * @param row the row index (zero-based). * @param column the column index (zero-based). * @param pass the pass. */ @Override public void drawItem(final Graphics2D g2, final CategoryItemRendererState state, final Rectangle2D dataArea, final CategoryPlot plot, final CategoryAxis domainAxis, final ValueAxis rangeAxis, final CategoryDataset dataset, final int row, final int column, final int pass) { // nothing is drawn for null... final Number v = dataset.getValue(row, column); if (v == null) { return; } // *************** This line was changed relative to StatisticalLineAndShapeRenderer***** final AsymmetricStatisticalCategoryDataset statData = (AsymmetricStatisticalCategoryDataset) dataset; // *************** end of changed line ********************************************** final Number meanValue = statData.getMeanValue(row, column); final PlotOrientation orientation = plot.getOrientation(); // current data point... final double x1 = domainAxis.getCategoryMiddle(column, getColumnCount(), dataArea, plot.getDomainAxisEdge()); final double y1 = rangeAxis.valueToJava2D(meanValue.doubleValue(), dataArea, plot.getRangeAxisEdge()); Shape shape = getItemShape(row, column); if (orientation == PlotOrientation.HORIZONTAL) { shape = ShapeUtilities.createTranslatedShape(shape, y1, x1); } else if (orientation == PlotOrientation.VERTICAL) { shape = ShapeUtilities.createTranslatedShape(shape, x1, y1); } if (getItemShapeVisible(row, column)) { if (getItemShapeFilled(row, column)) { g2.setPaint(getItemPaint(row, column)); g2.fill(shape); } else { if (getUseOutlinePaint()) { g2.setPaint(getItemOutlinePaint(row, column)); } else { g2.setPaint(getItemPaint(row, column)); } g2.setStroke(getItemOutlineStroke(row, column)); g2.draw(shape); } } if (getItemLineVisible(row, column)) { if (column != 0) { final Number previousValue = statData.getValue(row, column - 1); if (previousValue != null) { // previous data point... final double previous = previousValue.doubleValue(); final double x0 = domainAxis.getCategoryMiddle(column - 1, getColumnCount(), dataArea, plot.getDomainAxisEdge()); final double y0 = rangeAxis.valueToJava2D(previous, dataArea, plot.getRangeAxisEdge()); Line2D line = null; if (orientation == PlotOrientation.HORIZONTAL) { line = new Line2D.Double(y0, x0, y1, x1); } else if (orientation == PlotOrientation.VERTICAL) { line = new Line2D.Double(x0, y0, x1, y1); } g2.setPaint(getItemPaint(row, column)); g2.setStroke(getItemStroke(row, column)); g2.draw(line); } } } final RectangleEdge yAxisLocation = plot.getRangeAxisEdge(); final RectangleEdge xAxisLocation = plot.getDomainAxisEdge(); double rectX = domainAxis.getCategoryStart(column, getColumnCount(), dataArea, xAxisLocation); rectX = rectX + row * state.getBarWidth(); g2.setPaint(getItemPaint(row, column)); // ************* This is the block with changes relative to StatisticalLineAndShapeRenderer ********* // standard deviation lines final Number highValObj = statData.getUpperValue(row, column); final Number lowValObj = statData.getLowerValue(row, column); if (highValObj != null && lowValObj != null) { // rinke added this test double highVal = highValObj.doubleValue(); double lowVal = lowValObj.doubleValue(); if (highVal > rangeAxis.getRange().getUpperBound()) { highVal = rangeAxis.valueToJava2D(rangeAxis.getRange().getUpperBound(), dataArea, yAxisLocation); } else { highVal = rangeAxis.valueToJava2D(highVal, dataArea, yAxisLocation); } if (lowVal < rangeAxis.getRange().getLowerBound()) { lowVal = rangeAxis.valueToJava2D(rangeAxis.getRange().getLowerBound(), dataArea, yAxisLocation); } else { lowVal = rangeAxis.valueToJava2D(lowVal, dataArea, yAxisLocation); } // ****************** end of changed block ********************************** if (errorIndicatorPaint != null) { g2.setPaint(errorIndicatorPaint); } else { g2.setPaint(getItemPaint(row, column)); } final Line2D line = new Line2D.Double(); if (orientation == PlotOrientation.HORIZONTAL) { line.setLine(lowVal, x1, highVal, x1); g2.draw(line); line.setLine(lowVal, x1 - 5.0d, lowVal, x1 + 5.0d); g2.draw(line); line.setLine(highVal, x1 - 5.0d, highVal, x1 + 5.0d); g2.draw(line); } else { // PlotOrientation.VERTICAL line.setLine(x1, lowVal, x1, highVal); g2.draw(line); line.setLine(x1 - 5.0d, highVal, x1 + 5.0d, highVal); g2.draw(line); line.setLine(x1 - 5.0d, lowVal, x1 + 5.0d, lowVal); g2.draw(line); } } // draw the item label if there is one... if (isItemLabelVisible(row, column)) { if (orientation == PlotOrientation.HORIZONTAL) { drawItemLabel(g2, orientation, dataset, row, column, y1, x1, (meanValue.doubleValue() < 0.0)); } else if (orientation == PlotOrientation.VERTICAL) { drawItemLabel(g2, orientation, dataset, row, column, x1, y1, (meanValue.doubleValue() < 0.0)); } } // collect entity and tool tip information... if (state.getInfo() != null) { final EntityCollection entities = state.getEntityCollection(); if (entities != null && shape != null) { String tip = null; final CategoryToolTipGenerator tipster = getToolTipGenerator(row, column); if (tipster != null) { tip = tipster.generateToolTip(dataset, row, column); } String url = null; if (getItemURLGenerator(row, column) != null) { url = getItemURLGenerator(row, column).generateURL(dataset, row, column); } final CategoryItemEntity entity = new CategoryItemEntity(shape, tip, url, dataset, row, dataset.getColumnKey(column), column); entities.add(entity); } } }