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


Java GraphZoomScrollPane类代码示例

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


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

示例1: GraphicalQueryPanel

import edu.uci.ics.jung.visualization.GraphZoomScrollPane; //导入依赖的package包/类
/**
 * Creates new form GraphicalQueryBuilderPanel
 *
 * @param progressname the progress bar name to update
 * @param csfac the graph color shape factory to use
 */
public GraphicalQueryPanel( String progressname, GraphColorShapeRepository csfac ) {
	progress = progressname;
	this.csfac = csfac;
	initComponents();
	initVizualizer();
	visarea.add( new GraphZoomScrollPane( view ) );

	addConceptNodeAction = new AbstractAction() {
		private static final long serialVersionUID = -2138227128423655724L;

		@Override
		public void actionPerformed( ActionEvent e ) {
			URI concept = new URIImpl( e.getActionCommand() );
			vfac.setType( concept );
		}
	};

	addGraphListener();
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:26,代码来源:GraphicalQueryPanel.java

示例2: setUpView

import edu.uci.ics.jung.visualization.GraphZoomScrollPane; //导入依赖的package包/类
private void setUpView(Graph graph)
    {                 
//        layout = new SpringLayout2(graph);
        layout = new KKLayout(graph);
        //layout.setSize(new Dimension(700,700));
        vv = new VisualizationViewer(layout);
        vv.setPreferredSize(new Dimension(900,900));
        vv.setBackground( Color.white );
        // Tell the renderer to use our own customized label rendering
        vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());
        vv.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller());
        vv.getRenderer().getVertexLabelRenderer().setPosition(Position.CNTR);
        getContentPane().add(new GraphZoomScrollPane(vv), BorderLayout.CENTER);

        /*Mouse controller plugins*/
        PluggableGraphMouse gm = new PluggableGraphMouse();
        gm.add(new TranslatingGraphMousePlugin(MouseEvent.BUTTON3_MASK));
        gm.add(new ScalingGraphMousePlugin(new CrossoverScalingControl(), 0, 1.1f, 0.9f));
        gm.add(new PickingGraphMousePlugin());
        vv.setGraphMouse(gm);
    }
 
开发者ID:sinantie,项目名称:Generator,代码行数:22,代码来源:VisualiseHypergraph.java

示例3: writeToImageFile

import edu.uci.ics.jung.visualization.GraphZoomScrollPane; //导入依赖的package包/类
public void writeToImageFile(String imageFileName) throws AWTException {

        final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv);
        PersistentLayout pl = (PersistentLayout) vv.getGraphLayout();
        int height = pl.getSize().height;
        int width = pl.getSize().width;
        panel.setSize(width, height);
        BufferedImage bufImage = ScreenImage.createImage(panel);
        panel.setVisible(false);
        try {
            File outFile = new File(imageFileName);
            ImageIO.write(bufImage, "png", outFile);
            System.out.println("wrote image to " + imageFileName);
        } catch (Exception e) {
            System.out.println("writeToImageFile(): " + e.getMessage());
        }
    }
 
开发者ID:iTransformers,项目名称:netTransformer,代码行数:18,代码来源:GraphViewerPanel.java

示例4: initializeComponents

import edu.uci.ics.jung.visualization.GraphZoomScrollPane; //导入依赖的package包/类
private void initializeComponents() {
	// Graphを作成する
	Graph<V, E> graph = new SparseGraph<V, E>();

	// Layoutを作成する
	layout = new KCircleLayout<V, E>(graph);
	layout.setSize(INITIAL_SIZE);

	// Viewerを作成する
	viewer = new KVisualizationViewer<V, E>(layout, INITIAL_SIZE);
	viewer.setDoubleBuffered(false);
	viewer.setBackground(Color.WHITE);
	this.mouseHandler = new KNetworkMouseHandler<V, E>(viewer);
	viewer.setGraphMouse(mouseHandler);

	// Viewerを乗せる
	this.setLayout(new BorderLayout());
	GraphZoomScrollPane scroll = new GraphZoomScrollPane(viewer);
	this.add(scroll, BorderLayout.CENTER);
	//this.add(viewer, BorderLayout.CENTER);
}
 
开发者ID:macc704,项目名称:KBDeX,代码行数:22,代码来源:KNetworkPanel.java

示例5: GraphPreviewPanel

import edu.uci.ics.jung.visualization.GraphZoomScrollPane; //导入依赖的package包/类
/**
 * create an instance of a simple graph with controls to demo the zoom features.
 *
 * @param peopleList
 *            the people list
 * @param links
 *            the links
 * @throws UNISoNException
 *             the UNI so n exception
 */
public GraphPreviewPanel(final LinkedList<String> peopleList, final List<Relationship> links)
        throws UNISoNException {
	// create a simple graph for the demo
	this.graph = new DirectedSparseGraph();
	final Vertex[] v = this.createEdges(links, peopleList);

	final PluggableRenderer pr = new PluggableRenderer();
	pr.setVertexStringer(new UnicodeVertexStringer(v, peopleList));
	pr.setVertexPaintFunction(
	        new PickableVertexPaintFunction(pr, Color.lightGray, Color.white, Color.yellow));
	pr.setGraphLabelRenderer(new DefaultGraphLabelRenderer(Color.cyan, Color.cyan));
	final VertexIconAndShapeFunction dvisf = new VertexIconAndShapeFunction(
	        new EllipseVertexShapeFunction());
	pr.setVertexShapeFunction(dvisf);
	pr.setVertexIconFunction(dvisf);
	this.vv = new VisualizationViewer(new FRLayout(this.graph), pr);
	this.vv.setPickSupport(new ShapePickSupport());
	pr.setEdgeShapeFunction(new EdgeShape.QuadCurve());
	this.vv.setBackground(Color.white);

	// add my listener for ToolTips
	this.vv.setToolTipFunction(new DefaultToolTipFunction());

	// create a frome to hold the graph
	final GraphZoomScrollPane panel = new GraphZoomScrollPane(this.vv);
	this.add(panel);
	// this.add(vv);
	final ModalGraphMouse gm = new DefaultModalGraphMouse();
	this.vv.setGraphMouse(gm);

	// showLabels = true;
}
 
开发者ID:leonarduk,项目名称:unison,代码行数:43,代码来源:GraphPreviewPanel.java

示例6: setVisualizationViewer

import edu.uci.ics.jung.visualization.GraphZoomScrollPane; //导入依赖的package包/类
private void setVisualizationViewer (VisualizationViewer vviewer) {
		PortConnections pconns = PortConnections.getInstance();
		// give other color
		  Transformer vertexPaint = new Transformer() {
			  public Paint transform (Object obj) {
				  if (obj instanceof ProcletBlock) {
					  if (((ProcletBlock) obj).getBlockID().equals("exception")) {
						return Color.BLUE;  
					  }
					  else {
						  return Color.RED;
					  }
				  }
				  else if (obj instanceof ProcletPort) {
					  return Color.GREEN;  
				  }
				  return Color.RED;
			  }
		  };
		  this.vertexPaint = vertexPaint;
		vv = vviewer;
		//vv.setPickSupport(new edu.uci.ics.jung.visualization.picking.ShapePickSupport(vv));
		vv.setPreferredSize(new Dimension(350,350));
		vv.getRenderContext().setVertexFillPaintTransformer(this.vertexPaint);
		vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());
		vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line());
		vv.setGraphMouse(gm);
		splitPanelLeft.setRightComponent(new GraphZoomScrollPane(vv));
//		vv.validate();
//		vv.repaint();
//		splitPanelLeft.repaint();
//		getContentPane().repaint();
//		validate();
//		repaint();
	}
 
开发者ID:yawlfoundation,项目名称:yawl,代码行数:36,代码来源:FrmPConns.java

示例7: setVisualizationViewer

import edu.uci.ics.jung.visualization.GraphZoomScrollPane; //导入依赖的package包/类
private void setVisualizationViewer (VisualizationViewer vviewer) {
	if (vviewer != null) {
		vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint);
		vv = vviewer;
		//vv.setPickSupport(new edu.uci.ics.jung.visualization.picking.ShapePickSupport(vv));
		vv.setPreferredSize(new Dimension(350,350));
		vv.getRenderContext().setVertexLabelTransformer(vertexLabelTransformer);
		vv.getRenderContext().setEdgeStrokeTransformer(edgeStrokeTransformer);
		vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line());
		vv.setGraphMouse(gm);
		splitPanelLeft.setRightComponent(new GraphZoomScrollPane(vv));
	}
}
 
开发者ID:yawlfoundation,项目名称:yawl,代码行数:14,代码来源:FrmModel.java

示例8: setVisualizationViewer

import edu.uci.ics.jung.visualization.GraphZoomScrollPane; //导入依赖的package包/类
private void setVisualizationViewer (VisualizationViewer vviewer) {
//			vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint);
			vv = vviewer;
			//vv.setPickSupport(new edu.uci.ics.jung.visualization.picking.ShapePickSupport(vv));
			vv.setPreferredSize(new Dimension(350,350));
//			vv.getRenderContext().setVertexLabelTransformer(vertexLabelTransformer);
			vv.setGraphMouse(gm);
			vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());
			splitPanelLeft.setRightComponent(new GraphZoomScrollPane(vv));
		}
 
开发者ID:yawlfoundation,项目名称:yawl,代码行数:11,代码来源:FrmGraph.java

示例9: initGraph

import edu.uci.ics.jung.visualization.GraphZoomScrollPane; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private void initGraph() {
	try {
		labelMap = new HashMap();
		iconMap = new HashMap();
		graph = new DelegateForest();
		treeLayout = new TreeLayout(graph);
		balloonLayout = new BalloonLayout(graph);
		vv = new VisualizationViewer(balloonLayout);
		vv.setSize(new Dimension(800, 800));
		refreshGraph();
		vv.setBackground(Color.white);
		vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line());
		vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());
		vv.setVertexToolTipTransformer(new EntityTransformer());
		graphPanel = new GraphZoomScrollPane(vv);
		DefaultModalGraphMouse mouse = new DefaultModalGraphMouse();
		vv.setGraphMouse(mouse);
		mouse.add(new MemoriaGraphMouse(this));
		// T O D O  MemoriaPanel compile error suppress 2 lines
		//VertexStringerImpl localVertexStringerImpl = new VertexStringerImpl(/*this.labelMap*/);
		//this.vv.getRenderContext().setVertexLabelTransformer(new VertexStringerImpl(/*localVertexStringerImpl*/));
		VertexIconShapeTransformer transformer = new VertexIconShapeTransformer(new EllipseVertexShapeTransformer());
		DefaultVertexIconTransformer iconTransformer = new DefaultVertexIconTransformer();
		transformer.setIconMap(iconMap);
		iconTransformer.setIconMap(iconMap);
		vv.getRenderContext().setVertexShapeTransformer(transformer);
		vv.getRenderContext().setVertexIconTransformer(iconTransformer);
	} catch (Exception exc) {
		SbApp.error("MemoriaPanel.initGraph()",exc);
	}
}
 
开发者ID:markkohdev,项目名称:oStorybook,代码行数:33,代码来源:MemoriaPanel.java

示例10: zoomToWindow

import edu.uci.ics.jung.visualization.GraphZoomScrollPane; //导入依赖的package包/类
public void zoomToWindow(VisualizationViewer<VisualNode, VisualEdge> currentViewer, JTabbedPane jtp){
	final VisualizationViewer<VisualNode, VisualEdge> activeViewer;
	activeViewer = currentViewer;
	Shape r = activeViewer.getBounds();
	Point2D vvcenter = activeViewer.getCenter();
	for (VisualNode jungNode: activeViewer.getGraphLayout().getGraph().getVertices()) {
		if (jungNode.getVisible()) {
			Point2D p = activeViewer.getRenderContext().getMultiLayerTransformer().transform(activeViewer.getGraphLayout().transform(jungNode));
			while (!r.contains(p)) 
				{
				scaler.scale(activeViewer, 1 / 1.1f, vvcenter);
				p = activeViewer.getRenderContext().getMultiLayerTransformer().transform(activeViewer.getGraphLayout().transform(jungNode));
				try {
					Thread.sleep(20);
				} catch (InterruptedException ex) {
				}
			}
		}
	}
	if(jtp==null)
	{
		summaryGraphSourceTabbedPane.setComponentAt(0, new GraphZoomScrollPane(this.getActiveViewer()));
		sourceTabbedPane.setComponentAt(0, new GraphZoomScrollPane(this.getActiveViewerZOOM()));
	}
	else
	{
		jtp.setComponentAt(getActiveTab(jtp),new GraphZoomScrollPane(activeViewer));
	}
}
 
开发者ID:pmanousis,项目名称:Hecataeus,代码行数:30,代码来源:HecataeusViewer.java

示例11: zoomToModuleTab

import edu.uci.ics.jung.visualization.GraphZoomScrollPane; //导入依赖的package包/类
protected void zoomToModuleTab(List<VisualNode> subNodes, VisualGraph sub, String name){	
	this.graphs.add(sub);
	subLayout = new VisualAggregateLayout(sub, VisualLayoutType.ZoomedLayoutForModules, VisualLayoutType.ZoomedLayoutForModules);
	vv1 = VisualizationViewer.SetViewers(subLayout, this);
	GraphZoomScrollPane myPane = new GraphZoomScrollPane(vv1);
	vv1.setGraphLayout(subLayout);
	vv1.setName(name);
	viewers.add(vv1);
	tabbedPane.addTab(name, null, myPane, name);
	countOpenTabs++;		
	tabbedPane.setSelectedIndex(countOpenTabs);
	tabbedPane.setTabComponentAt(countOpenTabs,new HecataeusButtonTabComponent(tabbedPane));
	vv1.repaint();
	this.zoomToWindow(vv1,tabbedPane);
}
 
开发者ID:pmanousis,项目名称:Hecataeus,代码行数:16,代码来源:HecataeusViewer.java

示例12: JungGraphViewer

import edu.uci.ics.jung.visualization.GraphZoomScrollPane; //导入依赖的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

示例13: startFunction

import edu.uci.ics.jung.visualization.GraphZoomScrollPane; //导入依赖的package包/类
public JPanel startFunction() {
    Graph g = getGraph();
    
    pr = new PluggableRenderer();
    Layout layout = new FRLayout(g);
    vv = new VisualizationViewer(layout, pr);
    // add Shape based pick support
    vv.setPickSupport(new ShapePickSupport());
    PickedState picked_state = vv.getPickedState();
    
    affineTransformer = vv.getLayoutTransformer();
    
    // create decorators
    vcf = new SeedColor(picked_state);
    ewcs = 
        new EdgeWeightStrokeFunction(edge_weight);
    vsh = new VertexStrokeHighlight(picked_state);
    ff = new FontHandler();
    vs_none = new ConstantVertexStringer(null);
    es_none = new ConstantEdgeStringer(null);
    vssa = new VertexShapeSizeAspect(voltages);
    show_edge = new DirectionDisplayPredicate(true, true);
    show_arrow = new DirectionDisplayPredicate(true, false);
    show_vertex = new VertexDisplayPredicate(false);

    // uses a gradient edge if unpicked, otherwise uses picked selection
    edgePaint = new GradientPickedEdgePaintFunction( new PickableEdgePaintFunction(picked_state,Color.black,Color.cyan), 
            vv, vv, picked_state);
    
    pr.setVertexPaintFunction(vcf);
    pr.setVertexStrokeFunction(vsh);
    pr.setVertexStringer(vs_none);
    pr.setVertexFontFunction(ff);
    pr.setVertexShapeFunction(vssa);
    pr.setVertexIncludePredicate(show_vertex);
    
    pr.setEdgePaintFunction( edgePaint );
    pr.setEdgeStringer(es_none);
    pr.setEdgeFontFunction(ff);
    pr.setEdgeStrokeFunction(ewcs);
    pr.setEdgeIncludePredicate(show_edge);
    pr.setEdgeShapeFunction(new EdgeShape.Line());
    pr.setEdgeArrowPredicate(show_arrow);
    JPanel jp = new JPanel();
    jp.setLayout(new BorderLayout());
    
    vv.setBackground(Color.white);
    GraphZoomScrollPane scrollPane = new GraphZoomScrollPane(vv);
    jp.add(scrollPane);
    gm = new DefaultModalGraphMouse();
    vv.setGraphMouse(gm);
    gm.add(new PopupGraphMousePlugin());

    addBottomControls( jp );
    vssa.setScaling(true);

    vv.setToolTipFunction(new VoltageTips());
    vv.setToolTipText("<html><center>Use the mouse wheel to zoom<p>Click and Drag the mouse to pan<p>Shift-click and Drag to Rotate</center></html>");
    

    
    return jp;
}
 
开发者ID:dev-cuttlefish,项目名称:cuttlefish,代码行数:64,代码来源:PluggableRendererDemo.java

示例14: startFunction

import edu.uci.ics.jung.visualization.GraphZoomScrollPane; //导入依赖的package包/类
public JPanel startFunction() {
        Graph<Integer,Number> g = getGraph();
        
        Layout<Integer,Number> layout = new FRLayout<Integer,Number>(g);
//        layout.setSize(new Dimension(5000,5000));
        vv = new VisualizationViewer<Integer,Number>(layout);

        PickedState<Integer> picked_state = vv.getPickedVertexState();

//        affineTransformer = vv.getLayoutTransformer();
        self_loop = new SelfLoopEdgePredicate<Integer,Number>();
        // create decorators
        seedFillColor = new SeedFillColor<Integer>(picked_state);
        seedDrawColor = new SeedDrawColor<Integer>(picked_state);
        ewcs = 
            new EdgeWeightStrokeFunction<Number>(edge_weight);
        vsh = new VertexStrokeHighlight<Integer,Number>(g, picked_state);
        vff = new VertexFontTransformer<Integer>();
        eff = new EdgeFontTransformer<Number>();
        vs_none = new ConstantTransformer(null);
        es_none = new ConstantTransformer(null);
        vssa = new VertexShapeSizeAspect<Integer,Number>(g, voltages);
        show_edge = new DirectionDisplayPredicate<Integer,Number>(true, true);
        show_arrow = new DirectionDisplayPredicate<Integer,Number>(true, false);
        show_vertex = new VertexDisplayPredicate<Integer,Number>(false);

        // uses a gradient edge if unpicked, otherwise uses picked selection
        edgeDrawPaint = 
            new GradientPickedEdgePaintFunction<Integer,Number>(
                    new PickableEdgePaintTransformer<Number>(
                            vv.getPickedEdgeState(),Color.black,Color.cyan), vv);
        edgeFillPaint = 
            new GradientPickedEdgePaintFunction<Integer,Number>(
                    new PickableEdgePaintTransformer<Number>(
                            vv.getPickedEdgeState(),Color.black,Color.cyan), vv);
        
        vv.getRenderContext().setVertexFillPaintTransformer(seedFillColor);
        vv.getRenderContext().setVertexDrawPaintTransformer(seedDrawColor);
        vv.getRenderContext().setVertexStrokeTransformer(vsh);
        vv.getRenderContext().setVertexLabelTransformer(vs_none);
        vv.getRenderContext().setVertexFontTransformer(vff);
        vv.getRenderContext().setVertexShapeTransformer(vssa);
        vv.getRenderContext().setVertexIncludePredicate(show_vertex);
        
        vv.getRenderContext().setEdgeDrawPaintTransformer( edgeDrawPaint );
        vv.getRenderContext().setEdgeLabelTransformer(es_none);
        vv.getRenderContext().setEdgeFontTransformer(eff);
        vv.getRenderContext().setEdgeStrokeTransformer(ewcs);
        vv.getRenderContext().setEdgeIncludePredicate(show_edge);
        vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line<Integer,Number>());
        vv.getRenderContext().setEdgeArrowPredicate(show_arrow);
        
        vv.getRenderContext().setArrowFillPaintTransformer(new ConstantTransformer(Color.lightGray));
        vv.getRenderContext().setArrowDrawPaintTransformer(new ConstantTransformer(Color.black));
        JPanel jp = new JPanel();
        jp.setLayout(new BorderLayout());
        
        vv.setBackground(Color.white);
        GraphZoomScrollPane scrollPane = new GraphZoomScrollPane(vv);
        jp.add(scrollPane);
        gm = new DefaultModalGraphMouse<Integer, Number>();
        vv.setGraphMouse(gm);
        gm.add(new PopupGraphMousePlugin());

        addBottomControls( jp );
        vssa.setScaling(true);

        vv.setVertexToolTipTransformer(new VoltageTips<Number>());
        vv.setToolTipText("<html><center>Use the mouse wheel to zoom<p>Click and Drag the mouse to pan<p>Shift-click and Drag to Rotate</center></html>");
        

        
        return jp;
    }
 
开发者ID:marcvanzee,项目名称:mdp-plan-revision,代码行数:75,代码来源:PluggableRendererDemo.java

示例15: InitiateGraph

import edu.uci.ics.jung.visualization.GraphZoomScrollPane; //导入依赖的package包/类
public void InitiateGraph(Character[] cs, Template[] templates, Color[] colors, String[] picture_keys,
                          String[] extra_keys) {

    Map<CharacterNode, Icon> iconMap = new HashMap<CharacterNode, Icon>();

    characters = new CharacterNode[cs.length];
    for (int x = 0; x < cs.length; x++) {

        characters[x] = new CharacterNode(cs[x]);

        for (int y = 0; y < templates.length; y++) {

            if (cs[x].templateIdentifier.equals(templates[y].GetTemplateID())) {

                characters[x].color = colors[y];
                characters[x].extra_key = extra_keys[y];

                ImageIcon img = XEED.RescaleImageIcon((ImageIcon) cs[x].imgData.get(picture_keys[y]), ImageMaxSize,
                        ImageMaxSize);

                if (img != null) {
                    iconMap.put(characters[x], new LayeredIcon(img.getImage()));
                }

            }

        }
    }

    // creates the graph
    graph = new DelegateForest<CharacterNode, Integer>();

    //Loads the tree data
    createTree();

    //Sets up the transformer that paints the node.
    Transformer<CharacterNode, Paint> vertexPaint = new Transformer<CharacterNode, Paint>() {

        @Override
        public Paint transform(CharacterNode cn) {
            ;
            return cn.color;
        }
    };

    final DefaultVertexIconTransformer<CharacterNode> vertexIconFunction = new DefaultVertexIconTransformer<CharacterNode>();
    vertexIconFunction.setIconMap(iconMap);

    final VertexIconShapeTransformer<CharacterNode> vertexImageShapeFunction = new VertexIconShapeTransformer<CharacterNode>(
            new EllipseVertexShapeTransformer<CharacterNode>());
    vertexImageShapeFunction.setIconMap(iconMap);

    treeLayout = new TreeLayout<CharacterNode, Integer>(graph, TreeLayout.DEFAULT_DISTX * 3);

    //Skriva en anpassad metod för att bestämma platser.
    //använd treeLayout.setLocation();

    vv = new VisualizationViewer<CharacterNode, Integer>(treeLayout);
    vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line());
    vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());
    vv.getRenderContext().setVertexShapeTransformer(vertexImageShapeFunction);
    vv.getRenderContext().setVertexIconTransformer(vertexIconFunction);
    // add a listener for ToolTips
    vv.setVertexToolTipTransformer(new ToStringLabeller());
    vv.getRenderContext().setArrowFillPaintTransformer(new ConstantTransformer(Color.lightGray));
    vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint);
    vv.getRenderer().getVertexLabelRenderer().setPosition(Position.AUTO);

    Container content = this;
    final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv);
    content.add(panel);
    panel.setVisible(true);
    content.validate();

    final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse();
    vv.setGraphMouse(graphMouse);

    graphMouse.setMode(ModalGraphMouse.Mode.TRANSFORMING);

}
 
开发者ID:ErikGartner,项目名称:xeed,代码行数:81,代码来源:GenealogyGraphPanel.java


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