Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: ef14640691a2c583d572de9265a476e5f404bafc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*******************************************************************************
 * Copyright (c) 2012 CEA LIST.
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *******************************************************************************/
package org.eclipse.papyrus.uml.diagram.timing.custom.layouts;

import java.util.List;

import org.eclipse.draw2d.AbstractLayout;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.draw2d.geometry.Rectangle;

public class TimeRulerLayout extends AbstractLayout {

	public void layout(final IFigure container) {
		// reset the layout so that the BorderItemsAwareFreeFormLayer fills its parent FreeformViewport
		// if (!(container.getParent().getLayoutManager() instanceof FillLayout)) {
		// container.getParent().setLayoutManager(new FillLayout());
		// }

		// The grand-parent is a FreeformViewport, which lets its child expand outside of its clientArea, and
		// constantly resets the bounds (in org.eclipse.draw2d.FreeformViewport#readjustScrollBars)
		// So, layout based on the grand-parent's clientArea.
		final Rectangle clientArea = container.getParent().getClientArea();
		@SuppressWarnings("unchecked")
		final List<IFigure> children = container.getChildren();
		for(int i = 0; i < children.size(); i++) {
			final IFigure child = children.get(i);
			child.setBounds(clientArea);
		}

	}

	@Override
	protected Dimension calculatePreferredSize(final IFigure container, final int wHint, final int hHint) {
		return new Dimension(-1, -1);
	}

}

Back to the top