當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。