Yeah, that worked, thanks :))

        public Visual getRepresentation() {
            Bounds b = getNodeBounds(getSelectedPath());
BufferedImage canvas = new BufferedImage(b.width, b.height, BufferedImage.TYPE_INT_ARGB);
            Graphics2D g = (Graphics2D) canvas.getGraphics();
            g.translate(0, b.y * -1);
            paint(g);
            return new Picture(canvas);
        }


Den 08.06.2011 14:59, skrev Chris Bartlett:
I'll to reply with some example code in a couple of hours if I have some free time.

If I remember correctly, it goes something like ...
- Create a BufferedImage to hold the representation
- Get the bounds of the node you wish to use for the representation
- Apply a transformation so that the TreeView bounds of the node align over your BufferedImage
- Call the TreeView's paint(Graphics2D) method
http://pivot.apache.org/2.0/docs/api/org/apache/pivot/wtk/Component.html#paint(java.awt.Graphics2D) <http://pivot.apache.org/2.0/docs/api/org/apache/pivot/wtk/Component.html#paint%28java.awt.Graphics2D%29>
- Put the BufferedImage into a Picture
http://pivot.apache.org/2.0/docs/api/org/apache/pivot/wtk/media/Picture.html
- Use the Picture as the representation

Chris


On 8 June 2011 19:46, Edvin Syse <[email protected] <mailto:[email protected]>> wrote:

    While dragging, it would also be cool to show the actual node via
    DragSource#getRepresentation(). I'm unsure how to get a hold of this.

    -- Edvin

    Den 08.06.2011 10:35, skrev Edvin Syse:

        Den 08.06.2011 10:33, skrev Chris Bartlett:

            I'm sure plenty of people would be interested in what you
            have done if you are willing and able to share it.


        Allright, then I'll try to blog about it this coming weekend
        and put up some code :) Will post here.

        -- Edvin


Reply via email to