Java Code Examples for org.eclipse.draw2d.Graphics#setForegroundColor()
The following examples show how to use
org.eclipse.draw2d.Graphics#setForegroundColor() .
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: 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 2
Source File: DirectEditManagerEx.java From statecharts with Eclipse Public License 1.0 | 6 votes |
public void paint(IFigure figure, Graphics graphics, Insets insets) { Rectangle rect = getPaintRectangle(figure, insets); graphics.setForegroundColor(ColorConstants.white); graphics.drawLine(rect.x, rect.y, rect.x, rect.bottom()); rect.x++; rect.width--; rect.resize(-1, -1); graphics.setForegroundColor(ColorConstants.black); graphics.drawLine(rect.x + 2, rect.bottom(), rect.right(), rect.bottom()); graphics.drawLine(rect.right(), rect.bottom(), rect.right(), rect.y + 2); rect.resize(-1, -1); graphics.setForegroundColor(BLUE); graphics.drawRectangle(rect); }
Example 3
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 4
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 5
Source File: Grid.java From nebula with Eclipse Public License 2.0 | 6 votes |
@Override protected void paintFigure(Graphics graphics) { super.paintFigure(graphics); graphics.pushState(); if (axis.isShowMajorGrid()) { graphics.setLineStyle(axis.isDashGridLine() ? SWTConstants.LINE_DASH : SWTConstants.LINE_SOLID); graphics.setForegroundColor(axis.getMajorGridColor()); graphics.setLineWidth(1); for (int pos : axis.getScaleTickLabels().getTickLabelPositions()) { if (axis.isHorizontal()) graphics.drawLine(axis.getBounds().x + pos, bounds.y + bounds.height, axis.getBounds().x + pos, bounds.y); else graphics.drawLine(bounds.x, axis.getBounds().y + axis.getBounds().height - pos, bounds.x + bounds.width, axis.getBounds().y + axis.getBounds().height - pos); } } graphics.popState(); }
Example 6
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 7
Source File: EditorGuideEditPart.java From birt with Eclipse Public License 1.0 | 6 votes |
protected void paintFigure( Graphics g ) { g.setLineStyle( Graphics.LINE_DOT ); g.setXORMode( true ); g.setForegroundColor( ColorConstants.darkGray ); if ( bounds.width > bounds.height ) { g.drawLine( bounds.x, bounds.y, bounds.right( ), bounds.y ); g.drawLine( bounds.x + 2, bounds.y, bounds.right( ), bounds.y ); } else { g.drawLine( bounds.x, bounds.y, bounds.x, bounds.bottom( ) ); g.drawLine( bounds.x, bounds.y + 2, bounds.x, bounds.bottom( ) ); } }
Example 8
Source File: Legend.java From nebula with Eclipse Public License 2.0 | 5 votes |
@Override protected void outlineShape(Graphics graphics) { if (!isVisible() || !drawBorder) return; graphics.pushState(); if (!traceList.isEmpty()) { Color fg = traceList.get(0).getYAxis().getForegroundColor(); if (fg == null) fg = ColorConstants.black; graphics.setForegroundColor(fg); } super.outlineShape(graphics); graphics.popState(); }
Example 9
Source File: ERDiagramLineBorder.java From ermasterr with Apache License 2.0 | 5 votes |
private void paint1(final int i, final Color color, final Rectangle tempRect, final Graphics graphics) { tempRect.x++; tempRect.y++; tempRect.width -= 2; tempRect.height -= 2; graphics.setForegroundColor(color); graphics.drawRectangle(tempRect); }
Example 10
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 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: StatisticFigure.java From olca-app with Mozilla Public License 2.0 | 5 votes |
private void paintLines(Graphics g, Point box) { g.setForegroundColor(ColorConstants.red); drawLine(g, hist.statistics.getPercentileValue(5), box); drawLine(g, hist.statistics.median, box); drawLine(g, hist.statistics.getPercentileValue(95), box); drawLine(g, hist.statistics.mean, box); g.setForegroundColor(ColorConstants.black); }
Example 13
Source File: PrintERDiagramOperation.java From ermaster-b with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override protected void setupPrinterGraphicsFor(Graphics graphics, IFigure figure) { ERDiagram diagram = this.getDiagram(); PageSetting pageSetting = diagram.getPageSetting(); double dpiScale = (double) getPrinter().getDPI().x / Display.getCurrent().getDPI().x * pageSetting.getScale() / 100; Rectangle printRegion = getPrintRegion(); // put the print region in display coordinates printRegion.width /= dpiScale; printRegion.height /= dpiScale; Rectangle bounds = figure.getBounds(); double xScale = (double) printRegion.width / bounds.width; 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 14
Source File: SectionBorder.java From birt with Eclipse Public License 1.0 | 5 votes |
/** * Draw border of the section * * @param figure * @param g * @param in * @param side * @param style * @param width * @param color */ private void drawBorder( IFigure figure, Graphics g, Insets in, int side, int style, int[] width, int color ) { Rectangle r = figure.getBounds( ).getCropped( in ); //Outline the border //indicatorDimension = calculateIndicatorDimension( g, width[side] ); //if the border style is not set to "none", draw line with given style, // width and color if ( style != 0 ) { //set foreground color g.setForegroundColor( ColorManager.getColor( color ) ); BorderUtil.drawBorderLine( g, side, style, width, r ); } //if the border style is set to "none", draw a black solid line as // default else { g.setForegroundColor( ReportColorConstants.ShadowLineColor ); //draw default line BorderUtil.drawDefaultLine( g, side, r ); } g.restoreState( ); }
Example 15
Source File: CrosstabCellFigure.java From birt with Eclipse Public License 1.0 | 5 votes |
protected void paintFigure( Graphics graphics ) { super.paintFigure( graphics ); if ( getBlankString( ) != null && getBlankString( ).length( ) > 0 ) { graphics.setForegroundColor( ReportColorConstants.DarkShadowLineColor ); drawBlankString( graphics, getBlankString( ) ); graphics.restoreState( ); } }
Example 16
Source File: ThermometerFigure.java From nebula with Eclipse Public License 2.0 | 5 votes |
@Override protected void fillShape(Graphics graphics) { graphics.setAntialias(SWT.ON); boolean support3D = false; if(effect3D) support3D = GraphicsUtil.testPatternSupported(graphics); if(effect3D && support3D){ graphics.setBackgroundColor(fillColor); super.fillShape(graphics); //int l = (int) ((bounds.width - lineWidth)*0.293/2); Pattern backPattern = null; backPattern = GraphicsUtil.createScaledPattern(graphics, Display.getCurrent(), bounds.x + lineWidth, bounds.y + lineWidth, bounds.x+bounds.width-lineWidth, bounds.y+bounds.height-lineWidth, WHITE_COLOR,255, fillColor, 0); graphics.setBackgroundPattern(backPattern); super.fillShape(graphics); backPattern.dispose(); }else{ graphics.setBackgroundColor(fillColor); super.fillShape(graphics); } String valueString = getValueText(); Dimension valueSize = FigureUtilities.getTextExtents(valueString, getFont()); if(valueSize.width < bounds.width) { graphics.setForegroundColor(contrastFillColor); graphics.drawText(valueString, new Point( bounds.x + bounds.width/2 - valueSize.width/2, bounds.y + bounds.height/2 - valueSize.height/2)); } }
Example 17
Source File: CellDragTracker.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 18
Source File: Trace.java From nebula with Eclipse Public License 2.0 | 4 votes |
private void drawPoint(Graphics graphics, Point pos, ISample sample) { Color renderColor = traceColor; PointStyle renderPointStyle = pointStyle; int renderPointSize = pointSize; try { if ((fPointStyleProvider != null) && (sample != null)) { renderColor = fPointStyleProvider.getPointColor(sample, this); renderPointStyle = fPointStyleProvider.getPointStyle(sample, this); renderPointSize = fPointStyleProvider.getPointSize(sample, this); } } catch (Exception ex) { // Draw anyway and log error System.err.println(ex.getMessage()); renderColor = traceColor; renderPointStyle = pointStyle; renderPointSize = pointSize; } // Shortcut when no point requested if (renderPointStyle == PointStyle.NONE) { return; } graphics.pushState(); graphics.setBackgroundColor(renderColor); graphics.setForegroundColor(renderColor); // Otherwise redraw does not // affect lines graphics.setLineWidth(1); graphics.setLineStyle(SWTConstants.LINE_SOLID); int halfSize = renderPointSize / 2; switch (renderPointStyle) { case POINT: graphics.fillOval(new Rectangle(pos.x - halfSize, pos.y - halfSize, renderPointSize, renderPointSize)); break; case CIRCLE: graphics.drawOval(new Rectangle(pos.x - halfSize, pos.y - halfSize, renderPointSize, renderPointSize)); break; case FILLED_CIRCLE: graphics.fillOval(new Rectangle(pos.x - halfSize, pos.y - halfSize, renderPointSize, renderPointSize)); break; case TRIANGLE: graphics.drawPolygon(new int[] { pos.x - halfSize, pos.y + halfSize, pos.x, pos.y - halfSize, pos.x + halfSize, pos.y + halfSize }); break; case FILLED_TRIANGLE: graphics.fillPolygon(new int[] { pos.x - halfSize, pos.y + halfSize, pos.x, pos.y - halfSize, pos.x + halfSize, pos.y + halfSize }); break; case SQUARE: graphics.drawRectangle(new Rectangle(pos.x - halfSize, pos.y - halfSize, renderPointSize, renderPointSize)); break; case FILLED_SQUARE: graphics.fillRectangle(new Rectangle(pos.x - halfSize, pos.y - halfSize, renderPointSize, renderPointSize)); break; case BAR: graphics.drawLine(pos.x, pos.y - halfSize, pos.x, pos.y + halfSize); break; case CROSS: graphics.drawLine(pos.x, pos.y - halfSize, pos.x, pos.y + halfSize); graphics.drawLine(pos.x - halfSize, pos.y, pos.x + halfSize, pos.y); break; case XCROSS: graphics.drawLine(pos.x - halfSize, pos.y - halfSize, pos.x + halfSize, pos.y + halfSize); graphics.drawLine(pos.x + halfSize, pos.y - halfSize, pos.x - halfSize, pos.y + halfSize); break; case DIAMOND: graphics.drawPolyline(new int[] { pos.x, pos.y - halfSize, pos.x - halfSize, pos.y, pos.x, pos.y + halfSize, pos.x + halfSize, pos.y, pos.x, pos.y - halfSize }); break; case FILLED_DIAMOND: graphics.fillPolygon(new int[] { pos.x, pos.y - halfSize, pos.x - halfSize, pos.y, pos.x, pos.y + halfSize, pos.x + halfSize, pos.y }); break; default: break; } graphics.popState(); }
Example 19
Source File: ColumnConnection.java From birt with Eclipse Public License 1.0 | 4 votes |
protected void outlineShape( Graphics g ) { g.setForegroundColor( ColorConstants.blue ); this.setForegroundColor( this.getBackgroundColor( ) ); super.outlineShape( g ); }
Example 20
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); } }