Refine search
private void drawProgressArc(Graphics2D graphics, int x, int y, int w, int h, double radiusStart, double radiusEnd, int strokeWidth, Color color) { Stroke stroke = graphics.getStroke(); graphics.setStroke(new BasicStroke(strokeWidth, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL)); graphics.setColor(color); graphics.draw(new Arc2D.Double( x, y, w, h, radiusStart, radiusEnd, Arc2D.OPEN)); graphics.setStroke(stroke); }
public static void renderPolygon(Graphics2D graphics, Polygon poly, Color color) { graphics.setColor(color); final Stroke originalStroke = graphics.getStroke(); graphics.setStroke(new BasicStroke(2)); graphics.drawPolygon(poly); graphics.setColor(new Color(0, 0, 0, 50)); graphics.fillPolygon(poly); graphics.setStroke(originalStroke); }
g2.drawLine(padding + labelPadding, getHeight() - padding - labelPadding, getWidth() - padding, getHeight() - padding - labelPadding); Stroke oldStroke = g2.getStroke(); g2.setColor(lineColor); g2.setStroke(GRAPH_STROKE); for (int i = 0; i < graphPoints.size() - 1; i++) { int x1 = graphPoints.get(i).x; g2.setStroke(oldStroke); g2.setColor(pointColor); for (int i = 0; i < graphPoints.size(); i++) {
g.fillRect ( 350, 20, 20, 280 ); g.setStroke ( new BasicStroke ( 20.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL ) ); g.translate ( 0, 60 ); arrow.draw ( g ); g.setStroke ( new BasicStroke ( 20.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER ) ); g.translate ( 0, 100 ); arrow.draw ( g ); g.setStroke ( new BasicStroke ( 20.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND ) ); g.translate ( 0, 100 ); arrow.draw ( g ); float arrowLength = 80.0f; BasicStroke stroke = ( BasicStroke ) g.getStroke(); float arrowLength = 80.0f; BasicStroke stroke = ( BasicStroke ) g.getStroke();
public void draw(Graphics2D g) { if (getPointCount() < 2) return; // Since a contour has no fill or stroke information, draw it in black. // We save the current color so as not to disrupt the context. java.awt.Color savedColor = g.getColor(); Stroke savedStroke = g.getStroke(); GeneralPath gp = new GeneralPath(GeneralPath.WIND_EVEN_ODD, getPointCount()); _extendPath(gp); g.setColor(java.awt.Color.BLACK); g.setStroke(DEFAULT_STROKE); g.draw(gp); g.setColor(savedColor); g.setStroke(savedStroke); }
private void drawStraightLabelLine( java.awt.Shape outline, boolean drawingHalo, float thickness, float offset) { Rectangle2D bounds = outline.getBounds2D().getBounds(); double minX = bounds.getMinX(); double maxX = bounds.getMaxX(); if ((Math.abs(maxX - minX) < 0.0000001)) { // nothing to draw return; } // let's se if we are drawing the halo around the underline line if (drawingHalo) { // when drawing the halo we assume that the correct halo configuration has been set graphics.draw(new Line2D.Double(minX, offset, maxX, offset)); } else { // storing the current stroke and setting the stroke according to the specified // thickness Stroke currentStroke = graphics.getStroke(); graphics.setStroke(new BasicStroke(thickness)); // we draw a line with the same color of the text and a stroke of 2 graphics.draw(new Line2D.Double(minX, offset, maxX, offset)); // we need to restore the previous stroke graphics.setStroke(currentStroke); } }
/** * Glyph bounding boxes. */ @Override protected void showGlyph(Matrix textRenderingMatrix, PDFont font, int code, String unicode, Vector displacement) throws IOException { // draw glyph super.showGlyph(textRenderingMatrix, font, code, unicode, displacement); // bbox in EM -> user units Shape bbox = new Rectangle2D.Float(0, 0, font.getWidth(code) / 1000, 1); AffineTransform at = textRenderingMatrix.createAffineTransform(); bbox = at.createTransformedShape(bbox); // save Graphics2D graphics = getGraphics(); Color color = graphics.getColor(); Stroke stroke = graphics.getStroke(); Shape clip = graphics.getClip(); // draw graphics.setClip(graphics.getDeviceConfiguration().getBounds()); graphics.setColor(Color.RED); graphics.setStroke(new BasicStroke(.5f)); graphics.draw(bbox); // restore graphics.setStroke(stroke); graphics.setColor(color); graphics.setClip(clip); }
} else if (i % 10 == 5) { Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[]{5}, 0); Stroke oldstroke = g.getStroke(); g.setStroke(dashed); g.drawLine(0, 200 - 1 - i * height_factor, 400, 200 - 1 - i * height_factor); g.setStroke(oldstroke); } else if (i % 2 == 1) { Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[]{5}, 0); Stroke oldstroke = g.getStroke(); g.setStroke(dashed); g.drawLine(0, 200 - 1 - i * height_factor, 400, 200 - 1 - i * height_factor); g.setStroke(oldstroke);
/** * Filled path bounding boxes. */ @Override public void fillPath(int windingRule) throws IOException { // bbox in user units Shape bbox = getLinePath().getBounds2D(); // draw path (note that getLinePath() is now reset) super.fillPath(windingRule); // save Graphics2D graphics = getGraphics(); Color color = graphics.getColor(); Stroke stroke = graphics.getStroke(); Shape clip = graphics.getClip(); // draw graphics.setClip(graphics.getDeviceConfiguration().getBounds()); graphics.setColor(Color.GREEN); graphics.setStroke(new BasicStroke(.5f)); graphics.draw(bbox); // restore graphics.setStroke(stroke); graphics.setColor(color); graphics.setClip(clip); }