Java Code Examples for org.eclipse.gmf.runtime.notation.Location#getX()
The following examples show how to use
org.eclipse.gmf.runtime.notation.Location#getX() .
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: MultipleShapesHorizontalMoveTool.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@Override protected void executeCurrentCommand() { FiguresHelper.AVOID_OVERLAP_ENABLE = false ; super.executeCurrentCommand(); FiguresHelper.AVOID_OVERLAP_ENABLE = true ; CompoundCommand cc = new CompoundCommand("Check Overlap") ; for(IGraphicalEditPart ep : _movingShapes){ Location loc = (Location) ((Node) ep.getNotationView()).getLayoutConstraint() ; Point oldLoc = new Point(loc.getX(), loc.getY()) ; Point newLoc = FiguresHelper.handleCompartmentMargin(ep, loc.getX(), loc.getY(),(ep.resolveSemanticElement() instanceof SubProcessEvent)) ; if((newLoc.x != 0 && newLoc.y != 0) && !newLoc.equals(oldLoc)){ cc.add(new ICommandProxy(new SetBoundsCommand(_container.getEditingDomain(), "Check Overlap", new EObjectAdapter(ep.getNotationView()),newLoc))) ; } } executeCommand(cc) ; }
Example 2
Source File: MultipleShapesVerticalMoveTool.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@Override protected void executeCurrentCommand() { FiguresHelper.AVOID_OVERLAP_ENABLE = false ; super.executeCurrentCommand(); FiguresHelper.AVOID_OVERLAP_ENABLE = true ; CompoundCommand cc = new CompoundCommand("Check Overlap") ; for(IGraphicalEditPart ep : _movingShapes){ Location loc = (Location) ((Node) ep.getNotationView()).getLayoutConstraint() ; Point oldLoc = new Point(loc.getX(), loc.getY()) ; Point newLoc = FiguresHelper.handleCompartmentMargin(ep, loc.getX(), loc.getY(),(ep.resolveSemanticElement() instanceof SubProcessEvent)) ; if((newLoc.x != 0 && newLoc.y != 0) && !newLoc.equals(oldLoc)){ cc.add(new ICommandProxy(new SetBoundsCommand(_container.getEditingDomain(), "Check Overlap", new EObjectAdapter(ep.getNotationView()),newLoc))) ; } } executeCommand(cc) ; }
Example 3
Source File: DragEditPartsTrackerExWithoutCopyWithModKeyPressed.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@Override protected void executeCurrentCommand() { if(getOperationSet().size() > 1){ FiguresHelper.AVOID_OVERLAP_ENABLE = false ; super.executeCurrentCommand(); FiguresHelper.AVOID_OVERLAP_ENABLE = true ; CompoundCommand cc = new CompoundCommand("Check Overlap") ; for(Object ep : getOperationSet()){ if(ep instanceof IGraphicalEditPart){ IGraphicalEditPart gep = (IGraphicalEditPart) ep ; Location loc = (Location) ((Node) ((IGraphicalEditPart) ep).getNotationView()).getLayoutConstraint() ; Point oldLoc = new Point(loc.getX(), loc.getY()) ; Point newLoc = FiguresHelper.handleCompartmentMargin(gep, loc.getX(), loc.getY(),(gep.resolveSemanticElement() instanceof SubProcessEvent)) ; if((newLoc.x != 0 && newLoc.y != 0) && !newLoc.equals(oldLoc)){ cc.add(new ICommandProxy(new SetBoundsCommand(gep.getEditingDomain(), "Check Overlap", new EObjectAdapter(gep.getNotationView()),newLoc))) ; } } } executeCommand(cc) ; }else{ super.executeCurrentCommand() ; } }
Example 4
Source File: CompartmentEditPolicy.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Override public Command getCommand(Request request) { if(request.getType() == RequestConstants.REQ_RESIZE_CHILDREN && request instanceof ChangeBoundsRequest){ ChangeBoundsRequest changeBoundsRequest = (ChangeBoundsRequest)request; EditPart ep = (EditPart) changeBoundsRequest.getEditParts().get(0); if(ep instanceof IGraphicalEditPart){ Node node = (Node)((IGraphicalEditPart)ep).getModel() ; Size size =(Size)node.getLayoutConstraint() ; Dimension s = new Dimension(size.getWidth(),size.getHeight()); if(ep instanceof CustomPoolEditPart){ if(s.height < 0){ s.height = ((CustomPoolEditPart)ep).getDefaultHeight(); } if(s.width < 0){ s.width = ((CustomPoolEditPart)ep).getDefaultWidth(); } } Location loc =(Location)node.getLayoutConstraint() ; Dimension delta = changeBoundsRequest.getSizeDelta(); Rectangle constraint = new Rectangle(loc.getX(), loc.getY(), s.width + delta.width, s.height + delta.height); return createChangeConstraintCommand((ChangeBoundsRequest) request,ep,constraint); } } return super.getCommand(request); }
Example 5
Source File: BPMNShapeFactory.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
private void attachEdgeLabel(final DecorationNode decorationNode, final BPMNEdge edge, String labelText, Edge bonitaEdge) { Font font = createFont(bonitaEdge); if (font != null) { final BPMNLabel label = DiFactory.eINSTANCE.createBPMNLabel(); Location relativeLocation = (Location) decorationNode.getLayoutConstraint(); Point offSet = new Point(relativeLocation.getX(), relativeLocation.getY()); org.eclipse.gmf.runtime.notation.Bounds absoluteBounds = NotationFactory.eINSTANCE.createBounds(); PointList pList = new PointList(); edge.getWaypoint().stream().map(wayPoint -> new PrecisionPoint(wayPoint.getX(), wayPoint.getY())) .forEach(pList::addPoint); Point referencePoint = PointListUtilities.calculatePointRelativeToLine(pList, 0, LabelViewConstants.MIDDLE_LOCATION, true); Point location = LabelHelper.calculatePointRelativeToPointOnLine(pList, referencePoint, offSet); //Here we use some default constant values to avoid a dependency on a set Display //The output diemension values are sligthly the same between windows and linux Dimension dimension = new Dimension((int) (labelText.length() * 7.42), (int) (11 * 1.6)); absoluteBounds.setWidth(dimension.width); absoluteBounds.setHeight(dimension.height); location.translate(-1 * dimension.width / 2, -1 * dimension.height / 2); absoluteBounds.setWidth(dimension.width); absoluteBounds.setHeight(dimension.height); absoluteBounds.setX(location.x); absoluteBounds.setY(location.y); final Bounds elementBounds = DcFactory.eINSTANCE.createBounds(); elementBounds.setX(absoluteBounds.getX()); elementBounds.setY(absoluteBounds.getY()); elementBounds.setHeight(absoluteBounds.getHeight()); elementBounds.setWidth(absoluteBounds.getWidth()); edge.setBPMNLabel(label); } }
Example 6
Source File: CustomFeedbackXYLayoutPolicy.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
/** * Override to compute position of Subprocess event children when changing parent */ @Override protected Command createAddCommand(final EditPart child, final Object constraint) { if (child instanceof CustomSubProcessEvent2EditPart && constraint instanceof Rectangle) { final Rectangle rect = (Rectangle) constraint; final CompoundCommand cmds = new CompoundCommand("Move Subprocesss Event"); ICommand boundsCommand = new SetBoundsCommand(((ShapeEditPart) child).getEditingDomain(), DiagramUIMessages.SetLocationCommand_Label_Resize, new EObjectAdapter((View) child.getModel()), rect.getTopLeft()); cmds.add(new ICommandProxy(boundsCommand)); ShapeCompartmentEditPart compartment = null; for (final Object c : child.getChildren()) { if (c instanceof ShapeCompartmentEditPart) { compartment = (ShapeCompartmentEditPart) c; } } final Location origin = (Location) ((Node) child.getModel()).getLayoutConstraint(); for (final Object ep : compartment.getChildren()) { if (ep instanceof IGraphicalEditPart) { final Node view = (Node) ((IGraphicalEditPart) ep).getModel(); final Location loc = (Location) view.getLayoutConstraint(); final Point delta = new Point(loc.getX() - origin.getX(), loc.getY() - origin.getY()); final Point newLoc = new Point(rect.getTopLeft().x + delta.x, rect.getTopLeft().y + delta.y); boundsCommand = new SetBoundsCommand(((IGraphicalEditPart) ep).getEditingDomain(), DiagramUIMessages.SetLocationCommand_Label_Resize, new EObjectAdapter((View) ((IGraphicalEditPart) ep).getModel()), newLoc); cmds.add(new ICommandProxy(boundsCommand)); } } return cmds.unwrap(); } else { return super.createAddCommand(child, constraint); } }