Author: kono
Date: 2012-05-07 19:18:51 -0700 (Mon, 07 May 2012)
New Revision: 29143
Modified:
core3/impl/trunk/vizmap-impl/impl/src/main/java/org/cytoscape/view/vizmap/internal/AbstractApplyHandler.java
Log:
Fixed #958 Bypass problem fixed.
Modified:
core3/impl/trunk/vizmap-impl/impl/src/main/java/org/cytoscape/view/vizmap/internal/AbstractApplyHandler.java
===================================================================
---
core3/impl/trunk/vizmap-impl/impl/src/main/java/org/cytoscape/view/vizmap/internal/AbstractApplyHandler.java
2012-05-07 23:27:46 UTC (rev 29142)
+++
core3/impl/trunk/vizmap-impl/impl/src/main/java/org/cytoscape/view/vizmap/internal/AbstractApplyHandler.java
2012-05-08 02:18:51 UTC (rev 29143)
@@ -1,12 +1,16 @@
package org.cytoscape.view.vizmap.internal;
import java.util.Collection;
+import java.util.Set;
import org.cytoscape.model.CyIdentifiable;
import org.cytoscape.model.CyRow;
import org.cytoscape.view.model.View;
+import org.cytoscape.view.model.VisualLexicon;
+import org.cytoscape.view.model.VisualLexiconNode;
import org.cytoscape.view.model.VisualProperty;
import org.cytoscape.view.vizmap.VisualMappingFunction;
+import org.cytoscape.view.vizmap.VisualPropertyDependency;
import org.cytoscape.view.vizmap.VisualStyle;
public abstract class AbstractApplyHandler<T extends CyIdentifiable>
implements ApplyHandler<T> {
@@ -14,32 +18,85 @@
protected final VisualStyle style;
protected final VisualLexiconManager lexManager;
+ private VisualLexicon lex;
+ private Set<VisualPropertyDependency<?>> dependencies;
+
AbstractApplyHandler(final VisualStyle style, final
VisualLexiconManager lexManager) {
this.lexManager = lexManager;
this.style = style;
}
-
protected void applyValues(final CyRow row, final View<T> view, final
Collection<VisualProperty<?>> vps) {
for (final VisualProperty<?> vp : vps) {
// check mapping exists or not
final VisualMappingFunction<?, ?> mapping =
style.getVisualMappingFunction(vp);
- if (mapping != null) {
+
+ if (mapping != null)
applyMappedValue(row, view, vp, mapping);
- continue;
- }
- Object defaultValue = style.getDefaultValue(vp);
+ else
+ applyDefaultToView(view, vp);
+ }
- if (defaultValue == null) {
- ((VisualStyleImpl)
style).getStyleDefaults().put(vp, vp.getDefault());
- defaultValue = style.getDefaultValue(vp);
- }
+ override(view);
+ }
- if(!vp.shouldIgnoreDefault())
- view.setVisualProperty(vp, defaultValue);
+ // private void applyDefaultValue(final View<T> view, final
+ // VisualProperty<?> vp) {
+ // Object defaultValue = style.getDefaultValue(vp);
+ //
+ // if (defaultValue == null) {
+ // ((VisualStyleImpl) style).getStyleDefaults().put(vp,
vp.getDefault());
+ // defaultValue = style.getDefaultValue(vp);
+ // }
+ //
+ // if (!vp.shouldIgnoreDefault())
+ // view.setVisualProperty(vp, defaultValue);
+ // }
+
+ private void applyDefaultToView(final View<T> view, final
VisualProperty<?> vp) {
+ final Set<VisualLexicon> lexSet =
lexManager.getAllVisualLexicon();
+ if(lexSet.size() != 0)
+ this.lex = lexSet.iterator().next();
+ final VisualLexiconNode vlNode = lex.getVisualLexiconNode(vp);
+ final Collection<VisualLexiconNode> children =
vlNode.getChildren();
+
+ if (children.size() != 0)
+ return;
+
+ Object defaultValue = style.getDefaultValue(vp);
+
+ if (defaultValue == null) {
+ ((VisualStyleImpl) style).getStyleDefaults().put(vp,
vp.getDefault());
+ defaultValue = style.getDefaultValue(vp);
}
+
+ if (!vp.shouldIgnoreDefault())
+ view.setVisualProperty(vp, defaultValue);
+
}
+ private void override(final View<T> view) {
+ this.dependencies = style.getAllVisualPropertyDependencies();
+ // Override dependency
+ for (final VisualPropertyDependency<?> dep : dependencies) {
+ if (dep.isDependencyEnabled()) {
+ final Set<?> vpSet = dep.getVisualProperties();
+ // Pick parent
+ VisualProperty<?> visualProperty =
(VisualProperty<?>) vpSet.iterator().next();
+ final VisualLexiconNode node =
lex.getVisualLexiconNode(visualProperty);
+ final VisualProperty<?> parentVP =
node.getParent().getVisualProperty();
+ Object defaultValue =
style.getDefaultValue(parentVP);
+
+ if (defaultValue == null) {
+ ((VisualStyleImpl)
style).getStyleDefaults().put(visualProperty, visualProperty.getDefault());
+ defaultValue =
style.getDefaultValue(visualProperty);
+ }
+ for (Object vp : vpSet)
+
view.setVisualProperty((VisualProperty<?>) vp, defaultValue);
+ }
+ }
+ }
+
private void applyMappedValue(final CyRow row, final View<T> view,
final VisualProperty<?> vp,
final VisualMappingFunction<?, ?> mapping) {
// Default of this style
--
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.