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

The following examples show how to use org.eclipse.draw2d.Graphics#setAlpha() . 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: NoteFigure.java    From ermaster-b with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected void fillShape(Graphics graphics) {
	graphics.setAlpha(200);

	Rectangle bounds = this.getBounds();

	Point topRight1 = bounds.getTopRight().translate(0, RETURN_WIDTH);
	Point topRight2 = bounds.getTopRight().translate(-RETURN_WIDTH, 0);

	PointList pointList = new PointList();
	pointList.addPoint(bounds.getTopLeft());
	pointList.addPoint(bounds.getBottomLeft());
	pointList.addPoint(bounds.getBottomRight());
	pointList.addPoint(topRight1);
	pointList.addPoint(topRight2);
	pointList.addPoint(bounds.getTopLeft());

	graphics.fillPolygon(pointList);
}
 
Example 2
Source File: NormalColumnFigure.java    From ermasterr with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected void paintFigure(final Graphics graphics) {
    if (graphics.getBackgroundColor().equals(getParent().getBackgroundColor())) {
        graphics.setAlpha(0);
    }

    super.paintFigure(graphics);
}
 
Example 3
Source File: NormalColumnFigure.java    From erflute with Apache License 2.0 5 votes vote down vote up
@Override
protected void paintFigure(Graphics graphics) {
    if (graphics.getBackgroundColor().equals(getParent().getBackgroundColor())) {
        graphics.setAlpha(0);
    }

    super.paintFigure(graphics);
}
 
Example 4
Source File: GroupColumnFigure.java    From erflute with Apache License 2.0 5 votes vote down vote up
@Override
protected void paintFigure(Graphics graphics) {
    if (graphics.getBackgroundColor().equals(getParent().getBackgroundColor())) {
        graphics.setAlpha(0);
    }

    super.paintFigure(graphics);
}
 
Example 5
Source File: IndexFigure.java    From erflute with Apache License 2.0 5 votes vote down vote up
@Override
protected void paintFigure(Graphics graphics) {
    if (graphics.getBackgroundColor().equals(getParent().getBackgroundColor())) {
        graphics.setAlpha(0);
    }

    super.paintFigure(graphics);
}
 
Example 6
Source File: InsertedImageFigure.java    From erflute with Apache License 2.0 5 votes vote down vote up
@Override
protected void paintFigure(Graphics graphics) {
    super.paintFigure(graphics);

    graphics.setAlpha(alpha);

    final Rectangle area = getClientArea();
    if (fixAspectRatio) {
        final Rectangle destination = new Rectangle();

        final double dw = (double) imageSize.width / (double) area.width;
        final double dh = (double) imageSize.height / (double) area.height;

        if (dw > dh) {
            // we must limit the size by the width
            destination.width = area.width;
            destination.height = (int) (imageSize.height / dw);
        } else {
            // we must limit the size by the height
            destination.width = (int) (imageSize.width / dh);
            destination.height = area.height;
        }

        destination.x = (area.width - destination.width) / 2 + area.x;
        destination.y = (area.height - destination.height) / 2 + area.y;

        graphics.drawImage(image, new Rectangle(image.getBounds()), destination);
    } else {
        graphics.drawImage(image, new Rectangle(image.getBounds()), area);
    }
}
 
Example 7
Source File: IndexFigure.java    From ermaster-b with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected void paintFigure(Graphics graphics) {
	if (graphics.getBackgroundColor().equals(
			this.getParent().getBackgroundColor())) {
		graphics.setAlpha(0);
	}

	super.paintFigure(graphics);
}
 
Example 8
Source File: InsertedImageFigure.java    From ermaster-b with Apache License 2.0 5 votes vote down vote up
@Override
protected void paintFigure(Graphics graphics) {
	super.paintFigure(graphics);

	graphics.setAlpha(alpha);

	Rectangle area = getClientArea();

	if (this.fixAspectRatio) {
		Rectangle destination = new Rectangle();

		double dw = (double) this.imageSize.width / (double) area.width;
		double dh = (double) this.imageSize.height / (double) area.height;

		if (dw > dh) {
			// we must limit the size by the width
			destination.width = area.width;
			destination.height = (int) (this.imageSize.height / dw);

		} else {
			// we must limit the size by the height
			destination.width = (int) (this.imageSize.width / dh);
			destination.height = area.height;

		}

		destination.x = (area.width - destination.width) / 2 + area.x;
		destination.y = (area.height - destination.height) / 2 + area.y;

		graphics.drawImage(this.image,
				new Rectangle(this.image.getBounds()), destination);

	} else {
		graphics.drawImage(this.image,
				new Rectangle(this.image.getBounds()), area);

	}

}
 
Example 9
Source File: GroupColumnFigure.java    From ermasterr with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected void paintFigure(final Graphics graphics) {
    if (graphics.getBackgroundColor().equals(getParent().getBackgroundColor())) {
        graphics.setAlpha(0);
    }

    super.paintFigure(graphics);
}
 
Example 10
Source File: TextController.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
public TextController ( final FigureCanvas canvas, final SymbolController controller, final Text element, final ResourceManager manager )
{
    super ( controller, manager );
    this.canvas = canvas;
    this.figure = new Label ( element.getText ()) {
        @Override
        public void addNotify ()
        {
            super.addNotify ();
            start ();
        }

        @Override
        protected void paintFigure ( final Graphics graphics )
        {
            final Double alpha = getAlpha ();
            if ( alpha != null )
            {
                graphics.setAlpha ( (int) ( Math.max ( 0.0, Math.min ( 1.0, alpha ) ) * 255.0 ) );
            }
            super.paintFigure ( graphics );
        }

        @Override
        public void removeNotify ()
        {
            stop ();
            super.removeNotify ( );
        }
    };
    controller.addElement ( element, this );

    applyCommon ( element );
}
 
Example 11
Source File: KnobFigure.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected void paintClientArea(Graphics graphics) {
	
	super.paintClientArea(graphics);
	if(!isEnabled()) {
		graphics.setAlpha(DISABLED_ALPHA);
		graphics.setBackgroundColor(GRAY_COLOR);
		graphics.fillRectangle(bounds);
	}		
}
 
Example 12
Source File: CategoryFigure.java    From ermasterr with Apache License 2.0 4 votes vote down vote up
@Override
protected void fillShape(final Graphics graphics) {
    graphics.setAlpha(100);
    super.fillShape(graphics);
}
 
Example 13
Source File: Trace.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Draw line with the line style and line width of the trace.
 * 
 * @param graphics
 * @param p1
 * @param p2
 */
public void drawLine(Graphics graphics, Point p1, Point p2) {
	graphics.pushState();
	graphics.setLineWidth(lineWidth);
	switch (traceType) {
	case SOLID_LINE:
		graphics.setLineStyle(SWTConstants.LINE_SOLID);
		graphics.drawLine(p1, p2);
		break;
	case BAR:
		if (use_advanced_graphics)
			graphics.setAlpha(areaAlpha);
		graphics.setLineStyle(SWTConstants.LINE_SOLID);
		graphics.drawLine(p1, p2);
		break;
	case DASH_LINE:
		graphics.setLineStyle(SWTConstants.LINE_DASH);
		graphics.drawLine(p1, p2);
		break;
	case DASHDOT_LINE:
		graphics.setLineStyle(SWTConstants.LINE_DASHDOT);
		graphics.drawLine(p1, p2);
		break;
	case DASHDOTDOT_LINE:
		graphics.setLineStyle(SWTConstants.LINE_DASHDOTDOT);
		graphics.drawLine(p1, p2);
		break;
	case DOT_LINE:
		graphics.setLineStyle(SWTConstants.LINE_DOT);
		graphics.drawLine(p1, p2);
		break;
	case AREA:
	case LINE_AREA:
		if (traceType == TraceType.LINE_AREA) {
			graphics.setLineStyle(SWTConstants.LINE_SOLID);
			graphics.drawLine(p1, p2);
		}
		int basey;
		switch (baseLine) {
		case NEGATIVE_INFINITY:
			basey = yAxis.getValuePosition(yAxis.getRange().getLower(), false);
			break;
		case POSITIVE_INFINITY:
			basey = yAxis.getValuePosition(yAxis.getRange().getUpper(), false);
			break;
		default:
			basey = yAxis.getValuePosition(0, false);
			break;
		}
		if (use_advanced_graphics)
			graphics.setAlpha(areaAlpha);
		graphics.setBackgroundColor(traceColor);
		graphics.fillPolygon(new int[] { p1.x, p1.y, p1.x, basey, p2.x, basey, p2.x, p2.y });
		break;
	case STEP_HORIZONTALLY:
		graphics.setLineStyle(SWTConstants.LINE_SOLID);
		graphics.drawLine(p1.x, p1.y, p2.x, p1.y);
		graphics.drawLine(p2.x, p1.y, p2.x, p2.y);
		break;
	case STEP_VERTICALLY:
		graphics.setLineStyle(SWTConstants.LINE_SOLID);
		graphics.drawLine(p1.x, p1.y, p1.x, p2.y);
		graphics.drawLine(p1.x, p2.y, p2.x, p2.y);
		break;

	default:
		break;
	}
	graphics.popState();
}
 
Example 14
Source File: CategoryFigure.java    From erflute with Apache License 2.0 4 votes vote down vote up
@Override
protected void fillShape(Graphics graphics) {
    graphics.setAlpha(100);
    super.fillShape(graphics);
}
 
Example 15
Source File: ERModelFigure.java    From erflute with Apache License 2.0 4 votes vote down vote up
@Override
protected void fillShape(Graphics graphics) {
    graphics.setAlpha(100);
    super.fillShape(graphics);
}
 
Example 16
Source File: WalkerGroupFigure.java    From erflute with Apache License 2.0 4 votes vote down vote up
@Override
protected void fillShape(Graphics graphics) {
    graphics.setAlpha(100);
    super.fillShape(graphics);
}
 
Example 17
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());
				}
			}
		}
	};

}
 
Example 18
Source File: ERModelFigure.java    From ermaster-b with Apache License 2.0 4 votes vote down vote up
@Override
protected void fillShape(Graphics graphics) {
	graphics.setAlpha(100);
	super.fillShape(graphics);
}
 
Example 19
Source File: VGroupFigure.java    From ermaster-b with Apache License 2.0 4 votes vote down vote up
@Override
protected void fillShape(Graphics graphics) {
	graphics.setAlpha(100);
	super.fillShape(graphics);
}
 
Example 20
Source File: InsertedImageFigure.java    From ermasterr with Apache License 2.0 3 votes vote down vote up
@Override
protected void paintFigure(final Graphics graphics) {
    super.paintFigure(graphics);

    graphics.setAlpha(alpha);

    final Rectangle area = getClientArea();

    if (fixAspectRatio) {
        final Rectangle destination = new Rectangle();

        final double dw = (double) imageSize.width / (double) area.width;
        final double dh = (double) imageSize.height / (double) area.height;

        if (dw > dh) {
            // we must limit the size by the width
            destination.width = area.width;
            destination.height = (int) (imageSize.height / dw);

        } else {
            // we must limit the size by the height
            destination.width = (int) (imageSize.width / dh);
            destination.height = area.height;

        }

        destination.x = (area.width - destination.width) / 2 + area.x;
        destination.y = (area.height - destination.height) / 2 + area.y;

        graphics.drawImage(image, new Rectangle(image.getBounds()), destination);

    } else {
        graphics.drawImage(image, new Rectangle(image.getBounds()), area);

    }

}