Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Textures on shapes?

937161May 14 2012 — edited May 15 2012
Hello, i'm quiet new in javaFX, and would like to put a texture on a shape (Rectangle, Line, etc). I found somewhere that it's not implemented in the version 2.0.. is that true?

Because i found a sample of code in javafx (old version, maybe 1.3). It use a TexturePaint:
package org.jfxtras.cccp;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import javax.swing.ImageIcon;
import javafx.scene.paint.Paint;

/**
 * @author Jeff Friesen
 */
public class TexturePaint extends Paint
{
    public-init var url: String;
    public-init var x: Number;
    public-init var y: Number;
    public-init var width: Number;
    public-init var height: Number;

    public override function impl_getPlatformPaint ()
    {
        def image = new ImageIcon (new java.net.URL (url));
        def bi = new BufferedImage (image.getIconWidth (),
                                    image.getIconHeight (),
                                    BufferedImage.TYPE_INT_RGB);
        def g = bi.createGraphics ();
        g.drawImage (image.getImage (), 0, 0, null);
        g.dispose ();
        def _width = if (width == 0) then image.getIconWidth () else width;
        def _height = if (height == 0) then image.getIconHeight () else height;
        def anchor = new Rectangle2D.Double (x, y, _width, _height);
        new java.awt.TexturePaint (bi, anchor)
    }
}
I tried to adapt that code for the version 2.0 but it doesnt work..

Somebody knows how to do? Or is it just no possible at the moment?

Edited by: 934158 on 14 mai 2012 04:38
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 12 2012
Added on May 14 2012
4 comments
372 views