Class RenderComponent
java.lang.Object
java.awt.Component
java.awt.Canvas
de.gurkenlabs.litiengine.graphics.RenderComponent
- All Implemented Interfaces:
ImageObserver,MenuContainer,Serializable,Accessible
The
RenderComponent class extends Canvas and handles the rendering of the game screen, including managing fade effects, capturing
screenshots, and rendering the game cursor.- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.awt.Canvas
Canvas.AccessibleAWTCanvasNested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ColorThe default background color for the rendering component.static final FontThe default font for rendering text in the component.Fields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH -
Constructor Summary
ConstructorsConstructorDescriptionRenderComponent(Dimension size) Constructs a newRenderComponentwith the specified size. -
Method Summary
Modifier and TypeMethodDescriptionvoidfadeIn(int ms) Initiates a fade-in effect over the specified duration.voidfadeOut(int ms) Initiates a fade-out effect over the specified duration.voidinit()Initializes theRenderComponent, setting up the buffer strategy for rendering.voidonFpsChanged(IntConsumer fpsConsumer) Registers a consumer to be notified when the frames per second (FPS) change.voidonRendered(Consumer<Graphics2D> renderedConsumer) Registers a consumer to be notified after the component has been rendered.voidrender()Renders the game screen, including handling fade effects, cursor rendering, and screenshot capture.voidSignals theRenderComponentto take a screenshot on the next render cycle.Methods inherited from class java.awt.Canvas
addNotify, createBufferStrategy, createBufferStrategy, getAccessibleContext, getBufferStrategy, paint, updateMethods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, revalidate, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setMixingCutoutShape, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, validate
-
Field Details
-
DEFAULT_BACKGROUND_COLOR
The default background color for the rendering component. -
DEFAULT_FONT
The default font for rendering text in the component.
-
-
Constructor Details
-
RenderComponent
Constructs a newRenderComponentwith the specified size.- Parameters:
size- The size of the rendering component.
-
-
Method Details
-
fadeIn
public void fadeIn(int ms) Initiates a fade-in effect over the specified duration.- Parameters:
ms- The duration of the fade-in effect in milliseconds.
-
fadeOut
public void fadeOut(int ms) Initiates a fade-out effect over the specified duration.- Parameters:
ms- The duration of the fade-out effect in milliseconds.
-
init
public void init()Initializes theRenderComponent, setting up the buffer strategy for rendering. -
onFpsChanged
Registers a consumer to be notified when the frames per second (FPS) change.- Parameters:
fpsConsumer- The consumer to notify of FPS changes.
-
onRendered
Registers a consumer to be notified after the component has been rendered.- Parameters:
renderedConsumer- The consumer to notify after rendering.
-
render
public void render()Renders the game screen, including handling fade effects, cursor rendering, and screenshot capture. -
takeScreenshot
public void takeScreenshot()Signals theRenderComponentto take a screenshot on the next render cycle.
-