當前位置: 首頁>>代碼示例>>Java>>正文


Java Layout.getGraph方法代碼示例

本文整理匯總了Java中edu.uci.ics.jung.algorithms.layout.Layout.getGraph方法的典型用法代碼示例。如果您正苦於以下問題:Java Layout.getGraph方法的具體用法?Java Layout.getGraph怎麽用?Java Layout.getGraph使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在edu.uci.ics.jung.algorithms.layout.Layout的用法示例。


在下文中一共展示了Layout.getGraph方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: LayerViewer

import edu.uci.ics.jung.algorithms.layout.Layout; //導入方法依賴的package包/類
public LayerViewer(Layout<V, E> layout, ILayer<V, E> g) {
	super(layout);
	this.g = g;
	if (layout.getGraph() != g)
		layout.setGraph(g);

	// Cache the graph size.
	updateGraphBoundsCache();
	if (getGraphLayout() instanceof ChangeEventSupport)
		((ChangeEventSupport) getGraphLayout())
				.addChangeListener(new ChangeListener() {
					@Override
					public void stateChanged(ChangeEvent e) {
						updateGraphBoundsCache();
					}
				});
}
 
開發者ID:KeepTheBeats,項目名稱:alevin-svn2,代碼行數:18,代碼來源:LayerViewer.java

示例2: restore

import edu.uci.ics.jung.algorithms.layout.Layout; //導入方法依賴的package包/類
public void restore(String fileName) throws IOException,
        ClassNotFoundException {
    ObjectInputStream ois = new ObjectInputStream(new FileInputStream(
            fileName));
    map = (Map) ois.readObject();
    ois.close();
    Layout newLayout = this.getDelegate();
    Graph newGraph = newLayout.getGraph();
    Set<String> oldVertexes = map.keySet();
    for (String oldVertex : oldVertexes) {
        if (!newGraph.containsVertex(oldVertex)){
            this.lock(oldVertex,true);
        }
    }
    for (Object newVertex : newGraph.getVertices()) {
        if (!oldVertexes.contains(newVertex)){
            this.lock(newVertex,true);
        }
    }
    initializeLocations();

    locked = true;
    fireStateChanged();
}
 
開發者ID:iTransformers,項目名稱:netTransformer,代碼行數:25,代碼來源:MyPersistentLayoutImpl.java

示例3: LayerViewer

import edu.uci.ics.jung.algorithms.layout.Layout; //導入方法依賴的package包/類
public LayerViewer(Layout<V, E> layout, ILayer<V, E> g) {
    super(layout);
    this.g = g;
    if (layout.getGraph() != g)
        layout.setGraph(g);

    // Cache the graph size.
    updateGraphBoundsCache();
    if (getGraphLayout() instanceof ChangeEventSupport)
        ((ChangeEventSupport) getGraphLayout())
                .addChangeListener(new ChangeListener() {
                    @Override
                    public void stateChanged(ChangeEvent e) {
                        updateGraphBoundsCache();
                    }
                });
}
 
開發者ID:liruixpc11,項目名稱:crucian,代碼行數:18,代碼來源:LayerViewer.java

示例4: paintEdge

import edu.uci.ics.jung.algorithms.layout.Layout; //導入方法依賴的package包/類
public void paintEdge(RenderContext<V,E> rc, Layout<V, E> layout, E e) {
    GraphicsDecorator g2d = rc.getGraphicsContext();
    Graph<V,E> graph = layout.getGraph();
    if (!rc.getEdgeIncludePredicate().evaluate(Context.<Graph<V,E>,E>getInstance(graph,e)))
        return;
    
    // don't draw edge if either incident vertex is not drawn
    Pair<V> endpoints = graph.getEndpoints(e);
    V v1 = endpoints.getFirst();
    V v2 = endpoints.getSecond();
    if (!rc.getVertexIncludePredicate().evaluate(Context.<Graph<V,E>,V>getInstance(graph,v1)) || 
        !rc.getVertexIncludePredicate().evaluate(Context.<Graph<V,E>,V>getInstance(graph,v2)))
        return;
    
    Stroke new_stroke = rc.getEdgeStrokeTransformer().transform(e);
    Stroke old_stroke = g2d.getStroke();
    if (new_stroke != null)
        g2d.setStroke(new_stroke);
    
    drawSimpleEdge(rc, layout, e);

    // restore paint and stroke
    if (new_stroke != null)
        g2d.setStroke(old_stroke);

}
 
開發者ID:SiLeBAT,項目名稱:BfROpenLab,代碼行數:27,代碼來源:BasicEdgeRenderer.java

示例5: labelVertex

import edu.uci.ics.jung.algorithms.layout.Layout; //導入方法依賴的package包/類
/**
* Labels the specified vertex with the specified label.  
* Uses the font specified by this instance's 
* <code>VertexFontFunction</code>.  (If the font is unspecified, the existing
* font for the graphics context is used.)  If vertex label centering
* is active, the label is centered on the position of the vertex; otherwise
   * the label is offset slightly.
   */
  public void labelVertex(RenderContext<V,E> rc, Layout<V,E> layout, V v, String label) {
  	Graph<V,E> graph = layout.getGraph();
      if (rc.getVertexIncludePredicate().evaluate(Context.<Graph<V,E>,V>getInstance(graph,v)) == false) {
      	return;
      }
      GraphicsDecorator g = rc.getGraphicsContext();
      Component component = prepareRenderer(rc, rc.getVertexLabelRenderer(), label,
      		rc.getPickedVertexState().isPicked(v), v);
      Dimension d = component.getPreferredSize();
      
      int h_offset = -d.width / 2;
      int v_offset = -d.height / 2;
      
      Point2D p = layout.transform(v);
      p = rc.getMultiLayerTransformer().transform(Layer.LAYOUT, p);

      int x = (int)p.getX();
      int y = (int)p.getY();

      g.draw(component, rc.getRendererPane(), x+h_offset, y+v_offset, d.width, d.height, true);

      Dimension size = component.getPreferredSize();
      Rectangle bounds = new Rectangle(-size.width/2 -2, -size.height/2 -2, size.width+4, size.height);
      shapes.put(v, bounds);
  }
 
開發者ID:SiLeBAT,項目名稱:BfROpenLab,代碼行數:34,代碼來源:VertexLabelAsShapeRenderer.java

示例6: BoundingRectanglePaintable

import edu.uci.ics.jung.algorithms.layout.Layout; //導入方法依賴的package包/類
public BoundingRectanglePaintable(RenderContext<V, E> rc, Layout<V, E> layout) {
	super();
	this.rc = rc;
	this.layout = layout;
	this.graph = layout.getGraph();
	final BoundingRectangleCollector<V,E> brc = new BoundingRectangleCollector<V,E>(rc, layout);
	this.rectangles = brc.getRectangles();
	if(layout instanceof ChangeEventSupport) {
		((ChangeEventSupport)layout).addChangeListener(new ChangeListener() {

			public void stateChanged(ChangeEvent e) {
				brc.compute();
				rectangles = brc.getRectangles();
			}});
	}
}
 
開發者ID:SiLeBAT,項目名稱:BfROpenLab,代碼行數:17,代碼來源:BoundingRectanglePaintable.java

示例7: handlePopup

import edu.uci.ics.jung.algorithms.layout.Layout; //導入方法依賴的package包/類
/**
 * Reduced functionality of super class method and extended by own
 * content-aware editing.
 */
@SuppressWarnings("unchecked")
@Override
protected final void handlePopup(final MouseEvent e) {
	if (checkModifiers(e)) {
		final LV vv = (LV) e.getSource();
		final Layout<V, E> layout = vv.getGraphLayout();
		final L graph = (L) layout.getGraph();
		final Point p = e.getPoint();

		final List<V> sel_vertices = getSelectedVertices();
		final List<E> sel_edges = getSelectedEdges();

		GraphElementAccessor<V, E> pickSupport = vv.getPickSupport();
		if (pickSupport != null) {
			V vertex = pickSupport.getVertex(layout, p.getX(), p.getY());
			E edge = pickSupport.getEdge(layout, p.getX(), p.getY());

			if (vertex != null && !sel_vertices.contains(vertex))
				sel_vertices.add(vertex);
			if (edge != null && !sel_edges.contains(edge))
				sel_edges.add(edge);
		}

		popup.removeAll();
		if (sel_vertices.size() > 0)
			createVertexMenuEntries(p, graph, vv, sel_vertices);
		else if (sel_edges.size() > 0)
			createEdgeMenuEntries(p, graph, vv, sel_edges);
		else
			createGeneralMenuEntries(p, graph, vv);

		if (popup.getComponentCount() > 0)
			popup.show(vv, e.getX(), e.getY());
	}
}
 
開發者ID:KeepTheBeats,項目名稱:alevin-svn2,代碼行數:40,代碼來源:AbstractPopupMousePlugin.java

示例8: paintVertex

import edu.uci.ics.jung.algorithms.layout.Layout; //導入方法依賴的package包/類
@Override
public void paintVertex(RenderContext<V, E> rc, Layout<V, E> layout, V v) {
	Graph<V, E> graph = layout.getGraph();
	if (rc.getVertexIncludePredicate().evaluate(Context.<Graph<V, E>, V> getInstance(graph, v))) {
		paintIconForVertex(rc, v, layout);
	}
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:8,代碼來源:TreeModelNodeRenderer.java

示例9: paintVertex

import edu.uci.ics.jung.algorithms.layout.Layout; //導入方法依賴的package包/類
@Override
public void paintVertex(RenderContext<ViwnNode, ViwnEdge> rc,
                        Layout<ViwnNode, ViwnEdge> layout, ViwnNode v) {
    Graph<ViwnNode, ViwnEdge> graph = layout.getGraph();
    if (rc.getVertexIncludePredicate().evaluate(Context.<Graph<ViwnNode, ViwnEdge>, ViwnNode>getInstance(graph, v))) {
        paintVertex(rc, v, layout);
    }
}
 
開發者ID:CLARIN-PL,項目名稱:WordnetLoom,代碼行數:9,代碼來源:ViwnVertexRenderer.java

示例10: DeleteVertexUndoableAction

import edu.uci.ics.jung.algorithms.layout.Layout; //導入方法依賴的package包/類
public DeleteVertexUndoableAction(Layout<Vertex, Edge> layout, Vertex vertex) {
	this.layout = layout;
	this.graph = layout.getGraph();
	this.vertex = vertex;
	this.position = layout.transform(vertex);
	this.incidentEdges = new ArrayList<IncidentEdge>();

	for (Edge e : graph.getIncidentEdges(vertex)) {
		this.incidentEdges.add(new IncidentEdge(e, graph.getEdgeType(e), graph.getEndpoints(e)));
	}
}
 
開發者ID:dev-cuttlefish,項目名稱:cuttlefish,代碼行數:12,代碼來源:DeleteVertexUndoableAction.java

示例11: mouseReleased

import edu.uci.ics.jung.algorithms.layout.Layout; //導入方法依賴的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

示例12: computeCoreness

import edu.uci.ics.jung.algorithms.layout.Layout; //導入方法依賴的package包/類
private void computeCoreness() {
	Layout<Vertex, Edge> layout = new ARF2Layout<Vertex, Edge>(network,
			true, Integer.MAX_VALUE);
	kcoreWeightedLayout = new WeightedKCoreLayout<Vertex, Edge>(
			layout.getGraph(), layout, 1, 1);
	computedCoreness = kcoreWeightedLayout.getCoreness();
}
 
開發者ID:dev-cuttlefish,項目名稱:cuttlefish,代碼行數:8,代碼來源:TestWeightedKCore.java

示例13: ObservableLayout

import edu.uci.ics.jung.algorithms.layout.Layout; //導入方法依賴的package包/類
/**
 * Creates a new instance based on the provided {@code delegate}.
 */
public ObservableLayout(Layout<V, E> delegate) {
    super(delegate);

    if (!(delegate.getGraph() instanceof ObservableUpdatableGraph)) {
        throw new IllegalArgumentException("layouts graph has to be an obersable implementation");
    }

    this.observableGraph = (ObservableUpdatableGraph<V, E>) delegate.getGraph();

}
 
開發者ID:truffle-hog,項目名稱:truffle-hog,代碼行數:14,代碼來源:ObservableLayout.java

示例14: handlePopup

import edu.uci.ics.jung.algorithms.layout.Layout; //導入方法依賴的package包/類
/**
 * Reduced functionality of super class method and extended by own
 * content-aware editing.
 */
@SuppressWarnings("unchecked")
@Override
protected final void handlePopup(final MouseEvent e) {
    if (checkModifiers(e)) {
        final LV vv = (LV) e.getSource();
        final Layout<V, E> layout = vv.getGraphLayout();
        final L graph = (L) layout.getGraph();
        final Point p = e.getPoint();

        final List<V> sel_vertices = getSelectedVertices();
        final List<E> sel_edges = getSelectedEdges();

        GraphElementAccessor<V, E> pickSupport = vv.getPickSupport();
        if (pickSupport != null) {
            V vertex = pickSupport.getVertex(layout, p.getX(), p.getY());
            E edge = pickSupport.getEdge(layout, p.getX(), p.getY());

            if (vertex != null && !sel_vertices.contains(vertex))
                sel_vertices.add(vertex);
            if (edge != null && !sel_edges.contains(edge))
                sel_edges.add(edge);
        }

        popup.removeAll();
        if (sel_vertices.size() > 0)
            createVertexMenuEntries(p, graph, vv, sel_vertices);
        else if (sel_edges.size() > 0)
            createEdgeMenuEntries(p, graph, vv, sel_edges);
        else
            createGeneralMenuEntries(p, graph, vv);

        if (popup.getComponentCount() > 0)
            popup.show(vv, e.getX(), e.getY());
    }
}
 
開發者ID:liruixpc11,項目名稱:crucian,代碼行數:40,代碼來源:AbstractPopupMousePlugin.java

示例15: mousePressed

import edu.uci.ics.jung.algorithms.layout.Layout; //導入方法依賴的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


注:本文中的edu.uci.ics.jung.algorithms.layout.Layout.getGraph方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。