Refine search
public static BufferedImage makeRoundedCorner(BufferedImage image, int cornerRadius) { int w = image.getWidth(); int h = image.getHeight(); BufferedImage output = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB); Graphics2D g2 = output.createGraphics(); // This is what we want, but it only does hard-clipping, i.e. aliasing // g2.setClip(new RoundRectangle2D ...) // so instead fake soft-clipping by first drawing the desired clip shape // in fully opaque white with antialiasing enabled... g2.setComposite(AlphaComposite.Src); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.setColor(Color.WHITE); g2.fill(new RoundRectangle2D.Float(0, 0, w, h, cornerRadius, cornerRadius)); // ... then compositing the image on top, // using the white shape from above as alpha source g2.setComposite(AlphaComposite.SrcAtop); g2.drawImage(image, 0, 0, null); g2.dispose(); return output; }
argbBR=readInt(28, cmddata); argbBL=readInt(32, cmddata); g2.setStroke(new java.awt.BasicStroke(thickness)); updatePaintContext(g2, x, y, width, height, argbTL, argbTR, argbBL, argbBR); g2.drawRect(x+thickness/2, y+thickness/2, width-thickness, height-thickness); g2.fillRect(x, y, width, height); argbBL=readInt(28, cmddata); g2.setComposite(java.awt.AlphaComposite.getInstance(java.awt.AlphaComposite.SRC)); g2.setBackground(new java.awt.Color(argbTL, true)); g2.clearRect(x, y, width, height); java.awt.Color blendColor = new java.awt.Color(blend, true); java.awt.image.RescaleOp colorScaler = new java.awt.image.RescaleOp( blendColor.getRGBComponents(null), new float[] { 0f, 0f, 0f, 0f }, null); java.awt.RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY); g2.setComposite(java.awt.AlphaComposite.Src); java.awt.Shape imageArea = new java.awt.geom.RoundRectangle2D.Float(0, 0, destWidth, destHeight, maskCornerArc, maskCornerArc); g2.setClip(imageArea); g2.drawImage(srcImg, 0, 0, destWidth, destHeight, null);
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); BufferedImage buffer = GraphicsManager.gc.createCompatibleImage(this.getWidth(), this.getHeight(), Transparency.TRANSLUCENT); Graphics2D gb = buffer.createGraphics(); gb.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.setPaint(new GradientPaint(0, -buttonHeight, Color.darkGray, 0, buttonHeight, buttonColor, false)); g2.fillRoundRect(INSET, INSET, buttonWidth, buttonHeight, arc, arc); g2.setColor(Color.darkGray); gb.setColor(buttonColor.darker()); gb.fillRoundRect(INSET, INSET, buttonWidth, buttonHeight, arc, arc); gb.setColor(Color.darkGray); gb.setColor(buttonColor); gb.setClip(new RoundRectangle2D.Float(INSET, INSET, highlightWidth, highlightHeight, highlightArc, highlightArc)); gb.fillRoundRect(INSET, INSET, buttonWidth, buttonHeight, arc, arc); float y = (float) ((this.getHeight() / 2) + (textBounds.getHeight() / 2)) - metrics.getDescent(); g.setColor(Color.black); for (int i = 0; i < shadowPositionArray.length; i++) { int dx = shadowPositionArray[i][0]; int dy = shadowPositionArray[i][1]; g2.setColor(new Color(0, 0, 0, shadowColorArray[i])); g2.drawString(text, x + (int) ((dx) * offsetSize), y + (int) ((dy) * offsetSize));
g2.setRenderingHint(java.awt.RenderingHints.KEY_INTERPOLATION, java.awt.RenderingHints.VALUE_INTERPOLATION_BILINEAR); g2.setRenderingHint(java.awt.RenderingHints.KEY_ALPHA_INTERPOLATION, java.awt.RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY); g2.setRenderingHint(java.awt.RenderingHints.KEY_ANTIALIASING, java.awt.RenderingHints.VALUE_ANTIALIAS_ON); if (op.renderColor != null && bi instanceof java.awt.image.BufferedImage) float currAlpha = op.renderColor.getAlpha() / 255.0f; java.awt.Color textColor = new java.awt.Color((int)(op.renderColor.getRed() * currAlpha), (int)(op.renderColor.getGreen() * currAlpha), (int)(op.renderColor.getBlue() * currAlpha), (int)(currAlpha*255)); java.awt.image.RescaleOp colorScaler = new java.awt.image.RescaleOp( g2.fill(new java.awt.geom.RoundRectangle2D.Float(0, 0, op.primitive.shapeWidth, op.primitive.shapeHeight, op.primitive.cornerArc, op.primitive.cornerArc)); else g2.draw(new java.awt.geom.RoundRectangle2D.Float(thicky/2, thicky/2, op.primitive.shapeWidth - thicky, op.primitive.shapeHeight - thicky, op.primitive.cornerArc, op.primitive.cornerArc)); fixedRects[j] = foofer.getBounds(); rectRounds[j] = Math.round(foofer.arcwidth); fixedRects[j + op.legacyRegions.size()] = foofer.getBounds(); rectRounds[j + op.legacyRegions.size()] = Math.round(foofer.arcwidth);
GdiObject gdiObj; int gdiIndex; g.setPaintMode(); g2d.setStroke(solid); float h = vpH; g2d.setColor( Color.black ); Color clr = new Color( mr.elementAt( 1 ), mr.elementAt( 2 ), mr.elementAt( 3 ) ); g2d.setColor( (Color)gdiObj.obj ); penObject = gdiIndex; break; new RoundRectangle2D.Float(x1, y1, x2-x1, y2-y1, x3, y3); frgdColor = new Color( mr.elementAt( 0 ), mr.elementAt( 1 ), mr.elementAt( 2 ) );
@Override protected void paintComponent(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); g2.translate(MaterialShadow.OFFSET_LEFT, MaterialShadow.OFFSET_TOP); g2.setColor(getBackground()); g2.fill(new RoundRectangle2D.Float(0, 0, getWidth() - offset_lr, getHeight() - offset_td, borderRadius*2, borderRadius*2)); g2.setColor(new Color(rippleColor.getRed() / 255f, rippleColor.getBlue() / 255f, rippleColor.getBlue() / 255f, 0.12f)); if ((type == Type.FLAT && isMouseOver) || isFocusOwner()) { g2.fill(new RoundRectangle2D.Float(0, 0, getWidth() - offset_lr, getHeight() - offset_td, borderRadius*2, borderRadius*2)); g2.setColor(new Color(bg.getRed() / 255f, bg.getGreen() / 255f, bg.getBlue() / 255f, 0.6f)); g2.fill(new RoundRectangle2D.Float(0, 0, getWidth() - offset_lr, getHeight() - offset_td, borderRadius*2, borderRadius*2)); FontMetrics metrics = g.getFontMetrics(getFont()); int x = (getWidth() - offset_lr - metrics.stringWidth(getText().toUpperCase())) / 2; int y = (getHeight() - offset_td - metrics.getHeight()) / 2 + metrics.getAscent(); g2.setClip(new RoundRectangle2D.Float(0, 0, getWidth() - offset_lr, getHeight() - offset_td, Math.max(borderRadius*2 - 4, 0), Math.max(borderRadius*2 - 4, 0))); g2.setColor(rippleColor); ripple.paint(g2);
g2.setComposite(AlphaComposite.Src); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.setColor(Color.WHITE); g2.fill(new RoundRectangle2D.Float(0, 0, w, h, cornerRadius, cornerRadius)); g2.setComposite(AlphaComposite.SrcAtop); g2.drawImage(image, 0, 0, null); g2.dispose(); protected void paintComponent(Graphics g) { super.paintComponent(g); Color shadowColorA = new Color(shadowColor.getRed(), shadowColor.getGreen(), shadowColor.getBlue(), shadowAlpha); Graphics2D graphics = (Graphics2D) g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); RoundRectangle2D r = new RoundRectangle2D.Float(x, y, size-1, size-1, radius, radius ); g2.setColor( new Color( 255, 255, 0, 127) ); g2.fill(r); g2.setStroke( new BasicStroke(3));
frame.setBackground(new Color(0, 0, 0, 0)); BackgroundPane pane = new BackgroundPane(); pane.setMessage("Boo, This is a popup..."); protected void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2d = (Graphics2D) g.create(); g2d.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2d.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY); g2d.setRenderingHint(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_ENABLE); g2d.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON); new float[]{0f, 1f}, new Color[]{Color.GRAY, Color.BLACK}); RoundRectangle2D frame = new RoundRectangle2D.Float(0, 0, getWidth() - 1, getHeight() - 1, 20, 20); g2d.setPaint(glp); g2d.fill(frame); g2d.setColor(Color.WHITE); g2d.draw(frame);
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); BufferedImage buffer = GraphicsManager.gc.createCompatibleImage(this.getWidth(), this.getHeight(), Transparency.TRANSLUCENT); Graphics2D gb = buffer.createGraphics(); gb.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); int buttonWidth = this.getWidth() - (INSET * 2); int arc = buttonHeight; Color topColoring = backgroundColor.darker(); Color bottomColoring = backgroundColor.darker(); gb.setPaint(new GradientPaint(0, INSET, topColoring, 0, buttonHeight, bottomColoring, false)); int highlightWidth = buttonWidth - (HIGHLIGHT_INSET * 2); int highlightArc = highlightHeight; topColoring = backgroundColor.brighter().brighter().brighter().brighter(); bottomColoring = backgroundColor.brighter().brighter().brighter().brighter(); gb.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, .8f)); gb.setPaint(new GradientPaint(0, INSET + HIGHLIGHT_INSET, topColoring, 0, INSET + HIGHLIGHT_INSET + (highlightHeight / 2), backgroundColor.brighter(), false)); gb.setClip(new RoundRectangle2D.Float(INSET + HIGHLIGHT_INSET, INSET + HIGHLIGHT_INSET, highlightWidth, highlightHeight / 2, highlightHeight / 3, highlightHeight / 3)); gb.fillRoundRect(INSET + HIGHLIGHT_INSET, INSET + HIGHLIGHT_INSET, highlightWidth, highlightHeight, highlightArc, highlightArc);
@Override public void paintIcon(Component c, Graphics g, int x, int y) { Graphics2D g2 = (Graphics2D) g.create(); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.translate(x, y); g2.setStroke(new BasicStroke(a)); g2.setPaint(linec); g2.draw(new RoundRectangle2D.Float(a, a, size - 2 * a - 1, size - 2 * a - 1, r, r)); // draw bounding box g2.setStroke(new BasicStroke(b)); g2.setColor(UIManager.getColor("Panel.background")); g2.drawLine(1 * f, 0 * f, 1 * f, 4 * f); g2.drawLine(2 * f, 0 * f, 2 * f, 4 * f); g2.drawLine(3 * f, 0 * f, 3 * f, 4 * f); g2.drawLine(0 * f, 1 * f, 4 * f, 1 * f); g2.drawLine(0 * f, 2 * f, 4 * f, 2 * f); g2.drawLine(0 * f, 3 * f, 4 * f, 3 * f); // draw arrow g2.setPaint(linec); Rectangle2D b = s.getBounds(); Point2D.Double p = new Point2D.Double(b.getX() + b.getWidth() / 2d, b.getY() + b.getHeight() / 2d); AffineTransform toCenterAT = AffineTransform.getTranslateInstance(size / 2d - p.getX(), size / 2d - p.getY()); g2.fill(toCenterAT.createTransformedShape(s)); g2.translate(-x, -y); g2.dispose(); }
Graphics2D g2d = (Graphics2D) g.create(); g2d.drawImage(img, p.x, p.y, this); drawText(g2d, "Exit Game", getExitGameBounds()); g2d.dispose(); Math.min(bounds.width, bounds.height), new float[]{0f, 1f}, new Color[]{new Color(252, 180, 42), new Color(97, 205, 181)} ); g2d.setPaint(rpg); RoundRectangle2D fill = new RoundRectangle2D.Float(bounds.x, bounds.y, bounds.width, bounds.height, 22, 22); g2d.fill(fill); g2d.setColor(Color.WHITE); g2d.drawString( text, bounds.x + ((bounds.width - fm.stringWidth(text)) / 2),
Color transground = new Color( background.getRed(), background.getGreen(), background.getBlue(), 195 ); g.setColor( transground ); g.fillRoundRect( 0, 0, size.width, size.height, 6, 3 ); transground = new Color( foreground.getRed(), foreground.getGreen(), foreground.getBlue(), 195 ); g.setColor( transground ); final RoundRectangle2D.Float paintTextR = new RoundRectangle2D.Float( insets.left + 3, insets.top, size.height - (insets.top + insets.bottom), 10, 10 ); g.setFont( font ); SwingUtilities2.drawString( comp, g, tipText, (int)paintTextR.getX(), (int)paintTextR.getY() + metrics.getAscent() ); transground = new Color( foreground.getRed(), foreground.getGreen(), foreground.getBlue(), 63 ); g.setColor( transground );
@Override public void paintOverlay( Graphics g ){ Graphics2D g2 = (Graphics2D)g.create(); g2.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON ); g2.setPaint( new GradientPaint( 0, 0, new Color( 150, 150, 150 ), 0, h/2, Color.WHITE )); g2.setPaint( new GradientPaint( 0, 0, new Color( 150, 150, 150 ), w/2, 0, Color.WHITE )); switch( orientation ){ case TOP_OF_DOCKABLE: g2.setClip( new RoundRectangle2D.Float( 0, 0, w, h+arc, 2*arc, 2*arc )); break; case BOTTOM_OF_DOCKABLE: g2.setClip( new RoundRectangle2D.Float( 0, -arc, w, h+arc, 2*arc, 2*arc )); break; case LEFT_OF_DOCKABLE: g2.setClip( new RoundRectangle2D.Float( 0, 0, w+arc, h, 2*arc, 2*arc )); break; case RIGHT_OF_DOCKABLE: g2.setClip( new RoundRectangle2D.Float( -arc, 0, w+arc, h, 2*arc, 2*arc )); break;
public void paintBorder( Component c, Graphics g, int x, int y, int width, int height ) { Graphics2D g2 = (Graphics2D)g.create(); g2.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON ); int r = DEF_DIAMETER; g2.translate( x, y ); g2.setColor( _color ); g2.fillRect( r/2, 0, width - r - 1, _insets.top ); g2.fillRect( 0, r/2, _insets.left, height - r - 1 ); g2.fillRect( r/2 , height - _insets.bottom - 1, width - r - 1, _insets.bottom ); g2.fillRect( width - _insets.right - 1, r/2, _insets.right, height - r - 1 ); RoundRectangle2D round = new RoundRectangle2D.Float( 0, 0, width - 1, height - 1, r, r ); Container parent = c.getParent(); if( parent != null ) { g2.setColor( parent.getBackground() ); Area corner = new Area( new Rectangle2D.Float( 0, 0, width, height ) ); corner.subtract( new Area( round ) ); g2.fill( corner ); } BasicStroke stroke = new BasicStroke( 1.0f ); g2.setStroke( stroke ); g2.setColor( _color ); g2.draw( new Arc2D.Double( 0, 0, r, r, 90, 90, Arc2D.OPEN ) ); g2.draw( new Arc2D.Double( width - r - 2, 0, r, r, 90, -90, Arc2D.OPEN ) ); g2.draw( new Arc2D.Double( width - r - 2, height - r - 2, r, r, 0, -90, Arc2D.OPEN ) ); g2.draw( new Arc2D.Double( 0, height - r - 2, r, r, 180, 90, Arc2D.OPEN ) ); g2.dispose(); }
super.paintComponent(g); Graphics2D g2d = (Graphics2D) g; g2d.setFont(new Font("Bebas Neue", Font.PLAIN, 25)); g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); g2d.setColor(new Color(168, 168, 168, 200)); FontMetrics fm = g2d.getFontMetrics(); int y = (getHeight() - fm.getHeight()) + fm.getAscent(); g2d.drawString("Project Zenith", 10, y); g2d.setColor(new Color(0xFFA6A6)); g2d.fill(closeRect); protected void paintComponent(Graphics g) { super.paintComponent(g); RoundRectangle2D loginRect = new RoundRectangle2D.Float(0, 0, getWidth() - 1, getHeight() - 1, 20, 20); Graphics2D g2d = (Graphics2D) g; g2d.setColor(Color.WHITE); g2d.fill(loginRect); g2d.setColor(new Color(0xA8A8A8)); g2d.draw(loginRect);
g2.setColor(java.awt.Color.black); g2.fillRect(0, 0, getWidth(), getHeight()); g2.setPaint(new java.awt.GradientPaint(0, getHeight()/2.0f, java.awt.Color.red.darker().darker().darker(), getWidth(), getHeight()/2.0f, java.awt.Color.orange.darker().darker().darker())); g2.setRenderingHint(java.awt.RenderingHints.KEY_ANTIALIASING, java.awt.RenderingHints.VALUE_ANTIALIAS_ON); while (x + barSize < getWidth()) g2.fill(new java.awt.geom.RoundRectangle2D.Float(x, spacing, barSize, getHeight()-2*spacing, spacing, spacing)); x += barSize + spacing; while (x + barSize < getWidth() && x < xlimit) g2.fill(new java.awt.geom.RoundRectangle2D.Float(x, spacing, Math.min(barSize, xlimit - x), getHeight()-2*spacing, spacing, spacing)); x += barSize + spacing; g2.dispose(); g.drawImage(doubleBuff, 0, 0, null);
@Override public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { Graphics2D g2 = (Graphics2D)g.create(); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); int r = 5; RoundRectangle2D round = new RoundRectangle2D.Float(x, y, width-1, height-1, r, r); Container parent = c.getParent(); if (parent!=null) { g2.setColor(parent.getBackground()); Area corner = new Area(new Rectangle2D.Float(x, y, width, height)); corner.subtract(new Area(round)); g2.fill(corner); } catch (NoClassDefFoundError | UnsatisfiedLinkError e) { LOGGER.error(e, e);
super.paintComponent(g2); playGame = new RoundRectangle2D.Float((getWidth() / 2) - 200, (getHeight() / 2) - 100, 400, 100, 10, 10); quitGame = new RoundRectangle2D.Float((getWidth() / 2) - 200, (getHeight() / 2) + 20, 400, 100, 10, 10); Graphics2D g = (Graphics2D) g2.create(); g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.clearRect(0, 0, getWidth(), getHeight()); g.drawString("FPS: " + FPS, 10, 10); g.setColor(new Color(255, 152, 56)); } else { g.setColor(new Color(4, 47, 61)); g.draw(playGame); g.setColor(new Color(255, 152, 56)); } else { g.setColor(new Color(4, 47, 61));
@Override protected void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2 = (Graphics2D) g.create(); g2.setPaint(TEXTURE); g2.fillRect(0, 0, getWidth(), getHeight()); g2.dispose(); BufferedImage img = new BufferedImage(sz, sz, BufferedImage.TYPE_INT_ARGB); Graphics2D g2 = img.createGraphics(); g2.setPaint(new Color(120, 120, 220)); g2.fillRect(0, 0, sz, sz); g2.setPaint(new Color(200, 200, 200, 20)); for (int i = 0; i * cs < sz; i++) { for (int j = 0; j * cs < sz; j++) { g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); Shape area = new RoundRectangle2D.Float(x - i.left, y - i.top, w - 1, h - 1, R, R); Color color = new Color(0f, 0f, 0f, .3f); ButtonModel m = b.getModel(); if (m.isPressed()) {