In draw2d,How can I draw a figure without having any border? How to implements the CustomBorder for rectangles to remove the border? I know if we implement a class which extends Border, and in the paint method what should I do to remove the border?
rectangle without border
1.6k Views Asked by user414967 At
2
There are 2 best solutions below
1

You can disable the border with figure.setBorder(null);
or you can put it in the constructor:
public static class BorderlessFigure extends Figure {
public BorderlessFigure() {
ToolbarLayout layout = new ToolbarLayout();
setLayoutManager(layout);
setBorder(null);
add(new Label("test"));
}
}
If you want a Border that does not paint anything you can extend org.eclipse.draw2d.AbstractBorder
:
public class NoBorderBorder extends AbstractBorder {
@Override
public void paint(IFigure f, Graphics g, Insets i) { }
@Override
public Insets getInsets(IFigure f) {
return new Insets(0);
}
}
I don't know why would you do that though.
Figures don't have a border unless you explicitly set one by calling
setBorder(..)
. If you just want a blank figure that doesn't draw anything, thennew Figure()
will give you just that. There's no need to implement any custom borders or figures. If you are using aRectangle
then that's exactly what you will get: a rectangle; which is what you probably confused for a border.