[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.modeling.gmf] Re: need help on GMF graphic definition, how to add a vertical line in a rectangle?

Thanks a lot bluetlck.

I can't purely rely on the GMF and code generation stuff, do I?
As I have seen from the previous post about graphic definition, GEF is needed a lot.


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);

	}
}