Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Ruler on an EditPartViewer
Ruler on an EditPartViewer [message #3925] Thu, 23 May 2002 16:13 Go to next message
Eclipse UserFriend
Originally posted by: chyliko.dev.disnet.cz

Hello everybody,

I'm currently working on an application that uses an EditPartViewer
(with overview) to display a grid-like structured data and I need the viewer
to have a horizontal ruler -- i.e. a top bar that displays the units,
scrolls horizontally with the viewer, but stays on it's place (visible) when
the view is scrolled vertically.

Is there any direct support in GEF to attain this? Or could you point me
to some examples/applications that may be helpful when finding out how to do
such thing?

I'd appreciate any response, thanks in advance.

Ondrej
Re: Ruler on an EditPartViewer [message #3935 is a reply to message #3925] Thu, 23 May 2002 18:41 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.ibm.com

There is no support for this yet. Would you like to contribute this?

One way to implement this might be the way Swing did it. The ScrollPane and
its layout could place the 2 rulers along with the 2 scrollbars. But, we
are now using the native scrollbars from SWT with a Viewport placed directly
in the lightweight system's Canvas, so a ScrollPane figure is not needed or
desired.

Viewport figure will soon support zoom as well, which the ruler would also
need to know to display the "ticks" appropriately. Maybe a ruler could be
implemented as a Border on the Viewport (a feature Swing doesn't handle
properly :-P)

The hardest part will be making the native scrolling work properly. Native
scrolling copies a rectangular region from one place to another, resulting
in an optimized paint region on only the new region that is exposed.

"Ondrej Chylik" <chyliko@dev.disnet.cz> wrote in message
news:acj3me$gto$1@rogue.oti.com...
> Hello everybody,
>
> I'm currently working on an application that uses an EditPartViewer
> (with overview) to display a grid-like structured data and I need the
viewer
> to have a horizontal ruler -- i.e. a top bar that displays the units,
> scrolls horizontally with the viewer, but stays on it's place (visible)
when
> the view is scrolled vertically.
>
> Is there any direct support in GEF to attain this? Or could you point
me
> to some examples/applications that may be helpful when finding out how to
do
> such thing?
>
> I'd appreciate any response, thanks in advance.
>
> Ondrej
>
>
Re: Ruler on an EditPartViewer [message #3976 is a reply to message #3935] Fri, 24 May 2002 13:28 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: chyliko.dev.disnet.cz

I tried the following thing to be able to set a ruler to a ScrollPane. It
was pretty simple and seems to be working.
I guess I may get started with this patch/extension. However, I hope
there'll be some built-in support for rulers, both horizontal and vertical,
in GEF soon.
I just wonder if I'm not missing something... or doing things a wrong way...

Here's my solution:

Extension of the ScrollPane figure:


import com.ibm.etools.draw2d.IFigure;
import com.ibm.etools.draw2d.ScrollPane;
import com.ibm.etools.draw2d.Viewport;

public class MyScrollPane extends ScrollPane {

private IFigure horizontalRulerPort = null;

public MyScrollPane() {
super();
setLayoutManager(new MyScrollPaneLayout());
}

public void setHorizontalRuler(IFigure ruler) {
Viewport rulerPort = new Viewport() {
protected void readjustScrollBars() {
/* Do nothing - the scroll bars are adjusted
* by the main viewport of the scrollpane
*/
}
};

rulerPort.setHorizontalRangeModel(getViewport().getHorizonta lRangeModel());
rulerPort.setContents(ruler);
add(rulerPort);
this.horizontalRulerPort = rulerPort;
}

public IFigure getHorizontalRulerPort() {
return horizontalRulerPort;
}
}

_____

Extension of ScrollPaneLayout (shortened):


import com.ibm.etools.draw2d.IFigure;
import com.ibm.etools.draw2d.ScrollPaneLayout;
import com.ibm.etools.draw2d.geometry.Rectangle;

public class MyScrollPaneLayout extends ScrollPaneLayout {

public void layout(IFigure parent) {
/* ...
* here's code copied from ScrollPaneLayout.layout(IFigure),
unchanged.
* following prepended to the last statement of the method:
*/

IFigure hRuler = ((MyScrollPane)
scrollpane).getHorizontalRulerPort();
if (hRuler != null) {
int hRulerHeight = hRuler.getPreferredSize().height;

Rectangle hRulerArea = viewportArea.getCopy();
hRulerArea.height = hRulerHeight;
hRuler.setBounds(hRulerArea);

viewportArea.y += hRulerHeight;
viewportArea.height -= hRulerHeight;
}

/* this is the last line of ScrollPaneLayout.layout(IFigure)
(unchanged) */
viewport.setBounds(viewportArea);
}
}


_____

Regards,
Ondrej
Re: Ruler on an EditPartViewer [message #3981 is a reply to message #3976] Fri, 24 May 2002 15:37 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.ibm.com

How will you be sure that the ruler width matches the Viewport's content's
width?
I would probably do this as a Figure which paints ticks based on the
RangeModel, and have the ruler just be the size of the viewport. I'm just
trying to imagine how Zoom will affect the ruler.

I like the idea of making it a figure though, because then you can hit-test
and interact with the ruler much easier.

"Ondrej Chylik" <chyliko@dev.disnet.cz> wrote in message
news:aclecp$gs2$1@rogue.oti.com...
> I tried the following thing to be able to set a ruler to a ScrollPane. It
> was pretty simple and seems to be working.
> I guess I may get started with this patch/extension. However, I hope
> there'll be some built-in support for rulers, both horizontal and
vertical,
> in GEF soon.
> I just wonder if I'm not missing something... or doing things a wrong
way...
>
> Here's my solution:
>
> Extension of the ScrollPane figure:
>
>
> import com.ibm.etools.draw2d.IFigure;
> import com.ibm.etools.draw2d.ScrollPane;
> import com.ibm.etools.draw2d.Viewport;
>
> public class MyScrollPane extends ScrollPane {
>
> private IFigure horizontalRulerPort = null;
>
> public MyScrollPane() {
> super();
> setLayoutManager(new MyScrollPaneLayout());
> }
>
> public void setHorizontalRuler(IFigure ruler) {
> Viewport rulerPort = new Viewport() {
> protected void readjustScrollBars() {
> /* Do nothing - the scroll bars are adjusted
> * by the main viewport of the scrollpane
> */
> }
> };
>
>
rulerPort.setHorizontalRangeModel(getViewport().getHorizonta lRangeModel());
> rulerPort.setContents(ruler);
> add(rulerPort);
> this.horizontalRulerPort = rulerPort;
> }
>
> public IFigure getHorizontalRulerPort() {
> return horizontalRulerPort;
> }
> }
>
> _____
>
> Extension of ScrollPaneLayout (shortened):
>
>
> import com.ibm.etools.draw2d.IFigure;
> import com.ibm.etools.draw2d.ScrollPaneLayout;
> import com.ibm.etools.draw2d.geometry.Rectangle;
>
> public class MyScrollPaneLayout extends ScrollPaneLayout {
>
> public void layout(IFigure parent) {
> /* ...
> * here's code copied from ScrollPaneLayout.layout(IFigure),
> unchanged.
> * following prepended to the last statement of the method:
> */
>
> IFigure hRuler = ((MyScrollPane)
> scrollpane).getHorizontalRulerPort();
> if (hRuler != null) {
> int hRulerHeight = hRuler.getPreferredSize().height;
>
> Rectangle hRulerArea = viewportArea.getCopy();
> hRulerArea.height = hRulerHeight;
> hRuler.setBounds(hRulerArea);
>
> viewportArea.y += hRulerHeight;
> viewportArea.height -= hRulerHeight;
> }
>
> /* this is the last line of ScrollPaneLayout.layout(IFigure)
> (unchanged) */
> viewport.setBounds(viewportArea);
> }
> }
>
>
> _____
>
> Regards,
> Ondrej
>
>
Re: Ruler on an EditPartViewer [message #3987 is a reply to message #3981] Fri, 24 May 2002 17:14 Go to previous message
Eclipse UserFriend
Originally posted by: chyliko.dev.disnet.cz

> How will you be sure that the ruler width matches the Viewport's content's
> width?

I added following to the MyScrollPaneLayout.layout method:

IFigure ruler = ((Viewport) hRuler).getContents();
IFigure view = viewport.getContents();
ruler.setPreferredSize(new Dimension(view.getPreferredSize().width,
hRulerHeight));

These lines seem to ensure that the ruler width and the view (the viewport's
content) width match.


> I would probably do this as a Figure which paints ticks based on the
> RangeModel, and have the ruler just be the size of the viewport.

That means that the ruler figure would have to know that it's inside a
Viewport, doesn't it? My solution above can use simply any figure to be the
ruler. Am I right or is there some issue (performance maybe) I can't see?


> I'm just trying to imagine how Zoom will affect the ruler.

I don't know anything about how the zoom support is intended to be done, but
if it's a feature of the Viewport figure, couldn't the ScrollPane simply
synchronize the "ZoomModel" of the viewports (the main and those for
rulers), the same way it synchronizes their RangeModels now?
Previous Topic:The current download of GEF is not ready for distribution
Next Topic:Is there a detailed documentation of GEF
Goto Forum:
  


Current Time: Sat Jul 27 12:48:27 GMT 2024

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

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

Back to the top