|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.ctdp.rfdynhud.widgets.base.widget.Widget
net.ctdp.rfdynhud.widgets.base.needlemeter.NeedleMeterWidget
public abstract class NeedleMeterWidget
The NeedleMeterWidget
is an abstract Widget
implementation
for meter widgets with a needle on an analogue scale.
Fields inherited from class net.ctdp.rfdynhud.widgets.base.widget.Widget |
---|
LOG_CHANNEL, NEEDED_DATA_ALL, NEEDED_DATA_SCORING, NEEDED_DATA_TELEMETRY |
Constructor Summary | |
---|---|
NeedleMeterWidget(WidgetSet widgetSet,
WidgetPackage widgetPackage,
float width,
boolean widthPercent,
float height,
boolean heightPercent)
Creates a new NeedleMeterWidget . |
|
NeedleMeterWidget(WidgetSet widgetSet,
WidgetPackage widgetPackage,
float width,
float height)
Creates a new NeedleMeterWidget . |
Method Summary | |
---|---|
protected void |
addMaxValuePropertyToContainer(PropertiesContainer propsCont,
boolean forceAll)
Adds the maxValue property to the container. |
protected void |
addMinValuePropertyToContainer(PropertiesContainer propsCont,
boolean forceAll)
Adds the minValue property to the container. |
protected boolean |
doRenderNeedle(LiveGameData gameData,
boolean isEditorMode)
Live-checks, whether the needle is to be rendered or not. |
protected void |
drawBackground(LiveGameData gameData,
boolean isEditorMode,
TextureImage2D texture,
int offsetX,
int offsetY,
int width,
int height,
boolean isRoot)
You can use this method to directly draw static content onto your Widget's background. |
protected void |
drawMarkers(LiveGameData gameData,
boolean isEditorMode,
Texture2DCanvas texCanvas,
int offsetX,
int offsetY,
int width,
int height)
Draws the markers. |
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. |
protected void |
getDigiValueProperties(PropertiesContainer propsCont,
boolean forceAll)
Collects the properties for the digital value. |
protected java.lang.String |
getDigiValuePropertiesGroupName()
Gets the display name of the properties group for the digital value in the editor. |
protected boolean |
getDisplayMarkerNumbers()
|
protected boolean |
getDisplayMarkers()
|
boolean |
getDisplayValue()
|
protected java.lang.String |
getInitialBackground()
Gets the initial value for the background property. |
protected java.lang.String |
getInitialNeedleImage()
|
protected java.awt.Color |
getMarkerColorForValue(LiveGameData gameData,
boolean isEditorMode,
int value,
int minValue,
int maxValue)
Gets a certain marker's color at the given value. |
protected abstract java.lang.String |
getMarkerLabelForValue(LiveGameData gameData,
boolean isEditorMode,
float value)
Gets the text label for the big markers at the given value. |
protected java.awt.Color |
getMarkerNumberColorForValue(LiveGameData gameData,
boolean isEditorMode,
int value,
int minValue,
int maxValue)
Gets a certain marker number's color at the given value. |
protected boolean |
getMarkerNumbersInside()
|
protected int |
getMarkersBigStepLowerLimit()
|
protected int |
getMarkersInnerRadius()
|
protected int |
getMarkersLength()
|
protected boolean |
getMarkersOnCircle()
|
protected void |
getMarkersProperties(PropertiesContainer propsCont,
boolean forceAll)
Collects the properties for the markers. |
protected int |
getMarkersSmallStepLowerLimit()
|
protected abstract float |
getMaxDataValue(LiveGameData gameData,
boolean isEditorMode)
Gets the maximum value for the markers and needle coming from game data or known limits. |
protected float |
getMaxValue(LiveGameData gameData,
boolean isEditorMode)
Gets the maximum value for the markers and needle. |
protected abstract float |
getMinDataValue(LiveGameData gameData,
boolean isEditorMode)
Gets the minimum value for the markers and needle coming from game data or known limits. |
protected float |
getMinValue(LiveGameData gameData,
boolean isEditorMode)
Gets the minimum value for the markers and needle. |
protected ImageTemplate |
getNeedleImage()
|
protected boolean |
getNeedleMayExceedMaximum()
Gets, whether the needle may go beyond the getMaxValue(LiveGameData, boolean) result. |
protected boolean |
getNeedleMayExceedMinimum()
Gets, whether the needle may go below the getMinValue(LiveGameData, boolean) result. |
protected int |
getNeedleMountX(int widgetWidth)
|
protected int |
getNeedleMountY(int widgetHeight)
|
protected int |
getNeedlePivotBottomOffset()
|
protected void |
getNeedleProperties(PropertiesContainer propsCont,
boolean forceAll)
Collects the properties for the needle. |
protected float |
getNeedleRotationForMaxValue()
|
protected float |
getNeedleRotationForMinValue()
|
protected TransformableTexture |
getNeedleTexture()
|
void |
getProperties(PropertiesContainer propsCont,
boolean forceAll)
Puts all editable properties to the editor. |
protected boolean |
getSpecificPropertiesFirst(PropertiesContainer propsCont,
boolean forceAll)
Collects the widget type specific properties before needle, markers and digi value. |
protected abstract float |
getValue(LiveGameData gameData,
boolean isEditorMode)
Gets the value for the needle and the digital value display. |
protected ImageTemplate |
getValueBackgroundImage()
|
protected FontProperty |
getValueFont()
Gets the FontProperty for the value. |
protected ColorProperty |
getValueFontColor()
Gets the ColorProperty for the value. |
protected int |
getValueForValueDisplay(LiveGameData gameData,
boolean isEditorMode)
Gets the value for the digital value display. |
protected int |
getValuePosX()
|
protected int |
getValuePosY()
|
protected void |
initialize(LiveGameData gameData,
boolean isEditorMode,
DrawnStringFactory dsf,
TextureImage2D texture,
int width,
int height)
This method is called once to initialized DrawnString s 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 TransformableTexture s, 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. |
protected void |
onNeedleImageNameChanged()
|
void |
onPropertyChanged(Property property,
java.lang.Object oldValue,
java.lang.Object newValue)
Invoked when a kept Property has changed. |
void |
onRealtimeEntered(LiveGameData gameData,
boolean isEditorMode)
This method is called when a the user entered realtime mode. |
void |
onVehicleSetupUpdated(LiveGameData gameData,
boolean isEditorMode)
This method is called when VehicleSetup has been updated. |
void |
prepareForMenuItem()
This method is called by the editor before it draws the Widget to a menu item. |
protected void |
prepareMarkersBackground(LiveGameData gameData,
boolean isEditorMode,
Texture2DCanvas texCanvas,
int offsetX,
int offsetY,
int width,
int height,
float innerRadius,
float bigOuterRadius,
float smallOuterRadius)
|
protected void |
saveDigiValueProperties(PropertyWriter writer)
|
protected void |
saveMarkersProperties(PropertyWriter writer)
|
protected void |
saveNeedleProperties(PropertyWriter writer)
|
void |
saveProperties(PropertyWriter writer)
Saves all settings to the config file. |
void |
setDisplayValue(boolean display)
|
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int NEEDLE_LOCAL_Z_INDEX
protected static final float MIN_MAX_VALUE_NONE
protected final FloatProperty minValue
protected final FloatProperty maxValue
protected final BooleanProperty displayMarkers
protected final BooleanProperty displayMarkerNumbers
protected final BooleanProperty markerNumbersInside
protected final IntProperty markersInnerRadius
protected final IntProperty markersLength
protected final BooleanProperty markersOnCircle
protected final FactoredFloatProperty firstMarkerNumberOffset
protected final FactoredFloatProperty lastMarkerNumberOffset
protected final IntProperty markersBigStep
protected final IntProperty markersSmallStep
protected final BooleanProperty lastMarkerBig
protected final ColorProperty markersColor
protected final FontProperty markersFont
protected final ColorProperty markersFontColor
protected final ColorProperty markersFontDropShadowColor
protected final BooleanProperty markerNumbersCentered
protected final IntProperty needleMountX
protected final IntProperty needleMountY
protected final IntProperty needlePivotBottomOffset
protected final FactoredFloatProperty needleRotationForMinValue
protected final FactoredFloatProperty needleRotationForMaxValue
protected final BooleanProperty displayValue
protected final ImageProperty valueBackgroundImageName
protected final IntProperty valuePosX
protected final IntProperty valuePosY
protected final FontProperty valueFont
protected final ColorProperty valueFontColor
Constructor Detail |
---|
public NeedleMeterWidget(WidgetSet widgetSet, WidgetPackage widgetPackage, float width, boolean widthPercent, float height, boolean heightPercent)
NeedleMeterWidget
.
widgetSet
- the WidgetSet
this Widget
belongs towidgetPackage
- the package in the editorwidth
- negative numbers for (screen_width - width)widthPercent
- width parameter treated as percentsheight
- negative numbers for (screen_height - height)heightPercent
- height parameter treated as percentspublic NeedleMeterWidget(WidgetSet widgetSet, WidgetPackage widgetPackage, float width, float height)
NeedleMeterWidget
.
widgetSet
- the WidgetSet
this Widget
belongs towidgetPackage
- the package in the editorwidth
- negative numbers for (screen_width - width)height
- negative numbers for (screen_height - height)Method Detail |
---|
protected java.lang.String getInitialBackground()
Widget
getInitialBackground
in class Widget
protected void onBackgroundChanged(boolean imageChanged, float deltaScaleX, float deltaScaleY)
Widget
onBackgroundChanged
in class Widget
imageChanged
- whether the image has changeddeltaScaleX
- the x-scale factor in as a difference between the old background image and the new one or -1 of no background image was selecteddeltaScaleY
- the y-scale factor in as a difference between the old background image and the new one or -1 of no background image was selectedprotected int getMarkersBigStepLowerLimit()
protected int getMarkersSmallStepLowerLimit()
protected void onNeedleImageNameChanged()
protected java.lang.String getInitialNeedleImage()
public void onPropertyChanged(Property property, java.lang.Object oldValue, java.lang.Object newValue)
Widget
Property
has changed.
onPropertyChanged
in interface PropertiesKeeper
onPropertyChanged
in class Widget
property
- the changed propertyoldValue
- the old valuenewValue
- the new valuepublic void setDisplayValue(boolean display)
public boolean getDisplayValue()
protected boolean getDisplayMarkers()
protected boolean getDisplayMarkerNumbers()
protected boolean getMarkerNumbersInside()
protected int getMarkersInnerRadius()
protected int getMarkersLength()
protected boolean getMarkersOnCircle()
protected ImageTemplate getNeedleImage()
protected final TransformableTexture getNeedleTexture()
protected int getNeedlePivotBottomOffset()
protected int getNeedleMountX(int widgetWidth)
protected int getNeedleMountY(int widgetHeight)
protected float getNeedleRotationForMinValue()
protected float getNeedleRotationForMaxValue()
protected ImageTemplate getValueBackgroundImage()
protected int getValuePosX()
protected int getValuePosY()
protected FontProperty getValueFont()
FontProperty
for the value.
FontProperty
for the value.protected ColorProperty getValueFontColor()
ColorProperty
for the value.
ColorProperty
for the value.protected void initSubTextures(LiveGameData gameData, boolean isEditorMode, int widgetInnerWidth, int widgetInnerHeight, SubTextureCollector collector)
TransformableTexture
s, that this Widget
keeps.
initSubTextures
in class Widget
gameData
- the live game dataisEditorMode
- rendering in the editor?widgetInnerWidth
- the total widget width excluding borderswidgetInnerHeight
- the total widget height excluding borderscollector
- the collector to collect all the sub texturespublic void onRealtimeEntered(LiveGameData gameData, boolean isEditorMode)
Widget
needs some data
to be drawn correctly, consider using Widget.onNeededDataComplete(LiveGameData, boolean)
.
onRealtimeEntered
in class Widget
gameData
- the live game dataisEditorMode
- true
, if the Editor is used for rendering instead of rFactorpublic void onVehicleSetupUpdated(LiveGameData gameData, boolean isEditorMode)
VehicleSetup
has been updated.
onVehicleSetupUpdated
in class Widget
gameData
- the live game dataisEditorMode
- true
, if the Editor is used for rendering instead of rFactorpublic void onNeededDataComplete(LiveGameData gameData, boolean isEditorMode)
onNeededDataComplete
in class Widget
gameData
- the live game dataisEditorMode
- true
, if the Editor is used for rendering instead of rFactorprotected void initialize(LiveGameData gameData, boolean isEditorMode, DrawnStringFactory dsf, TextureImage2D texture, int width, int height)
DrawnString
s used on this Widget.
initialize
in class Widget
gameData
- the live game dataisEditorMode
- true
, if the Editor is used for rendering instead of rFactordsf
- a factory to get DrawnString
instances fromtexture
- the texture image to draw on. Use TextureImage2D.getTextureCanvas()
to retrieve the Texture2DCanvas
for Graphics2D drawing.width
- the width on the textureheight
- the height on the textureprotected abstract float getValue(LiveGameData gameData, boolean isEditorMode)
getValueForValueDisplay(LiveGameData, boolean)
to use a different value
for the digital value.
gameData
- isEditorMode
-
protected int getValueForValueDisplay(LiveGameData gameData, boolean isEditorMode)
getValue(LiveGameData, boolean)
and converts it to an int.
gameData
- isEditorMode
-
protected abstract float getMinDataValue(LiveGameData gameData, boolean isEditorMode)
gameData
- isEditorMode
-
protected abstract float getMaxDataValue(LiveGameData gameData, boolean isEditorMode)
gameData
- isEditorMode
-
protected final float getMinValue(LiveGameData gameData, boolean isEditorMode)
getMinDataValue(LiveGameData, boolean)
is returned.
gameData
- isEditorMode
-
protected final float getMaxValue(LiveGameData gameData, boolean isEditorMode)
getMaxDataValue(LiveGameData, boolean)
is returned.
gameData
- isEditorMode
-
protected boolean getNeedleMayExceedMinimum()
getMinValue(LiveGameData, boolean)
result.
The default implementation returns false
.
getMinValue(LiveGameData, boolean)
result.protected boolean getNeedleMayExceedMaximum()
getMaxValue(LiveGameData, boolean)
result.
The default implementation returns true
.
getMaxValue(LiveGameData, boolean)
result.protected abstract java.lang.String getMarkerLabelForValue(LiveGameData gameData, boolean isEditorMode, float value)
gameData
- isEditorMode
- value
-
protected void prepareMarkersBackground(LiveGameData gameData, boolean isEditorMode, Texture2DCanvas texCanvas, int offsetX, int offsetY, int width, int height, float innerRadius, float bigOuterRadius, float smallOuterRadius)
gameData
- isEditorMode
- texCanvas
- offsetX
- offsetY
- width
- height
- innerRadius
- bigOuterRadius
- smallOuterRadius
- protected java.awt.Color getMarkerColorForValue(LiveGameData gameData, boolean isEditorMode, int value, int minValue, int maxValue)
gameData
- isEditorMode
- value
- minValue
- maxValue
-
protected java.awt.Color getMarkerNumberColorForValue(LiveGameData gameData, boolean isEditorMode, int value, int minValue, int maxValue)
gameData
- isEditorMode
- value
- minValue
- maxValue
-
protected void drawMarkers(LiveGameData gameData, boolean isEditorMode, Texture2DCanvas texCanvas, int offsetX, int offsetY, int width, int height)
gameData
- isEditorMode
- texCanvas
- offsetX
- offsetY
- width
- height
- protected void drawBackground(LiveGameData gameData, boolean isEditorMode, TextureImage2D texture, int offsetX, int offsetY, int width, int height, boolean isRoot)
Widget
drawBackground
in class Widget
gameData
- the live game dataisEditorMode
- true
, if the Editor is used for rendering instead of rFactortexture
- the texture image to draw on. Use TextureImage2D.getTextureCanvas()
to retrieve the Texture2DCanvas
for Graphics2D drawing.offsetX
- the x-offset on the drawing textureoffsetY
- the y offset on the drawing texturewidth
- the width of the area on the drawing textureheight
- the height of the area on the drawing textureisRoot
- if this is true, you can possibly clear your stuff onto the texture instead of drawing it.protected boolean doRenderNeedle(LiveGameData gameData, boolean isEditorMode)
gameData
- isEditorMode
-
protected void drawWidget(Clock clock, boolean needsCompleteRedraw, LiveGameData gameData, boolean isEditorMode, TextureImage2D texture, int offsetX, int offsetY, int width, int height)
Widget
drawWidget
in class Widget
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 dataisEditorMode
- true
, if the Editor is used for rendering instead of rFactortexture
- the texture image to draw on. Use TextureImage2D.getTextureCanvas()
to retrieve the Texture2DCanvas
for Graphics2D drawing.offsetX
- the x-offset on the textureoffsetY
- the y-offset on the texturewidth
- the width on the textureheight
- the height on the textureprotected void saveMarkersProperties(PropertyWriter writer) throws java.io.IOException
java.io.IOException
protected void saveNeedleProperties(PropertyWriter writer) throws java.io.IOException
java.io.IOException
protected void saveDigiValueProperties(PropertyWriter writer) throws java.io.IOException
java.io.IOException
public void saveProperties(PropertyWriter writer) throws java.io.IOException
saveProperties
in interface PropertiesKeeper
saveProperties
in class Widget
writer
- the widgets configuration writer to write properties to
java.io.IOException
- if something went wrongpublic void loadProperty(PropertyLoader loader)
loadProperty
in interface PropertiesKeeper
loadProperty
in class Widget
loader
- the property loader to load properties fromprotected void addMinValuePropertyToContainer(PropertiesContainer propsCont, boolean forceAll)
propsCont
- the container to add the properties toforceAll
- 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.protected void addMaxValuePropertyToContainer(PropertiesContainer propsCont, boolean forceAll)
propsCont
- the container to add the properties toforceAll
- 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.protected boolean getSpecificPropertiesFirst(PropertiesContainer propsCont, boolean forceAll)
propsCont
- the container to add the properties toforceAll
- 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.
true
, if the implementation has added a group, false
otherwise.protected void getMarkersProperties(PropertiesContainer propsCont, boolean forceAll)
propsCont
- the container to add the properties toforceAll
- 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.protected void getNeedleProperties(PropertiesContainer propsCont, boolean forceAll)
propsCont
- the container to add the properties toforceAll
- 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.protected java.lang.String getDigiValuePropertiesGroupName()
protected void getDigiValueProperties(PropertiesContainer propsCont, boolean forceAll)
propsCont
- the container to add the properties toforceAll
- 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.public void getProperties(PropertiesContainer propsCont, boolean forceAll)
getProperties
in interface PropertiesKeeper
getProperties
in class Widget
propsCont
- the container to add the properties toforceAll
- 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.protected void initParentProperties()
public void prepareForMenuItem()
prepareForMenuItem
in class Widget
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |