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 double
m_ActualMaximum
the actual maximum to display (including the top margin).protected double
m_ActualMaximumNoMargin
the actual maximum to display (excluding the top margin).protected double
m_ActualMinimum
the actual minimum to display (including the bottom margin).protected double
m_ActualMinimumNoMargin
the actual minimum to display (excluding the bottom margin).protected Formatter
m_CustomerFormatter
a customer formatter to use.protected Formatter
m_Formatter
the format for outputting the values (SimpleDateFormat or DecimalFormat).protected Double
m_ManualMarginBottom
the manual bottom margin.protected Double
m_ManualMarginTop
the manual top margin.protected Double
m_ManualMaximum
the manual maximum.protected Double
m_ManualMinimum
the manual minimum.protected double
m_MarginBottom
the bottom margin.protected double
m_MarginTop
the top margin.protected double
m_Maximum
the maximum.protected double
m_Minimum
the minimum.protected int
m_NthValueToShow
every nth value to display.protected AxisPanel
m_Parent
the owning axis.protected int
m_PixelOffset
a pixel offset due to panning.protected Stack<Integer>
m_PixelOffsets
stack of pixel offsets for the zooms.protected TickGenerator
m_TickGenerator
the tick generator.protected boolean
m_Validated
indicates whether the layout has been validated.protected ZoomHandler
m_ZoomHandler
the 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 double
adjustMaximum(double max)
Adjusts the maximum to work with this model.abstract double
adjustMinimum(double min)
Adjusts the minimum to work with this model.void
assign(AbstractAxisModel model)
Obtains the necessary values from the given model and updates itself.protected boolean
canAssignFormatter(Formatter formatter)
Returns whether the formatter can be assigned.abstract boolean
canHandle(double min, double max)
Checks whether the data range can be handled by the model.boolean
canZoom(double min, double max)
Checks whether we can still zoom in.void
clearZoom()
Removes all zooms.protected abstract String
doValueToDisplay(double value)
Returns the display string of the value for the tooltip, for instance.protected Formatter
getActualFormatter()
Returns the formatter to use for parsing/formatting.double
getActualMaximum()
Returns the actual maximum on the axis (with margins).double
getActualMaximumNoMargin()
Returns the maximum in use on the axis (without margins).double
getActualMinimum()
Returns the actual minimum on the axis.double
getActualMinimumNoMargin()
Returns the actual minimum on the axis (no margin).double
getBottomMargin()
Returns the currently set bottom margin factor (>= 0.0).Formatter
getCustomFormatter()
Returns the current custom formatter, can be null if none set.protected Formatter
getDefaultFormatter()
Returns the default formatter.String
getDefaultNumberFormat()
Returns the default number format.abstract String
getDisplayName()
Returns the display name of this model.Double
getManualBottomMargin()
Returns the currently set manual bottom margin factor (>= 0.0 or null).Double
getManualMaximum()
Returns the currently set manual maximum on the axis.Double
getManualMinimum()
Returns the currently set manual minimum on the axis.Double
getManualTopMargin()
Returns the currently set manual top margin factor (>= 0.0 or null).double
getMaximum()
Returns the currently set maximum on the axis.double
getMinimum()
Returns the currently set minimum on the axis.protected double
getMinZoomDifference()
Returns the minimum difference that must exist between min/max in order to allow zooming.int
getNthValueToShow()
Returns the count of ticks a value is shown, i.e., "3" means every third tick: 1, 4, 7, ...String
getNumberFormat()
Returns the pattern used for displaying the numbers on the axis.AxisPanel
getParent()
Returns the owning axis panel.int
getPixelOffset()
Returns the current pixel offset.TickGenerator
getTickGenerator()
Returns the current tick generator in use.List<Tick>
getTicks()
Returns the ticks of this axis.double
getTopMargin()
Returns the currently set top margin factor (>= 0.0).boolean
hasCustomFormatter()
Returns whether a custom formatter is in use.protected void
initialize()
Initializes the member variables.void
invalidate()
Invalidates the current setup, calculations necessary for margins, etc.boolean
isZoomed()
Returns true if the axis is currently zoomed.void
popZoom()
Removes the latest zoom, if available.abstract double
posToValue(int pos)
Returns the value for the given position on the axis.void
pushZoom(double min, double max)
Adds the zoom to its internal list and updates the axis.void
setBottomMargin(double value)
Sets the bottom margin factor (>= 0.0).void
setCustomFormatter(Formatter value)
Sets the custom formatter to use.void
setManualBottomMargin(Double value)
Sets the manual bottom margin factor (>= 0.0 or null).void
setManualMaximum(Double value)
Sets the manual maximum to display on the axis.void
setManualMinimum(Double value)
Sets the manual minimum to display on the axis.void
setManualTopMargin(Double value)
Sets the manual top margin factor (>= 0.0 or null).void
setMaximum(double value)
Sets the maximum to display on the axis.void
setMinimum(double value)
Sets the minimum to display on the axis.void
setNthValueToShow(int value)
Sets the count of ticks a value is shown, i.e., "3" means every third tick: 1, 4, 7, ...void
setNumberFormat(String value)
Sets the pattern used for displaying the numbers on the axis.void
setParent(AxisPanel value)
Sets the owning axis panel.void
setPixelOffset(int value)
Sets the pixel offset due to panning.void
setTickGenerator(TickGenerator value)
Sets the tick generator to use.void
setTopMargin(double value)
Sets the top margin factor (>= 0.0).String
toString()
Returns a string representation of the model.void
update()
Forces the panel to repaint itself.void
validate()
calculates the top and bottom margin if necessary.String
valueToDisplay(double value)
Returns the display string of the value for the tooltip, for instance.abstract int
valueToPos(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.
-
-