Java Code Examples for org.eclipse.draw2d.Graphics#setClip()
The following examples show how to use
org.eclipse.draw2d.Graphics#setClip() .
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: 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 2
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 3
Source File: ExitFigure.java From statecharts with Eclipse Public License 1.0 | 5 votes |
@Override public void paint(Graphics graphics) { graphics.pushState(); graphics.setForegroundColor(getForegroundColor()); graphics.setBackgroundColor(getBackgroundColor()); super.paint(graphics); Path path = new Path(Display.getDefault()); path.addArc(getBounds().x, getBounds().y, getBounds().width - 1, getBounds().height - 1, 0, 360); graphics.setClip(path); graphics.setLineWidth(2); graphics.drawLine(bounds.getTopLeft(), bounds.getBottomRight()); graphics.drawLine(bounds.getTopRight(), bounds.getBottomLeft()); path.dispose(); graphics.popState(); }
Example 4
Source File: ReportElementFigure.java From birt with Eclipse Public License 1.0 | 5 votes |
protected void paintBorder( Graphics graphics ) { if ( clip != null ) { graphics.getClip( OLD_CLIP ); graphics.setClip( getBounds( ).getCopy( ).intersect( clip ) ); } super.paintBorder( graphics ); if ( clip != null ) { graphics.setClip( OLD_CLIP ); } }
Example 5
Source File: ReportElementFigure.java From birt with Eclipse Public License 1.0 | 4 votes |
/** * @see org.eclipse.draw2d.Figure#paintFigure(Graphics) */ protected void paintFigure( Graphics graphics ) { if ( isOpaque( ) ) { if ( getBorder( ) instanceof BaseBorder ) { graphics.fillRectangle( getBounds( ).getCopy().crop( ( (BaseBorder) getBorder( ) ).getBorderInsets( ) ) ); } else { graphics.fillRectangle( getBounds( ) ); } } Image image = getImage( ); if ( image == null ) { return; } int x, y; Rectangle area = getBounds( ); graphics.getClip( PRIVATE_RECT ); //graphics.setClip( area ); // Calculates X if ( position != null && position.x != -1 ) { x = area.x + position.x; } else { switch ( alignment & PositionConstants.EAST_WEST ) { case PositionConstants.EAST : x = area.x + area.width - size.width; break; case PositionConstants.WEST : x = area.x; break; default : x = ( area.width - size.width ) / 2 + area.x; break; } } // Calculates Y if ( position != null && position.y != -1 ) { y = area.y + position.y; } else { switch ( alignment & PositionConstants.NORTH_SOUTH ) { case PositionConstants.NORTH : y = area.y; break; case PositionConstants.SOUTH : y = area.y + area.height - size.height; break; default : y = ( area.height - size.height ) / 2 + area.y; break; } } ArrayList xyList = createImageList( x, y ); Iterator iter = xyList.iterator( ); Dimension imageSize = new Rectangle( image.getBounds( ) ).getSize( ); while ( iter.hasNext( ) ) { Point point = (Point) iter.next( ); graphics.drawImage( image, 0, 0, imageSize.width, imageSize.height, point.x, point.y, size.width, size.height); } xyList.clear( ); graphics.setClip( PRIVATE_RECT ); }