Author: paperwing
Date: 2012-03-06 15:01:58 -0800 (Tue, 06 Mar 2012)
New Revision: 28444
Modified:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/WindVisualLexicon.java
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/processing/MainCytoscapeDataProcessor.java
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/input/LightMovementInputHandler.java
Log:
Updated WindVisualLexicon with lookup maps and inclusion of light visual
properties into the property tree; added method in MainCytoscapeDataProcessor
to obtain light data from the user-exposed visual properties (the renderer
keeps a layer between the raw visual properties and its calculations); light
basic drag movement is working but not complete (needs to draw a shape to
represent where the light is, needs mechanism to update visual properties after
light is moved)
Modified:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/WindVisualLexicon.java
===================================================================
---
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/WindVisualLexicon.java
2012-03-06 23:00:55 UTC (rev 28443)
+++
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/WindVisualLexicon.java
2012-03-06 23:01:58 UTC (rev 28444)
@@ -5,7 +5,9 @@
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.Range;
import org.cytoscape.view.model.VisualProperty;
import org.cytoscape.view.presentation.property.BooleanVisualProperty;
import org.cytoscape.view.presentation.property.DoubleVisualProperty;
@@ -16,6 +18,10 @@
/** The visual lexicon for the Wind rendering engines */
public class WindVisualLexicon extends BasicVisualLexicon {
+ /** A range from 0.0 to 1.0; useful for values such as color */
+ protected static final Range<Double> ZERO_TO_ONE_DOUBLE_RANGE = new
ContinuousRange<Double>(
+ Double.class, 0.0, 1.0, true, true);
+
/** The root visual property */
public static final VisualProperty<NullDataType> WIND_ROOT = new
NullVisualProperty(
"WIND_ROOT_VISUAL_PROPERTY",
@@ -76,19 +82,19 @@
new Color(255, 255, 255), PAINT_RANGE,
"LIGHT_AMBIENT_COLOR", "Light Ambient Color", CyNetwork.class);
public static final VisualProperty<Double> LIGHT_AMBIENT_ALPHA = new
DoubleVisualProperty(
- 0.0, ARBITRARY_DOUBLE_RANGE, "LIGHT_AMBIENT_ALPHA",
"Light Ambient Alpha", CyNetwork.class);
+ 0.0, ZERO_TO_ONE_DOUBLE_RANGE, "LIGHT_AMBIENT_ALPHA",
"Light Ambient Alpha", CyNetwork.class);
public static final VisualProperty<Paint> LIGHT_DIFFUSE_COLOR = new
PaintVisualProperty(
new Color(255, 255, 255), PAINT_RANGE,
"LIGHT_DIFFUSE_COLOR", "Light Diffuse Color", CyNetwork.class);
public static final VisualProperty<Double> LIGHT_DIFFUSE_ALPHA = new
DoubleVisualProperty(
- 0.0, ARBITRARY_DOUBLE_RANGE, "LIGHT_DIFFUSE_ALPHA",
"Light Diffuse Alpha", CyNetwork.class);
+ 0.0, ZERO_TO_ONE_DOUBLE_RANGE, "LIGHT_DIFFUSE_ALPHA",
"Light Diffuse Alpha", CyNetwork.class);
public static final VisualProperty<Paint> LIGHT_SPECULAR_COLOR = new
PaintVisualProperty(
new Color(255, 255, 255), PAINT_RANGE,
"LIGHT_SPECULAR_COLOR", "Light Specular Color", CyNetwork.class);
public static final VisualProperty<Double> LIGHT_SPECULAR_ALPHA = new
DoubleVisualProperty(
- 0.0, ARBITRARY_DOUBLE_RANGE, "LIGHT_SPECULAR_ALPHA",
"Light Specular Alpha", CyNetwork.class);
+ 0.0, ZERO_TO_ONE_DOUBLE_RANGE, "LIGHT_SPECULAR_ALPHA",
"Light Specular Alpha", CyNetwork.class);
/** Create a new WindVisualLexicon object */
@@ -106,6 +112,19 @@
addVisualProperty(SHOW_NODE_LABELS, NETWORK);
addVisualProperty(SHOW_EDGE_LABELS, NETWORK);
+ // Add light-related visual properties
+ addVisualProperty(LIGHT_X_LOCATION, NETWORK);
+ addVisualProperty(LIGHT_Y_LOCATION, NETWORK);
+ addVisualProperty(LIGHT_Z_LOCATION, NETWORK);
+ addVisualProperty(LIGHT_ENABLED, NETWORK);
+
+ addVisualProperty(LIGHT_AMBIENT_COLOR, NETWORK);
+ addVisualProperty(LIGHT_AMBIENT_ALPHA, NETWORK);
+ addVisualProperty(LIGHT_DIFFUSE_COLOR, NETWORK);
+ addVisualProperty(LIGHT_DIFFUSE_ALPHA, NETWORK);
+ addVisualProperty(LIGHT_SPECULAR_COLOR, NETWORK);
+ addVisualProperty(LIGHT_SPECULAR_ALPHA, NETWORK);
+
createLookupMap();
}
@@ -124,5 +143,18 @@
addIdentifierMapping(CyNetwork.class, "showNodeLabels",
SHOW_NODE_LABELS);
addIdentifierMapping(CyNetwork.class, "showEdgeLabels",
SHOW_EDGE_LABELS);
+
+ // Add lighting-related lookup maps
+ addIdentifierMapping(CyNetwork.class, "lightX",
LIGHT_X_LOCATION);
+ addIdentifierMapping(CyNetwork.class, "lightY",
LIGHT_Y_LOCATION);
+ addIdentifierMapping(CyNetwork.class, "lightZ",
LIGHT_Z_LOCATION);
+ addIdentifierMapping(CyNetwork.class, "lightEnabled",
LIGHT_ENABLED);
+
+ addIdentifierMapping(CyNetwork.class, "lightAmbientColor",
LIGHT_AMBIENT_COLOR);
+ addIdentifierMapping(CyNetwork.class, "lightAmbientAlpha",
LIGHT_AMBIENT_ALPHA);
+ addIdentifierMapping(CyNetwork.class, "lightDiffuseColor",
LIGHT_DIFFUSE_COLOR);
+ addIdentifierMapping(CyNetwork.class, "lightDiffuseAlpha",
LIGHT_DIFFUSE_ALPHA);
+ addIdentifierMapping(CyNetwork.class, "lightSpecularColor",
LIGHT_SPECULAR_COLOR);
+ addIdentifierMapping(CyNetwork.class, "lightSpecularAlpha",
LIGHT_SPECULAR_ALPHA);
}
}
Modified:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/processing/MainCytoscapeDataProcessor.java
===================================================================
---
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/processing/MainCytoscapeDataProcessor.java
2012-03-06 23:00:55 UTC (rev 28443)
+++
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/processing/MainCytoscapeDataProcessor.java
2012-03-06 23:01:58 UTC (rev 28444)
@@ -1,12 +1,16 @@
package org.cytoscape.paperwing.internal.cytoscape.processing;
+import java.awt.Color;
import java.util.Set;
import org.cytoscape.model.CyEdge;
import org.cytoscape.model.CyNetwork;
import org.cytoscape.model.CyNode;
+import org.cytoscape.paperwing.internal.WindVisualLexicon;
import org.cytoscape.paperwing.internal.data.GraphicsData;
import org.cytoscape.paperwing.internal.data.GraphicsSelectionData;
+import org.cytoscape.paperwing.internal.data.LightingData;
+import org.cytoscape.paperwing.internal.lighting.Light;
import org.cytoscape.paperwing.internal.tools.NetworkToolkit;
import org.cytoscape.view.model.CyNetworkView;
@@ -53,7 +57,12 @@
}
}
- // Fills in the missing "selected" boolean values in CyTable
+ // Note: For the below method, Ding does not fill in selected states,
so for now the 3d renderer will not do so either.
+ /**
+ * Fills in the missing "selected" boolean values in CyTable.
+ *
+ * @param graphicsData The {@link GraphicsData} object containing a
reference to the network view.
+ */
private void initializeTableSelectionState(GraphicsData graphicsData) {
CyNetworkView networkView = graphicsData.getNetworkView();
CyNetwork network = graphicsData.getNetworkView().getModel();
@@ -67,4 +76,50 @@
}
}
+ /**
+ * Transfer lighting data from the visual property set
+ */
+ private void updateLightingData(GraphicsData graphicsData) {
+ CyNetworkView networkView = graphicsData.getNetworkView();
+
+ LightingData lightingData = graphicsData.getLightingData();
+
+ // Try to get it working with a single light first (index 0)
+ Light light = lightingData.getLight(0);
+
+ // Transfer color properties
+ Color ambient = (Color)
networkView.getVisualProperty(WindVisualLexicon.LIGHT_AMBIENT_COLOR);
+ double ambientAlpha =
networkView.getVisualProperty(WindVisualLexicon.LIGHT_AMBIENT_ALPHA);
+
+ Color diffuse = (Color)
networkView.getVisualProperty(WindVisualLexicon.LIGHT_DIFFUSE_COLOR);
+ double diffuseAlpha =
networkView.getVisualProperty(WindVisualLexicon.LIGHT_DIFFUSE_ALPHA);
+
+ Color specular = (Color)
networkView.getVisualProperty(WindVisualLexicon.LIGHT_SPECULAR_COLOR);
+ double specularAlpha =
networkView.getVisualProperty(WindVisualLexicon.LIGHT_SPECULAR_ALPHA);
+
+ light.setAmbient((float) ambient.getRed() / 255,
+ (float) ambient.getGreen() / 255,
+ (float) ambient.getBlue() / 255,
+ (float) ambientAlpha);
+
+ light.setDiffuse((float) diffuse.getRed() / 255,
+ (float) diffuse.getGreen() / 255,
+ (float) diffuse.getBlue() / 255,
+ (float) diffuseAlpha);
+
+ light.setSpecular((float) specular.getRed() / 255,
+ (float) specular.getGreen() / 255,
+ (float) specular.getBlue() / 255,
+ (float) specularAlpha);
+
+ // Transfer position properties
+
light.setPosition(networkView.getVisualProperty(WindVisualLexicon.LIGHT_X_LOCATION).floatValue(),
+
networkView.getVisualProperty(WindVisualLexicon.LIGHT_Y_LOCATION).floatValue(),
+
networkView.getVisualProperty(WindVisualLexicon.LIGHT_Z_LOCATION).floatValue(),
+ 1.0f);
+
+ // Transfer remaining properties
+
light.setTurnedOn(networkView.getVisualProperty(WindVisualLexicon.LIGHT_ENABLED));
+ }
+
}
Modified:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/input/LightMovementInputHandler.java
===================================================================
---
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/input/LightMovementInputHandler.java
2012-03-06 23:00:55 UTC (rev 28443)
+++
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/input/LightMovementInputHandler.java
2012-03-06 23:01:58 UTC (rev 28444)
@@ -4,6 +4,7 @@
import org.cytoscape.paperwing.internal.data.GraphicsSelectionData;
import org.cytoscape.paperwing.internal.data.LightingData;
import org.cytoscape.paperwing.internal.geometric.Vector3;
+import org.cytoscape.paperwing.internal.lighting.Light;
import org.cytoscape.paperwing.internal.tools.GeometryToolkit;
import org.cytoscape.paperwing.internal.tools.NetworkToolkit;
import org.cytoscape.paperwing.internal.tools.SimpleCamera;
@@ -40,32 +41,40 @@
SimpleCamera camera = graphicsData.getCamera();
// Currently attempts to move only the light at index 0
- float[] lightPosition = lightingData.getLight(0).getPosition();
- Vector3 lightCurrentPosition = new Vector3(lightPosition[0],
lightPosition[1], lightPosition[2]);
+ Light light = lightingData.getLight(0);
- lightCurrentPosition.divideLocal(lightPosition[3]); // Since
lightPosition contains homogenous coordinates, perform division
+ float[] lightPosition = light.getPosition();
+ Vector3 currentLightPosition = new Vector3(lightPosition[0],
lightPosition[1], lightPosition[2]);
+ currentLightPosition.divideLocal(lightPosition[3]); // Since
lightPosition contains homogenous coordinates, perform division
+
double mouseProjectionDistance =
GeometryToolkit.findOrthogonalDistance(
- camera.getPosition(), lightCurrentPosition,
camera.getDirection());
+ camera.getPosition(), currentLightPosition,
camera.getDirection());
// Capture mouse position
- if (mouse.getPressed().contains(MouseEvent.BUTTON2)) {
+ if (mouse.getPressed().contains(MouseEvent.BUTTON3)) {
- previousMouseProjection.set(
+ currentMouseProjection.set(
GeometryToolkit.convertMouseTo3d(mouse,
graphicsData, mouseProjectionDistance));
}
// Capture new mouse position and use displacement to move
lights
if (mouse.hasMoved()
- && mouse.getHeld().contains(MouseEvent.BUTTON2)
- && keys.getHeld().contains(KeyEvent.VK_SHIFT)) {
+ && mouse.getHeld().contains(MouseEvent.BUTTON3)
+ &&
keys.getHeld().contains(KeyEvent.VK_CONTROL)) {
+ previousMouseProjection.set(currentMouseProjection);
currentMouseProjection.set(
GeometryToolkit.convertMouseTo3d(mouse,
graphicsData, mouseProjectionDistance));
Vector3 displacement =
currentMouseProjection.subtract(previousMouseProjection);
+ Vector3 newLightPosition =
currentLightPosition.plus(displacement);
+ light.setPosition((float) newLightPosition.x(),
+ (float) newLightPosition.y(),
+ (float) newLightPosition.z(),
+ 1.0f);
}
}
}
--
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.