net.ctdp.rfdynhud.widgets.base.revneedlemeter
Class AbstractRevNeedleMeterWidget

java.lang.Object
  extended by net.ctdp.rfdynhud.widgets.base.widget.Widget
      extended by net.ctdp.rfdynhud.widgets.base.needlemeter.NeedleMeterWidget
          extended by net.ctdp.rfdynhud.widgets.base.revneedlemeter.AbstractRevNeedleMeterWidget
All Implemented Interfaces:
java.lang.Cloneable, PropertiesKeeper

public abstract class AbstractRevNeedleMeterWidget
extends NeedleMeterWidget

The AbstractRevNeedleMeterWidget displays rev/RPM information.

Author:
Marvin Froehlich (CTDP)

Field Summary
static java.lang.String DEFAULT_GEAR_FONT_NAME
           
protected  BooleanProperty displayGear
           
protected  ImageProperty gearBackgroundImageName
           
protected  FontProperty gearFont
           
protected  ColorProperty gearFontColor
           
protected  IntProperty gearPosX
           
protected  IntProperty gearPosY
           
static int PEAK_NEEDLE_LOCAL_Z_INDEX
           
protected  DelayProperty peakNeedleCooldown
           
protected  DelayProperty peakNeedleDownshiftIgnoreTime
           
protected  ImageProperty peakNeedleImageName
           
protected  IntProperty peakNeedlePivotBottomOffset
           
protected  DelayProperty peakNeedleWaitTime
           
protected  BooleanProperty useMaxRevLimit
           
 
Fields inherited from class net.ctdp.rfdynhud.widgets.base.needlemeter.NeedleMeterWidget
displayMarkerNumbers, displayMarkers, displayValue, firstMarkerNumberOffset, lastMarkerBig, lastMarkerNumberOffset, markerNumbersCentered, markerNumbersInside, markersBigStep, markersColor, markersFont, markersFontColor, markersFontDropShadowColor, markersInnerRadius, markersLength, markersOnCircle, markersSmallStep, maxValue, MIN_MAX_VALUE_NONE, minValue, NEEDLE_LOCAL_Z_INDEX, needleMountX, needleMountY, needlePivotBottomOffset, needleRotationForMaxValue, needleRotationForMinValue, valueBackgroundImageName, valueFont, valueFontColor, valuePosX, valuePosY
 
Fields inherited from class net.ctdp.rfdynhud.widgets.base.widget.Widget
LOG_CHANNEL, NEEDED_DATA_ALL, NEEDED_DATA_SCORING, NEEDED_DATA_TELEMETRY
 
Constructor Summary
AbstractRevNeedleMeterWidget(WidgetSet widgetSet, WidgetPackage widgetPackage, float width, float height)
           
 
Method Summary
protected  void addMaxValuePropertyToContainer(PropertiesContainer propsCont, boolean forceAll)
          Adds the maxValue property to the container.
protected  void addVisibilityPropertiesToContainer(PropertiesContainer propsCont, boolean forceAll)
          Adds the visibility properties to the PropertiesContainer.
protected  boolean checkForChanges(LiveGameData gameData, boolean isEditorMode, TextureImage2D texture, int width, int height)
          Checks, if the Widget needs any changes before it is drawn.
protected  boolean doRenderNeedle(LiveGameData gameData, boolean isEditorMode)
          Live-checks, whether the needle is to be rendered or not.
protected  void drawWidget(Clock clock, boolean needsCompleteRedraw, LiveGameData gameData, boolean isEditorMode, TextureImage2D texture, int offsetX, int offsetY, int width, int height)
          This method must contain the actual drawing code for this Widget.
 java.lang.String getDefaultNamedFontValue(java.lang.String name)
          Gets the default value for the given named font.
protected  java.lang.String getDigiValuePropertiesGroupName()
          Gets the display name of the properties group for the digital value in the editor.
protected  void getGearProperties(PropertiesContainer propsCont, boolean forceAll)
          Collects the properties for the gear.
protected  java.lang.String getInitialPeakNeedleImage()
           
protected  java.lang.String getMarkerLabelForValue(LiveGameData gameData, boolean isEditorMode, float value)
          Gets the text label for the big markers at the given value.
protected  int getMarkersBigStepLowerLimit()
           
protected  void getMarkersProperties(PropertiesContainer propsCont, boolean forceAll)
          Collects the properties for the markers.
protected  int getMarkersSmallStepLowerLimit()
           
protected  float getMaxDataValue(LiveGameData gameData, boolean isEditorMode)
          Gets the maximum value for the markers and needle coming from game data or known limits.
protected  float getMinDataValue(LiveGameData gameData, boolean isEditorModes)
          Gets the minimum value for the markers and needle coming from game data or known limits.
 int getNeededData()
          Gets the data indicators for the data needed for this Widget to be drawn (bitmask).
protected  void getNeedleProperties(PropertiesContainer propsCont, boolean forceAll)
          Collects the properties for the needle.
 java.lang.String getPeakNeedleImageName()
           
 void getProperties(PropertiesContainer propsCont, boolean forceAll)
          Puts all editable properties to the editor.
protected  float getValue(LiveGameData gameData, boolean isEditorMode)
          Gets the value for the needle and the digital value display.
protected  int getValueForValueDisplay(LiveGameData gameData, boolean isEditorMode)
          Gets the value for the digital value display.
protected  void initialize(LiveGameData gameData, boolean isEditorMode, DrawnStringFactory dsf, TextureImage2D texture, int width, int height)
          This method is called once to initialized DrawnStrings used on this Widget.
protected  void initParentProperties()
          This method is called as the last item in the constructor.
protected  void initSubTextures(LiveGameData gameData, boolean isEditorMode, int widgetInnerWidth, int widgetInnerHeight, SubTextureCollector collector)
          Gets the TransformableTextures, that this Widget keeps.
 void loadProperty(PropertyLoader loader)
          Loads (and parses) a certain property from a config file.
protected  void onBackgroundChanged(boolean imageChanged, float deltaScaleX, float deltaScaleY)
          This method is invoked when the background has changed.
 void onNeededDataComplete(LiveGameData gameData, boolean isEditorMode)
          This method is called when the needed data is available in realtime mode.
 void onRealtimeEntered(LiveGameData gameData, boolean isEditorMode)
          This method is called when a the user entered realtime mode.
protected  java.lang.Boolean onVehicleControlChanged(VehicleScoringInfo viewedVSI, LiveGameData gameData, boolean isEditorMode)
          This method is called when either the player's vehicle control has changed or another vehicle is being viewed.
 void prepareForMenuItem()
          This method is called by the editor before it draws the Widget to a menu item.
protected  void saveGearProperties(PropertyWriter writer)
           
protected  void saveMarkersProperties(PropertyWriter writer)
           
protected  void saveNeedleProperties(PropertyWriter writer)
           
 void saveProperties(PropertyWriter writer)
          Saves all settings to the config file.
 void setPeakNeedleImageName(java.lang.String image)
           
 
Methods inherited from class net.ctdp.rfdynhud.widgets.base.needlemeter.NeedleMeterWidget
addMinValuePropertyToContainer, drawBackground, drawMarkers, getDigiValueProperties, getDisplayMarkerNumbers, getDisplayMarkers, getDisplayValue, getInitialBackground, getInitialNeedleImage, getMarkerColorForValue, getMarkerNumberColorForValue, getMarkerNumbersInside, getMarkersInnerRadius, getMarkersLength, getMarkersOnCircle, getMaxValue, getMinValue, getNeedleImage, getNeedleMayExceedMaximum, getNeedleMayExceedMinimum, getNeedleMountX, getNeedleMountY, getNeedlePivotBottomOffset, getNeedleRotationForMaxValue, getNeedleRotationForMinValue, getNeedleTexture, getSpecificPropertiesFirst, getValueBackgroundImage, getValueFont, getValueFontColor, getValuePosX, getValuePosY, onNeedleImageNameChanged, onPropertyChanged, onVehicleSetupUpdated, prepareMarkersBackground, saveDigiValueProperties, setDisplayValue
 
Methods inherited from class net.ctdp.rfdynhud.widgets.base.widget.Widget
addBackgroundPropertyToContainer, addBorderPropertyToContainer, addFontPropertiesToContainer, addPaddingPropertiesToContainer, addPositionAndSizePropertiesToContainer, addTypeAndNamePropertiesToContainer, afterConfigurationLoaded, bake, beforeConfigurationCleared, canHaveBackground, canHaveBorder, clearBackgroundRegion, clearRegion, clearRegion, clone, cloneProperty, debug, debugCS, drawBorder, drawWidget, forceAndSetDirty, forceCompleteRedraw, forceReinitialization, getAbsoluteOffsetX, getAbsoluteOffsetY, getAutoVisibility, getBackground, getBackgroundProperty, getBorder, getBorderProperty, getConfiguration, getDefaultBorderValue, getDefaultNamedColorValue, getDirtyFlag, getDocumentationSource, getDrawnStringFactory, getEffectiveHeight, getEffectiveWidth, getFont, getFontColor, getFontColorProperty, getFontProperty, getInnerSize, getInputActions, getInputVisibility, getMasterWidget, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getName, getNewInstanceForClone, getOffsetXToRootMasterWidget, getOffsetYToRootMasterWidget, getPaddingBottom, getPaddingLeft, getPaddingPropertyBottom, getPaddingPropertyLeft, getPaddingPropertyRight, getPaddingPropertyTop, getPaddingRight, getPaddingTop, getPosition, getPropertiesForParentGroup, getPropertiesIterator, getSize, getSubTextures, getUpdatedVisibility, getWidgetController, getWidgetPackage, getWidgetSet, getZIndex, hasBorder, hasFixedSize, hasMasterCanvas, hasText, isFontAntiAliased, isVisible, log, log, logCS, logCS, onBoundInputStateChanged, onCanvasSizeChanged, onCompleteRedrawForced, onDirtyFlagSet, onGarageEntered, onGarageExited, onLapStarted, onPitsEntered, onPitsExited, onPositionChanged, onRealtimeExited, onReinitializationForced, onScoringInfoUpdated, onSessionStarted, onSizeChanged, onTrackChanged, onVisibilityChanged, setAllPosAndSizeToPercents, setAllPosAndSizeToPixels, setDirtyFlag, setName, setPadding, setWidgetController, setZIndex, updateVisibility, visibilityChangedSinceLastDraw
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PEAK_NEEDLE_LOCAL_Z_INDEX

public static final int PEAK_NEEDLE_LOCAL_Z_INDEX
See Also:
Constant Field Values

DEFAULT_GEAR_FONT_NAME

public static final java.lang.String DEFAULT_GEAR_FONT_NAME
See Also:
Constant Field Values

useMaxRevLimit

protected final BooleanProperty useMaxRevLimit

displayGear

protected final BooleanProperty displayGear

gearBackgroundImageName

protected final ImageProperty gearBackgroundImageName

gearPosX

protected final IntProperty gearPosX

gearPosY

protected final IntProperty gearPosY

gearFont

protected final FontProperty gearFont

gearFontColor

protected final ColorProperty gearFontColor

peakNeedleImageName

protected final ImageProperty peakNeedleImageName

peakNeedlePivotBottomOffset

protected final IntProperty peakNeedlePivotBottomOffset

peakNeedleCooldown

protected final DelayProperty peakNeedleCooldown

peakNeedleWaitTime

protected final DelayProperty peakNeedleWaitTime

peakNeedleDownshiftIgnoreTime

protected final DelayProperty peakNeedleDownshiftIgnoreTime
Constructor Detail

AbstractRevNeedleMeterWidget

public AbstractRevNeedleMeterWidget(WidgetSet widgetSet,
                                    WidgetPackage widgetPackage,
                                    float width,
                                    float height)
Method Detail

getMarkersBigStepLowerLimit

protected int getMarkersBigStepLowerLimit()
Overrides:
getMarkersBigStepLowerLimit in class NeedleMeterWidget

getMarkersSmallStepLowerLimit

protected int getMarkersSmallStepLowerLimit()
Overrides:
getMarkersSmallStepLowerLimit in class NeedleMeterWidget

getInitialPeakNeedleImage

protected java.lang.String getInitialPeakNeedleImage()

onBackgroundChanged

protected void onBackgroundChanged(boolean imageChanged,
                                   float deltaScaleX,
                                   float deltaScaleY)
Description copied from class: Widget
This method is invoked when the background has changed.

Overrides:
onBackgroundChanged in class NeedleMeterWidget
Parameters:
imageChanged - whether the image has changed
deltaScaleX - the x-scale factor in as a difference between the old background image and the new one or -1 of no background image was selected
deltaScaleY - the y-scale factor in as a difference between the old background image and the new one or -1 of no background image was selected

getDefaultNamedFontValue

public java.lang.String getDefaultNamedFontValue(java.lang.String name)
Gets the default value for the given named font.

Overrides:
getDefaultNamedFontValue in class Widget
Parameters:
name - the font name to query
Returns:
the default value for the given named font.

getNeededData

public int getNeededData()
Gets the data indicators for the data needed for this Widget to be drawn (bitmask).

Overrides:
getNeededData in class Widget
Returns:
the data indicators for the data needed for this Widget to be drawn.
See Also:
Widget.NEEDED_DATA_TELEMETRY, Widget.NEEDED_DATA_SCORING, Widget.NEEDED_DATA_SCORING

getMinDataValue

protected float getMinDataValue(LiveGameData gameData,
                                boolean isEditorModes)
Description copied from class: NeedleMeterWidget
Gets the minimum value for the markers and needle coming from game data or known limits.

Specified by:
getMinDataValue in class NeedleMeterWidget
Returns:
the minimum value for the markers and needle.

getMaxDataValue

protected float getMaxDataValue(LiveGameData gameData,
                                boolean isEditorMode)
Description copied from class: NeedleMeterWidget
Gets the maximum value for the markers and needle coming from game data or known limits.

Specified by:
getMaxDataValue in class NeedleMeterWidget
Returns:
the maximum value for the markers and needle.

getValue

protected float getValue(LiveGameData gameData,
                         boolean isEditorMode)
Description copied from class: NeedleMeterWidget
Gets the value for the needle and the digital value display. Override NeedleMeterWidget.getValueForValueDisplay(LiveGameData, boolean) to use a different value for the digital value.

Specified by:
getValue in class NeedleMeterWidget
Returns:
the value for the needle and the digital value display.

getValueForValueDisplay

protected int getValueForValueDisplay(LiveGameData gameData,
                                      boolean isEditorMode)
Description copied from class: NeedleMeterWidget
Gets the value for the digital value display. The default implementation simply gets the result of NeedleMeterWidget.getValue(LiveGameData, boolean) and converts it to an int.

Overrides:
getValueForValueDisplay in class NeedleMeterWidget
Returns:
the value for the digital value display.

getMarkerLabelForValue

protected java.lang.String getMarkerLabelForValue(LiveGameData gameData,
                                                  boolean isEditorMode,
                                                  float value)
Description copied from class: NeedleMeterWidget
Gets the text label for the big markers at the given value.

Specified by:
getMarkerLabelForValue in class NeedleMeterWidget
Returns:
the text label for the big markers at the given value.

setPeakNeedleImageName

public void setPeakNeedleImageName(java.lang.String image)

getPeakNeedleImageName

public final java.lang.String getPeakNeedleImageName()

initSubTextures

protected void initSubTextures(LiveGameData gameData,
                               boolean isEditorMode,
                               int widgetInnerWidth,
                               int widgetInnerHeight,
                               SubTextureCollector collector)
Description copied from class: NeedleMeterWidget
Gets the TransformableTextures, that this Widget keeps.

Overrides:
initSubTextures in class NeedleMeterWidget
Parameters:
gameData - the live game data
isEditorMode - rendering in the editor?
widgetInnerWidth - the total widget width excluding borders
widgetInnerHeight - the total widget height excluding borders
collector - the collector to collect all the sub textures

onRealtimeEntered

public void onRealtimeEntered(LiveGameData gameData,
                              boolean isEditorMode)
This method is called when a the user entered realtime mode. If your Widget needs some data to be drawn correctly, consider using Widget.onNeededDataComplete(LiveGameData, boolean).

Overrides:
onRealtimeEntered in class NeedleMeterWidget
Parameters:
gameData - the live game data
isEditorMode - true, if the Editor is used for rendering instead of rFactor

onNeededDataComplete

public void onNeededDataComplete(LiveGameData gameData,
                                 boolean isEditorMode)
This method is called when the needed data is available in realtime mode.

Overrides:
onNeededDataComplete in class NeedleMeterWidget
Parameters:
gameData - the live game data
isEditorMode - true, if the Editor is used for rendering instead of rFactor

onVehicleControlChanged

protected java.lang.Boolean onVehicleControlChanged(VehicleScoringInfo viewedVSI,
                                                    LiveGameData gameData,
                                                    boolean isEditorMode)
This method is called when either the player's vehicle control has changed or another vehicle is being viewed.

Overrides:
onVehicleControlChanged in class Widget
Parameters:
viewedVSI - the currently viewed vehicle
gameData - the live game data
isEditorMode - true, if the Editor is used for rendering instead of rFactor
Returns:
true to set visible, false to set invisible, null for no change in visibility. This doesn't affect the visiblity toggled by the Widget.updateVisibility(LiveGameData, boolean) method or Widget.onBoundInputStateChanged(InputAction, boolean, int, long, LiveGameData, boolean) method.
See Also:
Widget.getAutoVisibility()

initialize

protected void initialize(LiveGameData gameData,
                          boolean isEditorMode,
                          DrawnStringFactory dsf,
                          TextureImage2D texture,
                          int width,
                          int height)
This method is called once to initialized DrawnStrings used on this Widget.

Overrides:
initialize in class NeedleMeterWidget
Parameters:
gameData - the live game data
isEditorMode - true, if the Editor is used for rendering instead of rFactor
dsf - a factory to get DrawnString instances from
texture - the texture image to draw on. Use TextureImage2D.getTextureCanvas() to retrieve the Texture2DCanvas for Graphics2D drawing.
width - the width on the texture
height - the height on the texture

checkForChanges

protected boolean checkForChanges(LiveGameData gameData,
                                  boolean isEditorMode,
                                  TextureImage2D texture,
                                  int width,
                                  int height)
Checks, if the Widget needs any changes before it is drawn. If true, Widget.drawBorder(boolean, BorderWrapper, TextureImage2D, int, int, int, int) and possibly Widget.drawBackground(LiveGameData, boolean, TextureImage2D, int, int, int, int, boolean) are (re-)invoked.
The original method is just an empty stub returning false.

Overrides:
checkForChanges in class Widget
Parameters:
gameData - the live game data
isEditorMode - true, if the Editor is used for rendering instead of rFactor
texture - the texture image to draw on. Use TextureImage2D.getTextureCanvas() to retrieve the Texture2DCanvas for Graphics2D drawing.
width - the width on the texture
height - the height on the texture
Returns:
true, if size has changed.

doRenderNeedle

protected boolean doRenderNeedle(LiveGameData gameData,
                                 boolean isEditorMode)
Description copied from class: NeedleMeterWidget
Live-checks, whether the needle is to be rendered or not.

Overrides:
doRenderNeedle in class NeedleMeterWidget
Returns:
whether to render the needle or not.

drawWidget

protected void drawWidget(Clock clock,
                          boolean needsCompleteRedraw,
                          LiveGameData gameData,
                          boolean isEditorMode,
                          TextureImage2D texture,
                          int offsetX,
                          int offsetY,
                          int width,
                          int height)
Description copied from class: Widget
This method must contain the actual drawing code for this Widget.

Overrides:
drawWidget in class NeedleMeterWidget
Parameters:
clock - this is a clock for very dynamic content, that needs smooth display. If 'needsCompleteRedraw' is true, clock1 is also true.
needsCompleteRedraw - whether this widget needs to be completely redrawn (true) or just the changed parts (false)
gameData - the live game data
isEditorMode - true, if the Editor is used for rendering instead of rFactor
texture - the texture image to draw on. Use TextureImage2D.getTextureCanvas() to retrieve the Texture2DCanvas for Graphics2D drawing.
offsetX - the x-offset on the texture
offsetY - the y-offset on the texture
width - the width on the texture
height - the height on the texture

initParentProperties

protected void initParentProperties()
Description copied from class: NeedleMeterWidget
This method is called as the last item in the constructor.

Overrides:
initParentProperties in class NeedleMeterWidget

saveMarkersProperties

protected void saveMarkersProperties(PropertyWriter writer)
                              throws java.io.IOException
Overrides:
saveMarkersProperties in class NeedleMeterWidget
Throws:
java.io.IOException

saveNeedleProperties

protected void saveNeedleProperties(PropertyWriter writer)
                             throws java.io.IOException
Overrides:
saveNeedleProperties in class NeedleMeterWidget
Throws:
java.io.IOException

saveGearProperties

protected void saveGearProperties(PropertyWriter writer)
                           throws java.io.IOException
Throws:
java.io.IOException

saveProperties

public void saveProperties(PropertyWriter writer)
                    throws java.io.IOException
Saves all settings to the config file.

Specified by:
saveProperties in interface PropertiesKeeper
Overrides:
saveProperties in class NeedleMeterWidget
Parameters:
writer - the widgets configuration writer to write properties to
Throws:
java.io.IOException - if something went wrong

loadProperty

public void loadProperty(PropertyLoader loader)
Loads (and parses) a certain property from a config file.

Specified by:
loadProperty in interface PropertiesKeeper
Overrides:
loadProperty in class NeedleMeterWidget
Parameters:
loader - the property loader to load properties from

addVisibilityPropertiesToContainer

protected void addVisibilityPropertiesToContainer(PropertiesContainer propsCont,
                                                  boolean forceAll)
Adds the visibility properties to the PropertiesContainer.

Overrides:
addVisibilityPropertiesToContainer in class Widget
Parameters:
propsCont - the container to add the properties to
forceAll - If true, all properties provided by this Widget must be added. If false, only the properties, that are relevant for the current Widget's situation have to be added, some can be ignored.

addMaxValuePropertyToContainer

protected void addMaxValuePropertyToContainer(PropertiesContainer propsCont,
                                              boolean forceAll)
Adds the maxValue property to the container.

Overrides:
addMaxValuePropertyToContainer in class NeedleMeterWidget
Parameters:
propsCont - the container to add the properties to
forceAll - If true, all properties provided by this Widget must be added. If false, only the properties, that are relevant for the current Widget's situation have to be added, some can be ignored.

getMarkersProperties

protected void getMarkersProperties(PropertiesContainer propsCont,
                                    boolean forceAll)
Collects the properties for the markers.

Overrides:
getMarkersProperties in class NeedleMeterWidget
Parameters:
propsCont - the container to add the properties to
forceAll - If true, all properties provided by this Widget must be added. If false, only the properties, that are relevant for the current Widget's situation have to be added, some can be ignored.

getNeedleProperties

protected void getNeedleProperties(PropertiesContainer propsCont,
                                   boolean forceAll)
Collects the properties for the needle.

Overrides:
getNeedleProperties in class NeedleMeterWidget
Parameters:
propsCont - the container to add the properties to
forceAll - If true, all properties provided by this Widget must be added. If false, only the properties, that are relevant for the current Widget's situation have to be added, some can be ignored.

getGearProperties

protected void getGearProperties(PropertiesContainer propsCont,
                                 boolean forceAll)
Collects the properties for the gear.

Parameters:
propsCont - the container to add the properties to
forceAll - If true, all properties provided by this Widget must be added. If false, only the properties, that are relevant for the current Widget's situation have to be added, some can be ignored.

getDigiValuePropertiesGroupName

protected java.lang.String getDigiValuePropertiesGroupName()
Gets the display name of the properties group for the digital value in the editor.

Overrides:
getDigiValuePropertiesGroupName in class NeedleMeterWidget
Returns:
the display name of the properties group for the digital value in the editor.

getProperties

public void getProperties(PropertiesContainer propsCont,
                          boolean forceAll)
Puts all editable properties to the editor.

Specified by:
getProperties in interface PropertiesKeeper
Overrides:
getProperties in class NeedleMeterWidget
Parameters:
propsCont - the container to add the properties to
forceAll - If true, all properties provided by this PropertiesKeeper must be added. If false, only the properties, that are relevant for the current PropertiesKeeper's situation have to be added, some can be ignored.

prepareForMenuItem

public void prepareForMenuItem()
This method is called by the editor before it draws the Widget to a menu item.

Overrides:
prepareForMenuItem in class NeedleMeterWidget