protected void paintComponent (Graphics graphics) { Graphics2D g = (Graphics2D)graphics; int width = getWidth() - 1; int height = getHeight() - 1; for (int i = 0, n = paletteColors.length - 1; i < n; i++) { Color color1 = paletteColors[i]; Color color2 = paletteColors[i + 1]; float point1 = i / (float)n * width; float point2 = (i + 1) / (float)n * width; g.setPaint(new GradientPaint(point1, 0, color1, point2, 0, color2, false)); g.fillRect((int)point1, 0, (int)Math.ceil(point2 - point1), height); } g.setPaint(null); g.setColor(Color.black); g.drawRect(0, 0, width, height); } }
private void redrawGradient() { Color primaryRight = Color.getHSBColor(1f - this.selectedY / (float) (size - 1), 1, 1); Graphics2D g = image.createGraphics(); GradientPaint primary = new GradientPaint( 0f, 0f, Color.WHITE, size - 1, 0f, primaryRight); GradientPaint shade = new GradientPaint( 0f, 0f, new Color(0, 0, 0, 0), 0f, size - 1, Color.BLACK); g.setPaint(primary); g.fillRect(0, 0, size, size); g.setPaint(shade); g.fillRect(0, 0, size, size); g.dispose(); forceRedraw = true; }
int point1 = (int)(percent1 * gradientWidth); int point2 = (int)Math.ceil(percent2 * gradientWidth); g.setPaint(new GradientPaint(point1, 0, color1, point2, 0, color2, false)); g.fillRect(point1, 0, point2 - point1, gradientHeight); g.setPaint(null); g.setColor(Color.black); g.drawRect(0, 0, gradientWidth, gradientHeight);
graphics.setPaint(fillPaint); Rectangle2D cellAnc = tc.getAnchor(); graphics.fill(cellAnc); continue; graphics.setStroke(getStroke(stroke)); Paint linePaint = drawPaint.getPaint(graphics, stroke.getPaint()); graphics.setPaint(linePaint); default: case bottom: line = new Line2D.Double(x-borderSize, y+h, x+w+borderSize, y+h); break; case left: line = new Line2D.Double(x, y, x, y+h+borderSize); break; case right: line = new Line2D.Double(x+w, y, x+w, y+h+borderSize); break; case top: graphics.draw(line);
public static void drawRoundedBox(Graphics2D g, int x, int y, int w, int h, int bevel, Paint border, Paint fill) { g.setColor(new Color(0, 0, 0, 150)); g.drawOval(x - 1, y - 1, bevel * 2, h); g.setPaint(border); g.drawOval(x, y, bevel * 2 - 1, h - 1); g.drawOval(x + w - bevel * 2, y, bevel * 2 - 1, h - 1); g.drawOval(x + 1, y + 1, bevel * 2 - 3, h - 3); g.drawOval(x + 1 + w - bevel * 2, y + 1, bevel * 2 - 3, h - 3); g.drawRect(x + bevel, y, w - 2 * bevel, h - 1); g.drawRect(x + 1 + bevel, y + 1, w - 2 * bevel - 2, h - 3); g.setPaint(fill); g.fillOval(x + 2, y + 2, bevel * 2 - 4, h - 4); g.fillOval(x + 2 + w - bevel * 2, y + 2, bevel * 2 - 4, h - 4); g.fillRect(x + bevel, y + 2, w - 2 * bevel, h - 4); g.setPaint(fill); g.setColor(abitbrighter(g.getColor())); g.drawLine(x + 1 + bevel, y + 1, x + 1 + bevel + w - 2 * bevel - 2, y + 1); g.setPaint(fill); g.setColor(abitdarker(g.getColor())); g.drawLine(x + 1 + bevel, y + h - 2, x + 1 + bevel + w - 2 * bevel - 2, y + h - 2); }
private void paintShapeNode_0_0_0_3(Graphics2D g) { Rectangle2D.Double shape3 = new Rectangle2D.Double(6.419553279876709, 2.905667304992676, 6.532177448272705, 4.279702663421631); g.setPaint(new Color(183, 206, 243, 255)); g.fill(shape3); }
BufferedImage.TYPE_INT_RGB); Graphics2D imageGraphics = image.createGraphics(); GradientPaint gp = new GradientPaint( 20f, 20f, 280f, Color.orange); imageGraphics.setPaint(gp); imageGraphics.fillRect(0, 0, 400, 300); BufferedImage.TYPE_INT_ARGB); Graphics g = bi.createGraphics(); g.setColor(new Color(255, 255, 255, 128)); g.fillRoundRect( 0,
private Color colorBright = new Color(220,220,220); private Color colorDark = new Color(150,150,150); private Color black = new Color(0,0,0,100); private Color white = new Color(255,255,255,100); private Color light = new Color(220,220,220,100); int h = thumbBounds.height; g2.setPaint( new GradientPaint(x, (int)(y-0.1*h), colorDark , x, (int)(y+1.2*h), light) ); g2.fillRect( x, y, w, h ); g2.setPaint( new GradientPaint(x, (int)(y+.65*h), light , x, (int)(y+1.3*h), colorDark) ); g2.fillRect( x, (int)(y+.65*h), w, (int)(h-.65*h) );
final Color color1 = new Color(230, 255, 255, 0); final Color color2 = new Color(255, 230, 255, 64); final Color alphaColor = new Color(200, 200, 230, 64); final Color color3 = new Color( alphaColor.getRed(), alphaColor.getGreen(), alphaColor.getBlue(), 0); super.paint(g, c); Graphics2D g2D = (Graphics2D) g; GradientPaint gradient1 = new GradientPaint( 0.0F, (float) c.getHeight() / (float) 2, color1, 0.0F, 0.0F, color2); Rectangle rec1 = new Rectangle(0, 0, c.getWidth(), c.getHeight() / 2); g2D.setPaint(gradient1); g2D.fill(rec1); GradientPaint gradient2 = new GradientPaint( 0.0F, (float) c.getHeight() / (float) 2, color3, 0.0F, c.getHeight(), color4); Rectangle rec2 = new Rectangle(0, c.getHeight() / 2, c.getWidth(), c.getHeight()); g2D.setPaint(gradient2); g2D.fill(rec2);
public Image(Vertx vertx, String name) { try { final BufferedImage raster = ImageIO.read(((VertxInternal) vertx).resolveFile(name)); width = raster.getWidth(); height = raster.getHeight(); data = raster.getRGB(0, 0, width, height, null, 0, width); for (int pixel : data) if (!colorMap.containsKey(pixel)) { BufferedImage offlineImage = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB); Graphics2D g2 = offlineImage.createGraphics(); g2.setPaint(new Color(pixel, true)); g2.fillRect(0, 0, 1, 1); ByteArrayOutputStream out = new ByteArrayOutputStream(); ImageIO.write(offlineImage, "PNG", out); colorMap.put(pixel, Buffer.buffer().appendBytes(out.toByteArray())); out.close(); g2.dispose(); } } catch (IOException e) { throw new RuntimeException(e); } }
BasicStroke basicStroke = new BasicStroke(2.0f); public CButton(String txt) { super(txt); protected void paintComponent(Graphics g) { Graphics2D g2d = (Graphics2D) g.create(); g2d.setColor(new Color(0xFFAA00)); g2d.setStroke(basicStroke); Rectangle2D txRect = new Rectangle2D.Double(0, 0, textureImg.getWidth(), textureImg.getHeight()); TexturePaint txPaint = new TexturePaint(textureImg, txRect); g2d.setPaint(txPaint); new Color[] { new Color(0x002AFF), new Color(0x0CAAF9), new Color(0x0CAAF9), new Color(0x002AFF) }); g2d.setPaint(lgrPaint);
screenSize.height - taskBarSize - dialog.getHeight()); lpg = new LinearGradientPaint(0, 0, 0, dialog.getHeight() / 2, new float[]{0f, 0.3f, 1f}, new Color[]{new Color(0.8f, 0.8f, 1f), new Color(0.7f, 0.7f, 1f), new Color(0.6f, 0.6f, 1f)}); dialog.setContentPane(panel); dialog.setVisible(true); protected void paintComponent(final Graphics g) { final Graphics2D g2d = (Graphics2D) g; g2d.setPaint(lpg); g2d.fillRect(1, 1, getWidth() - 2, getHeight() - 2); g2d.setColor(Color.BLACK);
final HtmlColor extended = fontConfiguration.getExtendedColor(); if (fontConfiguration.containsStyle(FontStyle.BACKCOLOR)) { final Rectangle2D.Double area = new Rectangle2D.Double(x, y - dimBack.getHeight() + 1.5, dimBack.getWidth(), dimBack.getHeight()); if (extended instanceof HtmlColorGradient) { final GradientPaint paint = DriverRectangleG2d.getPaintGradient(x, y, mapper, dimBack.getWidth(), dimBack.getHeight(), extended); g2d.setPaint(paint); g2d.fill(area); } else { final Color backColor = mapper.getMappedColor(extended); g2d.setColor(backColor); g2d.setBackground(backColor); g2d.fill(area); g2d.setStroke(new BasicStroke((float) 1)); g2d.drawLine((int) x, ypos, (int) (x + dim.getWidth()), ypos); g2d.setStroke(new BasicStroke()); g2d.setColor(mapper.getMappedColor(extended)); g2d.setStroke(new BasicStroke((float) 1.5)); g2d.drawLine((int) x, ypos, (int) (x + dim.getWidth()), ypos); g2d.setStroke(new BasicStroke());
protected static BufferedImage drawSomething(final BufferedImage image) { Graphics2D g = image.createGraphics(); try { int width = image.getWidth(); int height = image.getHeight(); g.clearRect(0, 0, width, height); g.setPaint(new LinearGradientPaint(0, 0, width, 0, new float[] {0.2f, 1}, new Color[] {new Color(0x0, true), Color.BLUE})); g.fillRect(0, 0, width, height); g.setPaint(new LinearGradientPaint(0, 0, 0, height, new float[] {0.2f, 1}, new Color[] {new Color(0x0, true), Color.RED})); g.fillRect(0, 0, width, height); g.setPaint(new LinearGradientPaint(0, 0, 0, height, new float[] {0, 1}, new Color[] {new Color(0x00ffffff, true), Color.WHITE})); g.fill(new Polygon(new int[] {0, width, width}, new int[] {0, height, 0}, 3)); } finally { g.dispose(); } return image; }
rangeAxis); } else if (g instanceof LineString) { g2.draw(new TranslatedLiteShape(g, dataArea, plot, domainAxis, rangeAxis)); } else { Color c = (Color) p; p = new Color( c.getRed() / 255f, c.getGreen() / 255f, polygonFillOpacity); g2.setPaint(p); g2.fill(new TranslatedLiteShape(g, dataArea, plot, domainAxis, rangeAxis)); g2.setPaint(getSeriesPaint(series)); g2.draw(new TranslatedLiteShape(g, dataArea, plot, domainAxis, rangeAxis));
GradientPaint gp = new GradientPaint(0f, 0f, new Color(127 + random.nextInt(128), 127 + random.nextInt(128), 127 + random.nextInt(128)), (float) halfScreenSize.width, (float) halfScreenSize.width, new Color(random.nextInt(128), random.nextInt(128), random.nextInt(128))); BufferedImage bi = new BufferedImage(halfScreenSize.width, halfScreenSize.height, BufferedImage.TYPE_INT_RGB); Graphics2D g2d = bi.createGraphics(); g2d.setPaint(gp); g2d.fillRect(0, 0, halfScreenSize.width, halfScreenSize.height); g2d.setFont(bigFont);
imageTransform.translate(0, -1); Paint awtPaint = new TexturePaint(image, new Rectangle2D.Double(imageTransform.getTranslateX(), imageTransform.getTranslateY(), imageTransform.getScaleX(), imageTransform.getScaleY())); awtPaint = applySoftMaskToPaint(awtPaint, softMask); graphics.setPaint(awtPaint); Rectangle2D unitRect = new Rectangle2D.Float(0, 0, 1, 1); if (isContentRendered()) graphics.fill(at.createTransformedShape(unitRect));
g2d.fillRect(0, 0, w, h); g2d.setComposite(AlphaComposite.Src); g2d.setPaint(g2d.getBackground()); g2d.fillRect(0, 0, w, h); renderTime(g2d); timeG.fillRect(0, 0, w, h); timeG.setComposite(AlphaComposite.Src); timeG.setPaint(Color.green); timeG.drawString(s, 0, fm.getAscent()); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setBackground(new Color(0f, 0f, 0f, 0.3f)); f.setUndecorated(true); f.add(new Translucent());
lastY = y + coord[1]; } else if (type == USegmentType.SEG_LINETO) { final Shape line = new Line2D.Double(lastX, lastY, x + coord[0], y + coord[1]); drawShadow(g2d, line, shape.getDeltaShadow(), dpiFactor); lastX = x + coord[0]; (float) minMax.getMaxX(), (float) minMax.getMaxY(), mapper.getMappedColor(gr.getColor2())); g2d.setPaint(paint); g2d.fill(p); } else if (back != null) { g2d.setColor(mapper.getMappedColor(back)); g2d.fill(p); g2d.draw(p);
@SuppressWarnings("rawtypes") public void draw(Graphics2D graphics) { Dimension pg = shape.getSheet().getSlideShow().getPageSize(); final Rectangle2D anchor = new Rectangle2D.Double(0, 0, pg.getWidth(), pg.getHeight()); PlaceableShape<?,?> ps = new PlaceableShape(){ public ShapeContainer<?,?> getParent() { return null; } public Rectangle2D getAnchor() { return anchor; } public void setAnchor(Rectangle2D newAnchor) {} public double getRotation() { return 0; } public void setRotation(double theta) {} public void setFlipHorizontal(boolean flip) {} public void setFlipVertical(boolean flip) {} public boolean getFlipHorizontal() { return false; } public boolean getFlipVertical() { return false; } public Sheet<?,?> getSheet() { return shape.getSheet(); } }; DrawFactory drawFact = DrawFactory.getInstance(graphics); DrawPaint dp = drawFact.getPaint(ps); Paint fill = dp.getPaint(graphics, getShape().getFillStyle().getPaint()); Rectangle2D anchor2 = getAnchor(graphics, anchor); if(fill != null) { graphics.setRenderingHint(Drawable.GRADIENT_SHAPE, anchor); graphics.setPaint(fill); graphics.fill(anchor2); } }