Class AbstractAxisModel

    • 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_PixelOffsets

        protected Stack<Integer> m_PixelOffsets
        stack of pixel offsets for the zooms.
      • 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.
    • Constructor Detail

      • AbstractAxisModel

        public AbstractAxisModel()
        Initializes the model.
    • 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 value
        max - 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
      • 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 zoom
        max - 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 zoom
        max - 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.
      • toString

        public String toString()
        Returns a string representation of the model.
        Overrides:
        toString in class Object
        Returns:
        a string representation