本文整理匯總了Java中edu.uci.ics.jung.visualization.VisualizationViewer.getPickSupport方法的典型用法代碼示例。如果您正苦於以下問題:Java VisualizationViewer.getPickSupport方法的具體用法?Java VisualizationViewer.getPickSupport怎麽用?Java VisualizationViewer.getPickSupport使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類edu.uci.ics.jung.visualization.VisualizationViewer
的用法示例。
在下文中一共展示了VisualizationViewer.getPickSupport方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: handlePopup
import edu.uci.ics.jung.visualization.VisualizationViewer; //導入方法依賴的package包/類
/**
* Implementation of the AbstractPopupGraphMousePlugin method. This is where the
* work gets done. You shouldn't have to modify unless you really want to...
* @param me the MousEvent
*/
protected void handlePopup(MouseEvent me) {
Point2D p = me.getPoint();
VisualizationViewer<GraphNode,GraphEdge> visView = this.basicGraphGui.getVisualizationViewer();
GraphElementAccessor<GraphNode,GraphEdge> pickSupport = visView.getPickSupport();
if(pickSupport != null) {
GraphNode vertex = (GraphNode) pickSupport.getVertex(visView.getGraphLayout(), p.getX(), p.getY());
if(vertex != null) {
//System.out.println("Vertex " + v + " was right clicked");
this.updateVertexMenu(vertex);
vertexPopup.show(visView, me.getX(), me.getY());
basicGraphGui.handleObjectRightClick(vertex);
} else {
GraphEdge edge = (GraphEdge) pickSupport.getEdge(visView.getGraphLayout(), p.getX(), p.getY());
if(edge != null) {
//System.out.println("Edge " + edge + " was right clicked");
this.updateEdgeMenu(edge);
edgePopup.show(visView, me.getX(), me.getY());
basicGraphGui.handleObjectRightClick(edge);
}
}
}
}
示例2: 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 );
}
}
}
示例3: handlePopup
import edu.uci.ics.jung.visualization.VisualizationViewer; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
protected void handlePopup(MouseEvent e) {
final VisualizationViewer<V,E> vv =
(VisualizationViewer<V,E>)e.getSource();
Point2D p = e.getPoint();
GraphElementAccessor<V,E> pickSupport = vv.getPickSupport();
if(pickSupport != null) {
final V v = pickSupport.getVertex(vv.getGraphLayout(), p.getX(), p.getY());
if(v != null) {
updateVertexMenu(v, networkPanel, p);
vertexPopup.show(vv, e.getX(), e.getY());
} else {
final E edge = pickSupport.getEdge(vv.getGraphLayout(), p.getX(), p.getY());
if(edge != null) {
updateEdgeMenu(edge, networkPanel, p);
edgePopup.show(vv, e.getX(), e.getY());
}
}
}
}
示例4: getClickedElement
import edu.uci.ics.jung.visualization.VisualizationViewer; //導入方法依賴的package包/類
private GraphElement getClickedElement( VisualizationViewer<SEMOSSVertex, SEMOSSEdge> viewer,
double x, double y ) {
GraphElementAccessor<SEMOSSVertex, SEMOSSEdge> pickSupport
= viewer.getPickSupport();
SEMOSSVertex vert = pickSupport.getVertex( viewer.getGraphLayout(), x, y );
if ( null != vert ) {
return vert;
}
SEMOSSEdge edge = pickSupport.getEdge( viewer.getGraphLayout(), x, y );
if ( null != edge ) {
return edge;
}
return null;
}
示例5: mousePressed
import edu.uci.ics.jung.visualization.VisualizationViewer; //導入方法依賴的package包/類
/**
* If the mouse is pressed in an empty area, create a new vertex there.
* If the mouse is pressed on an existing vertex, prepare to create
* an edge from that vertex to another
*/
@SuppressWarnings("unchecked")
public void mousePressed(MouseEvent e) {
if(checkModifiers(e)) {
final VisualizationViewer<String,String> vv =
(VisualizationViewer<String,String>)e.getSource();
final Point2D p = e.getPoint();
GraphElementAccessor<String,String> pickSupport = vv.getPickSupport();
if(pickSupport != null) {
final String vertex = pickSupport.getVertex(vv.getModel().getGraphLayout(), p.getX(), p.getY());
if(vertex != null) { // get ready to make an edge
startVertex = vertex;
down = e.getPoint();
transformEdgeShape(down, down);
vv.addPostRenderPaintable(edgePaintable);
transformArrowShape(down, e.getPoint());
vv.addPostRenderPaintable(arrowPaintable);
}
}
vv.repaint();
}
}
示例6: mouseClicked
import edu.uci.ics.jung.visualization.VisualizationViewer; //導入方法依賴的package包/類
@Override
@SuppressWarnings("unchecked")
public void mouseClicked(MouseEvent paramMouseEvent) {
if (paramMouseEvent.getClickCount() == 2) {
VisualizationViewer localVisualizationViewer = (VisualizationViewer) paramMouseEvent.getSource();
Point localPoint = paramMouseEvent.getPoint();
GraphElementAccessor localGraphElementAccessor = localVisualizationViewer.getPickSupport();
if (localGraphElementAccessor != null) {
AbstractEntity localAbstractEntity = (AbstractEntity) localGraphElementAccessor.getVertex(localVisualizationViewer.getGraphLayout(), localPoint.getX(), localPoint.getY());
if (localAbstractEntity != null) {
this.parent.refresh(localAbstractEntity);
}
}
}
super.mouseClicked(paramMouseEvent);
}
示例7: handlePopup
import edu.uci.ics.jung.visualization.VisualizationViewer; //導入方法依賴的package包/類
/**
* If this event is over a node, pop up a menu to
* allow the user to center view to the node
*
* @param e
*/
protected void handlePopup(MouseEvent e)
{
final VisualizationViewer<Node,String> vv = (VisualizationViewer<Node,String>)e.getSource();
final Point p = e.getPoint();
GraphElementAccessor<Node,String> pickSupport = vv.getPickSupport();
if(pickSupport != null)
{
final Node station = pickSupport.getVertex(vv.getGraphLayout(), p.getX(), p.getY());
if (station != null)
{
currentGraphLayout = GraphLayouts.KK;
visualizeNode(station, currentGraphLayout);
}
else
{
currentGraphLayout = currentGraphLayout.next();
visualizeNode(currentVisualNode, currentGraphLayout);
}
}
}
示例8: handlePopup
import edu.uci.ics.jung.visualization.VisualizationViewer; //導入方法依賴的package包/類
/**
* Implementation of the AbstractPopupGraphMousePlugin method. This is where the
* work gets done. You shouldn't have to modify unless you really want to...
* @param e
*/
protected void handlePopup(MouseEvent e) {
final VisualizationViewer<V,E> vv =
(VisualizationViewer<V,E>)e.getSource();
Point2D p = e.getPoint();
GraphElementAccessor<V,E> pickSupport = vv.getPickSupport();
if(pickSupport != null) {
final V v = pickSupport.getVertex(vv.getGraphLayout(), p.getX(), p.getY());
if(v != null) {
// System.out.println("Vertex " + v + " was right clicked");
updateVertexMenu(v, vv, p);
vertexPopup.show(vv, e.getX(), e.getY());
} else {
final E edge = pickSupport.getEdge(vv.getGraphLayout(), p.getX(), p.getY());
if(edge != null) {
// System.out.println("Edge " + edge + " was right clicked");
updateEdgeMenu(edge, vv, p);
edgePopup.show(vv, e.getX(), e.getY());
}
}
}
}
示例9: 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();
}
}
示例10: mouseReleased
import edu.uci.ics.jung.visualization.VisualizationViewer; //導入方法依賴的package包/類
/**
* If startVertex is non-null, and the mouse is released over an
* existing vertex, create an undirected edge from startVertex to
* the vertex under the mouse pointer. If shift was also pressed,
* create a directed edge instead.
*/
@SuppressWarnings("unchecked")
public void mouseReleased(MouseEvent e) {
if(checkModifiers(e)) {
final VisualizationViewer<V,E> vv =
(VisualizationViewer<V,E>)e.getSource();
final Point2D p = e.getPoint();
Layout<V,E> layout = vv.getModel().getGraphLayout();
GraphElementAccessor<V,E> pickSupport = vv.getPickSupport();
if(pickSupport != null) {
final V vertex = pickSupport.getVertex(layout, p.getX(), p.getY());
if(vertex != null && startVertex != null) {
Graph<V,E> graph =
vv.getGraphLayout().getGraph();
graph.addEdge(edgeFactory.create(),
startVertex, vertex, edgeIsDirected);
vv.repaint();
}
}
startVertex = null;
down = null;
edgeIsDirected = EdgeType.UNDIRECTED;
vv.removePostRenderPaintable(edgePaintable);
vv.removePostRenderPaintable(arrowPaintable);
}
}
示例11: 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);
}
}
}
示例12: mousePressed
import edu.uci.ics.jung.visualization.VisualizationViewer; //導入方法依賴的package包/類
/**
* If the mouse is pressed in an empty area, create a new vertex there.
* If the mouse is pressed on an existing vertex, prepare to create
* an edge from that vertex to another
*/
@SuppressWarnings("unchecked")
@Override
public void mousePressed(MouseEvent e) {
if (checkModifiers(e)) {
final VisualizationViewer<Vertex, Edge> vv = (VisualizationViewer<Vertex, Edge>) e.getSource();
final Point2D p = e.getPoint();
GraphElementAccessor<Vertex, Edge> pickSupport = vv.getPickSupport();
if (pickSupport != null) {
final Vertex vertex = pickSupport.getVertex(vv.getModel().getGraphLayout(), p.getX(), p.getY());
if (vertex != null) { // get ready to make an edge
creatingAnEdge = true;
Graph<Vertex, Edge> graph = vv.getModel().getGraphLayout().getGraph();
edgeType = (graph instanceof DirectedGraph) ? EdgeType.DIRECTED : EdgeType.UNDIRECTED;
if ((e.getModifiers() & MouseEvent.SHIFT_MASK) != 0 && graph instanceof UndirectedGraph == false) {
edgeType = EdgeType.DIRECTED;
}
super.mousePressed(e);
} else { // make a new vertex
creatingAnEdge = false;
Vertex newVertex = (Vertex) vertexFactory.create();
action = new CreateVertexUndoableAction(vv.getGraphLayout(), newVertex, vv.getRenderContext().getMultiLayerTransformer().inverseTransform(p));
action.execute();
UndoableControl.getController().actionExecuted(action);
}
}
}
}
示例13: mouseReleased
import edu.uci.ics.jung.visualization.VisualizationViewer; //導入方法依賴的package包/類
/**
* If startVertex is non-null, and the mouse is released over an
* existing vertex, create an undirected edge from startVertex to
* the vertex under the mouse pointer. If shift was also pressed,
* create a directed edge instead.
*/
@SuppressWarnings("unchecked")
@Override
public void mouseReleased(MouseEvent e) {
if (checkModifiers(e)) {
final VisualizationViewer<Vertex, Edge> vv = (VisualizationViewer<Vertex, Edge>) e.getSource();
final Point2D p = e.getPoint();
Layout<Vertex, Edge> layout = vv.getGraphLayout();
GraphElementAccessor<Vertex, Edge> pickSupport = vv.getPickSupport();
if (pickSupport != null) {
if (creatingAnEdge) {
if (startVertex != null) {
Vertex from = (Vertex) startVertex;
Vertex to = pickSupport.getVertex(layout, p.getX(), p.getY());
// Create the new edge
super.mouseReleased(e);
// Find the new edge and wrap it in an UndoableAction
Edge newEdge = layout.getGraph().findEdge(from, to);
action = new CreateEdgeUndoableAction(layout.getGraph(), newEdge, from, to, edgeType);
UndoableControl.getController().actionExecuted(action);
}
}
}
}
}
示例14: mousePressed
import edu.uci.ics.jung.visualization.VisualizationViewer; //導入方法依賴的package包/類
/**
* If the mouse is pressed in an empty area, create a new vertex there. If the
* mouse is pressed on an existing vertex, prepare to create an edge from that
* vertex to another
*/
@SuppressWarnings( "unchecked" )
@Override
public void mousePressed( MouseEvent e ) {
if ( checkModifiers( e ) ) {
final VisualizationViewer<V, E> vv
= (VisualizationViewer<V, E>) e.getSource();
final Point2D p = e.getPoint();
GraphElementAccessor<V, E> pickSupport = vv.getPickSupport();
if ( pickSupport != null ) {
final V vertex = pickSupport.getVertex( vv.getModel().getGraphLayout(), p.getX(), p.getY() );
if ( vertex != null ) {
this.createMode = ( e.isControlDown() ? Creating.MOVE
: Creating.EDGE );
if ( e.isControlDown() ) {
this.createMode = Creating.MOVE;
moveVertex = vertex;
}
else {// get ready to make an edge
this.createMode = Creating.EDGE;
edgeSupport.startEdgeCreate( vv, vertex, e.getPoint(), EdgeType.DIRECTED );
}
}
else { // make a new vertex
this.createMode = Creating.VERTEX;
vertexSupport.startVertexCreate( vv, e.getPoint() );
}
}
}
}
示例15: mouseReleased
import edu.uci.ics.jung.visualization.VisualizationViewer; //導入方法依賴的package包/類
/**
* If startVertex is non-null, and the mouse is released over an existing
* vertex, create an undirected edge from startVertex to the vertex under the
* mouse pointer. If shift was also pressed, create a directed edge instead.
*/
@SuppressWarnings( "unchecked" )
@Override
public void mouseReleased( MouseEvent e ) {
if ( checkModifiers( e ) ) {
final VisualizationViewer<V, E> vv
= (VisualizationViewer<V, E>) e.getSource();
final Point2D p = e.getPoint();
Layout<V, E> layout = vv.getGraphLayout();
if ( createMode == Creating.EDGE ) {
GraphElementAccessor<V, E> pickSupport = vv.getPickSupport();
V vertex = null;
if ( pickSupport != null ) {
vertex = pickSupport.getVertex( layout, p.getX(), p.getY() );
}
if ( null == vertex ) {
edger.cleanup( vv );
}
else {
edgeSupport.endEdgeCreate( vv, vertex );
}
}
else if ( createMode == Creating.VERTEX ) {
vertexSupport.endVertexCreate( vv, e.getPoint() );
}
}
createMode = Creating.UNDETERMINED;
}