use of cbit.image.ZoomEvent in project vcell by virtualcell.
the class ImagePaneView method panAndZoom.
/**
* Comment
*/
private boolean panAndZoom(java.awt.event.MouseEvent mouseEvent) {
//
boolean bConsumed = false;
//
if (mouseEvent.getID() == java.awt.event.MouseEvent.MOUSE_PRESSED) {
// set anchor point for all operations
anchorPoint = mouseEvent.getPoint();
if (getForceZoom() || (mouseEvent.getModifiers() & InputEvent.ALT_MASK) != 0) {
mode = ZOOMING;
} else if (getForcePan() || (mouseEvent.getModifiers() & InputEvent.SHIFT_MASK) != 0) {
mode = PANNING;
}
if (mode != NO_OP) {
bConsumed = true;
}
} else if (mouseEvent.getID() == java.awt.event.MouseEvent.MOUSE_RELEASED) {
if (mode != NO_OP) {
mode = NO_OP;
bConsumed = true;
}
} else if (mode == PANNING) {
if (mouseEvent.getID() == java.awt.event.MouseEvent.MOUSE_DRAGGED) {
if (panListener != null) {
int deltaX = mouseEvent.getPoint().x - anchorPoint.x;
int deltaY = mouseEvent.getPoint().y - anchorPoint.y;
PanEvent panEvent = new PanEvent(this, 0, deltaX, deltaY);
panListener.panning(panEvent);
anchorPoint.x = mouseEvent.getPoint().x - deltaX;
anchorPoint.y = mouseEvent.getPoint().y - deltaY;
}
bConsumed = true;
}
} else if (mode == ZOOMING) {
if (mouseEvent.getID() == java.awt.event.MouseEvent.MOUSE_DRAGGED) {
if (anchorPoint != null) {
int zoomDelta = (mouseEvent.getPoint().x - anchorPoint.x) / ZOOM_MOUSE_DELTA;
if (Math.abs(zoomDelta) > 0 && zoomListener != null) {
anchorPoint = null;
ZoomEvent zoomEvent = new ZoomEvent(this, 0, zoomDelta);
zoomListener.zooming(zoomEvent);
}
} else {
anchorPoint = mouseEvent.getPoint();
}
bConsumed = true;
}
//
}
return bConsumed;
}
use of cbit.image.ZoomEvent in project vcell by virtualcell.
the class KymographPanel method zoomToFill.
/**
* Insert the method's description here.
* Creation date: (12/29/2004 12:57:18 PM)
*/
public void zoomToFill() {
getimagePaneView1().getImagePaneModel().changeZoomToFillViewport();
getImagePaneScroller1().zooming(new ZoomEvent(getimagePaneView1(), 0, 0));
}
use of cbit.image.ZoomEvent in project vcell by virtualcell.
the class KymographPanel method initDataManagerVariable.
/**
* Insert the method's description here.
* Creation date: (12/14/2004 9:47:38 AM)
* @param timeSeries double[][]
* @param distances double[]
*/
private void initDataManagerVariable() /*final DataIdentifier dataIdentifer,*/
/*boolean bFromGUI*/
{
final DataIdentifier dataIdentifer = (DataIdentifier) getVarNamesJComboBox().getSelectedItem();
// Thread.dumpStack();
if ((initVariableTimer = ClientTaskDispatcher.getBlockingTimer(this, multiTimePlotHelper.getPdeDatacontext(), null, initVariableTimer, new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
initDataManagerVariable();
}
}, "KymographPanel get '" + dataIdentifer.getName() + "'")) != null) {
return;
}
// Create SymbolTableEntry for Copy/Paste functionality
currentSymbolTablEntry = (symbolTable != null ? symbolTable.getEntry(dataIdentifer.getName()) : null);
String taskName = "Retrieving data for variable '" + dataIdentifer.getName() + "'";
AsynchClientTask task1 = new AsynchClientTask(taskName, AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
public void run(final Hashtable<String, Object> hashTable) throws Exception {
double[] timeValues = multiTimePlotHelper.getPdeDatacontext().getTimePoints();
final TimeSeriesJobSpec timeSeriesJobSpec = new TimeSeriesJobSpec(new String[] { dataIdentifer.getName() }, new int[][] { dataManagerIndices }, (crossingMembraneIndices != null ? new int[][] { crossingMembraneIndices } : null), resampleStartTimeOrig, resampleStepOrig, timeValues[timeValues.length - 1], VCDataJobID.createVCDataJobID(multiTimePlotHelper.getUser(), true));
hashTable.put(PDEDataViewer.StringKey_timeSeriesJobSpec, timeSeriesJobSpec);
}
};
// new TimeSeriesDataRetrievalTask(title, PDEDataViewer.this, PDEDataViewer.this.getPdeDataContext());//timeSeriesDataRetrievalTask;
AsynchClientTask task2 = new PDEDataViewer.TimeSeriesDataRetrievalTask("Retrieving Data", multiTimePlotHelper, multiTimePlotHelper.getPdeDatacontext());
AsynchClientTask task3 = new AsynchClientTask("Showing kymograph", AsynchClientTask.TASKTYPE_SWING_BLOCKING, false, false) {
public void run(Hashtable<String, Object> hashTable) throws Exception {
Throwable timeSeriesJobFailed = (Throwable) hashTable.get(PDEDataViewer.StringKey_timeSeriesJobException);
if (timeSeriesJobFailed == null) {
timeSeriesJobFailed = (Throwable) hashTable.get(ClientTaskDispatcher.TASK_ABORTED_BY_USER);
}
if (failMethod(timeSeriesJobFailed, dataIdentifer)) {
return;
}
TSJobResultsNoStats tsJobResultsNoStats = (TSJobResultsNoStats) hashTable.get(PDEDataViewer.StringKey_timeSeriesJobResults);
currentDataIdentifier = dataIdentifer;
final double[][] timeSeries = tsJobResultsNoStats.getTimesAndValuesForVariable(currentDataIdentifier.getName());
try {
initStandAloneTimeSeries_private(timeSeries, dataManagerAccumDistances);
} catch (Exception e) {
failMethod(e, dataIdentifer);
throw e;
}
if (isInit) {
// set crosshair to init time
// resampleStartTimeOrig;
double initTime = initialLineScanTime;
isInit = false;
int closestTimeIndex = 0;
double closestDiff = Double.MAX_VALUE;
for (int i = 0; i < currentTimes.length; i += 1) {
double diff = Math.abs(initTime - currentTimes[i]);
if (diff < closestDiff) {
closestTimeIndex = i;
closestDiff = diff;
}
}
currentSelectionImg = new Point(0, closestTimeIndex);
currentSelectionUnit = new Point2D.Double(0, (double) closestTimeIndex / (double) (currentTimes.length - 1));
configurePlotData((int) currentSelectionImg.getX(), (int) currentSelectionImg.getY());
// ChildWindowManager childWindowManager = ChildWindowManager.findChildWindowManager(pdeDataViewer);
// // final ChildWindow childWindow = childWindowManager.addChildWindow(new javax.swing.JPanel(),this,title);
// final ChildWindow childWindow = childWindowManager.addChildWindow(KymographPanel.this,KymographPanel.this,title);
// childWindow.setIsCenteredOnParent();
// childWindow.pack();
// childWindow.show();
// Timer timer = new Timer(1000,new ActionListener() {
//
// @Override
// public void actionPerformed(ActionEvent e) {
// childWindow.toFront();
// }
// });
// System.out.println("Kymograph panel ChildWindow requesting focus. Answer is: "+childWindow.requestFocusInWindow());
// zoomToFill();
} else {
getImagePaneScroller1().zooming(new ZoomEvent(getimagePaneView1(), 0, 0));
}
}
};
AsynchClientTask[] tasks = (task2 == null ? new AsynchClientTask[] { task1, task3 } : new AsynchClientTask[] { task1, task2, task3 });
ClientTaskDispatcher.dispatch(KymographPanel.this, new Hashtable<String, Object>(), tasks, false, true, true, null, false);
// if(bFromGUI){
// ClientTaskDispatcher.dispatch(KymographPanel.this, new Hashtable<String, Object>(), tasks, false, true, true, null, false);
// System.out.println("Waiting here");
// }else{
// multiTimePlotHelper.addExtraTasks(tasks);
// }
}
Aggregations