List of usage examples for java.awt TexturePaint TexturePaint
public TexturePaint(BufferedImage txtr, Rectangle2D anchor)
From source file:Main.java
public static BufferedImage getStrokedImage(BufferedImage bi, Shape shape, int strokeWidth) { int w = bi.getWidth(); int h = bi.getHeight(); BufferedImage bib = new BufferedImage(w, h, bi.getType()); Graphics2D g = bib.createGraphics(); BasicStroke bs = new BasicStroke(strokeWidth); g.setStroke(bs);/*from ww w .jav a 2 s. c om*/ Rectangle rect = new Rectangle(0, 0, w, h); TexturePaint tp = new TexturePaint(bi, rect); g.setPaint(tp); g.draw(shape); g.dispose(); return bib; }
From source file:Main.java
public static TexturePaint createCheckerTexture(int cs, Color color) { int size = cs * cs; BufferedImage img = new BufferedImage(size, size, BufferedImage.TYPE_INT_ARGB); Graphics2D g2 = img.createGraphics(); g2.setPaint(color);//from w ww . ja v a 2 s . com g2.fillRect(0, 0, size, size); for (int i = 0; i * cs < size; i++) { for (int j = 0; j * cs < size; j++) { if ((i + j) % 2 == 0) { g2.fillRect(i * cs, j * cs, cs, cs); } } } g2.dispose(); return new TexturePaint(img, new Rectangle(0, 0, size, size)); }
From source file:Textures.java
public void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2d = (Graphics2D) g; TexturePaint slatetp = new TexturePaint(s, new Rectangle(0, 0, 90, 60)); g2d.setPaint(slatetp);/*from w ww.j av a 2s . co m*/ g2d.fillRect(10, 15, 90, 60); }
From source file:WatermarkTextField.java
public WatermarkTextField(File file) { super();//from w w w . ja v a 2 s .c om try { img = ImageIO.read(file); } catch (IOException e) { e.printStackTrace(); } Rectangle rect = new Rectangle(0, 0, img.getWidth(null), img.getHeight(null)); texture = new TexturePaint(img, rect); setOpaque(false); }
From source file:BasicDraw.java
public void paint(Graphics g) { Graphics2D g2d = (Graphics2D) g; int x = 10;/*from w ww . j a v a 2 s . co m*/ int y = 10; int width = 50; int height = 25; BufferedImage bi = new BufferedImage(20, 20, BufferedImage.TYPE_INT_RGB); TexturePaint texture = new TexturePaint(bi, new Rectangle(x, y, width, height)); g2d.setPaint(texture); }
From source file:TexturePaintDemo.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; BufferedImage bi = new BufferedImage(5, 5, BufferedImage.TYPE_INT_RGB); Graphics2D big = bi.createGraphics(); big.setColor(Color.blue);//from w ww .jav a 2s . c o m big.fillRect(0, 0, 5, 5); big.setColor(Color.lightGray); big.fillOval(0, 0, 5, 5); Rectangle r = new Rectangle(0, 0, 5, 5); g2.setPaint(new TexturePaint(bi, r)); Rectangle rect = new Rectangle(5, 5, 200, 200); g2.fill(rect); }
From source file:TexturedText.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); Font font = new Font("Times New Roman", Font.PLAIN, 72); g2.setFont(font);//from w w w .j av a 2s .co m String s = "Java Source and Support"; Dimension d = getSize(); float x = 20, y = 100; BufferedImage bi = getTextureImage(); Rectangle r = new Rectangle(0, 0, bi.getWidth(), bi.getHeight()); TexturePaint tp = new TexturePaint(bi, r); g2.setPaint(tp); g2.drawString(s, x, y); }
From source file:Textures.java
public void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2d = (Graphics2D) g; g2d.setColor(new Color(212, 212, 212)); g2d.drawRect(10, 15, 90, 60);/*from www . j av a 2 s. c o m*/ BufferedImage bimage1 = null; URL url1 = ClassLoader.getSystemResource("a.png"); try { bimage1 = ImageIO.read(url1); } catch (IOException ioe) { ioe.printStackTrace(); } Rectangle rect1 = new Rectangle(0, 0, bimage1.getWidth(), bimage1.getHeight()); TexturePaint texture1 = new TexturePaint(bimage1, rect1); g2d.setPaint(texture1); g2d.fillRect(10, 15, 90, 60); }
From source file:ScrollPaneWatermark.java
public void setBackgroundTexture(URL url) throws IOException { bgimage = ImageIO.read(url);//from ww w .j a v a 2 s . co m Rectangle rect = new Rectangle(0, 0, bgimage.getWidth(null), bgimage.getHeight(null)); texture = new TexturePaint(bgimage, rect); }
From source file:Main.java
public WatermarkTextField(URL file) { super();/*from w w w . j a v a 2 s .c o m*/ try { img = ImageIO.read(file); } catch (IOException e) { e.printStackTrace(); } Rectangle rect = new Rectangle(0, 0, img.getWidth(null), img.getHeight(null)); texture = new TexturePaint(img, rect); setOpaque(false); }