Author: kono
Date: 2012-07-09 20:02:25 -0700 (Mon, 09 Jul 2012)
New Revision: 29819
Modified:
core3/impl/trunk/io-impl/impl/src/main/java/org/cytoscape/io/internal/util/vizmap/VisualStyleSerializer.java
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/editor/mappingeditor/C2CMappingEditorPanel.java
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/editor/mappingeditor/ContinuousMappingEditorPanel.java
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/editor/mappingeditor/ContinuousTrackRenderer.java
Log:
fixes #1244 Continuous editors had been modified to use correct numerical
values.
Modified:
core3/impl/trunk/io-impl/impl/src/main/java/org/cytoscape/io/internal/util/vizmap/VisualStyleSerializer.java
===================================================================
---
core3/impl/trunk/io-impl/impl/src/main/java/org/cytoscape/io/internal/util/vizmap/VisualStyleSerializer.java
2012-07-10 01:50:42 UTC (rev 29818)
+++
core3/impl/trunk/io-impl/impl/src/main/java/org/cytoscape/io/internal/util/vizmap/VisualStyleSerializer.java
2012-07-10 03:02:25 UTC (rev 29819)
@@ -257,20 +257,20 @@
}
@SuppressWarnings("unchecked")
- private <K, V> void createVizmapProperties(VisualStyle vs,
-
VisualProperty<Visualizable> root,
-
List<org.cytoscape.io.internal.util.vizmap.model.VisualProperty>
vpModelList) {
- Collection<VisualProperty<?>> vpList =
lexicon.getAllDescendants(root);
- Iterator<VisualProperty<?>> iter = vpList.iterator();
+ private void createVizmapProperties(VisualStyle vs,
VisualProperty<Visualizable> root,
+
List<org.cytoscape.io.internal.util.vizmap.model.VisualProperty> vpModelList) {
+
+ final Collection<VisualProperty<?>> vpList =
lexicon.getAllDescendants(root);
+ final Iterator<VisualProperty<?>> iter = vpList.iterator();
while (iter.hasNext()) {
- VisualProperty<V> vp = (VisualProperty<V>) iter.next();
+ final VisualProperty<Object> vp =
(VisualProperty<Object>) iter.next();
// NETWORK root includes NODES and EDGES, but we want
to separate the CyNetwork properties!
if (root == BasicVisualLexicon.NETWORK &&
vp.getTargetDataType() != CyNetwork.class) continue;
- V defValue = vs.getDefaultValue(vp);
- VisualMappingFunction<?, V> mapping =
vs.getVisualMappingFunction(vp);
+ Object defValue = vs.getDefaultValue(vp);
+ final VisualMappingFunction<?, ?> mapping =
vs.getVisualMappingFunction(vp);
if (defValue != null || mapping != null) {
org.cytoscape.io.internal.util.vizmap.model.VisualProperty vpModel = new
org.cytoscape.io.internal.util.vizmap.model.VisualProperty();
@@ -288,7 +288,7 @@
}
if (mapping instanceof PassthroughMapping<?,
?>) {
- PassthroughMapping<K, V> pm =
(PassthroughMapping<K, V>) mapping;
+ PassthroughMapping<?, ?> pm =
(PassthroughMapping<?, ?>) mapping;
AttributeType attrType =
toAttributeType(pm.getMappingColumnType());
org.cytoscape.io.internal.util.vizmap.model.PassthroughMapping pmModel = new
org.cytoscape.io.internal.util.vizmap.model.PassthroughMapping();
@@ -298,16 +298,16 @@
vpModel.setPassthroughMapping(pmModel);
} else if (mapping instanceof
DiscreteMapping<?, ?>) {
- DiscreteMapping<K, V> dm =
(DiscreteMapping<K, V>) mapping;
+ DiscreteMapping<?, ?> dm =
(DiscreteMapping<?, ?>) mapping;
AttributeType attrType =
toAttributeType(dm.getMappingColumnType());
org.cytoscape.io.internal.util.vizmap.model.DiscreteMapping dmModel = new
org.cytoscape.io.internal.util.vizmap.model.DiscreteMapping();
dmModel.setAttributeName(dm.getMappingColumnName());
dmModel.setAttributeType(attrType);
- Map<K, V> map = dm.getAll();
+ Map<?, ?> map = dm.getAll();
- for (Map.Entry<?, V> entry :
map.entrySet()) {
+ for (Map.Entry<?, ?> entry :
map.entrySet()) {
DiscreteMappingEntry entryModel
= new DiscreteMappingEntry();
entryModel.setAttributeValue(entry.getKey().toString());
entryModel.setValue(vp.toSerializableString(entry.getValue()));
@@ -318,25 +318,32 @@
vpModel.setDiscreteMapping(dmModel);
} else if (mapping instanceof
ContinuousMapping<?, ?>) {
- ContinuousMapping<K, V> cm =
(ContinuousMapping<K, V>) mapping;
+ final ContinuousMapping<?,?> cm =
(ContinuousMapping<?, ?>) mapping;
AttributeType attrType =
toAttributeType(cm.getMappingColumnType());
org.cytoscape.io.internal.util.vizmap.model.ContinuousMapping cmModel = new
org.cytoscape.io.internal.util.vizmap.model.ContinuousMapping();
cmModel.setAttributeName(cm.getMappingColumnName());
cmModel.setAttributeType(attrType);
- List<ContinuousMappingPoint<K, V>>
points = cm.getAllPoints();
+ List<?> points = cm.getAllPoints();
- for (ContinuousMappingPoint<K, V> p :
points) {
+ for (Object point : points) {
+ ContinuousMappingPoint<?, ?>
continuousPoint = (ContinuousMappingPoint<?, ?>) point;
org.cytoscape.io.internal.util.vizmap.model.ContinuousMappingPoint pModel = new
org.cytoscape.io.internal.util.vizmap.model.ContinuousMappingPoint();
- String sValue =
p.getValue().toString();
- BigDecimal value = new
BigDecimal(sValue);
- V lesser =
p.getRange().lesserValue;
- V equal =
p.getRange().equalValue;
- V greater =
p.getRange().greaterValue;
+ Object originalValue =
continuousPoint.getValue();
+
+ final String sValue =
originalValue.toString();
+ final BigDecimal value = new
BigDecimal(sValue);
+ pModel.setAttrValue(value);
+
+ Object lesser =
continuousPoint.getRange().lesserValue;
+ Object equal =
continuousPoint.getRange().equalValue;
+ Object greater =
continuousPoint.getRange().greaterValue;
+
+//
System.out.println(cm.getVisualProperty().getDisplayName() + ": ***Point is "
+// +
lesser.getClass() + ", " + equal.getClass() +", " + greater.getClass());
- pModel.setAttrValue(value);
pModel.setLesserValue(vp.toSerializableString(lesser));
pModel.setEqualValue(vp.toSerializableString(equal));
pModel.setGreaterValue(vp.toSerializableString(greater));
Modified:
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/editor/mappingeditor/C2CMappingEditorPanel.java
===================================================================
---
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/editor/mappingeditor/C2CMappingEditorPanel.java
2012-07-10 01:50:42 UTC (rev 29818)
+++
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/editor/mappingeditor/C2CMappingEditorPanel.java
2012-07-10 03:02:25 UTC (rev 29819)
@@ -70,16 +70,12 @@
private static final Number FIRST_LOCATION = 10d;
private static final Number SECOND_LOCATION = 30d;
- private final Class<K> columnType;
- private final Class<V> vpValueType;
+
public C2CMappingEditorPanel(final VisualStyle style, final
ContinuousMapping<K, V> mapping, final CyTable attr,
final CyApplicationManager appManager, final
VisualMappingManager vmm) {
super(style, mapping, attr, appManager, vmm);
- columnType = mapping.getMappingColumnType();
- vpValueType = mapping.getVisualProperty().getRange().getType();
-
abovePanel.setVisible(false);
belowPanel.setVisible(false);
@@ -102,33 +98,7 @@
return convert(columnType, value);
}
- private <T> T convert(final Class<T> type, Number value) {
- T converted = null;
- if(type == Double.class) {
- Double doubleValue = value.doubleValue();
- converted = (T) doubleValue;
- } else if(type == Integer.class) {
- Integer intValue = value.intValue();
- converted = (T) intValue;
- } else if(type == Float.class) {
- Float floatValue = value.floatValue();
- converted = (T) floatValue;
- } else if(type == Byte.class) {
- Byte byteValue = value.byteValue();
- converted = (T) byteValue;
- } else if(type == Long.class){
- Long longValue = value.longValue();
- converted = (T) longValue;
- } else if(type == Short.class) {
- Short shortValue = value.shortValue();
- converted = (T) shortValue;
- } else {
- throw new IllegalStateException("Could not covert
Number.");
- }
-
- return converted;
- }
-
+
public ImageIcon getIcon(final int iconWidth, final int iconHeight) {
final TrackRenderer rend = slider.getTrackRenderer();
@@ -162,7 +132,7 @@
if (mapping.getPointCount() == 0) {
slider.getModel().addThumb(position.floatValue(),
convertToValue(value));
- newRange = new BoundaryRangeValues<V>(below,
convertToValue(5d), above);
+ newRange = new
BoundaryRangeValues<V>(convertToValue(below), convertToValue(5d),
convertToValue(above));
final K newKey =
convertToColumnValue((maxValue.doubleValue() / 2));
mapping.addPoint(newKey, newRange);
@@ -184,7 +154,7 @@
V equalVal = convertToValue(5d);
V greaterVal = previousRange.greaterValue;
- newRange = new BoundaryRangeValues<V>(lesserVal, equalVal,
greaterVal);
+ newRange = new
BoundaryRangeValues<V>(convertToValue(lesserVal), convertToValue(equalVal),
convertToValue(greaterVal));
mapping.addPoint(maxValue, newRange);
Modified:
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/editor/mappingeditor/ContinuousMappingEditorPanel.java
===================================================================
---
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/editor/mappingeditor/ContinuousMappingEditorPanel.java
2012-07-10 01:50:42 UTC (rev 29818)
+++
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/editor/mappingeditor/ContinuousMappingEditorPanel.java
2012-07-10 03:02:25 UTC (rev 29819)
@@ -117,6 +117,9 @@
protected final VisualStyle style;
final JPanel mainPanel;
+
+ protected final Class<K> columnType;
+ protected final Class<V> vpValueType;
/**
* Creates new form ContinuousMapperEditorPanel Accepts only one visual
property type T.
@@ -140,6 +143,9 @@
this.mainPanel = new JPanel();
this.dataTable = table;
+ columnType = mapping.getMappingColumnType();
+ vpValueType = mapping.getVisualProperty().getRange().getType();
+
final String controllingAttrName =
mapping.getMappingColumnName();
//TODO more error checking
@@ -161,7 +167,35 @@
initRangeValues();
setSpinner();
}
+
+ protected static <T> T convert(final Class<T> type, Number value) {
+ T converted = null;
+ if(type == Double.class) {
+ Double doubleValue = value.doubleValue();
+ converted = (T) doubleValue;
+ } else if(type == Integer.class) {
+ Integer intValue = value.intValue();
+ converted = (T) intValue;
+ } else if(type == Float.class) {
+ Float floatValue = value.floatValue();
+ converted = (T) floatValue;
+ } else if(type == Byte.class) {
+ Byte byteValue = value.byteValue();
+ converted = (T) byteValue;
+ } else if(type == Long.class){
+ Long longValue = value.longValue();
+ converted = (T) longValue;
+ } else if(type == Short.class) {
+ Short shortValue = value.shortValue();
+ converted = (T) shortValue;
+ } else {
+ throw new IllegalStateException("Could not covert
Number.");
+ }
+
+ return converted;
+ }
+
private void setSpinner() {
spinnerModel = new SpinnerNumberModel(0.0d,
Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY, 0.01d);
spinnerModel.addChangeListener(new SpinnerChangeListener());
@@ -520,8 +554,11 @@
V lesserVal = below;
V greaterVal = above;
- mapping.getPoint(0).setRange(new
BoundaryRangeValues<V>(equalVal, lesserVal, greaterVal));
-
+ if(equalVal instanceof Number)
+ mapping.getPoint(0).setRange(new
BoundaryRangeValues<V>(convert(vpValueType, (Number)equalVal),
convert(vpValueType, (Number)lesserVal), convert(vpValueType,
(Number)greaterVal)));
+ else {
+ mapping.getPoint(0).setRange(new
BoundaryRangeValues<V>(equalVal, lesserVal, greaterVal));
+ }
newVal = ((thumbs.get(0).getPosition() / 100) * range)
+ min;
mapping.getPoint(0).setValue((K) newVal);
@@ -550,7 +587,12 @@
greaterVal = (V) t.getObject();
}
- mapping.getPoint(i).setRange(new
BoundaryRangeValues<V>(lesserVal, equalVal, greaterVal));
+ if(equalVal instanceof Number)
+ mapping.getPoint(i).setRange(new
BoundaryRangeValues<V>(convert(vpValueType, (Number)equalVal),
convert(vpValueType, (Number)lesserVal), convert(vpValueType,
(Number)greaterVal)));
+ else {
+ mapping.getPoint(i).setRange(new
BoundaryRangeValues<V>(equalVal, lesserVal, greaterVal));
+ }
+// mapping.getPoint(i).setRange(new
BoundaryRangeValues<V>(lesserVal, equalVal, greaterVal));
newVal = ((t.getPosition() / 100) * range) + min;
mapping.getPoint(i).setValue((K) newVal);
Modified:
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/editor/mappingeditor/ContinuousTrackRenderer.java
===================================================================
---
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/editor/mappingeditor/ContinuousTrackRenderer.java
2012-07-10 01:50:42 UTC (rev 29818)
+++
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/editor/mappingeditor/ContinuousTrackRenderer.java
2012-07-10 03:02:25 UTC (rev 29819)
@@ -127,6 +127,9 @@
private final VisualProperty<V> vp;
private final ContinuousMapping<K, V> cMapping;
+
+ private final Class<V> vpValueType;
+ private final Class<K> columnType;
/**
* Creates a new ContinuousTrackRenderer object.
@@ -156,6 +159,9 @@
this.style = style;
cMapping = mapping;
+ this.columnType = mapping.getMappingColumnType();
+ this.vpValueType =
mapping.getVisualProperty().getRange().getType();
+
title = cMapping.getMappingColumnName();
//TODO: where should I put this property value?
@@ -533,7 +539,9 @@
}
}
- final BoundaryRangeValues<V> brv = new
BoundaryRangeValues<V>(lesserVal, newVal, greaterVal);
+ final BoundaryRangeValues<V> brv = new
BoundaryRangeValues<V>(ContinuousMappingEditorPanel.convert(
+ vpValueType, lesserVal),
ContinuousMappingEditorPanel.convert(vpValueType, newVal),
+
ContinuousMappingEditorPanel.convert(vpValueType, greaterVal));
cMapping.getPoint(selectedIdx).setRange(brv);
}
@@ -592,8 +600,11 @@
}
}
- final BoundaryRangeValues<V> brv = new
BoundaryRangeValues<V>(
- lesserVal, newVal, greaterVal);
+// final BoundaryRangeValues<V> brv = new
BoundaryRangeValues<V>(
+// lesserVal, newVal, greaterVal);
+ final BoundaryRangeValues<V> brv = new
BoundaryRangeValues<V>(ContinuousMappingEditorPanel.convert(
+ vpValueType, lesserVal),
ContinuousMappingEditorPanel.convert(vpValueType, newVal),
+
ContinuousMappingEditorPanel.convert(vpValueType, greaterVal));
cMapping.getPoint(selectedIdx).setRange(brv);
@@ -626,7 +637,10 @@
BoundaryRangeValues<V> original;
original = cMapping.getPoint(0).getRange();
- brv = new BoundaryRangeValues<V>(newValue,
original.equalValue, original.greaterValue);
+// brv = new BoundaryRangeValues<V>(newValue,
original.equalValue, original.greaterValue);
+ brv = new
BoundaryRangeValues<V>(ContinuousMappingEditorPanel.convert(
+ vpValueType, newValue),
ContinuousMappingEditorPanel.convert(vpValueType, original.equalValue),
+
ContinuousMappingEditorPanel.convert(vpValueType, original.greaterValue));
cMapping.getPoint(0).setRange(brv);
@@ -660,7 +674,11 @@
original =
cMapping.getPoint(cMapping.getPointCount() - 1)
.getRange();
- brv = new
BoundaryRangeValues<V>(original.lesserValue,original.equalValue, above);
+// brv = new
BoundaryRangeValues<V>(original.lesserValue,original.equalValue, above);
+ brv = new
BoundaryRangeValues<V>(ContinuousMappingEditorPanel.convert(
+ vpValueType,
original.lesserValue), ContinuousMappingEditorPanel.convert(vpValueType,
original.equalValue),
+
ContinuousMappingEditorPanel.convert(vpValueType, above));
+
cMapping.getPoint(cMapping.getPointCount() -
1).setRange(brv);
// Update view.
--
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.