public class TurtleField extends javax.swing.JFrame implements TurtleListener
Modifier and Type | Class and Description |
---|---|
class |
TurtleField.BufferedPanel
Overkill with double buffering on by default, but shows how to do it.
|
class |
TurtleField.DrawingPanel |
javax.swing.JFrame.AccessibleJFrame
java.awt.Window.AccessibleAWTWindow, java.awt.Window.Type
Modifier and Type | Field and Description |
---|---|
private SLogoInterpreter |
interpreter |
private javax.swing.JTextField |
myAngle |
private WorkspaceContext |
myContext |
private TurtleField.DrawingPanel |
myDisplay |
private java.awt.Font |
myFont |
private javax.swing.JComboBox<java.lang.String> |
myStepSize |
private JTurtle |
myTurtle |
private javax.swing.JTextField |
myXPoint |
private javax.swing.JTextField |
myYPoint |
private javax.swing.JTextArea |
notificationArea |
private javax.swing.JFileChooser |
openFileChooser |
private javax.swing.JFileChooser |
openFileChooser2 |
private javax.swing.JFileChooser |
saveFileChooser |
private javax.swing.JButton |
sendCommand |
private static long |
serialVersionUID |
private static java.lang.String |
soundName |
private javax.swing.JPanel |
statsPanel |
private javax.swing.JTextArea |
textEntry |
private static java.awt.Image |
turtleImgLocName |
accessibleContext, EXIT_ON_CLOSE, rootPane, rootPaneCheckingEnabled
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Constructor and Description |
---|
TurtleField()
Creates a view of the turtle, using the default turtle representation
|
TurtleField(java.lang.String turtleImgLocName)
Creates a view of the turtle, given by the name of the turtle image
|
Modifier and Type | Method and Description |
---|---|
private void |
addCommandButtonPanel(javax.swing.JPanel mainPanel) |
private void |
createMenuBar()
Creates a menubar for the windows so the user can access
some commands.
|
private java.lang.String |
createOpenFileChooser() |
private java.lang.String |
createSaveFileChooser() |
void |
doSteps()
Make the turtle take some steps.
|
void |
enterCommand()
Makes turtle perform command
|
int |
getMoveSize()
Returns step size as currently selected.
|
private java.lang.String |
imageFileChooser() |
private void |
init() |
static void |
main(java.lang.String[] args) |
private void |
makeDashBoard(javax.swing.JPanel turtleGUI,
javax.swing.JPanel commandPanel)
Where turtle info is displayed
|
java.awt.Image |
makeImage(java.lang.String imageFileName) |
private void |
makeSlider(javax.swing.JPanel panel)
make a slider to set the turtle's heading
|
private javax.swing.JTextField |
makeTextField() |
void |
openFile(java.lang.String fileName)
Opens file
|
void |
openImageFile(java.lang.String fileName)
opens image file
|
void |
openSoundFile(java.lang.String fileName)
Opens a Sound File
|
static void |
playSound() |
void |
processTurtle(JTurtle turtle)
Process a (changed) turtle, display properties and redraw.
|
void |
saveFile(java.lang.String fileName)
Saves file
|
void |
setTurtle(JTurtle turtle) |
void |
showAngle(int angle)
Display (Turtle's) angle
|
void |
showPoint(java.awt.geom.Point2D d)
display Turtle's point information
|
protected java.lang.String |
soundFileChooser() |
void |
toggleTurtleStats()
Hides turtle stats
|
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
addNotify, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setBackground, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setOpacity, setResizable, setShape, setState, setTitle, setUndecorated
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBackground, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOpacity, getOwnedWindows, getOwner, getOwnerlessWindows, getShape, getToolkit, getType, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isAutoRequestFocus, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isOpaque, isShowing, isValidateRoot, pack, paint, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setAutoRequestFocus, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocation, setLocation, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setType, setVisible, show, toBack, toFront
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusDownCycle, validate, validateTree
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resize, resize, revalidate, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
private static final long serialVersionUID
private TurtleField.DrawingPanel myDisplay
private javax.swing.JTextField myXPoint
private javax.swing.JTextField myYPoint
private javax.swing.JTextField myAngle
private javax.swing.JTextArea textEntry
private javax.swing.JTextArea notificationArea
private javax.swing.JComboBox<java.lang.String> myStepSize
private java.awt.Font myFont
private javax.swing.JButton sendCommand
private javax.swing.JFileChooser openFileChooser
private javax.swing.JFileChooser openFileChooser2
private javax.swing.JFileChooser saveFileChooser
private static java.lang.String soundName
private static java.awt.Image turtleImgLocName
private JTurtle myTurtle
private WorkspaceContext myContext
private SLogoInterpreter interpreter
private javax.swing.JPanel statsPanel
public TurtleField(java.lang.String turtleImgLocName) throws java.io.IOException, javax.sound.sampled.UnsupportedAudioFileException, javax.sound.sampled.LineUnavailableException
turtleImgName
- - the location of the turtle image filejavax.sound.sampled.LineUnavailableException
java.io.IOException
javax.sound.sampled.UnsupportedAudioFileException
public TurtleField() throws javax.sound.sampled.UnsupportedAudioFileException, java.io.IOException, javax.sound.sampled.LineUnavailableException
javax.sound.sampled.LineUnavailableException
java.io.IOException
javax.sound.sampled.UnsupportedAudioFileException
public static void main(java.lang.String[] args) throws javax.sound.sampled.UnsupportedAudioFileException, java.io.IOException, javax.sound.sampled.LineUnavailableException
javax.sound.sampled.UnsupportedAudioFileException
java.io.IOException
javax.sound.sampled.LineUnavailableException
private void init() throws javax.sound.sampled.UnsupportedAudioFileException, java.io.IOException, javax.sound.sampled.LineUnavailableException
javax.sound.sampled.UnsupportedAudioFileException
java.io.IOException
javax.sound.sampled.LineUnavailableException
public void setTurtle(JTurtle turtle)
private void makeSlider(javax.swing.JPanel panel)
private javax.swing.JTextField makeTextField()
private void createMenuBar()
private java.lang.String imageFileChooser()
protected java.lang.String soundFileChooser()
private java.lang.String createOpenFileChooser()
private java.lang.String createSaveFileChooser()
private void addCommandButtonPanel(javax.swing.JPanel mainPanel)
private void makeDashBoard(javax.swing.JPanel turtleGUI, javax.swing.JPanel commandPanel) throws javax.sound.sampled.UnsupportedAudioFileException, java.io.IOException, javax.sound.sampled.LineUnavailableException
java.io.IOException
javax.sound.sampled.UnsupportedAudioFileException
javax.sound.sampled.LineUnavailableException
public void processTurtle(JTurtle turtle)
processTurtle
in interface TurtleListener
turtle
- is the turtle being displayedpublic void showPoint(java.awt.geom.Point2D d)
public void showAngle(int angle)
angle
- is the angle displayedpublic void doSteps()
public void enterCommand() throws javax.sound.sampled.UnsupportedAudioFileException, java.io.IOException, javax.sound.sampled.LineUnavailableException
javax.sound.sampled.LineUnavailableException
java.io.IOException
javax.sound.sampled.UnsupportedAudioFileException
public void openFile(java.lang.String fileName) throws java.io.IOException
java.io.IOException
public void saveFile(java.lang.String fileName) throws java.io.IOException
java.io.IOException
public void openSoundFile(java.lang.String fileName) throws java.io.FileNotFoundException
java.io.FileNotFoundException
public void openImageFile(java.lang.String fileName) throws java.io.IOException
fileName
- java.io.IOException
public void toggleTurtleStats()
public int getMoveSize()
public java.awt.Image makeImage(java.lang.String imageFileName) throws java.io.IOException
imageFileName
- java.io.IOException
- if there is an error reading in the filepublic static void playSound() throws javax.sound.sampled.UnsupportedAudioFileException, java.io.IOException, javax.sound.sampled.LineUnavailableException
javax.sound.sampled.UnsupportedAudioFileException
java.io.IOException
javax.sound.sampled.LineUnavailableException