Class RenderComponent
java.lang.Object
java.awt.Component
java.awt.Canvas
de.gurkenlabs.litiengine.graphics.RenderComponent
- All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible
-
Nested Class Summary
Nested classes/interfaces inherited from class Canvas
Canvas.AccessibleAWTCanvasNested classes/interfaces inherited from class 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 Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH -
Constructor Summary
ConstructorsConstructorDescriptionRenderComponent(Dimension size) Constructs a newRenderComponentwith the specified size. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidConfigures the Java2D rendering pipeline system properties from the current game configuration.voidfadeIn(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.voidremoveRenderedConsumer(Consumer<Graphics2D> renderedConsumer) Unregisters a consumer from being 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 Canvas
addNotify, createBufferStrategy, createBufferStrategy, getAccessibleContext, getBufferStrategy, paint, updateMethods inherited from class 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. -
configurePipeline
public static void configurePipeline()Configures the Java2D rendering pipeline system properties from the current game configuration. This must be called before anyGraphics2Dcontext is created (i.e. before the firstBufferedImage,Canvas.createGraphics(), orcreateBufferStrategy()call), because the pipeline is locked in once the first graphics context is initialized.- See Also:
-
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.
-
removeRenderedConsumer
Unregisters a consumer from being notified after the component has been rendered.- Parameters:
renderedConsumer- The consumer to remove.
-
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.
-