Author: paperwing
Date: 2011-12-29 13:39:14 -0800 (Thu, 29 Dec 2011)
New Revision: 27879
Modified:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/BirdsEyeGraphics.java
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/WindMapRenderingEngine.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/coordinator/MainCoordinatorProcessor.java
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/coordinator/ViewingCoordinator.java
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/data/GraphicsSelectionData.java
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/geometric/Vector3.java
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/input/BoundsInputHandler.java
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/input/MouseMonitor.java
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/input/NetworkChangeInputHandler.java
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderBoundingBoxProcedure.java
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderEdgesProcedure.java
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderNodesProcedure.java
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/utility/GraphicsUtility.java
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/utility/SimpleCamera.java
Log:
first working birds eye view implemented, minor bugs to fix
Modified:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/BirdsEyeGraphics.java
===================================================================
---
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/BirdsEyeGraphics.java
2011-12-29 02:22:38 UTC (rev 27878)
+++
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/BirdsEyeGraphics.java
2011-12-29 21:39:14 UTC (rev 27879)
@@ -51,9 +51,6 @@
public void drawScene(GraphicsData graphicsData) {
// TODO Auto-generated method stub
- //debug
- System.out.println("map display call");
-
// Control light positioning
float[] lightPosition = { -4.0f, 4.0f, 6.0f, 1.0f };
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
2011-12-29 02:22:38 UTC (rev 27878)
+++
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/Graphics.java
2011-12-29 21:39:14 UTC (rev 27879)
@@ -125,12 +125,12 @@
// Perform picking
shapePickingProcessor.processPicking(mouse, keys, graphicsData);
- // Check input
- inputProcessor.processInput(keys, mouse, graphicsData);
-
// Update data for bird's eye view camera movement
coordinatorProcessor.extractData(coordinator, graphicsData);
+ // Check input
+ inputProcessor.processInput(keys, mouse, graphicsData);
+
// Reset the scene for drawing
handler.resetSceneForDrawing(graphicsData);
Modified:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/WindMapRenderingEngine.java
===================================================================
---
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/WindMapRenderingEngine.java
2011-12-29 02:22:38 UTC (rev 27878)
+++
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/WindMapRenderingEngine.java
2011-12-29 21:39:14 UTC (rev 27879)
@@ -141,6 +141,7 @@
// capabilities.setDoubleBuffered(true);
// TODO: check whether to use GLCanvas or GLJPanel
+
GLJPanel panel = new GLJPanel(capabilities);
graphics = newInstance(networkView, visualLexicon);
@@ -165,26 +166,31 @@
animator = new FPSAnimator(60);
animator.add(panel);
+ animator.setIgnoreExceptions(true);
+ animator.setPrintExceptions(true);
+ animator.start();
- focus.addFocusListener(new FocusListener() {
-
- @Override
- public void focusGained(FocusEvent event) {
- if (!event.isTemporary()) {
- System.out.println("Animator
started for map: " + this);
- animator.start();
- }
- }
-
- @Override
- public void focusLost(FocusEvent event) {
- if (!event.isTemporary()) {
- System.out.println("Animator
stopped for map: " + this);
- animator.stop();
- }
- }
- });
+ System.out.println("Map animator animating status: " +
animator.isAnimating());
+// focus.addFocusListener(new FocusListener() {
+//
+// @Override
+// public void focusGained(FocusEvent event) {
+// if (!event.isTemporary()) {
+// System.out.println("Animator
started for map: " + this);
+// animator.start();
+// }
+// }
+//
+// @Override
+// public void focusLost(FocusEvent event) {
+// if (!event.isTemporary()) {
+// System.out.println("Animator
stopped for map: " + this);
+// animator.stop();
+// }
+// }
+// });
+
active = true;
// graphics.findMapPartner();
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
2011-12-29 02:22:38 UTC (rev 27878)
+++
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/coordinator/BirdsEyeCoordinatorProcessor.java
2011-12-29 21:39:14 UTC (rev 27879)
@@ -33,42 +33,51 @@
coordinatorData.setBounds(ViewingCoordinator.extractBounds(coordinator.getCurrentMainCamera(),
coordinator.getMainVerticalFov(), coordinator.getMainAspectRatio()));
- System.out.println("New Bounds: " +
ViewingCoordinator.extractBounds(coordinator.getCurrentMainCamera(),
-
coordinator.getMainVerticalFov(), coordinator.getMainAspectRatio()));
+// System.out.println("New Bounds: " +
ViewingCoordinator.extractBounds(coordinator.getCurrentMainCamera(),
+//
coordinator.getMainVerticalFov(), coordinator.getMainAspectRatio()));
- // Update the birds eye view camera
-
camera.copyOrientation(coordinator.getCurrentMainCamera());
+// updateBirdsEyeCamera(coordinator, graphicsData);
- Vector3 networkCenter =
GraphicsUtility.findNetworkCenter(graphicsData.getNetworkView(),
graphicsData.getDistanceScale());
- camera.moveTo(networkCenter);
+// System.out.println("Camera Displacement from
center: " + camera.getPosition().distance(networkCenter));
- Vector3 farthestNode =
GraphicsUtility.findFarthestNodeFromCenter(graphicsData.getNetworkView(),
networkCenter, graphicsData.getDistanceScale());
-
- double newDistance =
farthestNode.distance(networkCenter);
-
- // Further increase the distance needed
- newDistance *= 4;
-
- System.out.println("NewDistance: " +
newDistance);
- Vector3 offset =
camera.getDirection().multiply(-newDistance);
-
- System.out.println("NetworkCenter: " +
networkCenter);
- System.out.println("FarthestNode: " +
farthestNode);
- System.out.println("Map camera new position: "
+ networkCenter.plus(offset));
-
- camera.moveTo(networkCenter.plus(offset));
- camera.setDistance(newDistance);
-
- System.out.println("Camera Displacement from
center: " + camera.getPosition().distance(networkCenter));
-
coordinator.updateMainCamera();
} else if
(coordinator.compareBirdsEyeBoundsChanged(coordinatorData.getBounds())) {
coordinator.updateBirdsEyeBounds(coordinatorData.getBounds());
}
+
+ updateBirdsEyeCamera(coordinator, graphicsData);
}
+
+ }
+ private void updateBirdsEyeCamera(ViewingCoordinator coordinator,
+ GraphicsData graphicsData) {
+ SimpleCamera camera = graphicsData.getCamera();
+
+ // Update the birds eye view camera
+ camera.copyOrientation(coordinator.getCurrentMainCamera());
+
+ Vector3 networkCenter =
GraphicsUtility.findNetworkCenter(graphicsData.getNetworkView(),
graphicsData.getDistanceScale());
+ Vector3 farthestNode =
GraphicsUtility.findFarthestNodeFromCenter(graphicsData.getNetworkView(),
networkCenter, graphicsData.getDistanceScale());
+
+ double newDistance = farthestNode.distance(networkCenter);
+
+ // Further increase the distance needed
+ newDistance *= 2.5;
+ // newDistance = Math.max(newDistance,
coordinator.getCurrentMainCamera().getPosition().distance(networkCenter) * 2);
+ newDistance = Math.max(newDistance, 5);
+
+// System.out.println("NewDistance: " + newDistance);
+ Vector3 offset = camera.getDirection().multiply(-newDistance);
+
+// System.out.println("NetworkCenter: " + networkCenter);
+// System.out.println("FarthestNode: " + farthestNode);
+// System.out.println("Map camera new position: " +
networkCenter.plus(offset));
+
+ camera.moveTo(networkCenter.plus(offset));
+ camera.setDistance(newDistance);
}
-
+
@Override
public void unlinkCoordinator(ViewingCoordinator coordinator) {
coordinator.unlinkBirdsEye();
Modified:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/coordinator/MainCoordinatorProcessor.java
===================================================================
---
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/coordinator/MainCoordinatorProcessor.java
2011-12-29 02:22:38 UTC (rev 27878)
+++
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/coordinator/MainCoordinatorProcessor.java
2011-12-29 21:39:14 UTC (rev 27879)
@@ -46,9 +46,12 @@
if (coordinator.compareMainCameraChanged(camera)) {
coordinator.updateMainCamera(camera);
} else if (coordinator.birdsEyeBoundsChanged()) {
- newPosition =
ViewingCoordinator.extractCameraPosition(coordinator, camera.getDirection(),
camera.getDistance());
+ //newPosition =
ViewingCoordinator.extractCameraPosition(coordinator, camera.getDirection(),
camera.getDistance());
+ newPosition =
ViewingCoordinator.findNewOrthoCameraPosition(coordinator.getCurrentBirdsEyeBounds(),
camera.getPosition(), camera.getDirection());
camera.moveTo(newPosition);
+ coordinator.updateMainCamera(camera);
+
coordinator.updateBirdsEyeBounds();
}
}
Modified:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/coordinator/ViewingCoordinator.java
===================================================================
---
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/coordinator/ViewingCoordinator.java
2011-12-29 02:22:38 UTC (rev 27878)
+++
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/coordinator/ViewingCoordinator.java
2011-12-29 21:39:14 UTC (rev 27879)
@@ -11,8 +11,8 @@
public class ViewingCoordinator {
- public static double BOUNDS_CHANGE_THRESHOLD = 5e-22;
- public static double CAMERA_CHANGE_THRESHOLD = 5e-22;
+ public static double BOUNDS_CHANGE_THRESHOLD = 5e-10;
+ public static double CAMERA_CHANGE_THRESHOLD = 5e-10;
private SimpleCamera currentMainCamera;
private Quadrilateral currentBirdsEyeBounds;
@@ -20,8 +20,8 @@
private boolean mainCameraChanged = false;
private boolean birdsEyeBoundsChanged = false;
- private double mainVerticalFov = 45;
- private double mainAspectRatio = 1;
+ private double mainVerticalFov;
+ private double mainAspectRatio;
private boolean boundsInitialized = false;
@@ -57,6 +57,12 @@
return position;
}
+
+ // Orthogonally shifts the camera to match new bounds, orthogonal with
respect to the camera's direction vector
+ public static Vector3 findNewOrthoCameraPosition(Quadrilateral
newBounds, Vector3 oldCameraPosition, Vector3 cameraDirection) {
+ return
GraphicsUtility.findNewOrthogonalPosition(newBounds.getCenterPoint(),
oldCameraPosition, cameraDirection);
+ }
+
public static Quadrilateral extractBounds(SimpleCamera camera, double
verticalFov, double aspectRatio) {
return
GraphicsUtility.generateViewingBounds(camera.getPosition(),
camera.getDirection(), camera.getUp(),
camera.getDistance(), verticalFov, aspectRatio);
Modified:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/data/GraphicsSelectionData.java
===================================================================
---
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/data/GraphicsSelectionData.java
2011-12-29 02:22:38 UTC (rev 27878)
+++
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/data/GraphicsSelectionData.java
2011-12-29 21:39:14 UTC (rev 27879)
@@ -26,10 +26,10 @@
private int selectBottomRightY;
/** The index of the node currently being hovered over */
- private int hoverNodeIndex;
+ private int hoverNodeIndex = -1;
/** The index of the edge currently being hovered over */
- private int hoverEdgeIndex;
+ private int hoverEdgeIndex = -1;
/** A flag for whether drag selection mode is currently active */
private boolean dragSelectMode;
Modified:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/geometric/Vector3.java
===================================================================
---
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/geometric/Vector3.java
2011-12-29 02:22:38 UTC (rev 27878)
+++
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/geometric/Vector3.java
2011-12-29 21:39:14 UTC (rev 27879)
@@ -334,6 +334,14 @@
return rotated;
}
+ public Vector3 towards(Vector3 other, double fraction) {
+ Vector3 result = other.subtract(this);
+ result.multiplyLocal(fraction);
+ result.addLocal(this);
+
+ return result;
+ }
+
/** Give a string representation of this vector
*
* @return The string representation, in format (x, y, z)
Modified:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/input/BoundsInputHandler.java
===================================================================
---
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/input/BoundsInputHandler.java
2011-12-29 02:22:38 UTC (rev 27878)
+++
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/input/BoundsInputHandler.java
2011-12-29 21:39:14 UTC (rev 27879)
@@ -2,6 +2,7 @@
import org.cytoscape.paperwing.internal.data.CoordinatorData;
import org.cytoscape.paperwing.internal.data.GraphicsData;
+import org.cytoscape.paperwing.internal.geometric.Quadrilateral;
import org.cytoscape.paperwing.internal.geometric.Vector3;
import org.cytoscape.paperwing.internal.utility.GraphicsUtility;
@@ -19,13 +20,18 @@
private void processMoveBounds(MouseMonitor mouse, GraphicsData
graphicsData) {
CoordinatorData coordinatorData =
graphicsData.getCoordinatorData();
- if (mouse.getPressed().contains(MouseEvent.BUTTON1)) {
+ if (mouse.getHeld().contains(MouseEvent.BUTTON1)) {
Vector3 mousePosition =
GraphicsUtility.convertMouseTo3d(mouse, graphicsData,
graphicsData.getCamera().getDistance());
// The y-coordinate needs to be inverted
- mousePosition.set(mousePosition.x(),
-mousePosition.y(), mousePosition.z());
+ // mousePosition.set(mousePosition.x(),
-mousePosition.y(), mousePosition.z());
- coordinatorData.getBounds().moveTo(mousePosition);
+ Quadrilateral oldBounds = coordinatorData.getBounds();
+
+
oldBounds.moveTo(GraphicsUtility.findNewOrthogonalPosition(
+ mousePosition,
+ oldBounds.getCenterPoint(),
+
graphicsData.getCamera().getDirection()));
}
}
}
Modified:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/input/MouseMonitor.java
===================================================================
---
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/input/MouseMonitor.java
2011-12-29 02:22:38 UTC (rev 27878)
+++
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/input/MouseMonitor.java
2011-12-29 21:39:14 UTC (rev 27879)
@@ -20,6 +20,8 @@
public class MouseMonitor implements MouseListener, MouseMotionListener,
MouseWheelListener, FocusListener {
+ private static final int NULL_COORDINATE = Integer.MAX_VALUE;
+
/** The previous mouse x-coordinate, since the previous frame */
private int prevX;
@@ -143,6 +145,10 @@
@Override
public void mouseExited(MouseEvent event) {
ignoreNext = false;
+
+ // Scramble mouse coordinates
+ currentX = NULL_COORDINATE;
+ currentY = NULL_COORDINATE;
}
@Override
Modified:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/input/NetworkChangeInputHandler.java
===================================================================
---
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/input/NetworkChangeInputHandler.java
2011-12-29 02:22:38 UTC (rev 27878)
+++
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/input/NetworkChangeInputHandler.java
2011-12-29 21:39:14 UTC (rev 27879)
@@ -66,7 +66,7 @@
// Set the node to be hovered
// TODO: This might not be needed if the node
were added
// through some way other than the mouse
-
graphicsData.getSelectionData().setHoverNodeIndex(added.getIndex());
+ //
graphicsData.getSelectionData().setHoverNodeIndex(added.getIndex());
}
}
}
Modified:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderBoundingBoxProcedure.java
===================================================================
---
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderBoundingBoxProcedure.java
2011-12-29 02:22:38 UTC (rev 27878)
+++
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderBoundingBoxProcedure.java
2011-12-29 21:39:14 UTC (rev 27879)
@@ -2,35 +2,99 @@
import javax.media.opengl.GL;
import javax.media.opengl.GL2;
+import javax.media.opengl.glu.GLU;
+import javax.media.opengl.glu.GLUquadric;
import org.cytoscape.paperwing.internal.data.GraphicsData;
import org.cytoscape.paperwing.internal.geometric.Vector3;
+import org.cytoscape.paperwing.internal.utility.GraphicsUtility;
import org.cytoscape.paperwing.internal.utility.SimpleCamera;
public class RenderBoundingBoxProcedure implements ReadOnlyGraphicsProcedure {
@Override
public void initialize(GraphicsData graphicsData) {
- // TODO Auto-generated method stub
-
}
@Override
public void execute(GraphicsData graphicsData) {
+// drawFullBox(graphicsData);
+
+ drawHalfBox(graphicsData);
+ }
+
+ private void drawHalfBox(GraphicsData graphicsData) {
GL2 gl = graphicsData.getGlContext();
+ double fraction = 0.25;
+
Vector3 topLeft =
graphicsData.getCoordinatorData().getBounds().getTopLeft();
Vector3 topRight =
graphicsData.getCoordinatorData().getBounds().getTopRight();
Vector3 bottomLeft =
graphicsData.getCoordinatorData().getBounds().getBottomLeft();
Vector3 bottomRight =
graphicsData.getCoordinatorData().getBounds().getBottomRight();
+ Vector3 topLeftDown = topLeft.towards(bottomLeft, fraction);
+ Vector3 topLeftRight = topLeft.towards(topRight, fraction);
+
+ Vector3 topRightDown = topRight.towards(bottomRight, fraction);
+ Vector3 topRightLeft = topRight.towards(topLeft, fraction);
+
+ Vector3 bottomLeftUp = bottomLeft.towards(topLeft, fraction);
+ Vector3 bottomLeftRight = bottomLeft.towards(bottomRight,
fraction);
+
+ Vector3 bottomRightUp = bottomRight.towards(topRight, fraction);
+ Vector3 bottomRightLeft = bottomRight.towards(bottomLeft,
fraction);
+
gl.glDisable(GL2.GL_LIGHTING);
gl.glDisable(GL.GL_DEPTH_TEST);
- gl.glColor3f(0.8f, 0.8f, 0.8f);
+ gl.glColor3f(0.7f, 0.7f, 0.7f);
// Below uses converted 3D coordinates
+ gl.glBegin(GL2.GL_LINE_STRIP);
+ gl.glVertex3d(topLeftDown.x(), topLeftDown.y(),
topLeftDown.z());
+ gl.glVertex3d(topLeft.x(), topLeft.y(), topLeft.z());
+ gl.glVertex3d(topLeftRight.x(), topLeftRight.y(),
topLeftRight.z());
+ gl.glEnd();
+
+ gl.glBegin(GL2.GL_LINE_STRIP);
+ gl.glVertex3d(bottomLeftUp.x(), bottomLeftUp.y(),
bottomLeftUp.z());
+ gl.glVertex3d(bottomLeft.x(), bottomLeft.y(), bottomLeft.z());
+ gl.glVertex3d(bottomLeftRight.x(), bottomLeftRight.y(),
bottomLeftRight.z());
+ gl.glEnd();
+
+ gl.glBegin(GL2.GL_LINE_STRIP);
+ gl.glVertex3d(bottomRightUp.x(), bottomRightUp.y(),
bottomRightUp.z());
+ gl.glVertex3d(bottomRight.x(), bottomRight.y(),
bottomRight.z());
+ gl.glVertex3d(bottomRightLeft.x(), bottomRightLeft.y(),
bottomRightLeft.z());
+ gl.glEnd();
+
+ gl.glBegin(GL2.GL_LINE_STRIP);
+ gl.glVertex3d(topRightDown.x(), topRightDown.y(),
topRightDown.z());
+ gl.glVertex3d(topRight.x(), topRight.y(), topRight.z());
+ gl.glVertex3d(topRightLeft.x(), topRightLeft.y(),
topRightLeft.z());
+ gl.glEnd();
+
+ gl.glEnable(GL.GL_DEPTH_TEST);
+ gl.glEnable(GL2.GL_LIGHTING);
+ }
+
+ private void drawFullBox(GraphicsData graphicsData) {
+ GL2 gl = graphicsData.getGlContext();
+
+ Vector3 topLeft =
graphicsData.getCoordinatorData().getBounds().getTopLeft();
+ Vector3 topRight =
graphicsData.getCoordinatorData().getBounds().getTopRight();
+
+ Vector3 bottomLeft =
graphicsData.getCoordinatorData().getBounds().getBottomLeft();
+ Vector3 bottomRight =
graphicsData.getCoordinatorData().getBounds().getBottomRight();
+
+ gl.glDisable(GL2.GL_LIGHTING);
+ gl.glDisable(GL.GL_DEPTH_TEST);
+
+ gl.glColor3f(0.7f, 0.7f, 0.7f);
+
+ // Below uses converted 3D coordinates
gl.glBegin(GL2.GL_LINE_LOOP);
gl.glVertex3d(topLeft.x(), topLeft.y(), topLeft.z());
gl.glVertex3d(bottomLeft.x(), bottomLeft.y(), bottomLeft.z());
@@ -41,5 +105,4 @@
gl.glEnable(GL.GL_DEPTH_TEST);
gl.glEnable(GL2.GL_LIGHTING);
}
-
}
Modified:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderEdgesProcedure.java
===================================================================
---
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderEdgesProcedure.java
2011-12-29 02:22:38 UTC (rev 27878)
+++
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderEdgesProcedure.java
2011-12-29 21:39:14 UTC (rev 27879)
@@ -25,7 +25,7 @@
public class RenderEdgesProcedure implements ReadOnlyGraphicsProcedure {
/** The default radius of the semi-cylindrical edges */
- private static final float EDGE_RADIUS = 0.141f; // 0.018f default as
of Dec 2011
+ private static final float EDGE_RADIUS = 0.11f; // 0.018f default as of
Dec 2011
/**
* A multiplicative factor for the width of the edges when reading from
the
@@ -372,7 +372,7 @@
color.getBlue() / 255.0f);
// Default color is below
- // gl.glColor3f(0.73f, 0.73f, 0.73f);
+// gl.glColor3f(0.73f, 0.73f, 0.73f);
gl.glCallList(edgeListIndex);
} else if (modifier == DrawStateModifier.ENLARGED) {
gl.glScalef(1.6f, 1.6f, 1.0f);
@@ -381,11 +381,11 @@
color = (Color) edgeView
.getVisualProperty(RichVisualLexicon.EDGE_SELECTED_PAINT);
- gl.glColor3f(color.getRed() / 255.0f, color.getGreen()
/ 255.0f,
- color.getBlue() / 255.0f);
+// gl.glColor3f(color.getRed() / 255.0f, color.getGreen()
/ 255.0f,
+// color.getBlue() / 255.0f);
// Default color below
- // gl.glColor3f(0.48f, 0.65f, 0.48f);
+ gl.glColor3f(0.48f, 0.65f, 0.48f);
gl.glScalef(1.1f, 1.1f, 1.0f);
gl.glCallList(edgeListIndex);
} else if (modifier == DrawStateModifier.HOVERED) {
Modified:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderNodesProcedure.java
===================================================================
---
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderNodesProcedure.java
2011-12-29 02:22:38 UTC (rev 27878)
+++
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderNodesProcedure.java
2011-12-29 21:39:14 UTC (rev 27879)
@@ -116,14 +116,14 @@
color = (Color) nodeView
.getVisualProperty(RichVisualLexicon.NODE_SELECTED_PAINT);
- gl.glColor3f(color.getRed() / 255.0f,
- color.getGreen() / 255.0f,
color.getBlue() / 255.0f);
+// gl.glColor3f(color.getRed() / 255.0f,
+// color.getGreen() / 255.0f,
color.getBlue() / 255.0f);
nodeView.setVisualProperty(RichVisualLexicon.NODE_SELECTED,
true);
// Default color is below
- // gl.glColor3f(0.52f, 0.70f, 0.52f);
+ gl.glColor3f(0.52f, 0.70f, 0.52f);
} else if (index == hoverNodeIndex) {
gl.glColor3f(0.52f, 0.52f, 0.70f);
@@ -140,7 +140,7 @@
false);
// Default color is below
- // gl.glColor3f(0.73f, 0.73f, 0.73f);
+// gl.glColor3f(0.73f, 0.73f, 0.73f);
}
Modified:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/utility/GraphicsUtility.java
===================================================================
---
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/utility/GraphicsUtility.java
2011-12-29 02:22:38 UTC (rev 27878)
+++
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/utility/GraphicsUtility.java
2011-12-29 21:39:14 UTC (rev 27879)
@@ -183,8 +183,11 @@
}
Vector3 result = new Vector3(x, y, z);
- result.divideLocal(distanceScale * visitedCount);
+ if (visitedCount != 0) {
+ result.divideLocal(distanceScale * visitedCount);
+ }
+
return result;
}
@@ -219,4 +222,42 @@
public static Vector3 findFarthestNodeFromCenter(CyNetworkView
networkView, double distanceScale) {
return findFarthestNodeFromCenter(networkView,
findNetworkCenter(networkView, distanceScale), distanceScale);
}
+
+
+ // Just like Math.acos, but a bit safer
+ public static double saferArcCos(double argument) {
+ if (argument >= 1) {
+ return 0;
+ } else if (argument <= -1) {
+ return Math.PI;
+ } else {
+ return Math.acos(argument);
+ }
+ }
+
+
+ // This method solves the case where newAnchor and oldPosition are
supposed to be aligned by the normal vector,
+ // but newAnchor has moved and we need to update oldPosition
accordingly.
+ public static Vector3 findNewOrthogonalPosition(Vector3 newAnchor,
Vector3 oldPosition, Vector3 normal) {
+
+ Vector3 diagonalDisplacement = newAnchor.subtract(oldPosition);
+ double diagonalLength = diagonalDisplacement.magnitude();
+ double dotProduct = diagonalDisplacement.dot(normal);
+
+ // Use the dot product formula to find angle between diagonal
displacement and camera's direction vector
+ double angle = GraphicsUtility.saferArcCos(dotProduct /
diagonalLength);
+
+ double orthogonalDisplacementLength = Math.cos(angle) *
diagonalLength;
+
+ Vector3 orthogonalDisplacement =
normal.normalize().multiply(-orthogonalDisplacementLength);
+
+ return newAnchor.plus(orthogonalDisplacement);
+ }
+
+ public static Vector3 findMidpoint(Vector3 first, Vector3 second) {
+ Vector3 result = first.plus(second);
+ result.divideLocal(2);
+
+ return result;
+ }
}
Modified:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/utility/SimpleCamera.java
===================================================================
---
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/utility/SimpleCamera.java
2011-12-29 02:22:38 UTC (rev 27878)
+++
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/utility/SimpleCamera.java
2011-12-29 21:39:14 UTC (rev 27879)
@@ -272,6 +272,14 @@
target.set(newTarget);
}
+ public void moveTowards(Vector3 position) {
+ Vector3 offset = position.subtract(this.position);
+ offset.normalizeLocal();
+ offset.multiplyLocal(moveSpeed);
+
+ moveTo(this.position.plus(offset));
+ }
+
/** Turn the camera leftwards by a multiplier of its turning speed
*
* @param multiplier The multiplier, ie. how many times its turning
speed to turn
--
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.