Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.modama.gui.viewer
Class JAIAdjustableImage  view JAIAdjustableImage download JAIAdjustableImage.java

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JPanel
                  extended byorg.modama.gui.viewer.JAIAdjustableImage
All Implemented Interfaces:
javax.accessibility.Accessible, ICoordinatesystem, java.awt.image.ImageObserver, IViewer, java.awt.MenuContainer, java.io.Serializable

public class JAIAdjustableImage
extends javax.swing.JPanel
implements IViewer

org.modama.viewer for JAI images ability to move, zoom and rotating the image its also posible to add JComponents that are drawn over the image this is the second version of this class, new fetaeures are:
- the image is drawn with a Graphics2D object - a AffineTransform is used to do scaling and rotating - optional a LUT can be specified their is one important thing about the lut, because JAI doesnt suport lookupfunctions for floatingpointvalues, the image is transformed to USHORT if its DOUBLE or FLOAT, where the minimum value will be 0 and the maximumvalue will be 65535, you have to take care of this when you create a LUT for such an image


Nested Class Summary
 
Nested classes inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected  java.awt.image.RenderedImage image
          src image
protected  java.awt.image.Raster imageraster
          for getting the pixelvalues the raster of the image is needed, we save this, so we dont have to do call getData twice,
protected  LookupTableJAI lut
          a lookuptable can be specified that will be applied to the image
protected  double maxlutvalue
          these values are used to rescale the image to USHORT values from 0 to 65535, the same range as the lut, so they represent the range of the lut
protected  double maxpixelvalue
          smallest and biggest value of the image
protected  double minlutvalue
          these values are used to rescale the image to USHORT values from 0 to 65535, the same range as the lut, so they represent the range of the lut
protected  double minpixelvalue
          smallest and biggest value of the image
protected  java.awt.image.RenderedImage processed
          processed image (after Lookuptable operation, if their is no lut, its the source image)
protected  double scalex
          scaling factors for zooming size of the image source.width * scalex, source.height * scaley
protected  double scaley
          scaling factors for zooming size of the image source.width * scalex, source.height * scaley
protected  TransposeType transpose
          transposing (flip or rotate by multiples of 90)
is one of the values defined in TransposeDescriptor !!!!! this is not needed at the moment so it has no effect
protected  java.awt.Point viewposition
          position of the image (to get the sourceimage coordinat divide by scale)
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Container
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
JAIAdjustableImage()
          constructors
JAIAdjustableImage(java.awt.image.RenderedImage image)
          constructor sets the image
 
Method Summary
 void addCursor(org.modama.gui.viewer.cursor.EmptyCursor newcursor)
          sets a new cursor and registers him as mouseinputlistener
 void calcLUT()
          do a lookup operation on the image, if its floatingpoint, its rescaled to USHORT
protected  void calcMinMax()
          calculates the minpixelvalue and the maxpixelvalue from the image
 java.awt.image.RenderedImage createThumbnail(int width)
          creates a thumbnail with the given width
protected  java.awt.geom.Point2D.Double getCenterPoint()
          gets the image point the corrosponds to the center of the displayed image
 java.awt.geom.Point2D.Double getCoordinate(java.awt.Point screen)
           
 double getCoordinateX(int screenx)
           
 double getCoordinateY(int screeny)
           
 java.awt.image.RenderedImage getImage()
          gets the image
 java.awt.image.Raster getImageRaster()
          gets the raster for the image
 LookupTableJAI getLookupTable()
           
 double getMaxLUTValue()
          gets the value that corresponds to the last lookup entry
 double getMaxPixelValue()
           
 double getMinLUTValue()
          gets the value that corresponds to the first lookup entry
 double getMinPixelValue()
           
 double[] getPixelValue(int x, int y)
          gets the value of the given pixel from the image, x and y are in sourceimage coordinates not screencoordinates
 int getPosx()
           
 int getPosy()
           
 java.awt.image.RenderedImage getProcessedImage()
          returns the processed image, this is only different from getImage if a lookuptable is specified
 double getScalex()
           
 double getScaley()
           
 java.awt.Point getScreen(java.awt.geom.Point2D.Double object)
           
 int getScreenX(double objectx)
           
 int getScreenY(double objecty)
           
 java.awt.image.RenderedImage getThumbnail()
          gets the thumbnail, creates it, if its the first time called
 java.awt.Point getViewPosition()
          gets the position of the image
 void loadParamsFromAnotherViewer(IViewer viewer)
          gets the parameters from another viewer, this is usefull if the this viewer should show extactly the same as viewer
protected  void paintComponent(java.awt.Graphics g)
          paints the image
 void removeAllCursors()
          removes all components that are an EmptyCursor from this Container
 void removeCursor(org.modama.gui.viewer.cursor.EmptyCursor cursor)
          removes a cursor
protected  void resetParams()
          resets the intern parameters
 void setAutoScale(boolean keepproportion)
          zooms the image so, it fits exactly into the panel
 void setImage(java.awt.image.RenderedImage image)
          sets the image also resets zooming, position and transposing
 void setLookupTable(LookupTableJAI lut)
           
 void setLUTValues(double minlutvalue, double maxlutvalue)
          sets the values that corresponds to the first and last lookup entry
 void setMaxLUTValue(double maxlutvalue)
          sets the value that corresponds to the last lookup entry
 void setMinLUTValue(double minlutvalue)
          sets the value that corresponds to the first lookup entry
protected  void setPointToCenter(java.awt.geom.Point2D.Double point)
          moves the image so, that the point is showed in the center
protected  void setPreferredSize()
          sets the preferred size of this container
 void setScale(double scalex, double scaley)
          set zoominfactors of the picture
 void setScalex(double scalex)
          set the scaling for the x coordinates
 void setScaley(double scaley)
          set the scaling for the y coordinates
 void setViewPosition(int x, int y, boolean keep_image_in_sight)
          sets the postion of the image x and y are in pixels of the zoomed image
 void setViewPosition(java.awt.Point viewposition)
          sets the position of the image and keeps it in sight
 void translate(int x, int y, boolean keep_image_in_sight)
          translates the imageposition
 void transpose(TransposeType type)
          transposes the image (flip or rotate by multiples of 90) the type is one of the values defined in TransposeDescriptor
Transpose type : 0=FLIP_VERTICAL
: 1=FLIP_HORIZONTAL
: 2=FLIP_DIAGONAL
: 3=FLIP_ANTIDIAGONAL
: 4=ROTATE_90
: 5=ROTATE_180
: 6=ROTATE_270
type == null means no transpoing !!!!!!! this is not needed at the moment so it has no effect
 void zoomfit()
          zooms the image so it fits into the panel
 void zoomin()
          zooms in so that the center stays
 void zoomout()
          zooms out
 void zoomreset()
          zoom reset, set scale to 1
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.modama.gui.viewer.IViewer
getHeight, getPreferredSize, getWidth, repaint, setCursor
 

Field Detail

image

protected java.awt.image.RenderedImage image
src image


imageraster

protected java.awt.image.Raster imageraster
for getting the pixelvalues the raster of the image is needed, we save this, so we dont have to do call getData twice,


processed

protected java.awt.image.RenderedImage processed
processed image (after Lookuptable operation, if their is no lut, its the source image)


scalex

protected double scalex
scaling factors for zooming size of the image source.width * scalex, source.height * scaley


scaley

protected double scaley
scaling factors for zooming size of the image source.width * scalex, source.height * scaley


viewposition

protected java.awt.Point viewposition
position of the image (to get the sourceimage coordinat divide by scale)


transpose

protected TransposeType transpose
transposing (flip or rotate by multiples of 90)
is one of the values defined in TransposeDescriptor !!!!! this is not needed at the moment so it has no effect


lut

protected LookupTableJAI lut
a lookuptable can be specified that will be applied to the image


minpixelvalue

protected double minpixelvalue
smallest and biggest value of the image


maxpixelvalue

protected double maxpixelvalue
smallest and biggest value of the image


minlutvalue

protected double minlutvalue
these values are used to rescale the image to USHORT values from 0 to 65535, the same range as the lut, so they represent the range of the lut


maxlutvalue

protected double maxlutvalue
these values are used to rescale the image to USHORT values from 0 to 65535, the same range as the lut, so they represent the range of the lut

Constructor Detail

JAIAdjustableImage

public JAIAdjustableImage()
constructors


JAIAdjustableImage

public JAIAdjustableImage(java.awt.image.RenderedImage image)
constructor sets the image

Method Detail

setScale

public void setScale(double scalex,
                     double scaley)
set zoominfactors of the picture

Specified by:
setScale in interface IViewer

setAutoScale

public void setAutoScale(boolean keepproportion)
zooms the image so, it fits exactly into the panel

Specified by:
setAutoScale in interface IViewer

setScalex

public void setScalex(double scalex)
set the scaling for the x coordinates

Specified by:
setScalex in interface IViewer

setScaley

public void setScaley(double scaley)
set the scaling for the y coordinates

Specified by:
setScaley in interface IViewer

getScalex

public double getScalex()
Specified by:
getScalex in interface IViewer

getScaley

public double getScaley()
Specified by:
getScaley in interface IViewer

setViewPosition

public void setViewPosition(int x,
                            int y,
                            boolean keep_image_in_sight)
sets the postion of the image x and y are in pixels of the zoomed image

Specified by:
setViewPosition in interface IViewer

getViewPosition

public java.awt.Point getViewPosition()
gets the position of the image

Specified by:
getViewPosition in interface IViewer

getPosx

public int getPosx()
Specified by:
getPosx in interface IViewer

getPosy

public int getPosy()
Specified by:
getPosy in interface IViewer

setViewPosition

public void setViewPosition(java.awt.Point viewposition)
sets the position of the image and keeps it in sight

Specified by:
setViewPosition in interface IViewer

translate

public void translate(int x,
                      int y,
                      boolean keep_image_in_sight)
translates the imageposition

Specified by:
translate in interface IViewer

transpose

public void transpose(TransposeType type)
transposes the image (flip or rotate by multiples of 90) the type is one of the values defined in TransposeDescriptor
Transpose type : 0=FLIP_VERTICAL
: 1=FLIP_HORIZONTAL
: 2=FLIP_DIAGONAL
: 3=FLIP_ANTIDIAGONAL
: 4=ROTATE_90
: 5=ROTATE_180
: 6=ROTATE_270
type == null means no transpoing !!!!!!! this is not needed at the moment so it has no effect


setImage

public void setImage(java.awt.image.RenderedImage image)
sets the image also resets zooming, position and transposing

Specified by:
setImage in interface IViewer

getImage

public java.awt.image.RenderedImage getImage()
gets the image

Specified by:
getImage in interface IViewer

getImageRaster

public java.awt.image.Raster getImageRaster()
gets the raster for the image

Specified by:
getImageRaster in interface IViewer

getPixelValue

public double[] getPixelValue(int x,
                              int y)
gets the value of the given pixel from the image, x and y are in sourceimage coordinates not screencoordinates

Specified by:
getPixelValue in interface IViewer

getProcessedImage

public java.awt.image.RenderedImage getProcessedImage()
returns the processed image, this is only different from getImage if a lookuptable is specified

Specified by:
getProcessedImage in interface IViewer

getLookupTable

public LookupTableJAI getLookupTable()
Specified by:
getLookupTable in interface IViewer

setLookupTable

public void setLookupTable(LookupTableJAI lut)
Specified by:
setLookupTable in interface IViewer

removeAllCursors

public void removeAllCursors()
removes all components that are an EmptyCursor from this Container

Specified by:
removeAllCursors in interface IViewer

removeCursor

public void removeCursor(org.modama.gui.viewer.cursor.EmptyCursor cursor)
removes a cursor

Specified by:
removeCursor in interface IViewer

addCursor

public void addCursor(org.modama.gui.viewer.cursor.EmptyCursor newcursor)
sets a new cursor and registers him as mouseinputlistener

Specified by:
addCursor in interface IViewer

getMinPixelValue

public double getMinPixelValue()
Specified by:
getMinPixelValue in interface IViewer

getMaxPixelValue

public double getMaxPixelValue()
Specified by:
getMaxPixelValue in interface IViewer

getMinLUTValue

public double getMinLUTValue()
gets the value that corresponds to the first lookup entry

Specified by:
getMinLUTValue in interface IViewer

setMinLUTValue

public void setMinLUTValue(double minlutvalue)
sets the value that corresponds to the first lookup entry

Specified by:
setMinLUTValue in interface IViewer

getMaxLUTValue

public double getMaxLUTValue()
gets the value that corresponds to the last lookup entry

Specified by:
getMaxLUTValue in interface IViewer

setMaxLUTValue

public void setMaxLUTValue(double maxlutvalue)
sets the value that corresponds to the last lookup entry

Specified by:
setMaxLUTValue in interface IViewer

setLUTValues

public void setLUTValues(double minlutvalue,
                         double maxlutvalue)
sets the values that corresponds to the first and last lookup entry

Specified by:
setLUTValues in interface IViewer

zoomin

public void zoomin()
zooms in so that the center stays

Specified by:
zoomin in interface IViewer

zoomout

public void zoomout()
zooms out

Specified by:
zoomout in interface IViewer

zoomreset

public void zoomreset()
zoom reset, set scale to 1

Specified by:
zoomreset in interface IViewer

zoomfit

public void zoomfit()
zooms the image so it fits into the panel

Specified by:
zoomfit in interface IViewer

getThumbnail

public java.awt.image.RenderedImage getThumbnail()
gets the thumbnail, creates it, if its the first time called

Specified by:
getThumbnail in interface IViewer

createThumbnail

public java.awt.image.RenderedImage createThumbnail(int width)
creates a thumbnail with the given width

Specified by:
createThumbnail in interface IViewer

paintComponent

protected void paintComponent(java.awt.Graphics g)
paints the image


resetParams

protected void resetParams()
resets the intern parameters


loadParamsFromAnotherViewer

public void loadParamsFromAnotherViewer(IViewer viewer)
gets the parameters from another viewer, this is usefull if the this viewer should show extactly the same as viewer

Specified by:
loadParamsFromAnotherViewer in interface IViewer

calcMinMax

protected void calcMinMax()
calculates the minpixelvalue and the maxpixelvalue from the image


calcLUT

public void calcLUT()
do a lookup operation on the image, if its floatingpoint, its rescaled to USHORT

Specified by:
calcLUT in interface IViewer

getCenterPoint

protected java.awt.geom.Point2D.Double getCenterPoint()
gets the image point the corrosponds to the center of the displayed image


setPointToCenter

protected void setPointToCenter(java.awt.geom.Point2D.Double point)
moves the image so, that the point is showed in the center


setPreferredSize

protected void setPreferredSize()
sets the preferred size of this container


getCoordinateX

public double getCoordinateX(int screenx)
Specified by:
getCoordinateX in interface IViewer

getCoordinateY

public double getCoordinateY(int screeny)
Specified by:
getCoordinateY in interface IViewer

getCoordinate

public java.awt.geom.Point2D.Double getCoordinate(java.awt.Point screen)
Specified by:
getCoordinate in interface IViewer

getScreenX

public int getScreenX(double objectx)
Specified by:
getScreenX in interface IViewer

getScreenY

public int getScreenY(double objecty)
Specified by:
getScreenY in interface IViewer

getScreen

public java.awt.Point getScreen(java.awt.geom.Point2D.Double object)
Specified by:
getScreen in interface IViewer