Java Code Examples for org.eclipse.draw2d.Graphics#fillRoundRectangle()

The following examples show how to use org.eclipse.draw2d.Graphics#fillRoundRectangle() . 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: ThermometerFigure.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
@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 2
Source File: RoundedNode.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void paintFigure(Graphics graphics) {
	float lineInset = .5f;
	int inset1 = (int) Math.floor(lineInset);
	int inset2 = (int) Math.ceil(lineInset);

	Rectangle r = Rectangle.SINGLETON.setBounds(getBounds());
	r.x += inset1;
	r.y += inset1;
	r.width -= inset1 + inset2;
	r.height -= inset1 + inset2;

	graphics.fillRoundRectangle(r, Math.max(0, ILayoutConstants.ROUNDED_RECTANGLE_RADIUS - (int) lineInset), Math.max(0, ILayoutConstants.ROUNDED_RECTANGLE_RADIUS - (int) lineInset));
	graphics.drawRoundRectangle(r, Math.max(0, ILayoutConstants.ROUNDED_RECTANGLE_RADIUS - (int) lineInset), Math.max(0, ILayoutConstants.ROUNDED_RECTANGLE_RADIUS - (int) lineInset));
}
 
Example 3
Source File: DropShadowRectangle.java    From ermasterr with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected void fillShape(final Graphics graphics) {
    Rectangle f = Rectangle.SINGLETON.setBounds(getBounds());
    final Insets shadowInset = new Insets(0, 0, SHADOW_INSET, SHADOW_INSET);
    f = shrink(f, shadowInset);
    drawShadow(f, graphics);
    final Dimension cornerDimensions = getCornerDimensions();
    graphics.fillRoundRectangle(f, cornerDimensions.width, cornerDimensions.height);
}
 
Example 4
Source File: DropShadowRectangle.java    From ermasterr with Apache License 2.0 5 votes vote down vote up
private void drawShadowLayer(final Rectangle rectangle, final Graphics graphics, final int offset, final Color color) {

        // Save the state of the graphics object
        graphics.pushState();
        graphics.setLineWidth(0);
        graphics.setBackgroundColor(color);
        final Rectangle shadowLayer = new Rectangle(rectangle);
        shadowLayer.x += offset;
        shadowLayer.y += offset;

        final Dimension cornerDimensions = getCornerDimensions();
        graphics.fillRoundRectangle(shadowLayer, cornerDimensions.width, cornerDimensions.height);
        // Restore the start of the graphics object
        graphics.popState();
    }
 
Example 5
Source File: DropShadowRectangle.java    From erflute with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
protected void fillShape(Graphics graphics) {
    Rectangle f = Rectangle.SINGLETON.setBounds(getBounds());
    final Insets shadowInset = new Insets(0, 0, SHADOW_INSET, SHADOW_INSET);
    f = shrink(f, shadowInset);
    drawShadow(f, graphics);
    graphics.fillRoundRectangle(f, corner.width, corner.height);
}
 
Example 6
Source File: DropShadowRectangle.java    From erflute with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
private void drawShadowLayer(Rectangle rectangle, Graphics graphics, int offset, Color color) {
    // Save the state of the graphics object
    graphics.pushState();
    graphics.setLineWidth(0);
    graphics.setBackgroundColor(color);
    final Rectangle shadowLayer = new Rectangle(rectangle);
    shadowLayer.x += offset;
    shadowLayer.y += offset;
    graphics.fillRoundRectangle(shadowLayer, corner.width, corner.height);
    // Restore the start of the graphics object
    graphics.popState();
}
 
Example 7
Source File: ProcessFigure.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
private void paintBody(Graphics g) {
	Rectangle rect = new Rectangle(getLocation(), getSize());
	g.fillRoundRectangle(rect, 15, 15);
	String singleVal = format(node.directResult);
	String singlePerc = format(node.directContribution * 100);
	String totalVal = format(node.upstreamResult);
	String totalPerc = format(node.upstreamContribution * 100);
	String single = singleVal + " (" + singlePerc + "%)";
	String total = totalVal + " (" + totalPerc + "%)";
	drawTexts(g, single, total);
	drawDqBar(g);
}
 
Example 8
Source File: DropShadowRectangle.java    From ermaster-b with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected void fillShape(Graphics graphics) {
	Rectangle f = Rectangle.SINGLETON.setBounds(getBounds());
	Insets shadowInset = new Insets(0, 0, SHADOW_INSET, SHADOW_INSET);
	f = shrink(f, shadowInset);
	this.drawShadow(f, graphics);
	graphics.fillRoundRectangle(f, corner.width,
			corner.height);
}
 
Example 9
Source File: DropShadowRectangle.java    From ermaster-b with Apache License 2.0 5 votes vote down vote up
private void drawShadowLayer(Rectangle rectangle, Graphics graphics,
		int offset, Color color) {

	// Save the state of the graphics object
	graphics.pushState();
	graphics.setLineWidth(0);
	graphics.setBackgroundColor(color);
	Rectangle shadowLayer = new Rectangle(rectangle);
	shadowLayer.x += offset;
	shadowLayer.y += offset;
	graphics.fillRoundRectangle(shadowLayer, corner.width,
			corner.height);
	// Restore the start of the graphics object
	graphics.popState();
}
 
Example 10
Source File: ThermometerFigure.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
@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 11
Source File: SelectionFeedbackEditPolicy.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
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());
				}
			}
		}
	};

}