List of usage examples for java.awt Graphics2D setPaint
public abstract void setPaint(Paint paint);
From source file:CompositingDST_ATOP.java
public void paint(Graphics g) { Graphics2D g2d = (Graphics2D) g; AlphaComposite ac = AlphaComposite.getInstance(AlphaComposite.SRC, 0.5f); BufferedImage buffImg = new BufferedImage(60, 60, BufferedImage.TYPE_INT_ARGB); Graphics2D gbi = buffImg.createGraphics(); gbi.setPaint(Color.red); gbi.fillRect(0, 0, 40, 40);//from w ww .j a va2 s . c o m gbi.setComposite(ac); gbi.setPaint(Color.green); gbi.fillRect(5, 5, 40, 40); g2d.drawImage(buffImg, 20, 20, null); }
From source file:CompositingDST.java
public void paint(Graphics g) { Graphics2D g2d = (Graphics2D) g; AlphaComposite ac = AlphaComposite.getInstance(AlphaComposite.DST, 0.5f); BufferedImage buffImg = new BufferedImage(60, 60, BufferedImage.TYPE_INT_ARGB); Graphics2D gbi = buffImg.createGraphics(); gbi.setPaint(Color.red); gbi.fillRect(0, 0, 40, 40);/* w ww . j a v a 2 s. c om*/ gbi.setComposite(ac); gbi.setPaint(Color.green); gbi.fillRect(5, 5, 40, 40); g2d.drawImage(buffImg, 20, 20, null); }
From source file:CompositingDST_ATOP.java
public void paint(Graphics g) { Graphics2D g2d = (Graphics2D) g; AlphaComposite ac = AlphaComposite.getInstance(AlphaComposite.DST_OUT, 0.5f); BufferedImage buffImg = new BufferedImage(60, 60, BufferedImage.TYPE_INT_ARGB); Graphics2D gbi = buffImg.createGraphics(); gbi.setPaint(Color.red); gbi.fillRect(0, 0, 40, 40);/*from w w w .ja va 2 s. c o m*/ gbi.setComposite(ac); gbi.setPaint(Color.green); gbi.fillRect(5, 5, 40, 40); g2d.drawImage(buffImg, 20, 20, null); }
From source file:Main.java
public int print(Graphics g, PageFormat Pf, int pageIndex) throws PrinterException { if (pageIndex > 0) return NO_SUCH_PAGE; Graphics2D g2 = (Graphics2D) g; g2.setFont(sFont);/*from w w w.j a v a 2 s . c o m*/ g2.setPaint(Color.black); g2.drawString("Save a tree!", 96, 144); return PAGE_EXISTS; }
From source file:TexturedText.java
private BufferedImage getTextureImage() { // Create the test image. int size = 8; BufferedImage bi = new BufferedImage(size, size, BufferedImage.TYPE_INT_ARGB); Graphics2D g2 = bi.createGraphics(); g2.setPaint(Color.red); g2.fillRect(0, 0, size / 2, size / 2); g2.setPaint(Color.yellow);/*from ww w.j a va 2 s .c om*/ g2.fillRect(size / 2, 0, size, size / 2); g2.setPaint(Color.green); g2.fillRect(0, size / 2, size / 2, size); g2.setPaint(Color.blue); g2.fillRect(size / 2, size / 2, size, size); return bi; }
From source file:Main.java
@Override protected void paintComponent(Graphics g) { int width = this.getWidth(); int height = this.getHeight(); float startPointX = 0.0f; float startPointY = 0.0f; float endPointX = width; float endPointY = 0.0f; Color startColor = new Color(red, green, blue, 255); Color endColor = new Color(red, green, blue, 0); Paint paint = new GradientPaint(startPointX, startPointY, startColor, endPointX, endPointY, endColor); Graphics2D g2D = (Graphics2D) g; g2D.setPaint(paint); g2D.fillRect(0, 0, width, height);//w ww .ja v a 2 s .c o m }
From source file:BasicStrokeDemo.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.setStroke(new BasicStroke(3.0f)); g2.setPaint(Color.blue); Rectangle r = new Rectangle(5, 5, 200, 200); g2.draw(r);//from w w w .j a v a 2 s .c o m }
From source file:ThickStrokeDemo.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.setStroke(new BasicStroke(8.0f)); g2.setPaint(Color.blue); Rectangle r = new Rectangle(5, 5, 200, 200); g2.draw(r);/*w w w . j a v a 2 s.c o m*/ }
From source file:Test.java
public ApplicationWindow() { setBackground(new Color(0, 0, 0, 0)); this.setSize(200, 200); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel panel = new JPanel() { @Override//from w ww .ja v a 2 s . c o m protected void paintComponent(Graphics gradient) { if (gradient instanceof Graphics2D) { final int Red = 150; final int Green = 150; final int Blue = 150; Paint paint = new GradientPaint(0.0f, 0.0f, new Color(Red, Green, Blue, 0), getWidth(), getHeight(), new Color(Red, Green, Blue, 255)); Graphics2D gradient2d = (Graphics2D) gradient; gradient2d.setPaint(paint); gradient2d.fillRect(0, 0, getWidth(), getHeight()); } } }; this.setContentPane(panel); }
From source file:ScrollPaneWatermark.java
public void paintComponent(Graphics g) { // do the superclass behavior first super.paintComponent(g); // paint the texture if (texture != null) { Graphics2D g2 = (Graphics2D) g; g2.setPaint(texture); g.fillRect(0, 0, getWidth(), getHeight()); }//w ww. ja v a 2 s. co m }