Package view
Class GameFieldRenderer
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
view.GameFieldRenderer
- All Implemented Interfaces:
ImageObserver
,MenuContainer
,Serializable
,Accessible
- Direct Known Subclasses:
GameField
Implements the game's rendering engine.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final ControlPanel
ControlPanel component.protected static JFrame
The parent frame.protected Game
The Game dependency.protected final HamburgerMenu
HamburgerMenu component.protected Map
Reference to a Map instance.protected String
Text field 1 on the HUD.protected static int
The scaling of the game.protected Entity
The selected Entity.protected String
Text field 2 on the HUD.protected final int
The height of the panel.protected final int
The width of the panel.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 java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
-
Constructor Summary
ConstructorsConstructorDescriptionGameFieldRenderer
(Game game, JFrame frame) Constructs a GameFieldRenderer instance. -
Method Summary
Modifier and TypeMethodDescriptionstatic int
Returns the dock's scale.protected void
drawAnimated
(Graphics2D g2d) Draws the animated unitsprotected void
drawAvgHealthBar
(Graphics2D g2d, ArrayList<Entity> entities) Draws the avg health bar of the unitsprotected void
drawBuildingState
(Graphics2D g2d, Entity entity) Draws a building's visible attributesprotected void
Draws the current selectionprotected void
drawEnt
(Graphics2D g2d, int x, int y) Draws the selected Entity.protected void
drawHealthBar
(Graphics2D g2d, Entity entity) Draws the health bar of the unitvoid
drawImage
(Graphics2D g2d, Terrain ter, int x, int y) Draws the textures.void
drawLabels
(Graphics2D g2d) Draws the HUD's labels.protected void
drawPath
(Graphics2D g2d, Soldier soldier) Draws the pathsprotected void
drawTile
(Graphics2D g2d, int x, int y) Draws the selected tile.protected void
drawWayPoints
(Graphics2D g2d) Draws the waypointsstatic int
getScale()
Returns the current scale.protected void
handleType
(Graphics2D g2d, Types type) Defines which color to use when drawing an Entity.protected void
The paintComponent method of the class.protected void
renderField
(Graphics2D g2d) Renders the canvasprotected void
setSelection
(Entity entity) Sets the selection to a new Entity.void
Sets texturesvoid
Toggles the scale.void
Toggles the textures.Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, 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, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, 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, 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, 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
-
Field Details
-
scale
protected static int scaleThe scaling of the game. -
xLength
protected final int xLengthThe height of the panel. -
yLength
protected final int yLengthThe width of the panel. -
controlPanel
ControlPanel component. -
hamburgerMenu
HamburgerMenu component. -
mapRef
Reference to a Map instance. -
selection
The selected Entity. -
frame
The parent frame. -
game
The Game dependency. -
middleText
Text field 1 on the HUD. -
sideText
Text field 2 on the HUD.
-
-
Constructor Details
-
GameFieldRenderer
Constructs a GameFieldRenderer instance.- Parameters:
game
- Game dependency injectionframe
- the parent frame
-
-
Method Details
-
getScale
public static int getScale()Returns the current scale.- Returns:
- the current scale
-
dockScale
public static int dockScale()Returns the dock's scale.- Returns:
- the dock's scale
-
toggleScale
public void toggleScale()Toggles the scale. -
toggleTextures
public void toggleTextures()Toggles the textures. -
renderField
Renders the canvas- Parameters:
g2d
- the graphics we use
-
drawTile
Draws the selected tile.- Parameters:
g2d
- the graphics we usex
- the horizontal coordinatey
- the vertical coordinate
-
drawWayPoints
Draws the waypoints- Parameters:
g2d
- the graphics we use
-
drawEnt
Draws the selected Entity.- Parameters:
g2d
- the graphics we usex
- the horizontal coordinatey
- the vertical coordinate
-
paintComponent
The paintComponent method of the class.- Overrides:
paintComponent
in classJComponent
- Parameters:
g
- graphics we use
-
drawHealthBar
Draws the health bar of the unit- Parameters:
g2d
- the graphics we useentity
- the unit we want to draw the health bar of
-
drawAvgHealthBar
Draws the avg health bar of the units- Parameters:
g2d
- the graphics we useentities
- the units we want to draw the avg health bar of
-
drawPath
Draws the paths- Parameters:
g2d
- the graphics we usesoldier
- the path we want to draw
-
drawAnimated
Draws the animated units- Parameters:
g2d
- the graphics we use
-
drawBuildingState
Draws a building's visible attributes- Parameters:
g2d
- the graphics we useentity
- the building to draw to
-
drawCurrentSelection
Draws the current selection- Parameters:
g2d
- the graphics we use
-
drawLabels
Draws the HUD's labels.- Parameters:
g2d
- the graphics we use
-
setSelection
Sets the selection to a new Entity.- Parameters:
entity
- the entity to set to
-
handleType
Defines which color to use when drawing an Entity.- Parameters:
g2d
- the graphics we usetype
- the type to handle
-
setTextures
public void setTextures()Sets textures -
drawImage
Draws the textures.- Parameters:
g2d
- the graphics we useter
- the terrain to drawx
- the x coordinatey
- the y coordinate
-