本文整理汇总了Java中org.netbeans.api.visual.graph.GraphScene类的典型用法代码示例。如果您正苦于以下问题:Java GraphScene类的具体用法?Java GraphScene怎么用?Java GraphScene使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GraphScene类属于org.netbeans.api.visual.graph包,在下文中一共展示了GraphScene类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: HierarchicalLayout
import org.netbeans.api.visual.graph.GraphScene; //导入依赖的package包/类
public HierarchicalLayout(GraphScene<N, E> scene, boolean animate,
boolean inverted, int xOffset, int layerOffset) {
dummyWidth = DUMMY_WIDTH;
// scene is not used yet. It will be used when the container agnostic feature
// is put into the NBVL
this.animate = animate;
if (xOffset > 0) {
this.xOffset = xOffset;
} else {
this.xOffset = X_OFFSET;
}
if (layerOffset > 0) {
this.layerOffset = layerOffset;
} else {
this.layerOffset = LAYER_OFFSET;
}
this.invert = inverted;
}
示例2: getAllContainedEdges
import org.netbeans.api.visual.graph.GraphScene; //导入依赖的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;
}
示例3: isOwnerSelected
import org.netbeans.api.visual.graph.GraphScene; //导入依赖的package包/类
private boolean isOwnerSelected(Object o,
Set<?> selected,
GraphScene gscene) {
boolean retVal = false;
Widget widget = gscene.findWidget(o);
if (widget != null) {
Widget parent = widget.getParentWidget();
Object parentObj = gscene.findObject(parent);
if (parentObj != null) {
if (selected.contains(parentObj) == true) {
retVal = true;
} else {
retVal = isOwnerSelected(parentObj, selected, gscene);
}
}
}
return retVal;
}
示例4: DirectedGraph
import org.netbeans.api.visual.graph.GraphScene; //导入依赖的package包/类
/**
* Creates a new instance of DirectedGraph
*/
protected DirectedGraph(UniversalGraph<N, E> uGraph, GraphScene scene) {
this.uGraph = uGraph;
this.scene = scene;
this.nodes = uGraph.getNodes();
this.edges = uGraph.getEdges();
vertexMap = new HashMap<N, Vertex>();
edgeMap = new LinkedHashMap<E, Edge>();
rootVertices = new ArrayList<Vertex>();
vertices = new ArrayList<Vertex>();
}
示例5: MixedGraph
import org.netbeans.api.visual.graph.GraphScene; //导入依赖的package包/类
/** Creates a new instance of UndirectedGraph */
private MixedGraph(UniversalGraph<N, E> uGraph, GraphScene scene) {
this.uGraph = uGraph;
this.scene = scene;
this.nodes = uGraph.getNodes();
this.edges = uGraph.getEdges() ;
vertexMap = new HashMap<N, Vertex>();
}
示例6: MGraph
import org.netbeans.api.visual.graph.GraphScene; //导入依赖的package包/类
/**
*
* @param uGraph
* @param scene
*/
protected MGraph(UniversalGraph<N, E> uGraph, GraphScene scene) {
this.uGraph = uGraph;
this.scene = scene;
this.nodes = uGraph.getNodes();
vertexMap = new HashMap<N, Vertex>();
edgeMap = new LinkedHashMap<E, Edge>();
vertices = new ArrayList<Vertex>();
DummyVertex.resetCounter();
}
示例7: createSceneGraphLayout
import org.netbeans.api.visual.graph.GraphScene; //导入依赖的package包/类
/**
* Creates a scene layout which performs a specified graph-oriented layout on a specified GraphScene.
* @param graphScene the graph scene
* @param graphLayout the graph layout
* @return the scene layout
*/
public static <N,E> SceneLayout createSceneGraphLayout (final GraphScene<N,E> graphScene, final GraphLayout<N,E> graphLayout) {
assert graphScene != null && graphLayout != null;
return new SceneLayout(graphScene) {
protected void performLayout () {
graphLayout.layoutGraph (graphScene);
}
};
}
示例8: getAllNodeChildren
import org.netbeans.api.visual.graph.GraphScene; //导入依赖的package包/类
public static List<Object> getAllNodeChildren(Widget widget) {
if (!(widget.getScene() instanceof GraphScene)) {
return new ArrayList<Object>();
}
return getAllNodeChildrenRecursive(new ArrayList<Object>(), widget);
}
示例9: getAllNodeChildrenRecursive
import org.netbeans.api.visual.graph.GraphScene; //导入依赖的package包/类
private static List<Object> getAllNodeChildrenRecursive(List<Object> list, Widget widget) {
for (Widget child : widget.getChildren()) {
Object pe = ((GraphScene) widget.getScene()).findObject(child);
if (((GraphScene) widget.getScene()).isNode(pe)) {
list.add(pe);
}
list = getAllNodeChildrenRecursive(list, child);
}
return list;
}
示例10: getNodeWidget
import org.netbeans.api.visual.graph.GraphScene; //导入依赖的package包/类
/**
* A connection widget can not be moved. Therefore if the focused widget is
* a connection widget get one of the ends and base the movement on the
* nodes. A node widget will only returned if one of the nodes are selected.
*
* @param widget The target of the key event.
* @return The node widget. If no node widget is selected, then null is
* returned.
*/
private Widget getNodeWidget(Widget widget) {
Widget retVal = widget;
if (widget instanceof ConnectionWidget) {
retVal = null;
ConnectionWidget connection = (ConnectionWidget) widget;
Widget source = connection.getSourceAnchor().getRelatedWidget();
if ((source != null) && (source.getState().isSelected() == true)) {
retVal = source;
} else {
Widget target = connection.getTargetAnchor().getRelatedWidget();
if ((target != null) && (target.getState().isSelected() == true)) {
retVal = target;
}
}
if (retVal == null) {
if (widget.getScene() instanceof GraphScene) {
GraphScene scene = (GraphScene) widget.getScene();
for (Object select : scene.getSelectedObjects()) {
if (scene.isNode(select) == true) {
retVal = scene.findWidget(select);
break;
} else {
//we have an edge label selected here..
retVal = scene.findWidget(select);
if (retVal instanceof ConnectionWidget) {
// The only widget that is selected is an edge.
retVal = null;
}
}
}
}
}
}
return getTopmostWidget(retVal);
}
示例11: createConnection
import org.netbeans.api.visual.graph.GraphScene; //导入依赖的package包/类
@Override
public void createConnection(Widget source, Widget target) {
EdgeWidgetInfo edge = new EdgeWidgetInfo();
edge.setId("_" + NBModelerUtil.getAutoGeneratedId().toString());
edge.setName("");
edge.setSource(((NodeWidget) source).getNodeWidgetInfo().getId());
edge.setTarget(((NodeWidget) target).getNodeWidgetInfo().getId());
((GraphScene) scene).addEdge(edge);
((GraphScene) scene).setEdgeSource(edge, ((NodeWidget) source).getNodeWidgetInfo());
((GraphScene) scene).setEdgeTarget(edge, ((NodeWidget) target).getNodeWidgetInfo());
}
示例12: getElement
import org.netbeans.api.visual.graph.GraphScene; //导入依赖的package包/类
private INodeWidget getElement(Widget widget) {
INodeWidget retVal = null;
Scene widgetScene = widget.getScene();
if (widgetScene instanceof GraphScene) {
GraphScene objScene = (GraphScene) widgetScene;
Object value = objScene.findObject(widget);
if (value instanceof INodeWidget) {
retVal = findNode(objScene, (INodeWidget) value);
}
}
return retVal;
}
示例13: keyReleased
import org.netbeans.api.visual.graph.GraphScene; //导入依赖的package包/类
@Override
public State keyReleased(Widget widget, WidgetKeyEvent event) {
if (event.getKeyCode() == KeyEvent.VK_DELETE) {
GraphScene s = (GraphScene) widget.getScene();
if (widget instanceof NodeWidget) {
s.removeNode(s.findObject(widget));
return State.CONSUMED;
} else if (widget instanceof EdgeWidget) {
widget.removeFromParent();
return State.CONSUMED;
}
}
return State.REJECTED;
}
示例14: layoutScene
import org.netbeans.api.visual.graph.GraphScene; //导入依赖的package包/类
private static void layoutScene(GraphScene<String, String> scene,
String root) {
AbegoTreeLayoutForNetbeans<String, String> graphLayout = new AbegoTreeLayoutForNetbeans<String, String>(
root, 100, 100, 50, 50, true);
SceneLayout sceneLayout = LayoutFactory.createSceneGraphLayout(scene,
graphLayout);
sceneLayout.invokeLayoutImmediately();
}
示例15: layoutScene_NetbeansStyle
import org.netbeans.api.visual.graph.GraphScene; //导入依赖的package包/类
private static void layoutScene_NetbeansStyle(
GraphScene<String, String> scene, String root) {
GraphLayout<String, String> graphLayout = GraphLayoutFactory
.createTreeGraphLayout(100, 100, 50, 50, true);
GraphLayoutSupport.setTreeGraphLayoutRootNode(graphLayout, root);
SceneLayout sceneLayout = LayoutFactory.createSceneGraphLayout(scene,
graphLayout);
sceneLayout.invokeLayoutImmediately();
}