Author: clopes
Date: 2012-11-14 13:31:24 -0800 (Wed, 14 Nov 2012)
New Revision: 30788
Modified:
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/impl/DGraphView.java
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/impl/InnerCanvas.java
Log:
Fixes #1580 : Locking NETWORK_SCALE_FACTOR is now working and prevents users
from zooming with the mouse wheel. Running layouts and fitting to screen (or to
selected elements) don't change the scale either when it is locked.
Modified:
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/impl/DGraphView.java
===================================================================
---
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/impl/DGraphView.java
2012-11-14 16:54:41 UTC (rev 30787)
+++
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/impl/DGraphView.java
2012-11-14 21:31:24 UTC (rev 30788)
@@ -161,23 +161,6 @@
private static final Logger logger =
LoggerFactory.getLogger(DGraphView.class);
- private static enum ZOrder {
- BACKGROUND_PANE, NETWORK_PANE, FOREGROUND_PANE;
-
- int layer() {
- if (this == BACKGROUND_PANE)
- return -30000;
-
- if (this == NETWORK_PANE)
- return 0;
-
- if (this == FOREGROUND_PANE)
- return 301;
-
- return 0;
- }
- }
-
// Size of square for moving handle
static final float DEFAULT_ANCHOR_SIZE = 12.0f;
@@ -1112,7 +1095,7 @@
@Override
public void setZoom(final double zoom) {
synchronized (m_lock) {
- m_networkCanvas.m_scaleFactor =
checkZoom(zoom,m_networkCanvas.m_scaleFactor);
+ m_networkCanvas.m_scaleFactor = checkZoom(zoom,
m_networkCanvas.m_scaleFactor);
m_viewportChanged = true;
}
}
@@ -1138,21 +1121,23 @@
// Adjust the content based on the background canvas
m_backgroundCanvas.adjustBounds(m_extentsBuffD);
- m_networkCanvas.m_xCenter = (m_extentsBuffD[0] +
m_extentsBuffD[2]) / 2.0d;
- m_networkCanvas.m_yCenter = (m_extentsBuffD[1] +
m_extentsBuffD[3]) / 2.0d;
-
- // Apply a factor 0.98 to zoom, so that it leaves a
small border around the network and any annotations.
- final double zoom = Math.min(((double)
m_networkCanvas.getWidth()) /
- (m_extentsBuffD[2] -
m_extentsBuffD[0]),
- ((double)
m_networkCanvas.getHeight()) /
- (m_extentsBuffD[3] -
m_extentsBuffD[1])) * 0.98;
- m_networkCanvas.m_scaleFactor =
checkZoom(zoom,m_networkCanvas.m_scaleFactor);
- m_viewportChanged = true;
+ if
(!isValueLocked(BasicVisualLexicon.NETWORK_CENTER_X_LOCATION))
+
setVisualProperty(BasicVisualLexicon.NETWORK_CENTER_X_LOCATION,
+ (m_extentsBuffD[0] +
m_extentsBuffD[2]) / 2.0d);
- // Update view model. Zoom Level should be modified.
-
setVisualProperty(BasicVisualLexicon.NETWORK_SCALE_FACTOR, zoom);
-
setVisualProperty(BasicVisualLexicon.NETWORK_CENTER_X_LOCATION,
m_networkCanvas.m_xCenter);
-
setVisualProperty(BasicVisualLexicon.NETWORK_CENTER_Y_LOCATION,
m_networkCanvas.m_yCenter);
+ if
(!isValueLocked(BasicVisualLexicon.NETWORK_CENTER_Y_LOCATION))
+
setVisualProperty(BasicVisualLexicon.NETWORK_CENTER_Y_LOCATION,
+ (m_extentsBuffD[1] +
m_extentsBuffD[3]) / 2.0d);
+
+ if
(!isValueLocked(BasicVisualLexicon.NETWORK_SCALE_FACTOR)) {
+ // Apply a factor 0.98 to zoom, so that it
leaves a small border around the network and any annotations.
+ final double zoom = Math.min(((double)
m_networkCanvas.getWidth()) /
+ (m_extentsBuffD[2]
- m_extentsBuffD[0]),
+ ((double)
m_networkCanvas.getHeight()) /
+ (m_extentsBuffD[3]
- m_extentsBuffD[1])) * 0.98;
+ // Update view model. Zoom Level should be
modified.
+
setVisualProperty(BasicVisualLexicon.NETWORK_SCALE_FACTOR, zoom);
+ }
}
if (updateView)
@@ -1166,7 +1151,6 @@
public void fitContent() {
fitContent(/* updateView = */ true);
}
-
/**
* Redraw the canvas.
@@ -1181,8 +1165,7 @@
m_networkCanvas.repaint();
//Check if image size has changed if so, visual property needs
to be changed as well
- if( m_networkCanvas.getWidth() != imageWidth ||
m_networkCanvas.getHeight() != imageHeight)
- {
+ if ( m_networkCanvas.getWidth() != imageWidth ||
m_networkCanvas.getHeight() != imageHeight) {
imageWidth = m_networkCanvas.getWidth();
imageHeight = m_networkCanvas.getHeight();
setVisualProperty(BasicVisualLexicon.NETWORK_WIDTH,(double)imageWidth);
@@ -1588,6 +1571,7 @@
m_viewportChanged = true;
// Update view model
+ // TODO: don't do it from here?
setVisualProperty(BasicVisualLexicon.NETWORK_CENTER_X_LOCATION,
m_networkCanvas.m_xCenter);
setVisualProperty(BasicVisualLexicon.NETWORK_CENTER_Y_LOCATION,
m_networkCanvas.m_yCenter);
}
@@ -1605,8 +1589,7 @@
cyEventHelper.flushPayloadEvents();
synchronized (m_lock) {
- LongEnumerator selectedElms =
m_selectedNodes.searchRange(
- Integer.MIN_VALUE, Integer.MAX_VALUE,
false);
+ LongEnumerator selectedElms =
m_selectedNodes.searchRange(Integer.MIN_VALUE, Integer.MAX_VALUE, false);
// Only check for selected edges if we don't have
selected nodes.
if (selectedElms.numRemaining() == 0 &&
edgeSelectionEnabled()) {
@@ -1643,21 +1626,28 @@
xMin = xMin - (getLabelWidth(leftMost) / 2);
xMax = xMax + (getLabelWidth(rightMost) / 2);
- m_networkCanvas.m_xCenter = (((double) xMin) +
((double) xMax)) / 2.0d;
- m_networkCanvas.m_yCenter = (((double) yMin) +
((double) yMax)) / 2.0d;
- final double zoom = Math.min(((double)
m_networkCanvas.getWidth())
- / (((double) xMax) - ((double) xMin)),
- ((double) m_networkCanvas.getHeight())
- / (((double) yMax) -
((double) yMin)));
- m_networkCanvas.m_scaleFactor = checkZoom(zoom,
- m_networkCanvas.m_scaleFactor);
- m_viewportChanged = true;
+ if
(!isValueLocked(BasicVisualLexicon.NETWORK_CENTER_Y_LOCATION)) {
+ double zoom = Math.min(((double)
m_networkCanvas.getWidth())
+ / (((double) xMax) - ((double)
xMin)),
+ ((double)
m_networkCanvas.getHeight())
+ / (((double)
yMax) - ((double) yMin)));
+ zoom = checkZoom(zoom,
m_networkCanvas.m_scaleFactor);
+
+ // Update view model. Zoom Level should be
modified.
+
setVisualProperty(BasicVisualLexicon.NETWORK_SCALE_FACTOR, zoom);
+ }
- // Update view model. Zoom Level should be modified.
-
setVisualProperty(BasicVisualLexicon.NETWORK_SCALE_FACTOR, zoom);
-
setVisualProperty(BasicVisualLexicon.NETWORK_CENTER_X_LOCATION,
m_networkCanvas.m_xCenter);
-
setVisualProperty(BasicVisualLexicon.NETWORK_CENTER_Y_LOCATION,
m_networkCanvas.m_yCenter);
+ if
(!isValueLocked(BasicVisualLexicon.NETWORK_CENTER_X_LOCATION)) {
+ final double xCenter = (((double) xMin) +
((double) xMax)) / 2.0d;
+
setVisualProperty(BasicVisualLexicon.NETWORK_CENTER_X_LOCATION, xCenter);
+ }
+
+ if
(!isValueLocked(BasicVisualLexicon.NETWORK_CENTER_Y_LOCATION)) {
+ final double yCenter = (((double) yMin) +
((double) yMax)) / 2.0d;
+
setVisualProperty(BasicVisualLexicon.NETWORK_CENTER_Y_LOCATION, yCenter);
+ }
}
+
updateView();
}
@@ -2584,11 +2574,11 @@
setBackgroundPaint((Paint) value);
} else if (vp == BasicVisualLexicon.NETWORK_CENTER_X_LOCATION) {
final double x = (Double) value;
- if(x != m_networkCanvas.m_xCenter)
+ if (x != m_networkCanvas.m_xCenter)
setCenter(x, m_networkCanvas.m_yCenter);
} else if (vp == BasicVisualLexicon.NETWORK_CENTER_Y_LOCATION) {
final double y = (Double) value;
- if(y != m_networkCanvas.m_yCenter)
+ if (y != m_networkCanvas.m_yCenter)
setCenter(m_networkCanvas.m_xCenter, y);
} else if (vp == BasicVisualLexicon.NETWORK_SCALE_FACTOR) {
setZoom(((Double) value).doubleValue());
Modified:
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/impl/InnerCanvas.java
===================================================================
---
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/impl/InnerCanvas.java
2012-11-14 16:54:41 UTC (rev 30787)
+++
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/impl/InnerCanvas.java
2012-11-14 21:31:24 UTC (rev 30788)
@@ -269,21 +269,19 @@
* This method exposes the JComponent processMouseEvent so that
canvases on
* top of us can pass events they don't want down.
*
- * @param e
- * the MouseEvent to process
+ * @param e the MouseEvent to process
*/
@Override
public void processMouseEvent(MouseEvent e) {
super.processMouseEvent(e);
}
-
@Override
public void mouseWheelMoved(MouseWheelEvent e) {
- adjustZoom(e.getWheelRotation());
+ if
(!m_view.isValueLocked(BasicVisualLexicon.NETWORK_SCALE_FACTOR))
+ adjustZoom(e.getWheelRotation());
}
-
@Override
public void mouseDragged(MouseEvent e) {
mouseDraggedDelegator.delegateMouseDragEvent(e);
@@ -797,7 +795,6 @@
private void adjustZoom(int notches) {
-
final double factor;
if (notches < 0)
--
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.