public void draw(ColorMapper mapper, Graphics2D g2d) { final GradientPaint paint = new GradientPaint(0, 0, mapper.getMappedColor(c1), (float) width, (float) height, mapper.getMappedColor(c2)); final RoundRectangle2D r = new RoundRectangle2D.Double(0, 0, width, height, corner * 2, corner * 2); g2d.setPaint(paint); g2d.fill(r); }
RoundRectangle2D.Double bubble = new RoundRectangle2D.Double( 0 + strokePad, 0 + strokePad,
shape = new Rectangle2D.Double(x, y, rect.getWidth(), rect.getHeight()); } else { shape = new RoundRectangle2D.Double(x, y, rect.getWidth(), rect.getHeight(), rx, ry);
private static Area createShape () { Area shape = new Area ( new RoundRectangle2D.Double ( 0, 20, 500, 200, 20, 20 ) ); GeneralPath gp = new GeneralPath ( GeneralPath.WIND_EVEN_ODD ); gp.moveTo ( 230, 20 ); gp.lineTo ( 250, 0 ); gp.lineTo ( 270, 20 ); gp.closePath (); shape.add ( new Area ( gp ) ); return shape; }
JFrame frame = new JFrame(); frame.setUndecorated(true); AWTUtilities.setWindowShape(frame, new RoundRectangle2D.Double(10, 10, 100, 100, 50, 50)); frame.setSize(300, 200); frame.setVisible(true);
JFrame frame = new JFrame(); frame.setUndecorated(true); frame.setShape(new RoundRectangle2D.Double(10, 10, 100, 100, 50, 50)); frame.setSize(300, 200); frame.setVisible(true);
public Shape getShape() { Shape shape = new RoundRectangle2D.Double(-width / 2, -height / 2, width, height, width / 100.0 * roundness, height / 100.0 * roundness); AffineTransform tx = new AffineTransform(); tx.translate(x, -y); tx.rotate(Math.toRadians(-rotation)); return tx.createTransformedShape(shape); } }
RoundRectangle2D.Double bubble = new RoundRectangle2D.Double( 0+strokePad, 0+strokePad,
g2.drawLine(width + 1, 0, width + 1, height); RoundRectangle2D roundCasing = new RoundRectangle2D.Double(0, 2, width, height - 4, width, width); Area area = new Area(casing); area.subtract(new Area(roundCasing)); g2.drawLine(0, height + 1, width, height + 1); RoundRectangle2D roundCasing = new RoundRectangle2D.Double(2, 0, width - 4, height, height, height); Area area = new Area(casing); area.subtract(new Area(roundCasing));
int height = thumbBounds.height - 4; RoundRectangle2D casing = new RoundRectangle2D.Double(0, 0, width, height, width, width); g2.setColor(Color.BLACK); Paint paint = g2.getPaint(); int height = thumbBounds.height - 3 + ANTI_WIDTH; RoundRectangle2D casing = new RoundRectangle2D.Double(0, 0, width, height, height, height); g2.setColor(Color.BLACK);
RoundRectangle2D rr = new RoundRectangle2D.Double(borderWidth, borderWidth, cardWidth - borderWidth * 2, cardHeight - borderWidth * 4 - cornerRadius * 2, cornerRadius - 1, cornerRadius - 1); Area a = new Area(rr); RoundRectangle2D rr2 = new RoundRectangle2D.Double(borderWidth, cardHeight - borderWidth * 4 - cornerRadius * 4, cardWidth - borderWidth * 2, cornerRadius * 4, cornerRadius * 2, cornerRadius * 2);
g2.setColor(bgColor); RoundRectangle2D rect = new RoundRectangle2D.Double(0, 0, c.getWidth() - 1, c.getHeight() - 1, 24, 24); g2.fill(rect);
public class StaticRect { private static final RoundRectangle2D.Double RECTANGLE = new RoundRectangle2D.Double(1, 2, 3, 4, 5, 6); return new RoundRectangle2D.Double(1, 2, 3, 4, 5, 6).hashCode(); @Fork(jvmArgs = "-XX:-EliminateAllocations") public long testNewNoEliminate() { return new RoundRectangle2D.Double(1, 2, 3, 4, 5, 6).hashCode();
@Override public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { Graphics2D g2d = (Graphics2D) g; g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); RoundRectangle2D.Double rectangle = new RoundRectangle2D.Double(x, y, width - 1, height - 1, radius, radius); Area rectangleArea = new Area(rectangle); Area area = new Area(new Rectangle(0, 0, width, height)); area.subtract(rectangleArea); g2d.setClip(area); g2d.setColor(c.getParent().getBackground()); g2d.fillRect(0, 0, width, height); g2d.setClip(null); if (color == null) { g2d.setColor(c.getBackground()); } else { g2d.setColor(color); } g2d.setStroke(stroke); g2d.draw(rectangleArea); }
private static RoundRectangle2D.Double toRoundRect(final Rectangle2D pRectangle, final int pArcW, final int pArcH) { return new RoundRectangle2D.Double( pRectangle.getX(), pRectangle.getY(), pRectangle.getWidth(), pRectangle.getHeight(), pArcW, pArcH); }
GraphicInfo graphicInfo, Class<?> type) { RoundRectangle2D rect = new RoundRectangle2D.Double(graphicInfo.getX(), graphicInfo.getY(), graphicInfo.getWidth(), g.setStroke(originalStroke); } else if (type.equals(Transaction.class)) { RoundRectangle2D outerRect = new RoundRectangle2D.Double(graphicInfo.getX()-3, graphicInfo.getY()-3, graphicInfo.getWidth()+6,
RoundRectangle2D rect = new RoundRectangle2D.Double(x, y, width,
/** * Draws an outlined round-cornered rectangle using this graphics * context's current color. The left and right edges of the rectangle * are at <code>x</code> and <code>x + width</code>, * respectively. The top and bottom edges of the rectangle are at * <code>y</code> and <code>y + height</code>. * @param x the <i>x</i> coordinate of the rectangle to be drawn. * @param y the <i>y</i> coordinate of the rectangle to be drawn. * @param width the width of the rectangle to be drawn. * @param height the height of the rectangle to be drawn. * @param arcWidth the horizontal diameter of the arc * at the four corners. * @param arcHeight the vertical diameter of the arc * at the four corners. * @see java.awt.Graphics#fillRoundRect */ public void drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight){ RoundRectangle2D rect = new RoundRectangle2D.Double(x, y, width, height, arcWidth, arcHeight); draw(rect); }
/** * Fills the specified rounded corner rectangle with the current color. * The left and right edges of the rectangle * are at <code>x</code> and <code>x + width - 1</code>, * respectively. The top and bottom edges of the rectangle are at * <code>y</code> and <code>y + height - 1</code>. * @param x the <i>x</i> coordinate of the rectangle to be filled. * @param y the <i>y</i> coordinate of the rectangle to be filled. * @param width the width of the rectangle to be filled. * @param height the height of the rectangle to be filled. * @param arcWidth the horizontal diameter * of the arc at the four corners. * @param arcHeight the vertical diameter * of the arc at the four corners. * @see java.awt.Graphics#drawRoundRect */ public void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight){ RoundRectangle2D rect = new RoundRectangle2D.Double(x, y, width, height, arcWidth, arcHeight); fill(rect); }
public void drawHighLight(int x, int y, int width, int height) { Paint originalPaint = g.getPaint(); Stroke originalStroke = g.getStroke(); g.setPaint(HIGHLIGHT_COLOR); g.setStroke(THICK_TASK_BORDER_STROKE); RoundRectangle2D rect = new RoundRectangle2D.Double(x, y, width, height, 20, 20); g.draw(rect); g.setPaint(originalPaint); g.setStroke(originalStroke); }