Class MainDisplay

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JPanel
                          |
                          +--MainDisplay
Direct Known Subclasses:
EditorDisplay

public class MainDisplay
extends JPanel

This class is the panel on which the action part of the game is rendered. At
each tick, this panel is repainted with the contents of the screen that is in
the location for the local player as returned by GameSetup.getLocalPlayer.
This uses the scrolling, scaling, and optimize options specified by GameSetup.
The only method that should really be used from the outside is getClickLocation.
You could also call setForceDraw, but that can also be achieved by turning the
draw optimization off for one tick in the GameSetup.


Field Summary
 protected ScreenlastScreen
           
 protected intsizex
           
 protected intsizey
           

Fields inherited from class javax.swing.JComponent
ui, listenerList, WHEN_FOCUSED, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_IN_FOCUSED_WINDOW, UNDEFINED_CONDITION, TOOL_TIP_TEXT_KEY, accessibleContext

Fields inherited from class java.awt.Component
TOP_ALIGNMENT, CENTER_ALIGNMENT, BOTTOM_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT

Constructor Summary
MainDisplay(MainFrame mf)
          This mainly figures out what size this panel should "prefer" to be.

Method Summary
 voiddraw(Player player)
          Draw the display assuming the player passed in.
 LocationgetClickLocation(int x, int y)
          This function does a conversion from display coordinates to the locations
coordinates in the screen that it is displaying.
 intgetDrawX(Location loc)
          This function tells you the physical display x for a given location on
the screen.
 intgetDrawY(Location loc)
          This function tells you the physical display y for a given location on
the screen.
 DimensiongetPreferredSize()
          Returns the size that this display would be without any scaling for the
drawing options it was first set up to use.
 voidpaintComponent(Graphics g)
          Renders the image drawn by the draw method to the provided Graphics object.
 voidsetForceDraw()
          Tell the display that at the next draw call (typically the next tick) that
it must redraw all of the blocks for the background and can't use a
buffered image.

Methods inherited from class javax.swing.JPanel
updateUI, getUIClassID, paramString, getAccessibleContext

Methods inherited from class javax.swing.JComponent
setUI, getComponentGraphics, paintChildren, paintBorder, update, paint, printAll, print, printComponent, printChildren, printBorder, isPaintingTile, isFocusCycleRoot, isManagingFocus, setNextFocusableComponent, getNextFocusableComponent, setRequestFocusEnabled, isRequestFocusEnabled, requestFocus, grabFocus, setVerifyInputWhenFocusTarget, getVerifyInputWhenFocusTarget, setPreferredSize, setMaximumSize, getMaximumSize, setMinimumSize, getMinimumSize, isMinimumSizeSet, isPreferredSizeSet, isMaximumSizeSet, contains, setBorder, getBorder, getInsets, getInsets, getAlignmentY, setAlignmentY, getAlignmentX, setAlignmentX, setInputVerifier, getInputVerifier, getGraphics, setDebugGraphicsOptions, getDebugGraphicsOptions, registerKeyboardAction, registerKeyboardAction, unregisterKeyboardAction, getRegisteredKeyStrokes, getConditionForKeyStroke, getActionForKeyStroke, resetKeyboardActions, setInputMap, getInputMap, getInputMap, setActionMap, getActionMap, requestDefaultFocus, setVisible, hide, setEnabled, setForeground, setBackground, setFont, isFocusTraversable, processFocusEvent, processComponentKeyEvent, processKeyEvent, processKeyBinding, setToolTipText, getToolTipText, getToolTipText, getToolTipLocation, createToolTip, scrollRectToVisible, setAutoscrolls, getAutoscrolls, processMouseMotionEvent, enable, disable, getClientProperty, putClientProperty, isLightweightComponent, reshape, getBounds, getSize, getLocation, getX, getY, getWidth, getHeight, hasFocus, isOpaque, setOpaque, computeVisibleRect, getVisibleRect, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, addPropertyChangeListener, addPropertyChangeListener, removePropertyChangeListener, removePropertyChangeListener, fireVetoableChange, addVetoableChangeListener, removeVetoableChangeListener, getTopLevelAncestor, addAncestorListener, removeAncestorListener, getListeners, addNotify, removeNotify, repaint, repaint, revalidate, isValidateRoot, isOptimizedDrawingEnabled, paintImmediately, paintImmediately, setDoubleBuffered, isDoubleBuffered, getRootPane

Methods inherited from class java.awt.Container
getComponentCount, countComponents, getComponent, getComponents, insets, add, add, add, add, add, addImpl, remove, remove, removeAll, getLayout, setLayout, doLayout, layout, invalidate, validate, validateTree, preferredSize, minimumSize, paintComponents, printComponents, addContainerListener, removeContainerListener, processEvent, processContainerEvent, deliverEvent, getComponentAt, locate, getComponentAt, findComponentAt, findComponentAt, isAncestorOf, list, list

Methods inherited from class java.awt.Component
getName, setName, getParent, getPeer, setDropTarget, getDropTarget, getGraphicsConfiguration, getTreeLock, getToolkit, isValid, isDisplayable, isVisible, isShowing, isEnabled, enable, enableInputMethods, show, show, getForeground, getBackground, getFont, getLocale, setLocale, getColorModel, getLocation, getLocationOnScreen, location, setLocation, move, setLocation, getSize, size, setSize, resize, setSize, resize, getBounds, bounds, setBounds, setBounds, isLightweight, getFontMetrics, setCursor, getCursor, paintAll, repaint, repaint, repaint, imageUpdate, createImage, createImage, prepareImage, prepareImage, checkImage, checkImage, inside, contains, dispatchEvent, postEvent, addComponentListener, removeComponentListener, addFocusListener, removeFocusListener, addHierarchyListener, removeHierarchyListener, addHierarchyBoundsListener, removeHierarchyBoundsListener, addKeyListener, removeKeyListener, addMouseListener, removeMouseListener, addMouseMotionListener, removeMouseMotionListener, addInputMethodListener, removeInputMethodListener, getInputMethodRequests, getInputContext, enableEvents, disableEvents, coalesceEvents, processComponentEvent, processMouseEvent, processInputMethodEvent, processHierarchyEvent, processHierarchyBoundsEvent, handleEvent, mouseDown, mouseDrag, mouseUp, mouseMove, mouseEnter, mouseExit, keyDown, keyUp, action, gotFocus, lostFocus, transferFocus, nextFocus, add, remove, toString, list, list, list, setComponentOrientation, getComponentOrientation

Methods inherited from class java.lang.Object
getClass, hashCode, equals, clone, notify, notifyAll, wait, wait, wait, finalize

Field Detail

lastScreen

protected Screen lastScreen

sizex

protected int sizex

sizey

protected int sizey
Constructor Detail

MainDisplay

public MainDisplay(MainFrame mf)
This mainly figures out what size this panel should "prefer" to be.
Method Detail

draw

public void draw(Player player)
Draw the display assuming the player passed in.
Parameters:
player This is the player whose location is used for the drawing.

getClickLocation

public Location getClickLocation(int x, int y)
This function does a conversion from display coordinates to the locations
coordinates in the screen that it is displaying. When you get a MouseEvent
you can pass the getX() and getY() values from it into this and it will
return the Location of the click.
Parameters:
x The physical display x location.
y The physical display y location.
Returns: The location that corresponds to the physical location that was passed in.

getDrawX

public int getDrawX(Location loc)
This function tells you the physical display x for a given location on
the screen. This is used for drawing and shouldn't need to be called from
external code.
Parameters:
loc The Location you are interested in.
Returns: The x physical display position for that location.

getDrawY

public int getDrawY(Location loc)
This function tells you the physical display y for a given location on
the screen. This is used for drawing and shouldn't need to be called from
external code.
Parameters:
loc The Location you are interested in.
Returns: The y physical display position for that location.

getPreferredSize

public Dimension getPreferredSize()
Returns the size that this display would be without any scaling for the
drawing options it was first set up to use. This is used by the GUI.
Returns: The size that this "wants" to be so there isn't scaling.

paintComponent

public void paintComponent(Graphics g)
Renders the image drawn by the draw method to the provided Graphics object.
This is automatically called by the GUI framework and should generally
not be called by user code.
Parameters:
g The graphics object to render to.

setForceDraw

public void setForceDraw()
Tell the display that at the next draw call (typically the next tick) that
it must redraw all of the blocks for the background and can't use a
buffered image.

Association Links

to Class java.awt.image.BufferedImage

to Class java.awt.image.BufferedImage

to Class Screen

to Class java.awt.Dimension

to Class MainFrame