Author: kono
Date: 2011-05-24 16:40:41 -0700 (Tue, 24 May 2011)
New Revision: 25518

Modified:
   
core3/default-mappingcalculators/trunk/src/main/java/org/cytoscape/view/vizmap/mappings/DiscreteMapping.java
Log:
Default colors had been changed.

Modified: 
core3/default-mappingcalculators/trunk/src/main/java/org/cytoscape/view/vizmap/mappings/DiscreteMapping.java
===================================================================
--- 
core3/default-mappingcalculators/trunk/src/main/java/org/cytoscape/view/vizmap/mappings/DiscreteMapping.java
        2011-05-24 21:47:21 UTC (rev 25517)
+++ 
core3/default-mappingcalculators/trunk/src/main/java/org/cytoscape/view/vizmap/mappings/DiscreteMapping.java
        2011-05-24 23:40:41 UTC (rev 25518)
@@ -48,127 +48,127 @@
  */
 public class DiscreteMapping<K, V> extends AbstractVisualMappingFunction<K, V> 
{
 
-    private static final Logger logger = 
LoggerFactory.getLogger(DiscreteMapping.class);
+       private static final Logger logger = 
LoggerFactory.getLogger(DiscreteMapping.class);
 
-    // Name of mapping. This will be used by toString() method.
-    protected static final String DISCRETE = "Discrete Mapping";
+       // Name of mapping. This will be used by toString() method.
+       protected static final String DISCRETE = "Discrete Mapping";
 
-    // contains the actual map elements (sorted)
-    private final Map<K, V> attribute2visualMap;
+       // contains the actual map elements (sorted)
+       private final Map<K, V> attribute2visualMap;
 
-    /**
-     * Constructor.
-     * 
-     * @param defObj
-     *            Default Object.
-     */
-    public DiscreteMapping(final String attrName, final Class<K> attrType, 
final VisualProperty<V> vp) {
-       super(attrName, attrType, vp);
-       attribute2visualMap = new HashMap<K, V>();
-    }
+       /**
+        * Constructor.
+        * 
+        * @param defObj
+        *            Default Object.
+        */
+       public DiscreteMapping(final String attrName, final Class<K> attrType, 
final VisualProperty<V> vp) {
+               super(attrName, attrType, vp);
+               attribute2visualMap = new HashMap<K, V>();
+       }
 
-    @Override
-    public String toString() {
-       return DISCRETE;
-    }
+       @Override
+       public String toString() {
+               return DISCRETE;
+       }
 
-    @Override
-    public void apply(View<? extends CyTableEntry> view) {
-       if (view == null)
-           return; // empty view, nothing to do
+       @Override
+       public void apply(View<? extends CyTableEntry> view) {
+               if (view == null)
+                       return; // empty view, nothing to do
 
-       applyDiscreteMapping(view);
-    }
+               applyDiscreteMapping(view);
+       }
 
-    /**
-     * Read attribute from row, map it and apply it.
-     * 
-     * types are guaranteed to be correct (? FIXME: check this)
-     * 
-     * Putting this in a separate method makes it possible to make it
-     * type-parametric.
-     * 
-     * @param <V>
-     *            the type-parameter of the ViewColumn column
-     * @param <K>
-     *            the type-parameter of the key stored in the mapping (the
-     *            object read as an attribute value has to be is-a K)
-     * @param <V>
-     *            the type-parameter of the View
-     */
-    private void applyDiscreteMapping(final View<? extends CyTableEntry> view) 
{
-       final CyRow row = view.getModel().getCyRow();
-       V value = null;
+       /**
+        * Read attribute from row, map it and apply it.
+        * 
+        * types are guaranteed to be correct (? FIXME: check this)
+        * 
+        * Putting this in a separate method makes it possible to make it
+        * type-parametric.
+        * 
+        * @param <V>
+        *            the type-parameter of the ViewColumn column
+        * @param <K>
+        *            the type-parameter of the key stored in the mapping (the
+        *            object read as an attribute value has to be is-a K)
+        * @param <V>
+        *            the type-parameter of the View
+        */
+       private void applyDiscreteMapping(final View<? extends CyTableEntry> 
view) {
+               final CyRow row = view.getModel().getCyRow();
+               V value = null;
 
-       if (row.isSet(attrName)) {
-           // skip Views where source attribute is not defined;
-           // ViewColumn will automatically substitute the per-VS or global
-           // default, as appropriate
-           final CyColumn column = row.getTable().getColumn(attrName);
-           final Class<?> attrClass = column.getType();
+               if (row.isSet(attrName)) {
+                       // skip Views where source attribute is not defined;
+                       // ViewColumn will automatically substitute the per-VS 
or global
+                       // default, as appropriate
+                       final CyColumn column = 
row.getTable().getColumn(attrName);
+                       final Class<?> attrClass = column.getType();
 
-           if (attrClass.isAssignableFrom(List.class)) {
-               List<?> list = row.getList(attrName, 
column.getListElementType());
+                       if (attrClass.isAssignableFrom(List.class)) {
+                               List<?> list = row.getList(attrName, 
column.getListElementType());
 
-               if (list != null) {
-                   for (Object item : list) {
-                       // TODO: should we convert other types to String?
-                       String key = item.toString();
-                       value = attribute2visualMap.get(key);
-                       if (value != null)
-                           break;
-                   }
+                               if (list != null) {
+                                       for (Object item : list) {
+                                               // TODO: should we convert 
other types to String?
+                                               String key = item.toString();
+                                               value = 
attribute2visualMap.get(key);
+                                               if (value != null)
+                                                       break;
+                                       }
+                               }
+                       } else {
+                               Object key = row.get(attrName, attrType);
+
+                               if (key != null)
+                                       value = attribute2visualMap.get(key);
+                       }
                }
-           } else {
-               Object key = row.get(attrName, attrType);
 
-               if (key != null)
-                   value = attribute2visualMap.get(key);
-           }
+               // set a new value or null to use the default one:
+               view.setVisualProperty(vp, value);
        }
 
-       // set a new value or null to use the default one:
-       view.setVisualProperty(vp, value);
-    }
+       /**
+        * Gets Value for Specified Key.
+        * 
+        * @param key
+        *            String Key.
+        * @return Object.
+        */
+       public V getMapValue(K key) {
+               return attribute2visualMap.get(key);
+       }
 
-    /**
-     * Gets Value for Specified Key.
-     * 
-     * @param key
-     *            String Key.
-     * @return Object.
-     */
-    public V getMapValue(K key) {
-       return attribute2visualMap.get(key);
-    }
+       /**
+        * Puts New Key/Value in Map.
+        * 
+        * @param key
+        *            Key Object.
+        * @param value
+        *            Value Object.
+        */
+       public <T extends V> void putMapValue(final K key, final T value) {
+               attribute2visualMap.put(key, value);
+       }
 
-    /**
-     * Puts New Key/Value in Map.
-     * 
-     * @param key
-     *            Key Object.
-     * @param value
-     *            Value Object.
-     */
-    public <T extends V> void putMapValue(final K key, final T value) {
-       attribute2visualMap.put(key, value);
-    }
+       /**
+        * Adds All Members of Specified Map.
+        * 
+        * @param map
+        *            Map.
+        */
+       public <T extends V> void putAll(Map<K, T> map) {
+               attribute2visualMap.putAll(map);
+       }
 
-    /**
-     * Adds All Members of Specified Map.
-     * 
-     * @param map
-     *            Map.
-     */
-    public <T extends V> void putAll(Map<K, T> map) {
-       attribute2visualMap.putAll(map);
-    }
-
-    /**
-     * gets all map values
-     * 
-     */
-    public Map<K, V> getAll() {
-       return attribute2visualMap;
-    }
+       /**
+        * gets all map values
+        * 
+        */
+       public Map<K, V> getAll() {
+               return attribute2visualMap;
+       }
 }

-- 
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.

Reply via email to