List of usage examples for java.awt Graphics2D setPaint
public abstract void setPaint(Paint paint);
From source file:com.anrisoftware.prefdialog.miscswing.validatingfields.ValidatingComponent.java
private void paintInvalidOverlay(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.setComposite(ALPHA);/*from ww w .j av a 2 s .c o m*/ g2.setPaint(invalidBackground); Rectangle bounds = g.getClipBounds(); g2.fillRect(bounds.x, bounds.y, bounds.width, bounds.height); }
From source file:com.rapidminer.gui.new_plotter.engine.jfreechart.PlotInstanceLegendCreator.java
private static Paint createTransparentCheckeredPaint(Color color, int checkerSize) { int s = checkerSize; BufferedImage bufferedImage = new BufferedImage(2 * s, 2 * s, BufferedImage.TYPE_INT_ARGB); Graphics2D g2 = bufferedImage.createGraphics(); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, // Anti-alias! RenderingHints.VALUE_ANTIALIAS_ON); Color c1 = DataStructureUtils.setColorAlpha(color, (int) (color.getAlpha() * .8)); Color c2 = DataStructureUtils.setColorAlpha(color, (int) (color.getAlpha() * .2)); g2.setStroke(new BasicStroke(0)); g2.setPaint(c2); g2.setColor(c2);//from w ww.j a v a 2 s .c o m g2.fillRect(0, 0, s, s); g2.fillRect(s, s, s, s); g2.setPaint(c1); g2.setColor(c1); g2.fillRect(0, s, s, s); g2.fillRect(s, 0, s, s); // paint with the texturing brush Rectangle2D rect = new Rectangle2D.Double(0, 0, 2 * s, 2 * s); return new TexturePaint(bufferedImage, rect); }
From source file:Wallpaper.java
@Override public void paint(Graphics g, JComponent c) { super.paint(g, c); Graphics2D g2 = (Graphics2D) g.create(); int w = c.getWidth(); int h = c.getHeight(); g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, .5f)); g2.setPaint(new GradientPaint(0, 0, Color.yellow, 0, h, Color.red)); g2.fillRect(0, 0, w, h);//from w w w. j a v a 2 s .c o m g2.dispose(); }
From source file:Overlap.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; double x = 15, y = 50, w = 70, h = 70; Ellipse2D e = new Ellipse2D.Double(x, y, w, h); g2.setStroke(new BasicStroke(8)); Color smokeyColor = new Color(128, 128, 128, 128); g2.setPaint(smokeyColor); g2.fill(e);//from w ww .jav a2 s.co m g2.draw(e); e.setFrame(x + 100, y, w, h); g2.setPaint(Color.black); g2.draw(e); g2.setPaint(Color.gray); g2.fill(e); e.setFrame(x + 200, y, w, h); g2.setPaint(Color.gray); g2.fill(e); g2.setPaint(Color.black); g2.draw(e); }
From source file:TransparentText.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; // the rendering quality. g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); // a red rectangle. Rectangle2D r = new Rectangle2D.Double(50, 50, 550, 100); g2.setPaint(Color.red); g2.fill(r);/* w w w . jav a 2 s. c om*/ // a composite with transparency. Composite c = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, .4f); g2.setComposite(c); // Draw some blue text. g2.setPaint(Color.blue); g2.setFont(new Font("Times New Roman", Font.PLAIN, 72)); g2.drawString("Java Source and Support", 25, 130); }
From source file:PaintingAndStroking.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; double x = 15, y = 50, w = 70, h = 70; Ellipse2D e = new Ellipse2D.Double(x, y, w, h); GradientPaint gp = new GradientPaint(75, 75, Color.white, 95, 95, Color.gray, true); // Fill with a gradient. g2.setPaint(gp); g2.fill(e);/*from w w w. jav a2s . c o m*/ // Stroke with a solid color. e.setFrame(x + 100, y, w, h); g2.setPaint(Color.black); g2.setStroke(new BasicStroke(8)); g2.draw(e); // Stroke with a gradient. e.setFrame(x + 200, y, w, h); g2.setPaint(gp); g2.draw(e); }
From source file:net.sf.mzmine.modules.visualization.tic.TICPlotRenderer.java
protected void drawFirstPassShape(Graphics2D g2, int pass, int series, int item, Shape shape) { g2.setComposite(makeComposite(transparency)); g2.setStroke(getItemStroke(series, item)); g2.setPaint(getItemPaint(series, item)); g2.draw(shape);//from w ww . j a v a 2 s . c o m }
From source file:web.diva.server.model.profileplot.ProfilePlotImgeGenerator.java
public String toImage() { image = new BufferedImage(900, height, BufferedImage.TYPE_INT_ARGB); Graphics2D graphics = image.createGraphics(); graphics.setPaint(Color.WHITE); super.forceFullRepaint(graphics); // super.paint(graphics); byte[] imageData = null; try {//from w w w. java 2 s. c o m imageData = in.encode(image); } catch (Exception e) { System.out.println(e.getLocalizedMessage()); } String base64 = Base64.encodeBytes(imageData); base64 = "data:image/png;base64," + base64; return base64; }
From source file:org.jcurl.core.swing.SumDisplayBase.java
@Override protected void paintComponent(final Graphics g) { super.paintComponent(g); final Graphics2D g2 = (Graphics2D) g; g2.setRenderingHints(hints);//w w w . j a va 2s . c o m // background g2.setPaint(backGround); g2.fillRect(0, 0, getWidth(), getHeight()); for (int i = RockSet.ROCKS_PER_COLOR - 1; i >= 0; i--) { if (RockSet.isSet(recentMask, i, true)) paintRock(g2, i, true); if (RockSet.isSet(recentMask, i, false)) paintRock(g2, i, false); } }
From source file:BasicDraw.java
public void paint(Graphics g) { Graphics2D g2d = (Graphics2D) g; Color startColor = Color.red; Color endColor = Color.blue; int startX = 10, startY = 20, endX = 30, endY = 40; GradientPaint gradient = new GradientPaint(startX, startY, startColor, endX, endY, endColor); g2d.setPaint(gradient); g2d.draw(new Rectangle(20, 20, 200, 200)); }