| [news.eclipse.modeling.gmf] Re: need help on GMF graphic definition, how to add a vertical line in a rectangle? |
Thanks a lot bluetlck.
Long way to go for my project. 8-]
on GMF graphic definition,you can define PolyLine ,but the line's location and length is fixed.
so need use custom layout to set label's position and use custom border to draw line and rectangle just like below:
public class CustomBorder extends LineBorder {
public void paint(IFigure figure, Graphics g, Insets insets) {
tempRect.setBounds(getPaintRectangle(figure, insets));
if (getWidth() % 2 == 1) {
tempRect.width--;
tempRect.height--;
}
tempRect.shrink(getWidth() / 2, getWidth() / 2);
g.setLineWidth(getWidth());
if (getColor() != null)
g.setForegroundColor(getColor());
g.drawRectangle(tempRect);
g.drawLine(tempRect.x +30, tempRect.y tempRect.x + 30, tempRect.y + tempRect.height);
} }