public void fillRoundRectangle( int x, int y, int width, int height, int circleWidth, int circleHeight ) { switchForegroundBackgroundColors(); gc.fillRoundRect( x + xOffset, y + yOffset, width, height, circleWidth, circleHeight ); switchForegroundBackgroundColors(); }
public void fillRoundRectangle( int x, int y, int width, int height, int circleWidth, int circleHeight ) { switchForegroundBackgroundColors(); gc.fillRoundRect( x + xOffset, y + yOffset, width, height, circleWidth, circleHeight ); switchForegroundBackgroundColors(); }
graphics.fillRoundRect( graphics.fillRoundRect(0, 0, width - shadowGap, height - shadowGap, arcs.width, arcs.height); graphics.setColor(getForeground()); graphics.setStroke(new BasicStroke(strokeSize));
g2.fillRoundRect(cx, cy, 70, 40, 10, 10); g2.setColor(Color.WHITE); g2.fillOval(cx + 5, cy + 5, 30, 30); g2.setColor(Color.WHITE); g2.fillOval(cx + 12, cy + 12, 16, 16); g2.fillRoundRect(cx + 50, cy + 5, 15, 10, 5, 5); g2.fillRect(cx + 63, cy + 25, 7, 2); g2.fillRect(cx + 63, cy + 28, 7, 2);
@Signature public void roundRect(int x, int y, int width, int height, int arcWidth, int arcHeight, DrawOptions options) { applyOptions(options); if (options.isOutline()) { gc.drawRoundRect(x, y, width, height, arcWidth, arcHeight); } else { gc.fillRoundRect(x, y, width, height, arcWidth, arcHeight); } }
public void paint(Graphics2D g, StateColorMap colorMap) { Rectangle bounds = g.getClipBounds(); if (startY > bounds.getMaxY() || startY + height < bounds.getMinY()) { return; } int x = line.getX(); int width = line.getWidth(); Color color = colorMap.getColor(stateName); g.setColor(color); g.fillRoundRect(x, startY, width, height, ARC_SIZE, ARC_SIZE); g.setColor(Color.BLACK); }
@Override public void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) { groupG2D.fillRoundRect(x, y, width, height, arcWidth, arcHeight); alphaG2D.fillRoundRect(x, y, width, height, arcWidth, arcHeight); }
public void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) { delegate.fillRoundRect(x, y, width, height, arcWidth, arcHeight); }
private void paintButton(Graphics g, Dimension size, Color startColor, Color endColor) { Graphics2D g2d = createGraphics(g); try { g2d.setPaint(new GradientPaint(0, 0, startColor, 0, size.height, endColor)); g2d.fillRoundRect(0, 0, size.width-1, size.height-1, 9, 9); } finally { g2d.dispose(); } }
private static void paintTooltip(Graphics2D g, Point2D point, String text) { FontMetrics fontMetrics = g.getFontMetrics(); int textWidth = fontMetrics.stringWidth(text); int verticalOffset = 10; Rectangle r = new Rectangle((int) point.getX(), (int) point.getY() + verticalOffset, textWidth, fontMetrics.getHeight()); r.grow(4, 3); g.setColor(TOOLTIP_STROKE_COLOR); g.drawRoundRect(r.x, r.y, r.width, r.height, 8, 8); g.setColor(TOOLTIP_BACKGROUND_COLOR); g.fillRoundRect(r.x, r.y, r.width, r.height, 8, 8); g.setColor(TOOLTIP_TEXT_COLOR); g.drawString(text, (float) point.getX(), (float) point.getY() + fontMetrics.getAscent() + verticalOffset); }
private static void drawColor(Graphics2D g, Color c, int x, int y) { g.setColor(java.awt.Color.WHITE); g.fillRoundRect(x, y, COLOR_SIZE + 6, COLOR_SIZE + 6, 3, 3); g.setColor(java.awt.Color.LIGHT_GRAY); g.drawRoundRect(x, y, COLOR_SIZE + 6, COLOR_SIZE + 6, 3, 3); g.setColor(c.getAwtColor()); g.fillRect(x + 3, y + 3, COLOR_SIZE, COLOR_SIZE); }
JPanel p = new JPanel() { @Override protected void paintComponent(Graphics g) { super.paintComponent(g); Dimension arcs = new Dimension(15,15); //Border corners arcs {width,height}, change this to whatever you want int width = getWidth(); int height = getHeight(); Graphics2D graphics = (Graphics2D) g; graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); //Draws the rounded panel with borders. graphics.setColor(getBackground()); graphics.fillRoundRect(0, 0, width-1, height-1, arcs.width, arcs.height);//paint background graphics.setColor(getForeground()); graphics.drawRoundRect(0, 0, width-1, height-1, arcs.width, arcs.height);//paint border } };
/** * Icon for generic Geometry or Geometry Collection. * * @param color * @param fill * @return Icon */ public static BufferedImage geometry(final Color color, final Color fill) { BufferedImage bi = new BufferedImage(DEFAULT_WIDTH, DEFAULT_HEIGHT, BufferedImage.TYPE_INT_ARGB); Graphics2D gc = (Graphics2D) bi.getGraphics(); gc.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); Stroke stroke = new BasicStroke(1); gc.setStroke(stroke); Color c = color; Color f = fill; if (c == null) c = Color.BLACK; if (f == null) f = Color.LIGHT_GRAY; gc.setColor(f); gc.fillRoundRect(2, 1, 13, 13, 2, 2); gc.setColor(c); gc.drawRoundRect(2, 1, 13, 13, 2, 2); return bi; }
private void paintButton(Graphics g, Dimension size, Range<Color> grandientColors) { Graphics2D g2d = createGraphics(g); try { g2d.setPaint(new GradientPaint(0, 0, grandientColors.start(), 0, size.height, grandientColors.end())); g2d.fillRoundRect(0, 0, size.width-1, size.height-1, Border.RADIUS, Border.RADIUS); } finally { g2d.dispose(); } }
private static BufferedImage createShadowImage(ShadowKey key) { int w = key.width; int h = key.height; int arc = 10; int shadowSize = 50; BufferedImage base = GraphicsUtilities.createCompatibleTranslucentImage(w, h); Graphics2D g2 = base.createGraphics(); g2.setColor(Color.WHITE); g2.fillRoundRect(0, 0, w, h, arc, arc); g2.dispose(); ShadowRenderer renderer = new ShadowRenderer(shadowSize, 0.5f, Color.GRAY); return renderer.createShadow(base); }
g2.fillRoundRect(outerBorderWidth, outerBorderWidth, imgW - 2 * outerBorderWidth, imgH - 2 * outerBorderWidth, outerCornerRadius, outerCornerRadius); } else { g2.fillRect(outerBorderWidth, outerBorderWidth, imgW - 2 * outerBorderWidth, imgH - 2 * outerBorderWidth);
g.fillRoundRect(0, 0, cardWidth, cardHeight, cornerRadius, cornerRadius);
JFrame f = new JFrame(); f.setLayout(null); f.setDefaultCloseOperation(3); f.setSize(500, 500); JPanel p = new JPanel() { @Override protected void paintComponent(Graphics g) { super.paintComponent(g); Dimension arcs = new Dimension(15,15); int width = getWidth(); int height = getHeight(); Graphics2D graphics = (Graphics2D) g; graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); //Draws the rounded opaque panel with borders. graphics.setColor(getBackground()); graphics.fillRoundRect(0, 0, width-1, height-1, arcs.width, arcs.height);//paint background graphics.setColor(getForeground()); graphics.drawRoundRect(0, 0, width-1, height-1, arcs.width, arcs.height);//paint border } }; p.setBounds(10,10,100,30); p.setOpaque(false); f.getContentPane().setBackground(Color.red); f.add(p); f.show();
g2.fillRoundRect(x, y, w, h, arc, arc);
@Override protected void paintComponent(Graphics gfx) { super.paintComponent(gfx); Dimension arcs = new Dimension(radius, radius); Graphics2D gfx2d = (Graphics2D) gfx; gfx2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); gfx2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); // background Color background = getBackground(); if (!isEnabled() && backgroundDisabled != null) { background = backgroundDisabled; } else if (mousePressed && pressedBackground != null && isEnabled()) { background = pressedBackground; } else if (mouseOver && hoverBackground != null && isEnabled()) { background = hoverBackground; } Color foreground = getForeground(); if (!isEnabled() && foregroundDisabled != null) { foreground = foregroundDisabled; } gfx2d.setColor(background); gfx2d.fillRoundRect(0, 0, getWidth() - 1, getHeight() - 1, arcs.width, arcs.height); // border gfx2d.setColor(foreground); gfx2d.drawRoundRect(0, 0, getWidth() - 1, getHeight() - 1, arcs.width, arcs.height); }