Class ViewJFrameAnimate

All Implemented Interfaces:
ViewImageUpdateInterface, ActionListener, ComponentListener, WindowListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible, ChangeListener, RootPaneContainer, WindowConstants

public class ViewJFrameAnimate extends ViewJFrameBase implements ChangeListener
This class produces a frame surrounding an image whose slices are animated. Tool bar buttons are present for continuous reverse, reverse, continuous forward, forward, pause, stop, magnify, unmagnify, for generating a dialog to set brightness and contrast, and for deleting the current slice from the animation. In continuous forward the images are continuously displayed from start to end over and over again until pause or stop are hit. If pause is hit, the display may be resumed by repushing the continuous forward button. In forward each image is only displayed once from start to finish unless pause or stop are hit. If pause is hit, the display may be resumed by repushing the forward button. Continuous reverse and reverse work the same way as continuous forward and forward except for a reversal in direction. Users can instantly jump from one mode to another without hitting stop ro pause - from continuous forward to continuous reverse for example. Magnify will double the present magnification and Unmagnify will half the present magnification. Magnifications are only powers of 2. However, the scale function can be set to any value in the dialog box called up by JDialogAnimate. This scale function will do a slice by slice bilinear of bspline interpolation to create the initial slices on which the power of 2 magnification may be changed.

The dialog box for brightness and contrast has brightness and contrast sliders, an Apply button, and a Cancel button. The brightness will add an offset ranging from -255 to 255 to every scaled red, green, and blue in the image. Contrast will multiply every original red, green, and blue value by a floating point number ranging from 0.1 to 10.0. Before apply is pressed, slider changes are only temporarily made to the currently displayed slice. If apply is pressed, these changes are permanently made to all slices. Pressing cancel keeps all slices in their original state.

Images may also be viewed in a steady state mode. The slider is used to control the number of the slice shown when animation is not occurring. A text field for the desired frames per second is present. The initial default value is 30 per second. This is followed by a text field for the actual frames per second.

The file menu only has 2 simple functions - a save as function and a close animate structure function. The options menu has a view z slice numbers for use for 4D images.

ViewJFrameAnimate is called in ViewJFrameImage.

An animation of a blended image A and image B can be performed. However, all the blending parameters must be set before the animation structure is created. One parameter is alphaBlend for all images. For color only are also the parameters: RaOn, GaOn, BaOn, RbOn, GbOn, BbOn, RGBTA, and RGBTB. Changes in these parmeters that are made after the animation structure is created will not be propagated into the animation structure.

If 4D images are animated, the animation is performed on the fourth time dimension with all the z slices for a given time present in a given frame. The number of rows or columns for the z slices, whether or not a border frame is present around z slices, and the border frame color are all selected in JDialogAnimate before ViewJFrameAnimate is invoked. Note that JDialogAnimate converts all 4D images to 3D images so ViewJFrameAnimate actually is always passed 3D images.

Version:
1.0
See Also:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      Use serialVersionUID for interoperability.
      See Also:
    • toggleArray

      public JToggleButton[] toggleArray
      DOCUMENT ME!
    • progressBar

      ViewJProgressBar progressBar
      currently running.
    • actualPerSecond

      private float actualPerSecond
      DOCUMENT ME!
    • alphaBlend

      private float alphaBlend
      DOCUMENT ME!
    • aps

      private String aps
      set to give 2 digits to the right of the decimal.
    • backForthButton

      private JToggleButton backForthButton
      DOCUMENT ME!
    • bfRun

      private boolean bfRun
      DOCUMENT ME!
    • borderCol

      private Color borderCol
      z slice.
    • buttonArray

      private JButton[] buttonArray
      DOCUMENT ME!
    • cForwardButton

      private JToggleButton cForwardButton
      DOCUMENT ME!
    • cfRun

      private boolean cfRun
      DOCUMENT ME!
    • componentImage

      private ViewJComponentAnimate componentImage
      with complex images.
    • componentY

      private int componentY
      DOCUMENT ME!
    • controlFrame

      private ViewJFrameBase controlFrame
      DOCUMENT ME!
    • controlPanel

      private JPanel controlPanel
      DOCUMENT ME!
    • controls

      private ViewControlsImage controls
      DOCUMENT ME!
    • cpGBC

      private GridBagConstraints cpGBC
      DOCUMENT ME!
    • cpGBL

      private GridBagLayout cpGBL
      DOCUMENT ME!
    • cReverseButton

      private JToggleButton cReverseButton
      DOCUMENT ME!
    • crRun

      private boolean crRun
      DOCUMENT ME!
    • cycleTime

      private long cycleTime
      DOCUMENT ME!
    • deleteButton

      private JButton deleteButton
      DOCUMENT ME!
    • disposeImage

      private boolean disposeImage
      DOCUMENT ME!
    • etchedBorder

      private Border etchedBorder
      DOCUMENT ME!
    • extents

      private int[] extents
      DOCUMENT ME!
    • forwardButton

      private JToggleButton forwardButton
      DOCUMENT ME!
    • fpsSlider

      private JSlider fpsSlider
      DOCUMENT ME!
    • framesPerSecond

      private float framesPerSecond
      DOCUMENT ME!
    • fRun

      private boolean fRun
      DOCUMENT ME!
    • gbcTP

      private GridBagConstraints gbcTP
      DOCUMENT ME!
    • imageA

      private ModelImage imageA
      DOCUMENT ME!
    • imageB

      private ModelImage imageB
      DOCUMENT ME!
    • imageBufferA

      private float[] imageBufferA
      DOCUMENT ME!
    • imageBufferB

      private float[] imageBufferB
      DOCUMENT ME!
    • innerPanel

      private JPanel innerPanel
      DOCUMENT ME!
    • labelAnimationFrame

      private JLabel labelAnimationFrame
      DOCUMENT ME!
    • labelFramesPerSecond

      private JLabel labelFramesPerSecond
      DOCUMENT ME!
    • labelTable

      private Hashtable<Integer,JLabel> labelTable
      DOCUMENT ME!
    • localTime

      private long localTime
      newmsWait = msWait - msElapsed is passed to the sleep function.
    • localTime2

      private long localTime2
      DOCUMENT ME!
    • logMagDisplay

      private boolean logMagDisplay
      DOCUMENT ME!
    • LUTa

      private ModelLUT LUTa
      DOCUMENT ME!
    • LUTb

      private ModelLUT LUTb
      DOCUMENT ME!
    • minimumHeight

      private int minimumHeight
      DOCUMENT ME!
    • minimumToolBarWidth

      private int minimumToolBarWidth
      DOCUMENT ME!
    • mjpegQuality

      private float mjpegQuality
      DOCUMENT ME!
    • msElapsed

      private long msElapsed
      DOCUMENT ME!
    • msWait

      private long msWait
      DOCUMENT ME!
    • nColumn

      private int nColumn
      DOCUMENT ME!
    • newmsWait

      private long newmsWait
      DOCUMENT ME!
    • nf

      private NumberFormat nf
      DOCUMENT ME!
    • nImage

      private int nImage
      DOCUMENT ME!
    • nRow

      private int nRow
      DOCUMENT ME!
    • openingMenuBar

      private JMenuBar openingMenuBar
      DOCUMENT ME!
    • origBrightness

      private int origBrightness
      DOCUMENT ME!
    • origContrast

      private float origContrast
      red, green, and blue origBrightness remains constant until applyButton is pressed, restores brightness if cancelButton is pressed.
    • originalZDim

      private int originalZDim
      for 4D originalXDim and originalYDim are xDim and yDim before 4D to 3D conversion.
    • paintBuffer

      private int[] paintBuffer
      DOCUMENT ME!
    • pause

      private boolean pause
      DOCUMENT ME!
    • pauseButton

      private JToggleButton pauseButton
      DOCUMENT ME!
    • pixBuffer

      private int[] pixBuffer
      DOCUMENT ME!
    • pressedBorder

      private Border pressedBorder
      DOCUMENT ME!
    • recordButton

      private JButton recordButton
      DOCUMENT ME!
    • reverseButton

      private JToggleButton reverseButton
      DOCUMENT ME!
    • RGBTA

      private ModelRGB RGBTA
      DOCUMENT ME!
    • RGBTB

      private ModelRGB RGBTB
      DOCUMENT ME!
    • rRun

      private boolean rRun
      currently running.
    • scrollPane

      private JScrollPane scrollPane
      DOCUMENT ME!
    • scrollPaneSize

      private int scrollPaneSize
      DOCUMENT ME!
    • showFrameBorder

      private boolean showFrameBorder
      DOCUMENT ME!
    • showNumbers

      private boolean showNumbers
      equals zDim of original 4D before 4D to 3D conversion.
    • sliceOldNumber

      private int[] sliceOldNumber
      red, green, and blue origContrast remains constant until applyButton is pressed, restores contrast if cancelButton is pressed.
    • slider

      private JSlider slider
      DOCUMENT ME!
    • startTime

      private long startTime
      = localTime2 - localTime.
    • stopTime

      private long stopTime
      = localTime2 - localTime.
    • stop

      private boolean stop
      containing only 5 msec. sleep commands.
    • stopButton

      private JToggleButton stopButton
      DOCUMENT ME!
    • structureY

      private int structureY
      DOCUMENT ME!
    • textActualPerSecond

      private JTextField textActualPerSecond
      DOCUMENT ME!
    • textAnimationFrame

      private JTextField textAnimationFrame
      Note that an attempt to have DocumentListener for textAnimationFrame set the slider value was unsuccessful.
    • textFramesPerSecond

      private JTextField textFramesPerSecond
      DOCUMENT ME!
    • toolBar

      private JToolBar toolBar
      DOCUMENT ME!
    • topPanel

      private JPanel topPanel
      and innerPanel placed in scrollPane.
    • xScreen

      private int xScreen
      DOCUMENT ME!
    • yScreen

      private int yScreen
      DOCUMENT ME!
    • zoom

      private float zoom
      DOCUMENT ME!
    • zShow

      private int zShow
      DOCUMENT ME!
    • zSlice

      private int zSlice
      DOCUMENT ME!
  • Constructor Details

    • ViewJFrameAnimate

      public ViewJFrameAnimate(ModelImage _imageA, ModelLUT _LUTa, ModelImage _imageB, ModelLUT _LUTb, ModelRGB _RGBTA, ModelRGB _RGBTB, ViewJFrameBase controlFrame, int nRow, int nColumn, int originalZDim, boolean showFrameBorder, Color borderCol, boolean disposeImage)
      Makes a frame of the animated image.
      Parameters:
      _imageA - Model of imageA
      _LUTa - Model of LUT for image A
      _imageB - Model of imageB
      _LUTb - Model of LUT for image B
      _RGBTA - Model RGB LUT for color image (A) else null
      _RGBTB - Model RGB LUT for color image (B) else null
      controlFrame - ViewJFrameBase passed to ViewJComponentAnimate
      nRow - rows of z images in 4D images
      nColumn - columns of z images in 4D images
      originalZDim - for 4D images equals zDim before 4D to 3D conversion
      showFrameBorder - puts colored borders around z images in 4D images
      borderCol - color of the z image borders
      disposeImage - dispose of imageA and imageB on frame close
  • Method Details

    • actionPerformed

      public void actionPerformed(ActionEvent event)
      Calls various methods depending on the action.
      Specified by:
      actionPerformed in interface ActionListener
      Specified by:
      actionPerformed in class ViewJFrameBase
      Parameters:
      event - event that triggered function
    • cancelBrightness

      public void cancelBrightness()
      Resets current slice's brightness and contrast to original.
    • componentResized

      public void componentResized(ComponentEvent event)
      Resizes frame and all components.
      Specified by:
      componentResized in interface ComponentListener
      Overrides:
      componentResized in class ViewJFrameBase
      Parameters:
      event - event that triggered function
    • dispose

      public void dispose()
      Disposes of components and frame.
      Overrides:
      dispose in class Window
    • getControls

      public ViewControlsImage getControls()
      Get control widgets for frame.
      Specified by:
      getControls in class ViewJFrameBase
      Returns:
      controls
    • getImageA

      public ModelImage getImageA()
      Accessor that returns the reference to imageA.
      Specified by:
      getImageA in class ViewJFrameBase
      Returns:
      image
    • getImageB

      public ModelImage getImageB()
      Accessor that returns the reference to imageB.
      Specified by:
      getImageB in class ViewJFrameBase
      Returns:
      imageB
    • removeControls

      public void removeControls()
      Does nothing.
      Specified by:
      removeControls in class ViewJFrameBase
    • setActiveImage

      public void setActiveImage(int active)
      Does nothing.
      Specified by:
      setActiveImage in class ViewJFrameBase
      Parameters:
      active - DOCUMENT ME!
    • setAlphaBlend

      public void setAlphaBlend(int value)
      Does nothing.
      Specified by:
      setAlphaBlend in class ViewJFrameBase
      Parameters:
      value - DOCUMENT ME!
    • setBrightness

      public void setBrightness(int brightness, float contrast)
      Sets the brightness and contrast of the component image. Set all slices to have the new brightness and contrast. Results in createImage producing an Image img[slice] for every slice.
      Parameters:
      brightness - Brightness to set.
      contrast - Contrast to set.
    • setControls

      public void setControls()
      Does nothing.
      Specified by:
      setControls in class ViewJFrameBase
    • setDisposeImages

      public void setDisposeImages(boolean doDispose)
      DOCUMENT ME!
      Parameters:
      doDispose - DOCUMENT ME!
    • setEnabled

      public void setEnabled(boolean flag)
      Does nothing.
      Specified by:
      setEnabled in class ViewJFrameBase
      Parameters:
      flag - DOCUMENT ME!
    • setFramesPerSecond

      public void setFramesPerSecond(int fps)
      Sets the slider value (for invoking save image from dialog).
      Parameters:
      fps - int frames per second
    • setImageB

      public void setImageB(ModelImage _imageB)
      Does nothing.
      Specified by:
      setImageB in class ViewJFrameBase
      Parameters:
      _imageB - DOCUMENT ME!
    • setPaintBitmapSwitch

      public void setPaintBitmapSwitch(boolean paintBitmapSwitch)
      Does nothing.
      Specified by:
      setPaintBitmapSwitch in class ViewJFrameBase
      Parameters:
      paintBitmapSwitch - DOCUMENT ME!
    • setRGBTA

      public void setRGBTA(ModelRGB RGBT)
      Sets the RGB LUT table for ARGB image A.
      Specified by:
      setRGBTA in class ViewJFrameBase
      Parameters:
      RGBT - the new RGB LUT to be applied to the image
    • setRGBTB

      public void setRGBTB(ModelRGB RGBT)
      Sets the RGB LUT table for ARGB image B.
      Specified by:
      setRGBTB in class ViewJFrameBase
      Parameters:
      RGBT - the new RGB LUT to be applied to the image
    • setSlice

      public void setSlice(int slice)
      Sets the slice to be displayed and updates title frame.
      Specified by:
      setSlice in interface ViewImageUpdateInterface
      Parameters:
      slice - indicates image slice to be displayed
    • setTimeSlice

      public void setTimeSlice(int slice)
      Does nothing.
      Specified by:
      setTimeSlice in interface ViewImageUpdateInterface
      Parameters:
      slice - DOCUMENT ME!
    • setTitle

      public void setTitle()
      Set the title of the frame with the image name and magnification.
      Specified by:
      setTitle in class ViewJFrameBase
    • stateChanged

      public void stateChanged(ChangeEvent e)
      Sets values based on knob along slider.
      Specified by:
      stateChanged in interface ChangeListener
      Overrides:
      stateChanged in class ViewJFrameBase
      Parameters:
      e - Event that triggered this function
    • updateFrame

      public void updateFrame(float sX, float sY)
      Does nothing.
      Parameters:
      sX - DOCUMENT ME!
      sY - DOCUMENT ME!
    • updateImageExtents

      public boolean updateImageExtents()
      Does nothing.
      Specified by:
      updateImageExtents in interface ViewImageUpdateInterface
      Specified by:
      updateImageExtents in class ViewJFrameBase
      Returns:
      DOCUMENT ME!
      See Also:
    • updateImages

      public final boolean updateImages()
      Does nothing.
      Specified by:
      updateImages in interface ViewImageUpdateInterface
      Returns:
      DOCUMENT ME!
    • updateImages

      public final boolean updateImages(boolean forceShow)
      This methods calls the componentImage's update method to redraw the screen. Without LUT changes.
      Specified by:
      updateImages in interface ViewImageUpdateInterface
      Parameters:
      forceShow - unused parameter
      Returns:
      boolean confirming successful update
    • updateImages

      public final boolean updateImages(ModelLUT LUTa, ModelLUT LUTb, boolean forceShow, int interpMode)
      Does nothing.
      Specified by:
      updateImages in interface ViewImageUpdateInterface
      Parameters:
      LUTa - DOCUMENT ME!
      LUTb - DOCUMENT ME!
      forceShow - DOCUMENT ME!
      interpMode - DOCUMENT ME!
      Returns:
      DOCUMENT ME!
    • windowActivated

      public void windowActivated(WindowEvent event)
      Does nothing.
      Specified by:
      windowActivated in interface WindowListener
      Overrides:
      windowActivated in class ViewJFrameBase
      Parameters:
      event - DOCUMENT ME!
    • windowClosed

      public void windowClosed(WindowEvent event)
      Does nothing.
      Specified by:
      windowClosed in interface WindowListener
      Overrides:
      windowClosed in class ViewJFrameBase
      Parameters:
      event - DOCUMENT ME!
    • windowClosing

      public void windowClosing(WindowEvent event)
      Stops thread, calls close.
      Specified by:
      windowClosing in interface WindowListener
      Overrides:
      windowClosing in class ViewJFrameBase
      Parameters:
      event - event that triggered function
    • windowDeactivated

      public void windowDeactivated(WindowEvent event)
      Does nothing.
      Specified by:
      windowDeactivated in interface WindowListener
      Overrides:
      windowDeactivated in class ViewJFrameBase
      Parameters:
      event - DOCUMENT ME!
    • windowDeiconified

      public void windowDeiconified(WindowEvent event)
      Does nothing.
      Specified by:
      windowDeiconified in interface WindowListener
      Overrides:
      windowDeiconified in class ViewJFrameBase
      Parameters:
      event - DOCUMENT ME!
    • windowIconified

      public void windowIconified(WindowEvent event)
      Does nothing.
      Specified by:
      windowIconified in interface WindowListener
      Overrides:
      windowIconified in class ViewJFrameBase
      Parameters:
      event - DOCUMENT ME!
    • windowOpened

      public void windowOpened(WindowEvent event)
      Does nothing.
      Specified by:
      windowOpened in interface WindowListener
      Overrides:
      windowOpened in class ViewJFrameBase
      Parameters:
      event - DOCUMENT ME!
    • testParameter

      protected boolean testParameter(String str, double minValue, double maxValue)
      Tests that the entered parameter is in range.
      Parameters:
      str - the value entered by the user
      minValue - the minimum value this variable may be set to
      maxValue - the maximum value this variable may be set to
      Returns:
      boolean result of test
    • addControlPanel

      private void addControlPanel(Component c, GridBagConstraints gbc, int x, int y, int w, int h)
      Method that adds components to the control paenl.
      Parameters:
      c - component added to the control panel
      gbc - GridBagConstraints of added component
      x - grdix location
      y - gridy location
      w - gridwidth
      h - gridheight
    • buildAnimateToolBar

      private JToolBar buildAnimateToolBar(ActionListener al)
      Method to build the toolbar for the Animate frame.
      Parameters:
      al - Action listener (this frame)
      Returns:
      The animation toolbar
    • buildControlPanel

      private void buildControlPanel()
      Panel that sets the at rest frame number and the desired frames per second and reports the actual frames per second.
    • buildMenu

      private void buildMenu()
      This method builds a menu which contains the options Save image as and Close Animate.
    • buildScrollPane

      private void buildScrollPane()
      Make a scroll frame and puts an image component into it.
    • createLabel

      private JLabel createLabel(String title)
      Helper method to create a label with the proper font and font color.
      Parameters:
      title - Text of the label.
      Returns:
      New label.
    • makeSeparator

      private JButton makeSeparator()
      Makes a separator for the use in the toolbars.
      Returns:
      Separator button.