public class KarelWorld extends JComponent
JComponent.AccessibleJComponent
Container.AccessibleAWTContainer
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Modifier and Type | Field and Description |
---|---|
static int |
BEEPER_BORDER |
static Color |
BEEPER_COLOR |
static String |
BEEPER_FONT_FAMILY |
static double |
BEEPER_FRACTION |
static Font |
BEEPER_NUMBER_FONT |
static int |
BLANKB |
static int |
BOTTOM_NUMBER_MARGIN |
static int |
CENTER |
static int |
CROSS_THRESHOLD |
static int |
DOUBLE_WALL_THRESHOLD |
static int |
EAST |
static int |
FANCY |
static int |
INFINITE |
static int |
LEFT_NUMBER_MARGIN |
static Color |
MARKED_COLOR |
static int |
MAX_DISPLAY_HEIGHT |
static int |
MAX_DISPLAY_WIDTH |
static int |
MAX_HEIGHT |
static int |
MAX_WIDTH |
static int |
MIN_BEEPER |
static int |
MIN_FANCY |
static int |
MIN_LABEL |
static int |
MINUS1 |
static int |
NORTH |
static int |
NORTHEAST |
static int |
NORTHWEST |
static Font |
NUMBER_FONT |
static int |
NUMBER_THRESHOLD |
static int |
PLUS1 |
static int |
SIMPLE |
static double |
SIMPLE_FRACTION |
static int |
SOUTH |
static int |
SOUTHEAST |
static int |
SOUTHWEST |
static boolean |
TOKEN_TRACE |
static double |
WALL_FRACTION |
static double |
WALL_TOLERANCE |
static int |
WEST |
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor and Description |
---|
KarelWorld() |
Modifier and Type | Method and Description |
---|---|
void |
add(KarelInterface karel) |
static Point |
adjacentPoint(int x,
int y,
int dir) |
static Point |
adjacentPoint(Point pt,
int dir) |
static int |
adjustBeepers(int nBeepers,
int delta) |
protected void |
beeperBagCommand() |
protected void |
beeperCommand() |
static String |
beeperLabel(int n) |
boolean |
checkWall(int x,
int y,
int dir) |
boolean |
checkWall(Point pt,
int dir) |
void |
clearWall(int x,
int y,
int dir) |
void |
clearWall(Point pt,
int dir) |
protected void |
componentResizedHook() |
Image |
createImage(int width,
int height) |
static String |
directionName(int dir) |
static void |
drawBeeper(Graphics g,
int x,
int y,
int size,
int n,
int border,
Component comp) |
static void |
drawBeeper(Graphics g,
int x,
int y,
int size,
String label,
int border,
Component comp) |
void |
drawBeeperForStyle(Graphics g,
int x,
int y,
int size,
int n,
int border) |
void |
drawCorner(Graphics g,
int x,
int y,
Point pt) |
void |
drawCornerMarker(Graphics g,
int x,
int y) |
void |
drawFancyKarel(Graphics g,
int x,
int y,
int dir,
int size) |
void |
drawFancyKarel(Graphics g,
int x,
int y,
int dir,
int size,
boolean msKarel) |
static void |
drawFancyKarel(Graphics g,
int x,
int y,
int dir,
int size,
Color color) |
static void |
drawFancyKarel(Graphics g,
int x,
int y,
int dir,
int size,
Color color,
boolean msKarel) |
void |
drawKarel(Graphics g,
int x,
int y,
int dir,
int size) |
static void |
drawMarkedCorner(Graphics g,
int x,
int y,
int size) |
void |
drawSimpleKarel(Graphics g,
int x,
int y,
int dir,
int size) |
void |
forceSquareSize(int size) |
int |
getAlignment() |
int |
getBeepersOnCorner(int x,
int y) |
int |
getBeepersOnCorner(Point pt) |
int |
getColumns() |
Color |
getCornerColor(int x,
int y) |
Color |
getCornerColor(Point pt) |
boolean |
getEditMode() |
int |
getHeight() |
<K extends KarelInterface> |
getKarel() |
<K extends KarelInterface> |
getKarel(int k) |
int |
getKarelCount() |
<K extends KarelInterface> |
getKarelOnSquare(int x,
int y) |
int |
getLook() |
protected stanford.karel.KarelWorldMonitor |
getMonitor() |
boolean |
getNumberSquaresFlag() |
String |
getPathname() |
String |
getPathName() |
boolean |
getRepaintFlag() |
int |
getRows() |
Dimension |
getSize() |
int |
getSquareSize() |
String |
getTitle() |
int |
getWidth() |
protected void |
ignoreCommand() |
void |
init(int cols,
int rows) |
static void |
labelBeeper(Graphics g,
int x,
int y,
int size,
String label,
Component comp) |
static int |
leftFrom(int dir) |
void |
load(File file) |
void |
load(Reader rd) |
void |
load(String pathname) |
void |
load(String[] lines) |
protected void |
mouseDraggedHook(MouseEvent e) |
protected void |
mousePressedHook(MouseEvent e) |
static int |
oppositeDirection(int dir) |
boolean |
outOfBounds(int x,
int y) |
boolean |
outOfBounds(Point pt) |
void |
paintComponent(Graphics g) |
void |
remove(KarelInterface karel) |
void |
repaint() |
void |
reset() |
static int |
rightFrom(int dir) |
void |
save() |
void |
saveToImage(File file)
Saves an image of this Karel world to the given image file.
|
void |
saveToImage(String filename)
Saves an image of this Karel world to the given image file.
|
void |
setAlignment(int alignment) |
static int |
setBeepers(int nBeepers,
int delta) |
void |
setBeepersOnCorner(int x,
int y,
int nBeepers) |
void |
setBeepersOnCorner(Point pt,
int nBeepers) |
void |
setCornerColor(int x,
int y,
Color color) |
void |
setCornerColor(Point pt,
Color color) |
void |
setDisplayFlag(boolean flag) |
void |
setDisplayOneFlag(boolean flag) |
void |
setEditMode(boolean flag) |
void |
setInteractiveMode(boolean value) |
void |
setLook(int look) |
protected void |
setMonitor(stanford.karel.KarelWorldMonitor monitor) |
void |
setMsKarel(boolean value) |
void |
setNumberSquaresFlag(boolean flag) |
void |
setPathname(String pathname) |
void |
setPathName(String pathname) |
void |
setRepaintFlag(boolean flag) |
void |
setSize(int width,
int height) |
void |
setTitle(String title) |
void |
setToDefaultSize() |
void |
setWall(int x,
int y,
int dir) |
void |
setWall(Point pt,
int dir) |
BufferedImage |
toImage()
Converts this Karel world into an image that is returned.
|
void |
trace() |
void |
update(Graphics g) |
void |
updateContents(Graphics g,
Point pt) |
void |
updateCorner(int x,
int y) |
void |
updateCorner(Point pt) |
void |
updateEditMode(boolean flag) |
void |
updateWalls(Graphics g,
Point pt) |
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, 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, updateUI
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, transferFocusDownCycle, validate, validateTree
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, 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, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, 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, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
public static final int NORTH
public static final int EAST
public static final int SOUTH
public static final int WEST
public static final int NORTHEAST
public static final int NORTHWEST
public static final int SOUTHEAST
public static final int SOUTHWEST
public static final int CENTER
public static final int INFINITE
public static final int PLUS1
public static final int MINUS1
public static final int BLANKB
public static final int SIMPLE
public static final int FANCY
public static final int LEFT_NUMBER_MARGIN
public static final int BOTTOM_NUMBER_MARGIN
public static final int DOUBLE_WALL_THRESHOLD
public static final int CROSS_THRESHOLD
public static final int NUMBER_THRESHOLD
public static final Font NUMBER_FONT
public static final Font BEEPER_NUMBER_FONT
public static final double WALL_FRACTION
public static final double WALL_TOLERANCE
public static final int MAX_WIDTH
public static final int MAX_HEIGHT
public static final int MAX_DISPLAY_WIDTH
public static final int MAX_DISPLAY_HEIGHT
public static final boolean TOKEN_TRACE
public static final Color BEEPER_COLOR
public static final Color MARKED_COLOR
public static final int BEEPER_BORDER
public static final String BEEPER_FONT_FAMILY
public static final int MIN_FANCY
public static final int MIN_BEEPER
public static final int MIN_LABEL
public static final double BEEPER_FRACTION
public static final double SIMPLE_FRACTION
public Image createImage(int width, int height)
createImage
in class Component
public void init(int cols, int rows)
public void add(KarelInterface karel)
public void remove(KarelInterface karel)
public <K extends KarelInterface> K getKarel()
public <K extends KarelInterface> K getKarel(int k)
public int getKarelCount()
public <K extends KarelInterface> K getKarelOnSquare(int x, int y)
public void setTitle(String title)
public String getTitle()
public void setPathname(String pathname)
public String getPathname()
public void setDisplayFlag(boolean flag)
public void setRepaintFlag(boolean flag)
public boolean getRepaintFlag()
public boolean getNumberSquaresFlag()
public void setNumberSquaresFlag(boolean flag)
public int getAlignment()
public void setAlignment(int alignment)
public int getLook()
public void setLook(int look)
public void setDisplayOneFlag(boolean flag)
public String getPathName()
public void setPathName(String pathname)
public boolean getEditMode()
public void setEditMode(boolean flag)
public void updateEditMode(boolean flag)
public void forceSquareSize(int size)
public void reset()
public int getSquareSize()
public int getColumns()
public int getRows()
public boolean outOfBounds(Point pt)
public boolean outOfBounds(int x, int y)
public int getBeepersOnCorner(Point pt)
public int getBeepersOnCorner(int x, int y)
public void setBeepersOnCorner(Point pt, int nBeepers)
public void setBeepersOnCorner(int x, int y, int nBeepers)
public static int adjustBeepers(int nBeepers, int delta)
public static int setBeepers(int nBeepers, int delta)
public Color getCornerColor(int x, int y)
public void setCornerColor(int x, int y, Color color)
public boolean checkWall(Point pt, int dir)
public boolean checkWall(int x, int y, int dir)
public void setWall(Point pt, int dir)
public void setWall(int x, int y, int dir)
public void clearWall(Point pt, int dir)
public void clearWall(int x, int y, int dir)
public void updateCorner(int x, int y)
public void updateCorner(Point pt)
public static String directionName(int dir)
public static int leftFrom(int dir)
public static int rightFrom(int dir)
public static int oppositeDirection(int dir)
public static Point adjacentPoint(int x, int y, int dir)
public void saveToImage(File file)
public void saveToImage(String filename)
public int getWidth()
getWidth
in class JComponent
public int getHeight()
getHeight
in class JComponent
public void setToDefaultSize()
public BufferedImage toImage()
public void update(Graphics g)
update
in class JComponent
public void paintComponent(Graphics g)
paintComponent
in class JComponent
public void trace()
protected void setMonitor(stanford.karel.KarelWorldMonitor monitor)
protected stanford.karel.KarelWorldMonitor getMonitor()
protected void componentResizedHook()
protected void mousePressedHook(MouseEvent e)
protected void mouseDraggedHook(MouseEvent e)
public static void drawMarkedCorner(Graphics g, int x, int y, int size)
public void drawKarel(Graphics g, int x, int y, int dir, int size)
public void drawSimpleKarel(Graphics g, int x, int y, int dir, int size)
public void drawFancyKarel(Graphics g, int x, int y, int dir, int size)
public void drawFancyKarel(Graphics g, int x, int y, int dir, int size, boolean msKarel)
public static void drawFancyKarel(Graphics g, int x, int y, int dir, int size, Color color)
public static void drawFancyKarel(Graphics g, int x, int y, int dir, int size, Color color, boolean msKarel)
public void drawBeeperForStyle(Graphics g, int x, int y, int size, int n, int border)
public static void drawBeeper(Graphics g, int x, int y, int size, int n, int border, Component comp)
public static void drawBeeper(Graphics g, int x, int y, int size, String label, int border, Component comp)
public static void labelBeeper(Graphics g, int x, int y, int size, String label, Component comp)
public static String beeperLabel(int n)
public void drawCornerMarker(Graphics g, int x, int y)
public void save()
public void load(String[] lines)
public void load(File file)
public void load(String pathname)
public void load(Reader rd)
public void setMsKarel(boolean value)
public void setInteractiveMode(boolean value)
protected void beeperBagCommand()
protected void beeperCommand()
protected void ignoreCommand()