Java Code Examples for org.eclipse.draw2d.Graphics#setBackgroundPattern()
The following examples show how to use
org.eclipse.draw2d.Graphics#setBackgroundPattern() .
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: 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 3
Source File: GraphicsUtil.java From nebula with Eclipse Public License 2.0 | 6 votes |
public static synchronized boolean testPatternSupported(Graphics graphics){ if(SWT.getPlatform().startsWith("rap")) //$NON-NLS-1$ return false; if(!Preferences.useAdvancedGraphics()) return false; String value = System.getProperty(Preferences.PROHIBIT_ADVANCED_GRAPHICS); //$NON-NLS-1$ if(value != null && value.equals("true")) //$NON-NLS-1$ return false; boolean support3D = true; //just test if pattern is supported on the platform. try { graphics.setBackgroundPattern(null); } catch (Exception e) { support3D= false; } return support3D; }
Example 4
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 5
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 6
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 7
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 8
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 9
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 10
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 11
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 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()); } } } }; }