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
Hi,

I would like to create this figure
http://img705.imageshack.us/img705/4733/desiredfigure.jpg


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="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:gmfgraph="http://www.eclipse.org/gmf/2006/GraphicalDefinition" 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"/>
      </actualFigure>
    </descriptors>
    <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"/>
      </actualFigure>
    </descriptors>
    <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"/>
      </actualFigure>
    </descriptors>
  </figures>
  <nodes name="SiS" figure="EllipseSiSFigure"/>
  <nodes name="inputPort" figure="InPortFigure" affixedParentSide="WEST"/>
  <nodes name="outputPort" figure="OutPortFigure" affixedParentSide="EAST"/>
  <labels name="SiSID"/>
</gmfgraph:Canvas>


<?xml version="1.0" encoding="UTF-8"?>
<gmfmap:Mapping xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:gmfmap="http://www.eclipse.org/gmf/2008/mappings" xmlns:gmftool="http://www.eclipse.org/gmf/2005/ToolDefinition">
  <nodes>
    <containmentFeature href="servicegraph.ecore#//SOA/servicesInSOA"/>
    <ownedChild>
      <domainMetaElement href="servicegraph.ecore#//SiS"/>
      <labelMappings xsi:type="gmfmap:FeatureLabelMapping">
        <diagramLabel href="servicegraph.gmfgraph#SiSID"/>
        <features href="servicegraph.ecore#//SiS/sisID"/>
      </labelMappings>
      <tool xsi:type="gmftool:CreationTool" href="servicegraph.gmftool#//@palette/@tools.0/@tools.0"/>
      <diagramNode href="servicegraph.gmfgraph#SiS"/>
      <children>
        <containmentFeature href="servicegraph.ecore#//SiS/inputPort"/>
        <ownedChild>
          <domainMetaElement href="servicegraph.ecore#//InPort"/>
          <tool xsi:type="gmftool:CreationTool" href="servicegraph.gmftool#//@palette/@tools.0/@tools.1"/>
          <diagramNode href="servicegraph.gmfgraph#inputPort"/>
        </ownedChild>
      </children>
      <children>
        <containmentFeature href="servicegraph.ecore#//SiS/outputPort"/>
        <ownedChild>
          <domainMetaElement href="servicegraph.ecore#//OutPort"/>
          <tool xsi:type="gmftool:CreationTool" href="servicegraph.gmftool#//@palette/@tools.0/@tools.2"/>
          <diagramNode href="servicegraph.gmfgraph#outputPort"/>
        </ownedChild>
      </children>
    </ownedChild>
  </nodes>
  <diagram>
    <diagramCanvas href="servicegraph.gmfgraph#servicegraph"/>
    <domainModel href="servicegraph.ecore#/"/>
    <domainMetaElement href="servicegraph.ecore#//SOA"/>
    <palette href="servicegraph.gmftool#//@palette"/>
  </diagram>
</gmfmap:Mapping>


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();
		owner.getServicesInSOA().add(newElement);
				
		/*
		 * Added code
		 */		
		InPort newInPortElement = ServicegraphFactory.eINSTANCE.createInPort();
		newElement.setInputPort(newInPortElement);		
		OutPort newOutPortElement = ServicegraphFactory.eINSTANCE.createOutPort();
		newElement.setOutputPort(newOutPortElement);

		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,

Aintzane
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

Hi,

did you read this blogpost: http://www.bonitasoft.org/blog/tutorial/how-to-create-and-customize-boundary-items-in-eclipse-gmf/
Why don't use a custom border item locator?

Regards,


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: Thu Mar 28 15:38:33 GMT 2024

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

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

Back to the top