Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Grid in containers for 3.0
Grid in containers for 3.0 [message #155856] Wed, 27 October 2004 07:13 Go to next message
Stefan Junsved is currently offline Stefan JunsvedFriend
Messages: 56
Registered: July 2009
Member
Hi.

I am desperately trying to make snap to grid work in containers, and
containers in these containers, and so on...
My intention is to make a document designer where you can drag and drop
texts, images, lines, boxes etc, etc,
from the palette. I have some properties on the document saying what size
the top, bottom, left, and right margins
should be. My bottom figure in the editor is only used as a background, gray
in color. The first child figure of the
bottom figure is representing the blank sheet (A4 for now), and I call it
the 'sheetFigure'. This figure has a content
figure with the size of the 'sheetFigure' figure minus the margins. It is in
this figure I want to have my first grid !!
If I put a box in that figure I want that box to have its own grid, and so
on.

I have turned the logic example inside-out, and I still don't understand how
to put the grid into child containers of
the bottom FreeformGraphicalRootEditPart which is the root edit part of my
ScrollingGraphicalViewer. The logic
example puts the grid in the bottom figure belonging to the
LogicDiagramEditPart. That class implements the getAdapter
method from the org.eclipse.core.runtime.IAdaptable interface. I have done
the same in my 'SheetEditPart', but I don't
even get a call to that method. Now I feel like I have run out of options.

Thanks in advance!

/Stefan
Re: Grid in containers for 3.0 [message #155873 is a reply to message #155856] Wed, 27 October 2004 14:12 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: eostroukhov.hotmail.com

I did it this way:
1. Make the figures you use for your container layered (that is, inherit
LayeredPane).
2. Make them using local coordinates (override useLocalCoordinates to return
true).
3. Add two layers - one for grid and one for content:
public ContainerFigure() {
add(new GridLayer(), LayerConstants.GRID_LAYER);
add(new MainLayer(), LayerConstants.PRIMARY_LAYER);
}

And that should work - if I hadn't forgotten anything...

Best regards,
Eugene


"Stefan Junsved" <stefan.junsved@comactivity.net> wrote in message
news:clnhev$ce8$1@eclipse.org...
> Hi.
>
> I am desperately trying to make snap to grid work in containers, and
> containers in these containers, and so on...
> My intention is to make a document designer where you can drag and drop
> texts, images, lines, boxes etc, etc,
> from the palette. I have some properties on the document saying what size
> the top, bottom, left, and right margins
> should be. My bottom figure in the editor is only used as a background,
gray
> in color. The first child figure of the
> bottom figure is representing the blank sheet (A4 for now), and I call it
> the 'sheetFigure'. This figure has a content
> figure with the size of the 'sheetFigure' figure minus the margins. It is
in
> this figure I want to have my first grid !!
> If I put a box in that figure I want that box to have its own grid, and so
> on.
>
> I have turned the logic example inside-out, and I still don't understand
how
> to put the grid into child containers of
> the bottom FreeformGraphicalRootEditPart which is the root edit part of my
> ScrollingGraphicalViewer. The logic
> example puts the grid in the bottom figure belonging to the
> LogicDiagramEditPart. That class implements the getAdapter
> method from the org.eclipse.core.runtime.IAdaptable interface. I have done
> the same in my 'SheetEditPart', but I don't
> even get a call to that method. Now I feel like I have run out of options.
>
> Thanks in advance!
>
> /Stefan
>
>
Re: Grid in containers for 3.0 [message #155987 is a reply to message #155856] Thu, 28 October 2004 11:47 Go to previous messageGo to next message
Stefan Junsved is currently offline Stefan JunsvedFriend
Messages: 56
Registered: July 2009
Member
I've finally had a break through. I missed implementing the 'LayerConstants'
interface in the edit parts
that are supposed to have a grid. It works now !
Now I have another problem. I can't get the grid to become visible...??!! I
set the appropriate properties
in the viewer according to the logic example,
getGraphicalViewer().setProperty(SnapToGrid.PROPERTY_GRID_VI SIBLE,
new Boolean(true));
getGraphicalViewer().setProperty(SnapToGrid.PROPERTY_GRID_EN ABLED,
new Boolean(true));
and when I debug my code I can see that those properties are actually set to
true. Still , I can't see any grid. I have
also installed the 'SnapFeedbackPolicy' on the edit parts in question, and
that works just fine.

Anyone?

/Stefan

"Stefan Junsved" <stefan.junsved@comactivity.net> wrote in message
news:clnhev$ce8$1@eclipse.org...
> Hi.
>
> I am desperately trying to make snap to grid work in containers, and
> containers in these containers, and so on...
> My intention is to make a document designer where you can drag and drop
> texts, images, lines, boxes etc, etc,
> from the palette. I have some properties on the document saying what size
> the top, bottom, left, and right margins
> should be. My bottom figure in the editor is only used as a background,
> gray in color. The first child figure of the
> bottom figure is representing the blank sheet (A4 for now), and I call it
> the 'sheetFigure'. This figure has a content
> figure with the size of the 'sheetFigure' figure minus the margins. It is
> in this figure I want to have my first grid !!
> If I put a box in that figure I want that box to have its own grid, and so
> on.
>
> I have turned the logic example inside-out, and I still don't understand
> how to put the grid into child containers of
> the bottom FreeformGraphicalRootEditPart which is the root edit part of my
> ScrollingGraphicalViewer. The logic
> example puts the grid in the bottom figure belonging to the
> LogicDiagramEditPart. That class implements the getAdapter
> method from the org.eclipse.core.runtime.IAdaptable interface. I have done
> the same in my 'SheetEditPart', but I don't
> even get a call to that method. Now I feel like I have run out of options.
>
> Thanks in advance!
>
> /Stefan
>
Re: Grid in containers for 3.0 [message #156003 is a reply to message #155873] Thu, 28 October 2004 14:18 Go to previous messageGo to next message
Stefan Junsved is currently offline Stefan JunsvedFriend
Messages: 56
Registered: July 2009
Member
Thanks Eugene!!
This really helped me. If you could bare another question from me, I'd be
more than greatful.

I use a pretty fine grid, 2x2 pixels, and when I add edit parts to that
container, the grid is drawn
above them. I have laborated with the setOpaque() method both on the edit
part and on the grid layer
itself but without any success, and it seems as if I have run out of options
again.

Thanks in advance.

/Stefan

"Eugene Ostroukhov" <eostroukhov@hotmail.com> wrote in message
news:cloa0i$7b7$1@eclipse.org...
>I did it this way:
> 1. Make the figures you use for your container layered (that is, inherit
> LayeredPane).
> 2. Make them using local coordinates (override useLocalCoordinates to
> return
> true).
> 3. Add two layers - one for grid and one for content:
> public ContainerFigure() {
> add(new GridLayer(), LayerConstants.GRID_LAYER);
> add(new MainLayer(), LayerConstants.PRIMARY_LAYER);
> }
>
> And that should work - if I hadn't forgotten anything...
>
> Best regards,
> Eugene
>
>
> "Stefan Junsved" <stefan.junsved@comactivity.net> wrote in message
> news:clnhev$ce8$1@eclipse.org...
>> Hi.
>>
>> I am desperately trying to make snap to grid work in containers, and
>> containers in these containers, and so on...
>> My intention is to make a document designer where you can drag and drop
>> texts, images, lines, boxes etc, etc,
>> from the palette. I have some properties on the document saying what size
>> the top, bottom, left, and right margins
>> should be. My bottom figure in the editor is only used as a background,
> gray
>> in color. The first child figure of the
>> bottom figure is representing the blank sheet (A4 for now), and I call it
>> the 'sheetFigure'. This figure has a content
>> figure with the size of the 'sheetFigure' figure minus the margins. It is
> in
>> this figure I want to have my first grid !!
>> If I put a box in that figure I want that box to have its own grid, and
>> so
>> on.
>>
>> I have turned the logic example inside-out, and I still don't understand
> how
>> to put the grid into child containers of
>> the bottom FreeformGraphicalRootEditPart which is the root edit part of
>> my
>> ScrollingGraphicalViewer. The logic
>> example puts the grid in the bottom figure belonging to the
>> LogicDiagramEditPart. That class implements the getAdapter
>> method from the org.eclipse.core.runtime.IAdaptable interface. I have
>> done
>> the same in my 'SheetEditPart', but I don't
>> even get a call to that method. Now I feel like I have run out of
>> options.
>>
>> Thanks in advance!
>>
>> /Stefan
>>
>>
>
>
Re: Grid in containers for 3.0 [message #156064 is a reply to message #156003] Fri, 29 October 2004 06:04 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: eostroukhov.hotmail.com

Check that the grid layer is below the content layer (see my example).
I forgot to mention that you should override the getContentPane method in
your container edit part like:
public IFigure getContentPane() {
return ((LayeredPane)
getFigure()).getLayer(LayerConstants.PRIMARY_LAYER);
}




"Stefan Junsved" <stefan.junsved@comactivity.net> wrote in message
news:clqv3g$643$1@eclipse.org...
> Thanks Eugene!!
> This really helped me. If you could bare another question from me, I'd be
> more than greatful.
>
> I use a pretty fine grid, 2x2 pixels, and when I add edit parts to that
> container, the grid is drawn
> above them. I have laborated with the setOpaque() method both on the edit
> part and on the grid layer
> itself but without any success, and it seems as if I have run out of
options
> again.
>
> Thanks in advance.
>
> /Stefan
>
> "Eugene Ostroukhov" <eostroukhov@hotmail.com> wrote in message
> news:cloa0i$7b7$1@eclipse.org...
> >I did it this way:
> > 1. Make the figures you use for your container layered (that is, inherit
> > LayeredPane).
> > 2. Make them using local coordinates (override useLocalCoordinates to
> > return
> > true).
> > 3. Add two layers - one for grid and one for content:
> > public ContainerFigure() {
> > add(new GridLayer(), LayerConstants.GRID_LAYER);
> > add(new MainLayer(), LayerConstants.PRIMARY_LAYER);
> > }
> >
> > And that should work - if I hadn't forgotten anything...
> >
> > Best regards,
> > Eugene
> >
> >
> > "Stefan Junsved" <stefan.junsved@comactivity.net> wrote in message
> > news:clnhev$ce8$1@eclipse.org...
> >> Hi.
> >>
> >> I am desperately trying to make snap to grid work in containers, and
> >> containers in these containers, and so on...
> >> My intention is to make a document designer where you can drag and drop
> >> texts, images, lines, boxes etc, etc,
> >> from the palette. I have some properties on the document saying what
size
> >> the top, bottom, left, and right margins
> >> should be. My bottom figure in the editor is only used as a background,
> > gray
> >> in color. The first child figure of the
> >> bottom figure is representing the blank sheet (A4 for now), and I call
it
> >> the 'sheetFigure'. This figure has a content
> >> figure with the size of the 'sheetFigure' figure minus the margins. It
is
> > in
> >> this figure I want to have my first grid !!
> >> If I put a box in that figure I want that box to have its own grid, and
> >> so
> >> on.
> >>
> >> I have turned the logic example inside-out, and I still don't
understand
> > how
> >> to put the grid into child containers of
> >> the bottom FreeformGraphicalRootEditPart which is the root edit part of
> >> my
> >> ScrollingGraphicalViewer. The logic
> >> example puts the grid in the bottom figure belonging to the
> >> LogicDiagramEditPart. That class implements the getAdapter
> >> method from the org.eclipse.core.runtime.IAdaptable interface. I have
> >> done
> >> the same in my 'SheetEditPart', but I don't
> >> even get a call to that method. Now I feel like I have run out of
> >> options.
> >>
> >> Thanks in advance!
> >>
> >> /Stefan
> >>
> >>
> >
> >
>
>
Re: Grid in containers for 3.0 [message #156419 is a reply to message #156064] Mon, 01 November 2004 11:41 Go to previous message
Stefan Junsved is currently offline Stefan JunsvedFriend
Messages: 56
Registered: July 2009
Member
And that's exactly what I did, and it works just fine :-) !!!
Again, thank you, Eugene.

/Stefan

"Eugene Ostroukhov" <eostroukhov@hotmail.com> wrote in message
news:clsmgn$ab$1@eclipse.org...
> Check that the grid layer is below the content layer (see my example).
> I forgot to mention that you should override the getContentPane method in
> your container edit part like:
> public IFigure getContentPane() {
> return ((LayeredPane)
> getFigure()).getLayer(LayerConstants.PRIMARY_LAYER);
> }
>
>
>
>
> "Stefan Junsved" <stefan.junsved@comactivity.net> wrote in message
> news:clqv3g$643$1@eclipse.org...
>> Thanks Eugene!!
>> This really helped me. If you could bare another question from me, I'd be
>> more than greatful.
>>
>> I use a pretty fine grid, 2x2 pixels, and when I add edit parts to that
>> container, the grid is drawn
>> above them. I have laborated with the setOpaque() method both on the edit
>> part and on the grid layer
>> itself but without any success, and it seems as if I have run out of
> options
>> again.
>>
>> Thanks in advance.
>>
>> /Stefan
>>
>> "Eugene Ostroukhov" <eostroukhov@hotmail.com> wrote in message
>> news:cloa0i$7b7$1@eclipse.org...
>> >I did it this way:
>> > 1. Make the figures you use for your container layered (that is,
>> > inherit
>> > LayeredPane).
>> > 2. Make them using local coordinates (override useLocalCoordinates to
>> > return
>> > true).
>> > 3. Add two layers - one for grid and one for content:
>> > public ContainerFigure() {
>> > add(new GridLayer(), LayerConstants.GRID_LAYER);
>> > add(new MainLayer(), LayerConstants.PRIMARY_LAYER);
>> > }
>> >
>> > And that should work - if I hadn't forgotten anything...
>> >
>> > Best regards,
>> > Eugene
>> >
>> >
>> > "Stefan Junsved" <stefan.junsved@comactivity.net> wrote in message
>> > news:clnhev$ce8$1@eclipse.org...
>> >> Hi.
>> >>
>> >> I am desperately trying to make snap to grid work in containers, and
>> >> containers in these containers, and so on...
>> >> My intention is to make a document designer where you can drag and
>> >> drop
>> >> texts, images, lines, boxes etc, etc,
>> >> from the palette. I have some properties on the document saying what
> size
>> >> the top, bottom, left, and right margins
>> >> should be. My bottom figure in the editor is only used as a
>> >> background,
>> > gray
>> >> in color. The first child figure of the
>> >> bottom figure is representing the blank sheet (A4 for now), and I call
> it
>> >> the 'sheetFigure'. This figure has a content
>> >> figure with the size of the 'sheetFigure' figure minus the margins. It
> is
>> > in
>> >> this figure I want to have my first grid !!
>> >> If I put a box in that figure I want that box to have its own grid,
>> >> and
>> >> so
>> >> on.
>> >>
>> >> I have turned the logic example inside-out, and I still don't
> understand
>> > how
>> >> to put the grid into child containers of
>> >> the bottom FreeformGraphicalRootEditPart which is the root edit part
>> >> of
>> >> my
>> >> ScrollingGraphicalViewer. The logic
>> >> example puts the grid in the bottom figure belonging to the
>> >> LogicDiagramEditPart. That class implements the getAdapter
>> >> method from the org.eclipse.core.runtime.IAdaptable interface. I have
>> >> done
>> >> the same in my 'SheetEditPart', but I don't
>> >> even get a call to that method. Now I feel like I have run out of
>> >> options.
>> >>
>> >> Thanks in advance!
>> >>
>> >> /Stefan
>> >>
>> >>
>> >
>> >
>>
>>
>
>
Previous Topic:popup property dialog for each component?
Next Topic:short question about LocationPropertySource in logic example
Goto Forum:
  


Current Time: Thu Apr 25 02:13:36 GMT 2024

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

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

Back to the top