Java Code Examples for org.eclipse.swt.graphics.GC#drawRectangle()
The following examples show how to use
org.eclipse.swt.graphics.GC#drawRectangle() .
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: PolygonRectangleIntersection.java From gef with Eclipse Public License 2.0 | 6 votes |
@Override protected AbstractControllableShape createControllableShape2( Canvas canvas) { return new AbstractControllableShape(canvas) { @Override public void createControlPoints() { addControlPoint(new Point(100, 150)); addControlPoint(new Point(550, 300)); } @Override public Rectangle createGeometry() { Point[] points = getControlPoints(); return new Rectangle(points[0], points[1]); } @Override public void drawShape(GC gc) { Rectangle rect = createGeometry(); gc.drawRectangle(Geometry2SWT.toSWTRectangle(rect)); } }; }
Example 2
Source File: GridToolTip.java From nebula with Eclipse Public License 2.0 | 5 votes |
/** * Paints the tooltip. * * @param gc */ private void onPaint(GC gc) { gc.drawRectangle(0, 0, shell.getSize().x - 1, shell.getSize().y - 1); gc.drawString(text, xmargin, ymargin, true); }
Example 3
Source File: ViewportAnnotation.java From saros with GNU General Public License v2.0 | 5 votes |
@Override public void paint(GC gc, Canvas canvas, Rectangle bounds) { Point canvasSize = canvas.getSize(); gc.setBackground(fillColor); gc.setForeground(strokeColor); gc.setLineWidth(1); int x = ViewportAnnotation.INSET; int y = bounds.y; int w = canvasSize.x - 2 * ViewportAnnotation.INSET; int h = bounds.height; if (multipleLines) { h += gc.getFontMetrics().getHeight(); } if (y < 0) { h = h + y; y = 0; } if (h <= 0) { return; } gc.fillRectangle(x, y, w, h); gc.drawRectangle(x, y, w, h); }
Example 4
Source File: CheckBoxRenderer.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
/** * {@inheritDoc} */ public void paint(GC gc, Object value) { if (isGrayed()) { gc.setBackground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND)); } else { gc.setBackground(getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND)); } gc.fillRectangle(getBounds()); gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_FOREGROUND)); gc.drawRectangle(getBounds().x, getBounds().y, getBounds().width - 1, getBounds().height - 1); gc.drawRectangle(getBounds().x + 1, getBounds().y + 1, getBounds().width - 3, getBounds().height - 3); if (isGrayed()) { gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW)); } if (isChecked()) { gc.drawLine(getBounds().x + 3, getBounds().y + 5, getBounds().x + 6, getBounds().y + 8); gc.drawLine(getBounds().x + 3, getBounds().y + 6, getBounds().x + 5, getBounds().y + 8); gc.drawLine(getBounds().x + 3, getBounds().y + 7, getBounds().x + 5, getBounds().y + 9); gc.drawLine(getBounds().x + 9, getBounds().y + 3, getBounds().x + 6, getBounds().y + 6); gc.drawLine(getBounds().x + 9, getBounds().y + 4, getBounds().x + 6, getBounds().y + 7); gc.drawLine(getBounds().x + 9, getBounds().y + 5, getBounds().x + 7, getBounds().y + 7); } }
Example 5
Source File: GridToolTip.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
/** * Paints the tooltip. * * @param gc */ private void onPaint(GC gc) { gc.drawRectangle(0, 0, shell.getSize().x - 1, shell.getSize().y - 1); gc.drawString(text, xmargin, ymargin, true); }
Example 6
Source File: TextPainter.java From swt-bling with MIT License | 5 votes |
/** * Paints text and/or returns a Rectangle representing the computed bounds * of the text. You may only want they rectangle if you are trying to lay the * text out. * * @param gc * @param paint * @return Rectangle representing the computed bounds */ Rectangle conditionallyPaintText(final GC gc, final boolean paint) { final Rectangle clip = gc.getClipping(); final Color bg = gc.getBackground(); if (clipping) { gc.setClipping(this.bounds); } hyperlinks.clear(); int y = bounds.y + paddingTop; List<List<DrawData>> lines = buildLines(gc); for (int i = 0; i < lines.size(); i++) { if(justification == SWT.RIGHT) { y += drawRightJustified(gc, paint, lines.get(i), y); } else if (justification == SWT.LEFT) { y += drawLeftJustified(gc, paint, lines.get(i), y); } else if (justification == SWT.CENTER) { y += drawCenterJustified(gc, paint, lines.get(i), y); } } if (drawBounds) { gc.setForeground(boundaryColor); gc.drawRectangle(bounds); } Rectangle calculatedBounds = new Rectangle(bounds.x, bounds.y, bounds.width, y - bounds.y); if (drawCalculatedBounds) { gc.setForeground(ColorFactory.getColor(gc.getDevice(), 0, 255, 0)); gc.drawRectangle(calculatedBounds); } gc.setClipping(clip); gc.setBackground(bg); return calculatedBounds; }
Example 7
Source File: MinMaxToggleRenderer.java From nebula with Eclipse Public License 2.0 | 5 votes |
public void paint(GC gc, Object value) { Transform transform = new Transform(gc.getDevice()); transform.translate(getBounds().x, getBounds().y); gc.setTransform(transform); gc.setBackground(gc.getDevice().getSystemColor(SWT.COLOR_LIST_BACKGROUND)); gc.setForeground(gc.getDevice().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW)); if (isHover()) { gc.setForeground(gc.getDevice().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW)); gc.drawRoundRectangle(0, 0, 17, 17, 5, 5); } gc.setBackground(gc.getDevice().getSystemColor(SWT.COLOR_LIST_BACKGROUND)); gc.setForeground(gc.getDevice().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW)); if (isExpanded()) { gc.fillRectangle(4, 3, 9, 3); gc.drawRectangle(4, 3, 9, 3); } else { gc.fillRectangle(4, 3, 9, 9); gc.drawRectangle(4, 3, 9, 9); gc.drawLine(4, 5, 13, 5); } gc.setTransform(null); transform.dispose(); }
Example 8
Source File: Breadcrumb.java From nebula with Eclipse Public License 2.0 | 5 votes |
private void drawBackground(final GC gc, final int width, final int height) { gc.setForeground(START_GRADIENT_COLOR); gc.setBackground(END_GRADIENT_COLOR); gc.fillGradientRectangle(0, 0, width, height, true); if (hasBorder) { gc.setForeground(BORDER_COLOR); gc.drawRectangle(0, 0, width - 1, height - 1); } }
Example 9
Source File: BoxDrawingStrategy.java From uima-uimaj with Apache License 2.0 | 5 votes |
/** * Draws a box around the given annotation. * * @param annotation the annotation * @param gc the gc * @param textWidget the text widget * @param offset the offset * @param length the length * @param color the color */ @Override public void draw(Annotation annotation, GC gc, StyledText textWidget, int offset, int length, Color color) { if (length != 0) { if (gc != null) { Rectangle bounds = textWidget.getTextBounds(offset, offset + length - 1); gc.setForeground(color); int correctedHeight; if (bounds.height > 0) { correctedHeight = bounds.height -1; } else { correctedHeight = bounds.height; } int correctedWidth; if (bounds.width > 0) correctedWidth = bounds.width -1; else correctedWidth = bounds.width; gc.drawRectangle(bounds.x, bounds.y, correctedWidth, correctedHeight); } else { textWidget.redrawRange(offset, length, true); } } }
Example 10
Source File: MarkerEditorComposite.java From birt with Eclipse Public License 1.0 | 4 votes |
private void paintMarker( GC gc, Marker currentMarker, Location location ) { // Paint an icon sample, not a real icon in the Fill Marker renderMarker = currentMarker; int markerSize = 4; if ( currentMarker.getType( ) == MarkerType.ICON_LITERAL ) { renderMarker = currentMarker.copyInstance( ); renderMarker.setFill( ImageImpl.create( UIHelper.getURL( "icons/obj16/marker_icon.gif" ).toString( ) ) ); //$NON-NLS-1$ // To prevent the icon being too small in UI, use the original size // for icon markerSize = 0; } idrSWT.setProperty( IDeviceRenderer.GRAPHICS_CONTEXT, gc ); final MarkerRenderer mr = new MarkerRenderer( idrSWT, StructureSource.createUnknown( null ), location, LineAttributesImpl.create( ( getMarker( ).isSetVisible( ) && getMarker( ).isVisible( ) ) ? ColorDefinitionImpl.BLUE( ) : ColorDefinitionImpl.GREY( ), LineStyle.SOLID_LITERAL, 1 ), isMarkerTypeEnabled( ) ? ColorDefinitionImpl.create( 80, 168, 218 ) : ColorDefinitionImpl.GREY( ), renderMarker, markerSize, null, false, false ); try { mr.draw( idrSWT ); ChartWizard.removeException( ChartWizard.MarkerEdiCom_ID ); } catch ( ChartException ex ) { ChartWizard.showException( ChartWizard.MarkerEdiCom_ID, ex.getLocalizedMessage( ) ); } // Render a boundary line to indicate focus if ( cnvMarker.isFocusControl( ) ) { gc.setLineStyle( SWT.LINE_DOT ); gc.setForeground( Display.getCurrent( ) .getSystemColor( SWT.COLOR_BLACK ) ); gc.drawRectangle( 0, 0, getSize( ).x - 21, this.getSize( ).y - 5 ); } }
Example 11
Source File: DataTableDecorator.java From arx with Apache License 2.0 | 4 votes |
@Override public void paintCell(ILayerCell cell, GC gc, Rectangle rectangle, IConfigRegistry configRegistry) { BorderStyle borderStyle = getBorderStyle(cell, configRegistry); int borderThickness = borderStyle != null ? borderStyle.getThickness() : 0; // check how many border lines are configured for that cell List<String> labels = cell.getConfigLabels().getLabels(); int leftBorderThickness = 0; int rightBorderThickness = 0; int topBorderThickness = 0; int bottomBorderThickness = 0; if (labels.contains(LEFT_LINE_BORDER_LABEL)) leftBorderThickness = borderThickness; if (labels.contains(RIGHT_LINE_BORDER_LABEL)) rightBorderThickness = borderThickness; if (labels.contains(TOP_LINE_BORDER_LABEL)) topBorderThickness = borderThickness; if (labels.contains(BOTTOM_LINE_BORDER_LABEL)) bottomBorderThickness = borderThickness; Rectangle interiorBounds = new Rectangle(rectangle.x + leftBorderThickness, rectangle.y + topBorderThickness, (rectangle.width - leftBorderThickness - rightBorderThickness), (rectangle.height - topBorderThickness - bottomBorderThickness)); super.paintCell(cell, gc, interiorBounds, configRegistry); if (borderStyle == null || borderThickness <= 0 || (leftBorderThickness == 0 && rightBorderThickness == 0 && topBorderThickness == 0 && bottomBorderThickness == 0)) { return; } // Save GC settings Color originalForeground = gc.getForeground(); int originalLineWidth = gc.getLineWidth(); int originalLineStyle = gc.getLineStyle(); gc.setLineWidth(borderThickness); Rectangle borderArea = new Rectangle(rectangle.x, rectangle.y, rectangle.width, rectangle.height); if (borderThickness >= 1) { int shift = 0; int correction = 0; if ((borderThickness % 2) == 0) { shift = borderThickness / 2; } else { shift = borderThickness / 2; correction = 1; } if (leftBorderThickness >= 1) { borderArea.x += shift; borderArea.width -= shift; } if (rightBorderThickness >= 1) { borderArea.width -= shift + correction; } if (topBorderThickness >= 1) { borderArea.y += shift; borderArea.height -= shift; } if (bottomBorderThickness >= 1) { borderArea.height -= shift + correction; } } gc.setLineStyle(LineStyleEnum.toSWT(borderStyle.getLineStyle())); gc.setForeground(borderStyle.getColor()); // if all borders are set draw a rectangle if (leftBorderThickness > 0 && rightBorderThickness > 0 && topBorderThickness > 0 && bottomBorderThickness > 0) { gc.drawRectangle(borderArea); } // else draw a line for every set border else { Point topLeftPos = new Point(borderArea.x, borderArea.y); Point topRightPos = new Point(borderArea.x + borderArea.width, borderArea.y); Point bottomLeftPos = new Point(borderArea.x, borderArea.y + borderArea.height); Point bottomRightPos = new Point(borderArea.x + borderArea.width, borderArea.y + borderArea.height); if (leftBorderThickness > 0) { gc.drawLine(topLeftPos.x, topLeftPos.y, bottomLeftPos.x, bottomLeftPos.y); } if (rightBorderThickness > 0) { gc.drawLine(topRightPos.x, topRightPos.y, bottomRightPos.x, bottomRightPos.y); } if (topBorderThickness > 0) { gc.drawLine(topLeftPos.x, topLeftPos.y, topRightPos.x, topRightPos.y); } if (bottomBorderThickness > 0) { gc.drawLine(bottomLeftPos.x, bottomLeftPos.y, bottomRightPos.x, bottomRightPos.y); } } // Restore GC settings gc.setForeground(originalForeground); gc.setLineWidth(originalLineWidth); gc.setLineStyle(originalLineStyle); }
Example 12
Source File: MarkerEditorComposite.java From birt with Eclipse Public License 1.0 | 4 votes |
public void paintControl( PaintEvent e ) { GC gc = e.gc; int markerIndex = ( (Integer) e.widget.getData( ) ).intValue( ); int markerLength = typeNameSet.length; String typeName = null; if ( markerIndex < markerLength ) { typeName = typeNameSet[markerIndex]; gc.setBackground( Display.getDefault( ) .getSystemColor( SWT.COLOR_INFO_BACKGROUND ) ); gc.fillRectangle( 0, 0, MARKER_BLOCK_WIDTH, MARKER_BLOCK_HEIGHT ); } int lineWidth = 1; if ( isMarkerTypeEnabled( ) ) { gc.setForeground( Display.getDefault( ) .getSystemColor( SWT.COLOR_BLACK ) ); } else { gc.setForeground( Display.getDefault( ) .getSystemColor( SWT.COLOR_GRAY ) ); } gc.setLineWidth( lineWidth ); int x = lineWidth - 1; int y = lineWidth - 1; int width = MARKER_BLOCK_WIDTH + 1 - 2 * lineWidth; int height = MARKER_BLOCK_HEIGHT + 1 - 2 * lineWidth; if ( markerIndex / MARKER_ROW_MAX_NUMBER < markerLength / MARKER_ROW_MAX_NUMBER ) { // Remove the bottom border if not in the last row height++; } if ( ( markerIndex + 1 ) % MARKER_ROW_MAX_NUMBER != 0 ) { // Remove the right border if not in the rightmost column width++; } if ( typeName == null ) { if ( markerIndex > markerLength ) { // Remove the left and right border of the fake node unless // it's next to the last x = -1; width += 2; } // Remove the bottom border of the fake node height++; } // Draw the border gc.drawRectangle( x, y, width, height ); // Draw the boarder of current marker if ( getMarker( ).getType( ).getName( ).equals( typeName ) ) { markerTypeIndex = markerIndex; gc.setForeground( Display.getDefault( ) .getSystemColor( SWT.COLOR_RED ) ); gc.drawRectangle( 1, 1, MARKER_BLOCK_WIDTH - 2, MARKER_BLOCK_HEIGHT - 2 ); } // Draw the marker if ( typeName != null ) { paintMarker( gc, MarkerImpl.create( MarkerType.getByName( typeName ), 4 ), LocationImpl.create( MARKER_BLOCK_WIDTH / 2, MARKER_BLOCK_HEIGHT / 2 ) ); } }
Example 13
Source File: ToggleRenderer.java From translationstudio8 with GNU General Public License v2.0 | 4 votes |
/** * {@inheritDoc} */ public void paint(GC gc, Object value) { gc.setBackground(getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND)); gc.fillRectangle(getBounds()); gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW)); gc.drawRectangle(getBounds().x, getBounds().y, getBounds().width - 1, getBounds().height - 1); gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_FOREGROUND)); gc.drawLine(getBounds().x + 2, getBounds().y + 4, getBounds().x + 6, getBounds().y + 4); if (!isExpanded()) { gc.drawLine(getBounds().x + 4, getBounds().y + 2, getBounds().x + 4, getBounds().y + 6); } }
Example 14
Source File: SwtChartViewerSelector.java From birt with Eclipse Public License 1.0 | 4 votes |
private final void showException( GC g2d, Exception ex ) { String sWrappedException = ex.getClass( ).getName( ); Throwable th = ex; while ( ex.getCause( ) != null ) { ex = (Exception) ex.getCause( ); } String sException = ex.getClass( ).getName( ); if ( sWrappedException.equals( sException ) ) { sWrappedException = null; } String sMessage = null; if ( th instanceof BirtException ) { sMessage = ( (BirtException) th ).getLocalizedMessage( ); } else { sMessage = ex.getMessage( ); } if ( sMessage == null ) { sMessage = "<null>";//$NON-NLS-1$ } StackTraceElement[] stea = ex.getStackTrace( ); Point d = this.getSize( ); Device dv = Display.getCurrent( ); Font fo = new Font( dv, "Courier", SWT.BOLD, 16 );//$NON-NLS-1$ g2d.setFont( fo ); FontMetrics fm = g2d.getFontMetrics( ); g2d.setBackground( dv.getSystemColor( SWT.COLOR_WHITE ) ); g2d.fillRectangle( 20, 20, d.x - 40, d.y - 40 ); g2d.setForeground( dv.getSystemColor( SWT.COLOR_BLACK ) ); g2d.drawRectangle( 20, 20, d.x - 40, d.y - 40 ); g2d.setClipping( 20, 20, d.x - 40, d.y - 40 ); int x = 25, y = 20 + fm.getHeight( ); g2d.drawString( "Exception:", x, y );//$NON-NLS-1$ x += g2d.textExtent( "Exception:" ).x + 5;//$NON-NLS-1$ g2d.setForeground( dv.getSystemColor( SWT.COLOR_RED ) ); g2d.drawString( sException, x, y ); x = 25; y += fm.getHeight( ); if ( sWrappedException != null ) { g2d.setForeground( dv.getSystemColor( SWT.COLOR_BLACK ) ); g2d.drawString( "Wrapped In:", x, y );//$NON-NLS-1$ x += g2d.textExtent( "Wrapped In:" ).x + 5;//$NON-NLS-1$ g2d.setForeground( dv.getSystemColor( SWT.COLOR_RED ) ); g2d.drawString( sWrappedException, x, y ); x = 25; y += fm.getHeight( ); } g2d.setForeground( dv.getSystemColor( SWT.COLOR_BLACK ) ); y += 10; g2d.drawString( "Message:", x, y );//$NON-NLS-1$ x += g2d.textExtent( "Message:" ).x + 5;//$NON-NLS-1$ g2d.setForeground( dv.getSystemColor( SWT.COLOR_BLUE ) ); g2d.drawString( sMessage, x, y ); x = 25; y += fm.getHeight( ); g2d.setForeground( dv.getSystemColor( SWT.COLOR_BLACK ) ); y += 10; g2d.drawString( "Trace:", x, y );//$NON-NLS-1$ x = 40; y += fm.getHeight( ); g2d.setForeground( dv.getSystemColor( SWT.COLOR_DARK_GREEN ) ); for ( int i = 0; i < stea.length; i++ ) { g2d.drawString( stea[i].getClassName( ) + ":"//$NON-NLS-1$ + stea[i].getMethodName( ) + "(...):"//$NON-NLS-1$ + stea[i].getLineNumber( ), x, y ); x = 40; y += fm.getHeight( ); } fo.dispose( ); }
Example 15
Source File: DialChartViewer.java From birt with Eclipse Public License 1.0 | 4 votes |
private final void showException( GC g2d, Exception ex ) { String sWrappedException = ex.getClass( ).getName( ); Throwable th = ex; while ( ex.getCause( ) != null ) { ex = (Exception) ex.getCause( ); } String sException = ex.getClass( ).getName( ); if ( sWrappedException.equals( sException ) ) { sWrappedException = null; } String sMessage = null; if ( th instanceof BirtException ) { sMessage = ( (BirtException) th ).getLocalizedMessage( ); } else { sMessage = ex.getMessage( ); } if ( sMessage == null ) { sMessage = "<null>";//$NON-NLS-1$ } StackTraceElement[] stea = ex.getStackTrace( ); Point d = this.getSize( ); Device dv = Display.getCurrent( ); Font fo = new Font( dv, "Courier", SWT.BOLD, 16 );//$NON-NLS-1$ g2d.setFont( fo ); FontMetrics fm = g2d.getFontMetrics( ); g2d.setBackground( dv.getSystemColor( SWT.COLOR_WHITE ) ); g2d.fillRectangle( 20, 20, d.x - 40, d.y - 40 ); g2d.setForeground( dv.getSystemColor( SWT.COLOR_BLACK ) ); g2d.drawRectangle( 20, 20, d.x - 40, d.y - 40 ); g2d.setClipping( 20, 20, d.x - 40, d.y - 40 ); int x = 25, y = 20 + fm.getHeight( ); g2d.drawString( "Exception:", x, y );//$NON-NLS-1$ x += g2d.textExtent( "Exception:" ).x + 5;//$NON-NLS-1$ g2d.setForeground( dv.getSystemColor( SWT.COLOR_RED ) ); g2d.drawString( sException, x, y ); x = 25; y += fm.getHeight( ); if ( sWrappedException != null ) { g2d.setForeground( dv.getSystemColor( SWT.COLOR_BLACK ) ); g2d.drawString( "Wrapped In:", x, y );//$NON-NLS-1$ x += g2d.textExtent( "Wrapped In:" ).x + 5;//$NON-NLS-1$ g2d.setForeground( dv.getSystemColor( SWT.COLOR_RED ) ); g2d.drawString( sWrappedException, x, y ); x = 25; y += fm.getHeight( ); } g2d.setForeground( dv.getSystemColor( SWT.COLOR_BLACK ) ); y += 10; g2d.drawString( "Message:", x, y );//$NON-NLS-1$ x += g2d.textExtent( "Message:" ).x + 5;//$NON-NLS-1$ g2d.setForeground( dv.getSystemColor( SWT.COLOR_BLUE ) ); g2d.drawString( sMessage, x, y ); x = 25; y += fm.getHeight( ); g2d.setForeground( dv.getSystemColor( SWT.COLOR_BLACK ) ); y += 10; g2d.drawString( "Trace:", x, y );//$NON-NLS-1$ x = 40; y += fm.getHeight( ); g2d.setForeground( dv.getSystemColor( SWT.COLOR_DARK_GREEN ) ); for ( int i = 0; i < stea.length; i++ ) { g2d.drawString( stea[i].getClassName( ) + ":"//$NON-NLS-1$ + stea[i].getMethodName( ) + "(...):"//$NON-NLS-1$ + stea[i].getLineNumber( ), x, y ); x = 40; y += fm.getHeight( ); } fo.dispose( ); }
Example 16
Source File: AbstractPaintManager.java From nebula with Eclipse Public License 2.0 | 4 votes |
private void drawCheckpointMarker(final GC gc, final ISettings settings, final IColorManager colorManager, final GanttEvent event, final boolean threeDee, final int x, final int y, final int width, final int height, final Rectangle bounds) { final float fHoriSpacer = width * 0.17f; final int hSpacer = (int) fHoriSpacer; final float fVertiSpacer = height * 0.23f; final int vSpacer = (int) fVertiSpacer; final Rectangle topToBottom = new Rectangle(x + hSpacer, y, width - (hSpacer * 2), height + vSpacer); final Rectangle leftToRight = new Rectangle(x, y + vSpacer, width, height - vSpacer); final Rectangle inner = new Rectangle(x + hSpacer, y + vSpacer, width - (hSpacer * 2), height - (vSpacer * 2)); Color cEvent = event.getStatusColor(); Color gradient = event.getGradientStatusColor(); if (cEvent == null) { cEvent = settings.getDefaultEventColor(); } if (gradient == null) { gradient = settings.getDefaultGradientEventColor(); } gc.setForeground(gradient); gc.setBackground(cEvent); gc.fillRectangle(topToBottom); gc.fillRectangle(leftToRight); gc.fillGradientRectangle(inner.x, inner.y, inner.width, inner.height, true); gc.setForeground(colorManager.getBlack()); gc.drawRectangle(topToBottom); gc.drawRectangle(leftToRight); if (threeDee) { final boolean alpha = (colorManager.useAlphaDrawing() || colorManager.useAlphaDrawingOn3DEventDropShadows()); if (alpha) { gc.setAlpha(200); } gc.setForeground(colorManager.getFadeOffColor1()); // horizontal line.. ends a few pixles right of bottom right corner gc.drawLine(leftToRight.x, leftToRight.y + leftToRight.height + 1, leftToRight.x + hSpacer - 1, leftToRight.y + leftToRight.height + 1); gc.drawLine(leftToRight.x + hSpacer, leftToRight.y + leftToRight.height + vSpacer + 1, leftToRight.x - hSpacer + leftToRight.width, leftToRight.y + leftToRight.height + vSpacer + 1); gc.drawLine(leftToRight.x + leftToRight.width - hSpacer + 1, leftToRight.y + leftToRight.height + 1, leftToRight.x + leftToRight.width + 1, leftToRight.y + leftToRight.height + 1); // vertical line at end, starts slightly below top right corner gc.drawLine(leftToRight.x + leftToRight.width + 1, leftToRight.y + 2, leftToRight.x + leftToRight.width + 1, leftToRight.y + leftToRight.height + 1); if (alpha) { gc.setAlpha(100); } gc.setForeground(colorManager.getFadeOffColor2()); gc.drawLine(leftToRight.x, leftToRight.y + leftToRight.height + 2, leftToRight.x + hSpacer - 1, leftToRight.y + leftToRight.height + 2); gc.drawLine(leftToRight.x + hSpacer, leftToRight.y + leftToRight.height + vSpacer + 2, leftToRight.x - hSpacer + leftToRight.width, leftToRight.y + leftToRight.height + vSpacer + 2); gc.drawLine(leftToRight.x + leftToRight.width - hSpacer + 1, leftToRight.y + leftToRight.height + 2, leftToRight.x + leftToRight.width + 1, leftToRight.y + leftToRight.height + 2); gc.drawLine(leftToRight.x + leftToRight.width + 2, leftToRight.y + 3, leftToRight.x + leftToRight.width + 2, leftToRight.y + leftToRight.height + 1); if (alpha) { gc.setAlpha(50); } gc.setForeground(colorManager.getFadeOffColor3()); gc.drawLine(leftToRight.x, leftToRight.y + leftToRight.height + 3, leftToRight.x + hSpacer - 1, leftToRight.y + leftToRight.height + 3); gc.drawLine(leftToRight.x + hSpacer, leftToRight.y + leftToRight.height + vSpacer + 3, leftToRight.x - hSpacer + leftToRight.width, leftToRight.y + leftToRight.height + vSpacer + 3); gc.drawLine(leftToRight.x + leftToRight.width - hSpacer + 1, leftToRight.y + leftToRight.height + 3, leftToRight.x + leftToRight.width + 1, leftToRight.y + leftToRight.height + 3); gc.drawLine(leftToRight.x + leftToRight.width + 3, leftToRight.y + 4, leftToRight.x + leftToRight.width + 3, leftToRight.y + leftToRight.height + 1); if (alpha) { gc.setAlpha(255); gc.setAdvanced(false); } } }
Example 17
Source File: AbstractPaintManager.java From nebula with Eclipse Public License 2.0 | 4 votes |
public void drawScope(final GanttComposite ganttComposite, final ISettings settings, final IColorManager colorManager, final GanttEvent event, final GC gc, final boolean threeDee, final int dayWidth, final int x, final int y, final int eventWidth, final Rectangle bounds) { final List scopeEvents = event.getScopeEvents(); // empty scope if (scopeEvents.isEmpty()) { return; } gc.setForeground(colorManager.getScopeGradientColorTop()); gc.setBackground(colorManager.getScopeGradientColorBottom()); gc.fillGradientRectangle(x, y, eventWidth, settings.getEventHeight() - 5, true); gc.setForeground(colorManager.getScopeBorderColor()); gc.drawRectangle(new Rectangle(x, y, eventWidth, settings.getEventHeight() - 5)); gc.setForeground(colorManager.getScopeGradientColorTop()); gc.setBackground(colorManager.getScopeGradientColorBottom()); gc.fillGradientRectangle(x, y, dayWidth / 2, settings.getEventHeight(), true); gc.fillGradientRectangle(x + eventWidth + (dayWidth / 2) - dayWidth, y, dayWidth / 2, settings.getEventHeight(), true); gc.setForeground(colorManager.getScopeBorderColor()); gc.drawRectangle(x, y, dayWidth / 2, settings.getEventHeight()); gc.drawRectangle(x + eventWidth + (dayWidth / 2) - dayWidth, y, dayWidth / 2, settings.getEventHeight()); if (threeDee) { final boolean alpha = (colorManager.useAlphaDrawing() || colorManager.useAlphaDrawingOn3DEventDropShadows()); if (alpha) { gc.setAlpha(200); } gc.setForeground(colorManager.getFadeOffColor1()); gc.drawLine(x, y + settings.getEventHeight() + 1, x + dayWidth / 2, y + settings.getEventHeight() + 1); gc.drawLine(x + eventWidth - (dayWidth / 2), y + settings.getEventHeight() + 1, x + eventWidth, y + settings.getEventHeight() + 1); gc.drawLine(x + (dayWidth / 2) + 1, y + settings.getEventHeight() - 4, x + eventWidth - (dayWidth / 2) - 1, y + settings.getEventHeight() - 4); if (alpha) { gc.setAlpha(100); } gc.setForeground(colorManager.getFadeOffColor2()); gc.drawLine(x, y + settings.getEventHeight() + 2, x + dayWidth / 2, y + settings.getEventHeight() + 2); gc.drawLine(x + eventWidth - (dayWidth / 2), y + settings.getEventHeight() + 2, x + eventWidth, y + settings.getEventHeight() + 2); gc.drawLine(x + (dayWidth / 2) + 1, y + settings.getEventHeight() - 3, x + eventWidth - (dayWidth / 2) - 1, y + settings.getEventHeight() - 3); if (alpha) { gc.setAlpha(50); } gc.setForeground(colorManager.getFadeOffColor3()); gc.drawLine(x, y + settings.getEventHeight() + 3, x + dayWidth / 2, y + settings.getEventHeight() + 3); gc.drawLine(x + eventWidth - (dayWidth / 2), y + settings.getEventHeight() + 3, x + eventWidth, y + settings.getEventHeight() + 3); gc.drawLine(x + (dayWidth / 2) + 1, y + settings.getEventHeight() - 2, x + eventWidth - (dayWidth / 2) - 1, y + settings.getEventHeight() - 2); if (alpha) { gc.setAlpha(255); gc.setAdvanced(false); } } }
Example 18
Source File: AdvancedTooltipDialog.java From nebula with Eclipse Public License 2.0 | 4 votes |
private static void drawBorders(final GC gc, final IColorManager colorManager, final Rectangle bounds) { gc.setForeground(colorManager.getAdvancedTooltipInnerFillTopColor()); gc.setBackground(colorManager.getAdvancedTooltipInnerFillBottomColor()); gc.fillGradientRectangle(bounds.x, bounds.y, bounds.width, bounds.height, true); // draw border gc.setForeground(colorManager.getAdvancedTooltipBorderColor()); gc.drawRectangle(bounds.x, bounds.y, bounds.width - 1, bounds.height - 1); // what would would the world be without faded gradient corners? boring! // so let's draw a few. // draw corners gc.setForeground(colorManager.getAdvancedTooltipShadowCornerOuterColor()); // top left gc.drawLine(bounds.x + 1, bounds.y, bounds.x + 1, bounds.y); gc.drawLine(bounds.x, bounds.y + 1, bounds.x, bounds.y + 1); // top right gc.drawLine(bounds.x + bounds.width - 2, bounds.y, bounds.x + bounds.width - 2, bounds.y); gc.drawLine(bounds.x + bounds.width - 1, bounds.y + 1, bounds.x + bounds.width - 1, bounds.y + 1); // bottom right gc.drawLine(bounds.x + bounds.width - 1, bounds.y + bounds.height - 2, bounds.x + bounds.width - 1, bounds.y + bounds.height - 2); gc.drawLine(bounds.x + bounds.width - 2, bounds.y + bounds.height - 1, bounds.x + bounds.width - 2, bounds.y + bounds.height - 1); // bottom left gc.drawLine(bounds.x + 1, bounds.y + bounds.height - 1, bounds.x + 1, bounds.y + bounds.height - 1); gc.drawLine(bounds.x, bounds.y + bounds.height - 2, bounds.x, bounds.y + bounds.height - 2); // shadowed corner inside the above gc.setForeground(colorManager.getAdvancedTooltipShadowCornerInnerColor()); // top left gc.drawLine(bounds.x + 2, bounds.y, bounds.x + 2, bounds.y); gc.drawLine(bounds.x, bounds.y + 2, bounds.x, bounds.y + 2); // top right gc.drawLine(bounds.x + bounds.width - 3, bounds.y, bounds.x + bounds.width - 3, bounds.y); gc.drawLine(bounds.x + bounds.width - 1, bounds.y + 2, bounds.x + bounds.width - 1, bounds.y + 2); // bottom right gc.drawLine(bounds.x + bounds.width - 1, bounds.y + bounds.height - 3, bounds.x + bounds.width - 1, bounds.y + bounds.height - 3); gc.drawLine(bounds.x + bounds.width - 3, bounds.y + bounds.height - 1, bounds.x + bounds.width - 3, bounds.y + bounds.height - 1); // bottom left gc.drawLine(bounds.x + 2, bounds.y + bounds.height - 1, bounds.x + 2, bounds.y + bounds.height - 1); gc.drawLine(bounds.x, bounds.y + bounds.height - 3, bounds.x, bounds.y + bounds.height - 3); // draw inner corner pixel in each corner gc.setForeground(colorManager.getAdvancedTooltipShadowInnerCornerColor()); // top left gc.drawLine(bounds.x + 1, bounds.y + 1, bounds.x + 1, bounds.y + 1); // top right gc.drawLine(bounds.x + bounds.width - 2, bounds.y + 1, bounds.x + bounds.width - 2, bounds.y + 1); // bottom right gc.drawLine(bounds.x + bounds.width - 2, bounds.y + bounds.height - 2, bounds.x + bounds.width - 2, bounds.y + bounds.height - 2); // bottom left gc.drawLine(bounds.x + 1, bounds.y + bounds.height - 2, bounds.x + 1, bounds.y + bounds.height - 2); }
Example 19
Source File: CurveFittingViewer.java From birt with Eclipse Public License 1.0 | 4 votes |
private final void showException( GC g2d, Exception ex ) { String sWrappedException = ex.getClass( ).getName( ); Throwable th = ex; while ( ex.getCause( ) != null ) { ex = (Exception) ex.getCause( ); } String sException = ex.getClass( ).getName( ); if ( sWrappedException.equals( sException ) ) { sWrappedException = null; } String sMessage = null; if ( th instanceof BirtException ) { sMessage = ( (BirtException) th ).getLocalizedMessage( ); } else { sMessage = ex.getMessage( ); } if ( sMessage == null ) { sMessage = "<null>";//$NON-NLS-1$ } StackTraceElement[] stea = ex.getStackTrace( ); Point d = this.getSize( ); Device dv = Display.getCurrent( ); Font fo = new Font( dv, "Courier", SWT.BOLD, 16 );//$NON-NLS-1$ g2d.setFont( fo ); FontMetrics fm = g2d.getFontMetrics( ); g2d.setBackground( dv.getSystemColor( SWT.COLOR_WHITE ) ); g2d.fillRectangle( 20, 20, d.x - 40, d.y - 40 ); g2d.setForeground( dv.getSystemColor( SWT.COLOR_BLACK ) ); g2d.drawRectangle( 20, 20, d.x - 40, d.y - 40 ); g2d.setClipping( 20, 20, d.x - 40, d.y - 40 ); int x = 25, y = 20 + fm.getHeight( ); g2d.drawString( "Exception:", x, y );//$NON-NLS-1$ x += g2d.textExtent( "Exception:" ).x + 5;//$NON-NLS-1$ g2d.setForeground( dv.getSystemColor( SWT.COLOR_RED ) ); g2d.drawString( sException, x, y ); x = 25; y += fm.getHeight( ); if ( sWrappedException != null ) { g2d.setForeground( dv.getSystemColor( SWT.COLOR_BLACK ) ); g2d.drawString( "Wrapped In:", x, y );//$NON-NLS-1$ x += g2d.textExtent( "Wrapped In:" ).x + 5;//$NON-NLS-1$ g2d.setForeground( dv.getSystemColor( SWT.COLOR_RED ) ); g2d.drawString( sWrappedException, x, y ); x = 25; y += fm.getHeight( ); } g2d.setForeground( dv.getSystemColor( SWT.COLOR_BLACK ) ); y += 10; g2d.drawString( "Message:", x, y );//$NON-NLS-1$ x += g2d.textExtent( "Message:" ).x + 5;//$NON-NLS-1$ g2d.setForeground( dv.getSystemColor( SWT.COLOR_BLUE ) ); g2d.drawString( sMessage, x, y ); x = 25; y += fm.getHeight( ); g2d.setForeground( dv.getSystemColor( SWT.COLOR_BLACK ) ); y += 10; g2d.drawString( "Trace:", x, y );//$NON-NLS-1$ x = 40; y += fm.getHeight( ); g2d.setForeground( dv.getSystemColor( SWT.COLOR_DARK_GREEN ) ); for ( int i = 0; i < stea.length; i++ ) { g2d.drawString( stea[i].getClassName( ) + ":"//$NON-NLS-1$ + stea[i].getMethodName( ) + "(...):"//$NON-NLS-1$ + stea[i].getLineNumber( ), x, y ); x = 40; y += fm.getHeight( ); } fo.dispose( ); }
Example 20
Source File: AngleSelectorComposite.java From birt with Eclipse Public License 1.0 | 2 votes |
/** * * @param d * @param gc * @param x * @param y * @param bSelected */ private static final void smallPoint(Display d, GC gc, int x, int y, boolean bSelected) { gc.setForeground(d.getSystemColor(bSelected ? SWT.COLOR_RED : SWT.COLOR_BLACK)); gc.drawRectangle(x - 1, y - 1, 1, 1); }