[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?
|
- From: wu_07@xxxxxxxx (bluetlck )
- Date: Thu, 25 Jun 2009 15:02:15 +0000 (UTC)
- Newsgroups: eclipse.modeling.gmf
- Organization: Eclipse
- User-agent: NewsPortal/0.36 (http://florian-amrhein.de/newsportal)
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);
}
}