Refine search
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; }
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, JLabel imageLabel = new JLabel(ii); f.getContentPane().add(imageLabel); f.pack(); f.setLocationByPlatform(true);
/** * Constructs a new renderer with default values for the bar colors. */ public WaterfallBarRenderer() { this(new GradientPaint(0.0f, 0.0f, new Color(0x22, 0x22, 0xFF), 0.0f, 0.0f, new Color(0x66, 0x66, 0xFF)), new GradientPaint(0.0f, 0.0f, new Color(0x22, 0xFF, 0x22), 0.0f, 0.0f, new Color(0x66, 0xFF, 0x66)), new GradientPaint(0.0f, 0.0f, new Color(0xFF, 0x22, 0x22), 0.0f, 0.0f, new Color(0xFF, 0x66, 0x66)), new GradientPaint(0.0f, 0.0f, new Color(0xFF, 0xFF, 0x22), 0.0f, 0.0f, new Color(0xFF, 0xFF, 0x66))); }
plafComponents.add(plafChooser); plafComponents.add(pack); gui.add(plafComponents, BorderLayout.NORTH); 200,200,BufferedImage.TYPE_INT_ARGB); Graphics2D g = bi.createGraphics(); GradientPaint gp = new GradientPaint( 20f,20f,Color.red, 180f,180f,Color.yellow); g.setPaint(gp); g.fillRect(0,0,200,200); ImageIcon ii = new ImageIcon(bi);
xp = new int[]{x, x, x + w, x + w, x}; yp = new int[]{y, y + h - 3, y + h - 3, y, y}; gradientShadow = new GradientPaint(x, y, new Color(100, 100, 255), x, y + h, Color.ORANGE); break; case RIGHT: xp = new int[]{x, x, x + w - 2, x + w - 2, x}; yp = new int[]{y, y + h - 3, y + h - 3, y, y}; gradientShadow = new GradientPaint(x, y, new Color(100, 100, 255), x, y + h, new Color(153, 186, 243)); break; case BOTTOM: xp = new int[]{x, x, x + 3, x + w - inclTab - 6, x + w - inclTab - 2, x + w - inclTab, x + w - 3, x}; yp = new int[]{y, y + h - 3, y + h, y + h, y + h - 1, y + h - 3, y, y}; gradientShadow = new GradientPaint(x, y, new Color(100, 100, 255), x, y + h, Color.BLUE); break; case TOP: xp = new int[]{x, x, x + 3, x + w - inclTab - 6, x + w - inclTab - 2, x + w - inclTab, x + w - inclTab, x}; yp = new int[]{y + h, y + 3, y, y, y + 1, y + 3, y + h, y + h}; gradientShadow = new GradientPaint(0, 0, Color.ORANGE, 0, y + h / 2, new Color(240, 255, 210)); break; if (isSelected) { g2D.setColor(selectColor); g2D.setPaint(gradientShadow); } else { if (tabPane.isEnabled() && tabPane.isEnabledAt(tabIndex)) { g2D.setColor(deSelectColor); GradientPaint gradientShadowTmp = new GradientPaint(0, 0, new Color(255, 255, 200), 0, y + h / 2, new Color(240, 255, 210)); g2D.setPaint(gradientShadowTmp);
frame.add(tip1Null, BorderLayout.CENTER); frame.setLocation(150, 150); frame.setPreferredSize(new Dimension(310, 75)); 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);
/** * Constructs a new renderer with default values for the bar colors. */ public WaterfallBarRenderer() { this(new GradientPaint(0.0f, 0.0f, new Color(0x22, 0x22, 0xFF), 0.0f, 0.0f, new Color(0x66, 0x66, 0xFF)), new GradientPaint(0.0f, 0.0f, new Color(0x22, 0xFF, 0x22), 0.0f, 0.0f, new Color(0x66, 0xFF, 0x66)), new GradientPaint(0.0f, 0.0f, new Color(0xFF, 0x22, 0x22), 0.0f, 0.0f, new Color(0xFF, 0x66, 0x66)), new GradientPaint(0.0f, 0.0f, new Color(0xFF, 0xFF, 0x22), 0.0f, 0.0f, new Color(0xFF, 0xFF, 0x66))); }
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); } }
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().setLayout(new FlowLayout()); frame.add(JGradientButton.newInstance()); frame.setSize(new Dimension(300, 150)); // used for demonstration protected void paintComponent(Graphics g) { final Graphics2D g2 = (Graphics2D) g.create(); g2.setPaint(new GradientPaint( new Point(0, 0), Color.WHITE,
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); g2.setPaint(new GradientPaint(0, 0, new Color(0x818a9b), 0, height, new Color(0x3a4252))); g2.fill(casing); g2.setPaint(paint);
imageLabel = new JLabel(new ImageIcon(convertToFromBytes(getImage()))); memory = new JProgressBar(0, (int) Runtime.getRuntime().maxMemory()); p.add(imageLabel, BorderLayout.CENTER); p.add(memory, BorderLayout.SOUTH); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 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);
public Paint apply(N v) { float alpha = transparency.get(v).floatValue(); if (pi.isPicked(v)) { return new Color(1f, 1f, 0, alpha); } else { if (seed_coloring && seedNodes.contains(v)) { Color dark = new Color(0, 0, dark_value, alpha); Color light = new Color(0, 0, light_value, alpha); return new GradientPaint(0, 0, dark, 10, 0, light, true); } else { return new Color(1f, 0, 0, alpha); } } } }
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); } }
gui.add(quality, BorderLayout.WEST); dithering = new JCheckBox("Dithering", false); controls.add(antialiasing); controls.add(fractionalMetrics); GradientPaint gp = new GradientPaint( 0f, 0f, Color.red, (float)width, (float)height, Color.orange); g2d.setPaint(gp); g2d.fillRect(0,0, width, height);
protected BufferedImage createImage(final int pWidth, final int pHeigth, final int pType) { BufferedImage image = new BufferedImage(pWidth, pHeigth, pType); Graphics2D g = image.createGraphics(); try { g.setPaint(new GradientPaint(0, 0, Color.RED, pWidth, pHeigth, new Color(0x00000000, true))); g.fillRect(0, 0, pWidth, pHeigth); } finally { g.dispose(); } return image; }
private Color pInterfaceColour = new Color(255, 245, 62); protected int iDegreeWhite = 180; protected int iDegreeBlack = 0; RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); GradientPaint pGradient = new GradientPaint(0, 0, new Color(255, 255, 255, iDegreeWhite), 0, getHeight(), new Color(0, 0, 0, iDegreeBlack)); pGraphicsGradientRender.setPaint(pGradient); pGraphicsGradientRender.fillRect(0, 0, getWidth(), getHeight()); super.paintComponent(pGraphics); pGradientPane.setPreferredSize(new Dimension(iWidth - 16, iHeight - 62)); add(pGradientPane);
public static GradientPanel createGradientPanel() { final GradientPanel gp = new GradientPanel(); final LookAndFeel laf = UIManager.getLookAndFeel(); final boolean isAqua = laf == null ? false : laf.getID().equals( "Aqua" ); final GradientPaint grad = isAqua ? new GradientPaint( 0f, 0f, new Color( 0xF3, 0xF3, 0xF3 ), 0f, 69f, new Color( 0xC4, 0xC4, 0xC4 )) : null; gp.setLayout( new BoxLayout( gp, BoxLayout.X_AXIS )); gp.setGradient( grad ); gp.setBorder( BorderFactory.createEmptyBorder( 2, 2, 2, 2 )); return gp; }
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 static final Color gradientEndingColor = new Color(0xc0c0c0); private static final Color borderColor = new Color(0x736a60); private static final Color disabledBorderColor = new Color(0xbebebe); gradient = new GradientPaint(0.0f, 0.0f, Color.WHITE, 0.0f, h, gradientEndingColor); g2d.setPaint(gradient); g2d.setComposite(transparent); g2d.fillRect(1, 1, w - 1, (h >> 1));