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 interfaceFrameCounter.GetLinestatic interfaceFrameCounter.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 FrameCounterdataPoints(int dataPoints)The number of data points used for the FPS and FrameTime text / FrameTime graph.FrameCounterenabled(boolean enabled)Enabled by default.FrameCounterfont(java.awt.Font font)Sets the font used by the overlay UI.FrameCounterframeChart(boolean enabled)Enabled by default.FrameCounterline(FrameCounter.GetLine line)The function you supply will be run every frame.FrameCounterlines(FrameCounter.GetLines lines)The function you supply will be run every frame.voidrenderEnd(java.awt.Graphics2D g)Runs after everything else; theimageinCanvasPanelwill 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 voidattach()Attach this lifecycle to the canvasdefault voidonResize(CanvasPanel canvas, java.awt.event.ComponentEvent e)default voidpostRender(java.awt.Graphics2D g)Runs after everything else; theimageinCanvasPanelwill reflect your changes.default voidpreRender(java.awt.Graphics2D g)Runs before everything else; theimageinCanvasPanelwill reflect your changes.default voidrenderEnd(java.awt.Graphics2D g)Runs after everything else; theimageinCanvasPanelwill not reflect your changes.default voidrenderStart(java.awt.Graphics2D g)Runs before everything else; theimageinCanvasPanelwill 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. 6pt Dialog is the default.- Parameters:
font- The font to use- Returns:
- `this` for method chaining
-
renderEnd
public void renderEnd(java.awt.Graphics2D g)
Description copied from interface:RenderLifecycleRuns after everything else; theimageinCanvasPanelwill not reflect your changes.- Specified by:
renderEndin interfaceRenderLifecycle- Parameters:
g- The graphics context
-
-