public class JPassiveRenderer extends java.lang.Object implements JRenderer
JRendererPanel
.
To use this renderer a client constructs a JRendererPanel
and passes
it to the constructor with a JRendererTarget
implementation and a
timing source. A typical sequence would be
JFrame frame = new JFrame("Renderer Demonstration"); final JRendererPanel on = new JRendererPanel(); frame.setContentPane(on); final JRendererTarget<GraphicsConfiguration, Graphics2D> target = this; final TimingSource timingSource = new SwingTimerTimingSource(); JRenderer renderer = new JPassiveRenderer(on, target, timingSource); timingSource.init();In the above snippet on will be rendered to. The enclosing instance, this, implements
JRendererTarget
and will be called to
customize what is displayed on-screen.Constructor and Description |
---|
JPassiveRenderer(JRendererPanel on,
JRendererTarget<java.awt.GraphicsConfiguration,java.awt.Graphics2D> target,
TimingSource timingSource) |
Modifier and Type | Method and Description |
---|---|
long |
getAverageCycleTimeNanos()
Calculates the total average time for each rendering cycle.
|
long |
getFPS()
Calculates the frames per second being drawn to the screen.
|
TimingSource |
getTimingSource()
Gets the timing source being used by the renderer.
|
void |
invokeLater(java.lang.Runnable task)
Submits a task to be run by the renderer in the same thread context that
its
JRendererTarget uses. |
void |
shutdown()
Shuts down rendering.
|
public JPassiveRenderer(JRendererPanel on, JRendererTarget<java.awt.GraphicsConfiguration,java.awt.Graphics2D> target, TimingSource timingSource)
public void invokeLater(java.lang.Runnable task)
JRenderer
JRendererTarget
uses.
Safe to be called at any time within any thread.
invokeLater
in interface JRenderer
task
- a task for the renderer.public TimingSource getTimingSource()
JRenderer
getTimingSource
in interface JRenderer
public long getFPS()
JRenderer
Safe to be called at any time within any thread.
public long getAverageCycleTimeNanos()
JRenderer
Safe to be called at any time within any thread.
getAverageCycleTimeNanos
in interface JRenderer