Package paintingcanvas.extensions
Class FrameCounter
- java.lang.Object
-
- paintingcanvas.extensions.FrameCounter
-
- All Implemented Interfaces:
RenderLifecycle
public class FrameCounter extends java.lang.Object implements RenderLifecycle
A system to add a debug overlay showing the FPS, frame count, Element count and frame time graph.// Create and attach a new FrameCounter with default settings new FrameCounter().attach();
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
FrameCounter.GetLine
static interface
FrameCounter.GetLines
-
Nested classes/interfaces inherited from interface paintingcanvas.canvas.RenderLifecycle
RenderLifecycle.AntiAliasingLifecycle, RenderLifecycle.CenteringLifecycle, RenderLifecycle.ResizeListener
-
-
Constructor Summary
Constructors Constructor Description FrameCounter()
Create a new FrameCounter with default settings: Enabled: true FrameChart: true DataPoints: 100 Lines: {}
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
attach()
Adds system to the default static canvas.FrameCounter
dataPoints(int dataPoints)
The number of data points used for the FPS and FrameTime text / FrameTime graph.FrameCounter
enabled(boolean enabled)
Enabled by default.FrameCounter
font(java.awt.Font font)
Sets the font used by the overlay UI.FrameCounter
frameChart(boolean enabled)
Enabled by default.FrameCounter
line(FrameCounter.GetLine line)
The function you supply will be run every frame.FrameCounter
lines(FrameCounter.GetLines lines)
The function you supply will be run every frame.void
renderEnd(java.awt.Graphics g)
Runs after everything else; theimage
inCanvasPanel
will not reflect your changes.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface paintingcanvas.canvas.RenderLifecycle
Modifier and Type Method Description default void
onResize(CanvasPanel canvas, java.awt.event.ComponentEvent e)
default void
postRender(java.awt.Graphics g)
Runs after everything else; theimage
inCanvasPanel
will reflect your changes.default void
preRender(java.awt.Graphics g)
Runs before everything else; theimage
inCanvasPanel
will reflect your changes.default void
renderEnd(java.awt.Graphics g)
Runs after everything else; theimage
inCanvasPanel
will not reflect your changes.default void
renderStart(java.awt.Graphics g)
Runs before everything else; theimage
inCanvasPanel
will not reflect your changes.
-
-
-
-
Method Detail
-
enabled
public FrameCounter enabled(boolean enabled)
Enabled by default.- Parameters:
enabled
- To enable or disable the overlay- Returns:
- `this` for method chaining
-
frameChart
public FrameCounter frameChart(boolean enabled)
Enabled by default.- Parameters:
enabled
- To enable or disable the frame time graph- Returns:
- `this` for method chaining
-
dataPoints
public FrameCounter dataPoints(int dataPoints)
The number of data points used for the FPS and FrameTime text / FrameTime graph. 100 by default.- Parameters:
dataPoints
- The number of data-points to use- Returns:
- `this` for method chaining
-
lines
public FrameCounter lines(FrameCounter.GetLines lines)
The function you supply will be run every frame. Empty by default.- Parameters:
lines
- Function to get extra lines.- Returns:
- `this` for method chaining
-
line
public FrameCounter line(FrameCounter.GetLine line)
The function you supply will be run every frame. Empty by default.- Parameters:
line
- The function to get an extra line- Returns:
- `this` for method chaining
-
font
public FrameCounter font(java.awt.Font font)
Sets the font used by the overlay UI. 12pt Dialog is the default.- Parameters:
font
- The font to use- Returns:
- `this` for method chaining
-
attach
public void attach()
Adds system to the default static canvas.
-
renderEnd
public void renderEnd(java.awt.Graphics g)
Description copied from interface:RenderLifecycle
Runs after everything else; theimage
inCanvasPanel
will not reflect your changes.- Specified by:
renderEnd
in interfaceRenderLifecycle
- Parameters:
g
- The graphics context
-
-