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


Java VisualizationViewer.setPreferredSize方法代码示例

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


在下文中一共展示了VisualizationViewer.setPreferredSize方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: renderElement

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

示例2: setUpView

import edu.uci.ics.jung.visualization.VisualizationViewer; //导入方法依赖的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: showFull

import edu.uci.ics.jung.visualization.VisualizationViewer; //导入方法依赖的package包/类
/**
     * Show the full StateMachine with a special formater.
     * <p/>
     * @param <T>          type of state machine
     * @param stateMachine the statemachine to show
     * @param formater     an optional formater
     */
    public static <T> void showFull(final StateMachine<T> stateMachine, final StateFormater<T> formater) {
        DirectedGraph<State<T>, String> g = new DirectedSparseMultigraph<>();
        int i = 0;
        for (Link<T> link : stateMachine.getLinks()) {
            // TODO: A Graph needs for each transition a unique id. A StateMachine not. So we build it here.
            g.addEdge("[" + (i++) + "] " + link.getTransition().toString(), link.getSource(), link.getDestination());
        }

        FRLayout<State<T>, String> layout = new FRLayout<>(g);
//        layout.setRepulsionMultiplier(2);
//        layout.setMaxIterations(20);
        layout.setSize(new Dimension(1100, 950)); // sets the initial size of the space
        VisualizationViewer<State<T>, String> vv = new VisualizationViewer<>(layout);
        vv.setPreferredSize(new Dimension(1280, 1024)); //Sets the viewing area size

        vv.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller());
        vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());

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

//                final VisualizationModel<String,Number> visualizationModel =
//            new DefaultVisualizationModel<String,Number>(layout, preferredSize);
        // this class will provide both label drawing and vertex shapes
        VertexLabelAsShapeRenderer<State<T>, String> vlasr = new VertexLabelAsShapeRenderer<>(vv.getRenderContext());
//
//        // customize the render context
        if ( formater != null ) {
            vv.getRenderContext().setVertexLabelTransformer((state) -> {
                return formater.toHtml(state);
            });
            vv.setVertexToolTipTransformer((state) -> {
                return formater.toToolTipHtml(state);
            });
        }

        vv.getRenderContext().setVertexShapeTransformer(vlasr);
        vv.getRenderContext().setVertexLabelRenderer(new DefaultVertexLabelRenderer(Color.RED));
        vv.getRenderContext().setEdgeDrawPaintTransformer((input) -> {
            return Color.DARK_GRAY;
        });
        vv.getRenderContext().setEdgeStrokeTransformer((input) -> {
            return new BasicStroke(2.5f);
        });

        // customize the renderer
        vv.getRenderer().setVertexRenderer(new GradientVertexRenderer<State<T>, String>(Color.LIGHT_GRAY, Color.WHITE, true));
        vv.getRenderer().setVertexLabelRenderer(vlasr);
        DefaultModalGraphMouse gm = new DefaultModalGraphMouse();
        gm.setMode(ModalGraphMouse.Mode.TRANSFORMING);
        vv.setGraphMouse(gm);
        vv.addKeyListener(gm.getModeKeyListener());

        JFrame frame = new JFrame("Simple Graph View");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.getContentPane().setLayout(new BorderLayout());
        frame.getContentPane().add(vv, BorderLayout.CENTER);
        frame.getContentPane().add(gm.getModeComboBox(), BorderLayout.SOUTH);
        frame.pack();
        frame.setVisible(true);
    }
 
开发者ID:gg-net,项目名称:dwoss,代码行数:68,代码来源:Grapher.java

示例4: setupGraph

import edu.uci.ics.jung.visualization.VisualizationViewer; //导入方法依赖的package包/类
public static void setupGraph(DirectedSparseGraph g){
	
	bg = g;
	
	Layout<BooleanNode, TravelEdge> layout = new DAGLayout(bg);
       layout.setSize(new Dimension(300,300)); // sets the initial size of the layout space

       VisualizationViewer<BooleanNode,TravelEdge> vv = new VisualizationViewer<BooleanNode,TravelEdge>(layout);
       vv.setPreferredSize(new Dimension(500,500)); //Sets the viewing area size

       Transformer<BooleanNode,Paint> vertexPaint = new Transformer<BooleanNode,Paint>() {
       	public Paint transform(BooleanNode i) {
       		if (i.isCurrentNode()){
       			return Color.RED;
       		} else if (i.getObserved()){
       			return Color.BLUE;
       		} else if (i.isStartNode()) {
       			return Color.GREEN;
       		} else if (i.isEndNode()){
       			return Color.BLACK;
       		} else {
       			return Color.WHITE;
       		}
       	}
       	}; 
       	
       vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint);
       vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());
	
       PluggableGraphMouse gm = new PluggableGraphMouse();
       gm.add(new NetworkGameMousePlugin());
       
       vv.setGraphMouse(gm); 
       
       frame = new JFrame("Simple Graph View");
       frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
       frame.getContentPane().add(vv); 
       
       JMenuBar menuBar = new JMenuBar();
       
       JMenu restartMenu = new JMenu();
       restartMenu.setText("Restart");
       menuBar.add(restartMenu);
       JMenuItem restartItem = new JMenuItem("Restart level");
       
       restartItem.addActionListener(new ActionListener() {
           public void actionPerformed(ActionEvent evt) {
               restartLevel();
           }
       });
       
       restartMenu.add(restartItem);
       
       
       
       frame.setJMenuBar(menuBar);
       
       
       frame.pack();
       frame.setVisible(true);  

       
       
}
 
开发者ID:ksotala,项目名称:BayesGame,代码行数:65,代码来源:SeparationGame.java

示例5: main

import edu.uci.ics.jung.visualization.VisualizationViewer; //导入方法依赖的package包/类
/**
     * @param args the command line arguments
     */
    public static void main(String[] args) {        
        JFrame frame = new JFrame("Editing and Mouse Menu Demo");
        SparseMultigraph<GraphElements.MyVertex, GraphElements.MyEdge> g = 
                new SparseMultigraph<GraphElements.MyVertex, GraphElements.MyEdge>();
        // Layout<V, E>, VisualizationViewer<V,E>
//        Map<GraphElements.MyVertex,Point2D> vertexLocations = new HashMap<GraphElements.MyVertex, Point2D>();
        Layout<GraphElements.MyVertex, GraphElements.MyEdge> layout = new StaticLayout(g);
        layout.setSize(new Dimension(300,300));
        VisualizationViewer<GraphElements.MyVertex,GraphElements.MyEdge> vv = 
                new VisualizationViewer<GraphElements.MyVertex,GraphElements.MyEdge>(layout);
        vv.setPreferredSize(new Dimension(350,350));
        // Show vertex and edge labels
        vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());
        vv.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller());
        // Create a graph mouse and add it to the visualization viewer
        EditingModalGraphMouse gm = new EditingModalGraphMouse(vv.getRenderContext(), 
                 GraphElements.MyVertexFactory.getInstance(),
                GraphElements.MyEdgeFactory.getInstance()); 
        // Set some defaults for the Edges...
        GraphElements.MyEdgeFactory.setDefaultCapacity(192.0);
        GraphElements.MyEdgeFactory.setDefaultWeight(5.0);
        // Trying out our new popup menu mouse plugin...
        PopupVertexEdgeMenuMousePlugin myPlugin = new PopupVertexEdgeMenuMousePlugin();
        // Add some popup menus for the edges and vertices to our mouse plugin.
        JPopupMenu edgeMenu = new MyMouseMenus.EdgeMenu(frame);
        JPopupMenu vertexMenu = new MyMouseMenus.VertexMenu();
        myPlugin.setEdgePopup(edgeMenu);
        myPlugin.setVertexPopup(vertexMenu);
        gm.remove(gm.getPopupEditingPlugin());  // Removes the existing popup editing plugin
        
        gm.add(myPlugin);   // Add our new plugin to the mouse
        
        vv.setGraphMouse(gm);

        
        //JFrame frame = new JFrame("Editing and Mouse Menu Demo");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.getContentPane().add(vv);
        
        // Let's add a menu for changing mouse modes
        JMenuBar menuBar = new JMenuBar();
        JMenu modeMenu = gm.getModeMenu();
        modeMenu.setText("Mouse Mode");
        modeMenu.setIcon(null); // I'm using this in a main menu
        modeMenu.setPreferredSize(new Dimension(80,20)); // Change the size so I can see the text
        
        menuBar.add(modeMenu);
        frame.setJMenuBar(menuBar);
        gm.setMode(ModalGraphMouse.Mode.EDITING); // Start off in editing mode
        frame.pack();
        frame.setVisible(true);    
    }
 
开发者ID:ksotala,项目名称:BayesGame,代码行数:56,代码来源:EditorMouseMenu.java


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