Class 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
    • 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 list
      boolean containsObject()
      Check if cell contains an object
      Object getObject()
      Get the object that is in the cell
      Object getObjectOnBottom()
      Get a bottom object
      Object getObjectOnTop()
      Get a top object
      java.util.ArrayList<java.lang.Integer> getTextureNumbers()
      Get an array list of the texture numbers used
      int getX()
      Get the x coordinate of the cell
      int getY()
      Get the y coordinate for the cell
      void paintComponent​(java.awt.Graphics g)
      Override the paintComponent method of JComponent to paint the cell based on type
      void removeTexture​(int texture)
      Remove the texture from the map
      void setObject​(Object object)
      Put an object in the cell
      void setObjectOnBottom​(Object object)
      Set a bottom object
      void setObjectOnTop​(Object object)
      Set a top object
      void 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
    • Constructor Detail

      • Cell

        public Cell​(int xPixels,
                    int yPixels,
                    int x,
                    int y)
        Initialize the cell with its coordinates
        Parameters:
        xPixels - The x graphical coordinate
        yPixels - The y graphical coordinate
        x - The x coordinate of the cell
        y - The y coordinate of the cell
    • 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 class javax.swing.JComponent
        Returns:
        Returns the x coordinate
      • getY

        public int getY()
        Get the y coordinate for the cell
        Overrides:
        getY in class javax.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 texture
        textureNumber - 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 class javax.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 class javax.swing.JComponent
        Parameters:
        g - The graphics object to paint