org.eclipse.draw2d.Graphics Java Examples
The following examples show how to use
org.eclipse.draw2d.Graphics.
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: PrintERDiagramOperation.java From ermaster-b with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ @Override protected void printPages() { Graphics graphics = getFreshPrinterGraphics(); IFigure figure = getPrintSource(); setupPrinterGraphicsFor(graphics, figure); Rectangle bounds = figure.getBounds(); int x = bounds.x, y = bounds.y; Rectangle clipRect = new Rectangle(); while (y < bounds.y + bounds.height) { while (x < bounds.x + bounds.width) { graphics.pushState(); getPrinter().startPage(); graphics.translate(-x, -y); graphics.getClip(clipRect); clipRect.setLocation(x, y); graphics.clipRect(clipRect); figure.paint(graphics); getPrinter().endPage(); graphics.popState(); x += clipRect.width; } x = bounds.x; y += clipRect.height; } }
Example #2
Source File: ScaledSliderFigure.java From nebula with Eclipse Public License 2.0 | 6 votes |
@Override protected void paintClientArea(Graphics graphics) { super.paintClientArea(graphics); if(hasFocus() && drawFocus){ graphics.setForegroundColor(ColorConstants.black); graphics.setBackgroundColor(ColorConstants.white); Rectangle area = getClientArea(); graphics.drawFocus(area.x, area.y, area.width-1, area.height-1); } if(!isEnabled()) { graphics.setAlpha(DISABLED_ALPHA); graphics.setBackgroundColor(GRAY_COLOR); graphics.fillRectangle(bounds); } }
Example #3
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 #4
Source File: MultipleGuideHandle.java From birt with Eclipse Public License 1.0 | 6 votes |
protected void paintFigure( Graphics graphics ) { Rectangle rect = getBounds( ); graphics.setLineWidth( 2 ); graphics.drawRectangle( rect ); graphics.drawLine( rect.x, rect.y - 1, rect.x + rect.width, rect.y - 1 ); graphics.drawLine( rect.x, rect.y, rect.x, rect.y + rect.height ); graphics.setLineWidth( 3 ); graphics.drawLine( rect.x + rect.width, rect.y, rect.x + rect.width, rect.y + rect.height ); graphics.drawLine( rect.x, rect.y + rect.height, rect.x + rect.width, rect.y + rect.height ); }
Example #5
Source File: SVGFigure.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@Override protected void paintFigure(final Graphics graphics) { super.paintFigure(graphics); Document document = getDocument(); if (document == null) { return; } Image image = null; try { final Rectangle r = getClientArea(); transcoder.setCanvasSize(specifyCanvasWidth ? r.width : -1, specifyCanvasHeight ? r.height : -1); updateRenderingHints(graphics); final BufferedImage awtImage = transcoder.getBufferedImage(); if (awtImage != null) { image = toSWT(Display.getCurrent(), awtImage); graphics.drawImage(image, r.x, r.y); } } finally { if (image != null) { image.dispose(); } document = null; } }
Example #6
Source File: ChartFigure.java From neoscada with Eclipse Public License 1.0 | 6 votes |
@Override protected void paintClientArea ( final Graphics graphics ) { if ( this.renderer != null ) { final Draw2DGraphics g = new Draw2DGraphics ( graphics, this.resourceManager.getDevice () ); try { this.renderer.paint ( g ); } finally { g.dispose (); } } }
Example #7
Source File: FirstLevelHandleDataItemFigure.java From birt with Eclipse Public License 1.0 | 6 votes |
private void paintTriangle( Graphics graphics ) { graphics.pushState( ); Rectangle rect = super.getClientArea(); //int x = bounds.x + ( bounds.width - rect.width ) / 2; // int y = bounds.y + ( bounds.height - rect.height ) / 2; Point center = getCenterPoint( rect ); graphics.setBackgroundColor( Display.getCurrent( ) .getSystemColor( SWT.COLOR_BLACK ) ); ReportFigureUtilities.paintTriangle( graphics, TRIANGLE_HEIGHT, center ); graphics.popState( ); }
Example #8
Source File: EditorRulerFigure.java From birt with Eclipse Public License 1.0 | 6 votes |
private boolean canDrawNumber(String num, Point startPoint ,Graphics g) { Transposer transposer = new Transposer(); transposer.setEnabled( !isHorizontal() ); Rectangle rect = transposer.t( g.getClip( Rectangle.SINGLETON )); Dimension strSize = FigureUtilities.getStringExtents(num, getFont()); startPoint = transposer.t(startPoint); if (strSize.width + startPoint.x > rect.x + rect.width) { return false; } rect = transposer.t( getEndRect( g .getClip( Rectangle.SINGLETON ) )); if (rect.width == 0) { return true; } if (strSize.width + startPoint.x > rect.x) { return false; } return true; }
Example #9
Source File: ProductSystemFigure.java From olca-app with Mozilla Public License 2.0 | 6 votes |
@Override public void paint(Graphics graphics) { if (firstTime) { if (doPaint) { doPaint = checkAndAsk(); } } if (doPaint) { for (Node node : node.children) { ProcessNode pNode = (ProcessNode) node; if (!pNode.figure.isVisible()) { pNode.figure.setVisible(true); } } if (firstTime) { firePropertyChange("firstTimeInitialized", null, "not null"); } super.paint(graphics); if (firstTime) { ((GraphLayoutManager) getLayoutManager()).layoutTree(); firstTime = false; } } paintInfoBox(graphics); }
Example #10
Source File: PrintERDiagramOperation.java From ermasterr with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ @Override protected void printPages() { final Graphics graphics = getFreshPrinterGraphics(); final IFigure figure = getPrintSource(); setupPrinterGraphicsFor(graphics, figure); final Rectangle bounds = figure.getBounds(); int x = bounds.x, y = bounds.y; final Rectangle clipRect = new Rectangle(); while (y < bounds.y + bounds.height) { while (x < bounds.x + bounds.width) { graphics.pushState(); getPrinter().startPage(); graphics.translate(-x, -y); graphics.getClip(clipRect); clipRect.setLocation(x, y); graphics.clipRect(clipRect); figure.paint(graphics); getPrinter().endPage(); graphics.popState(); x += clipRect.width; } x = bounds.x; y += clipRect.height; } }
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: CrossAnnotation.java From nebula with Eclipse Public License 2.0 | 6 votes |
@Override protected void paintFigure(Graphics graphics) { if (trace != null && currentSnappedSample == null && !pointerDragged) updateToDefaultPosition(); if (Preferences.useAdvancedGraphics()) graphics.setAntialias(SWT.ON); graphics.setForegroundColor(getForegroundColor()); xValue = currentSnappedSample.getXValue(); yValue = currentSnappedSample.getYValue(); int x = xAxis.getValuePosition(xValue, false); int y = yAxis.getValuePosition(yValue, false); Point p = new Point(); p.setLocation(y, x); graphics.drawLine(x - CROSS_SIZE, y - CROSS_SIZE, x + CROSS_SIZE, y + CROSS_SIZE); graphics.drawLine(x - CROSS_SIZE, y + CROSS_SIZE, x + CROSS_SIZE, y - CROSS_SIZE); graphics.drawLine(x, y + CROSS_SIZE, x, y - CROSS_SIZE); graphics.drawLine(x - CROSS_SIZE, y, x + CROSS_SIZE, y); }
Example #13
Source File: CustomTextAnnotation2EditPart.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
public void paintGradient(Graphics graphics) { Rectangle rect = getClientArea(); if (rect == null) return; graphics.pushState(); Color from = ColorConstants.white; Color to = getBackgroundColor(); graphics.setForegroundColor(from); graphics.setBackgroundColor(to); graphics.fillGradient(rect, false); graphics.popState(); //now drawing the outline shape super.outlineShape(graphics); }
Example #14
Source File: SaveImageAction.java From olca-app with Mozilla Public License 2.0 | 6 votes |
@Override public void run() { if (file == null) return; log.trace("export product graph as image: {}", file); ScalableRootEditPart editPart = (ScalableRootEditPart) editor.getGraphicalViewer().getRootEditPart(); IFigure rootFigure = editPart.getLayer(LayerConstants.PRINTABLE_LAYERS); Rectangle bounds = rootFigure.getBounds(); Image img = new Image(null, bounds.width, bounds.height); GC imageGC = new GC(img); Graphics graphics = new SWTGraphics(imageGC); rootFigure.paint(graphics); ImageLoader imgLoader = new ImageLoader(); imgLoader.data = new ImageData[] { img.getImageData() }; imgLoader.save(file.getAbsolutePath(), SWT.IMAGE_PNG); }
Example #15
Source File: EditorRulerRootEditPart.java From birt with Eclipse Public License 1.0 | 6 votes |
/** * @see org.eclipse.draw2d.Figure#paintBorder(org.eclipse.draw2d.Graphics) */ protected void paintBorder( Graphics graphics ) { super.paintBorder( graphics ); if ( this.getContents( ) != null && ( (EditorRulerFigure) this.getContents( ) ) .getDrawFocus( ) ) { Rectangle focusBounds = getBounds( ).getCopy( ); if ( ( (EditorRulerFigure) this.getContents( ) ).isHorizontal( ) ) { focusBounds.resize( -2, -4 ); focusBounds.x++; } else { focusBounds.resize( -4, -2 ); focusBounds.y++; } graphics.setForegroundColor( ColorConstants.black ); graphics.setBackgroundColor( ColorConstants.white ); graphics.drawFocus( focusBounds ); } }
Example #16
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 #17
Source File: ListBandControlFigure.java From birt with Eclipse Public License 1.0 | 6 votes |
protected void paintFigure( Graphics graphics ) { // graphics.setBackgroundColor( ColorConstants.white ); Rectangle rect = getBounds( ).getCopy( ).shrink( 6, 6 ); graphics.fillRectangle( rect ); IFigure parent = this; while ( ( parent = parent.getParent( ) ) != null ) { if ( parent instanceof ReportShowFigure ) { state = ( (ReportShowFigure) parent ).isControlShowing( ); break; } } ReportFigureUtilities.paintExpandHandle( graphics, 8, getBounds( ).getCenter( ), !state ); }
Example #18
Source File: NoteFigure.java From ermasterr with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ @Override protected void fillShape(final Graphics graphics) { graphics.setAlpha(200); final Rectangle bounds = getBounds(); final Point topRight1 = bounds.getTopRight().translate(0, RETURN_WIDTH); final Point topRight2 = bounds.getTopRight().translate(-RETURN_WIDTH, 0); final PointList pointList = new PointList(); pointList.addPoint(bounds.getTopLeft()); pointList.addPoint(bounds.getBottomLeft()); pointList.addPoint(bounds.getBottomRight()); pointList.addPoint(topRight1); pointList.addPoint(topRight2); pointList.addPoint(bounds.getTopLeft()); graphics.fillPolygon(pointList); }
Example #19
Source File: GridLayer.java From nebula with Eclipse Public License 2.0 | 5 votes |
private void paintGrid(Graphics graphics) { final ITimelineStyleProvider styleProvider = RootFigure.getRootFigure(this).getStyleProvider(); graphics.setLineStyle(styleProvider.getGridLineStyle()); final Rectangle bounds = getBounds(); final Map<Double, Integer> markerPositions = RootFigure.getFigure(this, DetailFigure.class).getMarkerPositions(); for (final int position : markerPositions.values()) graphics.drawLine(position + bounds.x(), bounds.y, position + bounds.x(), bounds.y + bounds.height); }
Example #20
Source File: IndexFigure.java From ermaster-b with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override protected void paintFigure(Graphics graphics) { if (graphics.getBackgroundColor().equals( this.getParent().getBackgroundColor())) { graphics.setAlpha(0); } super.paintFigure(graphics); }
Example #21
Source File: ReportPrintGraphicalViewerOperation.java From birt with Eclipse Public License 1.0 | 5 votes |
/** * Prints the pages based on the current print mode. * * @see org.eclipse.draw2d.PrintOperation#printPages() */ protected void printPages( ) { Graphics graphics = getFreshGraphics( ); IFigure figure = getPrintSource( ); setupPrinterGraphicsFor( graphics, figure ); Rectangle bounds = figure.getBounds( ); int x = bounds.x, y = bounds.y; Rectangle clipRect = new Rectangle( ); while ( y < bounds.y + bounds.height ) { while ( x < bounds.x + bounds.width ) { graphics.pushState( ); graphics.translate( -x, -y ); graphics.getClip( clipRect ); clipRect.setLocation( x, y ); graphics.clipRect( clipRect ); figure.paint( graphics ); graphics.popState( ); x += clipRect.width; if ( x == 0 ) { return; } } x = bounds.x; y += clipRect.height; } }
Example #22
Source File: StatisticFigure.java From olca-app with Mozilla Public License 2.0 | 5 votes |
private void paintBoxes(Graphics graphics, Point boxSize) { graphics.setBackgroundColor(ColorConstants.lightGray); int height = getSize().height - marginBottom; for (int interval = 0; interval < 100; interval++) { int frequency = hist.getAbsoluteFrequency(interval); for (int block = 1; block <= frequency; block++) { int x = marginLeft + interval * boxSize.x; int y = height - block * boxSize.y; if (y >= marginTop) drawBox(graphics, boxSize, new Point(x, y)); } } graphics.setBackgroundColor(ColorConstants.white); }
Example #23
Source File: ProcessTextNonResizableEditPolicy.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
/** * @generated */ protected IFigure createFocusFeedbackFigure() { return new Figure() { protected void paintFigure(Graphics graphics) { graphics.drawFocus(getBounds().getResized(-1, -1)); } }; }
Example #24
Source File: ManualOverride.java From neoscada with Eclipse Public License 1.0 | 5 votes |
/** * Set graphics attribute according to the connection state * * @param connection * the connection to change * @param state * the state */ protected void setConnectionState ( final PolylineConnection connection, final boolean state ) { final PolygonDecoration dec = new PolygonDecoration (); dec.setTemplate ( PolygonDecoration.TRIANGLE_TIP ); connection.setLineStyle ( state ? Graphics.LINE_SOLID : Graphics.LINE_DOT ); connection.setLineWidth ( state ? 2 : 1 ); connection.setTargetDecoration ( state ? dec : null ); }
Example #25
Source File: XYGraphToolbar.java From nebula with Eclipse Public License 2.0 | 5 votes |
@Override protected void paintClientArea(Graphics graphics) { super.paintClientArea(graphics); graphics.setForegroundColor(GRAY_COLOR); graphics.setLineWidth(1); graphics.drawLine(bounds.x + bounds.width / 2, bounds.y, bounds.x + bounds.width / 2, bounds.y + bounds.height); }
Example #26
Source File: ProcessFigure.java From olca-app with Mozilla Public License 2.0 | 5 votes |
private void paintBody(Graphics g) { Rectangle rect = new Rectangle(getLocation(), getSize()); g.fillRoundRectangle(rect, 15, 15); String singleVal = format(node.directResult); String singlePerc = format(node.directContribution * 100); String totalVal = format(node.upstreamResult); String totalPerc = format(node.upstreamContribution * 100); String single = singleVal + " (" + singlePerc + "%)"; String total = totalVal + " (" + totalPerc + "%)"; drawTexts(g, single, total); drawDqBar(g); }
Example #27
Source File: CircleAnnotation.java From nebula with Eclipse Public License 2.0 | 5 votes |
@Override protected void paintFigure(Graphics graphics) { if (trace != null && currentSnappedSample == null && !pointerDragged) updateToDefaultPosition(); if (Preferences.useAdvancedGraphics()) graphics.setAntialias(SWT.ON); graphics.setForegroundColor(Display.getCurrent().getSystemColor(SWT.COLOR_RED)); xValue = currentSnappedSample.getXValue(); yValue = currentSnappedSample.getYValue(); int x = xAxis.getValuePosition(xValue, false); int y = yAxis.getValuePosition(yValue, false); graphics.drawOval(x - (CIRCLE_DIAMETER / 2), y - (CIRCLE_DIAMETER / 2), CIRCLE_DIAMETER, CIRCLE_DIAMETER); }
Example #28
Source File: ArcShape.java From neoscada with Eclipse Public License 1.0 | 5 votes |
@Override protected void outlineShape ( final Graphics graphics ) { final float lineInset = Math.max ( 1.0f, getLineWidthFloat () ) / 2.0f; final int inset1 = (int)Math.floor ( lineInset ); final int inset2 = (int)Math.ceil ( lineInset ); final Rectangle r = Rectangle.SINGLETON.setBounds ( getBounds () ); r.x += inset1; r.y += inset1; r.width -= inset1 + inset2; r.height -= inset1 + inset2; graphics.drawArc ( r, (int)this.start, (int)this.length ); }
Example #29
Source File: DropShadowRectangle.java From ermasterr with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override protected void outlineShape(final Graphics graphics) { final Rectangle f = Rectangle.SINGLETON.setBounds(getBounds()); final Insets shadowInset = new Insets(getLineWidth() / 2, getLineWidth() / 2, getLineWidth() + SHADOW_INSET, getLineWidth() + SHADOW_INSET); shrink(f, shadowInset); final Dimension cornerDimensions = getCornerDimensions(); graphics.drawRoundRectangle(f, cornerDimensions.width, cornerDimensions.height); }
Example #30
Source File: DropShadowRectangle.java From erflute with Apache License 2.0 | 5 votes |
@SuppressWarnings("deprecation") @Override protected void outlineShape(Graphics graphics) { final Rectangle f = Rectangle.SINGLETON.setBounds(getBounds()); final Insets shadowInset = new Insets(getLineWidth() / 2, getLineWidth() / 2, getLineWidth() + SHADOW_INSET, getLineWidth() + SHADOW_INSET); shrink(f, shadowInset); graphics.drawRoundRectangle(f, corner.width, corner.height); }