|
|
|
Re: need help on GMF graphic definition, how to add a vertical line in a rectangle? [message #234700 is a reply to message #234622] |
Thu, 25 June 2009 11:02   |
Eclipse User |
|
|
|
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);
}
}
|
|
|
Re: need help on GMF graphic definition, how to add a vertical line in a rectangle? [message #234845 is a reply to message #234700] |
Mon, 29 June 2009 10:26  |
Eclipse User |
|
|
|
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);
> }
> }
|
|
|
Powered by
FUDForum. Page generated in 0.48117 seconds