List of usage examples for java.awt.geom Rectangle2D getWidth
public abstract double getWidth();
From source file:net.sourceforge.processdash.ui.web.reports.RadarPlot.java
protected void drawRadar(Graphics2D g2, Rectangle2D plotArea, PlotRenderingInfo info, int pieIndex, PieDataset data) {/*w w w .j ava 2 s. c om*/ // adjust the plot area by the interior spacing value double gapHorizontal = plotArea.getWidth() * this.interiorGap; double gapVertical = plotArea.getHeight() * this.interiorGap; double radarX = plotArea.getX() + gapHorizontal / 2; double radarY = plotArea.getY() + gapVertical / 2; double radarW = plotArea.getWidth() - gapHorizontal; double radarH = plotArea.getHeight() - gapVertical; // make the radar area a square if the radar chart is to be circular... // NOTE that non-circular radar charts are not currently supported. if (true) { //circular) { double min = Math.min(radarW, radarH) / 2; radarX = (radarX + radarX + radarW) / 2 - min; radarY = (radarY + radarY + radarH) / 2 - min; radarW = 2 * min; radarH = 2 * min; } double radius = radarW / 2; double centerX = radarX + radarW / 2; double centerY = radarY + radarH / 2; Rectangle2D radarArea = new Rectangle2D.Double(radarX, radarY, radarW, radarH); // plot the data (unless the dataset is null)... if ((data != null) && (data.getKeys().size() > 0)) { // get a list of categories... List keys = data.getKeys(); int numAxes = keys.size(); // draw each of the axes on the radar chart, and register // the shape of the radar line. double multiplier = 1.0; GeneralPath lineShape = new GeneralPath(GeneralPath.WIND_NON_ZERO, numAxes + 1); GeneralPath gridShape = new GeneralPath(GeneralPath.WIND_NON_ZERO, numAxes + 1); int axisNumber = -1; Iterator iterator = keys.iterator(); while (iterator.hasNext()) { Comparable currentKey = (Comparable) iterator.next(); axisNumber++; Number dataValue = data.getValue(currentKey); double value = (dataValue != null ? dataValue.doubleValue() : 0); if (value > 1 || Double.isNaN(value) || Double.isInfinite(value)) value = 1.0; if (value < 0) value = 0.0; multiplier *= value; double angle = 2 * Math.PI * axisNumber / numAxes; double deltaX = Math.sin(angle) * radius; double deltaY = -Math.cos(angle) * radius; // draw the spoke g2.setPaint(axisPaint); g2.setStroke(axisStroke); Line2D line = new Line2D.Double(centerX, centerY, centerX + deltaX, centerY + deltaY); g2.draw(line); // register the grid line and the shape line if (axisNumber == 0) { gridShape.moveTo((float) deltaX, (float) deltaY); lineShape.moveTo((float) (deltaX * value), (float) (deltaY * value)); } else { gridShape.lineTo((float) deltaX, (float) deltaY); lineShape.lineTo((float) (deltaX * value), (float) (deltaY * value)); } if (showAxisLabels) { // draw the label double labelX = centerX + deltaX * (1 + axisLabelGap); double labelY = centerY + deltaY * (1 + axisLabelGap); String label = currentKey.toString(); drawLabel(g2, radarArea, label, axisNumber, labelX, labelY); } } gridShape.closePath(); lineShape.closePath(); // draw five gray concentric gridlines g2.translate(centerX, centerY); g2.setPaint(gridLinePaint); g2.setStroke(gridLineStroke); for (int i = 5; i > 0; i--) { Shape scaledGrid = gridShape .createTransformedShape(AffineTransform.getScaleInstance(i / 5.0, i / 5.0)); g2.draw(scaledGrid); } // get the color for the plot shape. Paint dataPaint = plotLinePaint; if (dataPaint == ADAPTIVE_COLORING) { //multiplier = Math.exp(Math.log(multiplier) * 2 / numAxes); dataPaint = getMultiplierColor((float) multiplier); } // compute a slightly transparent version of the plot color for // the fill. Paint dataFill = null; if (dataPaint instanceof Color && getForegroundAlpha() != 1.0) dataFill = new Color(((Color) dataPaint).getRed() / 255f, ((Color) dataPaint).getGreen() / 255f, ((Color) dataPaint).getBlue() / 255f, getForegroundAlpha()); else dataFill = dataPaint; // draw the plot shape. First fill with a parially // transparent color, then stroke with the opaque color. g2.setPaint(dataFill); g2.fill(lineShape); g2.setPaint(dataPaint); g2.setStroke(plotLineStroke); g2.draw(lineShape); // cleanup the graphics context. g2.translate(-centerX, -centerY); } }
From source file:at.tuwien.ifs.somtoolbox.visualization.thematicmap.SOMRegion.java
public void fillRegion(Graphics2D g, boolean chessboard) { if (!resolved) { fillcolor = getColor(mainClass.classIndex); Color c = repairColor(fillcolor); g.setColor(c);/* w w w. j av a 2s . c om*/ if (segments.isEmpty()) { return; } g.fillPolygon(this); } else { if (chessboard) { if (polygons == null) { // calculate polygons polygons = new ArrayList<Polygon>(); Rectangle2D rect = getBounds2D(); double w = rect.getWidth(); double h = rect.getHeight(); if (h > 200 || w > 200) { Logger.getLogger("at.tuwien.ifs.somtoolbox").info("ERROR: h>200 || w>200"); return; } int x = (int) rect.getX(); int y = (int) rect.getY(); int xSteps = (int) (w / (int) Grid.SIZE); int ySteps = (int) (h / (int) Grid.SIZE); // int n = classes.size(); for (int i = 0; i < xSteps; i++) { for (int j = 0; j < ySteps; j++) { Polygon p = new Polygon(); p.addPoint((int) (x + i * Grid.SIZE), (int) (y + j * Grid.SIZE)); p.addPoint((int) (x + i * Grid.SIZE + Grid.SIZE), (int) (y + j * Grid.SIZE)); p.addPoint((int) (x + i * Grid.SIZE + Grid.SIZE), (int) (y + Grid.SIZE + j * Grid.SIZE)); p.addPoint((int) (x + i * Grid.SIZE), (int) (y + Grid.SIZE + j * Grid.SIZE)); if (!this.contains(p.getBounds())) { continue; } SOMClass clss = indexGenerator.getNextIndex(); g.setColor(getColor(clss.classIndex)); g.fillPolygon(p); polygons.add(p); } } } else { // use pre-calculated polygons for (int i = 0; i < polygons.size(); i++) { SOMClass clss = indexGenerator.getNextIndex(); g.setColor(getColor(clss.classIndex)); Polygon p = polygons.get(i); g.fillPolygon(p); } } } else { for (int i = 0; i < grids.size(); i++) { Grid grid = grids.get(i); if (grid.clss == null) { continue; } g.setColor(getColor(grid.clss.classIndex)); g.fillRect((int) grid.topLeft.coord(0), (int) grid.topLeft.coord(1), (int) Grid.SIZE, (int) Grid.SIZE); } } } }
From source file:de.hs.mannheim.modUro.controller.diagram.fx.interaction.ZoomHandlerFX.java
@Override public void handleMouseReleased(ChartCanvas canvas, MouseEvent e) { Plot p = canvas.getChart().getPlot(); if (!(p instanceof Zoomable)) { return;/* w w w . j a v a 2 s.co m*/ } boolean hZoom, vZoom; Zoomable z = (Zoomable) p; if (z.getOrientation().isHorizontal()) { hZoom = z.isRangeZoomable(); vZoom = z.isDomainZoomable(); } else { hZoom = z.isDomainZoomable(); vZoom = z.isRangeZoomable(); } boolean zoomTrigger1 = hZoom && Math.abs(e.getX() - this.startPoint.getX()) >= 10; boolean zoomTrigger2 = vZoom && Math.abs(e.getY() - this.startPoint.getY()) >= 10; if (zoomTrigger1 || zoomTrigger2) { Point2D endPoint = new Point2D.Double(e.getX(), e.getY()); PlotRenderingInfo pri = canvas.getRenderingInfo().getPlotInfo(); if ((hZoom && (e.getX() < this.startPoint.getX())) || (vZoom && (e.getY() < this.startPoint.getY()))) { boolean saved = p.isNotify(); p.setNotify(false); z.zoomDomainAxes(0, pri, endPoint); z.zoomRangeAxes(0, pri, endPoint); p.setNotify(saved); } else { double x = this.startPoint.getX(); double y = this.startPoint.getY(); double w = e.getX() - x; double h = e.getY() - y; Rectangle2D dataArea = canvas.findDataArea(this.startPoint); double maxX = dataArea.getMaxX(); double maxY = dataArea.getMaxY(); // for mouseReleased event, (horizontalZoom || verticalZoom) // will be true, so we can just test for either being false; // otherwise both are true if (!vZoom) { y = dataArea.getMinY(); w = Math.min(w, maxX - this.startPoint.getX()); h = dataArea.getHeight(); } else if (!hZoom) { x = dataArea.getMinX(); w = dataArea.getWidth(); h = Math.min(h, maxY - this.startPoint.getY()); } else { w = Math.min(w, maxX - this.startPoint.getX()); h = Math.min(h, maxY - this.startPoint.getY()); } Rectangle2D zoomArea = new Rectangle2D.Double(x, y, w, h); boolean saved = p.isNotify(); p.setNotify(false); double pw0 = percentW(x, dataArea); double pw1 = percentW(x + w, dataArea); double ph0 = percentH(y, dataArea); double ph1 = percentH(y + h, dataArea); PlotRenderingInfo info = this.viewer.getRenderingInfo().getPlotInfo(); if (z.getOrientation().isVertical()) { z.zoomDomainAxes(pw0, pw1, info, endPoint); z.zoomRangeAxes(1 - ph1, 1 - ph0, info, endPoint); } else { z.zoomRangeAxes(pw0, pw1, info, endPoint); z.zoomDomainAxes(1 - ph1, 1 - ph0, info, endPoint); } p.setNotify(saved); } } viewer.hideZoomRectangle(); this.startPoint = null; canvas.clearLiveHandler(); }
From source file:org.apache.pdfbox.rendering.PageDrawer.java
@Override public void fillPath(int windingRule) throws IOException { graphics.setComposite(getGraphicsState().getNonStrokingJavaComposite()); graphics.setPaint(getNonStrokingPaint()); setClip();// w w w . ja va 2 s. com linePath.setWindingRule(windingRule); // disable anti-aliasing for rectangular paths, this is a workaround to avoid small stripes // which occur when solid fills are used to simulate piecewise gradients, see PDFBOX-2302 // note that we ignore paths with a width/height under 1 as these are fills used as strokes, // see PDFBOX-1658 for an example Rectangle2D bounds = linePath.getBounds2D(); boolean noAntiAlias = isRectangular(linePath) && bounds.getWidth() > 1 && bounds.getHeight() > 1; if (noAntiAlias) { graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } if (!(graphics.getPaint() instanceof Color)) { // apply clip to path to avoid oversized device bounds in shading contexts (PDFBOX-2901) Area area = new Area(linePath); area.intersect(new Area(graphics.getClip())); graphics.fill(area); } else { graphics.fill(linePath); } linePath.reset(); if (noAntiAlias) { // JDK 1.7 has a bug where rendering hints are reset by the above call to // the setRenderingHint method, so we re-set all hints, see PDFBOX-2302 setRenderingHints(); } }
From source file:org.tsho.dmc2.core.chart.LyapunovRenderer.java
public boolean renderVsTime(Graphics2D g2, Rectangle2D dataArea) { final int imageWidth = (int) dataArea.getWidth(); g2.setPaint(Color.red);//from ww w . j a v a 2s. co m final int timeStep; if (Math.abs(upper - lower) >= imageWidth) { timeStep = ((int) upper - (int) lower) / imageWidth; } else { timeStep = 1; } int prevX[] = new int[model.getNVar()]; int prevY[] = new int[model.getNVar()]; //? 14.7.2004 //LyapunovExpCalc lyapunovExpCalc; LuaLyapExp integrator = new LuaLyapExp(model, parameters, initialPoint); String colNames[] = new String[model.getNVar() + 1]; colNames[0] = "time"; for (int j = 1; j < model.getNVar() + 1; j++) colNames[j] = "" + (new Integer(j)); Dataset dataset = new Dataset(colNames); lyapunovComponent.setDataobject(dataset); double tmpRow[]; if (model instanceof ODE) { double step = stepSize; // stepSize and timeStep probably mean the same thing, one for discrete another for ODE //checking trajectory for (int i = 0; i < (int) (upper / stepSize); i++) { double[] result = new double[model.getNVar()]; int transX, transY; double[] temp = integrator.evaluateODEStep(step); double tt = integrator.getTime(); for (int h = 0; h < temp.length; h++) { result[h] = temp[h] / tt; } tmpRow = new double[model.getNVar() + 1]; tmpRow[0] = i; for (int a1 = 1; a1 < tmpRow.length; a1++) tmpRow[a1] = result[a1 - 1]; try { dataset.addRow(tmpRow); } catch (DatasetException de) { System.out.println("" + de); } for (int j = 0; j < result.length; j++) { if (Double.isNaN(result[j])) break; transX = (int) plot.getDomainAxis().valueToJava2D(i * stepSize, dataArea, RectangleEdge.BOTTOM); transY = (int) plot.getRangeAxis().valueToJava2D(result[j], dataArea, RectangleEdge.LEFT); g2.setPaint(paintSequence[j]); if (bigDots) { g2.fillRect(transX - 1, transY - 1, 3, 3); } else { g2.fillRect(transX, transY, 1, 1); } if (connectWithLines) { if (i > (int) lower) { g2.drawLine(transX, transY, prevX[j], prevY[j]); } prevX[j] = transX; prevY[j] = transY; } } if (stopped == true) { return false; } } } else {//? 14.7.2004 section of code above for (int i = (int) lower; i < (int) upper; i += timeStep) { double[] result = new double[model.getNVar()]; int transX, transY; result = Lua.evaluateLyapunovExponents(model, parameters, initialPoint, i); tmpRow = new double[model.getNVar() + 1]; tmpRow[0] = i; for (int a1 = 1; a1 < tmpRow.length; a1++) tmpRow[a1] = result[a1 - 1]; try { dataset.addRow(tmpRow); } catch (DatasetException de) { System.out.println("" + de); } for (int j = 0; j < result.length; j++) { if (Double.isNaN(result[j])) break; transX = (int) plot.getDomainAxis().valueToJava2D(i, dataArea, RectangleEdge.BOTTOM); transY = (int) plot.getRangeAxis().valueToJava2D(result[j], dataArea, RectangleEdge.LEFT); g2.setPaint(paintSequence[j]); if (bigDots) { g2.fillRect(transX - 1, transY - 1, 3, 3); } else { g2.fillRect(transX, transY, 1, 1); } if (connectWithLines) { if (i > (int) lower) { g2.drawLine(transX, transY, prevX[j], prevY[j]); } prevX[j] = transX; prevY[j] = transY; } } if (stopped == true) { return false; } } } //? } belongs to else 14.7.2004 return true; }
From source file:com.igormaznitsa.mindmap.swing.panel.MindMapPanel.java
private static void drawErrorText(final Graphics2D gfx, final Dimension fullSize, final String error) { final Font font = new Font(Font.DIALOG, Font.BOLD, 24); final FontMetrics metrics = gfx.getFontMetrics(font); final Rectangle2D textBounds = metrics.getStringBounds(error, gfx); gfx.setFont(font);/*from ww w . ja va 2 s. c o m*/ gfx.setColor(Color.DARK_GRAY); gfx.fillRect(0, 0, fullSize.width, fullSize.height); final int x = (int) (fullSize.width - textBounds.getWidth()) / 2; final int y = (int) (fullSize.height - textBounds.getHeight()) / 2; gfx.setColor(Color.BLACK); gfx.drawString(error, x + 5, y + 5); gfx.setColor(Color.RED.brighter()); gfx.drawString(error, x, y); }
From source file:org.tsho.dmc2.core.chart.LyapunovRenderer.java
public boolean renderVsParameter(Graphics2D g2, Rectangle2D dataArea) { final int imageWidth = (int) dataArea.getWidth(); g2.setPaint(Color.red);//from ww w. j a v a 2 s . c o m final double parStep; int prevX[] = new int[model.getNVar()]; int prevY[] = new int[model.getNVar()]; //? 28.7.2004 ValueAxis domainAxis = plot.getDomainAxis(); lower = domainAxis.getRange().getLowerBound(); upper = domainAxis.getRange().getUpperBound(); parStep = Math.abs(upper - lower) / imageWidth; String colNames[] = new String[model.getNVar() + 1]; colNames[0] = firstParLabel; for (int j = 1; j < (model.getNVar() + 1); j++) colNames[j] = "" + (new Integer(j)); Dataset dataset = new Dataset(colNames); lyapunovComponent.setDataobject(dataset); double tmpRow[]; if (model instanceof ODE) { double step = stepSize; // stepSize and timeStep probably mean the same thing, one for discrete another for ODE for (double i = lower; i < upper; i += parStep) { double[] result = new double[model.getNVar()];//initializing not needed but compiler too cautious. int transX, transY; parameters.put(firstParLabel, i); result = Lua.evaluateLyapunovExponentsODE(model, parameters, initialPoint, timePeriod, stepSize); tmpRow = new double[model.getNVar() + 1]; tmpRow[0] = i; for (int a1 = 1; a1 < tmpRow.length; a1++) tmpRow[a1] = result[a1 - 1]; try { dataset.addRow(tmpRow); } catch (DatasetException de) { System.out.println("" + de); } for (int j = 0; j < result.length; j++) { if (Double.isNaN(result[j])) break; transX = (int) plot.getDomainAxis().valueToJava2D(i, dataArea, RectangleEdge.BOTTOM); transY = (int) plot.getRangeAxis().valueToJava2D(result[j], dataArea, RectangleEdge.LEFT); g2.setPaint(paintSequence[j]); if (bigDots) { g2.fillRect(transX - 1, transY - 1, 3, 3); } else { g2.fillRect(transX, transY, 1, 1); } if (connectWithLines) { if (i != lower) { g2.drawLine(transX, transY, prevX[j], prevY[j]); } prevX[j] = transX; prevY[j] = transY; } } if (stopped == true) { return false; } } } //? 28.7.2004 else { for (double i = lower; i < upper; i += parStep) { double[] result; int transX, transY; parameters.put(firstParLabel, i); result = Lua.evaluateLyapunovExponents(model, parameters, initialPoint, iterations); tmpRow = new double[model.getNVar() + 1]; tmpRow[0] = i; for (int a1 = 1; a1 < tmpRow.length; a1++) tmpRow[a1] = result[a1 - 1]; try { dataset.addRow(tmpRow); } catch (DatasetException de) { System.out.println("" + de); } for (int j = 0; j < result.length; j++) { if (Double.isNaN(result[j])) break; transX = (int) plot.getDomainAxis().valueToJava2D(i, dataArea, RectangleEdge.BOTTOM); transY = (int) plot.getRangeAxis().valueToJava2D(result[j], dataArea, RectangleEdge.LEFT); g2.setPaint(paintSequence[j]); if (bigDots) { g2.fillRect(transX - 1, transY - 1, 3, 3); } else { g2.fillRect(transX, transY, 1, 1); } if (connectWithLines) { if (i != lower) { g2.drawLine(transX, transY, prevX[j], prevY[j]); } prevX[j] = transX; prevY[j] = transY; } } if (stopped == true) { return false; } } } return true; }
From source file:net.sourceforge.processdash.ui.web.reports.RadarPlot.java
/** * Draws the plot on a Java 2D graphics device (such as the screen * or a printer).// ww w.j ava2 s .co m * @param g2 The graphics device. * @param plotArea The area within which the plot should be drawn. */ @Override public void draw(Graphics2D g2, Rectangle2D plotArea, Point2D anchor, PlotState state, PlotRenderingInfo info) { // adjust for insets... RectangleInsets insets = getInsets(); if (insets != null) { plotArea.setRect(plotArea.getX() + insets.getLeft(), plotArea.getY() + insets.getTop(), plotArea.getWidth() - insets.getLeft() - insets.getRight(), plotArea.getHeight() - insets.getTop() - insets.getBottom()); } if (info != null) { info.setPlotArea(plotArea); info.setDataArea(plotArea); } drawBackground(g2, plotArea); drawOutline(g2, plotArea); Shape savedClip = g2.getClip(); g2.clip(plotArea); Composite originalComposite = g2.getComposite(); g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, getForegroundAlpha())); if (this.dataset != null) { drawRadar(g2, plotArea, info, 0, this.dataset); } else { drawNoDataMessage(g2, plotArea); } g2.clip(savedClip); g2.setComposite(originalComposite); drawOutline(g2, plotArea); }
From source file:com.controlj.addon.gwttree.server.OpaqueBarRenderer3D.java
/**<!====== drawItem ======================================================> Draws a 3D bar to represent one data item. <! Name Description> @param g2 the graphics device. @param state the renderer state. @param dataArea the area for plotting the data. @param plot the plot./* w ww.java 2 s. co m*/ @param domainAxis the domain axis. @param rangeAxis the range axis. @param dataset the dataset. @param row the row index (zero-based). @param column the column index (zero-based). @param pass the pass index. <!=======================================================================>*/ @Override public void drawItem(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryDataset dataset, int row, int column, int pass) { // check the value we are plotting... Number dataValue = dataset.getValue(row, column); if (dataValue == null) { return; } g2.setStroke(new BasicStroke(1)); double value = dataValue.doubleValue(); Rectangle2D adjusted = new Rectangle2D.Double(dataArea.getX(), dataArea.getY() + getYOffset(), dataArea.getWidth() - getXOffset(), dataArea.getHeight() - getYOffset()); PlotOrientation orientation = plot.getOrientation(); double barW0 = calculateBarW0(plot, orientation, adjusted, domainAxis, state, row, column); double[] barL0L1 = calculateBarL0L1(value); if (barL0L1 == null) { return; // the bar is not visible } RectangleEdge edge = plot.getRangeAxisEdge(); double transL0 = rangeAxis.valueToJava2D(barL0L1[0], adjusted, edge); double transL1 = rangeAxis.valueToJava2D(barL0L1[1], adjusted, edge); double barL0 = Math.min(transL0, transL1); double barLength = Math.abs(transL1 - transL0); // draw the bar... Rectangle2D bar = null; if (orientation == PlotOrientation.HORIZONTAL) { bar = new Rectangle2D.Double(barL0, barW0, barLength, state.getBarWidth()); } else { bar = new Rectangle2D.Double(barW0, barL0, state.getBarWidth(), barLength); } Paint itemPaint = getItemPaint(row, column); if (itemPaint instanceof Color) { Color endColor = getFrontDark((Color) itemPaint); Color startColor = (Color) itemPaint; Paint paint = new GradientPaint((float) bar.getX(), (float) bar.getY(), startColor, (float) (bar.getX()), (float) (bar.getY() + bar.getHeight()), endColor); g2.setPaint(paint); } g2.fill(bar); double x0 = bar.getMinX(); // left double x1 = x0 + getXOffset(); // offset left double x2 = bar.getMaxX(); // right double x3 = x2 + getXOffset(); // offset right double y0 = bar.getMinY() - getYOffset(); // offset top double y1 = bar.getMinY(); // bar top double y2 = bar.getMaxY() - getYOffset(); // offset bottom double y3 = bar.getMaxY(); // bottom //Rectangle2D.Double line = new Rectangle2D.Double(x2, y1, 2, bar.getHeight()); Line2D.Double line = new Line2D.Double(x2, y1, x2, y3); g2.draw(line); GeneralPath bar3dRight = null; GeneralPath bar3dTop = null; g2.setPaint(itemPaint); // Draw the right side if (barLength > 0.0) { bar3dRight = new GeneralPath(); bar3dRight.moveTo((float) x2, (float) y3); bar3dRight.lineTo((float) x2, (float) y1); bar3dRight.lineTo((float) x3, (float) y0); bar3dRight.lineTo((float) x3, (float) y2); bar3dRight.closePath(); if (itemPaint instanceof Color) { Color startColor = getSideLight((Color) itemPaint); Color endColor = getSideDark((Color) itemPaint); Paint paint = new GradientPaint((float) x3, (float) y0, startColor, (float) x2, (float) y3, endColor); g2.setPaint(paint); } g2.fill(bar3dRight); } // Draw the top bar3dTop = new GeneralPath(); bar3dTop.moveTo((float) x0, (float) y1); // bottom left bar3dTop.lineTo((float) x1, (float) y0); // top left bar3dTop.lineTo((float) x3, (float) y0); // top right bar3dTop.lineTo((float) x2, (float) y1); // bottom right bar3dTop.closePath(); if (itemPaint instanceof Color) { Color endColor = getTopDark((Color) itemPaint); Color startColor = getTopLight((Color) itemPaint); //Paint paint = new GradientPaint((float)x2, (float)y0, startColor, (float)x0, (float)(y1), endColor); Point2D.Double topRight = new Point2D.Double(x3, y0); Point2D.Double bottomLeft = new Point2D.Double(x0, y1); //Point2D.Double darkEnd = getTargetPoint(bottomLeft, topRight, ((y0-y1)/(x3-x2))); Point2D.Double darkEnd = new Point2D.Double(x1, y0 - (x3 - x1) * ((y0 - y1) / (x3 - x2))); Paint paint = new GradientPaint((float) topRight.getX(), (float) topRight.getY(), startColor, (float) darkEnd.getX(), (float) darkEnd.getY(), endColor); g2.setPaint(paint); //drawMarker(topRight, g2, startColor); } g2.fill(bar3dTop); g2.setPaint(itemPaint); if (isDrawBarOutline() && state.getBarWidth() > BAR_OUTLINE_WIDTH_THRESHOLD) { g2.setStroke(getItemOutlineStroke(row, column)); g2.setPaint(getItemOutlinePaint(row, column)); g2.draw(bar); if (bar3dRight != null) { g2.draw(bar3dRight); } if (bar3dTop != null) { g2.draw(bar3dTop); } } CategoryItemLabelGenerator generator = getItemLabelGenerator(row, column); if (generator != null && isItemLabelVisible(row, column)) { drawItemLabel(g2, dataset, row, column, plot, generator, bar, (value < 0.0)); } // add an item entity, if this information is being collected EntityCollection entities = state.getEntityCollection(); if (entities != null) { GeneralPath barOutline = new GeneralPath(); barOutline.moveTo((float) x0, (float) y3); barOutline.lineTo((float) x0, (float) y1); barOutline.lineTo((float) x1, (float) y0); barOutline.lineTo((float) x3, (float) y0); barOutline.lineTo((float) x3, (float) y2); barOutline.lineTo((float) x2, (float) y3); barOutline.closePath(); addItemEntity(entities, dataset, row, column, barOutline); } }
From source file:org.apache.xmlgraphics.ps.PSGenerator.java
/** * Formats a Rectangle2D to an array.// w w w. j a v a2 s . c o m * @param rect the rectangle * @return the formatted array */ public String formatRectangleToArray(Rectangle2D rect) { return "[" + formatDouble(rect.getX()) + " " + formatDouble(rect.getY()) + " " + formatDouble(rect.getWidth()) + " " + formatDouble(rect.getHeight()) + "]"; }