ScrollPane and EditParts [message #898435] |
Thu, 26 July 2012 11:39 |
tom maxx Messages: 20 Registered: July 2012 |
Junior Member |
|
|
I want to use a ScrollPane to create a scrollable figure (with subfigures). So I created a ScrollModel which contains the bounds of the ScrollPane and a SrcollModel:
public class ScrollEditPart
...
protected IFigure createFigure()
{
ScrollPane scrollPane = new ScrollPane();
scrollPane.setBorder(new LineBorder());
// scrollPane.setBounds(new Rectangle(0,0, 250, 500));
return scrollPane;
}
...
@Override
protected List<?> getModelChildren()
{
return ((ScrollModel)getModel()).getChildren();
}
...
I have a ContentModel which describes the bounds of a rectangle. The figure of the rectangle is in the ContentEditPart:
public class ContentEditPart
...
protected IFigure createFigure()
{
RectangleFigure figure = new RectangleFigure();
figure.setOutline(false);
//figure.setBounds(new Rectangle(0,0, 500, 1250));
RectangleFigure rect1 = new RectangleFigure();
//rect1.setBounds(new Rectangle(50,50, 50, 650));
rect1.setBackgroundColor(ColorConstants.red);
figure.add(rect1);
return figure;
}
...
If I run my application, I see the rectangles. But I can't scroll them, because GEF creates the the figure via the createFigure-method in the Editpart and calls the add-method of the figure. But the ScrollPane has a setContents-method which has to be called.
The following example works. But I can't use it, because it doesn't fit in my model:
public class ScrollEditPart
...
protected IFigure createFigure()
{
RectangleFigure figure = new RectangleFigure();
figure.setOutline(false);
//figure.setBounds(new Rectangle(0,0, 500, 1250));
RectangleFigure rect1 = new RectangleFigure();
//rect1.setBounds(new Rectangle(50,50, 50, 650));
rect1.setBackgroundColor(ColorConstants.red);
figure.add(rect1);
ScrollPane scrollPane = new ScrollPane();
scrollPane.setBorder(new LineBorder());
// scrollPane.setBounds(new Rectangle(0,0, 250, 500));
scrollPane.setContents(figure);
// scrollPane.add(figure); // <- doesn't work
return scrollPane;
}
...
Can someone help me?
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02564 seconds