Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Change the default Polyline Decoration for the target of a Polyline connection
Change the default Polyline Decoration for the target of a Polyline connection [message #513609] Wed, 10 February 2010 11:56 Go to next message
Eclipse UserFriend
Originally posted by: formatzeh.gmx.de

Hello all,
I defined a figure descriptor which should be used for a connection.
Therefore I added a Polyline Connection to it which should get an
ellipse as target decoration. So I created a new Polyline Decoration
which will be referenced in the target decoration. But after
regenerating the diagram code the links in the diagram only have the
default arrow and not the defined ellipse. Can you look over my Polyline
Decoration and give me some hints how to solve this issue?

<figures
xsi:type="gmfgraph:PolylineDecoration"
name="RoleImplicationTargetDecoration"
lineWidth="2">
<children
xsi:type="gmfgraph:Ellipse"
name="TargetEllipse">
<foregroundColor
xsi:type="gmfgraph:ConstantColor"
value="red"/>
<backgroundColor
xsi:type="gmfgraph:ConstantColor"
value="black"/>
<size
x="10"
y="10"/>
</children>
</figures>

best regards,
Gilbert
Re: Change the default Polyline Decoration for the target of a Polyline connection [message #513633 is a reply to message #513609] Wed, 10 February 2010 17:58 Go to previous messageGo to next message
Fernando Herrera is currently offline Fernando HerreraFriend
Messages: 49
Registered: January 2010
Member
Hi gilbert. try doing:

1) Create a new custom decoration with the name circleDecoration and the qualified class with the name yourplugin.diagram.figures.CircleDecoration

2) create the yourplugin.diagram.figures package and add a new class named CircleDecoration

3) copy and paste the following code.

package yourplugin.diagram.figures;

import org.eclipse.draw2d.Ellipse;
import org.eclipse.draw2d.RotatableDecoration;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.Rectangle;

public class CircleDecoration extends Ellipse implements RotatableDecoration {

private int myRadius = 5;
private Point myCenter = new Point();

public void setRadius(int radius){
erase();
myRadius = Math.abs(radius);
bounds = null;
repaint();
}

public void setLineWidth(int width){
super.setLineWidth(width);
}

public Rectangle getBounds(){
if(bounds == null){
int diameter = myRadius * 2;
bounds = new Rectangle(myCenter.x - myRadius, myCenter.y - myRadius, diameter, diameter);
bounds.expand(lineWidth/2 , lineWidth/2);
}
return bounds;
}

public void setLocation(Point p){
if(myCenter.equals(p))
return;
myCenter.setLocation(p);
bounds = null;
}

public void setReferencePoint(Point p) {
// TODO Auto-generated method stub

}


}

4) In the polyline connection set the target decoration property to the custom circleDecoration

5) regenerate the gmfgen model from your gmfmap model.

6) Ready

[Updated on: Wed, 10 February 2010 18:01]

Report message to a moderator

Re: Change the default Polyline Decoration for the target of a Polyline connection [message #513673 is a reply to message #513633] Wed, 10 February 2010 19:03 Go to previous message
Eclipse UserFriend
Originally posted by: formatzeh.gmx.de

Hi Fernando, thanks for your answer. I'll try this but I'm wondering if
there isn't a simpler solution like presented here [1]. There a little
stickman is modeled just without writing any Java code.

[1] http://wiki.eclipse.org/GMF_Tutorial_Part_3#Composite_Figure s
Previous Topic:[Announce] GMF 2.2.2RC3 is available
Next Topic:resize element by listening to model changes
Goto Forum:
  


Current Time: Tue Apr 20 08:33:39 GMT 2021

Powered by FUDForum. Page generated in 0.01696 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top