本文整理匯總了Java中edu.uci.ics.jung.visualization.VisualizationViewer.getPickedVertexState方法的典型用法代碼示例。如果您正苦於以下問題:Java VisualizationViewer.getPickedVertexState方法的具體用法?Java VisualizationViewer.getPickedVertexState怎麽用?Java VisualizationViewer.getPickedVertexState使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類edu.uci.ics.jung.visualization.VisualizationViewer
的用法示例。
在下文中一共展示了VisualizationViewer.getPickedVertexState方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: pickContainedVertices
import edu.uci.ics.jung.visualization.VisualizationViewer; //導入方法依賴的package包/類
/**
* pick the vertices inside the rectangle created from points
* 'down' and 'out'
*/
protected void pickContainedVertices( VisualizationViewer<Room, Exit> vv, Point2D down, Point2D out, boolean clear ) {
Layout<Room, Exit> layout = vv.getGraphLayout();
PickedState<Room> pickedVertexState = vv.getPickedVertexState();
Rectangle2D pickRectangle = new Rectangle2D.Double();
pickRectangle.setFrameFromDiagonal( down, out );
if (pickedVertexState != null) {
if (clear) {
pickedVertexState.clear();
}
GraphElementAccessor<Room, Exit> pickSupport = vv.getPickSupport();
Collection<Room> picked = pickSupport.getVertices( layout, pickRectangle );
for (Room v : picked) {
pickedVertexState.pick( v, true );
}
}
}
示例2: mousePressed
import edu.uci.ics.jung.visualization.VisualizationViewer; //導入方法依賴的package包/類
/**
* If the event occurs on a Vertex, pick that single Vertex
* @param e the event
*/
@SuppressWarnings("unchecked")
public void mousePressed(MouseEvent e) {
if (e.getModifiers() == modifiers) {
VisualizationViewer<V,E> vv = (VisualizationViewer) e.getSource();
GraphElementAccessor<V, E> pickSupport = vv.getPickSupport();
PickedState<V> pickedVertexState = vv.getPickedVertexState();
Layout<V,E> layout = vv.getGraphLayout();
if (pickSupport != null && pickedVertexState != null) {
// p is the screen point for the mouse event
Point2D p = e.getPoint();
vertex = pickSupport.getVertex(layout, p.getX(), p.getY());
if (vertex != null) {
if (pickedVertexState.isPicked(vertex) == false) {
pickedVertexState.clear();
pickedVertexState.pick(vertex, true);
}
}
}
e.consume();
}
}
示例3: pickContainedVertices
import edu.uci.ics.jung.visualization.VisualizationViewer; //導入方法依賴的package包/類
/**
* pick the vertices inside the rectangle created from points
* 'down' and 'out'
*
*/
protected void pickContainedVertices(VisualizationViewer<V,E> vv, Point2D down, Point2D out, boolean clear) {
Layout<V,E> layout = vv.getGraphLayout();
PickedState<V> pickedVertexState = vv.getPickedVertexState();
Rectangle2D pickRectangle = new Rectangle2D.Double();
pickRectangle.setFrameFromDiagonal(down,out);
if(pickedVertexState != null) {
if(clear) {
pickedVertexState.clear();
}
GraphElementAccessor<V,E> pickSupport = vv.getPickSupport();
Collection<V> picked = pickSupport.getVertices(layout, pickRectangle);
for(V v : picked) {
pickedVertexState.pick(v, true);
}
}
}
示例4: mouseDraggedSuperAction
import edu.uci.ics.jung.visualization.VisualizationViewer; //導入方法依賴的package包/類
/**
* This is the MouseDragged super action of the super class (because of several exceptions).
* @param me the MouseEvent
*/
private void mouseDraggedSuperAction(MouseEvent me) {
if(locked == false) {
VisualizationViewer<GraphNode,GraphEdge> vv = this.basicGraphGUI.getVisualizationViewer();
if(vertex != null) {
Point p = me.getPoint();
Point2D graphPoint = vv.getRenderContext().getMultiLayerTransformer().inverseTransform(p);
Point2D graphDown = vv.getRenderContext().getMultiLayerTransformer().inverseTransform(down);
Layout<GraphNode,GraphEdge> layout = vv.getGraphLayout();
double dx = graphPoint.getX()-graphDown.getX();
double dy = graphPoint.getY()-graphDown.getY();
PickedState<GraphNode> ps = vv.getPickedVertexState();
for(GraphNode v : ps.getPicked()) {
Point2D vp = layout.transform(v);
vp.setLocation(vp.getX()+dx, vp.getY()+dy);
layout.setLocation(v, vp);
}
down = p;
me.consume();
vv.repaint();
} else {
Point2D out = me.getPoint();
if(me.getModifiers() == this.addToSelectionModifiers || me.getModifiers() == modifiers) {
if (down!=null) {
rect.setFrameFromDiagonal(down,out);
vv.repaint();
}
}
}
}
}
示例5: mouseDragged
import edu.uci.ics.jung.visualization.VisualizationViewer; //導入方法依賴的package包/類
/**
* If the mouse is over a picked vertex, drag all picked
* vertices with the mouse.
* If the mouse is not over a Vertex, draw the rectangle
* to select multiple Vertices
*/
@SuppressWarnings("unchecked")
public void mouseDragged( MouseEvent e ) {
if (locked == false) {
VisualizationViewer<Room, Exit> vv = (VisualizationViewer) e.getSource();
if (room != null) {
Point p = e.getPoint();
Point2D graphPoint = vv.getRenderContext().getMultiLayerTransformer().inverseTransform( p );
Point2D graphDown = vv.getRenderContext().getMultiLayerTransformer().inverseTransform( down );
Layout<Room, Exit> layout = vv.getGraphLayout();
double dx = graphPoint.getX() - graphDown.getX();
double dy = graphPoint.getY() - graphDown.getY();
PickedState<Room> ps = vv.getPickedVertexState();
for (Room v : ps.getPicked()) {
Point2D vp = layout.transform( v );
vp.setLocation( vp.getX() + dx, vp.getY() + dy );
layout.setLocation( v, vp );
}
down = p;
} else {
Point2D out = e.getPoint();
if (e.getModifiers() == this.addToSelectionModifiers ||
e.getModifiers() == modifiers) {
rect.setFrameFromDiagonal( down, out );
}
}
if (room != null) e.consume();
vv.repaint();
}
}
示例6: mouseDragged
import edu.uci.ics.jung.visualization.VisualizationViewer; //導入方法依賴的package包/類
/**
* If the mouse is over a picked vertex, drag all picked vertices with the mouse. If the mouse
* is not over a Vertex, draw the rectangle to select multiple Vertices
*
*/
@Override
@SuppressWarnings("unchecked")
public void mouseDragged(MouseEvent e) {
if (locked == false) {
VisualizationViewer<V, E> vv = (VisualizationViewer<V, E>) e.getSource();
if (vertex != null) {
Point p = e.getPoint();
Point2D graphPoint = vv.getRenderContext().getMultiLayerTransformer().inverseTransform(p);
Point2D graphDown = vv.getRenderContext().getMultiLayerTransformer().inverseTransform(down);
Layout<V, E> layout = vv.getGraphLayout();
double dx = graphPoint.getX() - graphDown.getX();
double dy = graphPoint.getY() - graphDown.getY();
PickedState<V> ps = vv.getPickedVertexState();
for (V v : ps.getPicked()) {
Point2D vp = layout.transform(v);
vp.setLocation(vp.getX() + dx, vp.getY() + dy);
layout.setLocation(v, vp);
}
down = p;
} else {
if (rectangleSelectionEnabled) {
Point2D out = e.getPoint();
if (e.getModifiers() == this.addToSelectionModifiers || e.getModifiers() == modifiers) {
rect.setFrameFromDiagonal(down, out);
}
}
}
if (vertex != null) {
e.consume();
}
vv.repaint();
}
}
示例7: mouseDragged
import edu.uci.ics.jung.visualization.VisualizationViewer; //導入方法依賴的package包/類
/**
* If the mouse is over a picked vertex, drag all picked
* vertices with the mouse.
* If the mouse is not over a Vertex, draw the rectangle
* to select multiple Vertices
*
*/
@SuppressWarnings("unchecked")
public void mouseDragged(MouseEvent e) {
if(locked == false) {
VisualizationViewer<V,E> vv = (VisualizationViewer)e.getSource();
if(vertex != null) {
Point p = e.getPoint();
Point2D graphPoint = vv.getRenderContext().getMultiLayerTransformer().inverseTransform(p);
Point2D graphDown = vv.getRenderContext().getMultiLayerTransformer().inverseTransform(down);
Layout<V,E> layout = vv.getGraphLayout();
double dx = graphPoint.getX()-graphDown.getX();
double dy = graphPoint.getY()-graphDown.getY();
PickedState<V> ps = vv.getPickedVertexState();
for(V v : ps.getPicked()) {
Point2D vp = layout.transform(v);
vp.setLocation(vp.getX()+dx, vp.getY()+dy);
layout.setLocation(v, vp);
}
down = p;
} else {
Point2D out = e.getPoint();
if(e.getModifiers() == this.addToSelectionModifiers ||
e.getModifiers() == modifiers) {
rect.setFrameFromDiagonal(down,out);
}
}
if(vertex != null) e.consume();
vv.repaint();
}
}
示例8: mousePressed
import edu.uci.ics.jung.visualization.VisualizationViewer; //導入方法依賴的package包/類
@Override
public void mousePressed(MouseEvent e) {
previousNode = null;
travelThroughEdge = null;
down = e.getPoint();
VisualizationViewer<BooleanNode,TravelEdge> vv = (VisualizationViewer)e.getSource();
GraphElementAccessor<BooleanNode,TravelEdge> pickSupport = vv.getPickSupport();
PickedState<BooleanNode> pickedVertexState = vv.getPickedVertexState();
PickedState<TravelEdge> pickedEdgeState = vv.getPickedEdgeState();
if(pickSupport != null && pickedVertexState != null) {
Layout<BooleanNode,TravelEdge> layout = vv.getGraphLayout();
Point2D ip = e.getPoint();
vertex = pickSupport.getVertex(layout, ip.getX(), ip.getY());
if(vertex != null){
if(pickedVertexState.isPicked(vertex) == false) {
pickedVertexState.clear();
pickedVertexState.pick(vertex, true);
}
Graph<BooleanNode, TravelEdge> graph = layout.getGraph();
Collection<TravelEdge> inEdges = graph.getInEdges(vertex);
Collection<TravelEdge> outEdges = graph.getOutEdges(vertex);
TravelEdge[] inEdgesArray = inEdges.toArray(new TravelEdge[inEdges.size()]);
TravelEdge[] outEdgesArray = outEdges.toArray(new TravelEdge[outEdges.size()]);
checkEdge(inEdgesArray, graph);
if (previousNode == null){
checkEdge(outEdgesArray, graph);
}
if ((previousNode != null) && !(previousNode.equals(vertex))){
if ((inEdges.contains(travelThroughEdge) && travelThroughEdge.canTravelDownwards) || (outEdges.contains(travelThroughEdge) && travelThroughEdge.canTravelUpwards)){
previousNode.setCurrentNode(false);
previousNode.setStartNode(true);
vertex.setCurrentNode(true);
SeparationGame.incrementValidMoves();
vv.repaint();
if (vertex.isEndNode()){
System.out.println("End node reached!");
SeparationGame.endNodeReached();
}
} else {
System.out.println("Cannot travel there!");
SeparationGame.incrementInvalidMoves();
}
}
/*
boolean verstate = vertex.getObserved();
vertex.setObserved(!verstate);
vv.repaint();
*/
}
}
}