Skip to main content



      Home
Home » Eclipse Projects » GEF » [Draw2d] Help with scrolling
[Draw2d] Help with scrolling [message #63061] Fri, 07 February 2003 08:00 Go to next message
Eclipse UserFriend
Originally posted by: scheglov_ke.nlmk.ru

I need to show set of draw2d figures, but they don't fit in screen, to I
need scrolling. As I understand, I should use ScrollPane for this, but I
can not make it work. I code below, when I use layout:
panel.setLayoutManager(new FlowLayout(false));
all works. But in my situation I don't want use layout, but specify
location directly. But when I comment line with FlowLayout, scrolling
don't work. :-(
And second question: how to force ScrollPane to scroll, so that some
figure inside becomes visible?

package ru.nlmk.eclipse.plugins.profiler.views.threadCallGraph.test;
import org.eclipse.draw2d.*;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
/**
* @author Kosta
*/
public class TestScroll {
public static void main(String args[]) {
Display display = Display.getDefault();
Shell shell = new Shell(SWT.SHELL_TRIM | SWT.NO_BACKGROUND);
shell.open();
shell.setText("Draw2d Hello World");
LightweightSystem lws = new LightweightSystem(shell);
//
Panel root = new Panel();
root.setLayoutManager(new StackLayout());
lws.setContents(root);
//
ScrollPane scrollPane = new ScrollPane();
root.add(scrollPane);
Panel panel = new Panel();
panel.setBackgroundColor(ColorConstants.listBackground);
scrollPane.setView(panel);
panel.setLayoutManager(new FlowLayout(false));
//
for (int i = 0; i < 100; i++) {
int x = (int) (1000 * Math.random());
int y = (int) (1000 * Math.random());
Label label = new Label("Label_" + i);
panel.add(label);
label.setLocation(new Point(x, y));
}
//
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
}
}
Re: [Draw2d] Help with scrolling [message #63120 is a reply to message #63061] Fri, 07 February 2003 10:32 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

"Konstantin Scheglov" <scheglov_ke@nlmk.ru> wrote in message
news:b20alf$ili$1@rogue.oti.com...
> I need to show set of draw2d figures, but they don't fit in screen, to I
> need scrolling. As I understand, I should use ScrollPane for this, but I
> can not make it work. I code below, when I use layout:
> panel.setLayoutManager(new FlowLayout(false));
> all works. But in my situation I don't want use layout, but specify
> location directly.

The Viewport relies on the Layout to tell it its preferred size. It is part
of our "one pass" layout strategy that allows you to move 100 objects, but
only update the Viewport and scrollpane once, and only paint once.

If you want to specify location directly, use the XYLayoutManager on the
parent. Instead of calling child.setBounds(rect), call
parent.setLayoutConstraint(child, rect)

But when I comment line with FlowLayout, scrolling
> don't work. :-(
> And second question: how to force ScrollPane to scroll, so that some
> figure inside becomes visible?
>
> package ru.nlmk.eclipse.plugins.profiler.views.threadCallGraph.test;
> import org.eclipse.draw2d.*;
> import org.eclipse.draw2d.geometry.Point;
> import org.eclipse.swt.SWT;
> import org.eclipse.swt.widgets.Display;
> import org.eclipse.swt.widgets.Shell;
> /**
> * @author Kosta
> */
> public class TestScroll {
> public static void main(String args[]) {
> Display display = Display.getDefault();
> Shell shell = new Shell(SWT.SHELL_TRIM | SWT.NO_BACKGROUND);
> shell.open();
> shell.setText("Draw2d Hello World");
> LightweightSystem lws = new LightweightSystem(shell);
> //
> Panel root = new Panel();
> root.setLayoutManager(new StackLayout());
> lws.setContents(root);
> //
> ScrollPane scrollPane = new ScrollPane();
> root.add(scrollPane);
> Panel panel = new Panel();
> panel.setBackgroundColor(ColorConstants.listBackground);
> scrollPane.setView(panel);
> panel.setLayoutManager(new FlowLayout(false));
> //
> for (int i = 0; i < 100; i++) {
> int x = (int) (1000 * Math.random());
> int y = (int) (1000 * Math.random());
> Label label = new Label("Label_" + i);
> panel.add(label);
> label.setLocation(new Point(x, y));
> }
> //
> while (!shell.isDisposed()) {
> if (!display.readAndDispatch())
> display.sleep();
> }
> }
> }
>
>
Re: [Draw2d] Help with scrolling [message #63140 is a reply to message #63061] Fri, 07 February 2003 10:32 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

Also, you can use FigureCanvas for native scrolling. See the examples in
the example project on CVS server
Re: [Draw2d] Help with scrolling [message #63463 is a reply to message #63140] Sat, 08 February 2003 05:33 Go to previous message
Eclipse UserFriend
Originally posted by: kosta.empproject.com

Randy Hudson wrote:

> Also, you can use FigureCanvas for native scrolling. See the examples in
> the example project on CVS server
Thank you, with FigureCanvas and XYLayout scrolling is much faster.

--
SY, Kosta.
Previous Topic:Logic Editor Example IBM Copyright Statements
Next Topic:ActionBarContributor help (eclipse 2.1 M5 & GEF 2/4/2003)
Goto Forum:
  


Current Time: Sun Jun 08 17:33:26 EDT 2025

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

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

Back to the top