search

Class myphysicslab.lab.graph.EnergyBarGraph

Provided By
All Implemented Interfaces

Displays a bar graph of the various forms of energy (potential, kinetic, etc.) in an myphysicslab.lab.model.EnergySystem. The visible area must be set via #setVisibleArea in order for EnergyBarGraph to draw.

Display Formats

If the myphysicslab.lab.model.EnergyInfo of the EnergySystem only has data for the potential and translational energy, then the names shown are 'potential' and 'kinetic' (in English, the names are translated for the current locale). Here is the display for a typical situation:

 0                2                4                 6                 8
 ---------- potential ----------  *********** kinetic ***********
                                                         total  ^

If the EnergyInfo returns a value other than NaN for the rotational energy, then the the names shown are 'potential', 'translational', and 'rotational'. Here is the display for a typical situation:

 0                2                4                 6                 8
 ----- potential -----  ***** rotational *****  ===== translational ======
                                                                  total  ^

When potential energy is positive, all the energy components are on the same line of the graph, as shown above.

When potential energy is negative, the potential energy is shown on a separate line of the bar graph, extending left from the zero position; the kinetic and rotational energy is drawn underneath the potential energy bar starting from the left. Here is a typical situation:

     -2               0               2                 4
 ----- potential -----
 ******* rotational *******  ===== translational ======
                                                total ^

EnergyBarGraph draws with a transparent white rectangle to ensure it is readable against a black background.

Color and Font

Public properties can be set for changing the color of the bars and the font used. See #graphFont, #potentialColor, #translationColor, and #rotationColor.

Position and Size

The EnergyBarGraph will only draw after the visible area has been set via #setVisibleArea. Usually this is set to be the entire visible area of the myphysicslab.lab.view.LabView containing the EnergyBarGraph.

The width of the EnergyBarGraph is always the full width of the visible area.

The vertical position of the EnergyBarGraph is initially at the top of the visible area. If the EnergyBarGraph is not moved, then whenever the visible area is changed we continue to align the EnergyBarGraph at the top of the visible area.

Once the EnergyBarGraph is moved via #setPosition, we retain that vertical position when the visible area changes, except that we ensure the EnergyBarGraph is entirely within the visible area.

new EnergyBarGraph( system )

Parameters
systemmyphysicslab.lab.model.EnergySystem

the EnergySystem to display

Instance Methods

Instance Properties

Static Properties

Type Definitions