@Override protected void paintThumb(Graphics g, JComponent c, Rectangle thumbBounds) { Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.translate(thumbBounds.x + 1, thumbBounds.y + 2); RoundRectangle2D casing = new RoundRectangle2D.Double(0, 0, width, height, width, width); g2.setColor(Color.BLACK); Paint paint = g2.getPaint(); g2.setPaint(new GradientPaint(0, 0, new Color(0x818a9b), 0, height, new Color(0x3a4252))); g2.fill(casing); g2.setPaint(paint); Stroke stroke = g2.getStroke(); g2.setStroke(new BasicStroke(2.0f)); g2.draw(casing); g2.setStroke(stroke); int height = thumbBounds.height - 3 + ANTI_WIDTH; RoundRectangle2D casing = new RoundRectangle2D.Double(0, 0, width, height, height, height); g2.setColor(Color.BLACK); Stroke stroke = g2.getStroke(); g2.setStroke(new BasicStroke(2.0f)); g2.draw(casing); g2.setStroke(stroke);
private void paintShapeNode_0_0_0_1(Graphics2D g) { RoundRectangle2D.Double shape1 = new RoundRectangle2D.Double(-12.6668119430542, 1.0308878421783447, 9.45958423614502, 12.219721794128418, 1.428767442703247, 1.428767442703247); g.setPaint(new LinearGradientPaint(new Point2D.Double(-13.97996711730957, 7.864083766937256), new Point2D.Double(-2.027459144592285, 7.864083766937256), new float[] {0.0f,1.0f}, new Color[] {new Color(92, 184, 255, 255),new Color(213, 239, 255, 255)}, MultipleGradientPaint.CycleMethod.NO_CYCLE, MultipleGradientPaint.ColorSpaceType.SRGB, new AffineTransform(0.8083381652832031f, 0.0f, 0.0f, 0.8346183896064758f, -1.4673138856887817f, 0.577239990234375f))); g.fill(shape1); g.setPaint(new Color(0, 119, 203, 255)); g.setStroke(new BasicStroke(0.20534329f,0,2,4.0f,null,0.0f)); g.draw(shape1); }
Color borderColor = new Color(this.headerTextColor); Color activeColor = new Color(this.headerBackgroundColor); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2d.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY); g2d.setStroke(new BasicStroke(1)); g2d.setColor(borderColor); Rectangle2D border = new Rectangle2D.Double(1, 1, w - 3, h - 3); RoundRectangle2D round = new RoundRectangle2D.Double(1, 1, w - 3, h - 3, 2, 2); g2d.draw(round); Color lightBlue = new Color(216, 226, 240); Paint gradient1 = new GradientPaint(w - 4, h - 4, lightBlue, 2, 2, Color.white); g2d.setPaint(gradient1); border = new Rectangle2D.Double(2, 2, w - 4, h - 4); g2d.fill(border); border = new Rectangle2D.Double(3, 3, w - 6, h - 6); gradient1 = new GradientPaint(3, 3, lightBlue, w - 6, h - 6, borderColor); g2d.setPaint(gradient1);
public void paint(Graphics2D g2d) { g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); Color gradientColorStart = Color.WHITE; Color gradientColorEnd = new Color(this.getHeaderBackgroundColor()); Rectangle2D inSquare = new Rectangle2D.Double(2, 2, DIMENSIONS.getWidth() - 4, DIMENSIONS.getHeight() - 4); GradientPaint paint = new GradientPaint((float) 2, (float) 2, gradientColorStart, (float) DIMENSIONS.getWidth() - 2, (float) DIMENSIONS.getHeight() - 2, gradientColorEnd); g2d.setPaint(paint); g2d.fill(inSquare); RoundRectangle2D outSquare = new RoundRectangle2D.Double(0, 0, DIMENSIONS.getWidth(), DIMENSIONS.getHeight(), 4, 4); Rectangle2D midSquare = new Rectangle2D.Double(1, 1, DIMENSIONS.getWidth() - 2, DIMENSIONS.getHeight() - 2); g2d.setColor(new Color(this.getHeaderBackgroundColor())); Area area2 = new Area(outSquare); area2.subtract(new Area(midSquare)); g2d.fill(area2); g2d.setColor(new Color(this.getHeaderGradientColor())); Area area = new Area(midSquare); area.subtract(new Area(inSquare)); g2d.fill(area); } }
shadowPad = shadowWidth; stroke = new BasicStroke(thickness); strokePad = thickness/2; RoundRectangle2D.Double bubble = new RoundRectangle2D.Double( 0+strokePad, 0+strokePad, ); Area area = new Area(bubble); g2.setRenderingHints(hints); g2.setColor(color); g2.setStroke(stroke); g2.draw(area); l1.setBorder(new ThreeDimensionalBorder(Color.MAGENTA.darker(),128,4)); p.add(l1); p.add(l2); p.add(l3);
f.getContentPane().add(new NimbusTabbedPaneTest().makeUI()); f.setSize(400, 400); f.setLocationRelativeTo(null); f.setVisible(true); }); Graphics2D g2 = (Graphics2D) g.create(0, 0, width, height + ex); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); int w = width - 6 - 1; int h = height + r; for (int i = 0; i < 3; i++) { g2.setColor(new Color(0, 0, 0, 20)); g2.fill(new RoundRectangle2D.Double(x - i, y - i, w + i + i, h, r, r)); g2.setColor(color); g2.fill(new RoundRectangle2D.Double(x, y, w, h + 4, r, r)); g2.dispose(); RenderingHints.VALUE_ANTIALIAS_ON); RoundRectangle2D r = new RoundRectangle2D.Double( h += OVERPAINT; RoundRectangle2D r = new RoundRectangle2D.Double(
public void paintComponent(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); if (this.isOpaque()) { Color bg = getBackground(); g2.setColor(new Color(bg.getRed(), bg.getGreen(), bg.getBlue())); g2.fillRoundRect(0, 0, getWidth() - 1, getHeight() - 1, radius, radius); } g2.setColor(new Color(164, 164, 164)); if (dashed) { BasicStroke dashedStroke = new BasicStroke(dashThickness, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, new float[]{7.0f}, 0.0f); g2.setStroke(dashedStroke); g2.draw(new RoundRectangle2D.Double(0, 0, getWidth() - 1, getHeight() - 1, radius, radius)); } else { g2.drawRoundRect(0, 0, getWidth() - 1, getHeight() - 1, radius, radius); } }
private static final int PREF_H = PREF_W; private static final Color SELECTED_COLOR = Color.RED; private static final Stroke SELECTED_STROKE = new BasicStroke(8f); private List<Shape> shapes = new ArrayList<>(); private Map<Shape, Color> shapeColorMap = new HashMap<>(); shapes.add(shape); shape = new Rectangle2D.Double(140, 140, 200, 200); shapeColorMap.put(shape, Color.BLUE); shapes.add(shape); shape = new RoundRectangle2D.Double(200, 200, 80, 80, 10, 10); shapeColorMap.put(shape, Color.GREEN); shapes.add(shape); Graphics2D newG2 = (Graphics2D) g2.create(); newG2.setColor(SELECTED_COLOR); newG2.setStroke(SELECTED_STROKE); newG2.draw(selectedShape); newG2.dispose(); // because this is a created Graphics object JFrame frame = new JFrame("GraphicsEg"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().add(new GraphicsEg()); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true);
setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridwidth = GridBagConstraints.REMAINDER; add(fancyPB, gbc); add(normalPB, gbc); protected void paintDeterminate(Graphics g, JComponent c) { Graphics2D g2d = (Graphics2D) g.create(); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); RoundRectangle2D outline = new RoundRectangle2D.Double((iStrokWidth / 2), (iStrokWidth / 2), width - iStrokWidth, height - iStrokWidth, height, height); Color[] colors = {progressBar.getBackground(), progressBar.getBackground().brighter(), progressBar.getBackground().darker()}; LinearGradientPaint p = new LinearGradientPaint(start, end, dist, colors); g2d.setPaint(p); RoundRectangle2D fill = new RoundRectangle2D.Double(iStrokWidth * 2, iStrokWidth * 2, iInnerWidth, iInnerHeight, iInnerHeight, iInnerHeight); g2d.fill(fill); g2d.dispose();
Graphics2D g2d = (Graphics2D)g.create(); g2d.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON ); g2d.setStroke( new BasicStroke( 1, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND ) ); Color color = new Color( 210, 210, 210 ); g2d.setColor( color ); int height = progressBar.getHeight(); RoundRectangle2D outline = new RoundRectangle2D.Double( 2, 3, width - 3, height - 7, height - 5, height - 5 ); g2d.draw( outline ); color = new Color( 63, 152, 83 ); g2d.setColor( color ); g2d.setStroke( new BasicStroke( iStrokWidth, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND ) ); Color[] colors = {color, color, color.darker()}; LinearGradientPaint p = new LinearGradientPaint( start, end, dist, colors ); g2d.setPaint( p ); RoundRectangle2D fill = new RoundRectangle2D.Double( iStrokWidth * 2, iStrokWidth * 2, iInnerWidth, iInnerHeight, iInnerHeight, iInnerHeight );
model.addElement ( new CustomData ( new Color ( 209, 52, 23 ), 1, "Anna Williams" ) ); model.addElement ( new CustomData ( new Color ( 135, 163, 14 ), 0, "Lucy Frank" ) ); model.addElement ( new CustomData ( new Color ( 204, 204, 204 ), 0, "Joe Fritz" ) ); model.addElement ( new CustomData ( new Color ( 90, 90, 90 ), 3, "Mikle Garin" ) ); list.setCellRenderer ( new CustomListRenderer ( list ) ); list.setBorder ( BorderFactory.createEmptyBorder ( 5, 5, 5, 5 ) ); frame.add ( list ); g2d.setRenderingHint ( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON ); Area area = new Area ( new Ellipse2D.Double ( 0, 0, 36, 36 ) ); area.add ( new Area ( new RoundRectangle2D.Double ( 18, 3, getWidth () - 18, 29, 6, 6 ) ) ); g2d.setPaint ( selectionColor ); g2d.fill ( area ); g2d.setPaint ( Color.WHITE ); g2d.setPaint ( data.getCircleColor () ); g2d.fill ( new Ellipse2D.Double ( 5, 5, 26, 26 ) ); g2d.drawImage ( tipIcon.getImage (), 5 + 13 - tipIcon.getIconWidth () / 2, 5 + 13 - tipIcon.getIconHeight () / 2, null ); g2d.drawImage ( crossIcon.getImage (), getWidth () - 9 - 5 - crossIcon.getIconWidth () / 2, getHeight () / 2 - crossIcon.getIconHeight () / 2, null ); final Font oldFont = g2d.getFont (); g2d.setFont ( oldFont.deriveFont ( oldFont.getSize () - 1f ) ); final FontMetrics fm = g2d.getFontMetrics ();
ImageUtils.createCompatibleImage(getWidth(), getHeight()); setShape(new RoundRectangle2D.Double(0, 0, getWidth(), getHeight(), 20, 20)); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.drawImage(buffer2, 0, 0,null); Shape originalClip = g2.getClip(); Shape roundClip = new RoundRectangle2D.Double(0, 0, getWidth() - 1, getHeight() - 1, 20, 20); CanvasWindow.BORDER_COLOR_KEY)); g2.setStroke(new BasicStroke(1)); g2.draw(new RoundRectangle2D.Double(0, 0, getWidth() - 1, getHeight() - 1, 20, 20)); g2.dispose(); g.drawImage(buffer, 0, 0, this.getWidth(), this.getHeight(), null);
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); Composite original = g2.getComposite(); style.getBaseValues().getFloat( CanvasWindow.TITLE_TRANSPARENCY_KEY)); g2.setComposite(ac1); g2.setPaint(paint); g2.fill(new RoundRectangle2D.Double(0, 0, d.width - 0.5, d.height, 20, 20)); RenderingHints.VALUE_ANTIALIAS_ON); g2.setStroke(new BasicStroke(style.getBaseValues().getFloat( CanvasWindow.BORDER_THICKNESS_KEY))); g2.setColor(style.getBaseValues().getColor( CanvasWindow.BORDER_COLOR_KEY)); g2.draw(new RoundRectangle2D.Double(0, 0, d.width - 1.0, d.height - 0.5, 19.5, 19.5)); g.drawImage(buffer, 0, 0, null);
Graphics2D g2d = (Graphics2D) g.create(); g2d.setComposite(AlphaComposite.SrcOver.derive(toPaintEnabled ? 1.0f : 0.5f)); Shape clip = g2d.getClip(); RoundRectangle2D.Double roundRect = new RoundRectangle2D.Double(rect.x, rect.y, rect.width - 1, rect.height - 1, 6, 6); g2d.clip(roundRect); buttonRendererPane.paintComponent(g2d, rendererButton, c, rect.x - rect.width / 2, rect.y - rect.height / 2, 2 * rect.width,
gui.add(l1); l2.setBackground(Color.YELLOW); l2.setOpaque(true); gui.add(l2); p1.add(new JLabel("Panel 1")); p1.setBorder(brdrRight); p1.setOpaque(false); this.color = color; stroke = new BasicStroke(thickness); strokePad = thickness / 2; RoundRectangle2D.Double bubble = new RoundRectangle2D.Double( 0 + strokePad, 0 + strokePad, Area area = new Area(bubble); area.add(new Area(pointer)); g2.setRenderingHints(hints); g2.setColor(color); g2.setStroke(stroke); g2.draw(area);
frame.add(new TestPane()); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); setLayout(new GridBagLayout()); JLabel label = new JLabel("Test"); label.setBorder(new RoundedBorder(Color.BLACK, 20)); add(label); Graphics2D g2d = (Graphics2D) g.create(); g2d.setColor(color); g2d.draw(new RoundRectangle2D.Double(x, y, width - 1, height - 1, gap, gap)); g2d.dispose();
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); double y = getAppletSize().height / 2.0 - height; RoundRectangle2D bkgRect = new RoundRectangle2D.Double( x, y, width, height, 8, 8); g2.setColor(Color.BLACK); g2.fill(bkgRect); RoundRectangle2D rect = new RoundRectangle2D.Double( x + strokeWidth, y, (width - (strokeWidth) * 2f) / 100 * progress, height, 5, 5); g2.setStroke(new BasicStroke(blackStrokeWidth)); g2.setColor(Color.BLACK); width = getAppletSize().width - blackStrokeWidth - 0.5; RoundRectangle2D bkgRectWhite = new RoundRectangle2D.Double( x, y, width, height, 5, 5); g2.setStroke(new BasicStroke(strokeWidth)); g2.setColor(Color.WHITE);
final List<MyDrawable> myDrawables = new ArrayList<>(); myDrawables.add(new MyDrawable(new Line2D.Double(100, 40, 400, 400), Color.red, new BasicStroke(40))); myDrawables.add(new MyDrawable(new Ellipse2D.Double(50, 10, 400, 400), Color.blue, new BasicStroke(18))); myDrawables.add(new MyDrawable(new Rectangle2D.Double(40, 200, 300, 300), Color.cyan, new BasicStroke(25))); myDrawables.add(new MyDrawable(new RoundRectangle2D.Double(75, 75, 490, 450, 40, 40), Color.green, new BasicStroke(12))); frame.getContentPane().add(drawChit); frame.pack(); frame.setLocationByPlatform(true); frame.setVisible(true); Color oldColor = g2.getColor(); Stroke oldStroke = g2.getStroke(); g2.setColor(color); g2.setStroke(stroke); g2.draw(shape); g2.setColor(oldColor); g2.setStroke(oldStroke);
g2.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)); Shape firstClip = g.getClip(); RoundRectangle2D rect = new RoundRectangle2D.Double(); double arc = Math.ceil(getSize().getHeight() / 3); rect.setRoundRect(0, 0, Math.ceil(getSize().getWidth()), Math.ceil(getSize().getHeight()), arc, arc); Area secondClip = new Area(getBounds()); secondClip.subtract(new Area(rect)); Area finalClip = new Area(firstClip); finalClip.subtract(secondClip); g2.setClip(finalClip); super.paintComponent(g2); gradients = new Color[] { new Color(184, 207, 229), new Color(122, 138, 153), new Color(184, 207, 229) }; g2.setColor(gradients[i]); g2.drawRoundRect(i+1, i+1, (int)Math.ceil(getSize().getWidth()-2)-(i*2), (int)Math.ceil(getSize().getHeight()-2)-(i*2), (int)arc, (int)arc); frame.getContentPane().setLayout(new FlowLayout()); frame.getContentPane().add(sButton); frame.setSize(250, 250); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true);
t.concatenate(rotate); t.concatenate(translate); g2d.setTransform(t); AffineTransform scale = AffineTransform.getScaleInstance(getWidth(), getHeight()); for (ShapeAndColor shape : shapes) { Area area = new Area(shape.getShape()); g2d.setColor(shape.getColor()); area.transform(scale); g2d.fill(area); h = Math.min(h, 1 - y) / 2; double a = Math.min(w, h) / 10.0; RoundRectangle2D.Double shape = new RoundRectangle2D.Double(x, y, w, h, a, a); Color color = new Color(r.nextInt(256), r.nextInt(256), r.nextInt(256)); shapes.add(new ShapeAndColor(shape, color)); frame.add(panel); frame.setSize(600, 600); frame.setVisible(true); Timer t = new Timer(0, new ActionListener() {