[Eugenia] Create a second label in a Rectangle Figure [message #760955] |
Mon, 05 December 2011 17:29 |
Snakebyte Missing name Messages: 130 Registered: November 2011 |
Senior Member |
|
|
Hello everybody.
I created a node from following emfatic code.
@gmf.node(label="identifier,content", border.width="2",border.color="0,0,0",size="130,50",figure="rectangle", label.pattern="{0} : {1}")
class Goal extends StandardNode
{
attr String identifier;
attr String content;
}
Im using the Message Format here.
What i want to achieve is a second label in the node, appear at a fixed place inside the node.
The result should look like an automatic generated node. The identifier should appear as always.
But the second label "content" should be placed at a specific point.
So i think i have to change the .gmfgraph file.
I already looked at the tutorial, but i can't imagine how to do this.
Any more tutorials ? ideas ?
Particularly i need to know how doing this in EOL.
Is there a complete Syntax of EOL anywhere ?
When i try doing it like this :
var GoalFigure = GmfGraph!Rectangle.all.
selectOne(r|r.name = 'GoalFigure');
GoalFigure.label = new GmfGraph!Label;
The object is inserted as a sibling of the main canvas.
Is there any reference about the properties etc. ?
Greetings
[Updated on: Mon, 05 December 2011 18:08] Report message to a moderator
|
|
|
Re: [Eugenia] Create a second label in a Rectangle Figure [message #761020 is a reply to message #760955] |
Mon, 05 December 2011 19:30 |
Snakebyte Missing name Messages: 130 Registered: November 2011 |
Senior Member |
|
|
Ok i think i have found out how to do it.
I set a new ChildAccess and an new Label unter my Figure Descriptor GoalFigure.
Then i add a new Diagram Label to Canvas, setting all the options like they are in the first auto-generated label.
But i changed one think, because i want this label to appear at the bottom of my figure.
I set "Affixed Parent Side" to : SOUTH
and "Resize Constraint" to : SOUTH
afterwards i set a new mapping accordingly as they are set in the auto-generated label, inserting all the relevant attributes from my new label.
At first it works great. But the label was not really at the bottom. I appears alligned in the middle and to on the left side of my Figure.
And the second thing i realized. I can't start my GSNModel.diagram file.
When i do this i got some strange exeptions.
What im doing wrong ?
I tried to do everything like the auto generated label. All i change was the Affixed Parent Side and Resize Constraint.
[Updated on: Mon, 05 December 2011 19:40] Report message to a moderator
|
|
|
|
|
Re: [Eugenia] Create a second label in a Rectangle Figure [message #761412 is a reply to message #761123] |
Tue, 06 December 2011 12:50 |
Snakebyte Missing name Messages: 130 Registered: November 2011 |
Senior Member |
|
|
Is it really ?
What if i dont want to change the .gmfmap ?
I created the following CustomNode.
package gsnModel.diagram.figures;
import org.eclipse.draw2d.BorderLayout;
import org.eclipse.draw2d.Figure;
import org.eclipse.draw2d.Graphics;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.PositionConstants;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.PointList;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel;
public class StrategyFigure extends Figure {
@Override
public void paint(Graphics graphics) {
Rectangle r = getBounds();
// Define the points of a trapez
Point p1 = new Point(r.x + r.width/5, r.y);
Point p2 = new Point(r.x + r.width, r.y);
Point p3 = new Point (r.x -r.width/5 +r.width, r.y + r.height);
Point p4 = new Point (r.x, r.y + r.height);
PointList pointList = new PointList();
pointList.addPoint(p1);
pointList.addPoint(p2);
pointList.addPoint(p3);
pointList.addPoint(p4);
// Fill the shape
graphics.fillPolygon(pointList);
// Draw the outline
graphics.drawLine(p1, p2);
graphics.drawLine(p2, p3);
graphics.drawLine(p3, p4);
graphics.drawLine(p4, p1);
// Move the label to the centre of the diamond
WrappingLabel label = (WrappingLabel) this.getChildren().get(0);
//System.out.println(this.getChildren().get(0).toString());
label.setAlignment(PositionConstants.BOTTOM | PositionConstants.RIGHT );
label.paint(graphics);
}
}
This figure has 2 Labels.
Now i want to arrange them in my Node.
One should appear always in the top left of the figure.
The other one should appear in the center.
The problem is when i use :
label.setAlignment(PositionConstants.TOP | PositionConstants.LEFT );
the text gets out of the figure.
So i got two question. How i can set the text that it starts in the Figure ?
And how i can get these thing with the three dots, when the text is too long ?
Is there no other way to set the labels in the Figure ?
the setAlignment() method is really bad...i want for example give specific points relative to my figure.
Greetings
[Updated on: Tue, 06 December 2011 13:03] Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.03054 seconds