当前位置: 首页>>代码示例>>Java>>正文


Java VisualizationViewer.getGraphLayout方法代码示例

本文整理汇总了Java中edu.uci.ics.jung.visualization.VisualizationViewer.getGraphLayout方法的典型用法代码示例。如果您正苦于以下问题:Java VisualizationViewer.getGraphLayout方法的具体用法?Java VisualizationViewer.getGraphLayout怎么用?Java VisualizationViewer.getGraphLayout使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在edu.uci.ics.jung.visualization.VisualizationViewer的用法示例。


在下文中一共展示了VisualizationViewer.getGraphLayout方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 );
        }
    }
}
 
开发者ID:lauriholmas,项目名称:batmapper,代码行数:25,代码来源:MapperPickingGraphMousePlugin.java

示例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();
	}
}
 
开发者ID:SiLeBAT,项目名称:BfROpenLab,代码行数:26,代码来源:AnimatedPickingGraphMousePlugin.java

示例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);
        }
    }
}
 
开发者ID:SiLeBAT,项目名称:BfROpenLab,代码行数:26,代码来源:PickingGraphMousePlugin.java

示例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();
                   }
               }
           }
       }
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:38,代码来源:GraphEnvironmentMousePlugin.java

示例5: mouseClicked

import edu.uci.ics.jung.visualization.VisualizationViewer; //导入方法依赖的package包/类
public void mouseClicked(MouseEvent e){
            super.mouseClicked(e);
            VisualizationViewer<V,E> vv = (GraphVisualizationPanel<V,E>)e.getSource();
            Layout<V,E> layout = vv.getGraphLayout();
            Point2D p = e.getPoint();
            vertex = vv.getPickSupport().getVertex(layout,p.getX(), p.getY());
            if(vertex != null){
                MarkovVertex v = (MarkovVertex)vertex;
/**                JPopupMenu j = new JPopupMenu(v.toString());
                j.setLightWeightPopupEnabled(false);
                j.addSeparator();
                j.addMouseListener(new PopupMouseListener());
                j.add(("Single Sited: "+v.getSingleSitedProbability()));
                j.addSeparator();
                j.add(("AbortProbability: "+v.getAbortProbability()));
                j.addSeparator();
                JMenu readonly = new JMenu("Read Only");
                //TODO: This doesn't show the read-only information right now
                for(int i : MarkovViewer.getAllPartitions()){
                    readonly.add(new JMenuItem(i+" "+v.getReadOnlyProbability(i)));
                }
                j.add(readonly);
                j.addSeparator();
                j.add(("Done: "+v.getReadOnlyProbability(0)));
                j.setLocation(e.getLocationOnScreen());
                j.setVisible(true);
                **/
                // FIXME(pavlo) v.printProbabilities(MarkovViewer.this.args.catalog_db);
            }
        }
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:31,代码来源:MarkovViewer.java

示例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
 */
@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();
    }
}
 
开发者ID:lauriholmas,项目名称:batmapper,代码行数:38,代码来源:MapperPickingGraphMousePlugin.java

示例7: 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);
			}
		}
	}

}
 
开发者ID:dev-cuttlefish,项目名称:cuttlefish,代码行数:38,代码来源:UndoableEditingGraphMousePlugin.java

示例8: 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);
				}
			}
		}
	}
}
 
开发者ID:dev-cuttlefish,项目名称:cuttlefish,代码行数:35,代码来源:UndoableEditingGraphMousePlugin.java

示例9: 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;
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:33,代码来源:QueryGraphMousePlugin.java

示例10: 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();
	}
}
 
开发者ID:rapidminer,项目名称:rapidminer-studio,代码行数:41,代码来源:ExtendedPickingGraphMousePlugin.java

示例11: mousePressed

import edu.uci.ics.jung.visualization.VisualizationViewer; //导入方法依赖的package包/类
@Override
public void mousePressed(MouseEvent e) {
	if (e.getButton() == button){
		VisualizationViewer<BayesNode,Pair<Integer,Integer>> vv = (VisualizationViewer)e.getSource();
		Layout<BayesNode,Pair<Integer,Integer>> layout = vv.getGraphLayout();
		NetGraph graph = (NetGraph)layout.getGraph();
		BayesNet net = graph.getNet();

		BayesNode node = getVertex(e.getPoint(), vv);
		if (node != null ) {
			if (!node.isObserved()){
				Boolean assumedValue = node.assumedValue();
				if (assumedValue != null){
					if (assumedValue){
						net.assume(node.type, false);
					} else {
						net.assume(node.type);
				    }
				} else {
					net.assume(node.type, true);
				}
				vv.repaint();
				owner.message();
		}
		}
	}
}
 
开发者ID:ksotala,项目名称:BayesGame,代码行数:28,代码来源:AssumingMousePlugin.java

示例12: getVertex

import edu.uci.ics.jung.visualization.VisualizationViewer; //导入方法依赖的package包/类
/**
 * Transform the point to the coordinate system in the
 * VisualizationViewer, then use either PickSuuport
 * (if available) or Layout to find a Vertex.
 * 
 * (Code and comment copied from Jung MouseListenerTranslator.)
 * @param point
 * @return
 */
private BayesNode getVertex(Point2D point, VisualizationViewer vv) {
    // adjust for scale and offset in the VisualizationViewer
	Point2D p = point;
    	//vv.getRenderContext().getBasicTransformer().inverseViewTransform(point);
    GraphElementAccessor<BayesNode,Pair<Integer,Integer>> pickSupport = vv.getPickSupport();
       Layout<BayesNode,Pair<Integer,Integer>> layout = vv.getGraphLayout();
    BayesNode v = null;
    if(pickSupport != null) {
        v = pickSupport.getVertex(layout, p.getX(), p.getY());
    } 
    return v;
}
 
开发者ID:ksotala,项目名称:BayesGame,代码行数:22,代码来源:AssumingMousePlugin.java

示例13: mousePressed

import edu.uci.ics.jung.visualization.VisualizationViewer; //导入方法依赖的package包/类
@Override
public void mousePressed(MouseEvent e) {
	VisualizationViewer<BayesNode,Pair<Integer,Integer>> vv = (VisualizationViewer)e.getSource();
	Layout<BayesNode,Pair<Integer,Integer>> layout = vv.getGraphLayout();
	NetGraph graph = (NetGraph)layout.getGraph();
	BayesNet net = graph.getNet();

	BayesNode node = getVertex(e.getPoint(), vv);
	if (node != null ) {
		if (node.type.equals(target)){
			owner.message(e);
			switch(targetClicked){
			case 0:
				net.assume(target, true);
				break;
			case 1:
				net.assume(target, false);
				break;
			case 2:
				net.assume(target);
				break;
			}
			if (targetClicked < 2){
				targetClicked++;
			} else {
				targetClicked = 0;
			}
		vv.repaint();
		}
	}
}
 
开发者ID:ksotala,项目名称:BayesGame,代码行数:32,代码来源:TutorialMousePlugin.java

示例14: mouseReleased

import edu.uci.ics.jung.visualization.VisualizationViewer; //导入方法依赖的package包/类
/**
    * override subclass method to translate the master view instead
    * of this satellite view
    * 
    */
   @SuppressWarnings("unchecked")
   public void mouseReleased(MouseEvent e) {
   		if (e.getModifiers() == modifiers) {
		final VisualizationViewer<V,E> vv = (VisualizationViewer) e.getSource();
		if (vv instanceof SatelliteVisualizationViewer) {
			final VisualizationViewer<V,E> vvMaster = 
				((SatelliteVisualizationViewer) vv).getMaster();

			if (vertex != null) {
				Layout<V,E> layout = vvMaster.getGraphLayout();
				Point2D q = layout.transform(vertex);
				Point2D lvc = 
					vvMaster.getRenderContext().getMultiLayerTransformer().inverseTransform(Layer.LAYOUT, vvMaster.getCenter());
				final double dx = (lvc.getX() - q.getX()) / 10;
				final double dy = (lvc.getY() - q.getY()) / 10;

				Runnable animator = new Runnable() {

					public void run() {
						for (int i = 0; i < 10; i++) {
							vvMaster.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT).translate(dx,
									dy);
							try {
								Thread.sleep(100);
							} catch (InterruptedException ex) {
							}
						}
					}
				};
				Thread thread = new Thread(animator);
				thread.start();
			}
		}
	}
}
 
开发者ID:SiLeBAT,项目名称:BfROpenLab,代码行数:41,代码来源:SatelliteAnimatedPickingGraphMousePlugin.java

示例15: mouseReleased

import edu.uci.ics.jung.visualization.VisualizationViewer; //导入方法依赖的package包/类
/**
* If a Vertex was picked in the mousePressed event, start a Thread
* to animate the translation of the graph so that the picked Vertex
* moves to the center of the view
* 
* @param e the event
*/
   @SuppressWarnings("unchecked")
   public void mouseReleased(MouseEvent e) {
	if (e.getModifiers() == modifiers) {
		final VisualizationViewer<V,E> vv = (VisualizationViewer<V,E>) e.getSource();
		if (vertex != null) {
			Layout<V,E> layout = vv.getGraphLayout();
			Point2D q = layout.transform(vertex);
			Point2D lvc = vv.getRenderContext().getMultiLayerTransformer().inverseTransform(vv.getCenter());
			final double dx = (lvc.getX() - q.getX()) / 10;
			final double dy = (lvc.getY() - q.getY()) / 10;

			Runnable animator = new Runnable() {

				public void run() {
					for (int i = 0; i < 10; i++) {
						vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT).translate(dx, dy);
						try {
							Thread.sleep(100);
						} catch (InterruptedException ex) {
						}
					}
				}
			};
			Thread thread = new Thread(animator);
			thread.start();
		}
	}
}
 
开发者ID:SiLeBAT,项目名称:BfROpenLab,代码行数:36,代码来源:AnimatedPickingGraphMousePlugin.java


注:本文中的edu.uci.ics.jung.visualization.VisualizationViewer.getGraphLayout方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。