Java Code Examples for org.eclipse.swt.graphics.Pattern#dispose()
The following examples show how to use
org.eclipse.swt.graphics.Pattern#dispose() .
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: CollapsableEventSubprocessFigure.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@Override protected void fillShape(Graphics graphics) { if(useGradient){ Rectangle r = getBounds().getCopy(); Point topLeft = r.getTopLeft(); Point bottomRight = r.getBottomRight(); Pattern pattern = new Pattern(Display.getCurrent(), topLeft.x +2, topLeft.y+2 , bottomRight.x-2, bottomRight.y-2,gradientColor,255,getBackgroundColor(),90); graphics.setBackgroundPattern(pattern); graphics.fillRectangle(r.crop(new Insets(2,2,2,2))); graphics.setBackgroundPattern(null); pattern.dispose(); }else{ super.fillShape(graphics) ; } }
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: Bulb.java From nebula with Eclipse Public License 2.0 | 5 votes |
@Override protected void paintClientArea(Graphics graphics) { graphics.setAntialias(SWT.ON); if(effect3D && GraphicsUtil.testPatternSupported(graphics)) { // Fills the circle with solid bulb color graphics.setBackgroundColor(bulbColor); graphics.fillOval(bounds); //diagonal linear gradient Pattern p = new Pattern(Display.getCurrent(), bounds.x, bounds.y, bounds.x + getWidth(), bounds.y + getHeight(), COLOR_WHITE, 255, bulbColor, 0); try { graphics.setBackgroundPattern(p); graphics.fillOval(bounds); p.dispose(); } catch (Exception e) { p.dispose(); } } else { graphics.setBackgroundColor(bulbColor); graphics.fillOval(bounds); } super.paintClientArea(graphics); }
Example 5
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 6
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 7
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 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: PatternImageEditorDialog.java From birt with Eclipse Public License 1.0 | 5 votes |
private static void drawItem( GC gc, PatternImage patternImage, int x, int y ) { int width = VIEW_WIDTH; int height = VIEW_HEIGHT; Device device = gc.getDevice( ); Image image = createImageFromPattern( patternImage ); Pattern pattern = new Pattern( device, image ); gc.setBackgroundPattern( pattern ); gc.fillRectangle( x, y, width, height ); pattern.dispose( ); image.dispose( ); }
Example 10
Source File: DataTableBackgroundImagePainter.java From arx with Apache License 2.0 | 4 votes |
@Override public void paintCell(ILayerCell cell, GC gc, Rectangle rectangle, IConfigRegistry configRegistry) { if (this.bgImage != null) { // Save GC settings Color originalBackground = gc.getBackground(); Color originalForeground = gc.getForeground(); // Ugly hack Pattern pattern = new Pattern(Display.getCurrent(), getImage(rectangle.height)); gc.setBackgroundPattern(pattern); gc.fillRectangle(rectangle); gc.setBackgroundPattern(null); pattern.dispose(); if (isNotNull(this.separatorColor)) { gc.setForeground(this.separatorColor); gc.drawLine( rectangle.x - 1, rectangle.y, rectangle.x - 1, rectangle.y + rectangle.height); gc.drawLine( rectangle.x - 1 + rectangle.width, rectangle.y, rectangle.x - 1 + rectangle.width, rectangle.y + rectangle.height); } // Restore original GC settings gc.setBackground(originalBackground); gc.setForeground(originalForeground); } // Draw interior Rectangle interiorBounds = new Rectangle( rectangle.x + 2, rectangle.y + 2, rectangle.width - 4, rectangle.height - 4); super.paintCell(cell, gc, interiorBounds, configRegistry); }
Example 11
Source File: TabBar.java From nebula with Eclipse Public License 2.0 | 4 votes |
private void onPaint(PaintEvent e) { GC gc = e.gc; int y = getBounds().height - barHeight; int totalWidth = horzMargin + (itemWidth * items.size()) + (itemSpacing * items.size()) - itemSpacing + horzMargin; int croppedWidth = Math.max(totalWidth,getBounds().width); // Region reg = createRoundedTopRegion(0,y,croppedWidth,getClientArea().height - y); // gc.setClipping(reg); Pattern p = new Pattern(getDisplay(), 0, y, 0, y + barHeight, bottom, 255, getBackground(), 0); gc.setBackgroundPattern(p); gc.fillRectangle(0, y,croppedWidth, barHeight); p.dispose(); // reg.dispose(); gc.setClipping((Region)null); gc.setBackgroundPattern(null); int x = horzMargin; if ((getStyle() & SWT.RIGHT) != 0) { if (getBounds().width > totalWidth) { x += getBounds().width - totalWidth; } } y = (getBounds().height - barHeight) - itemHeight; for (Iterator iterator = items.iterator(); iterator.hasNext();) { TabBarItem item = (TabBarItem)iterator.next(); renderer.setBounds(new Rectangle(x,y,itemWidth,itemHeight)); renderer.setSelected(item == selectedItem); renderer.paint(gc, item); x += itemWidth + itemSpacing; } }
Example 12
Source File: SelectionFeedbackEditPolicy.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
public SelectionFeedbackEditPolicy(final EClass eClass) { feedBackFigure = new RoundedRectangle(){ protected void fillShape(Graphics graphics) { Rectangle r = getBounds() ; Point topLeft = r.getTopLeft(); Point bottomRight = r.getBottomRight(); Color backGroundColor = null ; if(useSelectionColor){ backGroundColor = ColorRegistry.getInstance().getColor(selectionColor) ; }else{ backGroundColor=FiguresHelper.getFeedbackColor(eClass) ; } Pattern pattern = new Pattern(Display.getCurrent(), topLeft.x, topLeft.y, bottomRight.x, bottomRight.y, backGroundColor,30, backGroundColor,60); graphics.setBackgroundPattern(pattern); graphics.fillRoundRectangle(r, 20, 20) ; graphics.setAlpha(0) ; graphics.setBackgroundPattern(null); pattern.dispose(); }; } ; figureListener = new FigureListener() { public void figureMoved(IFigure source) { hideFeedback(); List<?> selectedEditPart = getHost().getViewer().getSelectedEditParts() ; if(selectedEditPart.contains(getHost())){ if(!figureIsDisplayed()){ showFeedback(zoomManager.getZoom()); } } } }; }
Example 13
Source File: SwtRendererImpl.java From birt with Eclipse Public License 1.0 | 4 votes |
private final void fillPathImage( Path path, org.eclipse.birt.chart.model.attribute.Image g ) throws ChartException { org.eclipse.swt.graphics.Image img = null; if ( g instanceof EmbeddedImage ) { try { String imageData = ( (EmbeddedImage) g ).getData( ); if ( imageData != null ) { ByteArrayInputStream bis = new ByteArrayInputStream( Base64.decodeBase64( ( (EmbeddedImage) g ).getData( ) .getBytes( ) ) ); img = new org.eclipse.swt.graphics.Image( ( (SwtDisplayServer) _ids ).getDevice( ), bis ); } else { img = createEmptyImage( ); } } catch ( Exception ilex ) { throw new ChartException( ChartDeviceSwtActivator.ID, ChartException.RENDERING, ilex ); } } else if ( g instanceof PatternImage ) { PatternImage patternImage = (PatternImage) g; img = createImageFromPattern( patternImage ); } else { if ( g.getSource( ) == ImageSourceType.STATIC ) { final String sUrl = g.getURL( ); try { img = (org.eclipse.swt.graphics.Image) _ids.loadImage( SecurityUtil.newURL( sUrl ) ); } catch ( MalformedURLException muex ) { throw new ChartException( ChartDeviceSwtActivator.ID, ChartException.RENDERING, muex ); } } else { img = createEmptyImage( ); } } Pattern pattern = new Pattern( _gc.getDevice( ), img ); _gc.setBackgroundPattern( pattern ); _gc.fillPath( path ); pattern.dispose( ); img.dispose( ); }
Example 14
Source File: SwtRendererImpl.java From birt with Eclipse Public License 1.0 | 4 votes |
private final void fillPathGradient( Path path, Gradient g, Rectangle r ) throws ChartException { final ColorDefinition cdStart = g.getStartColor( ); final ColorDefinition cdEnd = g.getEndColor( ); double dAngleInDegrees = g.getDirection( ); if ( dAngleInDegrees < -90 || dAngleInDegrees > 90 ) { throw new ChartException( ChartDeviceSwtActivator.ID, ChartException.RENDERING, "SwtRendererImpl.exception.gradient.angle", //$NON-NLS-1$ new Object[]{ new Double( dAngleInDegrees ) }, Messages.getResourceBundle( getULocale( ) ) ); } final Color cPreviousFG = _gc.getForeground( ); final Color cPreviousBG = _gc.getBackground( ); Color cFG = (Color) _ids.getColor( cdStart ); Color cBG = (Color) _ids.getColor( cdEnd ); float x1, y1, x2, y2; // #232647 // The maximal round-off error to calculate x2 and y2 here can be 2. // And if the pattern value is less than the forground, it is very obvious. // So we add 2 here to overcome this error. final int iMaxError = 2; if ( dAngleInDegrees == 0 ) { x1 = r.x; x2 = r.x + r.width + iMaxError; y1 = y2 = r.y; } else if ( dAngleInDegrees == 90 ) { x1 = x2 = r.x; y1 = r.y + r.height + iMaxError; y2 = r.y; } else if ( dAngleInDegrees == -90 ) { x1 = x2 = r.x; y1 = r.y; y2 = r.y + r.height + iMaxError; } else if ( dAngleInDegrees > 0 ) { x1 = r.x; y1 = r.y + r.height; x2 = r.x + r.width + iMaxError; y2 = r.y; } else { x1 = r.x; y1 = r.y; x2 = r.x + r.width; y2 = r.y + r.height; } _gc.setForeground( cFG ); _gc.setBackground( cBG ); R31Enhance.setAlpha( _gc, g ); Pattern pattern = new Pattern( _gc.getDevice( ), x1, y1, x2, y2, cFG, cdStart.getTransparency( ), cBG, cdEnd.getTransparency( ) ); _gc.setBackgroundPattern( pattern ); _gc.fillPath( path ); _gc.setForeground( cPreviousFG ); _gc.setBackground( cPreviousBG ); cFG.dispose( ); cBG.dispose( ); pattern.dispose( ); }
Example 15
Source File: LoginDialog.java From nebula with Eclipse Public License 2.0 | 4 votes |
/** * Create a default image. It is a port of the image used by the Login Box * in the project SwingX * * @param w width * @param h height * @return a default image (blue wave) */ private Image createDefaultImage(final int w, final int h) { final Display display = Display.getCurrent(); final Color backgroundColor = new Color(display, 49, 121, 242); final Color gradientColor1 = new Color(display, 155, 185, 245); final Color gradientColor2 = new Color(display, 53, 123, 242); final Image img = new Image(display, w, h); final GC gc = new GC(img); gc.setAdvanced(true); gc.setAntialias(SWT.ON); gc.setBackground(backgroundColor); gc.fillRectangle(0, 0, w, h); final Path curveShape = new Path(display); curveShape.moveTo(0, h * .6f); curveShape.cubicTo(w * .167f, h * 1.2f, w * .667f, h * -.5f, w, h * .75f); curveShape.lineTo(w, h); curveShape.lineTo(0, h); curveShape.lineTo(0, h * .8f); curveShape.close(); final Pattern pattern = new Pattern(display, 0, 0, 1, h * 1.2f, gradientColor1, gradientColor2); gc.setBackgroundPattern(pattern); gc.fillPath(curveShape); final Font font = new Font(display, "Arial Bold", 30, SWT.NONE); gc.setFont(font); gc.setForeground(display.getSystemColor(SWT.COLOR_WHITE)); final Point textSize = gc.stringExtent(ResourceManager.getLabel(ResourceManager.LOGIN)); gc.drawString(ResourceManager.getLabel(ResourceManager.LOGIN), (int) (w * .05f), (h - textSize.y) / 2, true); font.dispose(); curveShape.dispose(); pattern.dispose(); backgroundColor.dispose(); gradientColor1.dispose(); gradientColor2.dispose(); gc.dispose(); return img; }
Example 16
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 17
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 18
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(); }