|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.Component java.awt.Container java.awt.Window java.awt.Frame TurtleGraphicsWindow
public class TurtleGraphicsWindow
Wrapper class which provides the TurtleGraphics support from the TG Logo programmng environment to the world of programming in Java.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.awt.Frame |
---|
java.awt.Frame.AccessibleAWTFrame |
Nested classes/interfaces inherited from class java.awt.Window |
---|
java.awt.Window.AccessibleAWTWindow |
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.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
Field Summary | |
---|---|
static int |
AQUA
Symbolic constant for input to setpencolor(). |
static int |
ARROW
jLogo comes with a few basic shapes (images) that the turtle may take on. |
static int |
BALL
jLogo comes with a few basic shapes (images) that the turtle may take on. |
static int |
BLACK
The setpencolor method's input is a built-in color number or an RGB value. |
static int |
BLUE
Symbolic constant for input to setpencolor(). |
static int |
BOX
jLogo comes with a few basic shapes (images) that the turtle may take on. |
static int |
BROWN
Symbolic constant for input to setpencolor(). |
static int |
CHOCOLATE
Symbolic constant for input to setpencolor(). |
static int |
COURIER
Symbolic constant for setlabelfont() to select a fixed-width Courier font. |
static int |
COURIER_BOLD
Symbolic constant for setlabelfont() to select an emboldened fixed-width Courier font. |
static int |
COURIER_BOLD_ITALIC
Symbolic constant for setlabelfont() to select an emboldened and italicized fixed-width Courier font. |
static int |
COURIER_ITALIC
Symbolic constant for setlabelfont() to select an italicized fixed-width Courier font. |
static int |
CROSS
jLogo comes with a few basic shapes (images) that the turtle may take on. |
static int |
CYAN
Symbolic constant for input to setpencolor(). |
static int |
DEFAULT_CANVAS_HEIGHT
Default height of the graphics canvas. |
static int |
DEFAULT_CANVAS_WIDTH
Default width of the graphics canvas. |
static int |
DIAMOND
jLogo comes with a few basic shapes (images) that the turtle may take on. |
static int |
EAST
Turtle heading for the positive X axis. |
static int |
FIRST_USER_SUPPLIED_SHAPE
The minimum shape number that users can assign an image of their own to. |
static int |
FOREST
Symbolic constant for input to setpencolor(). |
static int |
GOLD
Symbolic constant for input to setpencolor(). |
static int |
GRAY
Symbolic constant for input to setpencolor(). |
static int |
GREEN
Symbolic constant for input to setpencolor(). |
static int |
KHAKI
Symbolic constant for input to setpencolor(). |
static int |
LAST_USER_SUPPLIED_SHAPE
The maximum shape number that users can assign an image of their own to. |
static int |
LAWNGREEN
Symbolic constant for input to setpencolor(). |
static int |
LIGHTBLUE
Symbolic constant for input to setpencolor(). |
static int |
LIGHTGRAY
Symbolic constant for input to setpencolor(). |
static int |
LIME
Symbolic constant for input to setpencolor(). |
static int |
LINECAP_BUTT
Symbolic constant for setLinecap() which selects a basic line with no endcap. |
static int |
LINECAP_ROUND
Symbolic constant for setLinecap() to which selects a rounded endcap. |
static int |
LINECAP_SQUARE
Symbolic constant for setLinecap() to which selects a squared-off endcap. |
static int |
MAGENTA
Symbolic constant for input to setpencolor(). |
static int |
MAX_LOGO_COLOR
The maximum value for a built-in color which require conversion to RGB colors used by Java. |
static int |
NAVY
Symbolic constant for input to setpencolor(). |
static int |
NORTH
Turtle heading for the positive Y axis. |
static int |
NUM_USER_SUPPLIED_SHAPES
The number of shape numbers reserved for users to assign their own images to. |
static int |
OLIVE
Symbolic constant for input to setpencolor(). |
static int |
ORANGE
Symbolic constant for input to setpencolor(). |
static int |
PALEGREEN
Symbolic constant for input to setpencolor(). |
static int |
PERU
Symbolic constant for input to setpencolor(). |
static int |
PINK
Symbolic constant for input to setpencolor(). |
static int |
PURPLE
Symbolic constant for input to setpencolor(). |
static int |
RED
Symbolic constant for input to setpencolor(). |
static int |
SALMON
Symbolic constant for input to setpencolor(). |
static int |
SANS_SERIF
Symbolic constant for setlabelfont() to select the Sans Serif font. |
static int |
SANS_SERIF_BOLD
Symbolic constant for setlabelfont() to select an emboldened Sans Serif font. |
static int |
SANS_SERIF_BOLD_ITALIC
Symbolic constant for setlabelfont() to select an emboldened and italicized Sans Serif font. |
static int |
SANS_SERIF_ITALIC
Symbolic constant for setlabelfont() to select an italicized Sans Serif font. |
static int |
SERIF
Symbolic constant for setlabelfont() to select the Serif font. |
static int |
SERIF_BOLD
Symbolic constant for setlabelfont() to select an emboldened Serif font. |
static int |
SERIF_BOLD_ITALIC
Symbolic constant for setlabelfont() to select an emboldened and italicized Serif font. |
static int |
SERIF_ITALIC
Symbolic constant for setlabelfont() to select an italicized Serif font. |
static int |
SKYBLUE
Symbolic constant for input to setpencolor(). |
static int |
SOUTH
Turtle heading for the negative Y axis. |
static int |
STEELBLUE
Symbolic constant for input to setpencolor(). |
static int |
TAN
Symbolic constant for input to setpencolor(). |
static int |
TRIANGLE
jLogo comes with a few basic shapes (images) that the turtle may take on. |
static int |
TURTLE
jLogo comes with a few basic shapes (images) that the turtle may take on. |
static int |
VIOLET
Symbolic constant for input to setpencolor(). |
static int |
WEST
Turtle heading for the negative X axis. |
static int |
WHEAT
Symbolic constant for input to setpencolor(). |
static int |
WHITE
Symbolic constant for input to setpencolor(). |
static int |
YELLOW
Symbolic constant for input to setpencolor(). |
Fields inherited from class java.awt.Frame |
---|
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 |
Fields inherited from class java.awt.Component |
---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface TGKeyHandler |
---|
ALT, CONTROL, DOWN, DOWN_ARROW, LEFT, LEFT_ARROW, RIGHT, RIGHT_ARROW, SHIFT, UP, UP_ARROW |
Fields inherited from interface java.awt.image.ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
---|---|
TurtleGraphicsWindow()
Create and return an AWT Frame which contains a turtle graphics canvas. |
|
TurtleGraphicsWindow(int width,
int height)
Create and return an AWT Frame which contains a turtle graphics Canvas. |
Method Summary | |
---|---|
void |
arc(double angle,
double radius)
Draws an arc of a circle, with the turtle at the center, with the specified radius, starting at the turtle's heading and extending clockwise through the specified angle. |
void |
arc(int angle,
int radius)
Draws an arc of a circle, with the turtle at the center, with the specified radius, starting at the turtle's heading and extending clockwise through the specified angle. |
void |
back(double steps)
Move the turtle backwards along its current heading. |
void |
back(int steps)
Move the turtle backwards along its current heading. |
void |
bk(double steps)
Move the turtle backwards along its current heading. |
void |
bk(int steps)
Move the turtle backwards along its current heading. |
void |
clean()
Clear the graphics canvas area of the TurtleGraphicsWindow. |
int[] |
colorsunder()
Return an array of the unique colors this turtle's image is positioned over. |
int |
colorunder()
Return the color under the center of the turtle's image. |
void |
fd(double steps)
Move the turtle forward along its current heading. |
void |
fd(int steps)
Move the turtle forward along its current heading. |
void |
fill()
Fill a bounded area in the graphics canvas. |
void |
forward(double steps)
Move the turtle forward along its current heading. |
void |
forward(int steps)
Move the turtle forward along its current heading. |
double |
heading()
Return the turtle's heading in Logo (turtle space) degrees. |
void |
hideturtle()
Hide the turtle; make it invisible. |
void |
home()
Move the turtle to the center of the display. |
void |
ht()
Hide the turtle; make it invisible. |
boolean |
ispendown()
Return the current status of the pen. |
void |
keypressed(int keyNum)
Deprecated. |
void |
label(java.lang.String text)
Draws a String of characters on the graphics canvas. |
int |
labelwidth(java.lang.String label)
Return the width of the provided String, when rendered in the current font, in turtle steps (pixels). |
void |
left(double degrees)
Rotate the turtle counterclockwise by the specified angle, measured in degrees. |
void |
left(int degrees)
Rotate the turtle counterclockwise by the specified angle, measured in degrees. |
boolean |
loadpicture(java.lang.String fileName)
Draw a picture from a file onto the background of the graphics canvas. |
boolean |
loadshape(java.lang.String fileName,
int shapeNum)
Load an image file; it can then be used for a turtle's shape, its image. |
void |
lt(double degrees)
Rotate the turtle counterclockwise by the specified angle, measured in degrees. |
void |
lt(int degrees)
Rotate the turtle counterclockwise by the specified angle, measured in degrees. |
int |
mousex()
Return the x-coordinate where the mouse was last moved or clicked within the graphics canvas. |
int |
mousey()
Return the Y-coordinate where the mouse was last moved or clicked within the graphics canvas. |
void |
pd()
Lower the turtle's pen into the down position. |
int |
pencolor()
Return the color the pen is currently drawing in. |
void |
pendown()
Lower the turtle's pen into the down position. |
void |
penup()
Lift the turtle's pen into the up position. |
TGPoint |
pos()
Return the current position of this turtle. |
void |
pu()
Lift the turtle's pen into the up position. |
void |
right(double degrees)
Rotate the turtle clockwise by the specified angle, measured in degrees. |
void |
right(int degrees)
Rotate the turtle clockwise by the specified angle, measured in degrees. |
void |
rt(double degrees)
Rotate the turtle clockwise by the specified angle, measured in degrees. |
void |
rt(int degrees)
Rotate the turtle clockwise by the specified angle, measured in degrees. |
void |
setbg(int logoColor)
Set the background color of the graphics canvas. |
void |
seth(double degrees)
Turns the turtle to the specified absolute heading. |
void |
seth(int degrees)
Turns the turtle to the specified absolute heading. |
void |
setheading(double degrees)
Turns the turtle to the specified absolute heading. |
void |
setheading(int degrees)
Turns the turtle to the specified absolute heading. |
void |
setlabelfont(int fontNumber)
Set the font for LABELs, text drawn on the graphics canvas by the turtle. |
void |
setlabelheight(int size)
Set the height of the text drawn on the graphics canvas with the label() method. |
void |
setlinecap(int typeLinecap)
Set the type of linecaps applied to the ends of lines drawn. |
void |
setpc(int colorNum)
Sets the color of the turtle's pen to the supplied number. |
void |
setpencolor(int colorNum)
Sets the color of the turtle's pen to the supplied number. |
void |
setpenpattern(int segmentSize)
Set the pattern used to draw lines. |
void |
setpenpattern(int[] pattern)
Set the pattern used to draw lines. |
void |
setpensize(int width)
Sets the width of the turtle's pen to the supplied number. |
void |
setpos(TGPoint pos)
Move the turtle to an absolute display position, to the x and y coordinates in the TGPoint parameter. |
boolean |
setshape(int shapeNum)
Sets the shape of the turtle - its pixel image. |
boolean |
setshape(int shapeNum,
int[] params)
Sets the shape of the turtle - its pixel image. |
void |
setshape(SpritePixels newSpritePixels)
Sets the shape of the turtle - its pixel image. |
void |
setx(double newX)
Move the turtle to an absolute display position. |
void |
setx(int newX)
Move the turtle to an absolute display position. |
void |
setxy(double newX,
double newY)
Move the turtle to an absolute display position. |
void |
setxy(int newX,
int newY)
Move the turtle to an absolute display position. |
void |
setxy(TGPoint newPt)
Move the turtle to an absolute display position. |
void |
sety(double newY)
Move the turtle to an absolute display position. |
void |
sety(int newY)
Move the turtle to an absolute display position. |
int |
shapeheight()
Return the height of the image of the turtle, as it appears for its current heading. |
int |
shapewidth()
Return the width of the image of the turtle, as it appears for its current heading. |
boolean |
shownp()
Return true if this turtle's image is being displayed on the graphics canvas, else return false. |
void |
showturtle()
Show the turtle; make it visible. |
void |
st()
Show the turtle; make it visible. |
void |
stamp()
Draw the turtle's image onto the graphics canvas. |
void |
tgKeyPressed(int keyNum)
TurtleGraphicsWindow implements the TGKeyHandler interface and registers with TGCanvas to receive keyboard key events. |
void |
tgKeyReleased(int keyNum)
TurtleGraphicsWindow implements the TGKeyHandler interface and registers with TGCanvas to receive keyboard key events. |
void |
tgKeyTyped(char keyChar)
TurtleGraphicsWindow implements the TGKeyHandler interface and registers with TGCanvas to receive keyboard key events. |
void |
tgMouseClicked(int x,
int y)
TurtleGraphicsWindow implements the TGMouseHandler interface and registers with TGCanvas to receive mouse events. |
void |
tgMouseMoved(int x,
int y)
TurtleGraphicsWindow implements the TGMouseHandler interface and registers with TGCanvas to receive mouse events. |
void |
throttle(int amt)
Set the amount of time (milliseconds) that drawing is suspended each time a method which visibly changes the turtle's state is performed. |
void |
windowActivated(java.awt.event.WindowEvent we)
|
void |
windowClosed(java.awt.event.WindowEvent we)
|
void |
windowClosing(java.awt.event.WindowEvent we)
|
void |
windowDeactivated(java.awt.event.WindowEvent we)
|
void |
windowDeiconified(java.awt.event.WindowEvent we)
|
void |
windowIconified(java.awt.event.WindowEvent we)
|
void |
windowOpened(java.awt.event.WindowEvent we)
|
int |
xcor()
Return the turtle's X-coordinate |
int |
ycor()
Return the turtle's Y-coordinate |
Methods inherited from class java.awt.Frame |
---|
addNotify, getAccessibleContext, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, paramString, remove, removeNotify, setCursor, setExtendedState, setIconImage, setMaximizedBounds, setMenuBar, setResizable, setState, setTitle, setUndecorated |
Methods inherited from class java.awt.Window |
---|
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOwnedWindows, getOwner, getOwnerlessWindows, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, paint, postEvent, processEvent, processWindowEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setVisible, show, toBack, toFront |
Methods inherited from class java.awt.Container |
---|
add, add, add, add, add, addContainerListener, addImpl, 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, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, setLayout, transferFocusBackward, transferFocusDownCycle, update, 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, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, 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, isOpaque, 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, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resize, resize, setBackground, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusUpCycle |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.awt.MenuContainer |
---|
getFont, postEvent |
Field Detail |
---|
public static final int DEFAULT_CANVAS_HEIGHT
public static final int DEFAULT_CANVAS_WIDTH
public static final int BLACK
public static final int BLUE
public static final int GREEN
public static final int CYAN
public static final int RED
public static final int MAGENTA
public static final int YELLOW
public static final int WHITE
public static final int BROWN
public static final int TAN
public static final int FOREST
public static final int AQUA
public static final int SALMON
public static final int VIOLET
public static final int ORANGE
public static final int GRAY
public static final int NAVY
public static final int SKYBLUE
public static final int LIME
public static final int STEELBLUE
public static final int CHOCOLATE
public static final int PURPLE
public static final int GOLD
public static final int LIGHTGRAY
public static final int PERU
public static final int WHEAT
public static final int PALEGREEN
public static final int LIGHTBLUE
public static final int KHAKI
public static final int PINK
public static final int LAWNGREEN
public static final int OLIVE
public static final int MAX_LOGO_COLOR
public static final int COURIER
setlabelfont(int)
,
Constant Field Valuespublic static final int COURIER_BOLD
setlabelfont(int)
,
Constant Field Valuespublic static final int COURIER_ITALIC
setlabelfont(int)
,
Constant Field Valuespublic static final int COURIER_BOLD_ITALIC
setlabelfont(int)
,
Constant Field Valuespublic static final int SANS_SERIF
setlabelfont(int)
,
Constant Field Valuespublic static final int SANS_SERIF_BOLD
setlabelfont(int)
,
Constant Field Valuespublic static final int SANS_SERIF_ITALIC
setlabelfont(int)
,
Constant Field Valuespublic static final int SANS_SERIF_BOLD_ITALIC
setlabelfont(int)
,
Constant Field Valuespublic static final int SERIF
setlabelfont(int)
,
Constant Field Valuespublic static final int SERIF_BOLD
setlabelfont(int)
,
Constant Field Valuespublic static final int SERIF_ITALIC
setlabelfont(int)
,
Constant Field Valuespublic static final int SERIF_BOLD_ITALIC
setlabelfont(int)
,
Constant Field Valuespublic static final int NORTH
seth(double)
,
setheading(double)
,
Constant Field Valuespublic static final int EAST
seth(double)
,
setheading(double)
,
Constant Field Valuespublic static final int SOUTH
seth(double)
,
setheading(double)
,
Constant Field Valuespublic static final int WEST
seth(double)
,
setheading(double)
,
Constant Field Valuespublic static final int TURTLE
public static final int ARROW
public static final int BALL
public static final int BOX
public static final int CROSS
public static final int TRIANGLE
public static final int DIAMOND
public static final int LINECAP_BUTT
public static final int LINECAP_ROUND
public static final int LINECAP_SQUARE
public static final int FIRST_USER_SUPPLIED_SHAPE
public static final int NUM_USER_SUPPLIED_SHAPES
public static final int LAST_USER_SUPPLIED_SHAPE
Constructor Detail |
---|
public TurtleGraphicsWindow()
public TurtleGraphicsWindow(int width, int height)
Method Detail |
---|
public void tgKeyPressed(int keyNum)
Override this method to do something when a key on the keyboard is pressed while the graphics canvas is active, has focus.
tgKeyPressed
in interface TGKeyHandler
keyNum
- key identifier - either a character or an
action key code (e.g., arrow keys)TGKeyHandler.ALT
,
TGKeyHandler.CONTROL
,
TGKeyHandler.DOWN_ARROW
,
TGKeyHandler.LEFT_ARROW
,
TGKeyHandler.RIGHT_ARROW
,
TGKeyHandler.SHIFT
,
TGKeyHandler.UP_ARROW
public void tgKeyReleased(int keyNum)
Override this method to do something when a key which generates a character is pressed and released while the graphics canvas is active, has focus.
tgKeyReleased
in interface TGKeyHandler
keyNum
- key identifier - either a character or an
action key code (e.g., arrow keys)TGKeyHandler.ALT
,
TGKeyHandler.CONTROL
,
TGKeyHandler.DOWN_ARROW
,
TGKeyHandler.LEFT_ARROW
,
TGKeyHandler.RIGHT_ARROW
,
TGKeyHandler.SHIFT
,
TGKeyHandler.UP_ARROW
public void tgKeyTyped(char keyChar)
Override this method to do something when a key on the keyboard is released while the graphics canvas is active, has focus.
tgKeyTyped
in interface TGKeyHandler
keyChar
- a character generated by a keyboard keypublic void tgMouseClicked(int x, int y)
Override this method to do something when the left mouse button is clicked in the graphics canvas while it is active, has focus.
tgMouseClicked
in interface TGMouseHandler
x
- the X-coordinate where mouse was clickedy
- the Y-coordinate where mouse was clickedmousex()
,
mousey()
,
tgMouseMoved(int, int)
public void tgMouseMoved(int x, int y)
Override this method to do something when the mouse is moved within the graphics canvas while it is active, has focus.
tgMouseMoved
in interface TGMouseHandler
x
- the X-coordinate where mouse was clicked.y
- the Y-coordinate where mouse was clicked.mousex()
,
mousey()
,
tgMouseClicked(int, int)
public void windowActivated(java.awt.event.WindowEvent we)
windowActivated
in interface java.awt.event.WindowListener
public void windowClosed(java.awt.event.WindowEvent we)
windowClosed
in interface java.awt.event.WindowListener
public void windowClosing(java.awt.event.WindowEvent we)
windowClosing
in interface java.awt.event.WindowListener
public void windowDeactivated(java.awt.event.WindowEvent we)
windowDeactivated
in interface java.awt.event.WindowListener
public void windowDeiconified(java.awt.event.WindowEvent we)
windowDeiconified
in interface java.awt.event.WindowListener
public void windowIconified(java.awt.event.WindowEvent we)
windowIconified
in interface java.awt.event.WindowListener
public void windowOpened(java.awt.event.WindowEvent we)
windowOpened
in interface java.awt.event.WindowListener
public void arc(double angle, double radius) throws java.lang.IllegalArgumentException
angle
- clockwise rotation from current heading (in degrees)radius
- distance from center of the turtle to the drawn arc,
to the center of the arc line if the pen width is
greater than 1.
java.lang.IllegalArgumentException
public void arc(int angle, int radius) throws java.lang.IllegalArgumentException
angle
- clockwise rotation from current heading (in degrees)radius
- distance from center of the turtle to the drawn arc,
to the center of the arc line if the pen width is
greater than 1.
java.lang.IllegalArgumentException
public void back(double steps)
steps
- number of turtle steps to movebk(double)
public void back(int steps)
steps
- number of turtle steps to movebk(double)
public void bk(double steps)
steps
- number of turtle steps to movebk(double)
public void bk(int steps)
steps
- Number of turtle steps to moveback(double)
public void clean()
public int[] colorsunder()
pencolor()
,
setbg(int)
,
setpc(int)
,
setpencolor(int)
public int colorunder()
pencolor()
,
setpc(int)
,
setpencolor(int)
public void fill()
public void fd(double steps)
steps
- Number of turtle steps to take.forward(double)
public void fd(int steps)
steps
- Number of turtle steps to take.forward(double)
public void forward(double steps)
steps
- number of turtle steps to move in current directionfd(double)
public void forward(int steps)
steps
- number of turtle steps to move in current directionfd(double)
public int labelwidth(java.lang.String label)
label
- text to be measuredlabel(java.lang.String)
,
setlabelfont(int)
,
setlabelheight(int)
public double heading()
seth(double)
,
setheading(double)
public void hideturtle()
ht()
,
showturtle()
,
st()
public void home()
setxy(double, double)
public void ht()
hideturtle()
,
showturtle()
,
st()
public boolean ispendown()
pendown()
,
penup()
,
pd()
,
pu()
public void keypressed(int keyNum)
keyNum
- Character on the keyboard that was pressed
while the graphics canvas has its focus.tgKeyPressed(int)
,
tgKeyReleased(int)
,
tgKeyTyped(char)
public void label(java.lang.String text)
text
- characters to be drawn on the graphics canvaslabelwidth(java.lang.String)
,
setlabelfont(int)
,
setlabelheight(int)
public void left(double degrees)
degrees
- angle to rotate the turtle's headinglt(double)
public void left(int degrees)
degrees
- angle to rotate the turtle's headinglt(double)
public boolean loadpicture(java.lang.String fileName)
fileName
- String that identifies the source
image fileclean()
public boolean loadshape(java.lang.String fileName, int shapeNum)
fileName
- String that identifies the source
image fileshapeNum
- an integer that is between
FIRST_USER_SUPPLIED_SHAPE and
LAST_USER_SUPPLIED_SHAPE, inclusive
This number can then be used with
setshape() to change the turtle's
appearancesetshape(int)
public void lt(double degrees)
degrees
- Angle to change turtle's heading by.left(double)
public void lt(int degrees)
degrees
- Angle to change turtle's heading by.left(double)
public int mousex()
mousey()
,
tgMouseClicked(int, int)
,
tgMouseMoved(int, int)
public int mousey()
mousex()
,
tgMouseClicked(int, int)
,
tgMouseMoved(int, int)
public void pd()
ispendown()
,
pendown()
,
pu()
,
penup()
public int pencolor()
setpc(int)
,
setpencolor(int)
public void pendown()
ispendown()
,
pd()
,
penup()
,
pu()
public void penup()
ispendown()
,
pd()
,
pendown()
,
pu()
public TGPoint pos()
public void pu()
ispendown()
,
pd()
,
pendown()
,
penup()
public void right(double degrees)
degrees
- angle to rotate the turtle's headingrt(double)
public void right(int degrees)
degrees
- angle to rotate the turtle's headingrt(double)
public void rt(double degrees)
degrees
- angle to rotate the turtle's headingright(double)
public void rt(int degrees)
degrees
- angle to rotate the turtle's headingright(double)
public void setbg(int logoColor)
*NOTE* a side-effect of changing the background color is that all current graphics is cleared.
Number Color Number Color Number Color ------ ---------- ------ ---------- ------ --------- 0 black 11 aqua 22 gold 1 blue 12 salmon 23 lightgray 2 green 13 purple 24 peru 3 cyan 14 orange 25 wheat 4 red 15 grey 26 palegreen 5 magenta 16 navy 27 lightblue 6 yellow 17 skyblue 28 khaki 7 white 18 lime 29 pink 8 brown 19 steelblue 30 lawngreen 9 light brown 20 chocolate 31 olive 10 forest 21 purple
Color numbers greater than 31 will be treated as RGB values. Assuming bits are numbered 0-31, left to right, the red component is in bits 8-15, the green component in bits 16-23, and the blue component in bits 24-31. The actual color used in rendering will depend on finding the best match given the color space available for a given display.
clean()
,
loadpicture(java.lang.String)
,
setpencolor(int)
,
BLACK
,
BLUE
,
AQUA
,
BROWN
,
CHOCOLATE
,
CYAN
,
GOLD
,
FOREST
,
GRAY
,
GREEN
,
KHAKI
,
LAWNGREEN
,
LIGHTBLUE
,
LIGHTGRAY
,
LIME
,
MAGENTA
,
NAVY
,
OLIVE
,
ORANGE
,
PALEGREEN
,
PERU
,
PINK
,
PURPLE
,
RED
,
SALMON
,
SKYBLUE
,
STEELBLUE
,
TAN
,
VIOLET
,
WHEAT
,
WHITE
,
YELLOW
public void seth(double degrees)
degrees
- number of 1/360ths increments clockwise
from the positive Y axissetheading(double)
public void seth(int degrees)
degrees
- number of 1/360ths increments clockwise
from the positive Y axissetheading(double)
public void setheading(double degrees)
degrees
- number of 1/360ths increments clockwise
from the positive Y axisseth(double)
public void setheading(int degrees)
degrees
- number of 1/360ths increments clockwise
from the positive Y axisseth(double)
public void setlabelfont(int fontNumber) throws java.lang.IllegalArgumentException
fontNumber
- an integer representing a font face
and font style
Number Font Style ------ ---------- ----------- 0 Courier Plain 1 Courier Bold 2 Courier Italic 3 Courier Bold Italic 4 Sans Serif Plain 5 Sans Serif Bold 6 Sans Serif Italic 7 Sans Serif Bold Italic 8 Serif Plain 9 Serif Bold 10 Serif Italic 11 Serif Bold Italic
java.lang.IllegalArgumentException
label(java.lang.String)
,
labelwidth(java.lang.String)
,
setlabelheight(int)
,
COURIER
,
COURIER_BOLD
,
COURIER_ITALIC
,
COURIER_BOLD_ITALIC
,
SANS_SERIF
,
SANS_SERIF_BOLD
,
SANS_SERIF_ITALIC
,
SANS_SERIF_BOLD_ITALIC
,
SERIF
,
SERIF_BOLD
,
SERIF_ITALIC
,
SERIF_BOLD_ITALIC
public void setlabelheight(int size) throws java.lang.IllegalArgumentException
size
- approximate number of pixels tall the
uppercase characters should be (in the
current font/style)
java.lang.IllegalArgumentException
label(java.lang.String)
,
setlabelfont(int)
,
labelwidth(java.lang.String)
public void setlinecap(int typeLinecap) throws java.lang.IllegalArgumentException
typeLinecap
- an integer representing the desired linecap.
java.lang.IllegalArgumentException
public void setpc(int colorNum)
colorNum
- either a built-in Logo color number in
the range 0-31, else a 24-bit RGB color
value
Number Color Number Color Number Color ------ ---------- ------ ---------- ------ --------- 0 black 11 aqua 22 gold 1 blue 12 salmon 23 lightgray 2 green 13 purple 24 peru 3 cyan 14 orange 25 wheat 4 red 15 grey 26 palegreen 5 magenta 16 navy 27 lightblue 6 yellow 17 skyblue 28 khaki 7 white 18 lime 29 pink 8 brown 19 steelblue 30 lawngreen 9 light brown 20 chocolate 31 olive 10 forest 21 purple
Color numbers greater than 31 will be treated as RGB values. Assuming bits are numbered 0-31, left to right, the red component is in bits 8-15, the green component in bits 16-23, and the blue component in bits 24-31. The actual color used in rendering will depend on finding the best match given the color space available for a given display.
setbg(int)
,
setpencolor(int)
,
BLACK
,
BLUE
,
AQUA
,
BROWN
,
CHOCOLATE
,
CYAN
,
GOLD
,
FOREST
,
GRAY
,
GREEN
,
KHAKI
,
LAWNGREEN
,
LIGHTBLUE
,
LIGHTGRAY
,
LIME
,
MAGENTA
,
NAVY
,
OLIVE
,
ORANGE
,
PALEGREEN
,
PERU
,
PINK
,
PURPLE
,
RED
,
SALMON
,
SKYBLUE
,
STEELBLUE
,
TAN
,
VIOLET
,
WHEAT
,
WHITE
,
YELLOW
public void setpencolor(int colorNum)
colorNum
- either a built-in Logo color number in
the range 0-31, else a 24-bit RGB color
value
Number Color Number Color Number Color ------ ---------- ------ ---------- ------ --------- 0 black 11 aqua 22 gold 1 blue 12 salmon 23 lightgray 2 green 13 purple 24 peru 3 cyan 14 orange 25 wheat 4 red 15 grey 26 palegreen 5 magenta 16 navy 27 lightblue 6 yellow 17 skyblue 28 khaki 7 white 18 lime 29 pink 8 brown 19 steelblue 30 lawngreen 9 light brown 20 chocolate 31 olive 10 forest 21 purple
Color numbers greater than 31 will be treated as RGB values. Assuming bits are numbered 0-31, left to right, the red component is in bits 8-15, the green component in bits 16-23, and the blue component in bits 24-31. The actual color used in rendering will depend on finding the best match given the color space available for a given display.
setbg(int)
,
setpc(int)
,
BLACK
,
BLUE
,
AQUA
,
BROWN
,
CHOCOLATE
,
CYAN
,
GOLD
,
FOREST
,
GRAY
,
GREEN
,
KHAKI
,
LAWNGREEN
,
LIGHTBLUE
,
LIGHTGRAY
,
LIME
,
MAGENTA
,
NAVY
,
OLIVE
,
ORANGE
,
PALEGREEN
,
PERU
,
PINK
,
PURPLE
,
RED
,
SALMON
,
SKYBLUE
,
STEELBLUE
,
TAN
,
VIOLET
,
WHEAT
,
WHITE
,
YELLOW
public void setpenpattern(int segmentSize) throws java.lang.IllegalArgumentException
segmentSize
- draw/skip amount.
java.lang.IllegalArgumentException
back(double)
,
bk(double)
,
fd(double)
,
forward(double)
,
home()
,
setx(double)
,
setxy(double, double)
,
sety(double)
public void setpenpattern(int[] pattern) throws java.lang.IllegalArgumentException
pattern
- array of draw/skip amounts. If pattern has an odd
number of elements, the last draw amount is duplicated for
the skip amount, producing a pattern one element longer.
java.lang.IllegalArgumentException
public void setpensize(int width)
width
- small positive number; 1 (or less) results in a
single pixel line. greater numbers result in
line widths equal to width pixels.public void setpos(TGPoint pos)
pos
- a TGPoint object containing the X-coordinate
and Y-coordinate of destinationhome()
,
setx(double)
,
setxy(double, double)
,
sety(double)
public boolean setshape(int shapeNum)
shapeNum
- small positive number for either a
built-in shape (see constants (e.g.,
BALL, BOX, etc...) or a user-supplied
image via loadShape() method
Number Shape ------ -------- 0 Turtle 1 Arrow 2 Ball 3 Box 4 Cross 5 Triangle 6 Diamond
loadshape(java.lang.String, int)
,
stamp()
,
ARROW
,
BALL
,
BOX
,
CROSS
,
DIAMOND
,
TRIANGLE
,
public boolean setshape(int shapeNum, int[] params)
shapeNum
- small positive number; 0 for default
turtle image; see constants (e.g., BALL,
BOX, etc...) for other turtle shapesparams
- an optional int array containing sizing
information hints, e.g. radius of a ball,
width and height of a box, etc...
Number Shape Optional Size Parameters ------ -------- ------------------------ 0 Turtle 1 Arrow width, height 2 Ball diameter 3 Box width, height 4 Cross width, height 5 Triangle width, height 6 Diamond width, height
loadshape(java.lang.String, int)
,
stamp()
,
ARROW
,
BALL
,
BOX
,
CROSS
,
DIAMOND
,
TRIANGLE
,
TURTLE
public void setshape(SpritePixels newSpritePixels)
newSpritePixels
- loadshape(java.lang.String, int)
public void setx(double newX)
newX
- the X-coordinate of destinationhome()
,
setxy(double, double)
,
sety(double)
public void setx(int newX)
newX
- the X-coordinate of destinationhome()
,
setxy(double, double)
,
sety(double)
public void setxy(double newX, double newY)
newX
- the X-coordinate of destinationnewY
- the Y-coordinate of destinationhome()
,
setx(double)
,
sety(double)
public void setxy(int newX, int newY)
newX
- the X-coordinate of destinationnewY
- the Y-coordinate of destinationhome()
,
setx(double)
,
sety(double)
public void setxy(TGPoint newPt)
newPt
- a TGPoint objext containing the X-coordinate
and Y-coordinate of destinationhome()
,
setx(double)
,
sety(double)
public void sety(double newY)
newY
- the Y-coordinate of destinationhome()
,
setx(double)
,
setxy(double, double)
public void sety(int newY)
newY
- the Y-coordinate of destinationhome()
,
setx(double)
,
setxy(double, double)
public int shapeheight()
setshape(int)
,
setshape(int, int[])
public int shapewidth()
setshape(int)
,
setshape(int, int[])
public boolean shownp()
hideturtle()
,
ht()
,
showturtle()
,
st()
public void showturtle()
hideturtle()
,
ht()
,
st()
public void st()
hideturtle()
,
ht()
,
showturtle()
public void stamp()
setshape(int)
,
setshape(int, int[])
public void throttle(int amt)
amt
- - milliseconds to pause after the visible state of
the turtle changes. When less than or equal to
zero, pausing is turned off.public int xcor()
setxy(double, double)
,
setx(double)
,
sety(double)
,
ycor()
public int ycor()
setxy(double, double)
,
setx(double)
,
sety(double)
,
xcor()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |