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


Java Layout類代碼示例

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


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

示例1: getServer

import edu.uci.ics.jung.algorithms.layout.Layout; //導入依賴的package包/類
/**
 * @param args the command line arguments
 * @return
 */
public VisualizationImageServer<Integer, String> getServer() {
    // Layout<V, E>, VisualizationComponent<V,E>
    Layout<Integer, String> layout = new CircleLayout<>(
            this);
    layout.setSize(new Dimension(300, 300));
    VisualizationImageServer<Integer, String> vv = new VisualizationImageServer<>(
            layout, new Dimension(350, 350));
    // Setup up a new vertex to paint transformer...
    // Set up a new stroke Transformer for the edges
    float dash[] = {10.0f};
    final Stroke edgeStroke = new BasicStroke(1.0f,
            BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dash,
            0.0f);
    vv.getRenderContext().setVertexFillPaintTransformer(i -> Color.GREEN);
    vv.getRenderContext().setEdgeStrokeTransformer(
            s -> edgeStroke);
    vv.getRenderContext().setVertexLabelTransformer(
            new ToStringLabeller());
    vv.getRenderContext().setEdgeLabelTransformer(
            new ToStringLabeller());
    vv.getRenderer().getVertexLabelRenderer()
            .setPosition(Position.CNTR);

    return vv;
}
 
開發者ID:mstahv,項目名稱:svgexamples,代碼行數:30,代碼來源:JungExample.java

示例2: 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

示例3: setPrototypePreview

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

示例4: centerVisualization

import edu.uci.ics.jung.algorithms.layout.Layout; //導入依賴的package包/類
public void centerVisualization(V vertex, final boolean immediate) {
    if (vertex != null) {
        Layout<V,E> layout = this.getGraphLayout();
        Point2D q = layout.transform(vertex);
        Point2D lvc = this.getRenderContext().getMultiLayerTransformer().inverseTransform(this.getCenter());
        final int steps = (immediate ? 1 : 10);
        final double dx = (lvc.getX() - q.getX()) / steps;
        final double dy = (lvc.getY() - q.getY()) / steps;

        new Thread() {
            public void run() {
                MutableTransformer transformer = GraphVisualizationPanel.this.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT); 
                for (int i = 0; i < steps; i++) {
                    transformer.translate(dx, dy);
                    try {
                        Thread.sleep(100);
                    } catch (InterruptedException ex) {
                    }
                }
            }
        }.start();
    }
}
 
開發者ID:s-store,項目名稱:sstore-soft,代碼行數:24,代碼來源:GraphVisualizationPanel.java

示例5: pickContainedVertices

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

示例6: transform

import edu.uci.ics.jung.algorithms.layout.Layout; //導入依賴的package包/類
public Paint transform( Exit exit ) {
    Layout<Room, Exit> layout = vv.getGraphLayout();
    Pair<Room> pair = layout.getGraph().getEndpoints( exit );
    Room begin = pair.getFirst();
    Room end = pair.getSecond();
    Point2D beginPoint = transformer.transform( layout.transform( begin ) );
    Point2D endPoint = transformer.transform( layout.transform( end ) );
    float xFirst = (float) beginPoint.getX();
    float yFirst = (float) beginPoint.getY();
    float xEnd = (float) endPoint.getX();
    float yEnd = (float) endPoint.getY();

    if (selfLoop.evaluate( Context.<Graph<Room, Exit>, Exit>getInstance( layout.getGraph(), exit ) )) {
        xEnd += 50;
        yEnd += 50;
    }

    return new GradientPaint( xFirst, yFirst, getColorFor( begin ), xEnd, yEnd, getColorFor( end ), true );
}
 
開發者ID:lauriholmas,項目名稱:batmapper,代碼行數:20,代碼來源:ExitPaintTransformer.java

示例7: paintVertex

import edu.uci.ics.jung.algorithms.layout.Layout; //導入依賴的package包/類
/**
 * Paint vertex <code>v</code> on <code>g</code> at <code>(x,y)</code>.
 *
 * @param rc
 * @param v
 * @param layout
 */
protected void paintVertex(
        RenderContext<ViwnNode, ViwnEdge> rc,
        ViwnNode v,
        Layout<ViwnNode, ViwnEdge> layout) {
    Point2D p = layout.transform(v);
    p = rc.getMultiLayerTransformer().transform(Layer.LAYOUT, p);

    if (v instanceof ViwnNodeSet) {
        delegate.paintVertex(rc, layout, v);
        renderSet(rc, p, (ViwnNodeSet) v);
    } else if (v instanceof ViwnNodeSynset) {
        renderSynset(rc, p, (ViwnNodeSynset) v, layout);
    } else if (v instanceof ViwnNodeWord) {
        delegate.paintVertex(rc, layout, v);
        renderWord(rc, p, (ViwnNodeWord) v);
    }
}
 
開發者ID:CLARIN-PL,項目名稱:WordnetLoom,代碼行數:25,代碼來源:ViwnVertexRenderer.java

示例8: saveAsCxf

import edu.uci.ics.jung.algorithms.layout.Layout; //導入依賴的package包/類
public String saveAsCxf(BrowsableNetwork network,
		Layout<Vertex, Edge> layout) throws IOException {
	File saveTo = new File("random_network.cxf");
	String fname = saveTo.getCanonicalPath();

	if (saveTo.exists())
		saveTo.delete();
	try {
		saveTo.createNewFile();
	} catch (IOException e1) {
		e1.printStackTrace();
	}
	CxfSaver saver = new CxfSaver(network, layout);
	saver.save(saveTo);

	return fname;
}
 
開發者ID:dev-cuttlefish,項目名稱:cuttlefish,代碼行數:18,代碼來源:RandomNetworkGenerator.java

示例9: LayoutPopup

import edu.uci.ics.jung.algorithms.layout.Layout; //導入依賴的package包/類
/**
 * Constructor for LayoutPopup.
 *
 * @param name String
 * @param ps IPlaySheet
 */
public LayoutPopup( String name, GraphPlaySheet ps, Collection<SEMOSSVertex> verts ) {
	super( name );

	DirectedGraph<SEMOSSVertex, SEMOSSEdge> viz = ps.getVisibleGraph();
	boolean forestok = ( viz instanceof Forest || !verts.isEmpty() );

	for ( Class<? extends Layout> layout : LAYOUTS ) {
		LayoutMenuItem mi = new LayoutMenuItem( layout, ps, verts );
		add( mi );

		if ( TREELAYOUTS.contains( layout ) ) {
			mi.setEnabled( forestok );
		}
	}
}
 
開發者ID:Ostrich-Emulators,項目名稱:semtool,代碼行數:22,代碼來源:LayoutPopup.java

示例10: labelVertex

import edu.uci.ics.jung.algorithms.layout.Layout; //導入依賴的package包/類
@Override
public void labelVertex(RenderContext<GUINode, GUILink> rc, Layout<GUINode, GUILink> layout, GUINode v, String label)
{
    if (!callback.getVisualizationState().isVisibleInCanvas(v)) return;
    if (callback.getVisualizationState().isCanvasShowNodeNames() && v.getLayer().isDefaultLayer())
    {
        Point2D vertexPositionInPixels = layout.transform(v);
        vertexPositionInPixels = rc.getMultiLayerTransformer().transform(Layer.LAYOUT, vertexPositionInPixels);
        final Component component = prepareRenderer(rc, rc.getVertexLabelRenderer(), "<html><font color='black'>" + v.getLabel() + "</font></html>", rc.getPickedVertexState().isPicked(v), v);
        final GraphicsDecorator g = rc.getGraphicsContext();
        final Dimension dimensionMessage = component.getPreferredSize();
        final Icon vertexIcon = v.getIcon();
        final Rectangle2D boundsVertex = new Rectangle2D.Double(vertexPositionInPixels.getX() - vertexIcon.getIconWidth() / 2, vertexPositionInPixels.getY() - vertexIcon.getIconHeight() / 2, vertexIcon.getIconWidth(), vertexIcon.getIconHeight());
        final Point anchorPointInPixels = getAnchorPoint(boundsVertex, dimensionMessage, Renderer.VertexLabel.Position.NE);
        g.draw(component, rc.getRendererPane(), anchorPointInPixels.x, anchorPointInPixels.y, dimensionMessage.width, dimensionMessage.height, true);
    }
}
 
開發者ID:girtel,項目名稱:Net2Plan,代碼行數:18,代碼來源:JUNGCanvas.java

示例11: groupCluster

import edu.uci.ics.jung.algorithms.layout.Layout; //導入依賴的package包/類
private void groupCluster(AggregateLayout<Number,Number> layout, Set<Number> vertices) {
	if(vertices.size() < layout.getGraph().getVertexCount()) {
		Point2D center = layout.transform(vertices.iterator().next());
		Graph<Number,Number> subGraph = SparseMultigraph.<Number,Number>getFactory().create();
		for(Number v : vertices) {
			subGraph.addVertex(v);
		}
		Layout<Number,Number> subLayout = 
			new CircleLayout<Number,Number>(subGraph);
		subLayout.setInitializer(vv.getGraphLayout());
		subLayout.setSize(new Dimension(40,40));

		layout.put(subLayout,center);
		vv.repaint();
	}
}
 
開發者ID:marcvanzee,項目名稱:mdp-plan-revision,代碼行數:17,代碼來源:ClusteringDemo.java

示例12: paintVertex

import edu.uci.ics.jung.algorithms.layout.Layout; //導入依賴的package包/類
@Override public void paintVertex(RenderContext<String, String> rc,
    Layout<String, String> layout, String vertex) {
  GraphicsDecorator graphicsContext = rc.getGraphicsContext();
  Point2D center = layout.transform(vertex);
  Shape shape = null;
  Color color = null;
  if(vertex.equals("Square")) {
    shape = new Rectangle((int)center.getX()-10, (int)center.getY()-10, 20, 20);
    color = new Color(127, 127, 0);
  } else if(vertex.equals("Rectangle")) {
    shape = new Rectangle((int)center.getX()-10, (int)center.getY()-20, 20, 40);
    color = new Color(127, 0, 127);
  } else if(vertex.equals("Circle")) {
    shape = new Ellipse2D.Double(center.getX()-10, center.getY()-10, 20, 20);
    color = new Color(0, 127, 127);
  }
  graphicsContext.setPaint(color);
  graphicsContext.fill(shape);
}
 
開發者ID:marcvanzee,項目名稱:mdp-plan-revision,代碼行數:20,代碼來源:VertexShapes.java

示例13: buildJungLayout

import edu.uci.ics.jung.algorithms.layout.Layout; //導入依賴的package包/類
@Override
protected Layout<GraphNode,GraphEdge> buildJungLayout(
        DirectedGraph<GraphNode, GraphEdge> jungGraph,
        Dimension layoutSize) {
  SpringLayout<GraphNode, GraphEdge> result =
          new SpringLayout<GraphNode, GraphEdge>(jungGraph);
  result.setSize(layoutSize);
  if (force.isSet()) {
    result.setForceMultiplier(force.getValue());
  }
  if (range.isSet()) {
    result.setRepulsionRange(range.getValue());
  }
  if (stretch.isSet()) {
    result.setStretch(stretch.getValue());
  }
  return result;
}
 
開發者ID:google,項目名稱:depan,代碼行數:19,代碼來源:JungLayoutPlan.java

示例14: visualizeGraphAndDumpToFile

import edu.uci.ics.jung.algorithms.layout.Layout; //導入依賴的package包/類
void visualizeGraphAndDumpToFile(String fileName){
	Layout<Integer,Integer> l = new KKLayout<Integer,Integer>( assocG);
	VisualizationImageServer<Integer, Integer> vis =
		    new VisualizationImageServer<Integer, Integer>(l, new Dimension(1200,1200));
	vis.setBackground(Color.WHITE);
	
	// Create the buffered image
	BufferedImage image = (BufferedImage) vis.getImage (
	    new Point2D.Double(l.getSize().getWidth() / 2,
	    l.getSize().getHeight() / 2),
	    new Dimension(l.getSize()));

	// Write image to a png file
	File outputfile = new File(fileName);

	try {
	    ImageIO.write(image, "png", outputfile);
	
	} catch (IOException e) {
	    // Exception handling
		e.printStackTrace();
		System.exit(1);
	}

}
 
開發者ID:sriram0339,項目名稱:FixrAssociationRuleMining,代碼行數:26,代碼來源:AssociationRuleGraph.java

示例15: main

import edu.uci.ics.jung.algorithms.layout.Layout; //導入依賴的package包/類
public static void main(String [] args) {
	ProcletModel pmodel = new ProcletModel("visit");
	pmodel.buildFromDB();
	pmodel.persistProcletModel();
	ProcletBlock block1 = new ProcletBlock("b1",BlockType.PI,false,5);
	ProcletBlock block2 = new ProcletBlock("b2",BlockType.PI,false,5);
	pmodel.addBlock(block1);
	pmodel.addBlock(block2);
	ProcletPort port = new ProcletPort("p1",Direction.OUT,Signature.ONE,Signature.ONE);
	ProcletPort port2 = new ProcletPort("p2",Direction.OUT,Signature.ONE,Signature.ONE);
	pmodel.addProcletPort(port, block1);
	pmodel.addProcletPort(port2, block1);
	pmodel.getBlocks();
	pmodel.getPortsBlock(block1);
	// visualization
	Layout layout = new CircleLayout(pmodel);
	layout.setSize(new Dimension(300,300));
	BasicVisualizationServer vv = new BasicVisualizationServer(layout);
	vv.setPreferredSize(new Dimension(350,350));
	
	JFrame frame = new JFrame("simple");
	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	frame.getContentPane().add(vv);
	frame.pack();
	frame.setVisible(true);
}
 
開發者ID:yawlfoundation,項目名稱:yawl,代碼行數:27,代碼來源:ProcletModel.java


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