Search in sources :

Example 1 with VisualProperty

use of org.cytoscape.view.model.VisualProperty in project EnrichmentMapApp by BaderLab.

the class EMStyleBuilder method setNodeChart.

@SuppressWarnings({ "rawtypes", "unchecked" })
private void setNodeChart(VisualStyle vs, CyCustomGraphics2<?> chart) {
    VisualLexicon lexicon = renderingEngineManager.getDefaultVisualLexicon();
    VisualProperty customPaint1 = lexicon.lookup(CyNode.class, "NODE_CUSTOMGRAPHICS_1");
    if (customPaint1 != null)
        vs.setDefaultValue(customPaint1, chart);
}
Also used : BasicVisualLexicon(org.cytoscape.view.presentation.property.BasicVisualLexicon) VisualLexicon(org.cytoscape.view.model.VisualLexicon) LineTypeVisualProperty(org.cytoscape.view.presentation.property.LineTypeVisualProperty) VisualProperty(org.cytoscape.view.model.VisualProperty)

Example 2 with VisualProperty

use of org.cytoscape.view.model.VisualProperty in project cytoscape-api by cytoscape.

the class AbstractVisualLexiconTest method testTree.

protected void testTree(VisualLexicon lexicon) throws Exception {
    final VisualProperty<NullDataType> root = lexicon.getRootVisualProperty();
    assertNotNull(root);
    assertEquals(lexicon.getRootVisualProperty(), root);
    // test common methods
    try {
        Collection<VisualProperty<?>> result = lexicon.getAllDescendants(null);
    } catch (Exception e) {
        assertTrue(e instanceof NullPointerException);
    }
    try {
        Collection<VisualProperty<?>> result = lexicon.getAllDescendants(new DefaultVisualizableVisualProperty("test", "Test Visual Property", CyNode.class));
    } catch (Exception e) {
        assertTrue(e instanceof IllegalArgumentException);
    }
    final VisualLexiconNode rootNode = lexicon.getVisualLexiconNode(root);
    assertNotNull(rootNode);
    assertEquals(root, rootNode.getVisualProperty());
    final Collection<VisualLexiconNode> children = rootNode.getChildren();
    assertFalse(0 == children.size());
    traverse(children, lexicon);
    // Test adding
    final DoubleVisualProperty dummyVP = new DoubleVisualProperty(new Double(10), BasicVisualLexicon.ARBITRARY_DOUBLE_RANGE, "DUMMY", "Dummy VP", CyNode.class);
    try {
        ((BasicVisualLexicon) lexicon).addVisualProperty(BasicVisualLexicon.NODE_FILL_COLOR, root);
    } catch (Exception e) {
        assertTrue(e instanceof IllegalStateException);
    }
    try {
        ((BasicVisualLexicon) lexicon).addVisualProperty(dummyVP, null);
    } catch (Exception e) {
        assertTrue(e instanceof NullPointerException);
    }
    try {
        ((BasicVisualLexicon) lexicon).addVisualProperty(dummyVP, dummyVP);
    } catch (Exception e) {
        assertTrue(e instanceof IllegalArgumentException);
    }
    ((BasicVisualLexicon) lexicon).addVisualProperty(dummyVP, root);
}
Also used : VisualLexiconNode(org.cytoscape.view.model.VisualLexiconNode) NullDataType(org.cytoscape.view.model.NullDataType) VisualProperty(org.cytoscape.view.model.VisualProperty) CyNode(org.cytoscape.model.CyNode)

Example 3 with VisualProperty

use of org.cytoscape.view.model.VisualProperty in project EnrichmentMapApp by BaderLab.

the class LegendPanel method getIcon.

@SuppressWarnings({ "unchecked", "rawtypes" })
private Icon getIcon(VisualProperty<?> vp, Object value, CyNetworkView netView) {
    if (value == null || netView == null)
        return null;
    Collection<RenderingEngine<?>> engines = engineManager.getRenderingEngines(netView);
    RenderingEngine<?> engine = null;
    for (RenderingEngine<?> re : engines) {
        if (re.getRendererId().equals(netView.getRendererId())) {
            engine = re;
            break;
        }
    }
    Icon icon = engine != null ? engine.createIcon((VisualProperty) vp, value, LEGEND_ICON_SIZE, LEGEND_ICON_SIZE) : null;
    return icon;
}
Also used : RenderingEngine(org.cytoscape.view.presentation.RenderingEngine) VisualProperty(org.cytoscape.view.model.VisualProperty) Icon(javax.swing.Icon)

Example 4 with VisualProperty

use of org.cytoscape.view.model.VisualProperty in project cytoscape-api by cytoscape.

the class BasicVisualLexicon method getChildNodes.

private Set<VisualProperty<?>> getChildNodes(VisualProperty<?> prop) {
    final VisualLexiconNode node = visualPropertyMap.get(prop);
    final Set<VisualProperty<?>> children = new HashSet<>();
    // if this is a leaf node, return empty set
    if (node.getChildren().size() == 0)
        return children;
    Collection<VisualLexiconNode> currentChildren = node.getChildren();
    for (VisualLexiconNode nd : currentChildren) children.add(nd.getVisualProperty());
    for (VisualLexiconNode nd : currentChildren) children.addAll(getChildNodes(nd.getVisualProperty()));
    return children;
}
Also used : VisualLexiconNode(org.cytoscape.view.model.VisualLexiconNode) VisualProperty(org.cytoscape.view.model.VisualProperty) HashSet(java.util.HashSet)

Example 5 with VisualProperty

use of org.cytoscape.view.model.VisualProperty in project cytoscape-api by cytoscape.

the class VisualPropertyDependencyTest method setUp.

@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);
    lexicon = new BasicVisualLexicon(rootVisualProperty);
    vpSet = new HashSet<VisualProperty<Paint>>();
    vpSet.add(BasicVisualLexicon.NODE_BORDER_PAINT);
    vpSet.add(BasicVisualLexicon.NODE_FILL_COLOR);
    dependency = new VisualPropertyDependency<Paint>(id, displayName, vpSet, lexicon);
}
Also used : BasicVisualLexicon(org.cytoscape.view.presentation.property.BasicVisualLexicon) VisualProperty(org.cytoscape.view.model.VisualProperty) Paint(java.awt.Paint) Before(org.junit.Before)

Aggregations

VisualProperty (org.cytoscape.view.model.VisualProperty)5 VisualLexiconNode (org.cytoscape.view.model.VisualLexiconNode)2 BasicVisualLexicon (org.cytoscape.view.presentation.property.BasicVisualLexicon)2 Paint (java.awt.Paint)1 HashSet (java.util.HashSet)1 Icon (javax.swing.Icon)1 CyNode (org.cytoscape.model.CyNode)1 NullDataType (org.cytoscape.view.model.NullDataType)1 VisualLexicon (org.cytoscape.view.model.VisualLexicon)1 RenderingEngine (org.cytoscape.view.presentation.RenderingEngine)1 LineTypeVisualProperty (org.cytoscape.view.presentation.property.LineTypeVisualProperty)1 Before (org.junit.Before)1