Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Maximize Graph Width to View Width(how to get bounds of rootEditPart or similar)
Maximize Graph Width to View Width [message #843659] Fri, 13 April 2012 08:46 Go to next message
Ludwig Moser is currently offline Ludwig MoserFriend
Messages: 365
Registered: July 2009
Senior Member
Hello!

i try to write a view which contains a graph (which should fit to 100% of width of the view -> if the view gets increased the graph shall increase its size too.

i tried to create an EditPart which uses this code
	@Override
	protected IFigure createFigure() {
		Figure figure = new FreeformLayer();
		figure.setBorder(new MarginBorder(3));
		figure.setLayoutManager(Utils.getLayout(1));
		contentPane = new Panel();
		figure.add(contentPane, new GridData(GridData.FILL_BOTH));
		contentPane.setLayoutManager(new XYLayout());
		return figure;
	}

	public IFigure getContentPane() {
		return contentPane;
	}


this does not resize as i expected it to do.

its also not possible to gain the width of the control itself (from the figure)
super.getParent().getViewer().getControl().getBounds();


UPDATE: i also tried:
	public Dimension getViewSize() {
		ScrollingGraphicalViewer viewer = (ScrollingGraphicalViewer) super.getParent().getViewer();
		return ((FigureCanvas)viewer.getControl()).getViewport().getSize();
	}


so... how can i get those dimensions i need?
thanks in advance!
lumo

[Updated on: Fri, 13 April 2012 09:11]

Report message to a moderator

Re: Maximize Graph Width to View Width [message #888812 is a reply to message #843659] Mon, 18 June 2012 16:58 Go to previous messageGo to next message
Jan Krakora is currently offline Jan KrakoraFriend
Messages: 477
Registered: December 2009
Location: Prague
Senior Member
If you put the graphical viewer into a ViewPart, and set the FillLayout on the view's root composite (the graphical viewer's control parent). Then the graphical viewer itself should be automatically resized upon view resizing.
Re: Maximize Graph Width to View Width [message #888862 is a reply to message #888812] Mon, 18 June 2012 18:21 Go to previous messageGo to next message
Ludwig Moser is currently offline Ludwig MoserFriend
Messages: 365
Registered: July 2009
Senior Member
Thats not The problem
It's to scale the graph inside to fill the full view
Re: Maximize Graph Width to View Width [message #888888 is a reply to message #888862] Mon, 18 June 2012 18:56 Go to previous message
Jan Krakora is currently offline Jan KrakoraFriend
Messages: 477
Registered: December 2009
Location: Prague
Senior Member
Then you can use the zoom manager if your root edit part is either instance of the ScalableRootEditPart or the ScalableFreeformRootEditPart:
ZoomManager zoomManager = (ZoomManager) EditPartViewer.getProperty(ZoomManager.class.toString());
zoomManager.setZoomAsText(ZoomManager.FIT_ALL);
Previous Topic:Labels on Figure not showing up
Next Topic:Best way to add Draw2d to a GraphicalEditorWithFlyoutPalette?
Goto Forum:
  


Current Time: Sat Nov 29 07:55:20 GMT 2014

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

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