Search in sources :

Example 1 with BendImpl

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

the class EdgeBendTest method testEdgeBend.

@Test
public void testEdgeBend() {
    Bend bend1 = new BendImpl();
    bend1.insertHandleAt(0, new HandleImpl(null, null, 10, 20));
}
Also used : BendImpl(org.cytoscape.ding.impl.BendImpl) Bend(org.cytoscape.view.presentation.property.values.Bend) HandleImpl(org.cytoscape.ding.impl.HandleImpl) Test(org.junit.Test)

Example 2 with BendImpl

use of org.cytoscape.ding.impl.BendImpl 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

BendImpl (org.cytoscape.ding.impl.BendImpl)2 Color (java.awt.Color)1 HandleImpl (org.cytoscape.ding.impl.HandleImpl)1 InnerCanvas (org.cytoscape.ding.impl.InnerCanvas)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 Bend (org.cytoscape.view.presentation.property.values.Bend)1 Test (org.junit.Test)1