Java 8 TexturePaint - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 TexturePaint class.

This code example shows how to use the following methods:
        txG2d.setColor(new Color(this.getHeaderBackgroundColor()));
        txG2d.fillRect(0, 0, 2, 2);
        txG2d.setColor(new Color(255, 255, 255, 150));
        txG2d.fillRect(0, 0, 1, 1);
        txG2d.dispose();
        g2d.setPaint(new TexturePaint(texture, new Rectangle(1, 1, 3, 3)));
        g2d.fillRect(0, 0, dimensions.width, dimensions.height);
    } 
 
    private Dimension calculateDimension() {
        int h = (int) (this.getSeparatorHeight() * 0.8);
        h = h - h % 3;
        int w = 9;
        return new Dimension(w, h);
    } 
} 
5
CodeRank
This code example shows how to use the following methods:
     * equality.  Since this class is not serializable, we expect null as the 
     * result. 
     */ 
    public void testTexturePaintSerialization() { 
 
        final Paint p1 = new TexturePaint(
                new BufferedImage(5, 5, BufferedImage.TYPE_INT_RGB),
                new Rectangle2D.Double(0, 0, 5, 5));
        Paint p2 = null;
 
        try { 
            final ByteArrayOutputStream buffer = new ByteArrayOutputStream();
            final ObjectOutputStream out = new ObjectOutputStream(buffer);
            SerialUtilities.writePaint(p1, out);
            out.close();
 
            final ByteArrayInputStream bias = new ByteArrayInputStream(
                    buffer.toByteArray());
            final ObjectInputStream in = new ObjectInputStream(bias);
            p2 = SerialUtilities.readPaint(in);
5
CodeRank
This code example shows how to use the following methods:
    							int w, int h) 
    { 
        BufferedImage buff = Factory.createImage(img);
        Rectangle anchor = new Rectangle(x, y, img.getWidth(null),
        					img.getHeight(null));
        TexturePaint paint = new TexturePaint(buff,anchor);
        g2.setPaint(paint);
        g2.fillRect(x,y,w,h);
    } 
} 
 
 
5
CodeRank
This code example shows how to use the following methods:
This code example shows how to use the following methods:
        bg.setPaint(Color.red);
        bg.fillRect(0, 0, 10, 10);
        bg.setPaint(Color.yellow);
        bg.fillRect(10, 10, 10, 10);
        bg.dispose();
        TexturePaint fillTexture = new TexturePaint(buf, new Rectangle(10, 20, 20, 20));
        g.setPaint(defaultPaint);
        g.drawString("Texture Paint", 10, 10);
        g.setPaint(fillTexture);
        g.fill(rect);
    } 
} 
5
CodeRank
This code example shows how to use the following methods:
            g.fillRect( 0, 0, this.size, source.getHeight() );
            g.fillRect( source.getWidth() - this.size, 0, this.size, source.getHeight() );
            g.fillRect( 0, source.getHeight() - this.size, source.getWidth(), this.size );
        } 
 
        g.setPaint( new TexturePaint( source, new Rectangle2D.Float( 0, 0, source.getWidth(), source.getHeight() ) ) );
        g.fillRect( this.size, this.size, source.getWidth() - ( this.size * 2 ), source.getHeight() - ( this.size * 2 ) );
        g.dispose();
 
        return dest;
    } 
} 
5
CodeRank
This code example shows how to use the following methods:
     */ 
    public void testTexturePaintEquals() { 
        final Paint p1 = new TexturePaint(
            new BufferedImage(100, 200, BufferedImage.TYPE_INT_RGB), new Rectangle2D.Double()
        ); 
        final Paint p2 = new TexturePaint(
            new BufferedImage(100, 200, BufferedImage.TYPE_INT_RGB), new Rectangle2D.Double()
        ); 
        assertEquals(p1, p2);
    } 
 
} 
5
CodeRank
This code example shows how to use the following methods:
		Graphics2D gg = (Graphics2D)g;
		gg.setColor(Color.LIGHT_GRAY);
		gg.fillRect(0, 0, getWidth(), getHeight());
 
		if (background != null) {
			TexturePaint paint = new TexturePaint(background, new Rectangle(0, 0, background.getWidth(), background.getHeight()));
			gg.setPaint(paint);
			gg.fillRect(0, 0, getWidth(), getHeight());
			gg.setPaint(null);
		} 
 
		if (image != null && !useRegion) {
			float panelRatio = (float)getWidth() / (float)getHeight();
			float imgRatio = (float)image.getWidth() / (float)image.getHeight();
 
			if (imgRatio > panelRatio) {
				float tw = (float)getWidth();
				float th = (float)getWidth() / imgRatio;
				gg.drawImage(image, 0, (int)(getHeight()/2 - th/2), (int) tw, (int) th, null);
			} else { 
4
CodeRank
This code example shows how to use the following methods:
This code example shows how to use the following methods:
            g.fillRect( 0, 0, this.size, source.getHeight() );
            g.fillRect( source.getWidth() - this.size, 0, this.size, source.getHeight() );
            g.fillRect( 0, source.getHeight() - this.size, source.getWidth(), this.size );
        } 
 
        g.setPaint( new TexturePaint( source, new Rectangle2D.Float( 0, 0, source.getWidth(), source.getHeight() ) ) );
        g.fillRect( this.size, this.size, source.getWidth() - ( this.size * 2 ), source.getHeight() - ( this.size * 2 ) );
        g.dispose();
 
        return dest;
    } 
} 
4
CodeRank
See Code Examples for Java 8 TexturePaint Methods: