Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » [Eugenia] Create a second label in a Rectangle Figure
[Eugenia] Create a second label in a Rectangle Figure [message #760955] Mon, 05 December 2011 17:29 Go to next message
Snakebyte Missing name is currently offline 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 Go to previous messageGo to next message
Snakebyte Missing name is currently offline 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 #761027 is a reply to message #761020] Mon, 05 December 2011 19:39 Go to previous messageGo to next message
Snakebyte Missing name is currently offline Snakebyte Missing name
Messages: 130
Registered: November 2011
Senior Member
Ok i think i fixed all my problems.

Just one remaining.

It seems like it doesn't matter, what "AffixedParentSide" i choose.
The label always appears in the same position.

How can i change that ?
Re: [Eugenia] Create a second label in a Rectangle Figure [message #761123 is a reply to message #761027] Mon, 05 December 2011 23:33 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris Kolovos
Messages: 886
Registered: July 2009
Senior Member
Hi,

This looks like a pure GMF question so I'd try the GMF forum instead.

Cheers,
Dimitris
Re: [Eugenia] Create a second label in a Rectangle Figure [message #761412 is a reply to message #761123] Tue, 06 December 2011 12:50 Go to previous messageGo to next message
Snakebyte Missing name is currently offline 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

Re: [Eugenia] Create a second label in a Rectangle Figure [message #761438 is a reply to message #761412] Tue, 06 December 2011 13:31 Go to previous message
Dimitris Kolovos is currently offline Dimitris Kolovos
Messages: 886
Registered: July 2009
Senior Member
Hi,

These are pure GMF questions indeed. EuGENia only takes you as far as the *.gmf* models and then invokes the built-in GMF generator. Therefore, any questions about how to modify the *.gmf* models or the generated code should really be addressed to the GMF forum.

Cheers,
Dimitris
Previous Topic:[EOL] Get All Properties
Next Topic:[Eugenia] Deleting Tool Objects, Deleting Tool Connections
Goto Forum:
  


Current Time: Sat Oct 25 17:36:54 GMT 2014

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

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