org.eclipse.draw2d.geometry.Rectangle Java Examples
The following examples show how to use
org.eclipse.draw2d.geometry.Rectangle.
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: ColumnSelectionHandlesEditPolicy.java From ermasterr with Apache License 2.0 | 6 votes |
private int getColumnIndex(final DirectEditRequest editRequest) { final ZoomManager zoomManager = ((ScalableFreeformRootEditPart) getHost().getRoot()).getZoomManager(); final double zoom = zoomManager.getZoom(); final ColumnEditPart columnEditPart = (ColumnEditPart) getHost(); Column column = (Column) columnEditPart.getModel(); final TableView newTableView = (TableView) getHost().getParent().getModel(); final List<Column> columns = newTableView.getColumns(); if (column.getColumnHolder() instanceof ColumnGroup) { column = (ColumnGroup) column.getColumnHolder(); } int index = columns.indexOf(column); final Rectangle columnRectangle = getColumnRectangle(); final int center = (int) ((columnRectangle.y + (columnRectangle.height / 2)) * zoom); if (editRequest.getLocation().y >= center) { index++; } return index; }
Example #2
Source File: VerticalLineAction.java From ermaster-b with Apache License 2.0 | 6 votes |
public int compare(NodeElementEditPart o1, NodeElementEditPart o2) { if (o1 == null) { return -1; } if (o2 == null) { return 1; } Rectangle bounds1 = o1.getFigure().getBounds(); Rectangle bounds2 = o2.getFigure().getBounds(); int rightY1 = bounds1.y + bounds1.height; int rightY2 = bounds2.y + bounds2.height; return rightY1 - rightY2; }
Example #3
Source File: CustomRectilinearRouter.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
/** * Given the coordinates of the connection anchor point the shape's rectangle and the * orientation of the first rectilinear connection segment that comes out from the anchor * point the method detemines on which geographic side of the rectangle the anchor point * is located on. * * @param anchorPoint coordinates of the anchor point * @param rectangle the shape's bounding rectangle * @param segmentOrientation orinetation of the segment coming out from the anchor point * @return geographic position of the anchor point relative to the rectangle */ private int getAnchorLocationBasedOnSegmentOrientation(Point anchorPoint, Rectangle rectangle, int segmentOrientation) { if (segmentOrientation == PositionConstants.VERTICAL) { if (Math.abs(anchorPoint.y - rectangle.y) < Math.abs(anchorPoint.y - rectangle.y - rectangle.height)) { return PositionConstants.NORTH; } else { return PositionConstants.SOUTH; } } else if (segmentOrientation == PositionConstants.HORIZONTAL) { if (Math.abs(anchorPoint.x - rectangle.x) < Math.abs(anchorPoint.x - rectangle.x - rectangle.width)) { return PositionConstants.WEST; } else { return PositionConstants.EAST; } } return PositionConstants.NONE; }
Example #4
Source File: LinkAnchor.java From olca-app with Mozilla Public License 2.0 | 6 votes |
@Override public Point getLocation(Point reference) { int hTrans = 0; if (!node.isMinimized()) { hTrans = ProcessFigure.MARGIN_WIDTH + 1; if (forInput) { hTrans *= -1; } } Rectangle r = getOwner().getBounds().getCopy(); r.translate(hTrans, 0); getOwner().translateToAbsolute(r); Point location = null; if (forInput) { location = r.getLeft(); } else { location = r.getRight(); } return location; }
Example #5
Source File: PlotArea.java From nebula with Eclipse Public License 2.0 | 6 votes |
@Override protected void layout() { final Rectangle clientArea = getClientArea(); for (Trace trace : traceList) { if (trace != null && trace.isVisible()) // Shrink will make the trace has no intersection with axes, // which will make it only repaints the trace area. trace.setBounds(clientArea);// .getCopy().shrink(1, 1)); } for (Grid grid : gridList) { if (grid != null && grid.isVisible()) grid.setBounds(clientArea); } for (Annotation annotation : annotationList) { if (annotation != null && annotation.isVisible()) annotation.setBounds(clientArea);// .getCopy().shrink(1, 1)); } super.layout(); }
Example #6
Source File: LineBorder.java From birt with Eclipse Public License 1.0 | 6 votes |
/** * @param figure * @param g * @param side * @param style * @param width * the border width array, arranged by {top, bottom, left, * right}; * @param color * @param insets */ protected void drawBorder( IFigure figure, Graphics g, int side, int style, int[] width, int color, Insets insets ) { Rectangle r = figure.getBounds( ).getCopy( ).crop( insets ); if ( style != 0 ) { //set ForegroundColor with the given color g.setForegroundColor( ColorManager.getColor( color ) ); BorderUtil.drawBorderLine( g, side, style, width, r ); } else { g.setForegroundColor( ReportColorConstants.ShadowLineColor ); //if the border style is set to none, draw a default dot line in // black as default BorderUtil.drawDefaultLine( g, side, r ); } g.restoreState( ); }
Example #7
Source File: ReportPrintGraphicalViewerOperation.java From birt with Eclipse Public License 1.0 | 6 votes |
/** * Sets up Graphics object for the given IFigure. * * @param graphics * The Graphics to setup * @param figure * The IFigure used to setup graphics */ protected void setupPrinterGraphicsFor( Graphics graphics, IFigure figure ) { // Because the ScaleGraphics don't support the scale(float h,float v),so // now suppoer fit the page. Rectangle printRegion = getPrintRegion( ); Rectangle bounds = figure.getBounds( ); double xScale = (double) printRegion.width / bounds.width; double yScale = (double) printRegion.height / bounds.height; graphics.scale( Math.min( xScale, yScale ) ); // float xScale = (float) printRegion.width / bounds.width; // float yScale = (float) printRegion.height / bounds.height; // graphics.scale( xScale, yScale ); graphics.setForegroundColor( figure.getForegroundColor( ) ); graphics.setBackgroundColor( figure.getBackgroundColor( ) ); graphics.setFont( figure.getFont( ) ); }
Example #8
Source File: CrosstabRowDragTracker.java From birt with Eclipse Public License 1.0 | 6 votes |
protected Rectangle getMarqueeSelectionRectangle( ) { IFigure figure = getCrosstabTableEditPart( ).getFigure( ); Insets insets = figure.getInsets( ); int value = getLocation( ).y - getStartLocation( ).y; value = getTrueValueAbsolute( value ); Point p = getStartLocation( ).getCopy( ); figure.translateToAbsolute( p ); figure.translateToRelative( p ); Rectangle bounds = figure.getBounds( ).getCopy( ); figure.translateToAbsolute( bounds ); return new Rectangle( bounds.x + insets.left, value + p.y, bounds.width - ( insets.left + insets.right ), 2 ); }
Example #9
Source File: ProcessFigure.java From olca-app with Mozilla Public License 2.0 | 6 votes |
private void initializeFigure() { String tooltip = null; if (node.process instanceof ProcessDescriptor) { ProcessDescriptor d = (ProcessDescriptor) node.process; tooltip = Labels.of(d.processType) + ": " + node.getName(); } else { tooltip = M.ProductSystem + ": " + node.getName(); } setToolTip(new Label(tooltip)); setForegroundColor(TEXT_COLOR); setBounds(new Rectangle(0, 0, 0, 0)); setSize(calculateSize()); GridLayout layout = new GridLayout(1, true); layout.horizontalSpacing = 10; layout.verticalSpacing = 0; layout.marginHeight = MARGIN_HEIGHT; layout.marginWidth = MARGIN_WIDTH; setLayoutManager(layout); paintBorder(); }
Example #10
Source File: FiguresHelper.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
/** * Convenient method to translate bounds to Absolute coordinate * * @param owner * @param b */ public static void translateToAbsolute(final IFigure owner, final Rectangle b) { owner.translateToAbsolute(b); IFigure parentFigure = owner.getParent(); while (parentFigure != null) { if (parentFigure instanceof Viewport) { final Viewport viewport = (Viewport) parentFigure; b.translate( viewport.getHorizontalRangeModel().getValue(), viewport.getVerticalRangeModel().getValue()); parentFigure = parentFigure.getParent(); } else { parentFigure = parentFigure.getParent(); } } }
Example #11
Source File: AreaFigure.java From birt with Eclipse Public License 1.0 | 6 votes |
protected void paintFigure( Graphics graphics ) { Rectangle rect = getClientArea( ).expand( DEFAULT_EXPAND ); Color forecolor = graphics.getForegroundColor( ); if ( getBackgroundColor( ).equals( ColorConstants.blue ) ) { //paint the figure with blue when it's highlighted graphics.fillRectangle( rect ); } graphics.setForegroundColor( ReportColorConstants.MarginBorderColor ); drawLine( graphics, rect, SWT.LEFT, LINE_STYLE ); drawLine( graphics, rect, SWT.TOP, LINE_STYLE ); drawLine( graphics, rect, SWT.RIGHT, LINE_STYLE ); drawLine( graphics, rect, SWT.BOTTOM, LINE_STYLE ); graphics.setForegroundColor( forecolor ); }
Example #12
Source File: AbstractPageFlowLayout.java From birt with Eclipse Public License 1.0 | 5 votes |
protected void setViewProperty( Rectangle caleBounds, Rectangle ownerBounds ) { getOwner( ).getViewer( ).setProperty( DeferredGraphicalViewer.REPORT_SIZE, caleBounds ); getOwner( ).getViewer( ).setProperty( DeferredGraphicalViewer.LAYOUT_SIZE, ownerBounds ); getOwner( ).getViewer( ).setProperty( DeferredGraphicalViewer.RULER_SIZE, new Rectangle(ownerBounds.x, ownerBounds.y, getInitSize().width, ownerBounds.height) ); }
Example #13
Source File: LabelFigure.java From birt with Eclipse Public License 1.0 | 5 votes |
/** * Since Eclipse TextFlow figure ignore the trailing /r/n for calculating * the client size, we must append the extra size ourselves. * * @return dimension for the client area used by the editor. */ public Rectangle getEditorArea( ) { Rectangle rect = getClientArea( ).getCopy( ); String s = getText( ); int count = 0; if ( s != null && s.length( ) > 1 ) { for ( int i = s.length( ) - 2; i >= 0; i -= 2 ) { if ( "\r\n".equals( s.substring( i, i + 2 ) ) ) //$NON-NLS-1$ { //count++; } else { break; } } } int hh = getMinimumFontSize( getFont( ) ); rect.height += count * hh + ( ( count == 0 ) ? 0 : ( hh / 2 ) ); return rect; }
Example #14
Source File: CustomEndErrorEvent2EditPart.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
/** Create a list of points to draw a circle * */ @Override protected NodeFigure createNodePlate() { DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(FiguresHelper.EVENT_WIDTH, FiguresHelper.EVENT_WIDTH) { public PointList getPolygonPoints() { Rectangle anchRect = getHandleBounds(); return FiguresHelper.CirclePointList(anchRect); } }; return result; }
Example #15
Source File: ImageFigure.java From birt with Eclipse Public License 1.0 | 5 votes |
private void paintStretched( Graphics g ) { Image image = getImage( ); Rectangle area = getClientArea( ); if ( area.height > 0 && area.width > 0 ) { g.drawImage( image, new Rectangle( image.getBounds( ) ), area ); } }
Example #16
Source File: DropShadowRectangle.java From ermaster-b with Apache License 2.0 | 5 votes |
private void drawShadowLayer(Rectangle rectangle, Graphics graphics, int offset, Color color) { // Save the state of the graphics object graphics.pushState(); graphics.setLineWidth(0); graphics.setBackgroundColor(color); Rectangle shadowLayer = new Rectangle(rectangle); shadowLayer.x += offset; shadowLayer.y += offset; graphics.fillRoundRectangle(shadowLayer, corner.width, corner.height); // Restore the start of the graphics object graphics.popState(); }
Example #17
Source File: ListBandControlFigure.java From birt with Eclipse Public License 1.0 | 5 votes |
protected void paintFigure( Graphics graphics ) { Rectangle rect = getClientArea( ).getCopy( ); // String text = ( ( (ListBandProxy) getOwner( ).getModel( ) // ).getDisplayName( ) ); graphics.setForegroundColor( ReportColorConstants.DarkShadowLineColor ); graphics.drawString( text, rect.x, rect.y - 6 ); }
Example #18
Source File: FrameStyleSupport.java From erflute with Apache License 2.0 | 5 votes |
@Override public void adjustBounds(Rectangle rect) { final int width = border.getTitleBarWidth(getTableFigure()); if (width > rect.width) { rect.width = width; } }
Example #19
Source File: DropShadowRectangle.java From erflute with Apache License 2.0 | 5 votes |
@SuppressWarnings("deprecation") @Override protected void fillShape(Graphics graphics) { Rectangle f = Rectangle.SINGLETON.setBounds(getBounds()); final Insets shadowInset = new Insets(0, 0, SHADOW_INSET, SHADOW_INSET); f = shrink(f, shadowInset); drawShadow(f, graphics); graphics.fillRoundRectangle(f, corner.width, corner.height); }
Example #20
Source File: CategoryEditPart.java From ermaster-b with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override protected Rectangle getRectangle() { Rectangle rectangle = super.getRectangle(); Category category = (Category) this.getModel(); ERDiagramEditPart rootEditPart = (ERDiagramEditPart) this.getRoot() .getContents(); for (Object child : rootEditPart.getChildren()) { if (child instanceof NodeElementEditPart) { NodeElementEditPart editPart = (NodeElementEditPart) child; if (category.contains((NodeElement) editPart.getModel())) { Rectangle bounds = editPart.getFigure().getBounds(); if (bounds.x + bounds.width > rectangle.x + rectangle.width) { rectangle.width = bounds.x + bounds.width - rectangle.x; } if (bounds.y + bounds.height > rectangle.y + rectangle.height) { rectangle.height = bounds.y + bounds.height - rectangle.y; } if (rectangle.width != category.getWidth() || rectangle.height != category.getHeight()) { category.setLocation(new Location(category.getX(), category.getY(), rectangle.width, rectangle.height)); } } } } return rectangle; }
Example #21
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 #22
Source File: CustomThrowLinkEvent2EditPart.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
/** Create a list of points to draw a circle * */ @Override protected NodeFigure createNodePlate() { DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(FiguresHelper.BIG_EVENT_WIDTH, FiguresHelper.BIG_EVENT_WIDTH) { public PointList getPolygonPoints() { Rectangle anchRect = getHandleBounds(); return FiguresHelper.CirclePointList(anchRect); } }; return result; }
Example #23
Source File: CategoryEditPart.java From erflute with Apache License 2.0 | 5 votes |
@Override protected Rectangle getRectangle() { final Rectangle rectangle = super.getRectangle(); final Category category = (Category) getModel(); final ERDiagramEditPart rootEditPart = (ERDiagramEditPart) getRoot().getContents(); for (final Object child : rootEditPart.getChildren()) { if (child instanceof DiagramWalkerEditPart) { final DiagramWalkerEditPart editPart = (DiagramWalkerEditPart) child; if (category.contains((DiagramWalker) editPart.getModel())) { final Rectangle bounds = editPart.getFigure().getBounds(); if (bounds.x + bounds.width > rectangle.x + rectangle.width) { rectangle.width = bounds.x + bounds.width - rectangle.x; } if (bounds.y + bounds.height > rectangle.y + rectangle.height) { rectangle.height = bounds.y + bounds.height - rectangle.y; } if (rectangle.width != category.getWidth() || rectangle.height != category.getHeight()) { category.setLocation(new Location(category.getX(), category.getY(), rectangle.width, rectangle.height)); } } } } return rectangle; }
Example #24
Source File: FixedConnectionAnchor.java From statecharts with Eclipse Public License 1.0 | 5 votes |
public Point getLocation() { Rectangle r = getOwner().getBounds(); Point p = new PrecisionPoint(r.x + r.width * xOffset, r.y + r.height * yOffset); getOwner().translateToAbsolute(p); return p; }
Example #25
Source File: TableUtil.java From birt with Eclipse Public License 1.0 | 5 votes |
/** * Checks if the given figure is visible. * * @param fig * @return */ private static boolean isFigureVisible( IFigure fig ) { Rectangle figBounds = fig.getBounds( ).getCopy( ); IFigure walker = fig.getParent( ); while ( !figBounds.isEmpty( ) && walker != null ) { walker.translateToParent( figBounds ); figBounds.intersect( walker.getBounds( ) ); walker = walker.getParent( ); } return !figBounds.isEmpty( ); }
Example #26
Source File: CustomIntermediateThrowSignalEvent2EditPart.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
/** Create a list of points to draw a circle * */ @Override protected NodeFigure createNodePlate() { DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(FiguresHelper.EVENT_WIDTH, FiguresHelper.EVENT_WIDTH) { public PointList getPolygonPoints() { Rectangle anchRect = getHandleBounds(); return FiguresHelper.CirclePointList(anchRect); } }; return result; }
Example #27
Source File: LinearScaledMarker.java From nebula with Eclipse Public License 2.0 | 5 votes |
@Override public void setBounds(Rectangle rect) { if (!bounds.equals(rect)) dirty = true; super.setBounds(rect); }
Example #28
Source File: SwitchPoolSelectionEditPolicy.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
/** * */ private void showSelectionForAddBottom() { if (!isOnBottom()) { IFigure f = new ImageFigure(Pics.getImage(PicsConstants.arrowDown)); f.setSize(20, 20); sourceFigure = getHostFigure() ; Rectangle bounds = sourceFigure.getBounds().getCopy(); //get the absolute coordinate of bounds sourceFigure.translateToAbsolute(bounds); IFigure parentFigure = sourceFigure.getParent(); while( parentFigure != null ) { if(parentFigure instanceof Viewport) { Viewport viewport = (Viewport)parentFigure; bounds.translate( viewport.getHorizontalRangeModel().getValue(), viewport.getVerticalRangeModel().getValue()); parentFigure = parentFigure.getParent(); } else { parentFigure = parentFigure.getParent(); } } f.setLocation(new Point(bounds.getBottomLeft().x,bounds.getBottom().y)); f.addMouseListener(new MouseListenerForSpan(AbstractSwitchLaneSelectionEditPolicy.ADD_BOTTOM)); layer.add(f); figures.add(f); } }
Example #29
Source File: TableGridLayer.java From birt with Eclipse Public License 1.0 | 5 votes |
protected void drawColumns( Graphics g ) { g.setBackgroundColor( ReportColorConstants.greyFillColor ); Rectangle clip = g.getClip( Rectangle.SINGLETON ); List columns = getColumns( ); int size = columns.size( ); int width = 0; for ( int i = 0; i < size; i++ ) { int columnWidth = getColumnWidth( i + 1, columns.get( i ) ); // if ( width < clip.x + clip.width ) { // g.fillRectangle( width, clip.y, width, clip.y + clip.height // ); drawBackgroud( columns.get( i ), g, width, clip.y, columnWidth, clip.y + clip.height ); drawBackgroudImage( (DesignElementHandle) columns.get( i ), g, width, clip.y, columnWidth, clip.y + clip.height ); } width = width + columnWidth; } }
Example #30
Source File: ERDiagramAlignmentAction.java From ermaster-b with Apache License 2.0 | 5 votes |
/** * Returns the alignment rectangle to which all selected parts should be * aligned. * * @param request * the alignment Request * @return the alignment rectangle */ protected Rectangle calculateAlignmentRectangle(Request request) { List editparts = getOperationSet(request); if (editparts == null || editparts.isEmpty()) return null; GraphicalEditPart part = (GraphicalEditPart) editparts.get(editparts .size() - 1); Rectangle rect = new PrecisionRectangle(part.getFigure().getBounds()); part.getFigure().translateToAbsolute(rect); return rect; }