Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » How to create a rectangle-with-dog-ear figure? Gallery anywhere?
How to create a rectangle-with-dog-ear figure? Gallery anywhere? [message #70713] Fri, 27 October 2006 11:41 Go to next message
Michael Moser is currently offline Michael MoserFriend
Messages: 914
Registered: July 2009
Senior Member
What's an elegant way to create a figure like the ones used for notes
(the sheet with a dog-ear, i.e. a triangle bent down in the upper
right)? Is there a gallery or resource that one can import for that?
With "elegant" I also mean, that the figure should nicely resize,
provide a reflowing label, etc. etc,

I didn't find any such figure in the standard galleries
(platform:/plugin/org.eclipse.gmf.graphdef/models/basic.gmfg raph,
platform:/plugin/org.eclipse.gmf.graphdef/models/classDiagra m.gmfgraph,
platform:/plugin/org.eclipse.gmf.graphdef/models/stateDiagra m.gmfgraph),
but apparently it's around somewhere, since the created diagram plugins
all provide a "Note" palette entry.

Michael
Re: How to create a rectangle-with-dog-ear figure? Gallery anywhere? [message #70898 is a reply to message #70713] Fri, 27 October 2006 14:41 Go to previous messageGo to next message
Mohammed Mostafa is currently offline Mohammed MostafaFriend
Messages: 143
Registered: July 2009
Senior Member
The figure used by notes is called NoteFigure it is public in the
plugin org.eclipse.gmf.runtime.diagram.ui. You can use it or subclass it
to do any customizations you need
The way to use change the figure created by the edit part is to change
the code in the your edit part's createFigure() method to create
NoteFigure or a sub class of it

Michael Moser wrote:


> What's an elegant way to create a figure like the ones used for notes
> (the sheet with a dog-ear, i.e. a triangle bent down in the upper
> right)? Is there a gallery or resource that one can import for that?
> With "elegant" I also mean, that the figure should nicely resize,
> provide a reflowing label, etc. etc,
>
> I didn't find any such figure in the standard galleries
> (platform:/plugin/org.eclipse.gmf.graphdef/models/basic.gmfg raph,
> platform:/plugin/org.eclipse.gmf.graphdef/models/classDiagra m.gmfgraph,
> platform:/plugin/org.eclipse.gmf.graphdef/models/stateDiagra m.gmfgraph),
> but apparently it's around somewhere, since the created diagram plugins
> all provide a "Note" palette entry.
>
> Michael
>
Re: How to create a rectangle-with-dog-ear figure? Gallery anywhere? [message #71104 is a reply to message #70898] Fri, 27 October 2006 20:58 Go to previous messageGo to next message
Michael Moser is currently offline Michael MoserFriend
Messages: 914
Registered: July 2009
Senior Member
For the benefit of others: the class is in package "figures" of said
plugin, i.e.:
org.eclipse.gmf.runtime.diagram.ui.figures.NoteFigure

My next question: the constructor of that figure requires additional
parameters, it is defined as:
public NoteFigure(int width, int height, Insets insets) { ... }

Without these parameters the code generated does not compile. How does
one define such parameters???
Or is the onl;y way to define a derived class that hard-codes these
parameters, i.e. something like

public MySpecialNoteFigure() extends NoteFigure {
super(50, 70, null);
}


Michael


"Mohammed Mostafa" <mmostafa@ca.ibm.com> wrote in message
news:eht5tn$m3t$1@utils.eclipse.org...
> The figure used by notes is called NoteFigure it is public in the
> plugin org.eclipse.gmf.runtime.diagram.ui. You can use it or subclass
> it to do any customizations you need
> The way to use change the figure created by the edit part is to change
> the code in the your edit part's createFigure() method to create
> NoteFigure or a sub class of it
Re: How to create a rectangle-with-dog-ear figure? Gallery anywhere? [message #71381 is a reply to message #70898] Sun, 29 October 2006 15:57 Go to previous messageGo to next message
Michael Moser is currently offline Michael MoserFriend
Messages: 914
Registered: July 2009
Senior Member
This NoteFigure has a life of its own! I have created a sub-class of
NoteFigure:

public MyNotesFigure extends NoteFigure {
super(50, 75, new Insets(5,5,5,5));
}

but for some strange reason NoteFigure ignores the width and height
parameters that I pass into the super-constructor. The figure is always
displayed with a size of (I would estimate) 100x100. It also seems to
ignore child items! I added a label to it and this label is not
displayed.

So, this internal figure seems not very useful for derivation of custom
figures. Or has anybody else managed to extend this class properly?

Michael
Re: How to create a rectangle-with-dog-ear figure? Gallery anywhere? [message #71571 is a reply to message #71104] Mon, 30 October 2006 14:46 Go to previous messageGo to next message
Mohammed Mostafa is currently offline Mohammed MostafaFriend
Messages: 143
Registered: July 2009
Senior Member
Michael Moser wrote:

If you check the java doc of the note figure constructor you will find
that the extra parameter is :

* @param insets <code>Insets</code> that is the empty margin inside the
note figure in logical units

you should not pass null, you pass whatever value suitable in your case
and keep in mind it is in logical coordinates (if you do not use Map
mode then forget about logical and physical modes they both are the same)




> For the benefit of others: the class is in package "figures" of said
> plugin, i.e.:
> org.eclipse.gmf.runtime.diagram.ui.figures.NoteFigure
>
> My next question: the constructor of that figure requires additional
> parameters, it is defined as:
> public NoteFigure(int width, int height, Insets insets) { ... }
>
> Without these parameters the code generated does not compile. How does
> one define such parameters???
> Or is the onl;y way to define a derived class that hard-codes these
> parameters, i.e. something like
>
> public MySpecialNoteFigure() extends NoteFigure {
> super(50, 70, null);
> }
>
>
> Michael
>
>
> "Mohammed Mostafa" <mmostafa@ca.ibm.com> wrote in message
> news:eht5tn$m3t$1@utils.eclipse.org...
>> The figure used by notes is called NoteFigure it is public in the
>> plugin org.eclipse.gmf.runtime.diagram.ui. You can use it or subclass
>> it to do any customizations you need
>> The way to use change the figure created by the edit part is to change
>> the code in the your edit part's createFigure() method to create
>> NoteFigure or a sub class of it
>
Re: How to create a rectangle-with-dog-ear figure? Gallery anywhere? [message #71590 is a reply to message #71381] Mon, 30 October 2006 14:55 Go to previous message
Mohammed Mostafa is currently offline Mohammed MostafaFriend
Messages: 143
Registered: July 2009
Senior Member
I've tried a very simple case with the generated code where i use the
note figure instead of the generated figure , and noticed that width and
height works as i expect. It respect the value i pass (as long as I just
drop the shape on the diagram surface, otherwise it will use the exact
rectangle i draw on the diagram surface)

this is the way i create my figure :

/**
* @generated Not
*/
protected IFigure createNodeShape() {
Insets insets = new Insets(getMapMode().DPtoLP(30),
getMapMode().DPtoLP(30), getMapMode().DPtoLP(30), getMapMode().DPtoLP(45));
primaryShape = new MyFigure(getMapMode().DPtoLP(300),
getMapMode().DPtoLP(400), insets);
return primaryShape;
}

i have not tried to add labels though ; (I'll try it when i have free time)



Michael Moser wrote:
> This NoteFigure has a life of its own! I have created a sub-class of
> NoteFigure:
>
> public MyNotesFigure extends NoteFigure {
> super(50, 75, new Insets(5,5,5,5));
> }
>
> but for some strange reason NoteFigure ignores the width and height
> parameters that I pass into the super-constructor. The figure is always
> displayed with a size of (I would estimate) 100x100. It also seems to
> ignore child items! I added a label to it and this label is not displayed.
>
> So, this internal figure seems not very useful for derivation of custom
> figures. Or has anybody else managed to extend this class properly?
>
> Michael
>
Previous Topic:Re: Ecore diagram bugs with Linux Kubuntu Edgy
Next Topic:changing connection color programtically
Goto Forum:
  


Current Time: Wed Jul 17 20:44:02 GMT 2024

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

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

Back to the top