    All Packages  Class Hierarchy  This Package  Previous  Next  Index

# Class ncsa.horizon.viewer.BasicSelectionViewer

    java.lang.Object
       |
       +----java.awt.Component
               |
               +----java.awt.Container
                       |
                       +----java.awt.Panel
                               |
                               +----ncsa.horizon.viewer.Viewer
                                       |
                                       +----ncsa.horizon.viewer.SelectionViewer
                                               |
                                               +----ncsa.horizon.viewer.BasicSelectionViewer

public class BasicSelectionViewer
extends SelectionViewer
implements Cloneable

This Viewer provides a basic implementation of the methods needed for a SelectionViewer.

Programmer's are encouraged to inspect this code for examples of how to implement the various Viewer methods.

##

coord
  CoordinateSystem object for converting between data pixels and world coordinates
drawBox
  a flag that is true if the last selected box should be drawn
drawLine
  a flag that is true if the last selected line should be drawn
drawPixel
  a flag that is true if the last selected pixel should be drawn
image
  the last image extracted from the current viewable
mode
  the current display mode (FIT, CENTER, TRUNCATE, or SCALE)
newViewable
  a flag that is true if a new viewable has been attached
pixtrx
  ImageDataOrigin object for converting between display pixels and data pixels
pref_size
  the preferred size of this Panel
selbox
  the last selected display rectangle
selline
  the last selected display line
selpix
  the last selected display pixel
SIZE_IMAGE_CENTER
  Trim the image to the Viewer size (centered)
SIZE_IMAGE_FIT
  Fit the image to the Viewer size (default)
SIZE_IMAGE_SCALE
  Scale the image to the Viewer size (centered)
SIZE_IMAGE_TRUNCATE
  Trim the image to the Viewer size (centered)
slice
  the last slice requested from the current viewable
viewable
  the current viewable

##

BasicSelectionViewer()
  create a BasicSelectionViewer of default preferred size;
BasicSelectionViewer(Dimension)
  create a BasicSelectionViewer of specified preferred size;
BasicSelectionViewer(int, int)
  create a BasicSelectionViewer of specified preferred size;

##

addViewable(Viewable)
  This method adds a reference to a viewable object.
clone()
  Create a clone of this Viewer Panel.
displaySlice()
  Display a default slice of the current Viewable.
displaySlice(Slice)
  Display a slice from the current Viewable data, or do nothing if the current Viewable is not set.
getBoxSelection()
  get the current selected display box.
getDisplaySize()
  This method returns the size of the region that displays a Viewable
getLineSelection()
  get the current selected display Line.
getPixelSelection()
  get the current selected display pixel.
getSliceSelection()
  return the current selected Slice, or null if there is no current Viewable;
getViewable()
  Return a reference to the current Viewable object, or null if none are attached to this Viewer.
getViewSlice()
  return a Slice object describing the data currently being viewed, or null if there is no Viewable currently being viewed.
getVoxelSelection()
  return the current selected Voxel, or null if there is no current Viewable.
imageUpdate(Image, int, int, int, int, int)
  This implementation simple issues a repaint() when an image has become available.
mouseDown(Event, int, int)
  process selection request
mouseDrag(Event, int, int)
  process a box selection request
paint(Graphics)
  This implementationm simply calls the update() method.
preferredSize()
  return the preferred size of this Viewer Panel
setBoxSelection(int, int, int, int)
  set the current selected display box.
setLineSelection(int, int, int, int)
  set the current selected display line.
setMode(int)
  Set the display mode for sizing or trimming the viewable image.
setPixelSelection(int, int)
  set the current selected display pixel.
setSliceSelection(Volume)
  set the current selected Slice to the given Volume as projected onto the currently displayed Slice, or do nothing if there is no current Viewable.
setVoxelSelection(Voxel)
  set the current selected Voxel to the one given as projected onto the currently displayed Slice, or do nothing if there is no current Viewable.
update(Graphics)
  Redraw current slice/viewable.

##

SIZE_IMAGE_FIT

      public final static int SIZE_IMAGE_FIT

  Fit the image to the Viewer size (default)

SIZE_IMAGE_CENTER

      public final static int SIZE_IMAGE_CENTER

  Trim the image to the Viewer size (centered)

SIZE_IMAGE_TRUNCATE

      public final static int SIZE_IMAGE_TRUNCATE

  Trim the image to the Viewer size (centered)

SIZE_IMAGE_SCALE

      public final static int SIZE_IMAGE_SCALE

  Scale the image to the Viewer size (centered)

drawPixel

      public boolean drawPixel

  a flag that is true if the last selected pixel should be drawn

drawBox

      public boolean drawBox

  a flag that is true if the last selected box should be drawn

drawLine

      public boolean drawLine

  a flag that is true if the last selected line should be drawn

viewable

      protected Viewable viewable

  the current viewable

mode

      protected int mode

  the current display mode (FIT, CENTER, TRUNCATE, or SCALE)

image

      protected Image image

  the last image extracted from the current viewable

slice

      protected Slice slice

  the last slice requested from the current viewable

pref_size

      protected Dimension pref_size

  the preferred size of this Panel

pixtrx

      protected ImageDataOrigin pixtrx

  ImageDataOrigin object for converting between display pixels and data pixels

coord

      protected CoordinateSystem coord

  CoordinateSystem object for converting between data pixels and world coordinates

selpix

      protected Point selpix

  the last selected display pixel

selbox

      protected Rectangle selbox

  the last selected display rectangle

selline

      protected Rectangle selline

  the last selected display line

newViewable

      protected boolean newViewable

  a flag that is true if a new viewable has been attached

##

BasicSelectionViewer

      public BasicSelectionViewer()

  create a BasicSelectionViewer of default preferred size;

BasicSelectionViewer

      public BasicSelectionViewer(Dimension size)

  create a BasicSelectionViewer of specified preferred size;

BasicSelectionViewer

      public BasicSelectionViewer(int width,
                                  int height)

  create a BasicSelectionViewer of specified preferred size;

##

addViewable

      public void addViewable(Viewable dataset)

  This method adds a reference to a viewable object.
  Parameters:
    image - the Viewable object to be added
  Overrides:
    addViewable in class Viewer

getViewable

      public Viewable getViewable()

  Return a reference to the current Viewable object, or null if none are attached to this Viewer.
  Returns:
    The current Viewable object; null if none present.
  Overrides:
    getViewable in class Viewer

displaySlice

      public void displaySlice(Slice sl)

  Display a slice from the current Viewable data, or do nothing if the current Viewable is not set. A null slice means display the default slice.
  Overrides:
    displaySlice in class Viewer

displaySlice

      public void displaySlice()

  Display a default slice of the current Viewable.
  Overrides:
    displaySlice in class Viewer

getDisplaySize

      public Dimension getDisplaySize()

  This method returns the size of the region that displays a Viewable
  Returns:
    Dimension of the compoonent
  Overrides:
    getDisplaySize in class Viewer
  See Also:
    Dimension, size()

clone

      public Object clone() throws CloneNotSupportedException

  Create a clone of this Viewer Panel.
  Returns:
    A clone of this object.
  Throws: CloneNotSupportedException
    not thrown if called as a BasicSelectionViewer
  Overrides:
    clone in class Viewer

imageUpdate

      public boolean imageUpdate(Image img,
                                 int flags,
                                 int x,
                                 int y,
                                 int w,
                                 int h)

  This implementation simple issues a repaint() when an image has become available.
  Overrides:
    imageUpdate in class Component

getViewSlice

      public Slice getViewSlice()

  return a Slice object describing the data currently being viewed, or null if there is no Viewable currently being viewed.
  Overrides:
    getViewSlice in class Viewer

setPixelSelection

      public void setPixelSelection(int x,
                                    int y)

  set the current selected display pixel. The location is measured in real display (i.e. screen) pixels relative to the upper left hand corner.
  Overrides:
    setPixelSelection in class SelectionViewer

setBoxSelection

      public void setBoxSelection(int x1,
                                  int y1,
                                  int x2,
                                  int y2)

  set the current selected display box. The locations are measured in real display (i.e. screen) pixels relative to the upper left hand corner.
  Parameters:
    x1,y1 - the location of one vertex of the selected box
    x2,y2 - the location of the vertex of the selected box opposite to the one given by x1,y1
  Overrides:
    setBoxSelection in class SelectionViewer

setLineSelection

      public void setLineSelection(int x1,
                                   int y1,
                                   int x2,
                                   int y2)

  set the current selected display line. The locations are measured in real display (i.e. screen) pixels relative to the upper left hand corner.
  Parameters:
    x1,y1 - the location of the start of the line
    x2,y2 - the location of the end of the line
  Overrides:
    setLineSelection in class SelectionViewer

getPixelSelection

      public Point getPixelSelection()

  get the current selected display pixel.
  Overrides:
    getPixelSelection in class SelectionViewer

getBoxSelection

      public Rectangle getBoxSelection()

  get the current selected display box.
  Overrides:
    getBoxSelection in class SelectionViewer

getLineSelection

      public Rectangle getLineSelection()

  get the current selected display Line.
  Overrides:
    getLineSelection in class SelectionViewer

getVoxelSelection

      public Voxel getVoxelSelection()

  return the current selected Voxel, or null if there is no current Viewable.
  Overrides:
    getVoxelSelection in class SelectionViewer

setVoxelSelection

      public synchronized void setVoxelSelection(Voxel vox)

  set the current selected Voxel to the one given as projected onto the currently displayed Slice, or do nothing if there is no current Viewable.
  Overrides:
    setVoxelSelection in class SelectionViewer

getSliceSelection

      public Slice getSliceSelection()

  return the current selected Slice, or null if there is no current Viewable;
  Overrides:
    getSliceSelection in class SelectionViewer

setSliceSelection

      public synchronized void setSliceSelection(Volume vol)

  set the current selected Slice to the given Volume as projected onto the currently displayed Slice, or do nothing if there is no current Viewable.
  Overrides:
    setSliceSelection in class SelectionViewer

setMode

      public void setMode(int _mode)

  Set the display mode for sizing or trimming the viewable image.
  Parameters:
    _mode - The mode to use. Valid modes are SIZE_IMAGE_FIT, SIZE_IMAGE_CENTER, and SIZE_IMAGE_TRUNCATE.

preferredSize

      public Dimension preferredSize()

  return the preferred size of this Viewer Panel
  Overrides:
    preferredSize in class Container

update

      public void update(Graphics g)

  Redraw current slice/viewable.
  Overrides:
    update in class Component

paint

      public void paint(Graphics g)

  This implementationm simply calls the update() method.
  Parameters:
    g - The graphics context to paint.
  Overrides:
    paint in class Component

mouseDown

      public boolean mouseDown(Event evt,
                               int x,
                               int y)

  process selection request
  Overrides:
    mouseDown in class Component

mouseDrag

      public boolean mouseDrag(Event evt,
                               int x,
                               int y)

  process a box selection request
  Overrides:
    mouseDrag in class Component

    All Packages  Class Hierarchy  This Package  Previous  Next  Index