visualize
Class LineDrawPanel

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 visualize.LineDrawPanel
All Implemented Interfaces:
java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible

public class LineDrawPanel
extends javax.swing.JPanel
implements java.awt.event.MouseListener, java.awt.event.MouseMotionListener

The Class LineDrawPanel extends JPanel and is a Panel, in which the user can define the opacity from the transfer-function. The opacity is interpolated between special points defined by the user. Those Points are of type TransferPoint.

Version:
1.17
Author:
Fabian Hollaus, Markus Diem
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Field Summary
 
Fields inherited from class javax.swing.JComponent
TOOL_TIP_TEXT_KEY, 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
LineDrawPanel()
          Generates a new LineColorPanel and sets the initial TransferPoints.
 
Method Summary
 void addActionListener(java.awt.event.ActionListener listener)
          Adds an ActionListener to the Panel.
 void deleteSelectedPoint()
          Deletes the selected TransferPoint.
 void fTOpened()
          Is called when the user opens an existing transfer-function and redraws the LineDrawPanel, so that it shows the content of the opened transfer-function.
static float[] getInterpolatedOpacity()
          Returns the interpolated opacity between the first and the last TransferPoint in form of a FloatBuffer.
 java.util.LinkedList<TransferPoint> getPoints()
          Returns the TransferPoints from the LineDrawPanel.
 int getSelectedGrayValue()
          Returns the gray-value of the selected TransferPoint.
 int getSelectedOpacityValue()
          Returns the opacity-value of the selected color-point.
 void init()
          Resets the LineDrawPanel to it's initial state.
 void keyPressed(java.awt.event.KeyEvent e)
          Empty function.
 void keyReleased(java.awt.event.KeyEvent e)
          Empty function.
 void keyTyped(java.awt.event.KeyEvent e)
          Empty function.
 void mouseClicked(java.awt.event.MouseEvent e)
          Empty function.
 void mouseDragged(java.awt.event.MouseEvent e)
          If the user clicks on a TransferPoint and draggs the mouse the color-point will be dragged.
 void mouseDragMoved(java.awt.event.MouseEvent e)
          Empty function.
 void mouseEntered(java.awt.event.MouseEvent e)
          Empty function.
 void mouseExited(java.awt.event.MouseEvent e)
          Empty function.
 void mouseMoved(java.awt.event.MouseEvent me)
          Empty function.
 void mousePressed(java.awt.event.MouseEvent me)
          Adds a new TransferPoint if control is pressed or selects an existing point.
 void mouseReleased(java.awt.event.MouseEvent e)
          Empty function.
 void paintComponent(java.awt.Graphics g)
          Repaints the LineDrawPanel.
 void setHistogram(float[] histogramNormalized)
          Stretches a normalized histogram so that its height matches the height of the LineDrawPanel and plots it in the background of the LineDrawPanel.
 boolean setSelectedGrayValue(java.lang.String grayValueStr)
          Returns true if the gray-value of the selected TransferPoint can be changed to a specified value.
 boolean setSelectedOpacity(java.lang.String opacityStr)
          Returns true if the opactiy-value of the selected TransferPoint can be changed to a specified value.
 void setSelectedPoint(java.lang.String grayValueStr, java.lang.String opacityStr)
          Is called when the user changes the values of a selected TransferPoint in the textboxes and applies the changes.
 void tellListenerNoSelection()
          Is called when the user clicks on a color-point, that was not selected before.
 void tellListenerSelectionChanged()
          Is called when the user clicks on a color-point, that was not selected before.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, 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, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, 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, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, 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, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, 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, 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
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LineDrawPanel

public LineDrawPanel()
Generates a new LineColorPanel and sets the initial TransferPoints.

Method Detail

init

public void init()
Resets the LineDrawPanel to it's initial state.


getPoints

public java.util.LinkedList<TransferPoint> getPoints()
Returns the TransferPoints from the LineDrawPanel.

Returns:
a sorted list containing all TransferPoint objects.

fTOpened

public void fTOpened()
Is called when the user opens an existing transfer-function and redraws the LineDrawPanel, so that it shows the content of the opened transfer-function.


addActionListener

public void addActionListener(java.awt.event.ActionListener listener)
Adds an ActionListener to the Panel.

Parameters:
listener - The ActionListener which is attached.

setHistogram

public void setHistogram(float[] histogramNormalized)
Stretches a normalized histogram so that its height matches the height of the LineDrawPanel and plots it in the background of the LineDrawPanel.

Parameters:
histogramNormalized - normalized histogram in form of a float-array.

paintComponent

public void paintComponent(java.awt.Graphics g)
Repaints the LineDrawPanel. TransferPoints are ploted and connected with lines. Also in the background the histogram of the data-set is plotted.

Overrides:
paintComponent in class javax.swing.JComponent

getSelectedGrayValue

public int getSelectedGrayValue()
Returns the gray-value of the selected TransferPoint.

Returns:
grayValue in integer form.

getSelectedOpacityValue

public int getSelectedOpacityValue()
Returns the opacity-value of the selected color-point.

Returns:
opacity-value in integer form.

setSelectedGrayValue

public boolean setSelectedGrayValue(java.lang.String grayValueStr)
Returns true if the gray-value of the selected TransferPoint can be changed to a specified value.

Parameters:
grayValueStr - new gray-value in string-form of the TransferPoint
Returns:
boolean describing if operation is allowed

setSelectedOpacity

public boolean setSelectedOpacity(java.lang.String opacityStr)
Returns true if the opactiy-value of the selected TransferPoint can be changed to a specified value.

Parameters:
opacityStr - new opacity-value in string-form of the TransferPoint
Returns:
boolean describing if operation is allowed

setSelectedPoint

public void setSelectedPoint(java.lang.String grayValueStr,
                             java.lang.String opacityStr)
Is called when the user changes the values of a selected TransferPoint in the textboxes and applies the changes.

Parameters:
grayValueStr - gray-value in string form.
opacityStr - opacity-value in string form.

deleteSelectedPoint

public void deleteSelectedPoint()
Deletes the selected TransferPoint.


tellListenerSelectionChanged

public void tellListenerSelectionChanged()
Is called when the user clicks on a color-point, that was not selected before.


tellListenerNoSelection

public void tellListenerNoSelection()
Is called when the user clicks on a color-point, that was not selected before.


mousePressed

public void mousePressed(java.awt.event.MouseEvent me)
Adds a new TransferPoint if control is pressed or selects an existing point.

Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent me)
Empty function. Just added for inheritance.

Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Empty function. Just added for inheritance.

Specified by:
mouseClicked in interface java.awt.event.MouseListener

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)
If the user clicks on a TransferPoint and draggs the mouse the color-point will be dragged.

Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener

mouseDragMoved

public void mouseDragMoved(java.awt.event.MouseEvent e)
Empty function. Just added for inheritance.


mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Empty function. Just added for inheritance.

Specified by:
mouseReleased in interface java.awt.event.MouseListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Empty function. Just added for inheritance.

Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Empty function. Just added for inheritance.

Specified by:
mouseExited in interface java.awt.event.MouseListener

keyPressed

public void keyPressed(java.awt.event.KeyEvent e)
Empty function. Just added for inheritance.


keyReleased

public void keyReleased(java.awt.event.KeyEvent e)
Empty function. Just added for inheritance.


keyTyped

public void keyTyped(java.awt.event.KeyEvent e)
Empty function. Just added for inheritance.


getInterpolatedOpacity

public static float[] getInterpolatedOpacity()
Returns the interpolated opacity between the first and the last TransferPoint in form of a FloatBuffer.

Returns:
a FloatBuffer containing the opacity-values.