Home » Eclipse Projects » GEF » Display just a small area of figure...
Display just a small area of figure... [message #146802] |
Sun, 08 August 2004 18:38 |
Eclipse User |
|
|
|
Originally posted by: ngeorgemel.eclipse.laposte.net
Hi,
i read and read again gef documentation but i can't find reason why my
figure is partially rendered....
I wrote an eclipse plugin with one EditViewPart.
i've got one model
i've got one figure
i've got one EditPart
i've got a gef viewer to render all of that
in figure's class, Paint method display a rectangle (use for test). code
is the following :
public void paint(Graphics graphics)
{
Rectangle r = new Rectangle();
r.setSize(500, 400);
r.setLocation(1,1);
graphics.drawRectangle(r);
}
In my EditViewPart i've got this code :
//declaration is above in class...
private ScalableFreeformRootEditPart rootEditPart;
private GraphicalViewerImpl viewer;
public void createPartControl(Composite parent)
{
//set model
MyModel model = new Model(); //in my real code there is many
//init for model
//set root edit part
this.rootEditPart = new ScalableFreeformRootEditPart();
//create viewer
this.viewer = new GraphicalViewerImpl();
//create control
this.viewer.createControl(parent);
//set viewer properties
this.viewer.setRootEditPart(this.rootEditPart);
this.viewer.setEditPartFactory(new MyEditPartFactory());
this.viewer.setContents(model);
}
And the result is the half of a small rectangle (this is what it's
rendered in EditViewPart, in ascii you could see that :
------------
|
|
|
So dimension are not the one i want (500 * 400) and figure is the half
of the one i want to display....
Maybe there is a layout problem, a parent configuration missing... i
don't know. I tried to change color of figure but code failed (i don't
know how to change color...).
If someone can tell me what is wrong...
thanks !
|
|
|
Re: Display just a small area of figure... [message #146830 is a reply to message #146802] |
Mon, 09 August 2004 04:47 |
Eclipse User |
|
|
|
Originally posted by: gupolet.ulb.ac.be
What about a contents layer and a layout manager. As I recall from the
tutorial, they put a a content EditPart between the rootEditPart and the
rest of the childs:
This is what it looks like in the tuto:
public class DiagramContentsEditPart extends AbstractGraphicalEditPart {
protected IFigure createFigure() {
Figure f = new Figure();
f.setOpaque(true);
f.setLayoutManager(new XYLayout());
return f;
}
protected void createEditPolicies() {
...
}
protected List getModelChildren() {
return ((MyModelType)getModel()).getDiagramChildren();
}
}
the rest is @:
http://www-106.ibm.com/developerworks/opensource/library/os- gef/
I did used this:
protected IFigure createFigure() {
IFigure figure=new FreeformLayer();
figure.setOpaque(true);
figure.setLayoutManager(new MyLayoutManager());
return figure;
}
for the contents editPart where MyLayoutManager is just a daughter of
FreeformLayout.
For color change, just call something like this:
figure.setForegroundColor(ColorConstants.green);
this should do the trick.
"Nicolas Georgemel" <ngeorgemel.eclipse@laposte.net> a
-
Attachment: fig4.gif
(Size: 3.14KB, Downloaded 143 times)
|
|
|
Re: Display just a small area of figure... [message #146865 is a reply to message #146830] |
Mon, 09 August 2004 07:53 |
Eclipse User |
|
|
|
Originally posted by: ngeorgemel.eclipse.laposte.net
Thanks, i 'll follow this way !
thanks for your suppport,
et vive la belgique ;-) !!
Guillaume Polet wrote:
> What about a contents layer and a layout manager. As I recall from the
> tutorial, they put a a content EditPart between the rootEditPart and the
> rest of the childs:
> This is what it looks like in the tuto:
>
> public class DiagramContentsEditPart extends AbstractGraphicalEditPart {
> protected IFigure createFigure() {
> Figure f = new Figure();
> f.setOpaque(true);
> f.setLayoutManager(new XYLayout());
> return f;
> }
>
> protected void createEditPolicies() {
> ...
> }
>
> protected List getModelChildren() {
> return ((MyModelType)getModel()).getDiagramChildren();
> }
> }
> the rest is @:
> http://www-106.ibm.com/developerworks/opensource/library/os- gef/
>
> I did used this:
> protected IFigure createFigure() {
> IFigure figure=new FreeformLayer();
> figure.setOpaque(true);
> figure.setLayoutManager(new MyLayoutManager());
> return figure;
> }
>
> for the contents editPart where MyLayoutManager is just a daughter of
> FreeformLayout.
>
> For color change, just call something like this:
>
> figure.setForegroundColor(ColorConstants.green);
>
> this should do the trick.
>
> "Nicolas Georgemel" <ngeorgemel.eclipse@laposte.net> a écrit dans le message
> de news:cf5rcb$kdm$1@eclipse.org...
>
>>Hi,
>>
>>i read and read again gef documentation but i can't find reason why my
>>figure is partially rendered....
>>
>>I wrote an eclipse plugin with one EditViewPart.
>>i've got one model
>>i've got one figure
>>i've got one EditPart
>>i've got a gef viewer to render all of that
>>
>>in figure's class, Paint method display a rectangle (use for test). code
>>is the following :
>>
>>public void paint(Graphics graphics)
>>{
>> Rectangle r = new Rectangle();
>> r.setSize(500, 400);
>> r.setLocation(1,1);
>> graphics.drawRectangle(r);
>>}
>>
>>In my EditViewPart i've got this code :
>>
>>//declaration is above in class...
>>private ScalableFreeformRootEditPart rootEditPart;
>>private GraphicalViewerImpl viewer;
>>
>>public void createPartControl(Composite parent)
>>{
>> //set model
>> MyModel model = new Model(); //in my real code there is many
>>//init for model
>>
>> //set root edit part
>> this.rootEditPart = new ScalableFreeformRootEditPart();
>>
>> //create viewer
>> this.viewer = new GraphicalViewerImpl();
>>
>> //create control
>> this.viewer.createControl(parent);
>>
>> //set viewer properties
>> this.viewer.setRootEditPart(this.rootEditPart);
>> this.viewer.setEditPartFactory(new MyEditPartFactory());
>> this.viewer.setContents(model);
>>
>>}
>>
>>
>>And the result is the half of a small rectangle (this is what it's
>>rendered in EditViewPart, in ascii you could see that :
>>
>>------------
>>|
>>|
>>|
>>
>>
>>So dimension are not the one i want (500 * 400) and figure is the half
>>of the one i want to display....
>>
>>Maybe there is a layout problem, a parent configuration missing... i
>>don't know. I tried to change color of figure but code failed (i don't
>>know how to change color...).
>>
>>If someone can tell me what is wrong...
>>
>>thanks !
>
>
>
|
|
|
Re: Display just a small area of figure... [message #146873 is a reply to message #146830] |
Mon, 09 August 2004 09:03 |
Eclipse User |
|
|
|
Originally posted by: ngeorgemel.eclipse.laposte.net
This is a multi-part message in MIME format.
--------------000201070101070202000601
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit
Hi,
i follow the way... but result stay the same ... :-(
i create a container class for model (content)
i create an EditPart for the container
i update my EditPartFactory
i update my code
container classe is the following :
-----------------------------------
public class DefaultContent
{
ArrayList content = new ArrayList();
public void addChild(Object object) {
content.add(object);
}
public List getChildren() {
return content;
}
public void removeChild(Object object) {
content.remove(object);
}
}
my EditPartFactory as change like this :
----------------------------------------
else if(model instanceof DefaultContent)
{
part = new DefaultContentEditPart();
}
In my DefaultContentEditPart i've got this:
-------------------------------------------
protected IFigure createFigure()
{
IFigure figure=new FreeformLayer();
figure.setOpaque(true);
figure.setLayoutManager(new XYLayout());
return figure;
}
protected List getModelChildren()
{
return ((DefaultContent)getModel()).getChildren();
}
And code in my EditViewPart is:
-------------------------------
public void createPartControl(Composite parent)
{
//set model container
DefaultContent content = new DefaultContent();
//set model
MyModel model = new Model();
//add model to model container
content.addChild(model);
//set root edit part
this.rootEditPart = new ScalableFreeformRootEditPart();
//create viewer
this.viewer = new GraphicalViewerImpl();
//create control
this.viewer.createControl(parent);
//set viewer properties
this.viewer.setRootEditPart(this.rootEditPart);
this.viewer.setEditPartFactory(new MyEditPartFactory());
this.viewer.setContents(content);
}
you've got a screen shot of the problem, if you see i've missed...
Guillaume Polet wrote:
> What about a contents layer and a layout manager. As I recall from the
> tutorial, they put a a content EditPart between the rootEditPart and the
> rest of the childs:
> This is what it looks like in the tuto:
>
> public class DiagramContentsEditPart extends AbstractGraphicalEditPart {
> protected IFigure createFigure() {
> Figure f = new Figure();
> f.setOpaque(true);
> f.setLayoutManager(new XYLayout());
> return f;
> }
>
> protected void createEditPolicies() {
> ...
> }
>
> protected List getModelChildren() {
> return ((MyModelType)getModel()).getDiagramChildren();
> }
> }
> the rest is @:
> http://www-106.ibm.com/developerworks/opensource/library/os- gef/
>
> I did used this:
> protected IFigure createFigure() {
> IFigure figure=new FreeformLayer();
> figure.setOpaque(true);
> figure.setLayoutManager(new MyLayoutManager());
> return figure;
> }
>
> for the contents editPart where MyLayoutManager is just a daughter of
> FreeformLayout.
>
> For color change, just call something like this:
>
> figure.setForegroundColor(ColorConstants.green);
>
> this should do the trick.
>
> "Nicolas Georgemel" <ngeorgemel.eclipse@laposte.net> a
|
|
|
Re: Display just a small area of figure... [message #146898 is a reply to message #146802] |
Mon, 09 August 2004 17:40 |
Pratik Shah Messages: 1077 Registered: July 2009 |
Senior Member |
|
|
From what I see it's working fine. The rectangle is being drawn of the
right size, just that the figure's not big enough to show all of it, so it's
being clipped. If you want to see the whole rectangle, you have to set the
size of the Figure to be big enough. In the createFigure() method in your
EditPart, set the size of the figure to be 501, 401 after you create it and
you'll see it.
"Nicolas Georgemel" <ngeorgemel.eclipse@laposte.net> wrote in message
news:cf5rcb$kdm$1@eclipse.org...
> Hi,
>
> i read and read again gef documentation but i can't find reason why my
> figure is partially rendered....
>
> I wrote an eclipse plugin with one EditViewPart.
> i've got one model
> i've got one figure
> i've got one EditPart
> i've got a gef viewer to render all of that
>
> in figure's class, Paint method display a rectangle (use for test). code
> is the following :
>
> public void paint(Graphics graphics)
> {
> Rectangle r = new Rectangle();
> r.setSize(500, 400);
> r.setLocation(1,1);
> graphics.drawRectangle(r);
> }
>
> In my EditViewPart i've got this code :
>
> //declaration is above in class...
> private ScalableFreeformRootEditPart rootEditPart;
> private GraphicalViewerImpl viewer;
>
> public void createPartControl(Composite parent)
> {
> //set model
> MyModel model = new Model(); //in my real code there is many
> //init for model
>
> //set root edit part
> this.rootEditPart = new ScalableFreeformRootEditPart();
>
> //create viewer
> this.viewer = new GraphicalViewerImpl();
>
> //create control
> this.viewer.createControl(parent);
>
> //set viewer properties
> this.viewer.setRootEditPart(this.rootEditPart);
> this.viewer.setEditPartFactory(new MyEditPartFactory());
> this.viewer.setContents(model);
>
> }
>
>
> And the result is the half of a small rectangle (this is what it's
> rendered in EditViewPart, in ascii you could see that :
>
> ------------
> |
> |
> |
>
>
> So dimension are not the one i want (500 * 400) and figure is the half
> of the one i want to display....
>
> Maybe there is a layout problem, a parent configuration missing... i
> don't know. I tried to change color of figure but code failed (i don't
> know how to change color...).
>
> If someone can tell me what is wrong...
>
> thanks !
|
|
|
Re: Display just a small area of figure... [message #146902 is a reply to message #146802] |
Mon, 09 August 2004 18:04 |
Eclipse User |
|
|
|
Originally posted by: none.us.ibm.com
Your figure is the default size (64,32). You need to make the figure,
possibly using a layout manager such as XYLayout or StackLayout.
"Nicolas Georgemel" <ngeorgemel.eclipse@laposte.net> wrote in message
news:cf5rcb$kdm$1@eclipse.org...
> Hi,
>
> i read and read again gef documentation but i can't find reason why my
> figure is partially rendered....
>
> I wrote an eclipse plugin with one EditViewPart.
> i've got one model
> i've got one figure
> i've got one EditPart
> i've got a gef viewer to render all of that
>
> in figure's class, Paint method display a rectangle (use for test). code
> is the following :
>
> public void paint(Graphics graphics)
> {
> Rectangle r = new Rectangle();
> r.setSize(500, 400);
> r.setLocation(1,1);
> graphics.drawRectangle(r);
> }
>
> In my EditViewPart i've got this code :
>
> //declaration is above in class...
> private ScalableFreeformRootEditPart rootEditPart;
> private GraphicalViewerImpl viewer;
>
> public void createPartControl(Composite parent)
> {
> //set model
> MyModel model = new Model(); //in my real code there is many
> //init for model
>
> //set root edit part
> this.rootEditPart = new ScalableFreeformRootEditPart();
>
> //create viewer
> this.viewer = new GraphicalViewerImpl();
>
> //create control
> this.viewer.createControl(parent);
>
> //set viewer properties
> this.viewer.setRootEditPart(this.rootEditPart);
> this.viewer.setEditPartFactory(new MyEditPartFactory());
> this.viewer.setContents(model);
>
> }
>
>
> And the result is the half of a small rectangle (this is what it's
> rendered in EditViewPart, in ascii you could see that :
>
> ------------
> |
> |
> |
>
>
> So dimension are not the one i want (500 * 400) and figure is the half
> of the one i want to display....
>
> Maybe there is a layout problem, a parent configuration missing... i
> don't know. I tried to change color of figure but code failed (i don't
> know how to change color...).
>
> If someone can tell me what is wrong...
>
> thanks !
|
|
|
Re: Display just a small area of figure... [message #146908 is a reply to message #146873] |
Mon, 09 August 2004 18:05 |
Eclipse User |
|
|
|
Originally posted by: gupolet.ulb.ac.be
I'm not quite sure, but I would have thought that with a FreeFormLayer, you
should use a FreeFormLayout (although, I think that as long as you don't use
negative positions, it should react the same as the XYLayout).
I joined my editor class so that you can compare (although it is not
finished yet), and an editPart which is used to display a rectangle on the
screen
"Nicolas Georgemel" <ngeorgemel.eclipse@laposte.net> a
|
|
|
Re: Display just a small area of figure... [message #146991 is a reply to message #146902] |
Mon, 09 August 2004 20:47 |
Eclipse User |
|
|
|
Originally posted by: ngeorgemel.eclipse.laposte.net
Randy is right !
when figure size (rectangle) < 64,32 so rectangle is displaying fine !!
in my model i've got a Class (DefaultContent) wich manages a list of
models (vi an array list).
this class has an EditPart (DefaultContentEditPart) with this method :
protected IFigure createFigure()
{
IFigure figure = new FreeformLayer();
figure.setLayoutManager(new XYLayout());
figure.setOpaque(true);
return figure;
}
figure returned is parent of rectangle (an is the content of my viewer :
GraphicalViewerImpl).
i tried to change figure size via "figure.setSize(520, 420);" cause i
believed that parent figure was to small but result is null. If i set
a green color to figure (FreeformLayer) i see a green splach wich fill
all my ViewPart (so my view).
if i increase rectangle dimension, it desapear after 64,32 limit
The result is : parent figure is wide an height enough.
i don't understand, i can't feel what is wrong, it seem's there's
a layer problem (cause size of parent figure and child figure change
nothing). So parents figure and child figure have both a layout manager
and accessor setOpaque turn to "true".
i think i'm in front of a wall cause i'm not a gef specialist and
problem is so simple to solve that i'll think later i was a dummy guy.
but right now, if somebody could (again...) give me help to close this
troubleshoot...
Randy Hudson wrote:
> Your figure is the default size (64,32). You need to make the figure,
> possibly using a layout manager such as XYLayout or StackLayout.
>
>
> "Nicolas Georgemel" <ngeorgemel.eclipse@laposte.net> wrote in message
> news:cf5rcb$kdm$1@eclipse.org...
>
>>Hi,
>>
>>i read and read again gef documentation but i can't find reason why my
>>figure is partially rendered....
>>
>>I wrote an eclipse plugin with one EditViewPart.
>>i've got one model
>>i've got one figure
>>i've got one EditPart
>>i've got a gef viewer to render all of that
>>
>>in figure's class, Paint method display a rectangle (use for test). code
>>is the following :
>>
>>public void paint(Graphics graphics)
>>{
>> Rectangle r = new Rectangle();
>> r.setSize(500, 400);
>> r.setLocation(1,1);
>> graphics.drawRectangle(r);
>>}
>>
>>In my EditViewPart i've got this code :
>>
>>//declaration is above in class...
>>private ScalableFreeformRootEditPart rootEditPart;
>>private GraphicalViewerImpl viewer;
>>
>>public void createPartControl(Composite parent)
>>{
>> //set model
>> MyModel model = new Model(); //in my real code there is many
>>//init for model
>>
>> //set root edit part
>> this.rootEditPart = new ScalableFreeformRootEditPart();
>>
>> //create viewer
>> this.viewer = new GraphicalViewerImpl();
>>
>> //create control
>> this.viewer.createControl(parent);
>>
>> //set viewer properties
>> this.viewer.setRootEditPart(this.rootEditPart);
>> this.viewer.setEditPartFactory(new MyEditPartFactory());
>> this.viewer.setContents(model);
>>
>>}
>>
>>
>>And the result is the half of a small rectangle (this is what it's
>>rendered in EditViewPart, in ascii you could see that :
>>
>>------------
>>|
>>|
>>|
>>
>>
>>So dimension are not the one i want (500 * 400) and figure is the half
>>of the one i want to display....
>>
>>Maybe there is a layout problem, a parent configuration missing... i
>>don't know. I tried to change color of figure but code failed (i don't
>>know how to change color...).
>>
>>If someone can tell me what is wrong...
>>
>>thanks !
>
>
>
|
|
|
Re: Display just a small area of figure... [message #147000 is a reply to message #146902] |
Mon, 09 August 2004 21:22 |
Eclipse User |
|
|
|
Originally posted by: ngeorgemel.eclipse.laposte.net
When i said i was a dummy guy, Randy was right again !!
i was confuse between figure displaying and my "Figure" (the object).
as randy explain GEF default Figure object has a ... default size (64,32)
Solution :
----------
in EditPart :
protected IFigure createFigure()
{
MyFigure f = new MyFigure();
f.setLayoutManager(new XYLayout());
f.setOpaque(true);
//for test
Rectangle r = new Rectangle();
r.setSize(500, 500);
f.setBounds(r); // <--- solution here
//end of test
return f;
}
It's so simple that at this time i feel just... how say that...
ridiculous ;-)
i hope that will help GEF newbies in many way...
Thanks Randy, Pratik and Guillaume.
Randy Hudson wrote:
> Your figure is the default size (64,32). You need to make the figure,
> possibly using a layout manager such as XYLayout or StackLayout.
>
>
> "Nicolas Georgemel" <ngeorgemel.eclipse@laposte.net> wrote in message
> news:cf5rcb$kdm$1@eclipse.org...
>
>>Hi,
>>
>>i read and read again gef documentation but i can't find reason why my
>>figure is partially rendered....
>>
>>I wrote an eclipse plugin with one EditViewPart.
>>i've got one model
>>i've got one figure
>>i've got one EditPart
>>i've got a gef viewer to render all of that
>>
>>in figure's class, Paint method display a rectangle (use for test). code
>>is the following :
>>
>>public void paint(Graphics graphics)
>>{
>> Rectangle r = new Rectangle();
>> r.setSize(500, 400);
>> r.setLocation(1,1);
>> graphics.drawRectangle(r);
>>}
>>
>>In my EditViewPart i've got this code :
>>
>>//declaration is above in class...
>>private ScalableFreeformRootEditPart rootEditPart;
>>private GraphicalViewerImpl viewer;
>>
>>public void createPartControl(Composite parent)
>>{
>> //set model
>> MyModel model = new Model(); //in my real code there is many
>>//init for model
>>
>> //set root edit part
>> this.rootEditPart = new ScalableFreeformRootEditPart();
>>
>> //create viewer
>> this.viewer = new GraphicalViewerImpl();
>>
>> //create control
>> this.viewer.createControl(parent);
>>
>> //set viewer properties
>> this.viewer.setRootEditPart(this.rootEditPart);
>> this.viewer.setEditPartFactory(new MyEditPartFactory());
>> this.viewer.setContents(model);
>>
>>}
>>
>>
>>And the result is the half of a small rectangle (this is what it's
>>rendered in EditViewPart, in ascii you could see that :
>>
>>------------
>>|
>>|
>>|
>>
>>
>>So dimension are not the one i want (500 * 400) and figure is the half
>>of the one i want to display....
>>
>>Maybe there is a layout problem, a parent configuration missing... i
>>don't know. I tried to change color of figure but code failed (i don't
>>know how to change color...).
>>
>>If someone can tell me what is wrong...
>>
>>thanks !
>
>
>
|
|
|
Goto Forum:
Current Time: Wed Dec 04 03:14:30 GMT 2024
Powered by FUDForum. Page generated in 0.07187 seconds
|