net.ctdp.rfdynhud.widgets.base.widget
Class StatefulWidget<GeneralStore,LocalStore>

java.lang.Object
  extended by net.ctdp.rfdynhud.widgets.base.widget.Widget
      extended by net.ctdp.rfdynhud.widgets.base.widget.StatefulWidget<GeneralStore,LocalStore>
Type Parameters:
GeneralStore - the type name of the general store class
LocalStore - the type name of the local store class
All Implemented Interfaces:
java.lang.Cloneable, PropertiesKeeper
Direct Known Subclasses:
AbstractAssembledWidget

public abstract class StatefulWidget<GeneralStore,LocalStore>
extends Widget

Widgets extending this class can store state data, that is restored when a Widget of this type and/or name is (re-)loaded.

The general store object is used and restored for any StatefulWidget of the same class.

The local store object is used and restored for any StatefulWidget of the same class and name.

Author:
Marvin Froehlich (CTDP)

Field Summary
 
Fields inherited from class net.ctdp.rfdynhud.widgets.base.widget.Widget
LOG_CHANNEL, NEEDED_DATA_ALL, NEEDED_DATA_SCORING, NEEDED_DATA_TELEMETRY
 
Constructor Summary
protected StatefulWidget(float width, boolean widthPercent, float height, boolean heightPercent)
          Creates a new Widget.
protected StatefulWidget(float width, float height)
          Creates a new Widget.
 
Method Summary
protected abstract  GeneralStore createGeneralStore()
          Creates a store object for all widgets of this type.
protected abstract  LocalStore createLocalStore()
          Creates a store object for this Widget only.
 GeneralStore getGeneralStore()
          Gets a value store object for all StatefulWidgets of this class.
protected  java.lang.Class<? extends StatefulWidget> getGeneralStoreKey()
           
 LocalStore getLocalStore()
          Gets a value store object for this StatefulWidget.
 
Methods inherited from class net.ctdp.rfdynhud.widgets.base.widget.Widget
addBackgroundPropertyToContainer, addBorderPropertyToContainer, addFontPropertiesToContainer, addPaddingPropertiesToContainer, addPositionAndSizePropertiesToContainer, addTypeAndNamePropertiesToContainer, addVisibilityPropertiesToContainer, afterConfigurationLoaded, bake, beforeConfigurationCleared, canHaveBackground, canHaveBorder, checkForChanges, clearBackgroundRegion, clearRegion, clearRegion, clone, cloneProperty, debug, debugCS, drawBackground, drawBorder, drawWidget, drawWidget, forceAndSetDirty, forceCompleteRedraw, forceReinitialization, getAbsoluteOffsetX, getAbsoluteOffsetY, getAutoVisibility, getBackground, getBackgroundProperty, getBorder, getBorderProperty, getConfiguration, getDefaultBorderValue, getDefaultNamedColorValue, getDefaultNamedFontValue, getDirtyFlag, getDocumentationSource, getDrawnStringFactory, getEffectiveHeight, getEffectiveWidth, getFont, getFontColor, getFontColorProperty, getFontProperty, getInitialBackground, getInnerSize, getInputActions, getInputVisibility, getMasterWidget, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getName, getNeededData, getNewInstanceForClone, getOffsetXToRootMasterWidget, getOffsetYToRootMasterWidget, getPaddingBottom, getPaddingLeft, getPaddingPropertyBottom, getPaddingPropertyLeft, getPaddingPropertyRight, getPaddingPropertyTop, getPaddingRight, getPaddingTop, getPosition, getProperties, getPropertiesForParentGroup, getPropertiesIterator, getSize, getSubTextures, getUpdatedVisibility, getWidgetController, getWidgetPackage, getZIndex, hasBorder, hasFixedSize, hasMasterCanvas, hasText, initialize, initSubTextures, isFontAntiAliased, isVisible, loadProperty, log, log, logCS, logCS, onBackgroundChanged, onBoundInputStateChanged, onCanvasSizeChanged, onCompleteRedrawForced, onDirtyFlagSet, onGarageEntered, onGarageExited, onLapStarted, onNeededDataComplete, onPitsEntered, onPitsExited, onPositionChanged, onPropertyChanged, onRealtimeEntered, onRealtimeExited, onReinitializationForced, onScoringInfoUpdated, onSessionStarted, onSizeChanged, onTrackChanged, onVehicleControlChanged, onVehicleSetupUpdated, onVisibilityChanged, prepareForMenuItem, saveProperties, setAllPosAndSizeToPercents, setAllPosAndSizeToPixels, setDirtyFlag, setName, setPadding, setWidgetController, updateVisibility, visibilityChangedSinceLastDraw
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StatefulWidget

protected StatefulWidget(float width,
                         boolean widthPercent,
                         float height,
                         boolean heightPercent)
Creates a new Widget.

Parameters:
width - negative numbers for (screen_width - width)
widthPercent - width parameter treated as percents
height - negative numbers for (screen_height - height)
heightPercent - height parameter treated as percents

StatefulWidget

protected StatefulWidget(float width,
                         float height)
Creates a new Widget.

Parameters:
width - negative numbers for (screen_width - width)
height - negative numbers for (screen_height - height)
Method Detail

createGeneralStore

protected abstract GeneralStore createGeneralStore()
Creates a store object for all widgets of this type.

Returns:
the general store object. null is explicitly permitted and default implementation simply returns null.

getGeneralStoreKey

protected java.lang.Class<? extends StatefulWidget> getGeneralStoreKey()

getGeneralStore

public final GeneralStore getGeneralStore()
Gets a value store object for all StatefulWidgets of this class.

Returns:
a value store object for all StatefulWidgets of this class.

createLocalStore

protected abstract LocalStore createLocalStore()
Creates a store object for this Widget only.

Returns:
the local store object. null is explicitly permitted and default implementation simply returns null.

getLocalStore

public final LocalStore getLocalStore()
Gets a value store object for this StatefulWidget. The store is restored when the widget configuration is reloaded. The object is stored by the StatefulWidget's class and name.

Returns:
a value store object for this StatefulWidget.