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


Java StaticLayout类代码示例

本文整理汇总了Java中edu.uci.ics.jung.algorithms.layout.StaticLayout的典型用法代码示例。如果您正苦于以下问题:Java StaticLayout类的具体用法?Java StaticLayout怎么用?Java StaticLayout使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


StaticLayout类属于edu.uci.ics.jung.algorithms.layout包,在下文中一共展示了StaticLayout类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setPrototypePreview

import edu.uci.ics.jung.algorithms.layout.StaticLayout; //导入依赖的package包/类
/**
   * This method takes the GraphPrototype class name as string and creates a graph of the prototype and shows a preview in the visualizationViewer
   * @param graphPrototype
   */
  private void setPrototypePreview() {

  	String componentName = this.localComponentTypeListElement.getComponentName();
  	
  	// --- Create the graph of the NetworkComponent -------------
  	this.localNetworkModel = NetworkComponentFactory.getNetworkModel4NetworkComponent(this.graphController.getNetworkModel().getGeneralGraphSettings4MAS(), componentName, this.getVisualizationViewer().getSize());
  	this.localGraphElementPrototype = NetworkComponentFactory.getGraphElementPrototypeOfLastNetworkComponent();
if (this.localNetworkModel!=null && this.localGraphElementPrototype!=null) {

	// --- Set the graph to the layout ----------------------
   	Layout<GraphNode, GraphEdge> layout = new StaticLayout<GraphNode, GraphEdge>(this.localNetworkModel.getGraph());
	layout.setInitializer(new Transformer<GraphNode, Point2D>() {
		public Point2D transform(GraphNode node) {
			return node.getPosition(); 
		}
	});
	this.getVisualizationViewer().setGraphLayout(layout);
	this.getVisualizationViewer().repaint();
	
	// --- Pick first GraphNode --------------------
	this.pickFirstGraphNode();
    this.setSelectedGraphNode();
    
}
  }
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:30,代码来源:AddComponentDialog.java

示例2: renderElement

import edu.uci.ics.jung.algorithms.layout.StaticLayout; //导入依赖的package包/类
@Override
public void renderElement(JPanel jp, Object elem) {
    if (elem instanceof ViwnNode) {
        ViwnNode vn = (ViwnNode) elem;

        // one node visualisation
        Graph<ViwnNode, ViwnEdge> g = new DirectedSparseGraph<>();
        g.addVertex(vn);
        VisualizationViewer<ViwnNode, ViwnEdge> vv = new VisualizationViewer<>(new StaticLayout<>(g));
        vv.getRenderer().setVertexRenderer(new ViwnVertexRenderer(vv.getRenderer().getVertexRenderer()));

        vv.getRenderContext().setVertexShapeTransformer((ViwnNode v) -> v.getShape());

        vv.getRenderContext().setVertexFillPaintTransformer(new ViwnVertexFillColor(vv.getPickedVertexState(), null));
        vv.setVertexToolTipTransformer(new ViwnVertexToolTipTransformer());
        vv.setPreferredSize(new Dimension(110, 50));
        Point2D q = vv.getGraphLayout().transform(vn);
        Point2D lvc = vv.getRenderContext().getMultiLayerTransformer().inverseTransform(vv.getCenter());
        vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT).translate(lvc.getX() - q.getX(), lvc.getY() - q.getY());
        jp.add(vv, "vfill br");
    }
}
 
开发者ID:CLARIN-PL,项目名称:WordnetLoom,代码行数:23,代码来源:ViwnLockerViewUI.java

示例3: DerivationViewer

import edu.uci.ics.jung.algorithms.layout.StaticLayout; //导入依赖的package包/类
public DerivationViewer(DerivationTree g, Dimension d, Color targetColor, AnchorType anchor) {
  super(new CircleLayout<>(g));
  anchorStyle = anchor;
  DerivationTreeTransformer dtt = new DerivationTreeTransformer(g, d, false);
  StaticLayout<Node, DerivationTreeEdge> derivationLayout = new StaticLayout<>(g, dtt);
  // derivationLayout.setSize(dtt.getSize());
  setGraphLayout(derivationLayout);
  scaleToLayout(new LayoutScalingControl());
  // g.addCorrespondences();
  setPreferredSize(new Dimension(DEFAULT_HEIGHT, DEFAULT_WIDTH));
  getRenderContext().setVertexLabelTransformer(new ToStringLabeller<>());

  DefaultModalGraphMouse<Node, DerivationTreeEdge> graphMouse = new DefaultModalGraphMouse<>();
  graphMouse.setMode(ModalGraphMouse.Mode.TRANSFORMING);
  setGraphMouse(graphMouse);
  addKeyListener(graphMouse.getModeKeyListener());
  // this.setPickedVertexState(new DerivationTreePickedState(g));

  getRenderContext().setVertexFillPaintTransformer(vp);
  getRenderContext().setEdgeStrokeTransformer(es);
  getRenderContext().setVertexShapeTransformer(ns);
  getRenderer().getVertexLabelRenderer().setPosition(Position.CNTR);

  TGT = targetColor;
  anchorPoint = dtt.getAnchorPosition(anchorStyle);
}
 
开发者ID:apache,项目名称:incubator-joshua,代码行数:27,代码来源:DerivationViewer.java

示例4: DefaultInstanceViewer

import edu.uci.ics.jung.algorithms.layout.StaticLayout; //导入依赖的package包/类
/**
 * Instantiates a new default instance viewer.
 * 
 * @param graph
 *            the graph
 * @param preferredSize
 *            the preferred size
 * @param bounds
 *            bounds for the nodes coordinates
 */
public DefaultInstanceViewer(Graph<INodeVisit, IArc> graph, Dimension preferredSize,
        double[] bounds) {
    super(new StaticLayout<INodeVisit, IArc>(graph), preferredSize);

    mGraph = graph;

    mTransformer = new NodeVisitTransformer(Math.ceil(Math.max(bounds[1] - bounds[0], bounds[3]
            - bounds[2])), 14, -bounds[0], -bounds[2]);
    getGraphLayout().setInitializer(mTransformer);
    addComponentListener(mTransformer);

    mVertexSize = UIManager.getFont("Label.font").getSize() + 4;
    setDefaultVertexShapeTransformer();
    setDefaultVertexFillPaintTransformer();
    setDefaultVertexLabelTransformer();
    getRenderContext().setVertexFontTransformer(new Transformer<INodeVisit, Font>() {
        @Override
        public Font transform(INodeVisit arg0) {
            return UIManager.getFont("Label.font");
        }
    });
    addComponentListener(this);
}
 
开发者ID:vpillac,项目名称:vroom,代码行数:34,代码来源:DefaultInstanceViewer.java

示例5: doGraphLayout

import edu.uci.ics.jung.algorithms.layout.StaticLayout; //导入依赖的package包/类
@Override
public void doGraphLayout() {
	layout.setSize(vv.getSize());
	layout.initialize();
	Relaxer relaxer = new VisRunner((IterativeContext) layout);
	relaxer.stop();
	relaxer.prerelax();
	
	StaticLayout<Node, Edge> staticLayout = new StaticLayout<Node,Edge>(graph, layout, vv.getSize());
	LayoutTransition<Node,Edge> lt = new LayoutTransition<Node,Edge>(vv, vv.getGraphLayout(),
										staticLayout);
	Animator animator = new Animator(lt);
	animator.start();
	vv.repaint();
	
	FeatureMask mask = new FeatureMask(FeatureMask.TRANSLATE_SUPPORT | FeatureMask.SCALING_SUPPORT);
	GraphEditorEventHandler eventHandler = new GraphEditorEventHandler(vv.getRenderContext(),
												null, null, mask);
	vv.setGraphMouse(eventHandler);
}
 
开发者ID:andreiolaru-ro,项目名称:AmIciTy-Grph,代码行数:21,代码来源:AnimatedJungGraphViewer.java

示例6: updateGraph

import edu.uci.ics.jung.algorithms.layout.StaticLayout; //导入依赖的package包/类
public void updateGraph() {
    if (graphService == null || graphService.getReachabilityGraph() == null)
        return;
    Graph<State, TransitionEdge> graph = graphService.getReachabilityGraph();
    visualizationViewer.setGraphLayout(new StaticLayout<>(graph, new ReachGraphInitializer(graph.getVertices())));
    bfsDistanceLabeler.labelDistances(graph, ReachabilityGraphGenerator.findRoot(graph));
    visualizationViewer.getPickedVertexState().clear();
    visualizationViewer.repaint();
}
 
开发者ID:tomaszi1,项目名称:petri-nets-simulator,代码行数:10,代码来源:ReachabilityGraphPanel.java

示例7: animate

import edu.uci.ics.jung.algorithms.layout.StaticLayout; //导入依赖的package包/类
private void animate()
  {
  	// while we are animating, the task scheduler is not allowed to modify the graph
  	// otherwise we will have a ConcurrentModificationException, because this animation iterates
  	// over the vertices and edges, while the task scheduler thread modifies them.
  	
  	layout.initialize();

  	if (GeneralMDPSettings.ANIMATE) {
   	Relaxer relaxer = new VisRunner((IterativeContext)layout);
	relaxer.stop();
	relaxer.prerelax();
	
	StaticLayout<Vertex<?>,Edge<?,?>> staticLayout =
		new StaticLayout<Vertex<?>,Edge<?,?>>(g, layout);
	LayoutTransition<Vertex<?>,Edge<?,?>> lt =
		new LayoutTransition<Vertex<?>,Edge<?,?>>(vv, vv.getGraphLayout(),
				staticLayout);

	Animator animator = new Animator(lt);
	animator.start();
  	}
  	
vv.repaint();
  	repaint();
  	
  	// resume scheduling after 200ms, give the visualization some time to draw before editing the graph again
  	resumeTaskScheduler(GeneralMDPSettings.REPAINT_DELAY-100); 
  }
 
开发者ID:marcvanzee,项目名称:mdp-plan-revision,代码行数:30,代码来源:MDPDrawer.java

示例8: paintGraph

import edu.uci.ics.jung.algorithms.layout.StaticLayout; //导入依赖的package包/类
private void paintGraph(Collection<Planet> planets) {
	planetsInGraph = new HashMap<String, Planet>();
	graph = new SparseMultigraph<Planet, String>();

	for (Planet planet : planets) {
		graph.addVertex(planet);
		planetsInGraph.put(planet.getId(), planet);
	}

	paintEdges();
	locationTransformer = new LocationTransformer(
			Collections.unmodifiableCollection(planets), vm.getGameType());
	final Layout<Planet, String> layout = new StaticLayout<Planet, String>(graph,
			locationTransformer);
	layout.setSize(new Dimension(View.START_WIDTH, View.START_HEIGHT));

	vv = new VisualizationViewer<Planet, String>(layout);
	vv.setPreferredSize(new Dimension(View.START_WIDTH, View.START_HEIGHT));
	vv.setRenderer(new UglyHuckRenderer());
	vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint);
	vv.getRenderContext().setVertexShapeTransformer(vertexSize);
	// vv.getRenderContext().setEdgeStrokeTransformer(edgeStrokeTransformer);
	vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());
	vv.getRenderContext().setEdgeDrawPaintTransformer(edgePaint);
	vv.getRenderContext().setArrowDrawPaintTransformer(edgePaint);
	vv.getRenderContext().setEdgeLabelTransformer(edgeLabel);

	vv.getRenderer().getVertexLabelRenderer()
			.setPosition(Renderer.VertexLabel.Position.CNTR);

	vv.getRenderContext().setEdgeShapeTransformer(
			new EdgeShape.Line<Planet, String>());			

	this.add(vv);
	updateUI();
	// this.validate();
	this.repaint();
}
 
开发者ID:burningrain,项目名称:planetBot,代码行数:39,代码来源:GraphWidget.java

示例9: BetterVisualizationViewer

import edu.uci.ics.jung.algorithms.layout.StaticLayout; //导入依赖的package包/类
public BetterVisualizationViewer() {
	super(new ChangeSupportLayout<>(new StaticLayout<>(new DirectedSparseMultigraph<>())));
	getRenderer().setEdgeRenderer(new BetterEdgeRenderer<>());
	getRenderer().setEdgeLabelRenderer(new BetterEdgeLabelRenderer<>());
	getRenderer().setVertexLabelRenderer(new BetterVertexLabelRenderer<>(LabelPosition.BOTTOM_RIGHT));
	setPickSupport(new BetterShapePickSupport<>(this));
	getGraphLayout().setGraph(new BetterDirectedSparseMultigraph<>(this));
	setDoubleBuffered(true);
}
 
开发者ID:SiLeBAT,项目名称:BfROpenLab,代码行数:10,代码来源:BetterVisualizationViewer.java

示例10: LayoutTransition

import edu.uci.ics.jung.algorithms.layout.StaticLayout; //导入依赖的package包/类
/**
 * @param startLayout
 * @param endLayout
 */
public LayoutTransition(VisualizationViewer<V,E> vv, Layout<V, E> startLayout, Layout<V, E> endLayout) {
	this.vv = vv;
	this.startLayout = startLayout;
	this.endLayout = endLayout;
	if(endLayout instanceof IterativeContext) {
		Relaxer relaxer = new VisRunner((IterativeContext)endLayout);
		relaxer.prerelax();
	}
	this.transitionLayout =
		new StaticLayout<V,E>(startLayout.getGraph(), startLayout);
	vv.setGraphLayout(transitionLayout);
}
 
开发者ID:SiLeBAT,项目名称:BfROpenLab,代码行数:17,代码来源:LayoutTransition.java

示例11: JungGraphViewer

import edu.uci.ics.jung.algorithms.layout.StaticLayout; //导入依赖的package包/类
public JungGraphViewer(JungGraph aGraph) {
	this.graph = aGraph;

	this.setLayout(new BorderLayout());
	layout = new StaticLayout<Node, Edge>(graph);
	vv = new VisualizationViewer<Node, Edge>(layout);
	
	vv.setBackground(Color.white);

	vv.getRenderContext().setVertexLabelTransformer(new NodeTransformer());
	vv.getRenderContext().setEdgeLabelTransformer(new EdgeTransformer());
	vv.getRenderContext().setVertexStrokeTransformer(new NodeStrokeTransformer(vv));
	vv.getRenderContext().setEdgeLabelRenderer(new DefaultEdgeLabelRenderer(Color.YELLOW));
	vv.getRenderer().getVertexLabelRenderer().setPosition(Position.CNTR);

	Transformer<Node, Shape> vertexSize = new Transformer<Node, Shape>() {
		public Shape transform(Node i) {
			int length = i.getLabel().length() * 10;
			length = length > 30 ? length : 30;
			return new Rectangle(-20, -10, length, 30);
		}
	};
	vv.getRenderContext().setVertexShapeTransformer(vertexSize);

	final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv);
	panel.setPreferredSize(new Dimension(400, 400));
	add(panel, BorderLayout.CENTER);
}
 
开发者ID:andreiolaru-ro,项目名称:AmIciTy-Grph,代码行数:29,代码来源:JungGraphViewer.java

示例12: rotateGraph

import edu.uci.ics.jung.algorithms.layout.StaticLayout; //导入依赖的package包/类
/**
 * Rotates the current graph around itself.
 * @param rotateAngle the angle on which the graph should rotate 
 */
private void rotateGraph(double rotateAngle) {
	
	if (this.localNetworkModel!=null) {
		Graph<GraphNode, GraphEdge> graph = this.localNetworkModel.getGraph();
		if (graph!=null) {
			Vector<GraphNode> graphNodes = new Vector<GraphNode>(graph.getVertices());
			if (graphNodes.size()>1) {
				
    	    	double centerX = this.getVisualizationViewer().getCenter().getX();
    	    	double centerY = this.getVisualizationViewer().getCenter().getY();
    			
    			// --- Get all GraphNodes and rotate then around the center ---
    			for (GraphNode graphNode : graphNodes) {
    				
    				double newX = 0;
    				double newY = 0;
    				double oldX = graphNode.getPosition().getX() - centerX;
    				double oldY = graphNode.getPosition().getY() - centerY;
    				
    				double hypotenuse = Math.pow((Math.pow(oldX, 2) + Math.pow(oldY, 2)), 0.5);
    				hypotenuse = Math.round(hypotenuse*10)/10;
    				double oldAngle = Math.atan(oldY / oldX);
    				if (Double.isNaN(oldAngle)==false) {
    					if (oldX < 0 && oldY >= 0) {
        					oldAngle += Math.PI;
        				} else if (oldX < 0 && oldY < 0){
        					oldAngle += Math.PI;
        				}else if (oldX >= 0 && oldY < 0){
        					oldAngle += 2*Math.PI;
        				}
        				double newAngle = oldAngle + rotateAngle;
        				newX = Math.cos(newAngle) * hypotenuse;
        				newY = Math.sin(newAngle) * hypotenuse;
        				
    				}
    				Point2D newPosition = new Point2D.Double(centerX+newX, centerY+newY);
    				graphNode.setPosition(newPosition);
    				
    			}
    			
				Layout<GraphNode, GraphEdge> layout = new StaticLayout<GraphNode, GraphEdge>(graph);
				layout.setInitializer(new Transformer<GraphNode, Point2D>() {
					public Point2D transform(GraphNode node) {
						return node.getPosition(); // The position is specified in the GraphNode instance
					}
				});
				this.getVisualizationViewer().setGraphLayout(layout);
    			this.getVisualizationViewer().repaint();
    			
			}
		}
	}
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:58,代码来源:AddComponentDialog.java

示例13: setGraph

import edu.uci.ics.jung.algorithms.layout.StaticLayout; //导入依赖的package包/类
public void setGraph(DerivationTree tree) {
  DerivationTreeTransformer dtt = new DerivationTreeTransformer(tree, getSize(), true);
  dtt.setAnchorPoint(anchorStyle, anchorPoint);
  setGraphLayout(new StaticLayout<>(tree, dtt));
}
 
开发者ID:apache,项目名称:incubator-joshua,代码行数:6,代码来源:DerivationViewer.java

示例14: createGraphComponent

import edu.uci.ics.jung.algorithms.layout.StaticLayout; //导入依赖的package包/类
private JComponent createGraphComponent() {

        Graph<State, TransitionEdge> graph = new DirectedSparseGraph<>();

        Layout<State, TransitionEdge> layout = new StaticLayout<>(graph, new ReachGraphInitializer(graph.getVertices()));

        visualizationViewer = new VisualizationViewer<>(layout);
        DefaultModalGraphMouse gm = new DefaultModalGraphMouse();
        gm.setMode(ModalGraphMouse.Mode.TRANSFORMING);
        visualizationViewer.setGraphMouse(gm);

        VertexLabelAsShapeRenderer<State, TransitionEdge> vertexRenderer = new VertexLabelAsShapeRenderer<>(visualizationViewer.getRenderContext());

        // vertices
        visualizationViewer.getRenderContext().setVertexLabelTransformer(state -> {
            StringBuilder sb = new StringBuilder();
            for (Integer token : state.getMarking().values()) {
                sb.append(token == -1 ? "\u221E" : token).append(",");
            }
            if (sb.length() > 0) sb.setLength(sb.length() - 1);
            return sb.toString();
        });
        visualizationViewer.getRenderContext().setVertexShapeTransformer(vertexRenderer);
        visualizationViewer.getRenderContext().setVertexFillPaintTransformer(s -> {
            if (!visualizationViewer.getPickedVertexState().getPicked().isEmpty())
                return visualizationViewer.getPickedVertexState().isPicked(s) ? ACTIVE_VERTEX_FILL_COLOR : INACTIVE_VERTEX_FILL_COLOR;
            return VERTEX_FILL_COLOR;
        });
        visualizationViewer.getRenderContext().setVertexFontTransformer(s -> FONT);
        visualizationViewer.getRenderer().setVertexLabelRenderer(vertexRenderer);

        // edges
        visualizationViewer.getRenderContext().setEdgeLabelTransformer(transition -> "T" + transition.getTransition().getId());
        visualizationViewer.getRenderContext().setEdgeShapeTransformer(new EdgeShape.CubicCurve<>());
        visualizationViewer.getRenderContext().setEdgeDrawPaintTransformer(this::getEdgeColor);
        visualizationViewer.getRenderContext().setArrowDrawPaintTransformer(this::getEdgeColor);
        visualizationViewer.getRenderContext().setArrowFillPaintTransformer(this::getEdgeColor);
        visualizationViewer.getRenderContext().setEdgeFontTransformer(s -> FONT);
        visualizationViewer.getRenderContext().getEdgeLabelRenderer().setRotateEdgeLabels(false);
        ReachGraphEdgeLabelRenderer<State, TransitionEdge> reachGraphEdgeLabelRenderer = new ReachGraphEdgeLabelRenderer<>(this::getEdgeColor);
        visualizationViewer.getRenderer().setEdgeLabelRenderer(reachGraphEdgeLabelRenderer);

        visualizationViewer.setBackground(GRAPH_BACKGROUND);

        addComponentListener(new AbstractResizeComponentListener() {
            @Override
            public void componentResized(ComponentEvent e) {
                Dimension size = e.getComponent().getSize();
                layout.setSize(size);
            }
        });

        ReachGraphMouseListener graphMouseListener = new ReachGraphMouseListener(visualizationViewer, new StatePickedListener(graphService), this);
        visualizationViewer.addMouseListener(graphMouseListener);
        visualizationViewer.addGraphMouseListener(graphMouseListener);

        return visualizationViewer;
    }
 
开发者ID:tomaszi1,项目名称:petri-nets-simulator,代码行数:59,代码来源:ReachabilityGraphPanel.java

示例15: process

import edu.uci.ics.jung.algorithms.layout.StaticLayout; //导入依赖的package包/类
public void process() {

    	vv.getRenderContext().getPickedVertexState().clear();
    	vv.getRenderContext().getPickedEdgeState().clear();
        try {

            if (g.getVertexCount() < 100) {
                //add a vertex
                Integer v1 = new Integer(g.getVertexCount());

                g.addVertex(v1);
                vv.getRenderContext().getPickedVertexState().pick(v1, true);

                // wire it to some edges
                if (v_prev != null) {
                	Integer edge = g.getEdgeCount();
                	vv.getRenderContext().getPickedEdgeState().pick(edge, true);
                    g.addEdge(edge, v_prev, v1);
                    // let's connect to a random vertex, too!
                    int rand = (int) (Math.random() * g.getVertexCount());
                    edge = g.getEdgeCount();
                	vv.getRenderContext().getPickedEdgeState().pick(edge, true);
                   g.addEdge(edge, v1, rand);
                }

                v_prev = v1;

                layout.initialize();

        		Relaxer relaxer = new VisRunner((IterativeContext)layout);
        		relaxer.stop();
        		relaxer.prerelax();
        		StaticLayout<Number,Number> staticLayout =
        			new StaticLayout<Number,Number>(g, layout);
				LayoutTransition<Number,Number> lt =
					new LayoutTransition<Number,Number>(vv, vv.getGraphLayout(),
							staticLayout);
				Animator animator = new Animator(lt);
				animator.start();
//				vv.getRenderContext().getMultiLayerTransformer().setToIdentity();
				vv.repaint();

            } else {
            	done = true;
            }

        } catch (Exception e) {
            System.out.println(e);

        }
    }
 
开发者ID:marcvanzee,项目名称:mdp-plan-revision,代码行数:52,代码来源:AnimatingAddNodeDemo.java


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