Java Code Examples for org.eclipse.draw2d.Graphics#setBackgroundColor()
The following examples show how to use
org.eclipse.draw2d.Graphics#setBackgroundColor() .
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: GaugeFigure.java From nebula with Eclipse Public License 2.0 | 6 votes |
@Override protected void fillShape(Graphics graphics) { graphics.setAntialias(SWT.ON); Pattern pattern = null; graphics.setBackgroundColor(GRAY_COLOR); if(support3D == null) support3D = GraphicsUtil.testPatternSupported(graphics); if(effect3D && support3D){ pattern = GraphicsUtil.createScaledPattern(graphics, Display.getCurrent(), bounds.x, bounds.y, bounds.x + bounds.width, bounds.y + bounds.height, WHITE_COLOR, BORDER_COLOR); graphics.setBackgroundPattern(pattern); } super.fillShape(graphics); if(effect3D && support3D) pattern.dispose(); }
Example 2
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 3
Source File: ERDecoration.java From ermasterr with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ @Override public void paintFigure(final Graphics graphics) { final ERDiagramConnection connection = (ERDiagramConnection) getParent(); graphics.setAntialias(SWT.ON); final Color color = connection.getColor(); if (color != null) { graphics.setForegroundColor(color); graphics.setBackgroundColor(color); } super.paintFigure(graphics); }
Example 4
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 5
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 6
Source File: KnobFigure.java From nebula with Eclipse Public License 2.0 | 6 votes |
@Override protected void fillShape(Graphics graphics) { graphics.setAntialias(SWT.ON); Pattern pattern = null; graphics.setBackgroundColor(thumbColor); boolean support3D = GraphicsUtil.testPatternSupported(graphics); if(support3D && effect3D){ try { graphics.setBackgroundColor(thumbColor); super.fillShape(graphics); pattern = GraphicsUtil.createScaledPattern(graphics, Display.getCurrent(), bounds.x, bounds.y, bounds.x + bounds.width, bounds.y + bounds.height, WHITE_COLOR, 0, WHITE_COLOR, 255); graphics.setBackgroundPattern(pattern); } catch (Exception e) { support3D = false; pattern.dispose(); } } super.fillShape(graphics); if(effect3D && support3D) pattern.dispose(); graphics.setForegroundColor(thumbColor); }
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: ProgressBarFigure.java From nebula with Eclipse Public License 2.0 | 5 votes |
@Override protected void fillShape(Graphics g) { g.setAntialias(SWT.ON); g.setClip(new Rectangle(getBounds().x, getBounds().y, getBounds().width, getBounds().height)); g.setBackgroundColor(WHITE_COLOR); super.fillShape(g); Point leftPoint = getPoints().getPoint(0); Point rightPoint; //if(horizontal) rightPoint = getPoints().getPoint(2); //else // rightPoint = getPoints().getPoint(1);//.translate(0, -BREADTH/2); Pattern thumbPattern = null; boolean support3D = GraphicsUtil.testPatternSupported(g); setOutline(effect3D && support3D); if(effect3D && support3D) { thumbPattern = GraphicsUtil.createScaledPattern(g, Display.getCurrent(), leftPoint.x, leftPoint.y, rightPoint.x, rightPoint.y, WHITE_COLOR, 0, fillColor, 255); g.setBackgroundPattern(thumbPattern); }else g.setBackgroundColor(fillColor); g.fillPolygon(getPoints()); if(effect3D && support3D) thumbPattern.dispose(); }
Example 9
Source File: ThermometerFigure.java From nebula with Eclipse Public License 2.0 | 5 votes |
@Override protected void outlineShape(Graphics graphics) { boolean support3D = false; if(effect3D) support3D = GraphicsUtil.testPatternSupported(graphics); if(effect3D && support3D) graphics.setForegroundColor(EFFECT3D_BULB_COLOR); else graphics.setForegroundColor(BLACK_COLOR); super.outlineShape(graphics); //draw a small rectangle to hide the joint if(effect3D && support3D) { graphics.setBackgroundColor(fillColor); graphics.fillRectangle(new Rectangle(pipe.getBounds().x + pipe.getLineWidth(), ((LinearScale) scale).getValuePosition(scale.getRange().getLower(), false), Pipe.PIPE_WIDTH- pipe.getLineWidth() *2, 2)); Pattern backPattern = GraphicsUtil.createScaledPattern(graphics, Display.getCurrent(), pipe.getBounds().x, ((LinearScale) scale).getValuePosition(scale.getRange().getLower(), false), pipe.getBounds().x + Pipe.PIPE_WIDTH, ((LinearScale) scale).getValuePosition(scale.getRange().getLower(), false), WHITE_COLOR,255, fillColor, 0); graphics.setBackgroundPattern(backPattern); graphics.fillRectangle(new Rectangle(pipe.getBounds().x + pipe.getLineWidth(), ((LinearScale) scale).getValuePosition(scale.getRange().getLower(), false), Pipe.PIPE_WIDTH- pipe.getLineWidth() *2, 2)); backPattern.dispose(); }else{ graphics.setBackgroundColor(fillColor); graphics.fillRoundRectangle(new Rectangle(pipe.getBounds().x + pipe.getLineWidth(), ((LinearScale) scale).getValuePosition(scale.getRange().getLower(), false), Pipe.PIPE_WIDTH- pipe.getLineWidth() *2, ((LinearScale) scale).getMargin()), Pipe.FILL_CORNER, Pipe.FILL_CORNER); } }
Example 10
Source File: ScaledSliderFigure.java From nebula with Eclipse Public License 2.0 | 5 votes |
@Override protected void fillShape(Graphics g) { g.setAntialias(SWT.ON); g.setClip(new Rectangle(getBounds().x, getBounds().y, getBounds().width, getBounds().height)); g.setBackgroundColor(WHITE_COLOR); super.fillShape(g); Point leftPoint = getPoints().getPoint(0); Point rightPoint; if(horizontal) rightPoint = getPoints().getPoint(4); else rightPoint = getPoints().getPoint(1);//.translate(0, -BREADTH/2); Pattern thumbPattern = null; boolean support3D = GraphicsUtil.testPatternSupported(g); if(effect3D && support3D) { thumbPattern = GraphicsUtil.createScaledPattern(g, Display.getCurrent(), leftPoint.x, leftPoint.y, rightPoint.x, rightPoint.y, WHITE_COLOR, 0, thumbColor, 255); g.setBackgroundPattern(thumbPattern); }else g.setBackgroundColor(thumbColor); g.fillPolygon(getPoints()); if(effect3D && support3D) thumbPattern.dispose(); }
Example 11
Source File: ChoiceFigure.java From statecharts with Eclipse Public License 1.0 | 5 votes |
/** * @see org.eclipse.draw2d.Shape#fillShape(org.eclipse.draw2d.Graphics) */ @Override protected void fillShape(Graphics graphics) { graphics.pushState(); graphics.setForegroundColor(getForegroundColor()); graphics.setBackgroundColor(getBackgroundColor()); PointList pl = new PointList(); pl.addPoint(getBounds().getTop()); pl.addPoint(getBounds().getRight()); pl.addPoint(getBounds().getBottom()); pl.addPoint(getBounds().getLeft()); graphics.fillPolygon(pl); graphics.popState(); }
Example 12
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 13
Source File: ListBandControlFigure.java From birt with Eclipse Public License 1.0 | 5 votes |
protected void paintFigure( Graphics graphics ) { graphics.setForegroundColor( ReportColorConstants.ShadowLineColor ); graphics.setLineStyle( SWT.LINE_SOLID ); graphics.drawRectangle( getBounds( ).getCopy( ).shrink( 2, 1 ) ); graphics.setBackgroundColor( ReportColorConstants.ListControlFillColor ); graphics.fillRectangle( getBounds( ).getCopy( ).shrink( 3, 2 ) ); }
Example 14
Source File: PrintERDiagramOperation.java From erflute with Apache License 2.0 | 5 votes |
@Override protected void setupPrinterGraphicsFor(Graphics graphics, IFigure figure) { final ERDiagram diagram = getDiagram(); final PageSettings pageSetting = diagram.getPageSetting(); final double dpiScale = (double) getPrinter().getDPI().x / Display.getCurrent().getDPI().x * pageSetting.getScale() / 100; final Rectangle printRegion = getPrintRegion(); // put the print region in display coordinates printRegion.width /= dpiScale; printRegion.height /= dpiScale; final Rectangle bounds = figure.getBounds(); final double xScale = (double) printRegion.width / bounds.width; final double yScale = (double) printRegion.height / bounds.height; switch (getPrintMode()) { case FIT_PAGE: graphics.scale(Math.min(xScale, yScale) * dpiScale); break; case FIT_WIDTH: graphics.scale(xScale * dpiScale); break; case FIT_HEIGHT: graphics.scale(yScale * dpiScale); break; default: graphics.scale(dpiScale); } graphics.setForegroundColor(figure.getForegroundColor()); graphics.setBackgroundColor(figure.getBackgroundColor()); graphics.setFont(figure.getFont()); }
Example 15
Source File: ProductSystemFigure.java From olca-app with Mozilla Public License 2.0 | 5 votes |
private void drawColorScale(Graphics graphics) { int x = 25; int y = 140; for (int i = -100; i < 100; i += 2) { graphics.setBackgroundColor(Colors.getForContribution(i / 100d)); int posX = x + 3 * ((100 + i) / 2); graphics.fillRectangle(new Rectangle(posX, y, 4, 20)); } // draw percentage texts graphics.drawText(M.Sankey_ScaleDescription, x + 35, y + 22); graphics.drawLine(x, y, x + 300, y); for (int i = 0; i <= 20; i++) { int height = 0; if (i == 0 || i == 20) { height = 19; } else if (i % 2 == 0) { height = 12; } else { height = 6; } graphics.drawLine(x + 15 * i, y, x + 15 * i, y + height); String percentage = "" + (i * 10 - 100); if (i % 2 == 0) { int left = 5 * (percentage.length() - 1); if (i == 10) { left += 2; } else if (i == 0 || i == 20) { left -= 1; } graphics.drawText(percentage, x + 15 * i - left, y - 16); } } }
Example 16
Source File: ProcessFigure.java From olca-app with Mozilla Public License 2.0 | 5 votes |
@Override protected void paintFigure(Graphics g) { g.pushState(); g.setBackgroundColor(ColorConstants.white); g.fillRectangle(new Rectangle(getLocation(), getSize())); paintTop(g); if (!node.isMinimized() || Animation.isRunning()) paintTable(g); g.popState(); super.paintFigure(g); }
Example 17
Source File: ThermometerFigure.java From nebula with Eclipse Public License 2.0 | 4 votes |
@Override protected void fillShape(Graphics graphics) { corner.height =PIPE_WIDTH/2; corner.width = PIPE_WIDTH/2; graphics.setBackgroundColor(fillBackgroundColor); int valuePosition = ((LinearScale) scale).getValuePosition(getCoercedValue(), false); if(maximum > minimum){ if(value > maximum) valuePosition -= 10; else if(value < minimum) valuePosition +=10; }else{ if(value > minimum) valuePosition += 10; else if(value < maximum) valuePosition -=10; } boolean support3D = false; if(effect3D) support3D = GraphicsUtil.testPatternSupported(graphics); if(effect3D && support3D){ graphics.setForegroundColor(EFFECT3D_PIPE_COLOR); //fill back super.fillShape(graphics); Pattern backPattern = GraphicsUtil.createScaledPattern(graphics, Display.getCurrent(), bounds.x, bounds.y, bounds.x+bounds.width, bounds.y, WHITE_COLOR,255, fillBackgroundColor, 0); graphics.setBackgroundPattern(backPattern); super.fillShape(graphics); backPattern.dispose(); //fill value graphics.setBackgroundColor(fillColor); graphics.fillRoundRectangle(new Rectangle(bounds.x + lineWidth, valuePosition, bounds.width - 2* lineWidth, bounds.height - (valuePosition - bounds.y)), FILL_CORNER, FILL_CORNER); backPattern = GraphicsUtil.createScaledPattern(graphics, Display.getCurrent(), bounds.x, bounds.y, bounds.x+bounds.width, bounds.y, WHITE_COLOR,255, fillColor, 0); graphics.setBackgroundPattern(backPattern); graphics.fillRoundRectangle(new Rectangle(bounds.x + lineWidth, valuePosition, bounds.width - 2* lineWidth, bounds.height - (valuePosition - bounds.y)), FILL_CORNER, FILL_CORNER); backPattern.dispose(); } else { super.fillShape(graphics); graphics.setBackgroundColor(fillColor); graphics.fillRoundRectangle(new Rectangle(bounds.x + lineWidth, valuePosition, bounds.width - 2* lineWidth, bounds.height - (valuePosition - bounds.y)), FILL_CORNER, FILL_CORNER); } }
Example 18
Source File: RootDragTracker.java From birt with Eclipse Public License 1.0 | 4 votes |
/** * @see org.eclipse.draw2d.Figure#paintFigure(org.eclipse.draw2d.Graphics) */ protected void paintFigure( Graphics graphics ) { Rectangle bounds = getBounds( ).getCopy( ); graphics.translate( getLocation( ) ); graphics.setXORMode( true ); graphics.setForegroundColor( ColorConstants.white ); graphics.setBackgroundColor( ColorConstants.black ); graphics.setLineStyle( Graphics.LINE_DOT ); int[] points = new int[6]; points[0] = 0 + offset; points[1] = 0; points[2] = bounds.width - 1; points[3] = 0; points[4] = bounds.width - 1; points[5] = bounds.height - 1; graphics.drawPolyline( points ); points[0] = 0; points[1] = 0 + offset; points[2] = 0; points[3] = bounds.height - 1; points[4] = bounds.width - 1; points[5] = bounds.height - 1; graphics.drawPolyline( points ); graphics.translate( getLocation( ).getNegated( ) ); if ( schedulePaint ) { Display.getCurrent( ).timerExec( DELAY, new Runnable( ) { public void run( ) { offset++; if ( offset > 5 ) offset = 0; schedulePaint = true; repaint( ); } } ); } schedulePaint = false; }
Example 19
Source File: ScaledSliderFigure.java From nebula with Eclipse Public License 2.0 | 4 votes |
@Override protected void fillShape(Graphics graphics) { graphics.setAntialias(SWT.ON); int valuePosition = ((LinearScale) scale).getValuePosition(getCoercedValue(), false); boolean support3D = GraphicsUtil.testPatternSupported(graphics); if(effect3D && support3D) { //fill background graphics.setBackgroundColor(fillBackgroundColor); super.fillShape(graphics); Pattern backGroundPattern; if(horizontal) backGroundPattern= GraphicsUtil.createScaledPattern(graphics, Display.getCurrent(), bounds.x, bounds.y, bounds.x, bounds.y + bounds.height, WHITE_COLOR, 255, fillBackgroundColor, 0); else backGroundPattern= GraphicsUtil.createScaledPattern(graphics, Display.getCurrent(), bounds.x, bounds.y, bounds.x + bounds.width, bounds.y, WHITE_COLOR, 255, fillBackgroundColor, 0); graphics.setBackgroundPattern(backGroundPattern); super.fillShape(graphics); graphics.setForegroundColor(fillBackgroundColor); outlineShape(graphics); backGroundPattern.dispose(); //fill value if(horizontal) backGroundPattern = GraphicsUtil.createScaledPattern(graphics, Display.getCurrent(), bounds.x, bounds.y, bounds.x, bounds.y + bounds.height, WHITE_COLOR, 255, fillColor, 0); else backGroundPattern = GraphicsUtil.createScaledPattern(graphics, Display.getCurrent(), bounds.x, bounds.y, bounds.x + bounds.width, bounds.y, WHITE_COLOR, 255, fillColor, 0); graphics.setBackgroundColor(fillColor); graphics.setForegroundColor(fillColor); if(horizontal){ int fillWidth = valuePosition - bounds.x; graphics.fillRectangle(new Rectangle(bounds.x, bounds.y, fillWidth, bounds.height)); graphics.setBackgroundPattern(backGroundPattern); graphics.fillRectangle(new Rectangle(bounds.x, bounds.y, fillWidth, bounds.height)); graphics.drawRectangle(new Rectangle(bounds.x + lineWidth / 2, bounds.y + lineWidth / 2, fillWidth - Math.max(1, lineWidth), bounds.height - Math.max(1, lineWidth))); }else { int fillHeight = bounds.height - (valuePosition - bounds.y); graphics.fillRectangle(new Rectangle(bounds.x, valuePosition, bounds.width, fillHeight)); graphics.setBackgroundPattern(backGroundPattern); graphics.fillRectangle(new Rectangle(bounds.x, valuePosition, bounds.width, fillHeight)); graphics.drawRectangle(new Rectangle(bounds.x + lineWidth / 2, valuePosition+ lineWidth / 2, bounds.width- Math.max(1, lineWidth), fillHeight - Math.max(1, lineWidth))); } backGroundPattern.dispose(); }else { graphics.setBackgroundColor(fillBackgroundColor); super.fillShape(graphics); graphics.setBackgroundColor(fillColor); if(horizontal) graphics.fillRectangle(new Rectangle(bounds.x, bounds.y, valuePosition - bounds.x, bounds.height)); else graphics.fillRectangle(new Rectangle(bounds.x, valuePosition, bounds.width, bounds.height - (valuePosition - bounds.y))); // graphics.setForegroundColor(outlineColor); } }
Example 20
Source File: RowHandle.java From birt with Eclipse Public License 1.0 | 4 votes |
protected void paintFigure( Graphics graphics ) { if ( isSelect( ) ) { graphics.setBackgroundColor( ReportColorConstants.SelctionFillColor ); } else { graphics.setBackgroundColor( ReportColorConstants.TableGuideFillColor ); } graphics.setLineStyle( SWT.LINE_SOLID ); Rectangle bounds = getBounds( ).getCopy( ).resize( -1, -1 ); graphics.fillRectangle( bounds ); Font font = FontManager.getFont( "Dialog", 7, SWT.NORMAL );//$NON-NLS-1$ graphics.setFont( font ); Image image = getImage( ); if ( image == null ) return; graphics.setForegroundColor( ColorConstants.white ); graphics.setXORMode( true ); org.eclipse.swt.graphics.Rectangle rect = image.getBounds( ); int x = bounds.x + ( bounds.width - rect.width ) / 2; int y = bounds.y + ( bounds.height - rect.height ) / 2; graphics.drawImage( image, x, y ); TableEditPart part = (TableEditPart) getOwner( ); RowHandleAdapter rowHandleAdapter = HandleAdapterFactory.getInstance( ) .getRowHandleAdapter( part.getRow( getRowNumber( ) ) ); String type = rowHandleAdapter.getType( ); String displayName = rowHandleAdapter.getDisplayName( ); if ( TableHandleAdapter.TABLE_GROUP_HEADER.equals( type ) || TableHandleAdapter.TABLE_GROUP_FOOTER.equals( type ) ) { graphics.drawString( displayName, x + rect.width + 2, y + 2 ); } graphics.setBackgroundColor( ColorConstants.black ); // ReportFigureUtilities.paintBevel( graphics, // getBounds( ).getCopy( ), // true ); graphics.setXORMode( false ); }