Java Code Examples for org.eclipse.draw2d.geometry.Rectangle#getBottomRight()

The following examples show how to use org.eclipse.draw2d.geometry.Rectangle#getBottomRight() . 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: StateMachineDiagramElementsTxtUmlArranger.java    From txtUML with Eclipse Public License 1.0 6 votes vote down vote up
private Dimension calculatePreferredSize(List<? extends GraphicalEditPart> editparts){
	
	FreeFormLayoutEx manager = (FreeFormLayoutEx) editparts.get(0).getFigure().getParent().getLayoutManager();
	
	Point topLeft = new Point(Integer.MAX_VALUE, Integer.MAX_VALUE);
	Point bottomRight = new Point(Integer.MIN_VALUE, Integer.MIN_VALUE);
	
	for(GraphicalEditPart ep : editparts){
		Rectangle constraint = (Rectangle) manager.getConstraint(ep.getFigure());
		Dimension preferredSize = ep.getFigure().getPreferredSize();
		constraint.width = constraint.width < preferredSize.width ? preferredSize.width : constraint.width;
		constraint.height = constraint.height < preferredSize.height ? preferredSize.height : constraint.height;
				
		topLeft.x = constraint.x < topLeft.x ? constraint.x : topLeft.x;
		topLeft.y = constraint.y < topLeft.y ? constraint.y : topLeft.y;
		
		bottomRight.x = constraint.getBottomRight().x > bottomRight.x ? constraint.getBottomRight().x : bottomRight.x;
		bottomRight.y = constraint.getBottomRight().y > bottomRight.y ? constraint.getBottomRight().y : bottomRight.y;
	}
	
	return new Dimension(bottomRight.x-topLeft.x, bottomRight.y-topLeft.y);
}
 
Example 2
Source File: CompositeDiagramElementsTxtUmlArranger.java    From txtUML with Eclipse Public License 1.0 6 votes vote down vote up
private Dimension calculatePreferredSize(List<? extends GraphicalEditPart> editparts){
	
	FreeFormLayoutEx manager = (FreeFormLayoutEx) editparts.get(0).getFigure().getParent().getLayoutManager();
	
	Point topLeft = new Point(Integer.MAX_VALUE, Integer.MAX_VALUE);
	Point bottomRight = new Point(Integer.MIN_VALUE, Integer.MIN_VALUE);
	
	for(GraphicalEditPart ep : editparts){
		Rectangle constraint = (Rectangle) manager.getConstraint(ep.getFigure());
		Dimension preferredSize = ep.getFigure().getPreferredSize();
		constraint.width = constraint.width < preferredSize.width ? preferredSize.width : constraint.width;
		constraint.height = constraint.height < preferredSize.height ? preferredSize.height : constraint.height;
				
		topLeft.x = constraint.x < topLeft.x ? constraint.x : topLeft.x;
		topLeft.y = constraint.y < topLeft.y ? constraint.y : topLeft.y;
		
		bottomRight.x = constraint.getBottomRight().x > bottomRight.x ? constraint.getBottomRight().x : bottomRight.x;
		bottomRight.y = constraint.getBottomRight().y > bottomRight.y ? constraint.getBottomRight().y : bottomRight.y;
	}
	
	return new Dimension(bottomRight.x, bottomRight.y);
}
 
Example 3
Source File: CollapsableEventSubprocessFigure.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@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 4
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 5
Source File: ActivitySwitchEditPolicy.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
protected Point getIconLocation(final Rectangle bounds) {
	return new Point(bounds.getLeft().x + 10, bounds.getBottomRight().y);
}
 
Example 6
Source File: BoundaryEventSwitchEditPolicy.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
protected Point getIconLocation(Rectangle bounds) {
	return new Point(bounds.getLeft().x, bounds.getBottomRight().y);
}