org.eclipse.draw2d.geometry.Point Java Examples

The following examples show how to use org.eclipse.draw2d.geometry.Point. 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: ActivitySwitchEditPolicy.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private List<IFigure> addMessageEventFigures() {
    final List<IFigure> result = new ArrayList<IFigure>();
    final IGraphicalEditPart host = getHost();
    if (!(isEndEvent(host.resolveSemanticElement()) || hasIncomingConnection())){
    	result.add(createClickableFigure(new Point(0, 0),getHost(), ProcessElementTypes.StartMessageEvent_2010));
    } else {
    	result.add(EMPTY_FIGURE);
    }
    result.add(createClickableFigure(new Point(0, 0),getHost(), ProcessElementTypes.IntermediateCatchMessageEvent_2013));
    result.add(createClickableFigure(new Point(0, 0),getHost(), ProcessElementTypes.IntermediateThrowMessageEvent_2014));
    if (!(isStartEvent(host.resolveSemanticElement()) || hasOutgoingConnection())) {
    	result.add(createClickableFigure(new Point(0, 0),getHost(), ProcessElementTypes.EndMessageEvent_2011));
    } else {
    	result.add(EMPTY_FIGURE);
    }
    return result;
}
 
Example #2
Source File: EdgeLabelQuery.java    From statecharts with Eclipse Public License 1.0 6 votes vote down vote up
/**
	 * Calculate the new GMF label offset: the label offset defines the position of
	 * the label compared to labelAnchor point. <br>
	 * The new Label offset is computed taking into account:<br>
	 * <ul>
	 * <li>the label anchor point move (start, center or end)</li>
	 * <li>the orientation of the segment owning the label anchor. Indeed, the label
	 * offset is displayed by draw2D relatively to the direction of the edge segment
	 * including the anchor of the label</li>
	 * <li>the expected move of the label according to the functional
	 * specification</li>
	 * </ul>
	 * .
	 *
	 * @return the new offset of the label
	 */
	public Point calculateGMFLabelOffset() {
		if (areBendpointsIdentical() && areSegmentsValid()) {
			return oldLabelOffset;
		} else {
			int anchorPointRatio = getLocation(keyPoint);
			Point oldAnchorPoint = getAnchorPoint(oldBendPointList, anchorPointRatio);
			Point oldLabelCenter = relativeCenterCoordinateFromOffset(oldBendPointList, oldAnchorPoint, oldLabelOffset);
			Point newAnchorPoint = getAnchorPoint(newBendPointList, anchorPointRatio);
			Point newLabelCenter = calculateNewCenterLocation(oldLabelCenter,
					getStandardLabelCenterLocation(newBendPointList, keyPoint));
			Point newOffset = offsetFromRelativeCoordinate(newLabelCenter, newBendPointList, newAnchorPoint);
			if ((newLabelCenter.x != oldLabelCenter.x) && (newLabelCenter.y != oldLabelCenter.y)) {
				// rectilinear & both coordinates change => newOffset is 0,0
//				System.out.println("[ERR] Label JUMP oldLabelCenter=" + oldLabelCenter + ", oldAnchorPoint="
//						+ oldAnchorPoint + ", oldOffset=" + oldLabelOffset + ", newAnchorPoint=" + newAnchorPoint
//						+ ", newLabelCenter=" + newLabelCenter + ", newOffset=" + newOffset);
			}
			return newOffset;
		}
	}
 
Example #3
Source File: EditorDragGuidePolicy.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
private Dimension getDistance( )
	{
//		Point p = getStartLocation( );
//		
//		Control canvas = getGuideEditPart( ).getViewer( ).getControl( );
//		org.eclipse.swt.graphics.Rectangle rect = canvas.getBounds( );
//	
//		Dimension retValue = new Dimension(rect.width - p.x, p.y);
//		
//		return retValue;
		
		Point p = getStartLocation( );
		
		FigureCanvas canvas = ((DeferredGraphicalViewer)getGuideEditPart().getViewer( ).getProperty( GraphicalViewer.class.toString( ))).getFigureCanvas( );
		org.eclipse.swt.graphics.Rectangle rect = canvas.getBounds( );
	
		Dimension retValue = new Dimension(rect.width - p.x, p.y);
		if (canvas.getVerticalBar( ).isVisible( ))
		{
			retValue.width = retValue.width - canvas.getVerticalBar( ).getSize( ).x;
		}
		return retValue;
	}
 
Example #4
Source File: CustomAnchor.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private static int getClosestSide(Point p, Rectangle r) {
    double diff = Math.abs(r.preciseX() + r.preciseWidth() - p.preciseX());
    int side = PositionConstants.RIGHT;
    double currentDiff = Math.abs(r.preciseX() - p.preciseX());
    if (currentDiff < diff) {
        diff = currentDiff;
        side = PositionConstants.LEFT;
    }
    currentDiff = Math.abs(r.preciseY() + r.preciseHeight() - p.preciseY());
    if (currentDiff < diff) {
        diff = currentDiff;
        side = PositionConstants.BOTTOM;
    }
    currentDiff = Math.abs(r.preciseY() - p.preciseY());
    if (currentDiff < diff) {
        diff = currentDiff;
        side = PositionConstants.TOP;
    }
    return side;
}
 
Example #5
Source File: SequenceFlowLabelLocationCalculator.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
protected Point getEdgeCenter(final EList<org.omg.spec.dd.dc.Point> eList) {
	final double edgeHalfLength = computeEdgeLength(eList) / 2;
	double total = 0;
	double tmp = 0;
	for (int i = 0; i < eList.size() - 1; i++) {
		tmp = total;
		final org.omg.spec.dd.dc.Point pointA = eList.get(i);
		final org.omg.spec.dd.dc.Point pointB = eList.get(i + 1);
		total = total + computeSegmentLength(pointA, pointB);
		if (total > edgeHalfLength) {
			startPointOfCenterEdge = pointA;
			endPointOfCenterEdge = pointB;
			return computeEdgeCenter(edgeHalfLength - tmp, pointA, pointB);
		}
	}
	return new Point(0, 0);
}
 
Example #6
Source File: MultipleShapesVerticalMoveTool.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
/**
 * creates the command to move the shapes left or right.
 */
protected Command getCommand() {
	if (_container == null) {
		return null;
	}
	CompoundCommand command = new CompoundCommand("Multiple Shape Move");
	TransactionalEditingDomain editingDomain = _container.getEditingDomain();

	Point moveDelta  = ((ChangeBoundsRequest) getSourceRequest()).getMoveDelta().getCopy();
	Dimension spSizeDelta = new Dimension(moveDelta.x, moveDelta.y);
	ZoomManager zoomManager = ((DiagramRootEditPart) 
			getCurrentViewer().getRootEditPart()).getZoomManager();
	spSizeDelta.scale(1/zoomManager.getZoom());
	command.add(_container.getCommand(getSourceRequest()));


	for (IGraphicalEditPart sp : _subProcesses) {
		Dimension spDim = sp.getFigure().getBounds().getSize().getCopy();
		spDim.expand(spSizeDelta);
		SetBoundsCommand setBounds = 
			new SetBoundsCommand(editingDomain,"MultipleShape Move", sp, spDim);
		command.add(new ICommandProxy(setBounds));
	}
	return command;
}
 
Example #7
Source File: ProcBuilder.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
public void addTargetAnchor(final Point targetAnchor) throws ProcBuilderException {
    if (!(currentElement instanceof Connection)) {
        throw new ProcBuilderException("Impossible to add a source anchor on " + currentElement != null ? ((Element) currentElement).getName() : "null");
    }

    final IGraphicalEditPart edge = GMFTools.findEditPart(diagramPart, currentElement);

    if (edge != null) {
        /* Add source anchors */
        final SetConnectionAnchorsCommand setConnectionAnchorsCommand = new SetConnectionAnchorsCommand(editingDomain, "Add source anchor");
        setConnectionAnchorsCommand.setEdgeAdaptor(new EObjectAdapter(edge.getNotationView()));
        setConnectionAnchorsCommand.setNewTargetTerminal("(" + targetAnchor.preciseX() + "," + targetAnchor.preciseY() + ")");
        diagramPart.getDiagramEditDomain().getDiagramCommandStack().execute(new ICommandProxy(setConnectionAnchorsCommand));
    }

}
 
Example #8
Source File: BPMNToProc.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private PointList computeBendpoints(final String sequenceFlowID) {
    final BPMNEdge edge = getBPMNEdgeFor(sequenceFlowID);
    final PointList bendpoints = new PointList();
    if (edge != null) {
        /* Convert WayPoints to PointList */
        final EList<org.omg.spec.dd.dc.Point> wayPoints = edge
                .getWaypoint();
        final Point containerLocation = getContainerLocationFor(
                sequenceFlowID).getNegated();
        for (int i = 0; i < wayPoints.size(); i++) {
            final org.omg.spec.dd.dc.Point ddp = wayPoints.get(i);
            bendpoints.insertPoint(new Point((int) ddp.getX(),
                    (int) ddp.getY()).translate(containerLocation),
                    i);
        }
    }
    return bendpoints;
}
 
Example #9
Source File: BotGefProcessDiagramEditor.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Add an element from the contextual palette of one element.
 *
 * @param pSourceElement
 * @param pContextualPaletteId (see org.bonitasoft.studio.qa.util.SWTBotConstants.java)
 * @param pOrientation (org.eclipse.draw2d.PositionConstants)
 */
public void addElementAfter(final String pSourceElement, final int pContextualPaletteId, final int pOrientation) {
    final SWTBotGefEditPart gep = gmfEditor.getEditPart(pSourceElement);
    Assert.assertNotNull("Error: No Edit Part \'" + pSourceElement + "\' found.", gep);
    final SWTBotGefEditPart element = gep.parent();
    element.select();
    final IGraphicalEditPart graphicalEditPart = (IGraphicalEditPart) element.part();
    final NextElementEditPolicy nextElementEditPolicy = (NextElementEditPolicy) graphicalEditPart
            .getEditPolicy(NextElementEditPolicy.NEXT_ELEMENT_ROLE);

    final IFigure toolbarFigure = nextElementEditPolicy.getFigure(pContextualPaletteId);
    final Point dropLocation = computeTargetLocation(pSourceElement, pOrientation);

    final Point location = toolbarFigure.getBounds().getCenter().getCopy();
    toolbarFigure.translateToAbsolute(location);

    final Point delta = getDelta(pSourceElement);

    gmfEditor.drag(location.x, location.y, delta.x + dropLocation.x, delta.y + dropLocation.y);
}
 
Example #10
Source File: ERDiagramLayoutEditPolicy.java    From ermasterr with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected void showSizeOnDropFeedback(final CreateRequest request) {
    final Point p = new Point(request.getLocation().getCopy());

    final ZoomManager zoomManager = ((ScalableFreeformRootEditPart) getHost().getRoot()).getZoomManager();
    final double zoom = zoomManager.getZoom();

    final IFigure feedback = getSizeOnDropFeedback(request);

    final Dimension size = request.getSize().getCopy();
    feedback.translateToRelative(size);
    feedback.setBounds(new Rectangle((int) (p.x * zoom), (int) (p.y * zoom), size.width, size.height).expand(getCreationFeedbackOffset(request)));
}
 
Example #11
Source File: DiagramWalkerGraphicalNodeEditPolicy.java    From erflute with Apache License 2.0 5 votes vote down vote up
@Override
protected Command getReconnectTargetCommand(ReconnectRequest reconnectrequest) {
    final WalkerConnection connection = (WalkerConnection) reconnectrequest.getConnectionEditPart().getModel();
    if (!(connection instanceof Relationship)) {
        return null;
    }
    final Relationship relation = (Relationship) connection;
    if (relation.getSourceWalker() == relation.getTargetWalker()) {
        return null;
    }
    final DiagramWalker newTarget = ((DiagramWalker) reconnectrequest.getTarget().getModel()).toMaterialize();
    if (!relation.getTargetWalker().equals(newTarget)) {
        return null;
    }
    final DiagramWalkerEditPart targetEditPart = (DiagramWalkerEditPart) reconnectrequest.getConnectionEditPart().getTarget();
    final Point location = new Point(reconnectrequest.getLocation());
    final IFigure targetFigure = targetEditPart.getFigure();
    targetFigure.translateToRelative(location);
    int xp = -1;
    int yp = -1;
    final Rectangle bounds = targetFigure.getBounds();
    final Rectangle centerRectangle =
            new Rectangle(bounds.x + (bounds.width / 4), bounds.y + (bounds.height / 4), bounds.width / 2, bounds.height / 2);
    if (!centerRectangle.contains(location)) {
        final Point point = ERTableEditPart.getIntersectionPoint(location, targetFigure);
        xp = 100 * (point.x - bounds.x) / bounds.width;
        yp = 100 * (point.y - bounds.y) / bounds.height;
    }
    final ReconnectTargetCommand command = new ReconnectTargetCommand(relation, xp, yp);
    return command;
}
 
Example #12
Source File: ActivitySwitchEditPolicy.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private List<IFigure> addTimerEventFigures() {
    final List<IFigure> result = new ArrayList<IFigure>();
    final IGraphicalEditPart host = getHost();
    if (!(isEndEvent(host.resolveSemanticElement()) || hasIncomingConnection())){
    	result.add(createClickableFigure(new Point(0, 0),getHost(), ProcessElementTypes.StartTimerEvent_2016));
    } else {
    	result.add(EMPTY_FIGURE);
    }
    result.add(createClickableFigure(new Point(0, 0),getHost(), ProcessElementTypes.IntermediateCatchTimerEvent_2017));
    result.add(EMPTY_FIGURE);
    result.add(EMPTY_FIGURE);
    return result;
}
 
Example #13
Source File: CustomPasteCommand.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Compute the relative location of each copied editparts
 */
private Rectangle computeRelativeLocation(Point newOrigin,IGraphicalEditPart srcPart, List<IGraphicalEditPart> toCopy) {
	int relativeToPoolY=0;
	Rectangle newLoc = new Rectangle(newOrigin, new Dimension()) ;
	newLoc.setY(newLoc.y()+relativeToPoolY);
	int minX = Integer.MAX_VALUE ;
	IGraphicalEditPart mostLeftEditPart = null ;
	for(IGraphicalEditPart parts : toCopy){
		if(!(parts instanceof AbstractConnectionEditPart)){
			int x =((Location)((Node)parts.getNotationView()).getLayoutConstraint()).getX() ;

			if(x < minX){
				minX = x ;
				mostLeftEditPart = parts ;
			}
		}
	}

	if(mostLeftEditPart.equals(srcPart)){
		return newLoc;
	}else{
		int referenceX = minX ;
		int referenceY =((Location)((Node)mostLeftEditPart.getNotationView()).getLayoutConstraint()).getY() ;
		int toCopyX = ((Location)((Node)srcPart.getNotationView()).getLayoutConstraint()).getX() ;
		int toCopyY = ((Location)((Node)srcPart.getNotationView()).getLayoutConstraint()).getY() ;
		newLoc = newLoc.translate(toCopyX-referenceX, toCopyY-referenceY);
		newLoc.setY(newLoc.y()+relativeToPoolY);
		return newLoc;
	}

}
 
Example #14
Source File: TableLayout.java    From ermaster-b with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
private void addHorizontalSeparator(IFigure figure, Rectangle rect) {
	Polyline separator = new Polyline();
	separator.setLineWidth(separatorWidth);
	separator.addPoint(new Point(rect.x, rect.y));
	separator.addPoint(new Point(rect.x + rect.width, rect.y));
	figure.getChildren().add(separator);
	separator.setParent(figure);

	this.separators.add(separator);
}
 
Example #15
Source File: BotGefProcessDiagramEditor.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private Point getPositionOfPoolOfElement(final String pElement) {
    SWTBotGefEditPart gep = gmfEditor.getEditPart(pElement);
    while (gep != null) {
        gep = gep.parent();
        final IGraphicalEditPart graphicalEditPart = (IGraphicalEditPart) gep.part();
        if (graphicalEditPart.resolveSemanticElement() instanceof PoolImpl) {
            return graphicalEditPart.getFigure().getBounds().getTopLeft().getCopy();
        }
        gep = gep.parent();
    }
    return new Point(0, 0);
}
 
Example #16
Source File: CreateRelatedTableCommand.java    From ermasterr with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void setTarget(final EditPart target) {
    super.setTarget(target);

    if (target != null) {
        if (target instanceof TableViewEditPart) {
            final TableViewEditPart tableEditPart = (TableViewEditPart) target;

            final Point point = tableEditPart.getFigure().getBounds().getCenter();
            setTargetPoint(point.x, point.y);
        }
    }
}
 
Example #17
Source File: DropDownMenuFigure.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public void paintElements(){
	if (elements != null) {
		for(Pair<IFigure, MouseListener> pair : elements){
			IFigure elem = pair.getFirst();
			if (elem != null && !(elem instanceof Polyline)) {
				elem.setSize(new Dimension(20,20));
				elem.setLocation(new Point(location.x +elem.getSize().width*elements.indexOf(pair),location.y+20/*+elem.getSize().height*elements.indexOf(elem)*/));
				elem.setVisible(false);
				layer.add(elem);
				addElementsToShow(elem);
			}
		}
	}
}
 
Example #18
Source File: ProcBuilder.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private CreateViewAndElementRequest createCreationRequest(final Point location,
        final Dimension size, final ViewAndElementDescriptor viewDescriptor) {
    final CreateViewAndElementRequest createRequest = new CreateViewAndElementRequest(viewDescriptor);
    if (location != null) {
        createRequest.setLocation(location);
    }
    if (size != null) {
        createRequest.setSize(size);
    }
    return createRequest;
}
 
Example #19
Source File: SwitchPoolSelectionEditPolicy.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 
 */
private void showSelectionForAddBottom() {
	if (!isOnBottom()) {

		IFigure f = new ImageFigure(Pics.getImage(PicsConstants.arrowDown));
		f.setSize(20, 20);

		sourceFigure = getHostFigure() ;

		Rectangle bounds = sourceFigure.getBounds().getCopy();
		//get the absolute coordinate of bounds
		sourceFigure.translateToAbsolute(bounds);
		IFigure parentFigure = sourceFigure.getParent();
		while( parentFigure != null  ) {
			if(parentFigure instanceof Viewport) {
				Viewport viewport = (Viewport)parentFigure;
				bounds.translate(
						viewport.getHorizontalRangeModel().getValue(),
						viewport.getVerticalRangeModel().getValue());
				parentFigure = parentFigure.getParent();
			}
			else {
				parentFigure = parentFigure.getParent();
			}
		}

		f.setLocation(new Point(bounds.getBottomLeft().x,bounds.getBottom().y));

		f.addMouseListener(new MouseListenerForSpan(AbstractSwitchLaneSelectionEditPolicy.ADD_BOTTOM));
		layer.add(f);
		figures.add(f);
	}
}
 
Example #20
Source File: ConnectionRouterImp.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
private void routeTopToBottom(Point start, Point end, PointList points) {
	int offsetY = GraphLayoutManager.verticalSpacing / 4;
	int midX = 0;
	if (Math.abs(start.x - end.x) < ProcessFigure.WIDTH) {
		midX = Math.max(start.x, end.x) + ProcessFigure.WIDTH;
	} else {
		midX = start.x + (end.x - start.x) / 2;
	}
	points.addPoint(start.x, start.y - offsetY);
	points.addPoint(midX, start.y - offsetY);
	points.addPoint(midX, end.y + offsetY);
	points.addPoint(end.x, end.y + offsetY);
}
 
Example #21
Source File: GridViewerLauncher.java    From ice with Eclipse Public License 1.0 5 votes vote down vote up
public static List<Point> selectOctant(int rows, int columns,
		int octantIndex) {
	List<Point> octant = new ArrayList<Point>((int) Math.ceil(rows
			* columns / 8.0));

	return octant;
}
 
Example #22
Source File: DraggableElementCreationTool.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
protected void snapPoint(CreateRequest request) {
    if (helper != null && figure != null) {
        final PrecisionRectangle baseRect = sourceRectangle.getPreciseCopy();
        final PrecisionRectangle jointRect = compoundSrcRect.getPreciseCopy();
        Point location = getLocation().getTranslated(-figure.getSize().width / 2, -figure.getSize().height / 2);
        final PrecisionPoint preciseDelta = new PrecisionPoint(location.preciseX(), location.preciseY());
        baseRect.translate(preciseDelta);
        jointRect.translate(preciseDelta);
        helper.snapPoint(request, PositionConstants.HORIZONTAL | PositionConstants.VERTICAL, new PrecisionRectangle[] {
                baseRect, jointRect }, preciseDelta);
        request.setLocation(preciseDelta);
    }

}
 
Example #23
Source File: BPMNToProcTest.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void shouldNotinitializeLabelPositionOnSequenceFlowWhenEdgeIsNull() throws ProcBuilderException {
    final ProcBuilder builder = spy(new ProcBuilder());
    bpmnToProc.setBuilder(builder);
    doNothing().when(builder).setLabelPositionOnSequenceFlowOrEvent(any(Point.class));
    doReturn(null).when(bpmnToProc).getBPMNEdgeFor("mySequenceFlow");
    bpmnToProc.initializeLabelPositionOnSequenceFlow("mySequenceFlow");
    verify(builder, never()).setLabelPositionOnSequenceFlowOrEvent(any(Point.class));
}
 
Example #24
Source File: SequenceFlowLabelLocationCalculator.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
protected double computeEdgeLength(final EList<org.omg.spec.dd.dc.Point> eList) {
	double total = 0;
	for (int i = 0; i < eList.size() - 1; i++) {
		final org.omg.spec.dd.dc.Point pointA = eList.get(i);
		final org.omg.spec.dd.dc.Point pointB = eList.get(i + 1);
		total = total + computeSegmentLength(pointA, pointB);
	}
	return total;
}
 
Example #25
Source File: CustomRectilinearRouter.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Calculates geographic position of a point located outside the given rectangle relative
 * to the rectangle
 * 
 * @param p point outside of rectangle
 * @param r the rectangle
 * @return geographic position of the point relative to the recatangle
 */
private int getOutisePointOffRectanglePosition(Point p, Rectangle r) {
    int position = PositionConstants.NONE;
    if (r.x > p.x) {
        position |= PositionConstants.WEST;
    } else if (r.x + r.width < p.x) {
        position |= PositionConstants.EAST;
    }
    if (r.y > p.y) {
        position |= PositionConstants.NORTH;
    } else if (r.y + r.height < p.y) {
        position |= PositionConstants.SOUTH;
    }
    return position;
}
 
Example #26
Source File: LiveFeedbackResizableEditPolicy.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
protected void enforceConstraintForMove(ChangeBoundsRequest request) {
	Rectangle relativeBounds = getOriginalBounds();
	PrecisionRectangle manipulatedConstraint = new PrecisionRectangle(
			 request.getTransformedRectangle(relativeBounds));
	getHostFigure().translateToRelative(manipulatedConstraint);
	
	manipulatedConstraint.setX(Math.max(0, manipulatedConstraint.x));
	manipulatedConstraint.setY(Math.max(0, manipulatedConstraint.y));
	
	getHostFigure().translateToAbsolute(manipulatedConstraint);
	
	Dimension difference = manipulatedConstraint.getLocation().getDifference(originalBounds.getLocation());
	request.setMoveDelta(new Point(difference.width, difference.height));
}
 
Example #27
Source File: MovablePanningSelectionTool.java    From ermasterr with Apache License 2.0 5 votes vote down vote up
@Override
public void mouseDown(final MouseEvent e, final EditPartViewer viewer) {
    if (viewer.getContents() instanceof ERDiagramEditPart) {
        final ERDiagramEditPart editPart = (ERDiagramEditPart) viewer.getContents();
        final ERDiagram diagram = (ERDiagram) editPart.getModel();

        diagram.mousePoint = new Point(e.x, e.y);

        editPart.getFigure().translateToRelative(diagram.mousePoint);
    }

    super.mouseDown(e, viewer);
}
 
Example #28
Source File: SlideMenuBarFigure.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public void addToMenu(IFigure menuEntry){
	
	elements.add(menuEntry);
	
	for(IFigure elem : elements){
		elem.setSize(new Dimension(getSize().width/elements.size(),getSize().height));
		if(elements.indexOf(elem) >0){
			elem.setLocation(new Point(getBounds().getTopLeft().x+elem.getSize().width,getBounds().getTopLeft().y));
		}else{
			elem.setLocation(new Point(getBounds().getTopLeft().x,getBounds().getTopLeft().y));
		}
		this.add(elem);
	}

}
 
Example #29
Source File: ReportFigureUtilities.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Gets points to construct a triangle by give height and central point.
 * 
 * @param triangleHeight
 * @param triangleCenter
 * @return
 */
public static int[] getTrianglePoints( int triangleHeight,
		Point triangleCenter )
{
	int points[] = new int[6];
	int xOff = (int) ( triangleHeight * 2 * Math.tan( Math.PI / 6 ) );
	points[0] = triangleCenter.x - xOff;
	points[1] = triangleCenter.y - triangleHeight / 2;
	points[2] = triangleCenter.x + xOff;
	points[3] = triangleCenter.y - triangleHeight / 2;
	points[4] = triangleCenter.x;
	points[5] = triangleCenter.y + triangleHeight / 2;

	return points;
}
 
Example #30
Source File: FixedConnectionAnchor.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
public Point getLocation() {
	Rectangle r = getOwner().getBounds();
	Point p = new PrecisionPoint(r.x + r.width * xOffset, r.y + r.height
			* yOffset);
	getOwner().translateToAbsolute(p);
	return p;
}