Class AbstractAxisModel
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.gui.visualization.core.axis.AbstractAxisModel
-
- All Implemented Interfaces:
LoggingSupporter,SizeOfHandler,Serializable
- Direct Known Subclasses:
AbstractDateBasedAxisModel,DefaultAxisModel,LogAxisModel,PercentageAxisModel
public abstract class AbstractAxisModel extends LoggingObject
An abstract class of an axis model.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected doublem_ActualMaximumthe actual maximum to display (including the top margin).protected doublem_ActualMaximumNoMarginthe actual maximum to display (excluding the top margin).protected doublem_ActualMinimumthe actual minimum to display (including the bottom margin).protected doublem_ActualMinimumNoMarginthe actual minimum to display (excluding the bottom margin).protected Formatterm_CustomerFormattera customer formatter to use.protected Formatterm_Formatterthe format for outputting the values (SimpleDateFormat or DecimalFormat).protected Doublem_ManualMarginBottomthe manual bottom margin.protected Doublem_ManualMarginTopthe manual top margin.protected Doublem_ManualMaximumthe manual maximum.protected Doublem_ManualMinimumthe manual minimum.protected doublem_MarginBottomthe bottom margin.protected doublem_MarginTopthe top margin.protected doublem_Maximumthe maximum.protected doublem_Minimumthe minimum.protected intm_NthValueToShowevery nth value to display.protected AxisPanelm_Parentthe owning axis.protected intm_PixelOffseta pixel offset due to panning.protected Stack<Integer>m_PixelOffsetsstack of pixel offsets for the zooms.protected TickGeneratorm_TickGeneratorthe tick generator.protected booleanm_Validatedindicates whether the layout has been validated.protected ZoomHandlerm_ZoomHandlerthe zooms.-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
-
Constructor Summary
Constructors Constructor Description AbstractAxisModel()Initializes the model.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract doubleadjustMaximum(double max)Adjusts the maximum to work with this model.abstract doubleadjustMinimum(double min)Adjusts the minimum to work with this model.voidassign(AbstractAxisModel model)Obtains the necessary values from the given model and updates itself.protected booleancanAssignFormatter(Formatter formatter)Returns whether the formatter can be assigned.abstract booleancanHandle(double min, double max)Checks whether the data range can be handled by the model.booleancanZoom(double min, double max)Checks whether we can still zoom in.voidclearZoom()Removes all zooms.protected abstract StringdoValueToDisplay(double value)Returns the display string of the value for the tooltip, for instance.protected FormattergetActualFormatter()Returns the formatter to use for parsing/formatting.doublegetActualMaximum()Returns the actual maximum on the axis (with margins).doublegetActualMaximumNoMargin()Returns the maximum in use on the axis (without margins).doublegetActualMinimum()Returns the actual minimum on the axis.doublegetActualMinimumNoMargin()Returns the actual minimum on the axis (no margin).doublegetBottomMargin()Returns the currently set bottom margin factor (>= 0.0).FormattergetCustomFormatter()Returns the current custom formatter, can be null if none set.protected FormattergetDefaultFormatter()Returns the default formatter.StringgetDefaultNumberFormat()Returns the default number format.abstract StringgetDisplayName()Returns the display name of this model.DoublegetManualBottomMargin()Returns the currently set manual bottom margin factor (>= 0.0 or null).DoublegetManualMaximum()Returns the currently set manual maximum on the axis.DoublegetManualMinimum()Returns the currently set manual minimum on the axis.DoublegetManualTopMargin()Returns the currently set manual top margin factor (>= 0.0 or null).doublegetMaximum()Returns the currently set maximum on the axis.doublegetMinimum()Returns the currently set minimum on the axis.protected doublegetMinZoomDifference()Returns the minimum difference that must exist between min/max in order to allow zooming.intgetNthValueToShow()Returns the count of ticks a value is shown, i.e., "3" means every third tick: 1, 4, 7, ...StringgetNumberFormat()Returns the pattern used for displaying the numbers on the axis.AxisPanelgetParent()Returns the owning axis panel.intgetPixelOffset()Returns the current pixel offset.TickGeneratorgetTickGenerator()Returns the current tick generator in use.List<Tick>getTicks()Returns the ticks of this axis.doublegetTopMargin()Returns the currently set top margin factor (>= 0.0).booleanhasCustomFormatter()Returns whether a custom formatter is in use.protected voidinitialize()Initializes the member variables.voidinvalidate()Invalidates the current setup, calculations necessary for margins, etc.booleanisZoomed()Returns true if the axis is currently zoomed.voidpopZoom()Removes the latest zoom, if available.abstract doubleposToValue(int pos)Returns the value for the given position on the axis.voidpushZoom(double min, double max)Adds the zoom to its internal list and updates the axis.voidsetBottomMargin(double value)Sets the bottom margin factor (>= 0.0).voidsetCustomFormatter(Formatter value)Sets the custom formatter to use.voidsetManualBottomMargin(Double value)Sets the manual bottom margin factor (>= 0.0 or null).voidsetManualMaximum(Double value)Sets the manual maximum to display on the axis.voidsetManualMinimum(Double value)Sets the manual minimum to display on the axis.voidsetManualTopMargin(Double value)Sets the manual top margin factor (>= 0.0 or null).voidsetMaximum(double value)Sets the maximum to display on the axis.voidsetMinimum(double value)Sets the minimum to display on the axis.voidsetNthValueToShow(int value)Sets the count of ticks a value is shown, i.e., "3" means every third tick: 1, 4, 7, ...voidsetNumberFormat(String value)Sets the pattern used for displaying the numbers on the axis.voidsetParent(AxisPanel value)Sets the owning axis panel.voidsetPixelOffset(int value)Sets the pixel offset due to panning.voidsetTickGenerator(TickGenerator value)Sets the tick generator to use.voidsetTopMargin(double value)Sets the top margin factor (>= 0.0).StringtoString()Returns a string representation of the model.voidupdate()Forces the panel to repaint itself.voidvalidate()calculates the top and bottom margin if necessary.StringvalueToDisplay(double value)Returns the display string of the value for the tooltip, for instance.abstract intvalueToPos(double value)Returns the position on the axis for the given value.-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
-
-
-
Field Detail
-
m_Parent
protected AxisPanel m_Parent
the owning axis.
-
m_Minimum
protected double m_Minimum
the minimum.
-
m_Maximum
protected double m_Maximum
the maximum.
-
m_ActualMinimum
protected double m_ActualMinimum
the actual minimum to display (including the bottom margin).
-
m_ActualMaximum
protected double m_ActualMaximum
the actual maximum to display (including the top margin).
-
m_ActualMinimumNoMargin
protected double m_ActualMinimumNoMargin
the actual minimum to display (excluding the bottom margin).
-
m_ActualMaximumNoMargin
protected double m_ActualMaximumNoMargin
the actual maximum to display (excluding the top margin).
-
m_MarginTop
protected double m_MarginTop
the top margin.
-
m_MarginBottom
protected double m_MarginBottom
the bottom margin.
-
m_Validated
protected boolean m_Validated
indicates whether the layout has been validated.
-
m_Formatter
protected Formatter m_Formatter
the format for outputting the values (SimpleDateFormat or DecimalFormat).
-
m_CustomerFormatter
protected Formatter m_CustomerFormatter
a customer formatter to use.
-
m_ZoomHandler
protected ZoomHandler m_ZoomHandler
the zooms.
-
m_PixelOffset
protected int m_PixelOffset
a pixel offset due to panning.
-
m_TickGenerator
protected TickGenerator m_TickGenerator
the tick generator.
-
m_NthValueToShow
protected int m_NthValueToShow
every nth value to display.
-
m_ManualMinimum
protected Double m_ManualMinimum
the manual minimum.
-
m_ManualMaximum
protected Double m_ManualMaximum
the manual maximum.
-
m_ManualMarginTop
protected Double m_ManualMarginTop
the manual top margin.
-
m_ManualMarginBottom
protected Double m_ManualMarginBottom
the manual bottom margin.
-
-
Method Detail
-
initialize
protected void initialize()
Initializes the member variables.
-
getDefaultFormatter
protected Formatter getDefaultFormatter()
Returns the default formatter.- Returns:
- the formatter
-
setParent
public void setParent(AxisPanel value)
Sets the owning axis panel.- Parameters:
value- the axis panel
-
getParent
public AxisPanel getParent()
Returns the owning axis panel.- Returns:
- the axis panel
-
getDisplayName
public abstract String getDisplayName()
Returns the display name of this model.- Returns:
- the display name
-
canHandle
public abstract boolean canHandle(double min, double max)Checks whether the data range can be handled by the model.- Parameters:
min- the minimum valuemax- the maximum value- Returns:
- true if the data can be handled
-
adjustMinimum
public abstract double adjustMinimum(double min)
Adjusts the minimum to work with this model.- Parameters:
min- the minimum to adjust- Returns:
- the updated value
-
adjustMaximum
public abstract double adjustMaximum(double max)
Adjusts the maximum to work with this model.- Parameters:
max- the maximum to adjust- Returns:
- the updated value
-
setMinimum
public void setMinimum(double value)
Sets the minimum to display on the axis.- Parameters:
value- the minimum value
-
getMinimum
public double getMinimum()
Returns the currently set minimum on the axis.- Returns:
- the minimum value
-
setManualMinimum
public void setManualMinimum(Double value)
Sets the manual minimum to display on the axis.- Parameters:
value- the minimum value, null to unset
-
getManualMinimum
public Double getManualMinimum()
Returns the currently set manual minimum on the axis.- Returns:
- the minimum value, null if none set
-
getActualMinimum
public double getActualMinimum()
Returns the actual minimum on the axis.- Returns:
- the actual minimum
-
getActualMinimumNoMargin
public double getActualMinimumNoMargin()
Returns the actual minimum on the axis (no margin).- Returns:
- the actual minimum
-
setMaximum
public void setMaximum(double value)
Sets the maximum to display on the axis.- Parameters:
value- the maximum value
-
getMaximum
public double getMaximum()
Returns the currently set maximum on the axis.- Returns:
- the maximum value
-
setManualMaximum
public void setManualMaximum(Double value)
Sets the manual maximum to display on the axis.- Parameters:
value- the maximum value, null to unset
-
getManualMaximum
public Double getManualMaximum()
Returns the currently set manual maximum on the axis.- Returns:
- the manual maximum value, null if none set
-
getActualMaximum
public double getActualMaximum()
Returns the actual maximum on the axis (with margins).- Returns:
- the actual maximum
-
getActualMaximumNoMargin
public double getActualMaximumNoMargin()
Returns the maximum in use on the axis (without margins).- Returns:
- the maximum in used
-
setTopMargin
public void setTopMargin(double value)
Sets the top margin factor (>= 0.0).- Parameters:
value- the top margin
-
getTopMargin
public double getTopMargin()
Returns the currently set top margin factor (>= 0.0).- Returns:
- the top margin
-
setBottomMargin
public void setBottomMargin(double value)
Sets the bottom margin factor (>= 0.0).- Parameters:
value- the bottom margin
-
getBottomMargin
public double getBottomMargin()
Returns the currently set bottom margin factor (>= 0.0).- Returns:
- the bottom margin
-
setManualTopMargin
public void setManualTopMargin(Double value)
Sets the manual top margin factor (>= 0.0 or null).- Parameters:
value- the top margin
-
getManualTopMargin
public Double getManualTopMargin()
Returns the currently set manual top margin factor (>= 0.0 or null).- Returns:
- the top margin
-
setManualBottomMargin
public void setManualBottomMargin(Double value)
Sets the manual bottom margin factor (>= 0.0 or null).- Parameters:
value- the bottom margin
-
getManualBottomMargin
public Double getManualBottomMargin()
Returns the currently set manual bottom margin factor (>= 0.0 or null).- Returns:
- the bottom margin
-
setPixelOffset
public void setPixelOffset(int value)
Sets the pixel offset due to panning.- Parameters:
value- the offset
-
getPixelOffset
public int getPixelOffset()
Returns the current pixel offset.- Returns:
- the offset
-
getDefaultNumberFormat
public String getDefaultNumberFormat()
Returns the default number format.- Returns:
- the default format
-
setNumberFormat
public void setNumberFormat(String value)
Sets the pattern used for displaying the numbers on the axis.- Parameters:
value- the value to use
-
getNumberFormat
public String getNumberFormat()
Returns the pattern used for displaying the numbers on the axis.- Returns:
- the pattern
-
hasCustomFormatter
public boolean hasCustomFormatter()
Returns whether a custom formatter is in use.- Returns:
- true if a custom formatter is used
-
setCustomFormatter
public void setCustomFormatter(Formatter value)
Sets the custom formatter to use. Use null to unset the formatter.- Parameters:
value- the custom formatter to use
-
getCustomFormatter
public Formatter getCustomFormatter()
Returns the current custom formatter, can be null if none set.- Returns:
- the custom formatter
-
getActualFormatter
protected Formatter getActualFormatter()
Returns the formatter to use for parsing/formatting.- Returns:
- the formatter to use
- See Also:
m_Formatter,m_CustomerFormatter
-
getMinZoomDifference
protected double getMinZoomDifference()
Returns the minimum difference that must exist between min/max in order to allow zooming.- Returns:
- the minimum difference
-
canZoom
public boolean canZoom(double min, double max)Checks whether we can still zoom in.- Parameters:
min- the minimum of the zoommax- the maximum of the zoom- Returns:
- true if zoom is possible
-
pushZoom
public void pushZoom(double min, double max)Adds the zoom to its internal list and updates the axis.- Parameters:
min- the minimum of the zoommax- the maximum of the zoom
-
popZoom
public void popZoom()
Removes the latest zoom, if available.
-
isZoomed
public boolean isZoomed()
Returns true if the axis is currently zoomed.- Returns:
- true if a zoom is in place
-
clearZoom
public void clearZoom()
Removes all zooms.
-
setTickGenerator
public void setTickGenerator(TickGenerator value)
Sets the tick generator to use.- Parameters:
value- the tick generator
-
getTickGenerator
public TickGenerator getTickGenerator()
Returns the current tick generator in use.- Returns:
- the tick generator
-
getTicks
public List<Tick> getTicks()
Returns the ticks of this axis.- Returns:
- the current ticks to display
-
setNthValueToShow
public void setNthValueToShow(int value)
Sets the count of ticks a value is shown, i.e., "3" means every third tick: 1, 4, 7, ...- Parameters:
value- the count
-
getNthValueToShow
public int getNthValueToShow()
Returns the count of ticks a value is shown, i.e., "3" means every third tick: 1, 4, 7, ...- Returns:
- the count
-
doValueToDisplay
protected abstract String doValueToDisplay(double value)
Returns the display string of the value for the tooltip, for instance.- Parameters:
value- the value to turn into string- Returns:
- the display string
-
valueToDisplay
public String valueToDisplay(double value)
Returns the display string of the value for the tooltip, for instance.- Parameters:
value- the value to turn into string- Returns:
- the display string
-
valueToPos
public abstract int valueToPos(double value)
Returns the position on the axis for the given value.- Parameters:
value- the value to get the position for- Returns:
- the corresponding position
-
posToValue
public abstract double posToValue(int pos)
Returns the value for the given position on the axis.- Parameters:
pos- the position to get the corresponding value for- Returns:
- the corresponding value
-
invalidate
public void invalidate()
Invalidates the current setup, calculations necessary for margins, etc.
-
validate
public void validate()
calculates the top and bottom margin if necessary.
-
assign
public void assign(AbstractAxisModel model)
Obtains the necessary values from the given model and updates itself.- Parameters:
model- the model to get the parameters from
-
canAssignFormatter
protected boolean canAssignFormatter(Formatter formatter)
Returns whether the formatter can be assigned.- Parameters:
formatter- the formatter to check- Returns:
- true if it can be used
-
update
public void update()
Forces the panel to repaint itself.
-
-