tapeutils.gui
Class SampleCanvas

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended bytapeutils.gui.SampleCanvas
All Implemented Interfaces:
java.awt.event.ActionListener, java.awt.event.AdjustmentListener, AnalysisListener, java.awt.event.ComponentListener, java.util.EventListener, java.awt.image.ImageObserver, java.awt.MenuContainer, MessageSelectionListener, java.awt.event.MouseListener, java.io.Serializable

public class SampleCanvas
extends javax.swing.JComponent
implements java.awt.event.AdjustmentListener, java.awt.event.ComponentListener, java.awt.event.ActionListener, java.awt.event.MouseListener, AnalysisListener, MessageSelectionListener

This class provides a Canvas subclass which allows drawing of a sample, plus the analysis information.

Version:
0.1
Author:
Simon Holdsworth
See Also:
Serialized Form

Nested Class Summary
 
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
 
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
SampleCanvas(TapeConverter converter, int sampleNumber, javax.swing.JScrollBar scrollbar, javax.swing.JButton prevError, javax.swing.JButton nextError, javax.swing.JButton prevErrorWarning, javax.swing.JButton nextErrorWarning, javax.swing.JButton setToZero, javax.swing.JButton setToOne, javax.swing.JButton save, javax.swing.JButton undo, javax.swing.JButton redo, javax.swing.JLabel indexLabel)
          Creates a new SampleCanvas
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent evt)
          Handles button presses and menu item selections.
 void adjustmentValueChanged(java.awt.event.AdjustmentEvent evt)
          Handles a scrollbar adjustment event.
 void analysisComplete(AnalysisEvent event)
          Handle an analysis completion event.
 void componentHidden(java.awt.event.ComponentEvent evt)
           
 void componentMoved(java.awt.event.ComponentEvent evt)
           
 void componentResized(java.awt.event.ComponentEvent evt)
          Handles a component resized event.
 void componentShown(java.awt.event.ComponentEvent evt)
           
 void displayMessage(int messageNumber)
          Display the given message.
 void getBitNumber(int[] pos)
          Returns the bit number of the first bit displayed.
 java.awt.Dimension getPreferredSize()
          Returns the preferred size of the canvas.
 int getStartIndex()
          Get the start index.
 void messageSelected(int sampleNumber, int messageNumber)
          Indicate that a message has been selected for the given analyzer.
 void mouseClicked(java.awt.event.MouseEvent evt)
          Takes actions when the mouse button is clicked.
 void mouseEntered(java.awt.event.MouseEvent evt)
           
 void mouseExited(java.awt.event.MouseEvent evt)
           
 void mousePressed(java.awt.event.MouseEvent evt)
           
 void mouseReleased(java.awt.event.MouseEvent evt)
           
 void paint(java.awt.Graphics g)
          Paints the sample in the given Graphics object.
 void setCursorIndex(int index)
          Set the cursor index.
 void setStartIndex(int index)
          Sets the start of the display.
 void syncWith(SampleCanvas other)
          Synchronize the positioning of this canvas with the other.
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, 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, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, 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, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, 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, 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, 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, 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
 

Constructor Detail

SampleCanvas

public SampleCanvas(TapeConverter converter,
                    int sampleNumber,
                    javax.swing.JScrollBar scrollbar,
                    javax.swing.JButton prevError,
                    javax.swing.JButton nextError,
                    javax.swing.JButton prevErrorWarning,
                    javax.swing.JButton nextErrorWarning,
                    javax.swing.JButton setToZero,
                    javax.swing.JButton setToOne,
                    javax.swing.JButton save,
                    javax.swing.JButton undo,
                    javax.swing.JButton redo,
                    javax.swing.JLabel indexLabel)
Creates a new SampleCanvas

Parameters:
converter - The sample converter.
sampleNumber - The sample number.
scrollbar - The scrollbar.
prevError - The previous error button.
nextError - The next error button.
prevErrorWarning - The previous error/warning button.
nextErrorWarning - The next error/warning button.
setToZero - The set to zero button.
setToOne - The set to one button.
save - The save button.
undo - The undo button.
redo - The redo button.
indexLabel - The index label.
Method Detail

analysisComplete

public void analysisComplete(AnalysisEvent event)
Handle an analysis completion event.

Specified by:
analysisComplete in interface AnalysisListener
Parameters:
event - An object representing the event.

paint

public void paint(java.awt.Graphics g)
Paints the sample in the given Graphics object.

Parameters:
g - The Graphics in which to draw.

displayMessage

public void displayMessage(int messageNumber)
Display the given message.

Parameters:
messageNumber - The message number.

syncWith

public void syncWith(SampleCanvas other)
Synchronize the positioning of this canvas with the other.

Parameters:
other - The other panel.

setStartIndex

public void setStartIndex(int index)
Sets the start of the display.

Parameters:
index - The start index.

setCursorIndex

public void setCursorIndex(int index)
Set the cursor index.

Parameters:
index - The new index.

getStartIndex

public int getStartIndex()
Get the start index.

Returns:
The start index.

getBitNumber

public void getBitNumber(int[] pos)
Returns the bit number of the first bit displayed.

Parameters:
pos - An array which will contain the bit number and offset from the start of the bit.

messageSelected

public void messageSelected(int sampleNumber,
                            int messageNumber)
Indicate that a message has been selected for the given analyzer.

Specified by:
messageSelected in interface MessageSelectionListener
Parameters:
sampleNumber -
messageNumber -

getPreferredSize

public java.awt.Dimension getPreferredSize()
Returns the preferred size of the canvas.

Returns:
The preferred size.

adjustmentValueChanged

public void adjustmentValueChanged(java.awt.event.AdjustmentEvent evt)
Handles a scrollbar adjustment event.

Specified by:
adjustmentValueChanged in interface java.awt.event.AdjustmentListener
Parameters:
evt - The event to be handled.

componentResized

public void componentResized(java.awt.event.ComponentEvent evt)
Handles a component resized event.

Specified by:
componentResized in interface java.awt.event.ComponentListener
Parameters:
evt - The event to be handled.

componentHidden

public void componentHidden(java.awt.event.ComponentEvent evt)
Specified by:
componentHidden in interface java.awt.event.ComponentListener
Parameters:
evt -

componentMoved

public void componentMoved(java.awt.event.ComponentEvent evt)
Specified by:
componentMoved in interface java.awt.event.ComponentListener
Parameters:
evt -

componentShown

public void componentShown(java.awt.event.ComponentEvent evt)
Specified by:
componentShown in interface java.awt.event.ComponentListener
Parameters:
evt -

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent evt)
Handles button presses and menu item selections.

Specified by:
actionPerformed in interface java.awt.event.ActionListener
Parameters:
evt - The event.

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent evt)
Takes actions when the mouse button is clicked.

Specified by:
mouseClicked in interface java.awt.event.MouseListener
Parameters:
evt - The event.

mousePressed

public void mousePressed(java.awt.event.MouseEvent evt)
Specified by:
mousePressed in interface java.awt.event.MouseListener
Parameters:
evt -

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent evt)
Specified by:
mouseReleased in interface java.awt.event.MouseListener
Parameters:
evt -

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent evt)
Specified by:
mouseEntered in interface java.awt.event.MouseListener
Parameters:
evt -

mouseExited

public void mouseExited(java.awt.event.MouseEvent evt)
Specified by:
mouseExited in interface java.awt.event.MouseListener
Parameters:
evt -