float dx = Math.abs(cp.getRelativeX() - m.getRelativeX()); float dy = Math.abs(cp.getRelativeY() - m.getRelativeY()); cp.setRelativeX(closestMagnet.getRelativeX()); cp.setRelativeY(closestMagnet.getRelativeY()); cp.setConnectedToMagnet(closestMagnet); closestMagnet.addConnectorPoint(cp); connectableElement.getOutgoingConnectors().add(cp.getConnector()); cp.getConnector().setSource(connectableElement); connectableElement.getIncommingConnectors().add(cp.getConnector()); cp.getConnector().setTarget(connectableElement); cp.getConnector().refresh();
@Override public void removeIntermediateConnectorPoint(IConnectorPoint point) { point.getPreviousPoint().setNextPoint(point.getNextPoint()); point.getNextPoint().setPreviousPoint(point.getPreviousPoint()); this.connectorPoints.remove(point); this.fireEvent(new RemoveIntermediateConnectorPointEvent(point)); this.fireEvent(new RemoveWayPointEvent(point)); this.refresh(); }
public ClosestPoints getClosestPoints(Point point) { IConnectorPoint minPoint = this.connector.getConnectorStartPoint(); IConnectorPoint currentPoint = minPoint; while (currentPoint.getNextPoint() != null) { Point previousPoint = new Point(currentPoint.getAbsoluteLeft(),currentPoint.getAbsoluteTop()); Point nextPoint = new Point(currentPoint.getNextPoint().getAbsoluteLeft(),currentPoint.getNextPoint().getAbsoluteTop()); Region r = new Region(previousPoint,nextPoint); if (r.contains(point)){ minPoint = currentPoint; break; } currentPoint = currentPoint.getNextPoint(); } IConnectorPoint maxPoint = minPoint.getNextPoint(); ClosestPoints closesPoints = new ClosestPoints(minPoint, maxPoint); return closesPoints; }
@Override public void addIntermediateConnectorPoint(IConnectorPoint point, IConnectorPoint previousPoint, IConnectorPoint nextPoint) { this.connectorPoints.add(point); point.setPreviousPoint(previousPoint); point.setNextPoint(nextPoint); previousPoint.setNextPoint(point); nextPoint.setPreviousPoint(point); this.fireEvent(new AddIntermediateConnectorPointEvent(point, previousPoint, nextPoint)); }
if (point.getConnectedToMagnet()!=null){ int connectebleMiddleX = (int) (point.getConnectedToMagnet().getConnectableElement().getWidth()/2)+point.getConnectedToMagnet().getConnectableElement().getAbsoluteLeft(); int connectableMiddleY = (int) (point.getConnectedToMagnet().getConnectableElement().getHeight()/2)+point.getConnectedToMagnet().getConnectableElement().getAbsoluteTop(); p2 = new Point(point.getPreviousPoint().getAbsoluteLeft(),point.getPreviousPoint().getAbsoluteTop()); }else{ p2 = new Point(point.getNextPoint().getAbsoluteLeft(),point.getNextPoint().getAbsoluteTop()); p1, p2, point.getConnectedToMagnet().getConnectableElement().getAbsoluteLeft(), point.getConnectedToMagnet().getConnectableElement().getAbsoluteTop(), (int)point.getConnectedToMagnet().getConnectableElement().getWidth(), (int)point.getConnectedToMagnet().getConnectableElement().getHeight()); point.setRelativeX(x); point.setRelativeY(y);
cp.setRelativeX(cp.getRelativeX()+lastDiffX+uiPanel.getScrollLeft()); cp.setRelativeY(cp.getRelativeY()+lastDiffY+uiPanel.getScrollTop());
@Override public void refresh() { super.refresh(); invisibleLinearPath.getPoints().clear(); // TODO: determine best path // - rebuild it with new points starting with start point IConnectorPoint previousConnectorPoint = this.connectorStart; com.ebmwebsourcing.geasytools.geasysvg.ext.impl.Point previousPoint = null; while (previousConnectorPoint != null) { com.ebmwebsourcing.geasytools.geasysvg.ext.impl.Point point = new com.ebmwebsourcing.geasytools.geasysvg.ext.impl.Point( previousConnectorPoint.getRelativeX()+getUIPanel().getScrollLeft(), previousConnectorPoint.getRelativeY()+getUIPanel().getScrollTop()); if (previousPoint != null) previousPoint.setNextPoint(point); invisibleLinearPath.addPoint(point); previousConnectorPoint = previousConnectorPoint.getNextPoint(); previousPoint = point; } invisibleLinearPath.connectAllPoints(); refreshLabelPosition(); invisibleLinearPath.getElement().setAttribute("stroke-width", "7"); invisibleLinearPath.getElement().setAttribute("pointer-events", "painted"); invisibleLinearPath.getElement().setAttribute("visibility", "hidden"); //invisibleLinearPath.toFront(); this.visibleLinearPath.getElement().setAttribute("d", this.invisibleLinearPath.getElement().getAttribute("d")); //visibleLinearPath.toBack(); this.group.toFront(); }
cp.setConnectedToMagnet(null); if (connectable.getIncommingConnectors().contains(cp.getConnector())){ connectable.getIncommingConnectors().remove(cp.getConnector()); }else if (connectable.getOutgoingConnectors().contains(cp.getConnector())){ connectable.getOutgoingConnectors().remove(cp.getConnector()); cp.getConnector().setSource(null); cp.getConnector().setTarget(null);
minX = p.getAbsoluteLeft(); nwPoint = new Point(minX,nwPoint.getY()); minY = p.getAbsoluteTop(); nwPoint = new Point(nwPoint.getX(), minY); if (p.getAbsoluteLeft()<minX){ minX = p.getAbsoluteLeft(); nwPoint = new Point(minX,nwPoint.getY()); if (p.getAbsoluteTop()<minY){ minY = p.getAbsoluteTop(); nwPoint = new Point(nwPoint.getX(),minY);
if (m.getConnectedToMagnet()!=null){ if (m.getConnectedToMagnet().getConnectableElement().equals(connectable)){ m.setConnectedToMagnet(null); if (m.getConnectedToMagnet()!=null){ if (m.getConnectedToMagnet().getConnectableElement().equals(connectable)){ m.setConnectedToMagnet(null);
p.setRelativeX(p.getRelativeX()+dx); p.setRelativeY(p.getRelativeY()+dy);
@Override public void onDropAccepted(IDropAcceptedEvent event) { if (event.getDraggableElement() instanceof IConnectorPoint){ IConnectorPoint cp = (IConnectorPoint)event.getDraggableElement(); this.addConnectorPoint(cp); cp.setConnectedToMagnet(this); //add connector to incoming or outgoing //outgoing if (cp instanceof IConnectorStart){ getConnectableElement().addOutgoingConnector(cp.getConnector()); cp.getConnector().setSource(connectable); }else if (cp instanceof IConnectorEnd){ getConnectableElement().addIncommingConnector(cp.getConnector()); cp.getConnector().setTarget(connectable); } } }
maxX = p.getAbsoluteLeft(); sePoint = new Point(maxX,sePoint.getY()); maxY = p.getAbsoluteTop(); sePoint = new Point(sePoint.getX(),maxY); if (p.getAbsoluteLeft()>maxX){ maxX = p.getAbsoluteLeft(); sePoint = new Point(maxX,sePoint.getY()); if (p.getAbsoluteTop()>maxY){ maxY = p.getAbsoluteTop(); sePoint = new Point(sePoint.getX(),maxY);