Search in sources :

Example 1 with InnerCanvas

use of org.cytoscape.ding.impl.InnerCanvas in project cytoscape-impl by cytoscape.

the class PerfTest method visualizeNetworks.

private void visualizeNetworks() {
    try {
        CyNetworkView[] views = getViews("A50-50.sif");
        JFrame frame = new JFrame();
        frame.setPreferredSize(new Dimension(800, 800));
        JPanel panel = new JPanel();
        panel.setPreferredSize(new Dimension(800, 800));
        panel.setBackground(Color.blue);
        InnerCanvas jc = ((DGraphView) (views[0])).getCanvas();
        jc.setVisible(true);
        jc.setPreferredSize(new Dimension(800, 800));
        panel.add(jc);
        frame.getContentPane().add(panel);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.pack();
        frame.setVisible(true);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : JPanel(javax.swing.JPanel) JFrame(javax.swing.JFrame) InnerCanvas(org.cytoscape.ding.impl.InnerCanvas) Dimension(java.awt.Dimension) CyNetworkView(org.cytoscape.view.model.CyNetworkView) DGraphView(org.cytoscape.ding.impl.DGraphView)

Example 2 with InnerCanvas

use of org.cytoscape.ding.impl.InnerCanvas in project cytoscape-impl by cytoscape.

the class EdgeBendValueEditor method updateUI.

private void updateUI(Bend startBend) {
    innerPanel.removeAll();
    final Color NODE_COLOR = UIManager.getColor("Label.disabledForeground");
    final Color EDGE_COLOR = UIManager.getColor("Label.foreground");
    final Color SELECTION_COLOR = UIManager.getColor("Focus.color");
    final Color BACKGROUND_COLOR = UIManager.getColor("Table.background");
    // Create very simple dummy view.
    final CyNetworkFactory networkFactory = serviceRegistrar.getService(CyNetworkFactory.class);
    final CyNetwork dummyNet = networkFactory.createNetworkWithPrivateTables(SavePolicy.DO_NOT_SAVE);
    final CyNode source = dummyNet.addNode();
    final CyNode target = dummyNet.addNode();
    final CyEdge edge = dummyNet.addEdge(source, target, true);
    // TODO Unfortunately, handles cannot be clicked when the edge is selected like this
    // dummyNet.getRow(edge, CyNetwork.DEFAULT_ATTRS).set(CyNetwork.SELECTED, true);
    // Create View
    dummyView = cyNetworkViewFactory.createNetworkView(dummyNet);
    // Set appearances of the view
    final View<CyNode> sourceView = dummyView.getNodeView(source);
    final View<CyNode> targetView = dummyView.getNodeView(target);
    edgeView = dummyView.getEdgeView(edge);
    dummyView.setVisualProperty(NETWORK_BACKGROUND_PAINT, BACKGROUND_COLOR);
    sourceView.setVisualProperty(NODE_FILL_COLOR, NODE_COLOR);
    targetView.setVisualProperty(NODE_FILL_COLOR, NODE_COLOR);
    sourceView.setVisualProperty(NODE_LABEL_COLOR, BACKGROUND_COLOR);
    targetView.setVisualProperty(NODE_LABEL_COLOR, BACKGROUND_COLOR);
    sourceView.setVisualProperty(NODE_SELECTED_PAINT, SELECTION_COLOR);
    targetView.setVisualProperty(NODE_SELECTED_PAINT, SELECTION_COLOR);
    sourceView.setVisualProperty(NODE_LABEL_FONT_SIZE, 16);
    targetView.setVisualProperty(NODE_LABEL_FONT_SIZE, 16);
    sourceView.setVisualProperty(NODE_LABEL, "S");
    targetView.setVisualProperty(NODE_LABEL, "T");
    sourceView.setVisualProperty(NODE_SHAPE, NodeShapeVisualProperty.ELLIPSE);
    targetView.setVisualProperty(NODE_SHAPE, NodeShapeVisualProperty.ELLIPSE);
    sourceView.setVisualProperty(NODE_WIDTH, 40d);
    sourceView.setVisualProperty(NODE_HEIGHT, 40d);
    sourceView.setVisualProperty(NODE_BORDER_PAINT, NODE_COLOR);
    targetView.setVisualProperty(NODE_WIDTH, 40d);
    targetView.setVisualProperty(NODE_HEIGHT, 40d);
    targetView.setVisualProperty(NODE_BORDER_PAINT, NODE_COLOR);
    edgeView.setVisualProperty(EDGE_SELECTED_PAINT, SELECTION_COLOR);
    edgeView.setVisualProperty(EDGE_STROKE_SELECTED_PAINT, SELECTION_COLOR);
    edgeView.setVisualProperty(EDGE_STROKE_UNSELECTED_PAINT, EDGE_COLOR);
    edgeView.setVisualProperty(EDGE_WIDTH, 4d);
    edgeView.setVisualProperty(EDGE_TARGET_ARROW_SHAPE, ArrowShapeVisualProperty.ARROW);
    edgeView.setVisualProperty(DVisualLexicon.EDGE_TARGET_ARROW_UNSELECTED_PAINT, EDGE_COLOR);
    edgeView.setVisualProperty(DVisualLexicon.EDGE_CURVED, true);
    if (startBend == null || startBend.equals(EDGE_BEND.getDefault()))
        startBend = new BendImpl();
    edgeView.setVisualProperty(EDGE_BEND, startBend);
    sourceView.setVisualProperty(NODE_X_LOCATION, 0d);
    sourceView.setVisualProperty(NODE_Y_LOCATION, 100d);
    targetView.setVisualProperty(NODE_X_LOCATION, 400d);
    targetView.setVisualProperty(NODE_Y_LOCATION, 120d);
    // Render it in this panel.  It is not necessary to register this engine to manager.
    presentationFactory.createRenderingEngine(innerPanel, dummyView);
    final InnerCanvas innerCanvas = (InnerCanvas) innerPanel.getComponent(0);
    innerCanvas.disablePopupMenu();
}
Also used : BendImpl(org.cytoscape.ding.impl.BendImpl) Color(java.awt.Color) InnerCanvas(org.cytoscape.ding.impl.InnerCanvas) CyNetwork(org.cytoscape.model.CyNetwork) CyNetworkFactory(org.cytoscape.model.CyNetworkFactory) CyNode(org.cytoscape.model.CyNode) CyEdge(org.cytoscape.model.CyEdge)

Aggregations

InnerCanvas (org.cytoscape.ding.impl.InnerCanvas)2 Color (java.awt.Color)1 Dimension (java.awt.Dimension)1 JFrame (javax.swing.JFrame)1 JPanel (javax.swing.JPanel)1 BendImpl (org.cytoscape.ding.impl.BendImpl)1 DGraphView (org.cytoscape.ding.impl.DGraphView)1 CyEdge (org.cytoscape.model.CyEdge)1 CyNetwork (org.cytoscape.model.CyNetwork)1 CyNetworkFactory (org.cytoscape.model.CyNetworkFactory)1 CyNode (org.cytoscape.model.CyNode)1 CyNetworkView (org.cytoscape.view.model.CyNetworkView)1