Java Code Examples for org.eclipse.swt.graphics.GC#drawPolygon()
The following examples show how to use
org.eclipse.swt.graphics.GC#drawPolygon() .
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: AngleSelectorComposite.java From birt with Eclipse Public License 1.0 | 6 votes |
/** * * @param dAngle * @param gc * @param x * @param y */ private final void drawHand(Display d, GC gc, int x, int y, int r, double dAngleInDegrees, boolean bErase) { gc.setForeground(bErase ? clrBG : d.getSystemColor(SWT.COLOR_BLACK)); gc.setBackground(bErase ? clrBG : d.getSystemColor(SWT.COLOR_RED)); final double dAngleInRadians = Math.toRadians(dAngleInDegrees); final int rMinus = r - 10; final double dAngleInRadiansMinus = Math.toRadians(dAngleInDegrees - 3); final double dAngleInRadiansPlus = Math.toRadians(dAngleInDegrees + 3); final int xTip = (int) (x + r * Math.cos(dAngleInRadians)); final int yTip = (int) (y - r * Math.sin(dAngleInRadians)); // DRAW THE STICK gc.drawLine(x, y, xTip, yTip); // DRAW THE ARROW iaPolygon[0] = xTip; iaPolygon[1] = yTip; iaPolygon[2] = (int) (x + rMinus * Math.cos(dAngleInRadiansMinus)); iaPolygon[3] = (int) (y - rMinus * Math.sin(dAngleInRadiansMinus)); iaPolygon[4] = (int) (x + rMinus * Math.cos(dAngleInRadiansPlus)); iaPolygon[5] = (int) (y - rMinus * Math.sin(dAngleInRadiansPlus)); gc.fillPolygon(iaPolygon); gc.drawPolygon(iaPolygon); }
Example 2
Source File: TableDraw.java From hop with Apache License 2.0 | 5 votes |
private void drawMarker( GC gc, int x, int maxy ) { int[] triangle = new int[] { LEFT + MARGIN + x * fontwidth + offset.x, TOP - 4, LEFT + MARGIN + x * fontwidth + offset.x + 3, TOP + 1, LEFT + MARGIN + x * fontwidth + offset.x - 3, TOP + 1 }; gc.fillPolygon( triangle ); gc.drawPolygon( triangle ); gc .drawLine( LEFT + MARGIN + x * fontwidth + offset.x, TOP + 1, LEFT + MARGIN + x * fontwidth + offset.x, maxy ); }
Example 3
Source File: TwisteToggleRenderer.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); Color back = gc.getBackground(); Color fore = gc.getForeground(); if (!isHover()) { gc.setForeground(gc.getDevice().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW)); } else { gc.setForeground(gc.getDevice().getSystemColor(SWT.COLOR_LIST_SELECTION)); } gc.setBackground(gc.getForeground()); if (isExpanded()) { gc.drawPolygon(new int[] {1, 3, 4, 6, 5, 6, 8, 3 }); gc.fillPolygon(new int[] {1, 3, 4, 6, 5, 6, 8, 3 }); } else { gc.drawPolygon(new int[] {3, 1, 6, 4, 6, 5, 3, 8 }); gc.fillPolygon(new int[] {3, 1, 6, 4, 6, 5, 3, 8 }); } if (isFocus()) { gc.setBackground(back); gc.setForeground(fore); gc.drawFocus(-1, -1, 12, 12); } gc.setTransform(null); transform.dispose(); }
Example 4
Source File: ChevronsToggleRenderer.java From nebula with Eclipse Public License 2.0 | 5 votes |
/** * @see org.eclipse.nebula.widgets.pgroup.AbstractRenderer#paint(org.eclipse.swt.graphics.GC, java.lang.Object) */ public void paint(GC gc, Object value) { Transform transform = new Transform(gc.getDevice()); transform.translate(getBounds().x, getBounds().y); gc.setTransform(transform); Color back = gc.getBackground(); Color fore = gc.getForeground(); if (isHover()) { Color old = gc.getForeground(); gc.setForeground(gc.getDevice().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW)); gc.drawRoundRectangle(0, 0, 16, 15, 5, 5); gc.setForeground(old); } if (isExpanded()) { gc.drawPolygon(new int[] {5, 6, 8, 3, 11, 6, 10, 6, 8, 4, 6, 6 }); gc.drawPolygon(new int[] {5, 10, 8, 7, 11, 10, 10, 10, 8, 8, 6, 10 }); } else { gc.drawPolygon(new int[] {5, 4, 8, 7, 11, 4, 10, 4, 8, 6, 6, 4 }); gc.drawPolygon(new int[] {5, 8, 8, 11, 11, 8, 10, 8, 8, 10, 6, 8 }); } if (isFocus()) { gc.setBackground(back); gc.setForeground(fore); gc.drawFocus(2, 2, 13, 12); } gc.setTransform(null); transform.dispose(); }
Example 5
Source File: ToggleRenderer.java From nebula with Eclipse Public License 2.0 | 5 votes |
private void paintMacTwistie(GC gc) { Transform transform = new Transform(gc.getDevice()); transform.translate(getBounds().x, getBounds().y); gc.setTransform(transform); Color back = gc.getBackground(); Color fore = gc.getForeground(); if (!isHover()) { gc.setForeground(gc.getDevice().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW)); } else { gc.setForeground(gc.getDevice().getSystemColor(SWT.COLOR_LIST_SELECTION)); } gc.setBackground(gc.getForeground()); if (isExpanded()) { gc.drawPolygon(new int[] { 1, 3, 4, 6, 5, 6, 8, 3 }); gc.fillPolygon(new int[] { 1, 3, 4, 6, 5, 6, 8, 3 }); } else { gc.drawPolygon(new int[] { 3, 1, 6, 4, 6, 5, 3, 8 }); gc.fillPolygon(new int[] { 3, 1, 6, 4, 6, 5, 3, 8 }); } if (isFocus()) { gc.setBackground(back); gc.setForeground(fore); gc.drawFocus(-1, -1, 12, 12); } gc.setTransform(null); transform.dispose(); }
Example 6
Source File: AngleSelectorComposite.java From birt with Eclipse Public License 1.0 | 5 votes |
/** * * @param d * @param gc * @param x * @param y * @param bSelected */ private static final void bigPoint(Display d, GC gc, int x, int y, boolean bSelected) { gc.setForeground(d.getSystemColor(SWT.COLOR_BLACK)); gc.setBackground(d.getSystemColor(bSelected ? SWT.COLOR_RED : SWT.COLOR_BLACK)); final int[] iaXY = { x, y - 3, x - 3, y, x, y + 3, x + 3, y }; // TBD: REUSE INSTANCE VAR gc.fillPolygon(iaXY); gc.drawPolygon(iaXY); }
Example 7
Source File: MapView.java From olca-app with Mozilla Public License 2.0 | 5 votes |
private void renderPolygon(GC gc, LayerConfig conf, Feature f, Polygon polygon) { int[] points = translation.translate(polygon); Color fillColor = conf.getFillColor(f); if (fillColor != null) { gc.setBackground(fillColor); gc.setAlpha(fillColor.getAlpha()); gc.fillPolygon(points); gc.setAlpha(255); } // TODO: fill inner rings as white polygons // overlapping features can anyhow cause problems gc.drawPolygon(points); }
Example 8
Source File: FixedTableDraw.java From pentaho-kettle with Apache License 2.0 | 5 votes |
private void drawMarker( GC gc, int x, int maxy ) { int[] triangle = new int[] { LEFT + MARGIN + x * fontwidth + offset.x, TOP - 4, LEFT + MARGIN + x * fontwidth + offset.x + 3, TOP + 1, LEFT + MARGIN + x * fontwidth + offset.x - 3, TOP + 1 }; gc.fillPolygon( triangle ); gc.drawPolygon( triangle ); gc .drawLine( LEFT + MARGIN + x * fontwidth + offset.x, TOP + 1, LEFT + MARGIN + x * fontwidth + offset.x, maxy ); }
Example 9
Source File: TableDraw.java From pentaho-kettle with Apache License 2.0 | 5 votes |
private void drawMarker( GC gc, int x, int maxy ) { int[] triangle = new int[] { LEFT + MARGIN + x * fontwidth + offset.x, TOP - 4, LEFT + MARGIN + x * fontwidth + offset.x + 3, TOP + 1, LEFT + MARGIN + x * fontwidth + offset.x - 3, TOP + 1 }; gc.fillPolygon( triangle ); gc.drawPolygon( triangle ); gc .drawLine( LEFT + MARGIN + x * fontwidth + offset.x, TOP + 1, LEFT + MARGIN + x * fontwidth + offset.x, maxy ); }
Example 10
Source File: NebulaToolbar.java From nebula with Eclipse Public License 2.0 | 4 votes |
/** * Paint widget using Windows Vista mode on graphical canvas. * * @param gc GC */ private void paintVista(GC gc) { Color defaultForeground = gc.getForeground(); Color defaultBackground = gc.getBackground(); Rectangle rect = getClientArea(); Device device = gc.getDevice(); Color c1 = new Color(device, 5, 72, 117); Color c2 = new Color(device, 25, 108, 119); Color c3 = new Color(device, 28, 122, 134); Color wh = getDisplay().getSystemColor(SWT.COLOR_WHITE); int middle = (int) Math.ceil(rect.height / 2); Pattern patternBg1 = new Pattern(device, 0, 0, rect.width, middle, c1, 255, c3, 255); gc.setBackgroundPattern(patternBg1); gc.fillRectangle(new Rectangle(0, 0, rect.width, middle)); gc.setBackgroundPattern(null); Pattern patternBg2 = new Pattern(device, 0, middle, rect.width, rect.height - middle, c1, 255, c2, 255); gc.setBackgroundPattern(patternBg2); gc.fillRectangle(new Rectangle(0, middle, rect.width, rect.height - middle)); gc.setBackgroundPattern(null); Pattern patternTopGrad = new Pattern(device, 0, 0, 0, middle, wh, 120, wh, 50); gc.setBackgroundPattern(patternTopGrad); gc.fillRectangle(new Rectangle(0, 0, rect.width, middle)); gc.setBackgroundPattern(null); Pattern patternBtmGrad = new Pattern(device, 0, middle + 5, 0, rect.height, c1, 0, wh, 125); gc.setBackgroundPattern(patternBtmGrad); gc.fillRectangle(new Rectangle(0, middle + 5, rect.width, rect.height)); gc.setBackgroundPattern(null); gc.setAlpha(125); gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WHITE)); gc.drawPolygon(new int[]{0, 0, rect.width - 1, 0, rect.width - 1, rect.height - 2, 0, rect.height - 2}); gc.setAlpha(200); gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_BLACK)); gc.drawLine(0, rect.height - 1, rect.width - 1, rect.height - 1); gc.setForeground(defaultForeground); gc.setBackground(defaultBackground); gc.setAlpha(255); c1.dispose(); c2.dispose(); c3.dispose(); patternBg1.dispose(); patternBg2.dispose(); patternTopGrad.dispose(); patternBtmGrad.dispose(); }
Example 11
Source File: HeadStyleCanvas.java From birt with Eclipse Public License 1.0 | 4 votes |
public void paintControl( PaintEvent pe ) { if ( isEnabled( ) && isFocusControl( ) ) { isFocusIn = true; } Color cForeground = null; Color cBackground = null; if ( this.isEnabled( ) ) { cForeground = getDisplay( ).getSystemColor( SWT.COLOR_LIST_FOREGROUND ); cBackground = getDisplay( ).getSystemColor( SWT.COLOR_LIST_BACKGROUND ); } else { cForeground = getDisplay( ).getSystemColor( SWT.COLOR_DARK_GRAY ); cBackground = getDisplay( ).getSystemColor( SWT.COLOR_WIDGET_BACKGROUND ); } GC gc = pe.gc; if ( isFocusIn ) { gc.setBackground( getDisplay( ).getSystemColor( SWT.COLOR_LIST_SELECTION ) ); gc.setForeground( getDisplay( ).getSystemColor( SWT.COLOR_LIST_SELECTION_TEXT ) ); } else { gc.setBackground( cBackground ); gc.setForeground( cForeground ); } gc.fillRectangle( 0, 0, this.getSize( ).x, this.getSize( ).y ); gc.setLineWidth( 1 ); gc.drawLine( 10, this.getSize( ).y / 2, this.getSize( ).x - 10, this.getSize( ).y / 2 ); if ( iLineDecorator == LineDecorator.ARROW ) { int[] points = { this.getSize( ).x - 15, this.getSize( ).y / 2 - 3, this.getSize( ).x - 15, this.getSize( ).y / 2 + 3, this.getSize( ).x - 10, this.getSize( ).y / 2 }; gc.setLineWidth( 3 ); gc.drawPolygon( points ); } else if ( iLineDecorator == LineDecorator.CIRCLE ) { gc.setLineWidth( 4 ); gc.drawOval( this.getSize( ).x - 14, this.getSize( ).y / 2 - 3, 6, 6 ); } }
Example 12
Source File: SwtTextRenderer.java From birt with Eclipse Public License 1.0 | 4 votes |
private final void renderBorder( IChartComputation cComp, GC gc, Label la, int iLabelLocation, Location lo ) throws ChartException { // RENDER THE OUTLINE/BORDER final LineAttributes lia = la.getOutline( ); if ( lia != null && lia.isVisible( ) && lia.getColor( ) != null ) { RotatedRectangle rr = cComp.computePolygon( _sxs, iLabelLocation, la, lo.getX( ), lo.getY( ), null ); final int iOldLineStyle = gc.getLineStyle( ); final int iOldLineWidth = gc.getLineWidth( ); final Color cFG = (Color) _sxs.getColor( lia.getColor( ) ); gc.setForeground( cFG ); R31Enhance.setAlpha( gc, lia.getColor( ) ); int iLineStyle = SWT.LINE_SOLID; switch ( lia.getStyle( ).getValue( ) ) { case ( LineStyle.DOTTED ) : iLineStyle = SWT.LINE_DOT; break; case ( LineStyle.DASH_DOTTED ) : iLineStyle = SWT.LINE_DASHDOT; break; case ( LineStyle.DASHED ) : iLineStyle = SWT.LINE_DASH; break; } gc.setLineStyle( iLineStyle ); gc.setLineWidth( lia.getThickness( ) ); gc.drawPolygon( rr.getSwtPoints( ) ); gc.setLineStyle( iOldLineStyle ); gc.setLineWidth( iOldLineWidth ); cFG.dispose( ); } }