Author: kono
Date: 2011-06-09 17:47:43 -0700 (Thu, 09 Jun 2011)
New Revision: 25701
Added:
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/property/FontVisualProperty.java
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/property/IntegerVisualProperty.java
core3/viewmodel-api/trunk/src/test/java/org/cytoscape/view/model/ContinuousRangeTest.java
core3/viewmodel-api/trunk/src/test/java/org/cytoscape/view/model/DiscreteRangeTest.java
Removed:
core3/default-mappingcalculators/trunk/src/test/java/org/cytoscape/vizmap/ColorVisualProperty.java
core3/ding-presentation-impl/trunk/src/main/java/org/cytoscape/ding/impl/visualproperty/IntegerTwoDVisualProperty.java
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/property/FontTwoDVisualProperty.java
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/property/IntegerTwoDVisualProperty.java
Modified:
core3/ding-presentation-impl/trunk/src/main/java/org/cytoscape/ding/impl/FlagAndSelectionHandler.java
core3/ding-presentation-impl/trunk/src/main/java/org/cytoscape/ding/impl/visualproperty/ObjectPositionVisualProperty.java
core3/presentation-api/trunk/pom.xml
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/property/MinimalVisualLexicon.java
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/property/RichVisualLexicon.java
core3/viewmodel-api/trunk/pom.xml
core3/viewmodel-api/trunk/src/main/java/org/cytoscape/view/model/ContinuousRange.java
core3/viewmodel-api/trunk/src/main/java/org/cytoscape/view/model/DiscreteRange.java
core3/viewmodel-api/trunk/src/main/java/org/cytoscape/view/model/Range.java
core3/viewmodel-api/trunk/src/test/java/org/cytoscape/view/model/IntegerVisualProperty.java
core3/viewmodel-impl/trunk/pom.xml
core3/vizmap-api/trunk/pom.xml
core3/vizmap-gui-impl/trunk/pom.xml
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/editor/EditorManagerImpl.java
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/editor/valueeditor/AbstractValueEditor.java
core3/vizmap-impl/trunk/pom.xml
Log:
Validation mechanism had been added to the Vizmap. Unused dummy test classes
had been removed.
Deleted:
core3/default-mappingcalculators/trunk/src/test/java/org/cytoscape/vizmap/ColorVisualProperty.java
===================================================================
---
core3/default-mappingcalculators/trunk/src/test/java/org/cytoscape/vizmap/ColorVisualProperty.java
2011-06-10 00:43:50 UTC (rev 25700)
+++
core3/default-mappingcalculators/trunk/src/test/java/org/cytoscape/vizmap/ColorVisualProperty.java
2011-06-10 00:47:43 UTC (rev 25701)
@@ -1,31 +0,0 @@
-package org.cytoscape.vizmap;
-
-import java.awt.Color;
-
-import org.cytoscape.model.CyNode;
-import org.cytoscape.view.model.AbstractVisualProperty;
-import org.cytoscape.view.model.ContinuousRange;
-import org.cytoscape.view.model.Range;
-
-public class ColorVisualProperty extends AbstractVisualProperty<Color> {
-
-
- private static final Color MIN_COLOR = new Color(0, 0, 0);
- private static final Color MAX_COLOR = new Color(0xFF, 0xFF, 0xFF);
- private static final Range<Color> COLOR_RANGE = new
ContinuousRange<Color>(Color.class, MIN_COLOR, MAX_COLOR);
-
- public ColorVisualProperty(final Color defaultValue,
- final String id, final String name) {
- super(defaultValue, COLOR_RANGE, id, name, CyNode.class);
- }
-
- public Color parseSerializableString(final String text) {
- // This is dummy and not work, but it's ok for mapping tests.
- return Color.decode(text);
- }
-
- @Override
- public String toSerializableString(Color value) {
- return value.toString();
- }
-}
\ No newline at end of file
Modified:
core3/ding-presentation-impl/trunk/src/main/java/org/cytoscape/ding/impl/FlagAndSelectionHandler.java
===================================================================
---
core3/ding-presentation-impl/trunk/src/main/java/org/cytoscape/ding/impl/FlagAndSelectionHandler.java
2011-06-10 00:43:50 UTC (rev 25700)
+++
core3/ding-presentation-impl/trunk/src/main/java/org/cytoscape/ding/impl/FlagAndSelectionHandler.java
2011-06-10 00:47:43 UTC (rev 25701)
@@ -159,7 +159,7 @@
* flagged state in the SelectFilter object.
*/
public void graphViewChanged(final GraphViewChangeEvent event) {
-
+
// GINY bug: the event we get frequently has the correct indices
// but incorrect Node and Edge objects. For now we get around
this
// by converting indices to graph objects ourselves
Deleted:
core3/ding-presentation-impl/trunk/src/main/java/org/cytoscape/ding/impl/visualproperty/IntegerTwoDVisualProperty.java
===================================================================
---
core3/ding-presentation-impl/trunk/src/main/java/org/cytoscape/ding/impl/visualproperty/IntegerTwoDVisualProperty.java
2011-06-10 00:43:50 UTC (rev 25700)
+++
core3/ding-presentation-impl/trunk/src/main/java/org/cytoscape/ding/impl/visualproperty/IntegerTwoDVisualProperty.java
2011-06-10 00:47:43 UTC (rev 25701)
@@ -1,58 +0,0 @@
-
-/*
- Copyright (c) 2008, The Cytoscape Consortium (www.cytoscape.org)
-
- The Cytoscape Consortium is:
- - Institute for Systems Biology
- - University of California San Diego
- - Memorial Sloan-Kettering Cancer Center
- - Institut Pasteur
- - Agilent Technologies
-
- This library is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as published
- by the Free Software Foundation; either version 2.1 of the License, or
- any later version.
-
- This library is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
- MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. The software and
- documentation provided hereunder is on an "as is" basis, and the
- Institute for Systems Biology and the Whitehead Institute
- have no obligations to provide maintenance, support,
- updates, enhancements or modifications. In no event shall the
- Institute for Systems Biology and the Whitehead Institute
- be liable to any party for direct, indirect, special,
- incidental or consequential damages, including lost profits, arising
- out of the use of this software and its documentation, even if the
- Institute for Systems Biology and the Whitehead Institute
- have been advised of the possibility of such damage. See
- the GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this library; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
-*/
-package org.cytoscape.ding.impl.visualproperty;
-
-import org.cytoscape.view.model.AbstractVisualProperty;
-import org.cytoscape.view.model.ContinuousRange;
-import org.cytoscape.view.model.Range;
-
-public class IntegerTwoDVisualProperty extends AbstractVisualProperty<Integer>
{
-
- private static final Range<Integer> INT_RANGE = new
ContinuousRange<Integer>(Integer.class, Integer.MIN_VALUE, Integer.MAX_VALUE);
-
- public IntegerTwoDVisualProperty(final Integer def, final String id,
final String name, final Class<?> targetDataType) {
- super(def,INT_RANGE, id, name, targetDataType);
- }
-
- public String toSerializableString(final Integer value) {
- return value.toString();
- }
-
- public Integer parseSerializableString(final String text) {
- // Cytoscape 2.x serializes integer attributes as decimals
(e.g."1.0")!
- return Double.valueOf(text).intValue();
- }
-}
Modified:
core3/ding-presentation-impl/trunk/src/main/java/org/cytoscape/ding/impl/visualproperty/ObjectPositionVisualProperty.java
===================================================================
---
core3/ding-presentation-impl/trunk/src/main/java/org/cytoscape/ding/impl/visualproperty/ObjectPositionVisualProperty.java
2011-06-10 00:43:50 UTC (rev 25700)
+++
core3/ding-presentation-impl/trunk/src/main/java/org/cytoscape/ding/impl/visualproperty/ObjectPositionVisualProperty.java
2011-06-10 00:47:43 UTC (rev 25701)
@@ -13,7 +13,7 @@
private static final ObjectPosition MIN_OBJECT =
ObjectPositionImpl.DEFAULT_POSITION;
static {
- OBJECT_POSITION_RANGE = new
ContinuousRange<ObjectPosition>(ObjectPosition.class, MIN_OBJECT, MIN_OBJECT);
+ OBJECT_POSITION_RANGE = new
ContinuousRange<ObjectPosition>(ObjectPosition.class, MIN_OBJECT, MIN_OBJECT,
true, true);
}
public ObjectPositionVisualProperty(ObjectPosition defaultValue,
Modified: core3/presentation-api/trunk/pom.xml
===================================================================
--- core3/presentation-api/trunk/pom.xml 2011-06-10 00:43:50 UTC (rev
25700)
+++ core3/presentation-api/trunk/pom.xml 2011-06-10 00:47:43 UTC (rev
25701)
@@ -119,7 +119,7 @@
<dependency>
<groupId>org.cytoscape</groupId>
<artifactId>viewmodel-api</artifactId>
- <version>3.0.0-alpha4</version>
+ <version>3.0.0-alpha5-SNAPSHOT</version>
</dependency>
<!-- For Testing -->
Deleted:
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/property/FontTwoDVisualProperty.java
===================================================================
---
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/property/FontTwoDVisualProperty.java
2011-06-10 00:43:50 UTC (rev 25700)
+++
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/property/FontTwoDVisualProperty.java
2011-06-10 00:47:43 UTC (rev 25701)
@@ -1,111 +0,0 @@
-/*
- Copyright (c) 2008, The Cytoscape Consortium (www.cytoscape.org)
-
- The Cytoscape Consortium is:
- - Institute for Systems Biology
- - University of California San Diego
- - Memorial Sloan-Kettering Cancer Center
- - Institut Pasteur
- - Agilent Technologies
-
- This library is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as published
- by the Free Software Foundation; either version 2.1 of the License, or
- any later version.
-
- This library is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
- MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. The software and
- documentation provided hereunder is on an "as is" basis, and the
- Institute for Systems Biology and the Whitehead Institute
- have no obligations to provide maintenance, support,
- updates, enhancements or modifications. In no event shall the
- Institute for Systems Biology and the Whitehead Institute
- be liable to any party for direct, indirect, special,
- incidental or consequential damages, including lost profits, arising
- out of the use of this software and its documentation, even if the
- Institute for Systems Biology and the Whitehead Institute
- have been advised of the possibility of such damage. See
- the GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this library; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- */
-package org.cytoscape.view.presentation.property;
-
-import java.awt.Font;
-import java.awt.GraphicsEnvironment;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.cytoscape.view.model.AbstractVisualProperty;
-import org.cytoscape.view.model.DiscreteRange;
-import org.cytoscape.view.model.Range;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class FontTwoDVisualProperty extends AbstractVisualProperty<Font> {
-
- private static final Range<Font> FONT_RANGE;
- private static final int DEF_FONT_SIZE = 12;
-
- private static final Logger logger =
LoggerFactory.getLogger(FontTwoDVisualProperty.class);
-
- static {
- final Set<Font> fontSet = new HashSet<Font>();
- final Font[] allFonts =
GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();
-
- for(Font f: allFonts)
- fontSet.add(f.deriveFont(DEF_FONT_SIZE));
-
- FONT_RANGE = new DiscreteRange<Font>(Font.class,fontSet);
- }
-
- public FontTwoDVisualProperty(final Font def, final String id,
- final String name, final Class<?> targetDataType) {
- super(def, FONT_RANGE, id, name, targetDataType);
- }
-
- @Override
- public String toSerializableString(final Font value) {
- // e.g.: "SanSerif,bold,10"
- String name = value.getFontName();
- String weight = value.isBold() ? "bold" : "plain";
- int size = value.getSize();
-
- return name + "," + weight + "," + size;
- }
-
- @Override
- public Font parseSerializableString(final String text) {
- Font font = null;
-
- if (text != null) {
- // e.g. "Monospaced,plain,12"
- 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;
-
- String sSize = text.replaceAll(".+,[^,]+,", "");
-
- try {
- size = Integer.parseInt(sSize);
- } catch (NumberFormatException nfe) {
- logger.warn("Cannot parse font size in '" + text +"'", nfe);
- }
-
- font = new Font(name, style, size);
- }
-
- return font;
- }
-
- private static Set<Font> getSystemFonts() {
- //TODO: implement this.
- final Set<Font> fontSet = new HashSet<Font>();
- return fontSet;
- }
-}
Copied:
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/property/FontVisualProperty.java
(from rev 25624,
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/property/FontTwoDVisualProperty.java)
===================================================================
---
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/property/FontVisualProperty.java
(rev 0)
+++
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/property/FontVisualProperty.java
2011-06-10 00:47:43 UTC (rev 25701)
@@ -0,0 +1,111 @@
+/*
+ Copyright (c) 2008, The Cytoscape Consortium (www.cytoscape.org)
+
+ The Cytoscape Consortium is:
+ - Institute for Systems Biology
+ - University of California San Diego
+ - Memorial Sloan-Kettering Cancer Center
+ - Institut Pasteur
+ - Agilent Technologies
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of the License, or
+ any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
+ MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. The software and
+ documentation provided hereunder is on an "as is" basis, and the
+ Institute for Systems Biology and the Whitehead Institute
+ have no obligations to provide maintenance, support,
+ updates, enhancements or modifications. In no event shall the
+ Institute for Systems Biology and the Whitehead Institute
+ be liable to any party for direct, indirect, special,
+ incidental or consequential damages, including lost profits, arising
+ out of the use of this software and its documentation, even if the
+ Institute for Systems Biology and the Whitehead Institute
+ have been advised of the possibility of such damage. See
+ the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this library; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+package org.cytoscape.view.presentation.property;
+
+import java.awt.Font;
+import java.awt.GraphicsEnvironment;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.cytoscape.view.model.AbstractVisualProperty;
+import org.cytoscape.view.model.DiscreteRange;
+import org.cytoscape.view.model.Range;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class FontVisualProperty extends AbstractVisualProperty<Font> {
+
+ private static final Range<Font> FONT_RANGE;
+ private static final int DEF_FONT_SIZE = 12;
+
+ private static final Logger logger =
LoggerFactory.getLogger(FontVisualProperty.class);
+
+ static {
+ final Set<Font> fontSet = new HashSet<Font>();
+ final Font[] allFonts =
GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();
+
+ for(Font f: allFonts)
+ fontSet.add(f.deriveFont(DEF_FONT_SIZE));
+
+ FONT_RANGE = new DiscreteRange<Font>(Font.class,fontSet);
+ }
+
+ public FontVisualProperty(final Font def, final String id,
+ final String name, final Class<?> targetDataType) {
+ super(def, FONT_RANGE, id, name, targetDataType);
+ }
+
+ @Override
+ public String toSerializableString(final Font value) {
+ // e.g.: "SanSerif,bold,10"
+ String name = value.getFontName();
+ String weight = value.isBold() ? "bold" : "plain";
+ int size = value.getSize();
+
+ return name + "," + weight + "," + size;
+ }
+
+ @Override
+ public Font parseSerializableString(final String text) {
+ Font font = null;
+
+ if (text != null) {
+ // e.g. "Monospaced,plain,12"
+ 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;
+
+ String sSize = text.replaceAll(".+,[^,]+,", "");
+
+ try {
+ size = Integer.parseInt(sSize);
+ } catch (NumberFormatException nfe) {
+ logger.warn("Cannot parse font size in '" + text +"'", nfe);
+ }
+
+ font = new Font(name, style, size);
+ }
+
+ return font;
+ }
+
+ private static Set<Font> getSystemFonts() {
+ //TODO: implement this.
+ final Set<Font> fontSet = new HashSet<Font>();
+ return fontSet;
+ }
+}
Deleted:
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/property/IntegerTwoDVisualProperty.java
===================================================================
---
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/property/IntegerTwoDVisualProperty.java
2011-06-10 00:43:50 UTC (rev 25700)
+++
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/property/IntegerTwoDVisualProperty.java
2011-06-10 00:47:43 UTC (rev 25701)
@@ -1,58 +0,0 @@
-
-/*
- Copyright (c) 2008, The Cytoscape Consortium (www.cytoscape.org)
-
- The Cytoscape Consortium is:
- - Institute for Systems Biology
- - University of California San Diego
- - Memorial Sloan-Kettering Cancer Center
- - Institut Pasteur
- - Agilent Technologies
-
- This library is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as published
- by the Free Software Foundation; either version 2.1 of the License, or
- any later version.
-
- This library is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
- MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. The software and
- documentation provided hereunder is on an "as is" basis, and the
- Institute for Systems Biology and the Whitehead Institute
- have no obligations to provide maintenance, support,
- updates, enhancements or modifications. In no event shall the
- Institute for Systems Biology and the Whitehead Institute
- be liable to any party for direct, indirect, special,
- incidental or consequential damages, including lost profits, arising
- out of the use of this software and its documentation, even if the
- Institute for Systems Biology and the Whitehead Institute
- have been advised of the possibility of such damage. See
- the GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this library; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
-*/
-package org.cytoscape.view.presentation.property;
-
-import org.cytoscape.view.model.AbstractVisualProperty;
-import org.cytoscape.view.model.ContinuousRange;
-import org.cytoscape.view.model.Range;
-
-public class IntegerTwoDVisualProperty extends AbstractVisualProperty<Integer>
{
-
- private static final Range<Integer> INT_RANGE = new
ContinuousRange<Integer>(Integer.class, Integer.MIN_VALUE, Integer.MAX_VALUE);
-
- public IntegerTwoDVisualProperty(final Integer def, final String id,
final String name, final Class<?> targetDataType) {
- super(def,INT_RANGE, id, name, targetDataType);
- }
-
- public String toSerializableString(final Integer value) {
- return value.toString();
- }
-
- public Integer parseSerializableString(final String text) {
- // Cytoscape 2.x serializes integer attributes as decimals
(e.g."1.0")!
- return Double.valueOf(text).intValue();
- }
-}
Copied:
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/property/IntegerVisualProperty.java
(from rev 25624,
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/property/IntegerTwoDVisualProperty.java)
===================================================================
---
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/property/IntegerVisualProperty.java
(rev 0)
+++
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/property/IntegerVisualProperty.java
2011-06-10 00:47:43 UTC (rev 25701)
@@ -0,0 +1,63 @@
+/*
+ Copyright (c) 2008, The Cytoscape Consortium (www.cytoscape.org)
+
+ The Cytoscape Consortium is:
+ - Institute for Systems Biology
+ - University of California San Diego
+ - Memorial Sloan-Kettering Cancer Center
+ - Institut Pasteur
+ - Agilent Technologies
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of the License, or
+ any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
+ MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. The software and
+ documentation provided hereunder is on an "as is" basis, and the
+ Institute for Systems Biology and the Whitehead Institute
+ have no obligations to provide maintenance, support,
+ updates, enhancements or modifications. In no event shall the
+ Institute for Systems Biology and the Whitehead Institute
+ be liable to any party for direct, indirect, special,
+ incidental or consequential damages, including lost profits, arising
+ out of the use of this software and its documentation, even if the
+ Institute for Systems Biology and the Whitehead Institute
+ have been advised of the possibility of such damage. See
+ the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this library; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+package org.cytoscape.view.presentation.property;
+
+import org.cytoscape.view.model.AbstractVisualProperty;
+import org.cytoscape.view.model.Range;
+
+public class IntegerVisualProperty extends AbstractVisualProperty<Integer> {
+
+ /**
+ * Use specific range
+ * @param def
+ * @param id
+ * @param name
+ * @param targetDataType
+ * @param range
+ */
+ public IntegerVisualProperty(final Integer def, final Range<Integer>
range, final String id, final String name,
+ final Class<?> targetDataType) {
+ super(def, range, id, name, targetDataType);
+ }
+
+ public String toSerializableString(final Integer value) {
+ return value.toString();
+ }
+
+ public Integer parseSerializableString(final String text) {
+ // Cytoscape 2.x serializes integer attributes as decimals
(e.g."1.0")!
+ return Double.valueOf(text).intValue();
+ }
+}
Modified:
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/property/MinimalVisualLexicon.java
===================================================================
---
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/property/MinimalVisualLexicon.java
2011-06-10 00:43:50 UTC (rev 25700)
+++
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/property/MinimalVisualLexicon.java
2011-06-10 00:47:43 UTC (rev 25701)
@@ -62,7 +62,7 @@
protected static final Color MIN_COLOR = new Color(0, 0, 0);
protected static final Color MAX_COLOR = new Color(0xFF, 0xFF, 0xFF);
protected static final Range<Paint> PAINT_RANGE = new
ContinuousRange<Paint>(
- Paint.class, MIN_COLOR, MAX_COLOR);
+ Paint.class, MIN_COLOR, MAX_COLOR, true, true);
protected static final Set<String> STRING_SET = new HashSet<String>();
// This will be used to for String VP which accepts any string values.
@@ -70,7 +70,7 @@
String.class, STRING_SET);
protected static final Range<Double> ARBITRARY_DOUBLE_RANGE = new
ContinuousRange<Double>(
- Double.class, Double.NEGATIVE_INFINITY,
Double.POSITIVE_INFINITY);
+ Double.class, Double.NEGATIVE_INFINITY,
Double.POSITIVE_INFINITY, true, true);
protected static final Range<Double> NONE_ZERO_POSITIVE_DOUBLE_RANGE =
new ContinuousRange<Double>(
Double.class, 0d, Double.POSITIVE_INFINITY, false,
true);
Modified:
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/property/RichVisualLexicon.java
===================================================================
---
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/property/RichVisualLexicon.java
2011-06-10 00:43:50 UTC (rev 25700)
+++
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/property/RichVisualLexicon.java
2011-06-10 00:47:43 UTC (rev 25701)
@@ -7,6 +7,7 @@
import org.cytoscape.model.CyEdge;
import org.cytoscape.model.CyNetwork;
import org.cytoscape.model.CyNode;
+import org.cytoscape.view.model.ContinuousRange;
import org.cytoscape.view.model.NullDataType;
import org.cytoscape.view.model.VisualProperty;
import org.cytoscape.view.presentation.property.values.LineType;
@@ -61,27 +62,27 @@
"", MinimalVisualLexicon.ARBITRARY_STRING_RANGE,
"NODE_TOOLTIP",
"Node Tooltip", CyNode.class);
- public static final VisualProperty<Font> NODE_LABEL_FONT_FACE = new
FontTwoDVisualProperty(
+ public static final VisualProperty<Font> NODE_LABEL_FONT_FACE = new
FontVisualProperty(
new Font("SansSerif", Font.PLAIN, DEF_FONT_SIZE),
"NODE_LABEL_FONT_FACE", "Node Label Font Face",
CyNode.class);
- public static final VisualProperty<Integer> NODE_LABEL_FONT_SIZE = new
IntegerTwoDVisualProperty(
- DEF_FONT_SIZE, "NODE_LABEL_FONT_SIZE", "Node Label Font
Size",
- CyNode.class);
+ public static final VisualProperty<Integer> NODE_LABEL_FONT_SIZE = new
IntegerVisualProperty(DEF_FONT_SIZE,
+ new ContinuousRange<Integer>(Integer.class, 1,
Integer.MAX_VALUE, true, true), "NODE_LABEL_FONT_SIZE",
+ "Node Label Font Size", CyNode.class);
- public static final VisualProperty<Integer> NODE_TRANSPARENCY = new
IntegerTwoDVisualProperty(
- 200, "NODE_TRANSPARENCY", "Node Transparency",
CyNode.class);
-
+ public static final VisualProperty<Integer> NODE_TRANSPARENCY = new
IntegerVisualProperty(200,
+ new ContinuousRange<Integer>(Integer.class, 0, 255,
true, true), "NODE_TRANSPARENCY", "Node Transparency", CyNode.class);
+
public static final VisualProperty<String> EDGE_TOOLTIP = new
StringVisualProperty(
"", MinimalVisualLexicon.ARBITRARY_STRING_RANGE,
"EDGE_TOOLTIP",
"Edge Tooltip", CyEdge.class);
- public static final VisualProperty<Font> EDGE_LABEL_FONT_FACE = new
FontTwoDVisualProperty(
+ public static final VisualProperty<Font> EDGE_LABEL_FONT_FACE = new
FontVisualProperty(
new Font("SansSerif", Font.PLAIN, 10),
"EDGE_LABEL_FONT_FACE",
"Edge Label Font Face", CyEdge.class);
- public static final VisualProperty<Integer> EDGE_LABEL_FONT_SIZE = new
IntegerTwoDVisualProperty(
- 10, "EDGE_LABEL_FONT_SIZE", "Edge Label Font Size",
CyEdge.class);
+ public static final VisualProperty<Integer> EDGE_LABEL_FONT_SIZE = new
IntegerVisualProperty(10,
+ new ContinuousRange<Integer>(Integer.class, 1,
Integer.MAX_VALUE, true, true), "EDGE_LABEL_FONT_SIZE",
+ "Edge Label Font Size", CyEdge.class);
-
public static final VisualProperty<Paint> EDGE_SELECTED_PAINT = new
PaintVisualProperty(
Color.RED, MinimalVisualLexicon.PAINT_RANGE,
"EDGE_SELECTED_PAINT",
"Edge Selected Paint", CyEdge.class);
Modified: core3/viewmodel-api/trunk/pom.xml
===================================================================
--- core3/viewmodel-api/trunk/pom.xml 2011-06-10 00:43:50 UTC (rev 25700)
+++ core3/viewmodel-api/trunk/pom.xml 2011-06-10 00:47:43 UTC (rev 25701)
@@ -113,7 +113,7 @@
<dependency>
<groupId>org.cytoscape</groupId>
<artifactId>model-api</artifactId>
- <version>3.0.0-alpha4</version>
+ <version>3.0.0-alpha5-SNAPSHOT</version>
</dependency>
<!-- unit tests -->
Modified:
core3/viewmodel-api/trunk/src/main/java/org/cytoscape/view/model/ContinuousRange.java
===================================================================
---
core3/viewmodel-api/trunk/src/main/java/org/cytoscape/view/model/ContinuousRange.java
2011-06-10 00:43:50 UTC (rev 25700)
+++
core3/viewmodel-api/trunk/src/main/java/org/cytoscape/view/model/ContinuousRange.java
2011-06-10 00:47:43 UTC (rev 25701)
@@ -10,10 +10,7 @@
private final Boolean includeMin;
private final Boolean includeMax;
- public ContinuousRange(final Class<T> type, final T min, final T max) {
- this(type, min, max, true, true);
- }
-
+
public ContinuousRange(final Class<T> type, final T min, final T max,
final Boolean includeMin, final Boolean includeMax) {
this.type = type;
this.min = min;
@@ -51,4 +48,44 @@
return includeMax;
}
+ @Override
+ public boolean validate(T value) {
+ // By default, treat T as number. Otherwise, it should be
implemented by developer.
+ if(value instanceof Number && min instanceof Number && max
instanceof Number) {
+ return validateNumber((Number)value, (Number)min,
(Number)max);
+ } else {
+ return true;
+ }
+
+ }
+
+
+ private boolean validateNumber(final Number value, final Number
minNumber, final Number maxNumber) {
+ final double testValue = value.doubleValue();
+ final double doubleMin = minNumber.doubleValue();
+ final double doubleMax = maxNumber.doubleValue();
+
+ if(includeMax && includeMin) {
+ if(doubleMin <= testValue && doubleMax >= testValue )
+ return true;
+ else
+ return false;
+ } else if(includeMax == false && includeMin == false) {
+ if(doubleMin < testValue && doubleMax > testValue )
+ return true;
+ else
+ return false;
+ } else if(includeMax == false && includeMin) {
+ if(doubleMin <= testValue && doubleMax > testValue )
+ return true;
+ else
+ return false;
+ } else {
+ if(doubleMin < testValue && doubleMax >= testValue )
+ return true;
+ else
+ return false;
+ }
+ }
+
}
Modified:
core3/viewmodel-api/trunk/src/main/java/org/cytoscape/view/model/DiscreteRange.java
===================================================================
---
core3/viewmodel-api/trunk/src/main/java/org/cytoscape/view/model/DiscreteRange.java
2011-06-10 00:43:50 UTC (rev 25700)
+++
core3/viewmodel-api/trunk/src/main/java/org/cytoscape/view/model/DiscreteRange.java
2011-06-10 00:47:43 UTC (rev 25701)
@@ -32,4 +32,12 @@
values.add(newValue);
}
+ @Override
+ public boolean validate(T value) {
+ if(values.contains(value))
+ return true;
+ else
+ return false;
+ }
+
}
Modified:
core3/viewmodel-api/trunk/src/main/java/org/cytoscape/view/model/Range.java
===================================================================
--- core3/viewmodel-api/trunk/src/main/java/org/cytoscape/view/model/Range.java
2011-06-10 00:43:50 UTC (rev 25700)
+++ core3/viewmodel-api/trunk/src/main/java/org/cytoscape/view/model/Range.java
2011-06-10 00:47:43 UTC (rev 25701)
@@ -1,9 +1,16 @@
package org.cytoscape.view.model;
public interface Range<T> {
+
+ /**
+ * Type of object used in this range.
+ *
+ * @return object type.
+ */
Class<T> getType();
+
/**
* If this range is a set of discrete values, return true.
*
@@ -11,4 +18,14 @@
*
*/
boolean isDiscrete();
+
+
+ /**
+ * Return true if the given value is in the range defined in this class.
+ *
+ * @param value any value to be tested.
+ *
+ * @return true if the given value is in the range.
+ */
+ boolean validate(final T value);
}
Added:
core3/viewmodel-api/trunk/src/test/java/org/cytoscape/view/model/ContinuousRangeTest.java
===================================================================
---
core3/viewmodel-api/trunk/src/test/java/org/cytoscape/view/model/ContinuousRangeTest.java
(rev 0)
+++
core3/viewmodel-api/trunk/src/test/java/org/cytoscape/view/model/ContinuousRangeTest.java
2011-06-10 00:47:43 UTC (rev 25701)
@@ -0,0 +1,41 @@
+package org.cytoscape.view.model;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.awt.Color;
+
+import org.cytoscape.view.model.ContinuousRange;
+import org.junit.Test;
+
+
+public class ContinuousRangeTest {
+
+ @Test
+ public void testContinuousNumberRange() {
+ final ContinuousRange<Double> range1 = new
ContinuousRange<Double>(Double.class, 0.0d, 100.0d, true, true);
+ assertTrue(range1.validate(3.0));
+ assertTrue(range1.validate(0.0));
+ assertTrue(range1.validate(100.0));
+ assertFalse(range1.validate(200.0));
+ assertFalse(range1.validate(100.001));
+ assertFalse(range1.validate(-1.2));
+
+ final ContinuousRange<Double> range2 = new
ContinuousRange<Double>(Double.class, 0.0d, 100.0d, false, false);
+ assertFalse(range2.validate(0.0));
+ assertFalse(range2.validate(100.0));
+
+ final ContinuousRange<Double> range3 = new
ContinuousRange<Double>(Double.class, 0.0d, 100.0d, false, true);
+ assertFalse(range3.validate(0.0));
+ assertTrue(range3.validate(100.0));
+
+ final ContinuousRange<Double> range4 = new
ContinuousRange<Double>(Double.class, 0.0d, 100.0d, true, false);
+ assertTrue(range4.validate(0.0));
+ assertFalse(range4.validate(100.0));
+
+ final ContinuousRange<Color> colorRange = new
ContinuousRange<Color>(Color.class, Color.BLACK, Color.yellow, false, false);
+ // Need to define its own validator
+ assertTrue(colorRange.validate(new Color(10, 100, 10)));
+ }
+
+}
Added:
core3/viewmodel-api/trunk/src/test/java/org/cytoscape/view/model/DiscreteRangeTest.java
===================================================================
---
core3/viewmodel-api/trunk/src/test/java/org/cytoscape/view/model/DiscreteRangeTest.java
(rev 0)
+++
core3/viewmodel-api/trunk/src/test/java/org/cytoscape/view/model/DiscreteRangeTest.java
2011-06-10 00:47:43 UTC (rev 25701)
@@ -0,0 +1,42 @@
+package org.cytoscape.view.model;
+
+import static org.junit.Assert.*;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.junit.Test;
+
+
+public class DiscreteRangeTest {
+
+
+ @Test
+ public void testDiscreteRange() {
+
+ final Set<String> rangeValues = new HashSet<String>();
+ rangeValues.add("a");
+ rangeValues.add("b");
+ rangeValues.add("c");
+ rangeValues.add("d");
+ rangeValues.add("e");
+ rangeValues.add("foo");
+
+ final DiscreteRange<String> range1 = new
DiscreteRange<String>(String.class, rangeValues);
+
+ assertEquals(6, range1.values().size());
+ assertTrue(range1.validate("a"));
+ assertTrue(range1.validate("b"));
+ assertTrue(range1.validate("c"));
+ assertTrue(range1.validate("d"));
+ assertTrue(range1.validate("e"));
+ assertFalse(range1.validate("f"));
+ assertTrue(range1.validate("foo"));
+
+ range1.addRangeValue("f");
+ assertEquals(7, range1.values().size());
+ assertTrue(range1.validate("f"));
+
+ }
+
+}
Modified:
core3/viewmodel-api/trunk/src/test/java/org/cytoscape/view/model/IntegerVisualProperty.java
===================================================================
---
core3/viewmodel-api/trunk/src/test/java/org/cytoscape/view/model/IntegerVisualProperty.java
2011-06-10 00:43:50 UTC (rev 25700)
+++
core3/viewmodel-api/trunk/src/test/java/org/cytoscape/view/model/IntegerVisualProperty.java
2011-06-10 00:47:43 UTC (rev 25701)
@@ -40,7 +40,7 @@
class IntegerVisualProperty extends AbstractVisualProperty<Integer> {
- private static final ContinuousRange<Integer> cRange = new
ContinuousRange<Integer>(Integer.class, -10, 10);
+ private static final ContinuousRange<Integer> cRange = new
ContinuousRange<Integer>(Integer.class, -10, 10, true, true);
public IntegerVisualProperty() {
Modified: core3/viewmodel-impl/trunk/pom.xml
===================================================================
--- core3/viewmodel-impl/trunk/pom.xml 2011-06-10 00:43:50 UTC (rev 25700)
+++ core3/viewmodel-impl/trunk/pom.xml 2011-06-10 00:47:43 UTC (rev 25701)
@@ -74,7 +74,7 @@
<dependency>
<groupId>org.cytoscape</groupId>
<artifactId>viewmodel-api</artifactId>
- <version>3.0.0-alpha4</version>
+ <version>3.0.0-alpha5-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
@@ -124,7 +124,7 @@
<dependency>
<groupId>org.cytoscape</groupId>
<artifactId>viewmodel-api</artifactId>
- <version>3.0.0-alpha4</version>
+ <version>3.0.0-alpha5-SNAPSHOT</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
Modified: core3/vizmap-api/trunk/pom.xml
===================================================================
--- core3/vizmap-api/trunk/pom.xml 2011-06-10 00:43:50 UTC (rev 25700)
+++ core3/vizmap-api/trunk/pom.xml 2011-06-10 00:47:43 UTC (rev 25701)
@@ -143,7 +143,7 @@
<dependency>
<groupId>org.cytoscape</groupId>
<artifactId>viewmodel-api</artifactId>
- <version>3.0.0-alpha4</version>
+ <version>3.0.0-alpha5-SNAPSHOT</version>
</dependency>
<!-- Testing -->
Modified: core3/vizmap-gui-impl/trunk/pom.xml
===================================================================
--- core3/vizmap-gui-impl/trunk/pom.xml 2011-06-10 00:43:50 UTC (rev 25700)
+++ core3/vizmap-gui-impl/trunk/pom.xml 2011-06-10 00:47:43 UTC (rev 25701)
@@ -103,7 +103,7 @@
<dependency>
<groupId>org.cytoscape</groupId>
<artifactId>vizmap-gui-api</artifactId>
- <version>3.0.0-alpha2</version>
+ <version>3.0.0-alpha3-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.cytoscape</groupId>
Modified:
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/editor/EditorManagerImpl.java
===================================================================
---
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/editor/EditorManagerImpl.java
2011-06-10 00:43:50 UTC (rev 25700)
+++
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/editor/EditorManagerImpl.java
2011-06-10 00:47:43 UTC (rev 25701)
@@ -44,6 +44,7 @@
import java.util.Map;
import java.util.Set;
+import javax.swing.JOptionPane;
import javax.swing.table.TableCellRenderer;
import org.cytoscape.model.CyEdge;
@@ -52,6 +53,7 @@
import org.cytoscape.model.CyTableEntry;
import org.cytoscape.model.CyTableManager;
import org.cytoscape.session.CyApplicationManager;
+import org.cytoscape.view.model.ContinuousRange;
import org.cytoscape.view.model.DiscreteRange;
import org.cytoscape.view.model.Range;
import org.cytoscape.view.model.VisualLexicon;
@@ -174,48 +176,37 @@
this.editors.put(ve.getType(), ve);
}
- /*
- * (non-Javadoc)
- *
- * @see
org.cytoscape.application.swing.vizmap.gui.editors.EditorFactory#
- * removeEditorDisplayer(
- * org.cytoscape.application.swing.vizmap.gui.editors.EditorDisplayer,
- * java.util.Map)
- */
+
public void removeVisualPropertyEditor(VisualPropertyEditor<?> vpEditor,
@SuppressWarnings("rawtypes") Map properties) {
logger.debug("************* Removing VP Editor
****************");
editors.remove(vpEditor.getType());
}
- // private <T> VisualPropertyEditor<T> findEditor(VisualProperty<T>
type) {
- // final Class<T> dataType = type.getType();
- //
- // for (VisualPropertyEditor<?> disp : displayers)
- // if ((dataType == disp.getVisualProperty().getType()))
- // return disp;
- //
- // throw new NullPointerException("no editor displayer found for: "
- // + type.toString());
- // }
- /*
- * (non-Javadoc)
- *
- * @see
org.cytoscape.application.swing.vizmap.gui.editors.EditorFactory#
- * showDiscreteEditor(java .awt.Component,
- * org.cytoscape.application.swing.viewmodel.VisualProperty)
- */
- @SuppressWarnings("unchecked")
- public <V> V showVisualPropertyValueEditor(Component parentComponent,
VisualProperty<V> type, V initialValue)
+ @Override
+ public <V> V showVisualPropertyValueEditor(final Component
parentComponent, final VisualProperty<V> type, V initialValue)
throws Exception {
+ @SuppressWarnings("unchecked")
final ValueEditor<V> editor = (ValueEditor<V>)
valueEditors.get(type.getRange().getType());
if (editor == null)
throw new IllegalStateException("No value editor for "
+ type.getDisplayName() + " is available.");
- return editor.showEditor(null, initialValue);
+ while (true) {
+ final V newValue = editor.showEditor(parentComponent,
initialValue);
+ if (type.getRange().validate(newValue))
+ return newValue;
+ else {
+ String message = "Please evter valid value";
+ if(type.getRange() instanceof ContinuousRange)
+ message = message + ": " +
((ContinuousRange)type.getRange()).getMin() + " to " +
((ContinuousRange)type.getRange()).getMax();
+ JOptionPane.showMessageDialog(parentComponent,
message, "Invalid Value",
+ JOptionPane.ERROR_MESSAGE);
+ }
+ }
+
}
/*
Modified:
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/editor/valueeditor/AbstractValueEditor.java
===================================================================
---
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/editor/valueeditor/AbstractValueEditor.java
2011-06-10 00:43:50 UTC (rev 25700)
+++
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/editor/valueeditor/AbstractValueEditor.java
2011-06-10 00:47:43 UTC (rev 25701)
@@ -1,7 +1,5 @@
package org.cytoscape.view.vizmap.gui.internal.editor.valueeditor;
-import java.awt.Component;
-
import javax.swing.JDialog;
import javax.swing.JOptionPane;
@@ -25,7 +23,4 @@
@Override public Class<V> getType() {
return type;
}
-
- @Override public abstract <S extends V> V showEditor(Component parent,
S initialValue);
-
}
Modified: core3/vizmap-impl/trunk/pom.xml
===================================================================
--- core3/vizmap-impl/trunk/pom.xml 2011-06-10 00:43:50 UTC (rev 25700)
+++ core3/vizmap-impl/trunk/pom.xml 2011-06-10 00:47:43 UTC (rev 25701)
@@ -83,7 +83,7 @@
<dependency>
<groupId>org.cytoscape</groupId>
<artifactId>viewmodel-api</artifactId>
- <version>3.0.0-alpha4</version>
+ <version>3.0.0-alpha5-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
--
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.