Java Code Examples for org.eclipse.draw2d.IFigure#setBounds()
The following examples show how to use
org.eclipse.draw2d.IFigure#setBounds() .
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: CellDragoicator.java From birt with Eclipse Public License 1.0 | 6 votes |
public void relocate( IFigure target ) { IFigure reference = getReferenceFigure( ); Rectangle targetBounds = new PrecisionRectangle( getReferenceBox( ).getResized( -1, -1 ) ); reference.translateToAbsolute( targetBounds ); target.translateToRelative( targetBounds ); targetBounds.resize( 1, 1 ); Dimension targetSize = getTargetSize( targetBounds.getSize( ) ); targetBounds.x += (int) ( targetBounds.width * relativeX ) - 1; targetBounds.y += (int) ( targetBounds.height * relativeY ); if (targetBounds.x < 0) { targetBounds.x = 0; } if (targetBounds.y < 0) { targetBounds.y = 0; } targetBounds.setSize( targetSize ); target.setBounds( targetBounds ); }
Example 2
Source File: ERDiagramLayoutEditPolicy.java From ermaster-b with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ @Override protected void showSizeOnDropFeedback(CreateRequest request) { Point p = new Point(request.getLocation().getCopy()); ZoomManager zoomManager = ((ScalableFreeformRootEditPart) this .getHost().getRoot()).getZoomManager(); double zoom = zoomManager.getZoom(); IFigure feedback = getSizeOnDropFeedback(request); Dimension size = request.getSize().getCopy(); feedback.translateToRelative(size); feedback.setBounds(new Rectangle((int) (p.x * zoom), (int) (p.y * zoom), size.width, size.height) .expand(getCreationFeedbackOffset(request))); }
Example 3
Source File: WrappableToolbarLayout.java From nebula with Eclipse Public License 2.0 | 6 votes |
public void layout(IFigure container) { Rectangle clientArea = container.getClientArea(); int w = 0; int h = 0; int maxH = 0; for (Object child : container.getChildren()) { IFigure figure = (IFigure) child; Dimension preferSize = figure.getPreferredSize(); if (w + preferSize.width < clientArea.width) { figure.setBounds( new Rectangle(clientArea.x + w, clientArea.y + h, preferSize.width, preferSize.height)); w += preferSize.width; if (maxH < preferSize.height) { maxH = preferSize.height; } } else { h += maxH; w = 0; figure.setBounds( new Rectangle(clientArea.x + w, clientArea.y + h, preferSize.width, preferSize.height)); w = preferSize.width; maxH = preferSize.height; } } }
Example 4
Source File: ListBandHandle.java From birt with Eclipse Public License 1.0 | 6 votes |
public void relocate( IFigure target ) { Rectangle bounds; if ( getReference( ) instanceof ListBandFigure ) { ListBandFigure parent = (ListBandFigure) getReference( ); Figure content = (Figure) parent.getContent( ); bounds = content.getBounds( ).getCopy( ); } else { bounds = getReference( ).getBounds( ).getCopy( ); } getReference( ).translateToAbsolute( bounds ); target.translateToRelative( bounds ); bounds.translate( 1, 1 ); bounds.resize( -1, -1 ); target.setBounds( bounds ); }
Example 5
Source File: EditorRulerLayout.java From birt with Eclipse Public License 1.0 | 6 votes |
/** * @see org.eclipse.draw2d.LayoutManager#layout(org.eclipse.draw2d.IFigure) */ public void layout( IFigure container ) { List children = container.getChildren( ); Rectangle rulerSize = container.getClientArea( ); for ( int i = 0; i < children.size( ); i++ ) { IFigure child = (IFigure) children.get( i ); Dimension childSize = child.getPreferredSize( ); int position = ( (Integer) getConstraint( child ) ).intValue( ); if ( ( (EditorRulerFigure) container ).isHorizontal( ) ) { childSize.height = rulerSize.height - 1; Rectangle.SINGLETON.setLocation( position - ( childSize.width / 2 ), rulerSize.y ); } else { childSize.width = rulerSize.width - 1; Rectangle.SINGLETON.setLocation( rulerSize.x, position - ( childSize.height / 2 ) ); } Rectangle.SINGLETON.setSize( childSize ); child.setBounds( Rectangle.SINGLETON ); } }
Example 6
Source File: LibraryReportDesignLayout.java From birt with Eclipse Public License 1.0 | 5 votes |
public void layout( IFigure parent ) { super.layout( parent ); Dimension prefSize = getPreferredSize( parent, getInitSize( ).width, -1 ).getCopy( ); Rectangle bounds = parent.getBounds( ).getCopy( ); bounds.height = Math.max( prefSize.height, getInitSize( ).height ); bounds.width = getInitSize( ).width; // bounds = new PrecisionRectangle( bounds); // owner.getFigure().translateToAbsolute( bounds ); Result result = getReportBounds( bounds ); bounds = result.reportSize; parent.setBounds( bounds ); Rectangle rect = new Rectangle( 0, 0, bounds.x + bounds.width + result.rightSpace, bounds.y + bounds.height + result.bottomSpace ); setViewProperty( rect, bounds ); // parent.getParent( ).setSize( rect.getSize( ) ); }
Example 7
Source File: ERDiagramLayoutEditPolicy.java From erflute with Apache License 2.0 | 5 votes |
@Override protected void showSizeOnDropFeedback(CreateRequest request) { final Point p = new Point(request.getLocation().getCopy()); final ZoomManager zoomManager = ((ScalableFreeformRootEditPart) getHost().getRoot()).getZoomManager(); final double zoom = zoomManager.getZoom(); final IFigure feedback = getSizeOnDropFeedback(request); final Dimension size = request.getSize().getCopy(); feedback.translateToRelative(size); feedback.setBounds(new Rectangle((int) (p.x * zoom), (int) (p.y * zoom), size.width, size.height) .expand(getCreationFeedbackOffset(request))); }
Example 8
Source File: DirectEditManagerEx.java From statecharts with Eclipse Public License 1.0 | 5 votes |
private void placeBorder() { if (showingFeedback) { IFigure shadow = getCellEditorFrame(); Rectangle rect = new Rectangle(getCellEditor().getControl() .getBounds()); rect.expand(shadow.getInsets()); shadow.translateToRelative(rect); shadow.setBounds(rect); } }
Example 9
Source File: ListLayout.java From birt with Eclipse Public License 1.0 | 5 votes |
protected void setBoundsOfChild( IFigure parent, IFigure child, Rectangle bounds ) { parent.getClientArea( Rectangle.SINGLETON ); bounds.translate( Rectangle.SINGLETON.x, Rectangle.SINGLETON.y ); if ( !bounds.equals( child.getBounds( ) ) ) { child.setBounds( bounds ); } }
Example 10
Source File: ListBandLayout.java From birt with Eclipse Public License 1.0 | 5 votes |
protected void setBoundsOfChild( IFigure parent, IFigure child, Rectangle bounds ) { parent.getClientArea( Rectangle.SINGLETON ); bounds.translate( Rectangle.SINGLETON.x, Rectangle.SINGLETON.y ); if ( !bounds.equals( child.getBounds( ) ) ) { child.setBounds( bounds ); } }
Example 11
Source File: TableLayout.java From birt with Eclipse Public License 1.0 | 5 votes |
protected void setBoundsOfChild( IFigure parent, IFigure child, Rectangle bounds ) { parent.getClientArea( Rectangle.SINGLETON ); bounds.translate( Rectangle.SINGLETON.x, Rectangle.SINGLETON.y ); // comment out to force invalidation. // if ( !bounds.equals( child.getBounds( ) ) ) { child.setBounds( bounds ); if ( child.getLayoutManager( ) != null ) child.getLayoutManager( ).invalidate( ); child.revalidate( ); } }
Example 12
Source File: DraggableElementCreationTool.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
/** * @return */ private IFigure createImage() { final CreateUnspecifiedTypeRequest createUnspecifiedTypeRequest = (CreateUnspecifiedTypeRequest) tool.createCreateRequest(); final EClass eClass = ((IElementType) createUnspecifiedTypeRequest.getElementTypes().get(0)).getEClass(); final IFigure svgFigure = FiguresHelper.getSelectedFigure(eClass, -1, -1, null, null); final Rectangle r = svgFigure.getBounds().getCopy(); r.performScale(zoomManager.getZoom()); svgFigure.setBounds(r); return svgFigure; }
Example 13
Source File: BPMNShapeFactory.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings("unchecked") private PolylineConnection createConnectorFigure(Edge bonitaEdge) { Bounds sourceLocation = getBPMNShapeBounds(modelExporter.getEObjectID(bonitaEdge.getSource())); Bounds targetLocation = getBPMNShapeBounds(modelExporter.getEObjectID(bonitaEdge.getTarget())); PolylineConnection conn = new PolylineConnection(); AbstractRouter router = new CustomRectilinearRouter(); conn.setConnectionRouter(router); final List<RelativeBendpoint> pointList = ((RelativeBendpoints) bonitaEdge.getBendpoints()).getPoints(); List<org.eclipse.draw2d.RelativeBendpoint> figureConstraint = new ArrayList<>(); for (int i = 0; i < pointList.size(); i++) { RelativeBendpoint relativeBendpoint = (RelativeBendpoint) pointList.get(i); IFigure sourceFigure = new Figure(); sourceFigure.setBounds(toRectangle(sourceLocation)); IFigure targetFigure = new Figure(); targetFigure.setBounds(toRectangle(targetLocation)); conn.setSourceAnchor(new CustomAnchor(sourceFigure)); conn.setTargetAnchor(new CustomAnchor(targetFigure)); org.eclipse.draw2d.RelativeBendpoint rbp = new org.eclipse.draw2d.RelativeBendpoint(conn); rbp.setRelativeDimensions( new Dimension(relativeBendpoint.getSourceX(), relativeBendpoint.getSourceY()), new Dimension(relativeBendpoint.getTargetX(), relativeBendpoint.getTargetY())); if (pointList.size() == 1) { rbp.setWeight(0.5f); } else { rbp.setWeight(i / ((float) pointList.size() - 1)); } figureConstraint.add(rbp); } conn.setRoutingConstraint(figureConstraint); router.route(conn); return conn; }
Example 14
Source File: ERDiagramLayoutEditPolicy.java From ermasterr with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override protected void showSizeOnDropFeedback(final CreateRequest request) { final Point p = new Point(request.getLocation().getCopy()); final ZoomManager zoomManager = ((ScalableFreeformRootEditPart) getHost().getRoot()).getZoomManager(); final double zoom = zoomManager.getZoom(); final IFigure feedback = getSizeOnDropFeedback(request); final Dimension size = request.getSize().getCopy(); feedback.translateToRelative(size); feedback.setBounds(new Rectangle((int) (p.x * zoom), (int) (p.y * zoom), size.width, size.height).expand(getCreationFeedbackOffset(request))); }
Example 15
Source File: EnlargeContainerEditPolicy.java From statecharts with Eclipse Public License 1.0 | 4 votes |
protected void setBounds(IFigure figure, Rectangle bounds) { figure.setBounds(bounds); figure.getParent().setConstraint(figure, bounds); }
Example 16
Source File: GridLayout.java From ice with Eclipse Public License 1.0 | 4 votes |
/** * Applies a rectangle-based layout to the container. */ @Override public void layout(IFigure container) { // Get the maximum bounding box we can use for layout out sub-figures. Rectangle limit = container.getClientArea(); // Compute the maximum width/height of each cell. We'll make everything // square. int maxWidth = (limit.width - (columns - 1) * horizontalSpacing) / columns; int maxHeight = (limit.height - (rows - 1) * verticalSpacing) / rows; // Get the size and any vertical/horizontal padding necessary. int size, paddingX = 0, paddingY = 0; if (maxWidth > maxHeight) { // Height-restricted. size = maxHeight; paddingX = (limit.width - size * columns - horizontalSpacing * (columns - 1)) / 2; } else { // Width-restricted. size = maxWidth; paddingY = (limit.height - size * rows - verticalSpacing * (rows - 1)) / 2; } int i, row, column, x, y, w, h; // Loop over the IFigures in the container with this layout. for (Object childObject : container.getChildren()) { IFigure child = (IFigure) childObject; // Get the constraints (and the x, y, w, h offsets from it). GridData constraint = getConstraint(child); Rectangle offsets = constraint.getOffsets(); // Get the index and compute the row and column for the index. i = constraint.getIndex(); row = i / columns; column = i % columns; // Compute the bounds of the cell in the row, column position. x = paddingX + column * (size + horizontalSpacing) + offsets.x; y = paddingY + row * (size + verticalSpacing) + offsets.y; w = size + offsets.width; h = size + offsets.height; // Set the bounds for the child IFigure. child.setBounds(new Rectangle(x, y, w, h)); } return; }
Example 17
Source File: ReportFlowLayout.java From birt with Eclipse Public License 1.0 | 3 votes |
/** * Sets the given bounds for the child figure input. * * @param parent * the parent figure * @param child * the child figure * @param bounds * the size of the child to be set * @since 2.0 */ protected void setBoundsOfChild( IFigure parent, IFigure child, Rectangle bounds ) { parent.getClientArea( Rectangle.SINGLETON ); bounds.translate( Rectangle.SINGLETON.x, Rectangle.SINGLETON.y ); child.setBounds( bounds ); }