Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Scrolling a graphical view
Scrolling a graphical view [message #229169] Tue, 16 January 2007 17:30 Go to next message
Nacef is currently offline NacefFriend
Messages: 29
Registered: July 2009
Junior Member
Hi all,

I'm developing a diagram viewer using Draw2D (I'm intending to migrate later to GEF).

So actually I'm parsing an XML file and drawing corresponding figure in a graphical view. But the problem is that the graphics exeeds the bounds of the window so I want to make the view scrollable. So I have added a scrollpane to my view and this is the code :

public void createPartControl(Composite parent) {
Canvas canvas = new Canvas(parent, SWT.NONE);
canvas.setBackground(ColorConstants.white);
LightweightSystem lws = new LightweightSystem(canvas);

IFigure panel = new Figure();
lws.setContents(panel);

ScrollPane scrollpane = new ScrollPane();
scrollpane.setBounds(new Rectangle(0,0,800,600));
scrollpane.getViewport().setBorder(new LineBorder());
scrollpane.setBorder(new LineBorder());

final Figure simulationFigure = new Figure();
simulationFigure.setBorder(new LineBorder());

simulationFigure.setLayoutManager(new FreeFormLayout());
scrollpane.setContents(simulationFigure);

// Adding here all the figures

panel.add(simulationFigure);

}

The problem is that I get a blank white view.

Please help. Thanks to all

Nacef
Re: Scrolling a graphical view [message #229188 is a reply to message #229169] Tue, 16 January 2007 20:26 Go to previous messageGo to next message
Tomáš Studva is currently offline Tomáš StudvaFriend
Messages: 9
Registered: July 2009
Junior Member
Hi,
you have there mistake.

// ok create LWS
LightweightSystem lws = new LightweightSystem(canvas);
// this is not needed
IFigure panel = new Figure();
lws.setContents(panel);
// ok create scrollpane, !!! but add it as child to panel, or set is as content to LWS
ScrollPane scrollpane = new ScrollPane();
scrollpane.setBounds(new Rectangle(0,0,800,600));
scrollpane.getViewport().setBorder(new LineBorder());
scrollpane.setBorder(new LineBorder());

Later, when you integrate GEF, you should use ScrollingGraphicalViewer.

Tomas
Re: Scrolling a graphical view [message #229228 is a reply to message #229188] Wed, 17 January 2007 08:52 Go to previous messageGo to next message
Nacef is currently offline NacefFriend
Messages: 29
Registered: July 2009
Junior Member
Hi Tomas,

thank you for answering. I have done the corrections.

But I think that I am having a problem with the FreeFormLayout.

I have tried to change it to FlowLayout, I get the scrollbars but all the figures are drawn one under the other.

Which Layout do I have to use to have the scrollbars appear correctly.

Thanks

Nacef
Re: Scrolling a graphical view [message #230435 is a reply to message #229228] Mon, 12 February 2007 10:39 Go to previous message
Nacef is currently offline NacefFriend
Messages: 29
Registered: July 2009
Junior Member
Hi Tomas,

I have corrected my code and now I have scrollbars appearing on my window.
But when scrolling, it is not enough to go to the end of the figure. I can
only scroll few pixels while my figure is larger than that. Have anyone an
idea about that. This is the code I am using :

ScrollPane scrollPane = new ScrollPane();
scrollPane.setLayoutManager(new ScrollPaneLayout());
Figure simulationFigure = new Figure();

simulationFigure.add(...);
simulationFigure.add(...);
simulationFigure.add(...);

scrollPane.setContents(simulationFigure);
lws.setContents(scrollPane);
Previous Topic:Need to pause at view port edge in order to auto scroll
Next Topic:Loop Connections
Goto Forum:
  


Current Time: Tue Oct 19 10:13:00 GMT 2021

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

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

Back to the top