|
||||||||
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 javax.swing.JComponent javax.swing.JPanel edu.southern.computing.oopj.GraphicalObject
public class GraphicalObject
GraphicalObjects are persistent visual images that users can manipulate within a viewport. Graphical objects can receive user input from the pointing device and keyboard.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class javax.swing.JPanel |
---|
javax.swing.JPanel.AccessibleJPanel |
Nested classes/interfaces inherited from class javax.swing.JComponent |
---|
javax.swing.JComponent.AccessibleJComponent |
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 |
---|
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 edu.southern.computing.oopj.InteractiveArea |
---|
BLACK, BLUE, CROSSHAIR, CYAN, DARK_GRAY, GRAY, GREEN, HAND, LIGHT_GRAY, MAGENTA, MOVE, ORANGE, PINK, RED, TRANSPARENT, VERSION, WHITE, YELLOW |
Fields inherited from interface java.awt.image.ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
---|---|
GraphicalObject(int width,
int height)
Creates a graphical object with a given width and height. |
Method Summary | |
---|---|
void |
addNotify()
Called when a graphical object is added to another graphical component such as a viewport or another graphical object. |
void |
draw()
Called when this graphical object must be rendered within a viewport. |
void |
drawLine(int startX,
int startY,
int endX,
int endY)
Draws a line with the current drawing color. |
void |
drawLine(int startX,
int startY,
int endX,
int endY,
java.awt.Color color)
Draws a line with the given color. |
void |
drawOval(int left,
int top,
int width,
int height)
Draws an oval with the current drawing color. |
void |
drawOval(int left,
int top,
int width,
int height,
java.awt.Color color)
Draws an oval with the given color. |
void |
drawPolygon(int... coords)
Draws a polygon with the current color. |
void |
drawRectangle(int left,
int top,
int width,
int height)
Draws a rectangle with the current drawing color. |
void |
drawRectangle(int left,
int top,
int width,
int height,
java.awt.Color color)
Draws a rectangle with the given color. |
void |
drawString(java.lang.String message,
int x,
int y)
Draws a string with the current color. |
void |
fillOval(int left,
int top,
int width,
int height)
Paints a filled oval with the current color. |
void |
fillOval(int left,
int top,
int width,
int height,
java.awt.Color color)
Paints a filled oval with the given color. |
void |
fillPolygon(int... coords)
Paints a filled polygon with the current color. |
void |
fillRectangle(int left,
int top,
int width,
int height)
Paints a filled rectangle with the current color. |
void |
fillRectangle(int left,
int top,
int width,
int height,
java.awt.Color color)
Paints a filled rectangle with the given color. |
char |
getKeyTyped()
Returns the key typed by the user during the latest keyboard interaction event. |
int |
getMouseX()
Returns the x position of the latest mouse event. |
int |
getMouseY()
Returns the y position of the latest mouse event. |
boolean |
isMovable()
Indicates if the user can move the object. |
void |
keyPressed(java.awt.event.KeyEvent e)
Called when the user presses down a key when the graphical object has the keyboard focus. |
void |
keyReleased(java.awt.event.KeyEvent e)
Called when the user releases a pressed down a key when the graphical object has the keyboard focus. |
void |
keyTyped()
Called when the user presses and releases a key when the graphical object has the keyboard focus. |
void |
keyTyped(java.awt.event.KeyEvent e)
Called when the user presses and releases a key when the graphical object has the keyboard focus. |
void |
mouseClicked()
Called when the user presses and releases a mouse button when the pointer is over the graphical object. |
void |
mouseClicked(java.awt.event.MouseEvent e)
Called when the user presses and releases a mouse button when the pointer is over the graphical object. |
void |
mouseDragged()
Called when the user drags the mouse when the pointer is over the graphical object. |
void |
mouseDragged(java.awt.event.MouseEvent e)
Called when the user drags the mouse when the pointer is over the graphical object. |
void |
mouseEntered()
Called when the user moves the pointer into the graphical object. |
void |
mouseEntered(java.awt.event.MouseEvent e)
Called when the user moves the pointer into the graphical object. |
void |
mouseExited()
Called when the user moves the pointer out of the graphical object. |
void |
mouseExited(java.awt.event.MouseEvent e)
Called when the user moves the pointer out of the graphical object. |
void |
mouseMoved()
Called when the user moves the mouse when the pointer is over the graphical object. |
void |
mouseMoved(java.awt.event.MouseEvent e)
Called when the user moves the mouse when the pointer is over the graphical object. |
void |
mousePressed()
Called when the user presses a mouse button when the pointer is over the graphical object. |
void |
mousePressed(java.awt.event.MouseEvent e)
Called when the user presses a mouse button when the pointer is over the graphical object. |
void |
mouseReleased()
Called when the user releases a mouse button when the pointer is over the graphical object. |
void |
mouseReleased(java.awt.event.MouseEvent e)
Called when the user releases a mouse button when the pointer is over the graphical object. |
void |
paintComponent(java.awt.Graphics g)
Called when this graphical object must be rendered within a viewport. |
void |
removeNotify()
Called when a graphical object is removed from its current containing graphical component. |
static int |
round(double d)
Rounds the double to the nearest integer. |
void |
setColor(java.awt.Color color)
Draws a rectangle with the current drawing color. |
void |
setContextMenu(ContextMenu menu)
Attaches a given context menu to this graphical object/ |
void |
setMovable(boolean flag)
Determines if the user can move the object. |
protected void |
updateRoot(GraphicalObject root)
|
void |
visuallyUpdate()
Forces the redrawing of this graphical object. |
Methods inherited from class javax.swing.JPanel |
---|
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI |
Methods inherited from class javax.swing.JComponent |
---|
addAncestorListener, 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, 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, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, 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, update |
Methods inherited from class java.awt.Container |
---|
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, 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, firePropertyChange, 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, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, 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 |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public GraphicalObject(int width, int height)
width
- the width of the graphical objectheight
- the height of the graphical objectMethod Detail |
---|
protected void updateRoot(GraphicalObject root)
root
- public void addNotify()
addNotify
in class javax.swing.JComponent
public void removeNotify()
removeNotify
in class javax.swing.JComponent
public void setColor(java.awt.Color color)
color
- the new drawing color.public void drawLine(int startX, int startY, int endX, int endY, java.awt.Color color)
public void drawLine(int startX, int startY, int endX, int endY)
public void drawRectangle(int left, int top, int width, int height, java.awt.Color color)
public void drawRectangle(int left, int top, int width, int height)
public void fillRectangle(int left, int top, int width, int height, java.awt.Color color)
public void fillRectangle(int left, int top, int width, int height)
public void drawOval(int left, int top, int width, int height, java.awt.Color color)
public void drawOval(int left, int top, int width, int height)
public void fillOval(int left, int top, int width, int height, java.awt.Color color)
public void fillOval(int left, int top, int width, int height)
public void drawPolygon(int... coords)
public void fillPolygon(int... coords)
public void drawString(java.lang.String message, int x, int y)
public void setMovable(boolean flag)
public boolean isMovable()
public void mouseClicked(java.awt.event.MouseEvent e)
mouseClicked
in interface java.awt.event.MouseListener
public void mouseEntered(java.awt.event.MouseEvent e)
mouseEntered
in interface java.awt.event.MouseListener
public void mouseExited(java.awt.event.MouseEvent e)
mouseExited
in interface java.awt.event.MouseListener
public void mousePressed(java.awt.event.MouseEvent e)
mousePressed
in interface java.awt.event.MouseListener
public void mouseReleased(java.awt.event.MouseEvent e)
mouseReleased
in interface java.awt.event.MouseListener
public void mouseDragged(java.awt.event.MouseEvent e)
mouseDragged
in interface java.awt.event.MouseMotionListener
public void mouseMoved(java.awt.event.MouseEvent e)
mouseMoved
in interface java.awt.event.MouseMotionListener
public void mouseClicked()
public void mouseEntered()
public void mouseExited()
public void mousePressed()
public void mouseReleased()
public void mouseDragged()
public void mouseMoved()
public int getMouseX()
public int getMouseY()
public void keyPressed(java.awt.event.KeyEvent e)
keyPressed
in interface java.awt.event.KeyListener
public void keyReleased(java.awt.event.KeyEvent e)
keyReleased
in interface java.awt.event.KeyListener
public void keyTyped(java.awt.event.KeyEvent e)
keyTyped
in interface java.awt.event.KeyListener
public void keyTyped()
public char getKeyTyped()
public void paintComponent(java.awt.Graphics g)
paintComponent
in class javax.swing.JComponent
public void draw()
public void visuallyUpdate()
public void setContextMenu(ContextMenu menu)
setContextMenu
in interface InteractiveArea
menu
- the context menu to attach.public static int round(double d)
d
- the double value to round.
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |