jview
Class JFitsComponent

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by jview.JFitsComponent
All Implemented Interfaces:
ImageObserver, MenuContainer, PropertyChangeListener, Serializable, EventListener, Accessible, ChangeListener, Initializable, PropertyAware, PropertyComposed, ImageOperation, Savable

public class JFitsComponent
extends JPanel
implements Initializable, PropertyComposed, Savable, ChangeListener, PropertyChangeListener, ImageOperation

A special extension to JFitsCanvas that displays two sliders for adjusting contrast and brightness of the displayed fits image. It works together with the JCamera class.

See Also:
Serialized Form

Nested Class Summary
static class JFitsComponent.Show
          A test class.
 
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
private  double bright
          The last brightness of the image.
private  JSlider brightness
          The brightness slider.
private  double contrast
          The last contrast of the image.
private  JSlider contrastrate
          The contrast slider.
private static double DEFBRIGHTNESS
          Default brightness value.
private static boolean DEFCONTINUOUS
          Default property value.
private static double DEFCONTRAST
          Default contrast value.
private static int DEFICONSIZE
          The default icon size.
private static boolean DEFONADJUST
          Default not.
private  JFitsCanvas fitscanvas
          The fits canvas served by this panel.
private  PropertySupplying info
          My properties, also a handle to the fitscanvas properites.
static String KEY_BRIGHTNESS
          The default brightness value.
static String KEY_CONTINUOUS
          Always fill full view or snap to integer scales.
static String KEY_CONTRAST
          The default contrast value.
static String KEY_ICONSIZE
          The size of the brightness and contrast icon.
static String KEY_ONADJUST
          If true we allow b/c adjustment on slider move.
 
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.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
JFitsComponent(JFitsCanvas fits)
          Constructs a new fits component.
 
Method Summary
 double getBrightness()
          Returns the current brightness.
protected  JFitsCanvas getCanvas()
          Returns the fits canvas.
 PropertySupplying getComposedProperties()
          Returns the properties of the panel and the properties of the fits canvas.
 double getContrast()
          Returns the current contrast on the image in the range of -1 to +1.
 Map<String,Object> getDisplayMap()
           
 BufferedImage getSaveBuffer()
          Returns the buffered image from the fits canvas.
 void init()
          Initializes the shape canvas.
 BufferedImage prepareToDisplay(BufferedImage src)
          Rescales the image to display the new brightness and contrast.
 void propertyChange(PropertyChangeEvent e)
          Notified when the fits canvas has been reset.
 boolean setBrightness(double newbright)
          Sets the brightness of the image.
 void setComposedProperties(PropertySupplying prop)
          Defaults the icon size.
 boolean setContrast(double newcontrast)
          Sets the contrast of the image.
 void stateChanged(ChangeEvent e)
          Invoked when the contrast or brightness slider was moved.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, 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, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, 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, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, 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, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, 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, 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, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

KEY_ICONSIZE

public static final String KEY_ICONSIZE
The size of the brightness and contrast icon.

See Also:
Constant Field Values

KEY_ONADJUST

public static final String KEY_ONADJUST
If true we allow b/c adjustment on slider move.

See Also:
Constant Field Values

KEY_BRIGHTNESS

public static final String KEY_BRIGHTNESS
The default brightness value.

See Also:
Constant Field Values

KEY_CONTRAST

public static final String KEY_CONTRAST
The default contrast value.

See Also:
Constant Field Values

KEY_CONTINUOUS

public static final String KEY_CONTINUOUS
Always fill full view or snap to integer scales.

See Also:
Constant Field Values

DEFICONSIZE

private static final int DEFICONSIZE
The default icon size.

See Also:
Constant Field Values

DEFONADJUST

private static final boolean DEFONADJUST
Default not.

See Also:
Constant Field Values

DEFBRIGHTNESS

private static final double DEFBRIGHTNESS
Default brightness value.

See Also:
Constant Field Values

DEFCONTRAST

private static final double DEFCONTRAST
Default contrast value.

See Also:
Constant Field Values

DEFCONTINUOUS

private static final boolean DEFCONTINUOUS
Default property value.

See Also:
Constant Field Values

contrast

private double contrast
The last contrast of the image.


bright

private double bright
The last brightness of the image.


fitscanvas

private JFitsCanvas fitscanvas
The fits canvas served by this panel.


brightness

private JSlider brightness
The brightness slider.


contrastrate

private JSlider contrastrate
The contrast slider.


info

private PropertySupplying info
My properties, also a handle to the fitscanvas properites.

Constructor Detail

JFitsComponent

public JFitsComponent(JFitsCanvas fits)
Constructs a new fits component. The main initialization is done in the init method.

Method Detail

setComposedProperties

public void setComposedProperties(PropertySupplying prop)
Defaults the icon size. The super method resets the contrast and brightness values to the properties defaults.

Specified by:
setComposedProperties in interface PropertyAware

getComposedProperties

public PropertySupplying getComposedProperties()
Returns the properties of the panel and the properties of the fits canvas.

Specified by:
getComposedProperties in interface PropertyComposed

init

public void init()
Initializes the shape canvas. This includes some default setting that might be overruled in subclasses.

Specified by:
init in interface Initializable

getDisplayMap

public Map<String,Object> getDisplayMap()

getContrast

public double getContrast()
Returns the current contrast on the image in the range of -1 to +1.


setContrast

public boolean setContrast(double newcontrast)
Sets the contrast of the image. This method can destory data in a sense that this method is not totally reversable. E.g., if one sets a contrast of -1 (the minimum value allowd), all data will then have the median value. Setting a contrast of zero later will not restore the data, unless called in conjuncture with #revertFromFits.


getBrightness

public double getBrightness()
Returns the current brightness.


setBrightness

public boolean setBrightness(double newbright)
Sets the brightness of the image. This method can destory data in a sense that this method is not totally reversable. E.g., if one sets a brightness of -1 (the minimum value allowd), all data will then have zero value. Setting a brightness of zero later will not restore the data, unless called in conjuncture with #revertFromFits.


prepareToDisplay

public BufferedImage prepareToDisplay(BufferedImage src)
Rescales the image to display the new brightness and contrast.

Specified by:
prepareToDisplay in interface ImageOperation

stateChanged

public void stateChanged(ChangeEvent e)
Invoked when the contrast or brightness slider was moved. We call the brightness or contrast adjustment on the fits canvas only if the slider has come to rest.

Specified by:
stateChanged in interface ChangeListener

getCanvas

protected JFitsCanvas getCanvas()
Returns the fits canvas.


propertyChange

public void propertyChange(PropertyChangeEvent e)
Notified when the fits canvas has been reset. Adjustes the sliders.

Specified by:
propertyChange in interface PropertyChangeListener

getSaveBuffer

public BufferedImage getSaveBuffer()
Returns the buffered image from the fits canvas.

Specified by:
getSaveBuffer in interface Savable