Author: paperwing
Date: 2012-03-27 14:43:44 -0700 (Tue, 27 Mar 2012)
New Revision: 28676
Modified:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/Graphics.java
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/WindBirdsEyeRenderingEngine.java
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/WindMainRenderingEngine.java
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/WindRenderingEngine.java
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/coordinator/BirdsEyeCoordinatorProcessor.java
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/processing/CameraCytoscapeDataSubprocessor.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/cytoscape/processing/TableSelectionCytoscapeDataSubprocessor.java
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/view/WindNetworkView.java
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/input/DragMovementInputHandler.java
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/input/SelectionInputHandler.java
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderArcEdgesProcedure.java
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/tools/NetworkToolkit.java
Log:
fixes #641 The zoom in/out, zoom to extents and selection are now working.
Access to the camera was provided to the network view in order to perform
zooming.
Modified:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/Graphics.java
===================================================================
---
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/Graphics.java
2012-03-27 21:36:10 UTC (rev 28675)
+++
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/Graphics.java
2012-03-27 21:43:44 UTC (rev 28676)
@@ -262,6 +262,7 @@
graphicsData.setAnimatorController(controller);
((WindNetworkView)
graphicsData.getNetworkView()).setAnimatorController(controller);
+ ((WindNetworkView)
graphicsData.getNetworkView()).setNetworkCamera(graphicsData.getCamera());
}
}
Modified:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/WindBirdsEyeRenderingEngine.java
===================================================================
---
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/WindBirdsEyeRenderingEngine.java
2012-03-27 21:36:10 UTC (rev 28675)
+++
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/WindBirdsEyeRenderingEngine.java
2012-03-27 21:43:44 UTC (rev 28676)
@@ -45,8 +45,6 @@
public WindBirdsEyeRenderingEngine(Object container, View<CyNetwork>
viewModel,
VisualLexicon visualLexicon) {
super(container, viewModel, visualLexicon);
-
- System.out.println("Bird's eye rendering engine created: " +
this);
}
@Override
Modified:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/WindMainRenderingEngine.java
===================================================================
---
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/WindMainRenderingEngine.java
2012-03-27 21:36:10 UTC (rev 28675)
+++
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/WindMainRenderingEngine.java
2012-03-27 21:43:44 UTC (rev 28676)
@@ -44,8 +44,6 @@
public WindMainRenderingEngine(Object container, View<CyNetwork>
viewModel,
VisualLexicon visualLexicon) {
super(container, viewModel, visualLexicon);
-
- System.out.println("Main rendering engine created: " + this);
}
@Override
@@ -65,10 +63,8 @@
@Override
public void handleEvent(SetCurrentRenderingEngineEvent
e) {
if (e.getRenderingEngine() == renderingEngine) {
- System.out.println("Current network
view changed, starting animator for " + this + ".");
animator.start();
} else {
- System.out.println("Current network
view changed, stopping animator for " + this + ".");
animator.stop();
}
}
Modified:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/WindRenderingEngine.java
===================================================================
---
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/WindRenderingEngine.java
2012-03-27 21:36:10 UTC (rev 28675)
+++
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/WindRenderingEngine.java
2012-03-27 21:43:44 UTC (rev 28676)
@@ -226,7 +226,6 @@
// System.out.println("Current engine: " +
selfPointer);
if (evt.getNetworkView() == networkView) {
- System.out.println("Rendering engine
about to be removed, stopping animator");
animator.stop();
serviceRegistrar.unregisterService(networkViewDestroyedListener,
NetworkViewAboutToBeDestroyedListener.class);
Modified:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/coordinator/BirdsEyeCoordinatorProcessor.java
===================================================================
---
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/coordinator/BirdsEyeCoordinatorProcessor.java
2012-03-27 21:36:10 UTC (rev 28675)
+++
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/coordinator/BirdsEyeCoordinatorProcessor.java
2012-03-27 21:43:44 UTC (rev 28676)
@@ -126,7 +126,7 @@
*/
- NetworkToolkit.fitInView(camera,
graphicsData.getNetworkView().getNodeViews(), graphicsData.getDistanceScale(),
5.0);
+ NetworkToolkit.fitInView(camera,
graphicsData.getNetworkView().getNodeViews(), graphicsData.getDistanceScale(),
3.0, 5.0);
}
Modified:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/processing/CameraCytoscapeDataSubprocessor.java
===================================================================
---
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/processing/CameraCytoscapeDataSubprocessor.java
2012-03-27 21:36:10 UTC (rev 28675)
+++
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/processing/CameraCytoscapeDataSubprocessor.java
2012-03-27 21:43:44 UTC (rev 28676)
@@ -1,14 +1,28 @@
package org.cytoscape.paperwing.internal.cytoscape.processing;
import org.cytoscape.paperwing.internal.data.GraphicsData;
+import org.cytoscape.view.model.CyNetworkView;
+import org.cytoscape.view.presentation.property.BasicVisualLexicon;
public class CameraCytoscapeDataSubprocessor implements
CytoscapeDataSubprocessor {
@Override
public void processCytoscapeData(GraphicsData graphicsData) {
- // TODO Auto-generated method stub
-
+ // Check if the network's scale factor was changed. If so,
update the camera's position
+
+ CyNetworkView networkView = graphicsData.getNetworkView();
+ double minDifference = 1e-15;
+ double scaleFactor =
networkView.getVisualProperty(BasicVisualLexicon.NETWORK_SCALE_FACTOR);
+
+ if (scaleFactor - minDifference > 1) {
+ graphicsData.getCamera().zoomIn();
+
+ } else if (scaleFactor + minDifference < 1) {
+ graphicsData.getCamera().zoomOut();
+ }
+
+
networkView.setVisualProperty(BasicVisualLexicon.NETWORK_SCALE_FACTOR, 1.0);
}
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-27 21:36:10 UTC (rev 28675)
+++
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/processing/MainCytoscapeDataProcessor.java
2012-03-27 21:43:44 UTC (rev 28676)
@@ -31,6 +31,7 @@
// Populate the list of subprocessors; they are called in the
order added.
subprocessors.add(new
TableSelectionCytoscapeDataSubprocessor());
subprocessors.add(new LightingCytoscapeDataSubprocessor());
+ subprocessors.add(new CameraCytoscapeDataSubprocessor());
}
@Override
Modified:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/processing/TableSelectionCytoscapeDataSubprocessor.java
===================================================================
---
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/processing/TableSelectionCytoscapeDataSubprocessor.java
2012-03-27 21:36:10 UTC (rev 28675)
+++
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/processing/TableSelectionCytoscapeDataSubprocessor.java
2012-03-27 21:43:44 UTC (rev 28676)
@@ -69,6 +69,7 @@
Set<Integer> selectedNodeIndices =
graphicsData.getSelectionData().getSelectedNodeIndices();
Set<Integer> selectedEdgeIndices =
graphicsData.getSelectionData().getSelectedEdgeIndices();
+ // selectedNodeIndices.clear();
List<CyNode> tableSelectedNodes =
CyTableUtil.getNodesInState(networkView.getModel(), "selected", true);
Modified:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/view/WindNetworkView.java
===================================================================
---
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/view/WindNetworkView.java
2012-03-27 21:36:10 UTC (rev 28675)
+++
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/view/WindNetworkView.java
2012-03-27 21:43:44 UTC (rev 28676)
@@ -127,41 +127,33 @@
*/
@Override
public void fitContent() {
- Vector3 networkCenter = NetworkToolkit.findNetworkCenter(this,
1);
+ if (networkCamera != null) {
+ NetworkToolkit.fitInView(networkCamera,
nodeViews.values(), 180.0, 1.9, 2.0);
+ }
- // Shift the nodes to place the center of the network at the
origin
- for (View<CyNode> nodeView : getNodeViews()) {
-
nodeView.setVisualProperty(BasicVisualLexicon.NODE_X_LOCATION,
-
nodeView.getVisualProperty(BasicVisualLexicon.NODE_X_LOCATION) -
networkCenter.x());
-
nodeView.setVisualProperty(BasicVisualLexicon.NODE_Y_LOCATION,
-
nodeView.getVisualProperty(BasicVisualLexicon.NODE_Y_LOCATION) -
networkCenter.y());
-
nodeView.setVisualProperty(BasicVisualLexicon.NODE_Z_LOCATION,
-
nodeView.getVisualProperty(BasicVisualLexicon.NODE_Z_LOCATION) -
networkCenter.z());
+ if (animatorController != null) {
+ animatorController.startAnimator();
}
}
@Override
public void fitSelected() {
// Obtain selected nodes
- Set<Integer> selectedNodeIndices = new HashSet<Integer>();
+ Set<View<CyNode>> selectedNodeViews = new
HashSet<View<CyNode>>();
for (View<CyNode> nodeView : getNodeViews()) {
if
(nodeView.getVisualProperty(BasicVisualLexicon.NODE_SELECTED)) {
-
selectedNodeIndices.add(nodeView.getModel().getIndex());
+ selectedNodeViews.add(nodeView);
}
}
- Vector3 selectionCenter =
NetworkToolkit.findCenter(selectedNodeIndices, this, 1);
-
- // Shift the nodes to place the center of the network at the
center of the selected group of nodes
- for (View<CyNode> nodeView : getNodeViews()) {
-
nodeView.setVisualProperty(BasicVisualLexicon.NODE_X_LOCATION,
-
nodeView.getVisualProperty(BasicVisualLexicon.NODE_X_LOCATION) -
selectionCenter.x());
-
nodeView.setVisualProperty(BasicVisualLexicon.NODE_Y_LOCATION,
-
nodeView.getVisualProperty(BasicVisualLexicon.NODE_Y_LOCATION) -
selectionCenter.y());
-
nodeView.setVisualProperty(BasicVisualLexicon.NODE_Z_LOCATION,
-
nodeView.getVisualProperty(BasicVisualLexicon.NODE_Z_LOCATION) -
selectionCenter.z());
+ if (networkCamera != null) {
+ NetworkToolkit.fitInView(networkCamera,
selectedNodeViews, 180.0, 2.3, 1.8);
}
+
+ if (animatorController != null) {
+ animatorController.startAnimator();
+ }
}
@Override
@@ -174,6 +166,10 @@
// Match the current network view to the currently applied
visual style
// updateToMatchVisualStyle();
+
+ if (animatorController != null) {
+ animatorController.startAnimator();
+ }
}
// Checks if there is a discrepancy between number of nodes and
nodeViews, attempts
Modified:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/input/DragMovementInputHandler.java
===================================================================
---
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/input/DragMovementInputHandler.java
2012-03-27 21:36:10 UTC (rev 28675)
+++
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/input/DragMovementInputHandler.java
2012-03-27 21:43:44 UTC (rev 28676)
@@ -1,11 +1,19 @@
package org.cytoscape.paperwing.internal.input;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.cytoscape.model.CyNode;
+import org.cytoscape.model.CyTableUtil;
import org.cytoscape.paperwing.internal.data.GraphicsData;
import org.cytoscape.paperwing.internal.data.GraphicsSelectionData;
import org.cytoscape.paperwing.internal.geometric.Vector3;
import org.cytoscape.paperwing.internal.tools.GeometryToolkit;
import org.cytoscape.paperwing.internal.tools.NetworkToolkit;
import org.cytoscape.paperwing.internal.tools.SimpleCamera;
+import org.cytoscape.view.model.CyNetworkView;
+import org.cytoscape.view.model.View;
import com.jogamp.newt.event.KeyEvent;
import com.jogamp.newt.event.MouseEvent;
@@ -24,16 +32,23 @@
GraphicsSelectionData selectionData =
graphicsData.getSelectionData();
SimpleCamera camera = graphicsData.getCamera();
+ CyNetworkView networkView = graphicsData.getNetworkView();
- if (selectionData.getSelectedNodeIndices().isEmpty()) {
+ List<CyNode> selectedNodes =
CyTableUtil.getNodesInState(networkView.getModel(), "selected", true);
+ Set<View<CyNode>> selectedNodeViews = new
HashSet<View<CyNode>>(selectedNodes.size());
+
+ for (CyNode node : selectedNodes) {
+ selectedNodeViews.add(networkView.getNodeView(node));
+ }
+
+ System.out.println("Selected node count: " +
selectedNodes.size() + ", " + selectedNodeViews.size());
+
+ if (selectedNodeViews.isEmpty()) {
return;
}
if (mouse.getPressed().contains(MouseEvent.BUTTON1)) {
- Vector3 selectedCenter = NetworkToolkit.findCenter(
- selectionData.getSelectedNodeIndices(),
- graphicsData.getNetworkView(),
- graphicsData.getDistanceScale());
+ Vector3 selectedCenter =
NetworkToolkit.findCenter(selectedNodeViews, graphicsData.getDistanceScale());
selectionData.setSelectProjectionDistance(GeometryToolkit.findOrthogonalDistance(
camera.getPosition(), selectedCenter,
camera.getDirection()));
@@ -52,8 +67,7 @@
Vector3 nodeDisplacement =
selectionData.getCurrentSelectedProjection().subtract(
selectionData.getPreviousSelectedProjection());
-
NetworkToolkit.displaceNodes(selectionData.getSelectedNodeIndices(),
- graphicsData.getNetworkView(),
graphicsData.getDistanceScale(), nodeDisplacement);
+ NetworkToolkit.displaceNodes(selectedNodeViews,
graphicsData.getDistanceScale(), nodeDisplacement);
selectionData.setPreviousSelectedProjection(
selectionData.getCurrentSelectedProjection().copy());
Modified:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/input/SelectionInputHandler.java
===================================================================
---
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/input/SelectionInputHandler.java
2012-03-27 21:36:10 UTC (rev 28675)
+++
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/input/SelectionInputHandler.java
2012-03-27 21:43:44 UTC (rev 28676)
@@ -27,7 +27,7 @@
GraphicsSelectionData selectionData =
graphicsData.getSelectionData();
//TODO: Check whether to have this method here or in
MainCytoscapeDataProcessor
-// processClearToBeDeselected(selectionData);
+ processClearToBeDeselected(selectionData);
processDeselectOther(keys, mouse, graphicsData);
processSingleSelection(keys, mouse, graphicsData);
Modified:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderArcEdgesProcedure.java
===================================================================
---
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderArcEdgesProcedure.java
2012-03-27 21:36:10 UTC (rev 28675)
+++
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderArcEdgesProcedure.java
2012-03-27 21:43:44 UTC (rev 28676)
@@ -85,7 +85,7 @@
for (AugmentedEdgeContainer container : edgeContainers) {
edgeView = container.getEdgeView();
- if (container.isSufficientLength()) {
+ if (container.isSufficientLength() &&
edgeView.getVisualProperty(BasicVisualLexicon.EDGE_VISIBLE)) {
edgeWidth =
edgeView.getVisualProperty(BasicVisualLexicon.EDGE_WIDTH);
Modified:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/tools/NetworkToolkit.java
===================================================================
---
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/tools/NetworkToolkit.java
2012-03-27 21:36:10 UTC (rev 28675)
+++
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/tools/NetworkToolkit.java
2012-03-27 21:43:44 UTC (rev 28676)
@@ -60,16 +60,18 @@
* @param nodeViews The node views to be fit into the current view
* @param distanceScale The distance scaling used to convert between
Cytoscape and render coordinates. Cytoscape coordinates
* are divided by this scale to obtain renderer coordinates.
+ * @param distanceFactor The multiplier against the distance from the
center of the nodes to the farthest node used to place the camera
* @param minDistance The minimum distance between the camera and the
average node position.
*/
- public static void fitInView(SimpleCamera camera,
Collection<View<CyNode>> nodeViews, double distanceScale, double minDistance) {
+ public static void fitInView(SimpleCamera camera,
Collection<View<CyNode>> nodeViews,
+ double distanceScale, double distanceFactor, double
minDistance) {
Vector3 center = NetworkToolkit.findCenter(nodeViews,
distanceScale);
Vector3 farthestNode =
NetworkToolkit.findFarthestNodeFromCenter(nodeViews, center, distanceScale);
double newDistance = farthestNode.distance(center);
// Further increase the distance needed
- newDistance *= 3;
+ newDistance *= distanceFactor;
// Enforce minimum distance
newDistance = Math.max(newDistance, minDistance);
@@ -153,7 +155,7 @@
*/
public static Vector3
findFarthestNodeFromCenter(Collection<View<CyNode>> nodeViews, Vector3
networkCenter, double distanceScale) {
double currentDistanceSquared;
- double maxDistanceSquared = 0;
+ double maxDistanceSquared = -1;
Vector3 currentPosition = new Vector3();
Vector3 maxPosition = new Vector3();
@@ -217,7 +219,33 @@
}
}
+ /**
+ * Moves all of the given nodes by the given displacement vector.
+ *
+ * @param nodeViews The node view objects to move
+ * @param distanceScale The distance scaling used to convert between
Cytoscape and renderer coordinates
+ * @param displacement The displacement vector
+ */
+ public static void displaceNodes(Collection<View<CyNode>> nodeViews,
double distanceScale, Vector3 displacement) {
+ for (View<CyNode> nodeView : nodeViews) {
+
+ if (nodeView != null) {
+
nodeView.setVisualProperty(BasicVisualLexicon.NODE_X_LOCATION,
+
nodeView.getVisualProperty(BasicVisualLexicon.NODE_X_LOCATION)
+ +
displacement.x() * distanceScale);
+
+
nodeView.setVisualProperty(BasicVisualLexicon.NODE_Y_LOCATION,
+
nodeView.getVisualProperty(BasicVisualLexicon.NODE_Y_LOCATION)
+ +
displacement.y() * distanceScale);
+
+
nodeView.setVisualProperty(BasicVisualLexicon.NODE_Z_LOCATION,
+
nodeView.getVisualProperty(BasicVisualLexicon.NODE_Z_LOCATION)
+ +
displacement.z() * distanceScale);
+ }
+ }
+ }
+
// Updates data in CyTable as well as View<CyNode>
public static void deselectNodes(Set<Integer> nodeIndices,
CyNetworkView networkView) {
CyNetwork network = networkView.getModel();
--
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.