Author: kono
Date: 2011-07-21 14:28:18 -0700 (Thu, 21 Jul 2011)
New Revision: 26242
Modified:
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/property/AbstractVisualLexicon.java
core3/presentation-api/trunk/src/test/java/org/cytoscape/view/presentation/MinimalVisualLexiconTest.java
core3/viewmodel-api/trunk/src/main/java/org/cytoscape/view/model/VisualLexicon.java
Log:
fixes #57 isSupported(VisualProperty vp) method had been added to VisualLexicon.
Modified:
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/property/AbstractVisualLexicon.java
===================================================================
---
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/property/AbstractVisualLexicon.java
2011-07-21 21:27:43 UTC (rev 26241)
+++
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/property/AbstractVisualLexicon.java
2011-07-21 21:28:18 UTC (rev 26242)
@@ -134,6 +134,11 @@
return map.get(id.toLowerCase());
}
+
+ @Override
+ public boolean isSupported(VisualProperty<?> vp) {
+ return visualPropertyMap.containsKey(vp);
+ }
protected final void addIdentifierMapping(final Class<?> type, final
String id, final VisualProperty<?> vp) {
if ( type == null ) {
Modified:
core3/presentation-api/trunk/src/test/java/org/cytoscape/view/presentation/MinimalVisualLexiconTest.java
===================================================================
---
core3/presentation-api/trunk/src/test/java/org/cytoscape/view/presentation/MinimalVisualLexiconTest.java
2011-07-21 21:27:43 UTC (rev 26241)
+++
core3/presentation-api/trunk/src/test/java/org/cytoscape/view/presentation/MinimalVisualLexiconTest.java
2011-07-21 21:28:18 UTC (rev 26242)
@@ -1,5 +1,6 @@
package org.cytoscape.view.presentation;
+import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@@ -12,17 +13,25 @@
import org.cytoscape.view.presentation.property.AbstractVisualLexiconTest;
import org.cytoscape.view.presentation.property.NullVisualProperty;
import org.cytoscape.view.presentation.property.MinimalVisualLexicon;
+import org.cytoscape.view.presentation.property.RichVisualLexicon;
import org.junit.Before;
import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
public class MinimalVisualLexiconTest extends AbstractVisualLexiconTest {
private VisualLexicon minimalLex;
private VisualProperty<NullDataType> minimalRoot;
+
+ // Fake VPs
+ @Mock private VisualProperty<Double> numberVP;
+ @Mock private VisualProperty<String> textVP;
@Before
public void setUp() throws Exception {
-
+ MockitoAnnotations.initMocks(this);
+
// Create root node.
minimalRoot = new NullVisualProperty("MINIMAL_ROOT", "Minimal
Root Visual Property");
minimalLex = new MinimalVisualLexicon(minimalRoot);
@@ -42,29 +51,41 @@
public void testTree() throws Exception {
testTree(minimalLex);
}
-
+
@Test
public void testGetAllDecendents() throws Exception {
final VisualProperty<NullDataType> root =
minimalLex.getRootVisualProperty();
Collection<VisualProperty<?>> allChildren =
minimalLex.getAllDescendants(root);
-
- assertEquals(minimalLex.getAllVisualProperties().size() -1,
allChildren.size());
-
- Collection<VisualLexiconNode> nodeTextChild =
minimalLex.getVisualLexiconNode(MinimalVisualLexicon.NODE_LABEL).getChildren();
+
+ assertEquals(minimalLex.getAllVisualProperties().size() - 1,
allChildren.size());
+
+ Collection<VisualLexiconNode> nodeTextChild =
minimalLex.getVisualLexiconNode(MinimalVisualLexicon.NODE_LABEL)
+ .getChildren();
assertEquals(0, nodeTextChild.size());
-
- Collection<VisualLexiconNode> nodePaintChild =
minimalLex.getVisualLexiconNode(MinimalVisualLexicon.NODE_PAINT).getChildren();
+
+ Collection<VisualLexiconNode> nodePaintChild =
minimalLex.getVisualLexiconNode(MinimalVisualLexicon.NODE_PAINT)
+ .getChildren();
assertEquals(2, nodePaintChild.size());
assertEquals(minimalLex.getAllDescendants(MinimalVisualLexicon.NODE_PAINT).size(),
nodePaintChild.size());
-
+
Collection<VisualProperty<?>> nodeChildren =
minimalLex.getAllDescendants(MinimalVisualLexicon.NODE);
assertEquals(11, nodeChildren.size());
-
+
Collection<VisualProperty<?>> edgeChildren =
minimalLex.getAllDescendants(MinimalVisualLexicon.EDGE);
assertEquals(6, edgeChildren.size());
-
+
Collection<VisualProperty<?>> leaf =
minimalLex.getAllDescendants(MinimalVisualLexicon.EDGE_LABEL_COLOR);
assertEquals(0, leaf.size());
-
+
}
+
+ @Test
+ public void testIsSupported() throws Exception {
+ assertFalse(minimalLex.isSupported(this.numberVP));
+
assertTrue(minimalLex.isSupported(MinimalVisualLexicon.EDGE_PAINT));
+
assertTrue(minimalLex.isSupported(MinimalVisualLexicon.NODE_SIZE));
+
assertTrue(minimalLex.isSupported(MinimalVisualLexicon.NETWORK_CENTER_Y_LOCATION));
+
assertFalse(minimalLex.isSupported(RichVisualLexicon.EDGE_LINE_TYPE));
+ assertFalse(minimalLex.isSupported(this.textVP));
+ }
}
\ No newline at end of file
Modified:
core3/viewmodel-api/trunk/src/main/java/org/cytoscape/view/model/VisualLexicon.java
===================================================================
---
core3/viewmodel-api/trunk/src/main/java/org/cytoscape/view/model/VisualLexicon.java
2011-07-21 21:27:43 UTC (rev 26241)
+++
core3/viewmodel-api/trunk/src/main/java/org/cytoscape/view/model/VisualLexicon.java
2011-07-21 21:28:18 UTC (rev 26242)
@@ -99,5 +99,14 @@
* @return Collection of visual properties for the type.
*/
Collection<VisualProperty<?>> getAllDescendants(final VisualProperty<?>
prop);
+
+
+ /**
+ * Test the given Visual Property is supported in this Lexicon.
+ *
+ * @param vp visual property to be tested.
+ * @return true if this lexicon supports the given vp.
+ */
+ boolean isSupported(final VisualProperty<?> vp);
}
--
You received this message because you are subscribed to the Google Groups
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/cytoscape-cvs?hl=en.