Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Repeating/Streching with ImageFigures(Or: how to skin a Rectangle with bitmaps)
Repeating/Streching with ImageFigures [message #631723] Fri, 08 October 2010 14:26
Chris  is currently offline Chris Friend
Messages: 44
Registered: April 2010
Member
Hi,

in order to make my editor more user friendly, I decided, to replace some blunt b/w boxes with more eye-friendly skins. Based on the rounded corners and gradients found in the eclipse gui, I came up with a subtle skin:

http://www.startrek-journey.de/webcontent/img/eclipseskin.png

Now I've implemented a skinned rectangle:
public class SkinnedBox extends RectangleFigure {
    // corners and edge filler bitmaps of the skin
    static private final Image TOP_LEFT = Activator.getImageDescriptor("icons/BoxSkinTopLeft.png").createImage();
    static private final Image TOP_RIGHT = Activator.getImageDescriptor("icons/BoxSkinTopRight.png").createImage();
    static private final Image TOP_FILL = Activator.getImageDescriptor("icons/BoxSkinTopFill.png").createImage();
    static private final Image BOTTOM_LEFT = Activator.getImageDescriptor("icons/BoxSkinBottomLeft.png").createImage();
    static private final Image BOTTOM_RIGHT = Activator.getImageDescriptor("icons/BoxSkinBottomRight.png").createImage();
    static private final Image BOTTOM_FILL = Activator.getImageDescriptor("icons/BoxSkinBottomFill.png").createImage();
    static private final Image LEFT_FILL = Activator.getImageDescriptor("icons/BoxSkinLeftFill.png").createImage();
    static private final Image RIGHT_FILL = Activator.getImageDescriptor("icons/BoxSkinRightFill.png").createImage();
    
    /**
     * @param typeName the fully qualified type name
     */
    public SkinnedBox() {
        // create top figure
        RectangleFigure topFigure = new RectangleFigure();
        topFigure.setOutline(false);
        topFigure.setFill(false);
        BorderLayout topLayout = new BorderLayout();
        topLayout.setHorizontalSpacing(0);
        topLayout.setVerticalSpacing(0);
        topFigure.setLayoutManager(topLayout);
        topFigure.add(new ImageFigure(SkinnedBox.TOP_LEFT), BorderLayout.LEFT);
        topFigure.add(new ImageFigure(SkinnedBox.TOP_FILL), BorderLayout.CENTER);
        topFigure.add(new ImageFigure(SkinnedBox.TOP_RIGHT), BorderLayout.RIGHT);
        //topFigure.setMaximumSize(new Dimension(-1, 23));
        
        // create bottom figure
        RectangleFigure bottomFigure = new RectangleFigure();
        bottomFigure.setOutline(false);
        bottomFigure.setFill(false);
        BorderLayout bottomLayout = new BorderLayout();
        bottomLayout.setHorizontalSpacing(0);
        bottomLayout.setVerticalSpacing(0);
        bottomFigure.setLayoutManager(bottomLayout);
        bottomFigure.add(new ImageFigure(SkinnedBox.BOTTOM_LEFT), BorderLayout.LEFT);
        bottomFigure.add(new ImageFigure(SkinnedBox.BOTTOM_FILL), BorderLayout.CENTER);
        bottomFigure.add(new ImageFigure(SkinnedBox.BOTTOM_RIGHT), BorderLayout.RIGHT);
        //topFigure.setMaximumSize(new Dimension(-1, 3));

        // create primary layout
        this.setOutline(false);
        this.setFill(false);
        BorderLayout layout = new BorderLayout();
        layout.setHorizontalSpacing(0);
        layout.setVerticalSpacing(0);
        this.setLayoutManager(layout);
        this.add(topFigure, BorderLayout.TOP);
        this.add(bottomFigure, BorderLayout.BOTTOM);
        this.add(new ImageFigure(SkinnedBox.LEFT_FILL), BorderLayout.LEFT);
        this.add(new ImageFigure(SkinnedBox.RIGHT_FILL), BorderLayout.RIGHT);
        RectangleFigure whiteFill = new RectangleFigure();
        whiteFill.setOutline(false);
        this.add(whiteFill, BorderLayout.CENTER);
        this.setPreferredSize(new Dimension(26,72));
        this.setMinimumSize(new Dimension(26,72));
    }
}


The problem is, that I would like to stretch or repeat the filler bitmaps along the edges. The above setup only works if the edge textures are incredibly large, so that the box is always smaller than the bitmap. It's a waste of resources and I'd like to do better, short of implementing a new ImageFigure class if possible Wink

I'd appreciate any help with this.

Regards,
Chris
Previous Topic:How to update Figure with a timer?
Next Topic:Different Routing for different type of connections
Goto Forum:
  


Current Time: Thu Dec 18 09:50:00 GMT 2014

Powered by FUDForum. Page generated in 0.07228 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software