Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Problem with nodes affixed to an ellipse
Problem with nodes affixed to an ellipse [message #658658] Wed, 09 March 2011 12:17 Go to next message
Aintzane  is currently offline Aintzane Friend
Messages: 10
Registered: March 2011
Junior Member

I would like to create this figure

Therefore, I've created three nodes:

  • SiS: for the ellipse figure
  • InputPort: for the rectangle on the left
  • OutputPort: for the rectangle on the right

Input and output ports are nodes affixed to the west and east of SiS node, respectively. Next, the corresponding .gmfgraph and .gmfmap files.

<?xml version="1.0" encoding="UTF-8"?>
<gmfgraph:Canvas xmi:version="2.0" xmlns:xmi="" xmlns:xsi=""
    xmlns:gmfgraph="" name="servicegraph">
  <figures name="Default">
    <descriptors name="EllipseSiSFigure">
      <actualFigure xsi:type="gmfgraph:Ellipse" name="EllipseSiSFigure">
        <maximumSize dx="202" dy="102"/>
        <minimumSize dx="201" dy="101"/>
        <size x="202" y="102"/>
    <descriptors name="InPortFigure">
      <actualFigure xsi:type="gmfgraph:Rectangle" name="InPortFigure">
        <maximumSize dx="21" dy="21"/>
        <minimumSize dx="20" dy="20"/>
        <preferredSize dx="20" dy="20"/>
        <size x="20" y="20"/>
    <descriptors name="OutPortFigure">
      <actualFigure xsi:type="gmfgraph:Rectangle" name="OutPortFigure">
        <maximumSize dx="21" dy="21"/>
        <minimumSize dx="20" dy="20"/>
        <preferredSize dx="20" dy="20"/>
        <size x="20" y="20"/>
  <nodes name="SiS" figure="EllipseSiSFigure"/>
  <nodes name="inputPort" figure="InPortFigure" affixedParentSide="WEST"/>
  <nodes name="outputPort" figure="OutPortFigure" affixedParentSide="EAST"/>
  <labels name="SiSID"/>

<?xml version="1.0" encoding="UTF-8"?>
<gmfmap:Mapping xmi:version="2.0" xmlns:xmi="" xmlns:xsi=""
    xmlns:gmfmap="" xmlns:gmftool="">
    <containmentFeature href="servicegraph.ecore#//SOA/servicesInSOA"/>
      <domainMetaElement href="servicegraph.ecore#//SiS"/>
      <labelMappings xsi:type="gmfmap:FeatureLabelMapping">
        <diagramLabel href="servicegraph.gmfgraph#SiSID"/>
        <features href="servicegraph.ecore#//SiS/sisID"/>
      <tool xsi:type="gmftool:CreationTool" href="servicegraph.gmftool#//@palette/@tools.0/@tools.0"/>
      <diagramNode href="servicegraph.gmfgraph#SiS"/>
        <containmentFeature href="servicegraph.ecore#//SiS/inputPort"/>
          <domainMetaElement href="servicegraph.ecore#//InPort"/>
          <tool xsi:type="gmftool:CreationTool" href="servicegraph.gmftool#//@palette/@tools.0/@tools.1"/>
          <diagramNode href="servicegraph.gmfgraph#inputPort"/>
        <containmentFeature href="servicegraph.ecore#//SiS/outputPort"/>
          <domainMetaElement href="servicegraph.ecore#//OutPort"/>
          <tool xsi:type="gmftool:CreationTool" href="servicegraph.gmftool#//@palette/@tools.0/@tools.2"/>
          <diagramNode href="servicegraph.gmfgraph#outputPort"/>
    <diagramCanvas href="servicegraph.gmfgraph#servicegraph"/>
    <domainModel href="servicegraph.ecore#/"/>
    <domainMetaElement href="servicegraph.ecore#//SOA"/>
    <palette href="servicegraph.gmftool#//@palette"/>

Unfortunately, when running the generated code, both rectangles are created in the west of the ellipse, and I've not found the error. What is happening? Is this a bug?

Supposing that the ellipse has a width of 200 and a height of 100, I've added some code to the createInPort_3001 and createOutPort_3002 methods.
Point location = new Point(200, 40);
ViewUtil.setStructuralFeatureValue(node, NotationPackage.eINSTANCE.getLocation_X(), new Integer(location.x));
ViewUtil.setStructuralFeatureValue(node, NotationPackage.eINSTANCE.getLocation_Y(), new Integer(location.y));

By means of this code I've been able to place the rectangles in the desired place. But now I've two more problems.

On the one hand, although I've established a maximum size for the ellipse, it is not taken into account, so big ellipses can be created, and the previously depicted code is useless. Is there any way to determine the maximum size of a figure?

On the other hand, I've tried to create at the same time the ellipse and the two affixed rectangles using the SiS create tool. For that purpose, I've modified the code of the doExecuteWithResult method of the SiSCreateCommand class.
	protected CommandResult doExecuteWithResult(IProgressMonitor monitor,
			IAdaptable info) throws ExecutionException {
		SiS newElement = ServicegraphFactory.eINSTANCE.createSiS();

		edu.ehu.gcis.iland.servicegraph.SOA owner = (edu.ehu.gcis.iland.servicegraph.SOA) getElementToEdit();
		 * Added code
		InPort newInPortElement = ServicegraphFactory.eINSTANCE.createInPort();
		OutPort newOutPortElement = ServicegraphFactory.eINSTANCE.createOutPort();

		doConfigure(newElement, monitor, info);

		((CreateElementRequest) getRequest()).setNewElement(newElement);
		return CommandResult.newOKCommandResult(newElement);

Again, in this case the rectangles are not created in the correct place. I don't know why this is happening.

In summary, my doubts are the following ones:

  • • Why the automatically generated code does not put affixed nodes in their correct side?
  • • Is it possible to avoid resizing a figure during its creation and after it?
  • • Why affixed nodes are not created in their correct place when all the nodes are created using the SiS create tool?

Thanks in advance,

Re: Problem with nodes affixed to an ellipse [message #672154 is a reply to message #658658] Fri, 20 May 2011 05:43 Go to previous message
Aurélien Pupier is currently offline Aurélien PupierFriend
Messages: 637
Registered: July 2009
Location: Grenoble, FRANCE
Senior Member


did you read this blogpost:
Why don't use a custom border item locator?


Aurélien Pupier - Red Hat
Senior Software Engineer in Fuse Tooling team
Previous Topic:GraphicalNodeEditPolicy classes not generated
Next Topic:Contributing my own "SAVE" Action
Goto Forum:

Current Time: Fri Feb 26 19:04:28 GMT 2021

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

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

Back to the top