edu.mit.sketch.clocksketch.gui
Class DrawingPanel

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 edu.mit.sketch.clocksketch.gui.DrawingPanel
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.awt.print.Printable, java.io.Serializable, javax.accessibility.Accessible

public class DrawingPanel
extends javax.swing.JPanel
implements java.awt.print.Printable

Author:
David Pitman May 23, 2005
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Field Summary
static java.lang.String ANIMATION_FINISHED
           
static java.lang.String ANIMATION_STARTED
           
static java.lang.String UPDATE_TIME
           
 
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.print.Printable
NO_SUCH_PAGE, PAGE_EXISTS
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
DrawingPanel(java.util.Collection<PenDrawing> drawingsIn)
          Creates a JPanel for animating the drawing, given a PenDrawing to work off of
DrawingPanel(java.util.Collection<PenDrawing> drawingIn, double initialWidth)
           
 
Method Summary
 void addActionListener(java.awt.event.ActionListener a)
           
 void BoldHighlight(boolean show)
           
 void cancelAnimation()
          Stops the timer, resets the drawing and releases the animation lock
 void displayDrawing()
          Method call to show the drawing as a static image
 void displayDrawing(double scalingX, double scalingY, java.awt.Graphics2D g2d)
          Draws the drawing using the DrawingPanel's width and height
 void doAnimation(java.util.TreeSet<PenDrawing> drawingsToAnimate)
          Starts animating the drawing.
 void draw(double scalingX, double scalingY, boolean showPoints, boolean NoShowInitX, java.awt.Graphics2D g2d, java.util.TreeSet<PenDrawing> drawingsToUse)
          Draws the drawing w/ supplied scaling, widths, and Graphics2D
 java.lang.String getAnimationTime()
           
 java.awt.Graphics2D getDrawingGraphics()
           
 double getImageScaleX()
           
 double getImageScaleY()
           
 java.util.Collection<PenDrawing> getPenDrawings()
          Returns the PenDrawing the DrawingPanel is using.
 Point getSelectedPoint()
           
 Stroke getSelectedStroke()
           
 void invalidateBackground(boolean invalidation)
           
 boolean isAnimationPaused()
          Returns true if the animation is running, but paused at the moment.
 boolean isAnimationRunning()
           
 void NoClassifDisp(boolean show)
          RD 6/9 Tells the panel to turn off all annotaiton display
 void NoShowInitPointX(boolean show)
           
 void pauseAnimation()
          Stops the timer, but doesn't reset the drawing or release the animation lock, effectively pausing the animation
 int print(java.awt.Graphics arg0, java.awt.print.PageFormat pageF, int numPages)
           
 void removeActionListener(java.awt.event.ActionListener a)
           
 void resetSize()
          Resizes the Panel if there have been any changes in the drawing size.
 void setDisplayDrawing(boolean drawing)
          Sets the boolean which dictates whether to redraw the drawing
 void setDrawAncillaryInfo(boolean drawAncillaryInfo)
           
 void setImageScale(double scale)
          Changes the scale of the drawing uniformly for the X and Y axis
 void setImageScale(double scaleX, double scaleY)
          Changes the scale of the drawing for both the X and Y axis...
 java.lang.String setRelativeZoom(double zoom)
          Multiples the current scale by the double argument, and returns a string with the percentile of zoom.
 void setSelectedPoint(Point p)
           
 void setSelectedStroke(Stroke s)
           
 void setShowAnimationTime(boolean show)
           
 void setTimeScale(double scale)
          Changes the speed of the animation
 boolean showAnimationTime()
           
 void showExtrapolatedPoints(boolean show)
           
 void showPoints(boolean show)
          Tells the panel whether to draw an "x" at each point
 
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
 

Field Detail

ANIMATION_FINISHED

public static java.lang.String ANIMATION_FINISHED

ANIMATION_STARTED

public static java.lang.String ANIMATION_STARTED

UPDATE_TIME

public static java.lang.String UPDATE_TIME
Constructor Detail

DrawingPanel

public DrawingPanel(java.util.Collection<PenDrawing> drawingsIn)
Creates a JPanel for animating the drawing, given a PenDrawing to work off of

Parameters:
drawingsIn -

DrawingPanel

public DrawingPanel(java.util.Collection<PenDrawing> drawingIn,
                    double initialWidth)
Method Detail

setDisplayDrawing

public void setDisplayDrawing(boolean drawing)
Sets the boolean which dictates whether to redraw the drawing

Parameters:
drawing -

displayDrawing

public void displayDrawing()
Method call to show the drawing as a static image


showPoints

public void showPoints(boolean show)
Tells the panel whether to draw an "x" at each point


NoShowInitPointX

public void NoShowInitPointX(boolean show)

BoldHighlight

public void BoldHighlight(boolean show)

NoClassifDisp

public void NoClassifDisp(boolean show)
RD 6/9 Tells the panel to turn off all annotaiton display

Parameters:
show -

showExtrapolatedPoints

public void showExtrapolatedPoints(boolean show)

doAnimation

public void doAnimation(java.util.TreeSet<PenDrawing> drawingsToAnimate)
Starts animating the drawing. Currently, the animation is first compiled into a series of frames and then played using Graphics2D. Also sets the animation lock to prevent concurrent animations


pauseAnimation

public void pauseAnimation()
Stops the timer, but doesn't reset the drawing or release the animation lock, effectively pausing the animation


isAnimationPaused

public boolean isAnimationPaused()
Returns true if the animation is running, but paused at the moment.


cancelAnimation

public void cancelAnimation()
Stops the timer, resets the drawing and releases the animation lock


setDrawAncillaryInfo

public void setDrawAncillaryInfo(boolean drawAncillaryInfo)

isAnimationRunning

public boolean isAnimationRunning()

getAnimationTime

public java.lang.String getAnimationTime()

invalidateBackground

public void invalidateBackground(boolean invalidation)

setImageScale

public void setImageScale(double scale)
Changes the scale of the drawing uniformly for the X and Y axis


getImageScaleX

public double getImageScaleX()

getImageScaleY

public double getImageScaleY()

getSelectedStroke

public Stroke getSelectedStroke()

getSelectedPoint

public Point getSelectedPoint()

setSelectedStroke

public void setSelectedStroke(Stroke s)

setSelectedPoint

public void setSelectedPoint(Point p)

setImageScale

public void setImageScale(double scaleX,
                          double scaleY)
Changes the scale of the drawing for both the X and Y axis... But currently forces it to use the smaller scaling...


setRelativeZoom

public java.lang.String setRelativeZoom(double zoom)
Multiples the current scale by the double argument, and returns a string with the percentile of zoom.

Parameters:
zoom -

resetSize

public void resetSize()
Resizes the Panel if there have been any changes in the drawing size.


setTimeScale

public void setTimeScale(double scale)
Changes the speed of the animation


getPenDrawings

public java.util.Collection<PenDrawing> getPenDrawings()
Returns the PenDrawing the DrawingPanel is using.


displayDrawing

public void displayDrawing(double scalingX,
                           double scalingY,
                           java.awt.Graphics2D g2d)
Draws the drawing using the DrawingPanel's width and height

Parameters:
scalingX -
scalingY -
g2d -

showAnimationTime

public boolean showAnimationTime()

setShowAnimationTime

public void setShowAnimationTime(boolean show)

draw

public void draw(double scalingX,
                 double scalingY,
                 boolean showPoints,
                 boolean NoShowInitX,
                 java.awt.Graphics2D g2d,
                 java.util.TreeSet<PenDrawing> drawingsToUse)
Draws the drawing w/ supplied scaling, widths, and Graphics2D


addActionListener

public void addActionListener(java.awt.event.ActionListener a)

removeActionListener

public void removeActionListener(java.awt.event.ActionListener a)

getDrawingGraphics

public java.awt.Graphics2D getDrawingGraphics()

print

public int print(java.awt.Graphics arg0,
                 java.awt.print.PageFormat pageF,
                 int numPages)
          throws java.awt.print.PrinterException
Specified by:
print in interface java.awt.print.Printable
Throws:
java.awt.print.PrinterException