|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JLabel
rushhour.RushHourVehicle
public class RushHourVehicle
A vehicle must be either a car or a truck. It can be placed on the game board and its (vehicleX, vehicleY) coordinates can be shifted depending on its horizontal or vertical orientation. Vehicles contain a unique ID, which represents the order in which they were added to the game board, and a unique hash ID, which combines their unique ID with their (vehicleX, vehicleY) coordinate index on the game board.
Vehicles can also be distinguished by their color. Two vehicles should not have the same color, but the vehicle object does no assurance checking to make sure a vehicle of the specified color does not already exist.
Cars have a vehicleLength of two (2) and trucks have a vehicleLength of three (3). All vehicles have a vehicleWidth of one (1).
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class javax.swing.JLabel |
|---|
javax.swing.JLabel.AccessibleJLabel |
| 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.JLabel |
|---|
labelFor |
| 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 javax.swing.SwingConstants |
|---|
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST |
| Fields inherited from interface java.awt.image.ImageObserver |
|---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
| Constructor Summary | |
|---|---|
RushHourVehicle(RushHourGameBoard gameBoard,
int uniqueID,
java.lang.String type,
java.lang.String color,
java.lang.String orientation,
int x,
int y)
Construct a vehicle that can be placed on the game board. |
|
| Method Summary | |
|---|---|
java.lang.String |
getColor()
Retrieve the color of the vehicle. |
java.lang.String |
getHashID()
Retrieve the hash ID for the vehicle. |
java.lang.String |
getOrientation()
Retrieve the orientation of the vehicle. |
java.lang.String |
getType()
Retrieve the type of the vehicle. |
int |
getUniqueID()
Retrieve the unique ID of the vehicle. |
int |
getVehicleIconLength()
Retrieve the vehicle icon length. |
int |
getVehicleIconWidth()
Retrieve the vehicle icon boardWidth. |
int |
getVehicleLength()
Retrieve the length of the vehicle. |
int |
getVehicleWidth()
Retrieve the boardWidth of the vehicle. |
int |
getVehicleX()
Retrieve the x-coordinate of the vehicle. |
int |
getVehicleY()
Retrieve the y-coordinate of the vehicle. |
void |
paintComponent(java.awt.Graphics g)
The paintComponent() method is overriden to encroprate alpha (composite) manipulation to the 2D graphics. |
void |
resetIconImage()
Reset the icon image to the default image for this vehicle. |
void |
setComposite(float composite)
Set the alpha (composite) of the vehicle. |
void |
setUniqueID(int uniqueID)
Set the unique ID of the vehicle to a new unique ID. |
void |
setVehicleX(int x)
Set the new vehicleX-coordinate of the vehicle. |
void |
setVehicleY(int y)
Set the new y-coordinate of the vehicle. |
java.lang.String |
toString()
A string representation of the vehicle, which is the uniqe identification number. |
| Methods inherited from class javax.swing.JLabel |
|---|
checkHorizontalKey, checkVerticalKey, getAccessibleContext, getDisabledIcon, getDisplayedMnemonic, getDisplayedMnemonicIndex, getHorizontalAlignment, getHorizontalTextPosition, getIcon, getIconTextGap, getLabelFor, getText, getUI, getUIClassID, getVerticalAlignment, getVerticalTextPosition, imageUpdate, paramString, setDisabledIcon, setDisplayedMnemonic, setDisplayedMnemonic, setDisplayedMnemonicIndex, setHorizontalAlignment, setHorizontalTextPosition, setIcon, setIconTextGap, setLabelFor, setText, setUI, setVerticalAlignment, setVerticalTextPosition, updateUI |
| Methods inherited from class javax.swing.JComponent |
|---|
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, 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, 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, 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, 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, transferFocus, transferFocusUpCycle |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public RushHourVehicle(RushHourGameBoard gameBoard,
int uniqueID,
java.lang.String type,
java.lang.String color,
java.lang.String orientation,
int x,
int y)
throws InvalidVehicleColorException,
InvalidVehicleException,
RedCarException,
OffGameBoardException,
VehicleOverlapException
gameBoard - The game board object. If a null game board object is
passed, the object will not be aligned on the GUI, nor will the icon
image be assigned.uniqueID - The unique number that represents this car on the board
(represents the sequence in which the vehicle was added to the board.)type - The type of the new vehicle.color - The color of the new vehicle.orientation - The orientation of the new vehicle.x - The x-coordinate of the new vehicle.y - The y-coordinate of the new vehicle.
InvalidVehicleColorException - The specified vehicle color is
either null or already exists on another vehicle on the game board.
InvalidVehicleException - The vehicle was placed improperly.
OffGameBoardException - The specified coordinates are off the game
board.
RedCarException - The red car must be in the third row so it can
exit.
VehicleOverlapException - The vehicle is placed at coordinates
that cause it to overlap an already existing vehicle.| Method Detail |
|---|
public void setComposite(float composite)
composite - The new composite.public void paintComponent(java.awt.Graphics g)
paintComponent in class javax.swing.JComponentg - The graphics of the vehicle.public void resetIconImage()
public java.lang.String getHashID()
public int getUniqueID()
public void setUniqueID(int uniqueID)
uniqueID - The new unique ID.public java.lang.String getType()
public java.lang.String getColor()
public java.lang.String getOrientation()
public int getVehicleX()
public void setVehicleX(int x)
throws OffGameBoardException
x - The new vehicleX-coordinate of the vehicle.
OffGameBoardException - The specified coordinates are off the game
board.public int getVehicleY()
public void setVehicleY(int y)
throws OffGameBoardException
y - The new y-coordinate of the vehicle.
OffGameBoardException - The specified coordinates are off the game
board.public int getVehicleLength()
public int getVehicleIconLength()
public int getVehicleWidth()
public int getVehicleIconWidth()
public java.lang.String toString()
toString in class java.awt.Component
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||