org.eclipse.draw2d.geometry.Insets Java Examples
The following examples show how to use
org.eclipse.draw2d.geometry.Insets.
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: TableCellEditPart.java From birt with Eclipse Public License 1.0 | 6 votes |
public void refreshFigure( ) { CellBorder cborder = new CellBorder( ); if ( getFigure( ).getBorder( ) instanceof CellBorder ) { cborder.setBorderInsets( ( (CellBorder) getFigure( ).getBorder( ) ) .getBorderInsets( ) ); } refreshBorder( getCellAdapter( ).getHandle( ), cborder ); Insets ist = getCellAdapter( ).getPadding( getFigure( ).getInsets( ) ); ( (CellBorder) ( getFigure( ).getBorder( ) ) ).setPaddingInsets( ist ); setTextAliment( ( (CellHandle) getModel( ) ).getPrivateStyle( ) ); ( (CellFigure) getFigure( ) ).setDirectionRTL( BidiUIUtils .INSTANCE.isDirectionRTL( getModel( ) ) ); // bidi_hcg updateBlankString( ); refreshBackground( (DesignElementHandle) getModel( ) ); }
Example #2
Source File: TimeAxisFigure.java From nebula with Eclipse Public License 2.0 | 6 votes |
private void paintMarkers(Graphics graphics) { final Rectangle bounds = getBounds(); graphics.setForegroundColor(ColorConstants.darkGray); graphics.setLineStyle(SWT.LINE_SOLID); final Insets insets = RootFigure.getFigure(this, TracksFigure.class).getInsets(); final ITimelineStyleProvider styleProvider = RootFigure.getRootFigure(this).getStyleProvider(); final Map<Double, Integer> markerPositions = getDetailFigure().getMarkerPositions(); for (final Entry<Double, Integer> entry : markerPositions.entrySet()) { final String label = styleProvider.getTimeLabel(entry.getKey(), TimeUnit.NANOSECONDS); final int textWidth = FigureUtilities.getTextWidth(label, graphics.getFont()); graphics.drawLine(entry.getValue() + bounds.x() + insets.left, bounds.y, entry.getValue() + bounds.x() + insets.left, bounds.y + 5); graphics.drawText(label, (entry.getValue() + bounds.x() + insets.left) - (textWidth / 2), bounds.y + 5); } }
Example #3
Source File: ERDiagramLineBorder.java From ermasterr with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ @Override public void paint(final IFigure figure, final Graphics graphics, final Insets insets) { if (getColor() != null) { graphics.setForegroundColor(getColor()); } tempRect.setBounds(getPaintRectangle(figure, insets)); if (getWidth() % 2 == 1) { tempRect.width--; tempRect.height--; } tempRect.shrink(getWidth() / 2, getWidth() / 2); graphics.setLineWidth(1); int g = 9 * DELTA; int b = 9 * DELTA; for (int i = 0; i <= 5; i++) { final Color color = Resources.getColor(new int[] {b, g, 255}); paint1(i, color, tempRect, graphics); g -= DELTA; b -= DELTA; } }
Example #4
Source File: LeftRightBorder.java From nebula with Eclipse Public License 2.0 | 6 votes |
@Override public void paint(IFigure figure, Graphics graphics, Insets insets) { tempRect.setBounds(getPaintRectangle(figure, insets)); if ((getWidth() % 2) == 1) { tempRect.width--; tempRect.height--; } tempRect.shrink(getWidth() / 2, getWidth() / 2); graphics.setLineWidth(getWidth()); graphics.setLineStyle(getStyle()); if (getColor() != null) graphics.setForegroundColor(getColor()); graphics.drawLine(tempRect.getTopLeft(), tempRect.getBottomLeft()); graphics.drawLine(tempRect.getTopRight(), tempRect.getBottomRight()); }
Example #5
Source File: LaneFigure.java From nebula with Eclipse Public License 2.0 | 6 votes |
/** * This is a copy of the parent method. Only change is that we call getContraintAsRectangle() instead of directly accessing the constraints member. */ @Override protected Dimension calculatePreferredSize(IFigure f, int wHint, int hHint) { final Rectangle rect = new Rectangle(); final ListIterator children = f.getChildren().listIterator(); while (children.hasNext()) { final IFigure child = (IFigure) children.next(); Rectangle r = getConstraintAsRectangle(child); if (r == null) continue; if ((r.width == -1) || (r.height == -1)) { final Dimension preferredSize = child.getPreferredSize(r.width, r.height); r = r.getCopy(); if (r.width == -1) r.width = preferredSize.width; if (r.height == -1) r.height = preferredSize.height; } rect.union(r); } final Dimension d = rect.getSize(); final Insets insets = f.getInsets(); return new Dimension(d.width + insets.getWidth(), d.height + insets.getHeight()).union(getBorderPreferredSize(f)); }
Example #6
Source File: RoundedRectangleBorder.java From nebula with Eclipse Public License 2.0 | 6 votes |
@Override public void paint(IFigure figure, Graphics graphics, Insets insets) { tempRect.setBounds(getPaintRectangle(figure, insets)); if ((getWidth() % 2) == 1) { tempRect.width--; tempRect.height--; } tempRect.shrink(getWidth() / 2, getWidth() / 2); graphics.setLineWidth(getWidth()); graphics.setLineStyle(getStyle()); if (getColor() != null) graphics.setForegroundColor(getColor()); graphics.drawRoundRectangle(tempRect, fArcWidth, fArcHeight); }
Example #7
Source File: ERDiagramLineBorder.java From ermaster-b with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ @Override public void paint(IFigure figure, Graphics graphics, Insets insets) { if (getColor() != null) { graphics.setForegroundColor(getColor()); } tempRect.setBounds(getPaintRectangle(figure, insets)); if (getWidth() % 2 == 1) { tempRect.width--; tempRect.height--; } tempRect.shrink(getWidth() / 2, getWidth() / 2); graphics.setLineWidth(1); int g = 9 * DELTA; int b = 9 * DELTA; for (int i = 0; i <= 5; i++) { Color color = Resources.getColor(new int[] { b, g, 255 }); this.paint1(i, color, tempRect, graphics); g -= DELTA; b -= DELTA; } }
Example #8
Source File: FunnyStyleSupport.java From ermasterr with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ @Override public void createColumnArea(final IFigure columns) { initColumnArea(columns); columns.setBorder(new MarginBorder(0, 0, 0, 0)); columns.setBackgroundColor(ColorConstants.white); columns.setOpaque(true); final Figure centerFigure = new Figure(); centerFigure.setLayoutManager(new BorderLayout()); centerFigure.setBorder(new MarginBorder(new Insets(0, 2, 0, 2))); centerFigure.add(columns, BorderLayout.CENTER); getTableFigure().add(centerFigure, BorderLayout.CENTER); }
Example #9
Source File: SimpleStyleSupport.java From ermasterr with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ @Override public void initTitleBar(final Figure top) { final ToolbarLayout topLayout = new ToolbarLayout(); topLayout.setMinorAlignment(OrderedLayout.ALIGN_TOPLEFT); topLayout.setStretchMinorAxis(true); top.setLayoutManager(topLayout); nameLabel = new Label(); nameLabel.setBorder(new MarginBorder(new Insets(5, 20, 5, 20))); top.add(nameLabel); final Figure separater = new Figure(); separater.setSize(-1, 1); separater.setBackgroundColor(getTextColor()); separater.setOpaque(true); top.add(separater); }
Example #10
Source File: FunnyStyleSupport.java From ermaster-b with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ @Override public void createColumnArea(IFigure columns) { this.initColumnArea(columns); columns.setBorder(new MarginBorder(new Insets(1, 0, 1, 0))); columns.setBackgroundColor(ColorConstants.white); columns.setOpaque(true); Figure centerFigure = new Figure(); centerFigure.setLayoutManager(new BorderLayout()); centerFigure.setBorder(new MarginBorder(new Insets(0, 2, 0, 2))); centerFigure.add(columns, BorderLayout.CENTER); this.getTableFigure().add(centerFigure, BorderLayout.CENTER); }
Example #11
Source File: ERDiagramLineBorder.java From erflute with Apache License 2.0 | 6 votes |
@Override public void paint(IFigure figure, Graphics graphics, Insets insets) { if (getColor() != null) { graphics.setForegroundColor(getColor()); } tempRect.setBounds(getPaintRectangle(figure, insets)); if (getWidth() % 2 == 1) { tempRect.width--; tempRect.height--; } tempRect.shrink(getWidth() / 2, getWidth() / 2); graphics.setLineWidth(1); int g = 9 * DELTA; int b = 9 * DELTA; for (int i = 0; i <= 5; i++) { final Color color = DesignResources.getColor(new int[] { b, g, 255 }); paint1(i, color, tempRect, graphics); g -= DELTA; b -= DELTA; } }
Example #12
Source File: ReportDesignMarginBorder.java From birt with Eclipse Public License 1.0 | 6 votes |
@Override protected void drawBorder( IFigure figure, Graphics g, int side, int style, int[] width, int color, Insets insets ) { Rectangle r = figure.getBounds( ).getCopy( ).crop(getMarginInsets( )).crop( insets ). crop(ReportRootFigure.DEFAULT_CROP).crop( new Insets(1,1,1,1)); if ( style != 0 && needChangeStyle) { //set ForegroundColor with the given color g.setForegroundColor( ColorManager.getColor( color ) ); BorderUtil.drawBorderLine( g, side, style, width, r ); } else { g.setForegroundColor( ReportColorConstants.MarginBorderColor ); //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 #13
Source File: PrintERDiagramOperation.java From ermaster-b with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ @Override public Rectangle getPrintRegion() { ERDiagram diagram = this.getDiagram(); PageSetting pageSetting = diagram.getPageSetting(); org.eclipse.swt.graphics.Rectangle trim = this.getPrinter() .computeTrim(0, 0, 0, 0); org.eclipse.swt.graphics.Point printerDPI = this.getPrinter().getDPI(); Insets notAvailable = new Insets(-trim.y, -trim.x, trim.height + trim.y, trim.width + trim.x); Insets userPreferred = new Insets( (pageSetting.getTopMargin() * printerDPI.x) / 72, (pageSetting.getLeftMargin() * printerDPI.x) / 72, (pageSetting.getBottomMargin() * printerDPI.x) / 72, (pageSetting.getRightMargin() * printerDPI.x) / 72); Rectangle paperBounds = new Rectangle(this.getPrinter().getBounds()); Rectangle printRegion = shrink(paperBounds, notAvailable); printRegion.intersect(shrink(paperBounds, userPreferred)); printRegion.translate(trim.x, trim.y); return printRegion; }
Example #14
Source File: FunnyStyleSupport.java From erflute with Apache License 2.0 | 6 votes |
@Override public void createFooter() { final IFigure footer = new Figure(); final BorderLayout footerLayout = new BorderLayout(); footer.setLayoutManager(footerLayout); footer.setBorder(new MarginBorder(new Insets(0, 0, 0, 0))); final IFigure footer1 = new Figure(); footer1.setSize(-1, 1); footer1.setBackgroundColor(ColorConstants.black); footer1.setOpaque(true); footer.add(footer1, BorderLayout.TOP); final IFigure footer2 = new Figure(); footer2.setSize(-1, 6); footer.add(footer2, BorderLayout.BOTTOM); getTableFigure().add(footer, BorderLayout.BOTTOM); }
Example #15
Source File: FunnyStyleSupport.java From erflute with Apache License 2.0 | 6 votes |
@Override public void addColumnGroup(GroupColumnFigure columnFigure, int viewMode, String name, boolean isAdded, boolean isUpdated, boolean isRemoved) { columnFigure.setBorder(new MarginBorder(new Insets(1, 0, 1, 0))); final ImageFigure image = new ImageFigure(); image.setBorder(new MarginBorder(new Insets(0, 4, 0, 7))); image.setImage(Activator.getImage(ImageKey.GROUP)); columnFigure.add(image); final StringBuilder text = new StringBuilder(); text.append(name); text.append(" (GROUP)"); setColumnFigureColor(columnFigure, false, false, isAdded, isUpdated, isRemoved); final Label label = createColumnLabel(); label.setForegroundColor(ColorConstants.black); label.setLabelAlignment(PositionConstants.RIGHT); label.setBorder(new MarginBorder(new Insets(1, 3, 0, 4))); label.setText(text.toString()); columnFigure.add(label); }
Example #16
Source File: FunnyStyleSupport.java From erflute with Apache License 2.0 | 6 votes |
@Override public void addIndex(IndexFigure indexFigure, String name, boolean isFirst) { final ImageFigure image = new ImageFigure(); image.setBorder(new MarginBorder(new Insets(0, 0, 0, 19))); image.setImage(Activator.getImage(ImageKey.BLANK_WHITE)); image.setOpaque(true); indexFigure.add(image); final StringBuilder text = new StringBuilder(); text.append(name); final Label label = createColumnLabel(); label.setBorder(new MarginBorder(new Insets(1, 0, 0, 4))); label.setForegroundColor(ColorConstants.black); label.setText(text.toString()); indexFigure.add(label); }
Example #17
Source File: SimpleStyleSupport.java From erflute with Apache License 2.0 | 6 votes |
@Override public void initTitleBar(Figure top) { final ToolbarLayout topLayout = new ToolbarLayout(); topLayout.setMinorAlignment(ToolbarLayout.ALIGN_TOPLEFT); topLayout.setStretchMinorAxis(true); top.setLayoutManager(topLayout); this.nameLabel = new Label(); nameLabel.setBorder(new MarginBorder(new Insets(5, 20, 5, 20))); top.add(nameLabel); final Figure separater = new Figure(); separater.setSize(-1, 1); separater.setBackgroundColor(getTextColor()); separater.setOpaque(true); top.add(separater); }
Example #18
Source File: CellBorder.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, String color, Insets insets ) { Rectangle r = figure.getBounds( ) .getCopy( ) .crop( DEFAULT_CROP ) .crop( insets ); if ( style != 0 ) { //set ForegroundColor with the given color g.setForegroundColor( ColorManager.getColor( ColorUtil.parseColor( 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 #19
Source File: CrosstabColumnDragTracker.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( ).x - getStartLocation( ).x; value = getTrueValueAbsolute( value ); Point p = getStartLocation( ).getCopy( ); figure.translateToAbsolute( p ); figure.translateToRelative( p ); Rectangle bounds = figure.getBounds( ).getCopy( ); figure.translateToAbsolute( bounds ); return new Rectangle( value + p.x, bounds.y + insets.top, 2, bounds.height - ( insets.top + insets.bottom ) ); }
Example #20
Source File: SimpleStyleSupport.java From ermaster-b with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ @Override public void initTitleBar(Figure top) { ToolbarLayout topLayout = new ToolbarLayout(); topLayout.setMinorAlignment(ToolbarLayout.ALIGN_TOPLEFT); topLayout.setStretchMinorAxis(true); top.setLayoutManager(topLayout); this.nameLabel = new Label(); this.nameLabel.setBorder(new MarginBorder(new Insets(5, 20, 5, 20))); top.add(nameLabel); Figure separater = new Figure(); separater.setSize(-1, 1); separater.setBackgroundColor(this.getTextColor()); separater.setOpaque(true); top.add(separater); }
Example #21
Source File: FunnyStyleSupport.java From ermaster-b with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ @Override public void createFooter() { IFigure footer = new Figure(); BorderLayout footerLayout = new BorderLayout(); footer.setLayoutManager(footerLayout); footer.setBorder(new MarginBorder(new Insets(0, 0, 0, 0))); IFigure footer1 = new Figure(); footer1.setSize(-1, 1); footer1.setBackgroundColor(ColorConstants.black); footer1.setOpaque(true); footer.add(footer1, BorderLayout.TOP); IFigure footer2 = new Figure(); footer2.setSize(-1, 6); footer.add(footer2, BorderLayout.BOTTOM); this.getTableFigure().add(footer, BorderLayout.BOTTOM); }
Example #22
Source File: EditorRulerComposite.java From birt with Eclipse Public License 1.0 | 6 votes |
/** * @see org.eclipse.draw2d.Border#paint(org.eclipse.draw2d.IFigure, * org.eclipse.draw2d.Graphics, org.eclipse.draw2d.geometry.Insets) */ public void paint( IFigure figure, Graphics graphics, Insets insets ) { graphics.setForegroundColor( ColorConstants.buttonDarker ); if ( horizontal ) { graphics.drawLine( figure.getBounds( ).getTopLeft( ), figure.getBounds( ) .getBottomLeft( ) .translate( new org.eclipse.draw2d.geometry.Point( 0, -4 ) ) ); } else { graphics.drawLine( figure.getBounds( ).getTopLeft( ), figure.getBounds( ) .getTopRight( ) .translate( new org.eclipse.draw2d.geometry.Point( -4, 0 ) ) ); } }
Example #23
Source File: EditorDragGuidePolicy.java From birt with Eclipse Public License 1.0 | 6 votes |
protected void updateInfomation(String label) { if (infoLabel == null) { return; } infoLabel.setText( label ); Dimension size = FigureUtilities.getTextExtents( label, infoLabel.getFont( ) ); //Insets insets = getInfomationLabel( ).getInsets( ); Insets insets = INSETS; Dimension newSize = size.getCopy( ).expand( insets.getWidth( ), insets.getHeight( ) ) ; if (size.width > maxWidth) { maxWidth = size.width; } else { newSize = new Dimension(maxWidth, size.height).expand( insets.getWidth( ), insets.getHeight( ) ); } infoLabel.setSize( newSize); setLabelLocation( ); adjustLocation( ); }
Example #24
Source File: RowDragTracker.java From birt with Eclipse Public License 1.0 | 6 votes |
protected Rectangle getMarqueeSelectionRectangle( ) { IFigure figure = ( (TableEditPart) getSourceEditPart( ) ).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 #25
Source File: ReportFlowLayoutEditPolicy.java From birt with Eclipse Public License 1.0 | 6 votes |
/** * Generates a draw2d constraint object derived from the specified child * EditPart using the provided Request. The returned constraint will be * translated to the application's model later using * {@link #translateToModelConstraint(Object)}. * * @param request * the ChangeBoundsRequest * @param child * the child EditPart for which the constraint should be * generated * @return the draw2d constraint */ protected Object getConstraintFor( ChangeBoundsRequest request, GraphicalEditPart child ) { IFigure figure = child.getFigure( ); Rectangle rect = new PrecisionRectangle(figure.getBounds()); figure.translateToAbsolute(rect); rect = request.getTransformedRectangle( rect ); figure.translateToRelative(rect); rect.translate( getLayoutOrigin( ).getNegated( ) ); if (figure instanceof IOutsideBorder) { Border border = ((IOutsideBorder)figure).getOutsideBorder( ); if (border != null) { Insets insets = border.getInsets( figure ); rect.shrink( insets.right, insets.bottom ); } } return getConstraintFor( rect ); }
Example #26
Source File: CollapsableEventSubprocessFigure.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@Override protected void fillShape(Graphics graphics) { if(useGradient){ Rectangle r = getBounds().getCopy(); Point topLeft = r.getTopLeft(); Point bottomRight = r.getBottomRight(); Pattern pattern = new Pattern(Display.getCurrent(), topLeft.x +2, topLeft.y+2 , bottomRight.x-2, bottomRight.y-2,gradientColor,255,getBackgroundColor(),90); graphics.setBackgroundPattern(pattern); graphics.fillRectangle(r.crop(new Insets(2,2,2,2))); graphics.setBackgroundPattern(null); pattern.dispose(); }else{ super.fillShape(graphics) ; } }
Example #27
Source File: ColumnDragTracker.java From birt with Eclipse Public License 1.0 | 6 votes |
protected Rectangle getMarqueeSelectionRectangle( ) { IFigure figure = ( (TableEditPart) getSourceEditPart( ) ).getFigure( ); Insets insets = figure.getInsets( ); int value = getLocation( ).x - getStartLocation( ).x; value = getTrueValueAbsolute( value ); Point p = getStartLocation( ).getCopy( ); figure.translateToAbsolute( p ); figure.translateToRelative( p ); Rectangle bounds = figure.getBounds( ).getCopy( ); figure.translateToAbsolute( bounds ); return new Rectangle( value + p.x, bounds.y + insets.top, 2, bounds.height - ( insets.top + insets.bottom ) ); }
Example #28
Source File: IndexEditPart.java From erflute with Apache License 2.0 | 5 votes |
public void refreshTableColumns() { final ERDiagram diagram = getDiagram(); final IndexFigure indexFigure = (IndexFigure) getFigure(); final ERIndex index = (ERIndex) getModel(); final int notationLevel = diagram.getDiagramContents().getSettings().getNotationLevel(); final TableViewEditPart parent = (TableViewEditPart) getParent(); final List<?> figures = parent.getContentPane().getChildren(); boolean isFirst = false; if (!(figures.get(figures.size() - 1) instanceof IndexFigure)) { if (notationLevel != DiagramSettings.NOTATION_LEVLE_TITLE) { isFirst = true; parent.getContentPane().add(new GuideEditPart.GuideLineFigure()); final Label indexHeader = new Label(); indexHeader.setLabelAlignment(PositionConstants.LEFT); indexHeader.setText("<< index >>"); indexHeader.setBorder(new MarginBorder(new Insets(4, 3, 0, 0))); parent.getContentPane().add(indexHeader); } } parent.getContentPane().add(figure); if (notationLevel != DiagramSettings.NOTATION_LEVLE_TITLE) { final TableFigure tableFigure = (TableFigure) parent.getFigure(); addColumnFigure(diagram, tableFigure, indexFigure, index, isFirst, false); if (selected) { indexFigure.setBackgroundColor(ColorConstants.titleBackground); indexFigure.setForegroundColor(ColorConstants.titleForeground); } } else { indexFigure.clearLabel(); return; } }
Example #29
Source File: ReportFlowLayout.java From birt with Eclipse Public License 1.0 | 5 votes |
protected Insets getFigureMargin( IFigure f ) { ReportItemConstraint constraint = (ReportItemConstraint) getConstraint( f ); Insets margin = INSETS_SINGLETON; if ( constraint != null ) margin = constraint.getMargin( ); if ( ( margin == null || margin == INSETS_SINGLETON ) && f instanceof IReportElementFigure ) { margin = ( (IReportElementFigure) f ).getMargin( ); } return margin; }
Example #30
Source File: PrintERDiagramOperation.java From erflute with Apache License 2.0 | 5 votes |
private Rectangle shrink(Rectangle bounds, Insets insets) { final Rectangle shrinked = bounds.getCopy(); shrinked.x += insets.left; shrinked.y += insets.top; shrinked.width -= insets.getWidth(); shrinked.height -= insets.getHeight(); return shrinked; }