本文整理汇总了Java中org.netbeans.api.visual.widget.ConnectionWidget类的典型用法代码示例。如果您正苦于以下问题:Java ConnectionWidget类的具体用法?Java ConnectionWidget怎么用?Java ConnectionWidget使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ConnectionWidget类属于org.netbeans.api.visual.widget包,在下文中一共展示了ConnectionWidget类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: mousePressed
import org.netbeans.api.visual.widget.ConnectionWidget; //导入依赖的package包/类
@Override
public State mousePressed (Widget widget, WidgetMouseEvent event) {
if (isLocked ())
return State.createLocked (widget, this);
if (event.getButton () == MouseEvent.BUTTON1 && event.getClickCount () == 1) {
if (widget instanceof ConnectionWidget) {
ConnectionWidget conn = (ConnectionWidget) widget;
controlPointIndex = conn.getControlPointHitAt (event.getPoint ());
if (controlPointIndex >= 0) {
movingWidget = conn;
controlPointLocation = new Point (conn.getControlPoints (). get (controlPointIndex));
lastLocation = new Point (event.getPoint ());
return State.createLocked (widget, this);
} else {
movingWidget = null;
}
}
}
return State.REJECTED;
}
示例2: addRemoveControlPoint
import org.netbeans.api.visual.widget.ConnectionWidget; //导入依赖的package包/类
/**
* Adds or removes a control point on a specified location
* @param widget the connection widget
* @param localLocation the local location
*/
private void addRemoveControlPoint (ConnectionWidget widget, Point localLocation) {
ArrayList<Point> list = new ArrayList<Point> (widget.getControlPoints ());
if (!removeControlPoint (localLocation, list, deleteSensitivity)) {
Point exPoint = null;
int index = 0;
for (Point elem : list) {
if (exPoint != null) {
Line2D l2d = new Line2D.Double (exPoint, elem);
if (l2d.ptSegDist (localLocation) < createSensitivity) {
list.add (index, localLocation);
break;
}
}
exPoint = elem;
index++;
}
}
if (routingPolicy != null)
widget.setRoutingPolicy (routingPolicy);
widget.setControlPoints (list, false);
}
示例3: routeConnection
import org.netbeans.api.visual.widget.ConnectionWidget; //导入依赖的package包/类
public List<Point> routeConnection(ConnectionWidget widget) {
ArrayList<Point> list = new ArrayList<Point> ();
Anchor sourceAnchor = widget.getSourceAnchor();
Anchor targetAnchor = widget.getTargetAnchor();
if (sourceAnchor == null || targetAnchor == null)
return Collections.emptyList();
list.add(sourceAnchor.compute(widget.getSourceAnchorEntry()).getAnchorSceneLocation());
List<Point> oldControlPoints = widget.getControlPoints ();
if(oldControlPoints !=null) {
ArrayList<Point> oldList = new ArrayList<Point> (oldControlPoints);
oldList.remove(widget.getFirstControlPoint());
oldList.remove(widget.getLastControlPoint());
list.addAll(oldList);
}
list.add(targetAnchor.compute(widget.getTargetAnchorEntry()).getAnchorSceneLocation());
return list;
}
示例4: testCollisionsCollector
import org.netbeans.api.visual.widget.ConnectionWidget; //导入依赖的package包/类
public void testCollisionsCollector () {
Scene scene = new Scene ();
ConnectionWidget widget = new ConnectionWidget (scene);
widget.setSourceAnchor (AnchorFactory.createFixedAnchor (new Point (100, 100)));
widget.setTargetAnchor (AnchorFactory.createFixedAnchor (new Point (300, 200)));
widget.setRouter (RouterFactory.createOrthogonalSearchRouter (new CollisionsCollector() {
public void collectCollisions (List<Rectangle> verticalCollisions, List<Rectangle> horizontalCollisions) {
getRef ().println ("CollisionsCollector invoked");
}
}));
scene.addChild (widget);
JFrame frame = showFrame (scene);
frame.setVisible(false);
frame.dispose ();
compareReferenceFiles ();
}
示例5: testConnectionWidgetCollisionsCollector
import org.netbeans.api.visual.widget.ConnectionWidget; //导入依赖的package包/类
public void testConnectionWidgetCollisionsCollector () {
Scene scene = new Scene ();
final ConnectionWidget widget = new ConnectionWidget (scene);
widget.setSourceAnchor (AnchorFactory.createFixedAnchor (new Point (100, 100)));
widget.setTargetAnchor (AnchorFactory.createFixedAnchor (new Point (300, 200)));
widget.setRouter (RouterFactory.createOrthogonalSearchRouter (new ConnectionWidgetCollisionsCollector () {
public void collectCollisions (ConnectionWidget connectionWidget, List<Rectangle> verticalCollisions, List<Rectangle> horizontalCollisions) {
getRef ().println ("ConnectionWidgetCollisionsCollector invoked - is widget valid: " + (connectionWidget == widget));
}
}));
scene.addChild (widget);
JFrame frame = showFrame (scene);
frame.setVisible(false);
frame.dispose ();
compareReferenceFiles ();
}
示例6: collectObstacles
import org.netbeans.api.visual.widget.ConnectionWidget; //导入依赖的package包/类
private int collectObstacles(List<Rectangle> colrects, List<Widget> colwidgets , ConnectionWidget cw){
int count=0;
Anchor sourceAnchor = cw.getSourceAnchor();
Anchor targetAnchor = cw.getTargetAnchor();
Widget sourceWidget = sourceAnchor.getRelatedWidget();
Widget targetWidget = targetAnchor.getRelatedWidget();
Point start = sourceAnchor.compute(cw.getSourceAnchorEntry()).getAnchorSceneLocation();
Point end = targetAnchor.compute(cw.getTargetAnchorEntry()).getAnchorSceneLocation();
for(Widget w : colwidgets){
if(w==sourceWidget || w == targetWidget) continue;
Rectangle r = w.convertLocalToScene(w.getBounds());
r.grow(HEXPAND, VEXPAND);
if(r.intersectsLine(start.x,start.y,end.x,end.y))
count++;
colrects.add(r);
}
return count;
}
示例7: getAllContainedEdges
import org.netbeans.api.visual.widget.ConnectionWidget; //导入依赖的package包/类
public static Collection<ConnectionWidget> getAllContainedEdges(Widget widget) {
HashSet<ConnectionWidget> set = new HashSet<ConnectionWidget>();
Scene scene = widget.getScene();
if (scene instanceof GraphScene) {
GraphScene gs = (GraphScene) scene;
List<Object> nodeChildren = getAllNodeChildren(widget);
for (Object obj : nodeChildren) {
Collection edges = gs.findNodeEdges(obj, true, true);
for (Object e : edges) {
Object source = gs.getEdgeSource(e);
Object target = gs.getEdgeTarget(e);
if (nodeChildren.contains(source) && nodeChildren.contains(target)) {
set.add((ConnectionWidget) gs.findWidget(e));
}
}
}
}
return set;
}
示例8: getOppositeSceneLocation
import org.netbeans.api.visual.widget.ConnectionWidget; //导入依赖的package包/类
@Override
public Point getOppositeSceneLocation(Entry entry) {
Point retVal = super.getOppositeSceneLocation(entry);
// If the connection widget has connection points we need to find the
// connection point that is closes to the related widget.
//
// There are always two, one for the source and target ends.
ConnectionWidget connection = entry.getAttachedConnectionWidget();
if ((connection != null) && (connection.getControlPoints().size() > 2)) {
List< Point> points = connection.getControlPoints();
if (entry.isAttachedToConnectionSource() == true) {
// The source end starts from the start of the collection of points.
retVal = points.get(1);
} else {
// The target end starts from the end of the collection of points.
retVal = points.get(points.size() - 2);
}
}
return retVal;
}
示例9: show
import org.netbeans.api.visual.widget.ConnectionWidget; //导入依赖的package包/类
public void show(Widget label) {
Widget owner = connector.getParentWidget();
if (owner != null) {
if (lineWidget == null) {
lineWidget = createLineWidget(connector.getScene());
if (connector instanceof ConnectionWidget) {
lineWidget.setSourceAnchor(new ConnectionAnchor(((ConnectionWidget) connector), anchorLocation));
} else if (connector instanceof INodeWidget) {
INodeWidget nodeWidget = (INodeWidget) connector;
lineWidget.setSourceAnchor(nodeWidget.getModelerScene().getModelerFile().getModelerUtil().getAnchor(nodeWidget));
}
lineWidget.setTargetAnchor(new ShapeUniqueAnchor(label, false));
}
owner.addChild(lineWidget);
}
}
示例10: getLocationPoint
import org.netbeans.api.visual.widget.ConnectionWidget; //导入依赖的package包/类
protected Point getLocationPoint(double location) {
ConnectionWidget connectionWidget = (ConnectionWidget) getRelatedWidget();
java.util.List<Point> controlPoints = connectionWidget.getControlPoints();
boolean empty = controlPoints == null || controlPoints.size() <= 0;
double totalDistance = 0.0;
double[] distances = new double[empty ? 0 : controlPoints.size() - 1];
for (int i = 0; i < distances.length; i++) {
distances[i] = totalDistance += GeomUtil.distanceSq(controlPoints.get(i), controlPoints.get(i + 1));
}
// For now I always want the center and the left and right sides of the
// connectoin widget.
double lineDistance = totalDistance * location;
return getLinePointDistance(distances, (int) lineDistance, controlPoints);
}
示例11: reconnect
import org.netbeans.api.visual.widget.ConnectionWidget; //导入依赖的package包/类
@Override
public void reconnect(ConnectionWidget connectionWidget, Widget replacementWidget, boolean reconnectingSource) {
EdgeWidget edgeWidget = (EdgeWidget) connectionWidget;
NodeWidget nodeWidget = (NodeWidget) ((SvgNodeWidget) replacementWidget).getParentNodeWidget();
// EdgeWidget edgeWidget = (EdgeWidget)sequenceWidget;
if (replacementWidget == null) {
((IEdgeWidget) edgeWidget).remove(true);
} else if (reconnectingSource) {
NBModelerUtil.dettachEdgeSourceAnchor(scene, (IEdgeWidget) edgeWidget, (INodeWidget) ((IFlowEdgeWidget) edgeWidget).getSourceWidget()); //.getSourceNode()
NBModelerUtil.attachEdgeSourceAnchor(scene, (IEdgeWidget) edgeWidget, (INodeWidget) nodeWidget);
} else {
NBModelerUtil.dettachEdgeTargetAnchor(scene, (IEdgeWidget) edgeWidget, (INodeWidget) ((IFlowEdgeWidget) edgeWidget).getTargetWidget());
NBModelerUtil.attachEdgeTargetAnchor(scene, (IEdgeWidget) edgeWidget, (INodeWidget) nodeWidget);
}
scene.validate();
}
示例12: mousePressed
import org.netbeans.api.visual.widget.ConnectionWidget; //导入依赖的package包/类
@Override
public State mousePressed(Widget widget, WidgetMouseEvent event) {
if (isLocked()) {
return State.createLocked(widget, this);
}
if (event.getButton() == MouseEvent.BUTTON1 && event.getClickCount() == 1) {
if (widget instanceof ConnectionWidget) {
ConnectionWidget conn = (ConnectionWidget) widget;
controlPointIndex = conn.getControlPointHitAt(event.getPoint());
if (controlPointIndex >= 0) {
movingWidget = conn;
controlPointLocation = new Point(conn.getControlPoints().get(controlPointIndex));
lastLocation = new Point(event.getPoint());
return State.createLocked(widget, this);
} else {
movingWidget = null;
}
}
}
return State.REJECTED;
}
示例13: setEdgeWidgetAction
import org.netbeans.api.visual.widget.ConnectionWidget; //导入依赖的package包/类
@Override
public void setEdgeWidgetAction(IEdgeWidget edgeWidget) {
WidgetAction.Chain actions = edgeWidget.getActions();
actions.addAction(ActionFactory.createAddRemoveControlPointAction());
if (edgeWidget instanceof PEdgeWidget) {
actions.addAction(ActionFactory.createMoveControlPointAction(ActionFactory.createFreeMoveControlPointProvider(), ConnectionWidget.RoutingPolicy.DISABLE_ROUTING_UNTIL_END_POINT_IS_MOVED));
} else {
actions.addAction(new MoveControlPointAction(new FreeMoveControlPointProvider(), null)); // Working
}
actions.addAction(file.getModelerScene().createWidgetHoverAction());
actions.addAction(ActionFactory.createSelectAction(EDGE_WIDGET_SELECT_PROVIDER));
actions.addAction(ActionFactory.createReconnectAction(ActionFactory.createDefaultReconnectDecorator(), new SequenceFlowReconnectProvider(file.getModelerScene())));
actions.addAction(ActionFactory.createPopupMenuAction(edgeWidget.getPopupMenuProvider()));
}
示例14: creaCandidateCorrespondence
import org.netbeans.api.visual.widget.ConnectionWidget; //导入依赖的package包/类
private void creaCandidateCorrespondence(ValueCorrespondence valueCorrespondence, MappingTask mappingTask) {
INode iNodeSource = finder.findNodeInSchema(valueCorrespondence.getSourcePaths().get(0), mappingTask.getSourceProxy());
VMDPinWidgetSource sourceWidget = (VMDPinWidgetSource) iNodeSource.getAnnotation(Costanti.PIN_WIDGET_TREE_SPICY);
INode iNodeTarget = finder.findNodeInSchema(valueCorrespondence.getTargetPath(), mappingTask.getTargetProxy());
VMDPinWidgetTarget targetWidget = (VMDPinWidgetTarget) iNodeTarget.getAnnotation(Costanti.PIN_WIDGET_TREE_SPICY);
ConnectionWidget connection = new ConnectionWidget(glassPane.getScene());
connection.setTargetAnchorShape(AnchorShape.TRIANGLE_FILLED);
connection.setSourceAnchor(AnchorFactory.createCenterAnchor(sourceWidget));
connection.setTargetAnchor(AnchorFactory.createRectangularAnchor(targetWidget));
Stroke stroke = Costanti.DASHED_STROKE;
connection.setStroke(stroke);
ConnectionInfo connectionInfo = new ConnectionInfo();
connectionInfo.setConnectionWidget(connection);
connectionInfo.setValueCorrespondence(valueCorrespondence);
connection.setToolTipText(connectionInfo.getValueCorrespondence().toString());
setColorOnConfidence(connectionInfo, connection);
glassPane.getConnectionLayer().addChild(connection, connectionInfo);
connection.getActions().addAction(ActionFactory.createPopupMenuAction(new MyPopupProviderConnectionSpicy(glassPane.getScene())));
connection.getActions().addAction(ActionFactory.createSelectAction(new MySelectConnectionActionProvider(glassPane.getConnectionLayer())));
glassPane.getScene().validate();
}
示例15: creaCorrespondence
import org.netbeans.api.visual.widget.ConnectionWidget; //导入依赖的package包/类
private void creaCorrespondence(VariableCorrespondence variableCorrespondence, ValueCorrespondence valueCorrespondence, MappingTask mappingTask) {
INode iNodeSource = finder.findNodeInSchema(valueCorrespondence.getSourcePaths().get(0), mappingTask.getSourceProxy());
VMDPinWidgetSource sourceWidget = (VMDPinWidgetSource) iNodeSource.getAnnotation(Costanti.PIN_WIDGET_TREE);
INode iNodeTarget = finder.findNodeInSchema(valueCorrespondence.getTargetPath(), mappingTask.getTargetProxy());
VMDPinWidgetTarget targetWidget = (VMDPinWidgetTarget) iNodeTarget.getAnnotation(Costanti.PIN_WIDGET_TREE);
ConnectionWidget connection = new ConnectionWidget(glassPane.getScene());
connection.setTargetAnchorShape(AnchorShape.TRIANGLE_FILLED);
connection.setSourceAnchor(AnchorFactory.createCenterAnchor(sourceWidget));
connection.setTargetAnchor(AnchorFactory.createRectangularAnchor(targetWidget));
Stroke stroke = Costanti.BASIC_STROKE;
connection.setStroke(stroke);
ConnectionInfo connectionInfo = new ConnectionInfo();
connectionInfo.setConnectionWidget(connection);
connectionInfo.setValueCorrespondence(valueCorrespondence);
connection.setToolTipText(connectionInfo.getValueCorrespondence().toString());
glassPane.getConnectionLayer().addChild(connection, connectionInfo);
connection.getActions().addAction(ActionFactory.createPopupMenuAction(new MyPopupProviderConnectionMappingTask(glassPane.getScene())));
connection.getActions().addAction(ActionFactory.createSelectAction(new MySelectConnectionActionProvider(glassPane.getConnectionLayer())));
// analisiFiltro.creaWidgetEsisteFiltro(connection, connectionInfo);
glassPane.getScene().validate();
}