Author: kono
Date: 2012-04-24 13:24:48 -0700 (Tue, 24 Apr 2012)
New Revision: 28968
Modified:
core3/api/trunk/presentation-api/src/main/java/org/cytoscape/view/presentation/property/BasicVisualLexicon.java
core3/api/trunk/presentation-api/src/main/java/org/cytoscape/view/presentation/property/FontVisualProperty.java
core3/api/trunk/presentation-api/src/test/java/org/cytoscape/view/presentation/BasicVisualLexiconTest.java
Log:
Minor update had been done for Font Visual Property. Also, new Visual Property
(Node Label Width) had been added.
Modified:
core3/api/trunk/presentation-api/src/main/java/org/cytoscape/view/presentation/property/BasicVisualLexicon.java
===================================================================
---
core3/api/trunk/presentation-api/src/main/java/org/cytoscape/view/presentation/property/BasicVisualLexicon.java
2012-04-24 20:15:34 UTC (rev 28967)
+++
core3/api/trunk/presentation-api/src/main/java/org/cytoscape/view/presentation/property/BasicVisualLexicon.java
2012-04-24 20:24:48 UTC (rev 28968)
@@ -112,7 +112,12 @@
public static final VisualProperty<Boolean>
NODE_NESTED_NETWORK_IMAGE_VISIBLE = new BooleanVisualProperty(true,
"NODE_NESTED_NETWORK_IMAGE_VISIBLE", "Nested Network
Image Visible", CyNode.class);
- // ///// Edge VP ///////
+
+ public static final VisualProperty<Double> NODE_LABEL_WIDTH = new
DoubleVisualProperty(100d, NONE_ZERO_POSITIVE_DOUBLE_RANGE,
+ "NODE_LABEL_WIDTH", "Node Label Width", CyNode.class);
+
+ ////////////////////////////////// Edge VP
////////////////////////////////////////
+
public static final VisualProperty<Paint> EDGE_PAINT = new
PaintVisualProperty(Color.gray, PAINT_RANGE,
"EDGE_PAINT", "Edge Paint", CyEdge.class);
@@ -331,6 +336,7 @@
addVisualProperty(NODE_WIDTH, NODE_SIZE);
addVisualProperty(NODE_HEIGHT, NODE_SIZE);
addVisualProperty(NODE_DEPTH, NODE_SIZE);
+ addVisualProperty(NODE_LABEL_WIDTH, NODE_SIZE);
// Level 3: Edge-related VP
addVisualProperty(EDGE_LABEL_COLOR, EDGE_PAINT);
@@ -370,7 +376,8 @@
addIdentifierMapping(CyNode.class, "nodeHeight", NODE_HEIGHT);
addIdentifierMapping(CyNode.class, "nodeLabel", NODE_LABEL);
addIdentifierMapping(CyNode.class, "nodeLabelColor",
NODE_LABEL_COLOR);
-
+ addIdentifierMapping(CyNode.class, "nodeLabelWidth",
NODE_LABEL_WIDTH);
+
addIdentifierMapping(CyEdge.class, "edgeColor", EDGE_PAINT);
addIdentifierMapping(CyEdge.class, "edgeLineWidth", EDGE_WIDTH);
addIdentifierMapping(CyEdge.class, "edgeLabel", EDGE_LABEL);
Modified:
core3/api/trunk/presentation-api/src/main/java/org/cytoscape/view/presentation/property/FontVisualProperty.java
===================================================================
---
core3/api/trunk/presentation-api/src/main/java/org/cytoscape/view/presentation/property/FontVisualProperty.java
2012-04-24 20:15:34 UTC (rev 28967)
+++
core3/api/trunk/presentation-api/src/main/java/org/cytoscape/view/presentation/property/FontVisualProperty.java
2012-04-24 20:24:48 UTC (rev 28968)
@@ -51,22 +51,25 @@
* @CyAPI.Final.Class
*/
public final class FontVisualProperty extends AbstractVisualProperty<Font> {
+
+ private static final Logger logger =
LoggerFactory.getLogger(FontVisualProperty.class);
private static final Range<Font> FONT_RANGE;
private static final int DEF_FONT_SIZE = 12;
- private static final Logger logger =
LoggerFactory.getLogger(FontVisualProperty.class);
+ private static final Font DEFAULT_FONT = new Font("SansSerif",
Font.PLAIN, DEF_FONT_SIZE);
static {
final Set<Font> fontSet = new HashSet<Font>();
final Font[] allFonts =
GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();
- for(Font f: allFonts)
+ for (Font f : allFonts)
fontSet.add(f.deriveFont(DEF_FONT_SIZE));
-
+
FONT_RANGE = new DiscreteRange<Font>(Font.class, fontSet) {
// Takes any String as valid value.
- @Override public boolean inRange(Font value) {
+ @Override
+ public boolean inRange(Font value) {
return true;
}
};
@@ -79,8 +82,7 @@
* @param displayName A human readable string used for displays and
user interfaces.
* @param modelDataType The model data type associated with this visual
property, e.g. CyNode, CyEdge, or CyNetwork.
*/
- public FontVisualProperty(final Font def, final String id,
- final String displayName, final Class<?> modelDataType)
{
+ public FontVisualProperty(final Font def, final String id, final String
displayName, final Class<?> modelDataType) {
super(def, FONT_RANGE, id, displayName, modelDataType);
}
@@ -96,33 +98,24 @@
@Override
public Font parseSerializableString(final String text) {
- Font font = null;
-
- if (text != null && text.trim().length() !=0) {
+ if (text != null && text.trim().length() != 0) {
// e.g. "Monospaced,plain,12"
- String name =
text.replaceAll("(\\.[bB]old)?,[a-zA-Z]+,\\d+(\\.\\d+)?", "");
+ String name =
text.replaceAll("(\\.[bB]old)?,[a-zA-Z]+,\\d+(\\.\\d+)?", "");
- boolean bold = text.matches("(?i).*\\.bold,[a-zA-Z]+,.*");
- int style = bold ? Font.BOLD : Font.PLAIN;
- int size = 12;
+ boolean bold =
text.matches("(?i).*\\.bold,[a-zA-Z]+,.*");
+ int style = bold ? Font.BOLD : Font.PLAIN;
+ int size = DEF_FONT_SIZE;
- String sSize = text.replaceAll(".+,[^,]+,", "");
-
- try {
- size = Integer.parseInt(sSize);
- } catch (NumberFormatException nfe) {
- logger.warn("Cannot parse font size in '" + text +"'", nfe);
- }
+ String sSize = text.replaceAll(".+,[^,]+,", "");
- font = new Font(name, style, size);
- }
-
- return font;
- }
+ try {
+ size = Integer.parseInt(sSize);
+ } catch (NumberFormatException nfe) {
+ logger.warn("Cannot parse font size in '" +
text + "'", nfe);
+ }
- private static Set<Font> getSystemFonts() {
- //TODO: implement this.
- final Set<Font> fontSet = new HashSet<Font>();
- return fontSet;
+ return new Font(name, style, size);
+ } else
+ return DEFAULT_FONT;
}
}
Modified:
core3/api/trunk/presentation-api/src/test/java/org/cytoscape/view/presentation/BasicVisualLexiconTest.java
===================================================================
---
core3/api/trunk/presentation-api/src/test/java/org/cytoscape/view/presentation/BasicVisualLexiconTest.java
2012-04-24 20:15:34 UTC (rev 28967)
+++
core3/api/trunk/presentation-api/src/test/java/org/cytoscape/view/presentation/BasicVisualLexiconTest.java
2012-04-24 20:24:48 UTC (rev 28968)
@@ -46,7 +46,7 @@
@Test
public void test2DLexicon() throws Exception {
- assertEquals(58, richLex.getAllVisualProperties().size());
+ assertEquals(59, richLex.getAllVisualProperties().size());
}
@Test
@@ -71,7 +71,7 @@
assertEquals(richLex.getAllDescendants(BasicVisualLexicon.NODE_PAINT).size(),
nodePaintChild.size());
Collection<VisualProperty<?>> nodeChildren =
richLex.getAllDescendants(BasicVisualLexicon.NODE);
- assertEquals(25, nodeChildren.size());
+ assertEquals(26, nodeChildren.size());
Collection<VisualProperty<?>> edgeChildren =
richLex.getAllDescendants(BasicVisualLexicon.EDGE);
assertEquals(19, edgeChildren.size());
--
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.