List of usage examples for java.awt Graphics2D draw
public abstract void draw(Shape s);
From source file:com.projity.pm.graphic.graph.GraphInteractor.java
private void drawLinkShadow(double x, double y, boolean alternate) { if (x == -1 || y == -1) return;//from w ww . ja v a2 s . c o m Graphics2D g = initGraphics(); Line2D line = new Line2D.Double(x0link, y0link, x, y); g.setStroke(new BasicStroke(2)); g.draw(line); if (alternate) { lastLinkShadowX = (lastLinkShadowX == -1) ? x : -1; lastLinkShadowY = (lastLinkShadowY == -1) ? y : -1; } }
From source file:GeneralPathOpenDemo2D.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.setPaint(Color.gray);/*from w w w . java 2 s . c o m*/ int x = 5; int y = 7; // draw GeneralPath (polyline) int xPoints[] = { x, 200, x, 200 }; int yPoints[] = { y, 200, 200, y }; GeneralPath polyline = new GeneralPath(GeneralPath.WIND_EVEN_ODD, xPoints.length); polyline.moveTo(xPoints[0], yPoints[0]); for (int index = 1; index < xPoints.length; index++) { polyline.lineTo(xPoints[index], yPoints[index]); } g2.draw(polyline); g2.drawString("GeneralPath (open)", x, 250); }
From source file:TextLayoutPanel.java
public void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2 = (Graphics2D) g; AffineTransform at = AffineTransform.getTranslateInstance(rx, ry); Shape hilight = layout.getLogicalHighlightShape(hit1, hit2); hilight = at.createTransformedShape(hilight); g2.setColor(Color.lightGray); g2.fill(hilight);/*from w ww .ja v a 2s .c o m*/ g2.setColor(Color.black); layout.draw(g2, rx, ry); // Draw caret Shape[] caretShapes = layout.getCaretShapes(hit1); Shape caret = at.createTransformedShape(caretShapes[0]); g2.setColor(caretColor); g2.draw(caret); }
From source file:ShapeMover.java
public void update(Graphics g) { Graphics2D g2 = (Graphics2D) g; Dimension dim = getSize();// ww w . j av a2 s . c o m int w = (int) dim.getWidth(); int h = (int) dim.getHeight(); g2.setStroke(new BasicStroke(8.0f)); if (isFirstTime) { area = new Rectangle(dim); rect.setLocation(w / 2 - 50, h / 2 - 25); isFirstTime = false; } // Clears the rectangle that was previously drawn. g2.setPaint(Color.white); g2.fillRect(0, 0, w, h); g2.setColor(Color.red); g2.draw(rect); g2.setColor(Color.black); g2.fill(rect); }
From source file:com.projity.pm.graphic.graph.GraphInteractor.java
protected void drawBarShadow(double x, double y, boolean alternate) { if (x == -1)/*from www.j a v a 2 s .c o m*/ return; Graphics2D g = initGraphics(); Shape bounds = getBarShadowBounds(x, y); if (bounds == null) return; g.setStroke(new BasicStroke(3)); g.draw(bounds); if (alternate) { lastShadowX = (lastShadowX == -1) ? x : -1; lastShadowY = (lastShadowY == -1) ? y : -1; } }
From source file:PaintSample.java
/** * Fills the component with the current Paint. * * @param g the graphics device.//w ww .java 2 s . c o m */ public void paintComponent(final Graphics g) { final Graphics2D g2 = (Graphics2D) g; final Dimension size = getSize(); final Insets insets = getInsets(); final double xx = insets.left; final double yy = insets.top; final double ww = size.getWidth() - insets.left - insets.right - 1; final double hh = size.getHeight() - insets.top - insets.bottom - 1; final Rectangle2D area = new Rectangle2D.Double(xx, yy, ww, hh); g2.setPaint(this.paint); g2.fill(area); g2.setPaint(Color.black); g2.draw(area); }
From source file:GeneralPathDemo2D.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.setPaint(Color.gray);/*from w ww . j a v a 2 s . c o m*/ int x = 5; int y = 7; // draw GeneralPath (polygon) int xPoints[] = { x, 200, x, 200 }; int yPoints[] = { y, 200, 200, y }; GeneralPath polygon = new GeneralPath(GeneralPath.WIND_EVEN_ODD, xPoints.length); polygon.moveTo(xPoints[0], yPoints[0]); for (int index = 1; index < xPoints.length; index++) { polygon.lineTo(xPoints[index], yPoints[index]); } polygon.closePath(); g2.draw(polygon); g2.drawString("GeneralPath", x, 250); }
From source file:com.rapidminer.gui.new_plotter.engine.jfreechart.legend.CustomLegendGraphic.java
@Override public void draw(Graphics2D g2, Rectangle2D area) { area = trimMargin(area);//from w w w .j ava 2 s. c om drawBorder(g2, area); area = trimBorder(area); area = trimPadding(area); if (isLineVisible()) { Point2D location = RectangleAnchor.coordinates(area, getShapeLocation()); Shape aLine = ShapeUtilities.createTranslatedShape(getLine(), getShapeAnchor(), location.getX(), location.getY()); g2.setPaint(getLinePaint()); g2.setStroke(getLineStroke()); g2.draw(aLine); } if (isShapeVisible()) { Point2D location = RectangleAnchor.coordinates(area, getShapeLocation()); Shape s = ShapeUtilities.createTranslatedShape(getShape(), getShapeAnchor(), location.getX(), location.getY()); if (isShapeFilled()) { Paint p = getFillPaint(); if (p instanceof GradientPaint) { GradientPaint gp = (GradientPaint) getFillPaint(); p = getFillPaintTransformer().transform(gp, s); } else if (p instanceof LinearGradientPaint) { LinearGradientPaint gradient = (LinearGradientPaint) p; Rectangle2D bounds = s.getBounds2D(); p = getTranslatedLinearGradientPaint(gradient, new Point2D.Double(bounds.getMinX(), bounds.getMinY()), new Point2D.Double(bounds.getMaxX(), bounds.getMaxY()), false); } g2.setPaint(p); g2.fill(s); } if (isShapeOutlineVisible()) { g2.setPaint(getOutlinePaint()); g2.setStroke(getOutlineStroke()); g2.draw(s); } } }
From source file:com.od.jtimeseries.ui.visualizer.chart.creator.EfficientXYLineAndShapeRenderer.java
private void drawLine(XYItemRendererState state, Graphics2D g2, XYPlot plot, double transX0, double transY0, double transX1, double transY1, Stroke s, Paint p) { PlotOrientation orientation = plot.getOrientation(); if (orientation == PlotOrientation.HORIZONTAL) { state.workingLine.setLine(transY0, transX0, transY1, transX1); } else if (orientation == PlotOrientation.VERTICAL) { state.workingLine.setLine(transX0, transY0, transX1, transY1); }/* w w w . j a va 2 s .co m*/ g2.setStroke(s); g2.setPaint(p); g2.draw(state.workingLine); }
From source file:gov.nih.nci.caintegrator.application.geneexpression.BoxAndWhiskerCoinPlotRenderer.java
private void drawMultipleEllipse(Point2D point, double boxWidth, double oRadius, Graphics2D g2) { Ellipse2D dot1 = new Ellipse2D.Double(point.getX() - (boxWidth / 2) + oRadius, point.getY(), oRadius, oRadius);// ww w . j a v a2s. co m Ellipse2D dot2 = new Ellipse2D.Double(point.getX() + (boxWidth / 2), point.getY(), oRadius, oRadius); g2.draw(dot1); g2.draw(dot2); }