本文整理汇总了Java中edu.uci.ics.jung.visualization.picking.PickedState.isPicked方法的典型用法代码示例。如果您正苦于以下问题:Java PickedState.isPicked方法的具体用法?Java PickedState.isPicked怎么用?Java PickedState.isPicked使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.uci.ics.jung.visualization.picking.PickedState
的用法示例。
在下文中一共展示了PickedState.isPicked方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: mousePressed
import edu.uci.ics.jung.visualization.picking.PickedState; //导入方法依赖的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();
}
}
示例2: transform
import edu.uci.ics.jung.visualization.picking.PickedState; //导入方法依赖的package包/类
@Override
public Paint transform(ConflictEdge e) {
Color c = CONFLICT_COLORS.get(e.getConflictType());
PickedState<ConflictVertex> pickedState = vizPanel.getPickedVertexState();
Pair<ConflictVertex> p = graph.getEndpoints(e);
if (pickedState.isPicked(p.getFirst())) {
c = c.darker().darker();
}
return c;
}
示例3: mousePressed
import edu.uci.ics.jung.visualization.picking.PickedState; //导入方法依赖的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();
*/
}
}
}
示例4: mousePressed
import edu.uci.ics.jung.visualization.picking.PickedState; //导入方法依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public void mousePressed(MouseEvent e) {
down = e.getPoint();
nodesMoved = false;
PickedState<V> pickedVertexState = ((VisualizationViewer<V, E>) e.getSource()).getPickedVertexState();
PickedState<E> pickedEdgeState = ((VisualizationViewer<V, E>) e.getSource()).getPickedEdgeState();
if (e.getButton() == MouseEvent.BUTTON1) {
rect.setFrameFromDiagonal(down, down);
if (!e.isShiftDown()) {
if ((vertex = getPickedNode(e)) != null) {
if (!pickedVertexState.isPicked(vertex)) {
pickedVertexState.clear();
pickedVertexState.pick(vertex, true);
call(l -> l.nodePickingFinished());
}
} else if ((edge = getPickedEdge(e)) != null) {
if (!pickedEdgeState.isPicked(edge)) {
pickedEdgeState.clear();
pickedEdgeState.pick(edge, true);
call(l -> l.edgePickingFinished());
}
} else {
boolean nodesPicked = !pickedVertexState.getPicked().isEmpty();
boolean edgesPicked = !pickedEdgeState.getPicked().isEmpty();
if (nodesPicked && edgesPicked) {
pickedVertexState.clear();
pickedEdgeState.clear();
call(l -> l.pickingFinished());
} else if (nodesPicked) {
pickedVertexState.clear();
call(l -> l.nodePickingFinished());
} else if (edgesPicked) {
pickedEdgeState.clear();
call(l -> l.edgePickingFinished());
}
}
} else {
if ((vertex = getPickedNode(e)) != null) {
if (pickedVertexState.pick(vertex, !pickedVertexState.isPicked(vertex))) {
vertex = null;
}
call(l -> l.nodePickingFinished());
} else if ((edge = getPickedEdge(e)) != null) {
if (pickedEdgeState.pick(edge, !pickedEdgeState.isPicked(edge))) {
edge = null;
}
call(l -> l.edgePickingFinished());
}
}
}
}