|
|
|
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 15:02 |
bluetlck Mising name Messages: 4 Registered: July 2009 |
Junior Member |
|
|
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 14:26 |
Bo Liu Messages: 9 Registered: July 2009 |
Junior Member |
|
|
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.03344 seconds