de.unibi.techfak.jpredictor.gui
Class ScorePlotBrowser

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 de.unibi.techfak.jpredictor.gui.ScorePlotBrowser
All Implemented Interfaces:
java.awt.event.ActionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.event.ChangeListener

public class ScorePlotBrowser
extends javax.swing.JPanel
implements java.awt.event.ActionListener, javax.swing.event.ChangeListener

Panel for browsing sequences and showing the motifs found.

See Also:
Serialized Form

Nested Class Summary
(package private)  class ScorePlotBrowser.ScorePlotArea
          The hand-made JComponent, in which the score plot is drawn.
(package private)  class ScorePlotBrowser.SequencePlotArea
          The hand-made JComponent, in which the sequence together with the motifs is drawn.
 
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
static int BARS
          Draws something using bars.
(package private)  javax.swing.AbstractButton bMax
          The radio button for the comprised maximum.
(package private)  javax.swing.AbstractButton bMean
          The radio button for the comprised mean.
(package private)  javax.swing.AbstractButton bMin
          The radio button for the comprised minimum.
(package private)  javax.swing.AbstractButton bNoBar
          The button to disable the bar.
(package private)  javax.swing.AbstractButton bNoHLine
          The button to disable the horizontal line.
(package private)  java.lang.String[] bTexts
          The text for the buttons.
(package private) static ICommunicator comm
          The global communicator, used to 'talk' to the operator, what means, doing all settings and gettings through.
static int DOTS
          Draws something using dots.
(package private)  int drawingChoose
          If the score plot is zoomed out many scores have to be comprised to one pixel (dot or line).
(package private)  int drawingStyle
          The style in which the scores are plotted.
(package private)  javax.swing.JFileChooser fileChooser
          The file chooser used in this window, its always used the same filechooser.
(package private)  int horizontalLine
          Set by the spinner and by the methods receiving state change events of it.
static int LINES
          Draws something using lines.
static int MAXIMUM
          State for the maximum.
static int MEAN
          State for the mean.
(package private)  javax.swing.JMenuBar menuBar
          Global setting whether a menu is present or not.
static int MINIMUM
          State for the minimum.
(package private) static Operator op
          The global operator, which performs all tasks on the sequences by using the motifs.
(package private)  javax.swing.JFrame parent
          Parent window that holds the panel.
(package private)  double resultMax
          The maximal number stored in the result vector.
(package private)  double resultMin
          The minimal number stored in the result vector.
(package private)  int resultNumber
          The number of results stored in the result vector.
(package private)  java.util.Vector results
          Here the result vector from the communicator is stored.
(package private)  ScorePlotBrowser.ScorePlotArea scorePlotArea
          The global area to draw the score plot.
(package private)  int selectionMid
          Set by methods receiving mouse motion events of the ScorePlotArea.
(package private)  SequenceEnumeration sequenceEnum
          Holds all sequences to be displayed.
(package private)  ScorePlotBrowser.SequencePlotArea sequencePlotArea
          The global area to draw the sequence.
(package private)  javax.swing.SpinnerNumberModel spinnerNumberModel
          The model used for the spinner which in turn is responsible for choosing the horizontal line's y-axis.
(package private)  StatusBar statusBar
          The status bar with the different labels.
(package private)  double xZoom
          Set when the buttons x zoom in and x zoom out are pressed.
(package private)  boolean xZoomFitToWindow
          Set to true, if the user has not clicked on one of the buttons for x-zoom .
(package private)  double yZoom
          Set when the buttons y zoom in and y zoom out are pressed.
(package private)  boolean yZoomFitToWindow
          Set to true, if the user has not clicked on one of the buttons for y-zoom .
 
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
ScorePlotBrowser(javax.swing.JFrame parent, boolean menu)
          Constructor which builds the panel used in a stand alone application.
ScorePlotBrowser(javax.swing.JFrame parent, ICommunicator comm, Operator op, javax.swing.JFileChooser fc, boolean menu)
          Constructor which builds the panel.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
           
protected  void createPanelSurface()
          Creates this panel.
 javax.swing.JMenuBar getJMenuBar()
          After constructing this class the menu bar can be obtained.
protected  javax.swing.JPanel getMotifPane(MouseOverHintManager hints)
          Creates and returns the pane, where the sequence window together with the occuring motifs are shown.
protected  javax.swing.JPanel getPlotPane(MouseOverHintManager hints)
          Creates and returns the pane, where the score over the sequence is plotted
static void main(java.lang.String[] args)
          The main method, called if the sequence browser is ran as stand alone prog
 void setXZoom(double newXZoom)
          Sets the new zoom on the x axis.
 void setYZoom(double newYZoom)
          Sets the new zoom on the y axis.
 void stateChanged(javax.swing.event.ChangeEvent e)
           
 void updateCursorLocation(int x, int y)
          Gets the actual mouse cursor position and prints them to the coordLabel label.
 
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, 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, 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

comm

static ICommunicator comm
The global communicator, used to 'talk' to the operator, what means, doing all settings and gettings through.


op

static Operator op
The global operator, which performs all tasks on the sequences by using the motifs.


MINIMUM

public static final int MINIMUM
State for the minimum. Tells a method to calculate the minimum out of many values, if the task is to comprise that values.

See Also:
Constant Field Values

MAXIMUM

public static final int MAXIMUM
State for the maximum. Tells a method to calculate the maximum out of many values, if the task is to comprise that values.

See Also:
Constant Field Values

MEAN

public static final int MEAN
State for the mean. Tells a method to calculate the mean out of many values, if the task is to comprise that values.

See Also:
Constant Field Values

BARS

public static final int BARS
Draws something using bars.

See Also:
Constant Field Values

DOTS

public static final int DOTS
Draws something using dots.

See Also:
Constant Field Values

LINES

public static final int LINES
Draws something using lines.

See Also:
Constant Field Values

parent

javax.swing.JFrame parent
Parent window that holds the panel.


menuBar

javax.swing.JMenuBar menuBar
Global setting whether a menu is present or not. Per default menuBar is null. This means, that no menu will be drawn and all buttons are present on the panels surface. If the class is constructed by wishing a menu to be present, only rudimentary buttons are shown on the panel and all other buttons are banned to the menu.


fileChooser

javax.swing.JFileChooser fileChooser
The file chooser used in this window, its always used the same filechooser.


scorePlotArea

ScorePlotBrowser.ScorePlotArea scorePlotArea
The global area to draw the score plot. Set by method getPlotPane


sequencePlotArea

ScorePlotBrowser.SequencePlotArea sequencePlotArea
The global area to draw the sequence. Set by method getMotifPane


statusBar

StatusBar statusBar
The status bar with the different labels. The first label is for hint texts, the next is for the mouse coordinates, then comes the x-zoom and y-zoom. The last label is the clock.


bTexts

java.lang.String[] bTexts
The text for the buttons.


bNoBar

javax.swing.AbstractButton bNoBar
The button to disable the bar.


bNoHLine

javax.swing.AbstractButton bNoHLine
The button to disable the horizontal line.


bMin

javax.swing.AbstractButton bMin
The radio button for the comprised minimum.


bMax

javax.swing.AbstractButton bMax
The radio button for the comprised maximum.


bMean

javax.swing.AbstractButton bMean
The radio button for the comprised mean.


results

java.util.Vector results
Here the result vector from the communicator is stored. If the graphical output is not activated, the vector is null.


resultNumber

int resultNumber
The number of results stored in the result vector. Note, that one "result" may consist of more than one object and that only fully completed "results" are counted. If number of results changes due to updates made to the result vector the minimum and maximum must be recalculated, in fact beginning with this number. This value is recognized and set in paint-method of the ScorePlotArea class.


resultMin

double resultMin
The minimal number stored in the result vector. It is set from the paint-method of the ScorePlotArea class and used to draw the y-axis.


resultMax

double resultMax
The maximal number stored in the result vector. It is set from the paint-method of the ScorePlotArea class and used to draw the y-axis.


spinnerNumberModel

javax.swing.SpinnerNumberModel spinnerNumberModel
The model used for the spinner which in turn is responsible for choosing the horizontal line's y-axis. The horizontal line has a minimal and maximal range dependent on the score data. It is stored here in this class, because minimum and maximum will be dynamically adjusted by ScorePlotArea-class, when the result vector is updated.


sequenceEnum

SequenceEnumeration sequenceEnum
Holds all sequences to be displayed.


xZoom

double xZoom
Set when the buttons x zoom in and x zoom out are pressed. Every zoom out halfes it, and every zoom in doubles it. In other words, it represents the number of dots, that must be drawn for every score. This value is used by the ScorePlotArea class. It is initialy set to one by the constructor.


yZoom

double yZoom
Set when the buttons y zoom in and y zoom out are pressed. Every zoom out halfes it, and every zoom in doubles it. In other words, it represents the number of dots, that are drawn for every unit of heigth. This value is used by the ScorePlotArea class. It is initialy set to one by the constructor.


xZoomFitToWindow

boolean xZoomFitToWindow
Set to true, if the user has not clicked on one of the buttons for x-zoom . As long as this switch is true, the x-zoom is automatically set the way that the user can see the whole area. This variable is used by the ScorePlotArea-class.


yZoomFitToWindow

boolean yZoomFitToWindow
Set to true, if the user has not clicked on one of the buttons for y-zoom . As long as this switch is true, the y-zoom is automatically set the way that the user can see the whole area. This variable is used by the ScorePlotArea-class.


selectionMid

int selectionMid
Set by methods receiving mouse motion events of the ScorePlotArea. Gives the mid point of the grey bar (displayed in the ScorePlotArea) and the mid of the sequence shown in SequencePlotArea. Set to -1 for no bar (dont't forget to repaint).
This mid point is messured in indices on the score and index arrays.


horizontalLine

int horizontalLine
Set by the spinner and by the methods receiving state change events of it. Gives the y coordinate of the horizontal line to be drawn. Used by the ScorePlotArea class. Set to Integer.MIN_VALUE for no bar (dont't forget to repaint).


drawingStyle

int drawingStyle
The style in which the scores are plotted. Set this variable to BARS, if bars should be drawn, to DOTS, if dots are wished and to LINES, if lines connecting the dots should be drawn. Default is BARS.


drawingChoose

int drawingChoose
If the score plot is zoomed out many scores have to be comprised to one pixel (dot or line). Set this to MINIMUM, MAXIMUM (default) or MEAN, repectively, to tell the draw method what to do with the scores, when they are broken down to one pixel width.

Constructor Detail

ScorePlotBrowser

public ScorePlotBrowser(javax.swing.JFrame parent,
                        ICommunicator comm,
                        Operator op,
                        javax.swing.JFileChooser fc,
                        boolean menu)
Constructor which builds the panel. The parent has to supply the used communicator, the operator and a file chooser. If fc==null, no file chooser will be uild up.

Parameters:
parent - The parent frame, in which this panel is shown.
comm - The communicator interface.
op - An operator for calling the specified tasks.
fc - The filechooser from the parent, in which the correct directory is set.
menu - Decides whether the application is interactive by buttons or by menu. If menu is true only rudimentary buttons can be seen within the panel, all other buttons are gathered in the menu.

ScorePlotBrowser

public ScorePlotBrowser(javax.swing.JFrame parent,
                        boolean menu)
Constructor which builds the panel used in a stand alone application. The communicator and the operator are newly created. If menu is true this application will have a menu, that can be obtained by calling createMenuBar() and its own the file chooser.

Parameters:
parent - The parent frame, in which this panel is shown.
menu - Decides whether the application is interactive by buttons or by menu. If menu is true only rudimentary buttons can be seen within the panel, all other buttons are gathered in the menu.
See Also:
getJMenuBar()
Method Detail

createPanelSurface

protected void createPanelSurface()
Creates this panel.


getJMenuBar

public javax.swing.JMenuBar getJMenuBar()
After constructing this class the menu bar can be obtained. Calling this method will cause the created menu bar to be returned.

Returns:
The menu bar how it was build while class construction.

getPlotPane

protected javax.swing.JPanel getPlotPane(MouseOverHintManager hints)
Creates and returns the pane, where the score over the sequence is plotted

Parameters:
hints - The hint manager some hints for the used components are registered.
Returns:
The panel where the score plot is drawn.

getMotifPane

protected javax.swing.JPanel getMotifPane(MouseOverHintManager hints)
Creates and returns the pane, where the sequence window together with the occuring motifs are shown.

Parameters:
hints - The hint manager some hints for the used components are registered.
Returns:
The panel where the motif occurrences is drawn.

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
Specified by:
actionPerformed in interface java.awt.event.ActionListener

stateChanged

public void stateChanged(javax.swing.event.ChangeEvent e)
Specified by:
stateChanged in interface javax.swing.event.ChangeListener

main

public static void main(java.lang.String[] args)
The main method, called if the sequence browser is ran as stand alone prog

Parameters:
args - Runtime arguments, parameters

setXZoom

public void setXZoom(double newXZoom)
Sets the new zoom on the x axis. If necessary, the x zoom labels text is changed.

Parameters:
newXZoom - The new zoom to apply.

setYZoom

public void setYZoom(double newYZoom)
Sets the new zoom on the y axis. If necessary, the y zoom labels text is changed.

Parameters:
newYZoom - The new zoom to apply.

updateCursorLocation

public void updateCursorLocation(int x,
                                 int y)
Gets the actual mouse cursor position and prints them to the coordLabel label.

Parameters:
x - The mouse actual position within the window.
y - The mouse actual position within the window.