示例#1
0
 /** Updates the stack scrollbar. */
 public void updateSliceSelector() {
   if (hyperStack || zSelector == null) return;
   int stackSize = imp.getStackSize();
   int max = zSelector.getMaximum();
   if (max != (stackSize + 1)) zSelector.setMaximum(stackSize + 1);
   zSelector.setValue(imp.getCurrentSlice());
 }
示例#2
0
 private void syncWindows(Object source) {
   if (SyncWindows.getInstance() == null) return;
   if (source == cSelector) SyncWindows.setC(this, cSelector.getValue());
   else if (source == zSelector) SyncWindows.setZ(this, zSelector.getValue());
   else if (source == tSelector) SyncWindows.setT(this, tSelector.getValue());
   else throw new RuntimeException("Unknownsource:" + source);
 }
示例#3
0
 void removeScrollbars() {
   if (cSelector != null) {
     remove(cSelector);
     cSelector.removeAdjustmentListener(this);
     cSelector = null;
   }
   if (zSelector != null) {
     remove(zSelector);
     zSelector.removeAdjustmentListener(this);
     zSelector = null;
   }
   if (tSelector != null) {
     remove(tSelector);
     tSelector.removeAdjustmentListener(this);
     tSelector = null;
   }
 }
示例#4
0
 public synchronized void adjustmentValueChanged(AdjustmentEvent e) {
   if (!running2 || imp.isHyperStack()) {
     if (e.getSource() == cSelector) {
       c = cSelector.getValue();
       if (c == imp.getChannel() && e.getAdjustmentType() == AdjustmentEvent.TRACK) return;
     } else if (e.getSource() == zSelector) {
       z = zSelector.getValue();
       int slice = hyperStack ? imp.getSlice() : imp.getCurrentSlice();
       if (z == slice && e.getAdjustmentType() == AdjustmentEvent.TRACK) return;
     } else if (e.getSource() == tSelector) {
       t = tSelector.getValue();
       if (t == imp.getFrame() && e.getAdjustmentType() == AdjustmentEvent.TRACK) return;
     }
     updatePosition();
     notify();
   }
   if (!running) syncWindows(e.getSource());
 }
示例#5
0
 public void setPosition(int channel, int slice, int frame) {
   if (cSelector != null && channel != c) {
     c = channel;
     cSelector.setValue(channel);
     SyncWindows.setC(this, channel);
   }
   if (zSelector != null && slice != z) {
     z = slice;
     zSelector.setValue(slice);
     SyncWindows.setZ(this, slice);
   }
   if (tSelector != null && frame != t) {
     t = frame;
     tSelector.setValue(frame);
     SyncWindows.setT(this, frame);
   }
   updatePosition();
   if (this.slice > 0) {
     int s = this.slice;
     this.slice = 0;
     if (s != imp.getCurrentSlice()) imp.setSlice(s);
   }
 }
示例#6
0
 void addScrollbars(ImagePlus imp) {
   ImageStack s = imp.getStack();
   int stackSize = s.getSize();
   nSlices = stackSize;
   hyperStack = imp.getOpenAsHyperStack();
   // imp.setOpenAsHyperStack(false);
   int[] dim = imp.getDimensions();
   int nDimensions = 2 + (dim[2] > 1 ? 1 : 0) + (dim[3] > 1 ? 1 : 0) + (dim[4] > 1 ? 1 : 0);
   if (nDimensions <= 3 && dim[2] != nSlices) hyperStack = false;
   if (hyperStack) {
     nChannels = dim[2];
     nSlices = dim[3];
     nFrames = dim[4];
   }
   // IJ.log("StackWindow: "+hyperStack+" "+nChannels+" "+nSlices+" "+nFrames);
   if (nSlices == stackSize) hyperStack = false;
   if (nChannels * nSlices * nFrames != stackSize) hyperStack = false;
   if (cSelector != null || zSelector != null || tSelector != null) removeScrollbars();
   ImageJ ij = IJ.getInstance();
   if (nChannels > 1) {
     cSelector = new ScrollbarWithLabel(this, 1, 1, 1, nChannels + 1, 'c');
     add(cSelector);
     if (ij != null) cSelector.addKeyListener(ij);
     cSelector.addAdjustmentListener(this);
     cSelector.setFocusable(false); // prevents scroll bar from blinking on Windows
     cSelector.setUnitIncrement(1);
     cSelector.setBlockIncrement(1);
   }
   if (nSlices > 1) {
     char label = nChannels > 1 || nFrames > 1 ? 'z' : 't';
     if (stackSize == dim[2] && imp.isComposite()) label = 'c';
     zSelector = new ScrollbarWithLabel(this, 1, 1, 1, nSlices + 1, label);
     if (label == 't') animationSelector = zSelector;
     add(zSelector);
     if (ij != null) zSelector.addKeyListener(ij);
     zSelector.addAdjustmentListener(this);
     zSelector.setFocusable(false);
     int blockIncrement = nSlices / 10;
     if (blockIncrement < 1) blockIncrement = 1;
     zSelector.setUnitIncrement(1);
     zSelector.setBlockIncrement(blockIncrement);
     sliceSelector = zSelector.bar;
   }
   if (nFrames > 1) {
     animationSelector = tSelector = new ScrollbarWithLabel(this, 1, 1, 1, nFrames + 1, 't');
     add(tSelector);
     if (ij != null) tSelector.addKeyListener(ij);
     tSelector.addAdjustmentListener(this);
     tSelector.setFocusable(false);
     int blockIncrement = nFrames / 10;
     if (blockIncrement < 1) blockIncrement = 1;
     tSelector.setUnitIncrement(1);
     tSelector.setBlockIncrement(blockIncrement);
   }
 }
示例#7
0
 public void setAnimate(boolean b) {
   if (running2 != b && animationSelector != null) animationSelector.updatePlayPauseIcon();
   running2 = b;
 }