Java Code Examples for java.awt.geom.Rectangle2D#getMaxY()
The following examples show how to use
java.awt.geom.Rectangle2D#getMaxY() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XYStepAreaRenderer.java From buffer_bci with GNU General Public License v3.0 | 6 votes |
/** * Helper method which returns a value if it lies * inside the visible dataArea and otherwise the corresponding * coordinate on the border of the dataArea. The PlotOrientation * is taken into account. * Useful to avoid possible sun.dc.pr.PRException: endPath: bad path * which occurs when trying to draw lines/shapes which in large part * lie outside of the visible dataArea. * * @param value the value which shall be * @param dataArea the area within which the data is being drawn. * @param plot the plot (can be used to obtain standard color * information etc). * @return <code>double</code> value inside the data area. */ protected static double restrictValueToDataArea(double value, XYPlot plot, Rectangle2D dataArea) { double min = 0; double max = 0; if (plot.getOrientation() == PlotOrientation.VERTICAL) { min = dataArea.getMinY(); max = dataArea.getMaxY(); } else if (plot.getOrientation() == PlotOrientation.HORIZONTAL) { min = dataArea.getMinX(); max = dataArea.getMaxX(); } if (value < min) { value = min; } else if (value > max) { value = max; } return value; }
Example 2
Source File: jMutRepair_0030_t.java From coming with MIT License | 6 votes |
/** * Draws a range crosshair. * * @param g2 the graphics target. * @param dataArea the data area. * @param orientation the plot orientation. * @param value the crosshair value. * @param axis the axis against which the value is measured. * @param stroke the stroke used to draw the crosshair line. * @param paint the paint used to draw the crosshair line. * * @since 1.0.5 */ protected void drawRangeCrosshair(Graphics2D g2, Rectangle2D dataArea, PlotOrientation orientation, double value, ValueAxis axis, Stroke stroke, Paint paint) { if (!axis.getRange().contains(value)) { return; } Line2D line = null; if (orientation == PlotOrientation.HORIZONTAL) { double xx = axis.valueToJava2D(value, dataArea, RectangleEdge.BOTTOM); line = new Line2D.Double(xx, dataArea.getMinY(), xx, dataArea.getMaxY()); } else { double yy = axis.valueToJava2D(value, dataArea, RectangleEdge.LEFT); line = new Line2D.Double(dataArea.getMinX(), yy, dataArea.getMaxX(), yy); } g2.setStroke(stroke); g2.setPaint(paint); g2.draw(line); }
Example 3
Source File: jMutRepair_000_t.java From coming with MIT License | 6 votes |
/** * Draws a line perpendicular to the range axis. * * @param g2 the graphics device. * @param plot the plot. * @param axis the value axis. * @param dataArea the area for plotting data (not yet adjusted for any 3D * effect). * @param value the value at which the grid line should be drawn. * @param paint the paint (<code>null</code> not permitted). * @param stroke the stroke (<code>null</code> not permitted). * * @see #drawRangeGridline * * @since 1.0.13 */ public void drawRangeLine(Graphics2D g2, CategoryPlot plot, ValueAxis axis, Rectangle2D dataArea, double value, Paint paint, Stroke stroke) { Range range = axis.getRange(); if (!range.contains(value)) { return; } PlotOrientation orientation = plot.getOrientation(); Line2D line = null; double v = axis.valueToJava2D(value, dataArea, plot.getRangeAxisEdge()); if (orientation == PlotOrientation.HORIZONTAL) { line = new Line2D.Double(v, dataArea.getMinY(), v, dataArea.getMaxY()); } else if (orientation == PlotOrientation.VERTICAL) { line = new Line2D.Double(dataArea.getMinX(), v, dataArea.getMaxX(), v); } g2.setPaint(paint); g2.setStroke(stroke); g2.draw(line); }
Example 4
Source File: 1_AbstractCategoryItemRenderer.java From SimFix with GNU General Public License v2.0 | 6 votes |
/** * Draws a line perpendicular to the range axis. * * @param g2 the graphics device. * @param plot the plot. * @param axis the value axis. * @param dataArea the area for plotting data (not yet adjusted for any 3D * effect). * @param value the value at which the grid line should be drawn. * @param paint the paint (<code>null</code> not permitted). * @param stroke the stroke (<code>null</code> not permitted). * * @see #drawRangeGridline * * @since 1.0.13 */ public void drawRangeLine(Graphics2D g2, CategoryPlot plot, ValueAxis axis, Rectangle2D dataArea, double value, Paint paint, Stroke stroke) { Range range = axis.getRange(); if (!range.contains(value)) { return; } PlotOrientation orientation = plot.getOrientation(); Line2D line = null; double v = axis.valueToJava2D(value, dataArea, plot.getRangeAxisEdge()); if (orientation == PlotOrientation.HORIZONTAL) { line = new Line2D.Double(v, dataArea.getMinY(), v, dataArea.getMaxY()); } else if (orientation == PlotOrientation.VERTICAL) { line = new Line2D.Double(dataArea.getMinX(), v, dataArea.getMaxX(), v); } g2.setPaint(paint); g2.setStroke(stroke); g2.draw(line); }
Example 5
Source File: ChartPanel.java From ECG-Viewer with GNU General Public License v2.0 | 6 votes |
/** * Draws a vertical line used to trace the mouse position to the horizontal * axis. * * @param g2 the graphics device. * @param x the x-coordinate of the trace line. */ private void drawHorizontalAxisTrace(Graphics2D g2, int x) { Rectangle2D dataArea = getScreenDataArea(); g2.setXORMode(Color.orange); if (((int) dataArea.getMinX() < x) && (x < (int) dataArea.getMaxX())) { if (this.verticalTraceLine != null) { g2.draw(this.verticalTraceLine); this.verticalTraceLine.setLine(x, (int) dataArea.getMinY(), x, (int) dataArea.getMaxY()); } else { this.verticalTraceLine = new Line2D.Float(x, (int) dataArea.getMinY(), x, (int) dataArea.getMaxY()); } g2.draw(this.verticalTraceLine); } // Reset to the default 'overwrite' mode g2.setPaintMode(); }
Example 6
Source File: Axis.java From buffer_bci with GNU General Public License v3.0 | 5 votes |
protected double labelLocationY(AxisLabelLocation location, Rectangle2D dataArea) { if (location.equals(AxisLabelLocation.HIGH_END)) { return dataArea.getMinY(); } if (location.equals(AxisLabelLocation.MIDDLE)) { return dataArea.getCenterY(); } if (location.equals(AxisLabelLocation.LOW_END)) { return dataArea.getMaxY(); } throw new RuntimeException("Unexpected AxisLabelLocation: " + location); }
Example 7
Source File: ContourPlot.java From SIMVA-SoS with Apache License 2.0 | 5 votes |
/** * Draws a vertical line on the chart to represent a 'range marker'. * * @param g2 the graphics device. * @param plot the plot. * @param domainAxis the domain axis. * @param marker the marker line. * @param dataArea the axis data area. */ public void drawDomainMarker(Graphics2D g2, ContourPlot plot, ValueAxis domainAxis, Marker marker, Rectangle2D dataArea) { if (marker instanceof ValueMarker) { ValueMarker vm = (ValueMarker) marker; double value = vm.getValue(); Range range = domainAxis.getRange(); if (!range.contains(value)) { return; } double x = domainAxis.valueToJava2D(value, dataArea, RectangleEdge.BOTTOM); Line2D line = new Line2D.Double(x, dataArea.getMinY(), x, dataArea.getMaxY()); Paint paint = marker.getOutlinePaint(); Stroke stroke = marker.getOutlineStroke(); g2.setPaint(paint != null ? paint : Plot.DEFAULT_OUTLINE_PAINT); g2.setStroke(stroke != null ? stroke : Plot.DEFAULT_OUTLINE_STROKE); g2.draw(line); } }
Example 8
Source File: ProjectMetagonEditGrammarIconImage.java From Forsythia with GNU General Public License v3.0 | 5 votes |
ProjectMetagonEditGrammarIconImage(ProjectMetagon pm,int span){ super(span,span,BufferedImage.TYPE_INT_RGB); //init image Path2D path=pm.getImagePath(); Graphics2D g=createGraphics(); g.setRenderingHints(UI.RENDERING_HINTS); //fill background g.setColor(UI.ELEMENTMENU_ICONBACKGROUND); g.fillRect(0,0,span,span); //glean metrics and transform Rectangle2D pbounds=path.getBounds2D(); double pw=pbounds.getWidth(),ph=pbounds.getHeight(),scale; int maxpolygonimagespan=span-(UI.ELEMENTMENU_ICONGEOMETRYINSET*2); scale=(pw>ph)?maxpolygonimagespan/pw:maxpolygonimagespan/ph; AffineTransform t=new AffineTransform(); t.scale(scale,-scale);//note y flip double xoffset=-pbounds.getMinX()+(((span-(pw*scale))/2)/scale), yoffset=-pbounds.getMaxY()-(((span-(ph*scale))/2)/scale); t.translate(xoffset,yoffset); g.transform(t); //fill metagon //use color to distinguish protojig counts int pjcount=pm.getJigCount(); if(pjcount<UI.GRAMMAR_EDITOR_METAGON_ICONS_FILLCOLOR.length) g.setColor(UI.GRAMMAR_EDITOR_METAGON_ICONS_FILLCOLOR[pjcount]); else g.setColor(UI.GRAMMAR_EDITOR_METAGON_ICONS_FILLCOLOR[UI.GRAMMAR_EDITOR_METAGON_ICONS_FILLCOLOR.length-1]); g.fill(path); //stroke it g.setColor(UI.ELEMENTMENU_ICON_STROKE); g.setStroke(new BasicStroke( (float)(UI.ELEMENTMENU_ICONPATHSTROKETHICKNESS/scale), BasicStroke.CAP_SQUARE, BasicStroke.JOIN_ROUND, 0,null,0)); g.draw(path);}
Example 9
Source File: XYPlot.java From buffer_bci with GNU General Public License v3.0 | 5 votes |
/** * Draws a range crosshair. * * @param g2 the graphics target. * @param dataArea the data area. * @param orientation the plot orientation. * @param value the crosshair value. * @param axis the axis against which the value is measured. * @param stroke the stroke used to draw the crosshair line. * @param paint the paint used to draw the crosshair line. * * @since 1.0.4 */ protected void drawRangeCrosshair(Graphics2D g2, Rectangle2D dataArea, PlotOrientation orientation, double value, ValueAxis axis, Stroke stroke, Paint paint) { if (!axis.getRange().contains(value)) { return; } Object saved = g2.getRenderingHint(RenderingHints.KEY_STROKE_CONTROL); g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE); Line2D line; if (orientation == PlotOrientation.HORIZONTAL) { double xx = axis.valueToJava2D(value, dataArea, RectangleEdge.BOTTOM); line = new Line2D.Double(xx, dataArea.getMinY(), xx, dataArea.getMaxY()); } else { double yy = axis.valueToJava2D(value, dataArea, RectangleEdge.LEFT); line = new Line2D.Double(dataArea.getMinX(), yy, dataArea.getMaxX(), yy); } g2.setStroke(stroke); g2.setPaint(paint); g2.draw(line); g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, saved); }
Example 10
Source File: JGenProg2017_000_s.java From coming with MIT License | 5 votes |
/** * Draws a grid line against the domain axis. * <P> * Note that this default implementation assumes that the horizontal axis * is the domain axis. If this is not the case, you will need to override * this method. * * @param g2 the graphics device. * @param plot the plot. * @param dataArea the area for plotting data (not yet adjusted for any * 3D effect). * @param value the Java2D value at which the grid line should be drawn. * @param paint the paint (<code>null</code> not permitted). * @param stroke the stroke (<code>null</code> not permitted). * * @see #drawRangeGridline(Graphics2D, CategoryPlot, ValueAxis, * Rectangle2D, double) * * @since 1.2.0 */ public void drawDomainLine(Graphics2D g2, CategoryPlot plot, Rectangle2D dataArea, double value, Paint paint, Stroke stroke) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } if (stroke == null) { throw new IllegalArgumentException("Null 'stroke' argument."); } Line2D line = null; PlotOrientation orientation = plot.getOrientation(); if (orientation == PlotOrientation.HORIZONTAL) { line = new Line2D.Double(dataArea.getMinX(), value, dataArea.getMaxX(), value); } else if (orientation == PlotOrientation.VERTICAL) { line = new Line2D.Double(value, dataArea.getMinY(), value, dataArea.getMaxY()); } g2.setPaint(paint); g2.setStroke(stroke); g2.draw(line); }
Example 11
Source File: DateAxis.java From openstock with GNU General Public License v3.0 | 5 votes |
/** * Translates the data value to the display coordinates (Java 2D User Space) * of the chart. * * @param value the date to be plotted. * @param area the rectangle (in Java2D space) where the data is to be * plotted. * @param edge the axis location. * * @return The coordinate corresponding to the supplied data value. */ @Override public double valueToJava2D(double value, Rectangle2D area, RectangleEdge edge) { value = this.timeline.toTimelineValue((long) value); DateRange range = (DateRange) getRange(); double axisMin = this.timeline.toTimelineValue(range.getLowerMillis()); double axisMax = this.timeline.toTimelineValue(range.getUpperMillis()); double result = 0.0; if (RectangleEdge.isTopOrBottom(edge)) { double minX = area.getX(); double maxX = area.getMaxX(); if (isInverted()) { result = maxX + ((value - axisMin) / (axisMax - axisMin)) * (minX - maxX); } else { result = minX + ((value - axisMin) / (axisMax - axisMin)) * (maxX - minX); } } else if (RectangleEdge.isLeftOrRight(edge)) { double minY = area.getMinY(); double maxY = area.getMaxY(); if (isInverted()) { result = minY + (((value - axisMin) / (axisMax - axisMin)) * (maxY - minY)); } else { result = maxY - (((value - axisMin) / (axisMax - axisMin)) * (maxY - minY)); } } return result; }
Example 12
Source File: BarRenderer3D.java From buffer_bci with GNU General Public License v3.0 | 5 votes |
/** * Draws the outline for the plot. * * @param g2 the graphics device. * @param plot the plot. * @param dataArea the area inside the axes. */ @Override public void drawOutline(Graphics2D g2, CategoryPlot plot, Rectangle2D dataArea) { float x0 = (float) dataArea.getX(); float x1 = x0 + (float) Math.abs(this.xOffset); float x3 = (float) dataArea.getMaxX(); float x2 = x3 - (float) Math.abs(this.xOffset); float y0 = (float) dataArea.getMaxY(); float y1 = y0 - (float) Math.abs(this.yOffset); float y3 = (float) dataArea.getMinY(); float y2 = y3 + (float) Math.abs(this.yOffset); GeneralPath clip = new GeneralPath(); clip.moveTo(x0, y0); clip.lineTo(x0, y2); clip.lineTo(x1, y3); clip.lineTo(x3, y3); clip.lineTo(x3, y1); clip.lineTo(x2, y0); clip.closePath(); // put an outline around the data area... Stroke outlineStroke = plot.getOutlineStroke(); Paint outlinePaint = plot.getOutlinePaint(); if ((outlineStroke != null) && (outlinePaint != null)) { g2.setStroke(outlineStroke); g2.setPaint(outlinePaint); g2.draw(clip); } }
Example 13
Source File: ContourPlot.java From SIMVA-SoS with Apache License 2.0 | 5 votes |
/** * Utility method for drawing a crosshair on the chart (if required). * * @param g2 The graphics device. * @param dataArea The data area. * @param value The coordinate, where to draw the line. * @param stroke The stroke to use. * @param paint The paint to use. */ protected void drawVerticalLine(Graphics2D g2, Rectangle2D dataArea, double value, Stroke stroke, Paint paint) { double xx = getDomainAxis().valueToJava2D(value, dataArea, RectangleEdge.BOTTOM); Line2D line = new Line2D.Double(xx, dataArea.getMinY(), xx, dataArea.getMaxY()); g2.setStroke(stroke); g2.setPaint(paint); g2.draw(line); }
Example 14
Source File: jKali_0052_t.java From coming with MIT License | 5 votes |
/** * Creates a rectangle that is aligned to the frame. * * @param dimensions * @param frame * @param hAlign * @param vAlign * * @return A rectangle. */ private Rectangle2D createAlignedRectangle2D(Size2D dimensions, Rectangle2D frame, HorizontalAlignment hAlign, VerticalAlignment vAlign) { double x = Double.NaN; double y = Double.NaN; if (hAlign == HorizontalAlignment.LEFT) { x = frame.getX(); } else if (hAlign == HorizontalAlignment.CENTER) { x = frame.getCenterX() - (dimensions.width / 2.0); } else if (hAlign == HorizontalAlignment.RIGHT) { x = frame.getMaxX() - dimensions.width; } if (vAlign == VerticalAlignment.TOP) { y = frame.getY(); } else if (vAlign == VerticalAlignment.CENTER) { y = frame.getCenterY() - (dimensions.height / 2.0); } else if (vAlign == VerticalAlignment.BOTTOM) { y = frame.getMaxY() - dimensions.height; } return new Rectangle2D.Double(x, y, dimensions.width, dimensions.height); }
Example 15
Source File: Arja_000_t.java From coming with MIT License | 5 votes |
/** * Draws a grid line against the domain axis. * <P> * Note that this default implementation assumes that the horizontal axis * is the domain axis. If this is not the case, you will need to override * this method. * * @param g2 the graphics device. * @param plot the plot. * @param dataArea the area for plotting data (not yet adjusted for any * 3D effect). * @param value the Java2D value at which the grid line should be drawn. * @param paint the paint (<code>null</code> not permitted). * @param stroke the stroke (<code>null</code> not permitted). * * @see #drawRangeGridline(Graphics2D, CategoryPlot, ValueAxis, * Rectangle2D, double) * * @since 1.2.0 */ public void drawDomainLine(Graphics2D g2, CategoryPlot plot, Rectangle2D dataArea, double value, Paint paint, Stroke stroke) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } if (stroke == null) { throw new IllegalArgumentException("Null 'stroke' argument."); } Line2D line = null; PlotOrientation orientation = plot.getOrientation(); if (orientation == PlotOrientation.HORIZONTAL) { line = new Line2D.Double(dataArea.getMinX(), value, dataArea.getMaxX(), value); } else if (orientation == PlotOrientation.VERTICAL) { line = new Line2D.Double(value, dataArea.getMinY(), value, dataArea.getMaxY()); } g2.setPaint(paint); g2.setStroke(stroke); g2.draw(line); }
Example 16
Source File: GraphicsLib.java From osp with GNU General Public License v3.0 | 5 votes |
/** * Compute the intersection of a line and a rectangle. * @param a1 the first endpoint of the line * @param a2 the second endpoint of the line * @param r the rectangle * @param pts a length 2 or greater array of points in which to store * the results * @return the intersection code. One of {@link #NO_INTERSECTION}, * {@link #COINCIDENT}, or {@link #PARALLEL}. */ public static int intersectLineRectangle(Point2D a1, Point2D a2, Rectangle2D r, Point2D[] pts) { double a1x = a1.getX(), a1y = a1.getY(); double a2x = a2.getX(), a2y = a2.getY(); double mxx = r.getMaxX(), mxy = r.getMaxY(); double mnx = r.getMinX(), mny = r.getMinY(); if(pts[0]==null) { pts[0] = new Point2D.Double(); } if(pts[1]==null) { pts[1] = new Point2D.Double(); } int i = 0; if(intersectLineLine(mnx, mny, mxx, mny, a1x, a1y, a2x, a2y, pts[i])>0) { i++; } if(intersectLineLine(mxx, mny, mxx, mxy, a1x, a1y, a2x, a2y, pts[i])>0) { i++; } if(i==2) { return i; } if(intersectLineLine(mxx, mxy, mnx, mxy, a1x, a1y, a2x, a2y, pts[i])>0) { i++; } if(i==2) { return i; } if(intersectLineLine(mnx, mxy, mnx, mny, a1x, a1y, a2x, a2y, pts[i])>0) { i++; } return i; }
Example 17
Source File: TextBounds.java From ramus with GNU General Public License v3.0 | 5 votes |
private int drawSels(Graphics2D g, int[][] found, int selIndex, int i, TextLayout textLayout, float left, float fromY) { Shape[] start = null; while (selIndex < found.length) { if (in) { if (start == null) start = textLayout.getCaretShapes(0); Shape[] shapes; boolean b = false; if (found[selIndex][0] == i) { shapes = textLayout.getCaretShapes(found[selIndex][1]); selIndex++; in = false; } else { shapes = textLayout.getCaretShapes(texts.get(i).length()); b = true; } Rectangle2D s = start[0].getBounds2D(); Rectangle2D e = shapes[0].getBounds2D(); Rectangle2D r = new Rectangle2D.Double(s.getMinX() + left, s.getMinY() + fromY, e.getMaxX() - s.getMinX(), e.getMaxY() - s.getMinY()); g.draw(r); if (b) break; } else { if (found[selIndex][0] == i) { start = textLayout.getCaretShapes(found[selIndex][1]); selIndex++; in = true; } else break; } } return selIndex; }
Example 18
Source File: CrosshairOverlay.java From SIMVA-SoS with Apache License 2.0 | 4 votes |
/** * Draws a crosshair vertically on the plot. * * @param g2 the graphics target. * @param dataArea the data area. * @param x the x-value in Java2D space. * @param crosshair the crosshair. */ protected void drawVerticalCrosshair(Graphics2D g2, Rectangle2D dataArea, double x, Crosshair crosshair) { if (x >= dataArea.getMinX() && x <= dataArea.getMaxX()) { Line2D line = new Line2D.Double(x, dataArea.getMinY(), x, dataArea.getMaxY()); Paint savedPaint = g2.getPaint(); Stroke savedStroke = g2.getStroke(); g2.setPaint(crosshair.getPaint()); g2.setStroke(crosshair.getStroke()); g2.draw(line); if (crosshair.isLabelVisible()) { String label = crosshair.getLabelGenerator().generateLabel( crosshair); RectangleAnchor anchor = crosshair.getLabelAnchor(); Point2D pt = calculateLabelPoint(line, anchor, 5, 5); float xx = (float) pt.getX(); float yy = (float) pt.getY(); TextAnchor alignPt = textAlignPtForLabelAnchorV(anchor); Shape hotspot = TextUtilities.calculateRotatedStringBounds( label, g2, xx, yy, alignPt, 0.0, TextAnchor.CENTER); if (!dataArea.contains(hotspot.getBounds2D())) { anchor = flipAnchorH(anchor); pt = calculateLabelPoint(line, anchor, 5, 5); xx = (float) pt.getX(); yy = (float) pt.getY(); alignPt = textAlignPtForLabelAnchorV(anchor); hotspot = TextUtilities.calculateRotatedStringBounds( label, g2, xx, yy, alignPt, 0.0, TextAnchor.CENTER); } g2.setPaint(crosshair.getLabelBackgroundPaint()); g2.fill(hotspot); g2.setPaint(crosshair.getLabelOutlinePaint()); g2.draw(hotspot); TextUtilities.drawAlignedString(label, g2, xx, yy, alignPt); } g2.setPaint(savedPaint); g2.setStroke(savedStroke); } }
Example 19
Source File: PointerNeedle.java From ECG-Viewer with GNU General Public License v2.0 | 4 votes |
/** * Draws the needle. * * @param g2 the graphics device. * @param plotArea the plot area. * @param rotate the rotation point. * @param angle the angle. */ @Override protected void drawNeedle(Graphics2D g2, Rectangle2D plotArea, Point2D rotate, double angle) { GeneralPath shape1 = new GeneralPath(); GeneralPath shape2 = new GeneralPath(); float minX = (float) plotArea.getMinX(); float minY = (float) plotArea.getMinY(); float maxX = (float) plotArea.getMaxX(); float maxY = (float) plotArea.getMaxY(); float midX = (float) (minX + (plotArea.getWidth() / 2)); float midY = (float) (minY + (plotArea.getHeight() / 2)); shape1.moveTo(minX, midY); shape1.lineTo(midX, minY); shape1.lineTo(maxX, midY); shape1.closePath(); shape2.moveTo(minX, midY); shape2.lineTo(midX, maxY); shape2.lineTo(maxX, midY); shape2.closePath(); if ((rotate != null) && (angle != 0)) { /// we have rotation huston, please spin me getTransform().setToRotation(angle, rotate.getX(), rotate.getY()); shape1.transform(getTransform()); shape2.transform(getTransform()); } if (getFillPaint() != null) { g2.setPaint(getFillPaint()); g2.fill(shape1); } if (getHighlightPaint() != null) { g2.setPaint(getHighlightPaint()); g2.fill(shape2); } if (getOutlinePaint() != null) { g2.setStroke(getOutlineStroke()); g2.setPaint(getOutlinePaint()); g2.draw(shape1); g2.draw(shape2); } }
Example 20
Source File: Chart3D.java From orson-charts with GNU General Public License v3.0 | 4 votes |
/** * A utility method that calculates a drawing area based on a bounding area * and an anchor. * * @param dim the dimensions for the drawing area ({@code null} not * permitted). * @param anchor the anchor ({@code null} not permitted). * @param bounds the bounds ({@code null} not permitted). * * @return A drawing area. */ private Rectangle2D calculateDrawArea(Dimension2D dim, Anchor2D anchor, Rectangle2D bounds) { Args.nullNotPermitted(dim, "dim"); Args.nullNotPermitted(anchor, "anchor"); Args.nullNotPermitted(bounds, "bounds"); double x, y; double w = Math.min(dim.getWidth(), bounds.getWidth()); double h = Math.min(dim.getHeight(), bounds.getHeight()); if (anchor.getRefPt().equals(RefPt2D.CENTER)) { x = bounds.getCenterX() - w / 2.0; y = bounds.getCenterY() - h / 2.0; } else if (anchor.getRefPt().equals(RefPt2D.CENTER_LEFT)) { x = bounds.getX() + anchor.getOffset().getDX(); y = bounds.getCenterY() - h / 2.0; } else if (anchor.getRefPt().equals(RefPt2D.CENTER_RIGHT)) { x = bounds.getMaxX() - anchor.getOffset().getDX() - dim.getWidth(); y = bounds.getCenterY() - h / 2.0; } else if (anchor.getRefPt().equals(RefPt2D.TOP_CENTER)) { x = bounds.getCenterX() - w / 2.0; y = bounds.getY() + anchor.getOffset().getDY(); } else if (anchor.getRefPt().equals(RefPt2D.TOP_LEFT)) { x = bounds.getX() + anchor.getOffset().getDX(); y = bounds.getY() + anchor.getOffset().getDY(); } else if (anchor.getRefPt().equals(RefPt2D.TOP_RIGHT)) { x = bounds.getMaxX() - anchor.getOffset().getDX() - dim.getWidth(); y = bounds.getY() + anchor.getOffset().getDY(); } else if (anchor.getRefPt().equals(RefPt2D.BOTTOM_CENTER)) { x = bounds.getCenterX() - w / 2.0; y = bounds.getMaxY() - anchor.getOffset().getDY() - dim.getHeight(); } else if (anchor.getRefPt().equals(RefPt2D.BOTTOM_RIGHT)) { x = bounds.getMaxX() - anchor.getOffset().getDX() - dim.getWidth(); y = bounds.getMaxY() - anchor.getOffset().getDY() - dim.getHeight(); } else if (anchor.getRefPt().equals(RefPt2D.BOTTOM_LEFT)) { x = bounds.getX() + anchor.getOffset().getDX(); y = bounds.getMaxY() - anchor.getOffset().getDY() - dim.getHeight(); } else { x = 0.0; y = 0.0; } return new Rectangle2D.Double(x, y, w, h); }