Java Code Examples for org.eclipse.draw2d.geometry.Dimension#expand()

The following examples show how to use org.eclipse.draw2d.geometry.Dimension#expand() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CursorTimingsLayer.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
public void showTimingsFor(CursorFigure cursorFigure, MouseEvent me) {

		removeAll();

		// get all cursors except the highlighted one
		final List<CursorFigure> cursors = getAllCursors();
		cursors.remove(cursorFigure);

		// sort cursors by distance to highlighted one
		Collections.sort(cursors,
				(o1, o2) -> (int) (Math.abs(cursorFigure.getEventTime() - o1.getEventTime()) - Math.abs(cursorFigure.getEventTime() - o2.getEventTime())));

		final Dimension distance = new Dimension(20, me.y);
		for (final CursorFigure cursor : cursors) {
			add(new CursorConnection(cursorFigure, cursor, distance));

			distance.expand(20, 30);
		}

		fConnectionsLocation = me.getLocation();
		setVisible(true);
	}
 
Example 2
Source File: MultipleShapesHorizontalMoveTool.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
/**
 * creates the command to move the shapes left or right.
 */
protected Command getCommand() {
	if (_container == null) {
		return null;
	}
	CompoundCommand command = new CompoundCommand("Multiple Shape Move");
	TransactionalEditingDomain editingDomain = _container.getEditingDomain();

	Point moveDelta  = ((ChangeBoundsRequest) getSourceRequest()).getMoveDelta().getCopy();
	Dimension spSizeDelta = new Dimension(moveDelta.x, moveDelta.y);
	ZoomManager zoomManager = ((DiagramRootEditPart) 
			getCurrentViewer().getRootEditPart()).getZoomManager();
	spSizeDelta.scale(1/zoomManager.getZoom());

	command.add(_container.getCommand(getSourceRequest()));


	for (IGraphicalEditPart sp : _subProcesses) {
		Dimension spDim = sp.getFigure().getBounds().getSize().getCopy();
		spDim.expand(spSizeDelta);
		SetBoundsCommand setBounds = 
			new SetBoundsCommand(editingDomain,"MultipleShape Move", sp, spDim);
		command.add(new ICommandProxy(setBounds));
	}
	return command;
}
 
Example 3
Source File: MultipleShapesVerticalMoveTool.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
/**
 * creates the command to move the shapes left or right.
 */
protected Command getCommand() {
	if (_container == null) {
		return null;
	}
	CompoundCommand command = new CompoundCommand("Multiple Shape Move");
	TransactionalEditingDomain editingDomain = _container.getEditingDomain();

	Point moveDelta  = ((ChangeBoundsRequest) getSourceRequest()).getMoveDelta().getCopy();
	Dimension spSizeDelta = new Dimension(moveDelta.x, moveDelta.y);
	ZoomManager zoomManager = ((DiagramRootEditPart) 
			getCurrentViewer().getRootEditPart()).getZoomManager();
	spSizeDelta.scale(1/zoomManager.getZoom());
	command.add(_container.getCommand(getSourceRequest()));


	for (IGraphicalEditPart sp : _subProcesses) {
		Dimension spDim = sp.getFigure().getBounds().getSize().getCopy();
		spDim.expand(spSizeDelta);
		SetBoundsCommand setBounds = 
			new SetBoundsCommand(editingDomain,"MultipleShape Move", sp, spDim);
		command.add(new ICommandProxy(setBounds));
	}
	return command;
}
 
Example 4
Source File: TankFigure.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected Dimension calculatePreferredSize(IFigure container, int w,
		int h) {
	Insets insets = container.getInsets();
	Dimension d = new Dimension(64, 4*64);
	d.expand(insets.getWidth(), insets.getHeight());
	return d;
}
 
Example 5
Source File: GaugeFigure.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected Dimension calculatePreferredSize(IFigure container, int w,
		int h) {
	Insets insets = container.getInsets();
	Dimension d = new Dimension(256, 256);
	d.expand(insets.getWidth(), insets.getHeight());
	return d;
}
 
Example 6
Source File: ScaledSliderFigure.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected Dimension calculatePreferredSize(IFigure container, int w,
		int h) {
	Insets insets = container.getInsets();
	Dimension d = new Dimension(64, 4*64);
	d.expand(insets.getWidth(), insets.getHeight());
	return d;
}
 
Example 7
Source File: ThermometerFigure.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected Dimension calculatePreferredSize(IFigure container, int w,
		int h) {
	Insets insets = container.getInsets();
	Dimension d = new Dimension(64, 4*64);
	d.expand(insets.getWidth(), insets.getHeight());
	return d;
}
 
Example 8
Source File: MeterFigure.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected Dimension calculatePreferredSize(IFigure container, int w,
		int h) {
	Insets insets = container.getInsets();
	Dimension d = new Dimension(256, 256);
	d.expand(insets.getWidth(), insets.getHeight());
	return d;
}
 
Example 9
Source File: ProgressBarFigure.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected Dimension calculatePreferredSize(IFigure container, int w,
		int h) {
	Insets insets = container.getInsets();
	Dimension d = new Dimension(64, 4*64);
	d.expand(insets.getWidth(), insets.getHeight());
	return d;
}
 
Example 10
Source File: KnobFigure.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected Dimension calculatePreferredSize(IFigure container, int w,
		int h) {
	Insets insets = container.getInsets();
	Dimension d = new Dimension(256, 256);
	d.expand(insets.getWidth(), insets.getHeight());
	return d;
}
 
Example 11
Source File: SetPreferredSizeRequest.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
public SetPreferredSizeRequest(IGraphicalEditPart host) {
	super(RequestConstants.REQ_RESIZE);
	setEditParts(host);
	double zoom = ((DiagramRootEditPart) host.getRoot()).getZoomManager().getZoom();
	IFigure figure = host.getFigure();
	Dimension prefSize = figure.getLayoutManager().getPreferredSize(figure, -1, -1).getCopy().scale(zoom);
	prefSize.expand(8,8);
	Dimension currentSize = figure.getSize().scale(zoom);
	Dimension newDimension = new Dimension(prefSize.width - currentSize.width,
			prefSize.height - currentSize.height);
	setSizeDelta(newDimension);
}
 
Example 12
Source File: ComponentMeterFigure.java    From arx with Apache License 2.0 5 votes vote down vote up
@Override
protected Dimension calculatePreferredSize(IFigure container, int w,
        int h) {
    Insets insets = container.getInsets();
    Dimension d = new Dimension(container.getClientArea().width, container.getClientArea().height);
    d.expand(insets.getWidth(), insets.getHeight());
    return d;
}
 
Example 13
Source File: TableLayout.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
protected Dimension calculateMinimumSize( IFigure figure, int wHint,
		int hHint )
{
	isCalculating = true;
	layout( figure, true );
	isCalculating = false;
	IFigure table = figure.getParent( ).getParent( ).getParent( );
	int widthExpand = table.getInsets( ).getWidth( );

	int width = 0;
	int size = data.columnWidths.length;
	for ( int i = 0; i < size; i++ )
	{
		width = width + data.columnWidths[i].trueMinColumnWidth;
	}

	String ww = getOwner( ).getDefinedWidth( );

	if ( ww != null
			&& ww.length( ) > 0
			&& !ww.endsWith( DesignChoiceConstants.UNITS_PERCENTAGE ) )
	{
		try
		{
			int dwidth = Integer.parseInt( ww );

			if ( dwidth > width + widthExpand )
			{
				width = dwidth - widthExpand;
			}
		}
		catch ( Exception e )
		{
			// ignore;
		}
	}

	int height = 0;
	size = data.rowHeights.length;
	for ( int i = 0; i < size; i++ )
	{
		height = height + data.rowHeights[i].height;
	}
	Dimension dim = new Dimension( width, height );

	return dim.expand( table.getInsets( ).getWidth( ), table.getInsets( )
			.getHeight( ) );
}