Package cl.cromer.azaraka
Class Cell
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- cl.cromer.azaraka.Cell
-
- All Implemented Interfaces:
Constants
,java.awt.image.ImageObserver
,java.awt.MenuContainer
,java.io.Serializable
public class Cell extends javax.swing.JComponent implements Constants
This class is a cell that will contain a game element such as a player, enemy, prize, etc- See Also:
- Serialized Form
-
-
Nested Class Summary
-
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
-
Nested classes/interfaces inherited from interface cl.cromer.azaraka.Constants
Constants.AIHeuristic, Constants.LogLevel, Constants.PlayerAIType
-
-
Field Summary
-
Fields inherited from class javax.swing.JComponent
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
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
-
Fields inherited from interface cl.cromer.azaraka.Constants
AI_HEURISTIC, APPEND_LOGS, CELL_PIXELS, CHESTS, ENEMIES, ENEMY_AI, EXPORT_SCENE, FONT, FONT_SIZE, GENERATE_SCENE, GLOBAL_LOG, HORIZONTAL_CELLS, LOG_TO_FILE, OBSTACLES, PLAYER_AI, PRETTY_JSON, TITLE, VERTICAL_CELLS, VOLUME
-
-
Constructor Summary
Constructors Constructor Description Cell(int xPixels, int yPixels, int x, int y)
Initialize the cell with its coordinates
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addTexture(java.awt.image.BufferedImage texture, int textureNumber)
Add a texture to the texture listboolean
containsObject()
Check if cell contains an objectObject
getObject()
Get the object that is in the cellObject
getObjectOnBottom()
Get a bottom objectObject
getObjectOnTop()
Get a top objectjava.util.ArrayList<java.lang.Integer>
getTextureNumbers()
Get an array list of the texture numbers usedint
getX()
Get the x coordinate of the cellint
getY()
Get the y coordinate for the cellvoid
paintComponent(java.awt.Graphics g)
Override the paintComponent method of JComponent to paint the cell based on typevoid
removeTexture(int texture)
Remove the texture from the mapvoid
setObject(Object object)
Put an object in the cellvoid
setObjectOnBottom(Object object)
Set a bottom objectvoid
setObjectOnTop(Object object)
Set a top objectvoid
update(java.awt.Graphics g)
Override the update method of JComponent to do double buffering-
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, getUI, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, 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
-
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, 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, 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, getPropertyChangeListeners, getPropertyChangeListeners, getSize, 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, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface cl.cromer.azaraka.Constants
getLogger, initializeLogger, random
-
-
-
-
Method Detail
-
getObject
public Object getObject()
Get the object that is in the cell- Returns:
- Returns the object
-
setObject
public void setObject(Object object)
Put an object in the cell- Parameters:
object
- The new object
-
getObjectOnTop
public Object getObjectOnTop()
Get a top object- Returns:
- Returns the top object
-
setObjectOnTop
public void setObjectOnTop(Object object)
Set a top object- Parameters:
object
- The top object
-
getObjectOnBottom
public Object getObjectOnBottom()
Get a bottom object- Returns:
- Returns the bottom object
-
setObjectOnBottom
public void setObjectOnBottom(Object object)
Set a bottom object- Parameters:
object
- The object
-
containsObject
public boolean containsObject()
Check if cell contains an object- Returns:
- Returns true if it contains an object or false otherwise
-
getX
public int getX()
Get the x coordinate of the cell- Overrides:
getX
in classjavax.swing.JComponent
- Returns:
- Returns the x coordinate
-
getY
public int getY()
Get the y coordinate for the cell- Overrides:
getY
in classjavax.swing.JComponent
- Returns:
- Returns the y coordinate
-
addTexture
public void addTexture(java.awt.image.BufferedImage texture, int textureNumber)
Add a texture to the texture list- Parameters:
texture
- The new texturetextureNumber
- The texture's number
-
removeTexture
public void removeTexture(int texture)
Remove the texture from the map- Parameters:
texture
- The texture to remove
-
getTextureNumbers
public java.util.ArrayList<java.lang.Integer> getTextureNumbers()
Get an array list of the texture numbers used- Returns:
- Returns an array list of texture numbers
-
paintComponent
public void paintComponent(java.awt.Graphics g)
Override the paintComponent method of JComponent to paint the cell based on type- Overrides:
paintComponent
in classjavax.swing.JComponent
- Parameters:
g
- The graphics object to paint
-
update
public void update(java.awt.Graphics g)
Override the update method of JComponent to do double buffering- Overrides:
update
in classjavax.swing.JComponent
- Parameters:
g
- The graphics object to paint
-
-