Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » how to change the transition arrow?
how to change the transition arrow? [message #756514] Mon, 14 November 2011 02:09 Go to next message
Iqbal Hossain is currently offline Iqbal Hossain
Messages: 101
Registered: May 2011
Location: Bangladesh
Senior Member
hi,
i make a diagram. but the problem is when i connect to nodes the connector is a straight line. but I want to show the connector as a arrow. what should i have to do? see the following pic:
index.php/fa/6118/0/


also how to make the connector as a fullduplex connector. see the following picture.
index.php/fa/6119/0/
  • Attachment: 11.jpg
    (Size: 11.56KB, Downloaded 241 times)
  • Attachment: 22.jpg
    (Size: 11.74KB, Downloaded 229 times)

[Updated on: Mon, 14 November 2011 03:48]

Report message to a moderator

Re: how to change the transition arrow? [message #756570 is a reply to message #756514] Mon, 14 November 2011 06:27 Go to previous messageGo to next message
Hoang  is currently offline Hoang
Messages: 45
Registered: September 2011
Location: Milan
Member
I am new to GMF but I will try to answer your question. Please someone correct me if I am wrong.

In your Figure Descriptors, you have to first add these lines of code:
    <figures
        xsi:type="gmfgraph:PolylineDecoration"
        name="ArrowDecoration">
      <template
          x="-1"
          y="1"/>
      <template/>
      <template
          x="-1"
          y="-1"/>
    </figures>


Then, you define your descriptors with the targetDecoration or SourceDecoration with references to this figure, like this:
    <descriptors
        name="SolidLineWDstArrowFigure">
      <actualFigure
          xsi:type="gmfgraph:PolylineConnection"
          targetDecoration="//@figures.0/@figures.0"/>
    </descriptors>


This example is from the StateDiagram sample code which you can add to your own gmf by using Load Resource... menu and add:
platform:/plugin/org.eclipse.gmf.graphdef/models/stateDiagram.gmfgraph


Here are the full sample state diagram code in case you don't have it.
<?xml verion="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="StateDiagram Canvas">
  <figures
      name="ClassDiagram Figure Gallery">
    <figures
        xsi:type="gmfgraph:PolylineDecoration"
        name="ArrowDecoration">
      <template
          x="-1"
          y="1"/>
      <template/>
      <template
          x="-1"
          y="-1"/>
    </figures>
    <descriptors
        name="RoundedRectangle">
      <actualFigure
          xsi:type="gmfgraph:RoundedRectangle"
          cornerWidth="25"
          cornerHeight="25">
        <layout
            xsi:type="gmfgraph:XYLayout"/>
        <children
            xsi:type="gmfgraph:Label"
            name="RoundedRectangle_NameLabel"/>
      </actualFigure>
      <accessors
          accessor="Name"
          figure="//@figures.0/@descriptors.0/@actualFigure/@children.0"/>
    </descriptors>
    <descriptors
        name="SimpleRectangle">
      <actualFigure
          xsi:type="gmfgraph:Rectangle"
          lineKind="LINE_DASH">
        <layout
            xsi:type="gmfgraph:XYLayout"/>
        <foregroundColor
            xsi:type="gmfgraph:ConstantColor"
            value="black"/>
        <children
            xsi:type="gmfgraph:Label"
            name="SimpleRectangle_NameLabel"/>
      </actualFigure>
      <accessors
          accessor="Name"
          figure="//@figures.0/@descriptors.1/@actualFigure/@children.0"/>
    </descriptors>
    <descriptors
        name="SolidLineWDstArrowFigure">
      <actualFigure
          xsi:type="gmfgraph:PolylineConnection"
          targetDecoration="//@figures.0/@figures.0"/>
    </descriptors>
  </figures>
  <nodes
      name="StateMachine_Node"
      figure="RoundedRectangle"/>
  <nodes
      name="Region"
      figure="SimpleRectangle"/>
  <nodes
      name="State"
      figure="RoundedRectangle"/>
	  <connections
	      name="SolidLineWDstArrow"
	      figure="SolidLineWDstArrowFigure"/>
	  <labels
	      name="StateMachine_Name"
	      figure="RoundedRectangle"
	      accessor="//@figures.0/@descriptors.0/@accessors.0"/>
	  <labels
	      name="Region_Name"
	      figure="SimpleRectangle"
	      accessor="//@figures.0/@descriptors.1/@accessors.0"/>
	  <labels
	      name="State_Name"
	      figure="RoundedRectangle"
	      accessor="//@figures.0/@descriptors.0/@accessors.0"/>
	</gmfgraph:Canvas>
Re: how to change the transition arrow? [message #756587 is a reply to message #756570] Mon, 14 November 2011 07:26 Go to previous messageGo to next message
Ralph Gerbig is currently offline Ralph Gerbig
Messages: 695
Registered: November 2009
Senior Member
Hi,

If you want to react on changes in the meta model you can override the handleNotification method in the EditPart. There you can change the decoration of the figure. Let me know if you want to do this and need further assistance.

Ralph
Re: how to change the transition arrow? [message #756633 is a reply to message #756587] Mon, 14 November 2011 09:41 Go to previous messageGo to next message
Iqbal Hossain is currently offline Iqbal Hossain
Messages: 101
Registered: May 2011
Location: Bangladesh
Senior Member
Hoang... u r new???? u knew a lot....thnx for ur help....let me try....i find an idea just like urs....
Re: how to change the transition arrow? [message #756634 is a reply to message #756633] Mon, 14 November 2011 09:42 Go to previous messageGo to next message
Iqbal Hossain is currently offline Iqbal Hossain
Messages: 101
Registered: May 2011
Location: Bangladesh
Senior Member
ralph....actually i am a begginer. i can't touch the raw code. u told me to go to the edit part. but its difficult for me. can i do anything from the editor?
Re: how to change the transition arrow? [message #756647 is a reply to message #756634] Mon, 14 November 2011 10:08 Go to previous messageGo to next message
Ralph Gerbig is currently offline Ralph Gerbig
Messages: 695
Registered: November 2009
Senior Member
Hi,

it depends on what you want to do. If you want to do this on creation only you can change the gmfgraph model and do what Hoang suggested. If you want to have dynamic behaviour you need to manipulate the figure which is not a big deal. All you need to do is to set the decoration in your code.

Ralph
Re: how to change the transition arrow? [message #756772 is a reply to message #756647] Mon, 14 November 2011 21:21 Go to previous message
Iqbal Hossain is currently offline Iqbal Hossain
Messages: 101
Registered: May 2011
Location: Bangladesh
Senior Member
done it.. i have to modify .gmfgraph. thnx guys...
Previous Topic:Error message: Node is referenced from multiple containers with different 'List Layout' value
Next Topic:importing swt plugin for xxx project in GMF
Goto Forum:
  


Current Time: Wed Apr 16 03:17:05 EDT 2014

Powered by FUDForum. Page generated in 0.16595 seconds