Class Axis

  • Direct Known Subclasses:
    CartesianAxis, ProjectionAxis, RadialAxis

    public abstract class Axis
    extends Object
    Axes are an integral part of a chart.
    They are used to determine how data maps to a pixel value on the chart.
    It contains a number of config callbacks that can be used to change parameters in the scale at different points in the update process.
    Author:
    Andrea "Stock" Stocchero
    • Constructor Detail

      • Axis

        protected Axis​(IsChart chart,
                       ScaleId id,
                       AxisType type,
                       AxisKind kind)
        Builds the object storing the chart instance.
        Parameters:
        chart - chart instance
        id - axis id
        type - axis type
        kind - axis kind to set the right position
    • Method Detail

      • getCharbaId

        public final int getCharbaId()
        Returns the unique id of axis.
        Returns:
        the unique id of axis
      • getId

        public final ScaleId getId()
        The ID is used to link datasets and scale axes together.
        This is especially needed if multi-axes charts are used.
        Returns:
        The ID is used to link datasets and scale axes together or DefaultScaleId.UNKNOWN if not set
      • getType

        public final AxisType getType()
        Returns the type of axis.
        Returns:
        the type of axis
      • getAxis

        public final AxisKind getAxis()
        Which kind of axis this is.
        Possible values are: 'x', 'y' or 'r'.
        Returns:
        the kind of axis.
      • setDisplay

        public final void setDisplay​(Display display)
        The display option controls the visibility of axis.
        Controls the axis global visibility (visible when true, hidden when false).
        When Display.AUTO, the axis is visible only if at least one associated data set is visible.
        Parameters:
        display - display option controls the visibility of axis
      • getDisplay

        public final Display getDisplay()
        The display option controls the visibility of axis.
        Controls the axis global visibility (visible when true, hidden when false).
        When Display.AUTO, the axis is visible only if at least one associated data set is visible.
        Returns:
        display option controls the visibility of axis
      • setBackgroundColor

        public void setBackgroundColor​(IsColor backgroundColor)
        Sets the default background color to use in the chart, on all objects, if not override by the specific configuration.
        Parameters:
        backgroundColor - background color to use in the chart.
      • setBackgroundColor

        public void setBackgroundColor​(String backgroundColor)
        Sets the background color of the scale area.
        Parameters:
        backgroundColor - the background color of the scale area.
      • getBackgroundColorAsString

        public String getBackgroundColorAsString()
        Returns the background color of the scale area.
        Returns:
        the background color of the scale area.
      • getBackgroundColor

        public IsColor getBackgroundColor()
        Returns the background color of the scale area.
        Returns:
        the background color of the scale area.
      • setWeight

        public void setWeight​(double weight)
        The weight used to sort the axis.
        Higher weights are further away from the chart area.
        Parameters:
        weight - weight of axis
      • getWeight

        public double getWeight()
        The weight used to sort the axis.
        Higher weights are further away from the chart area.
        Returns:
        weight of axis
      • setAlignToPixels

        public void setAlignToPixels​(boolean alignToPixels)
        Sets true to align pixel values to device pixels.
        Parameters:
        alignToPixels - true to align pixel values to device pixels.
      • isAlignToPixels

        public boolean isAlignToPixels()
        Returns true to align pixel values to device pixels.
        Returns:
        true to align pixel values to device pixels
      • setReverse

        public void setReverse​(boolean reverse)
        Sets the reversed order of tick labels.
        Parameters:
        reverse - reversed order of tick labels.
      • isReverse

        public boolean isReverse()
        Returns the reversed order of tick labels.
        Returns:
        reversed order of tick labels.
      • getScaleItem

        public final ScaleItem getScaleItem()
        Returns the scale item related to this axis.
        Returns:
        the scale item related to this axis
      • getDisplayCallback

        public DisplayCallback<ScaleContext> getDisplayCallback()
        Returns the user callback that sets if the axis will be shown.
        Returns:
        the user callback that sets if the axis will be shown.
      • setDisplay

        public void setDisplay​(DisplayCallback<ScaleContext> displayCallback)
        Sets the user callback that sets if the axis will be shown.
        Parameters:
        displayCallback - the user callback that sets if the axis will be shown
      • setDisplay

        public void setDisplay​(NativeCallback displayCallback)
        Sets the user callback that sets if the axis will be shown.
        Parameters:
        displayCallback - that sets if the axis will be shown.
      • getBackgroundColorCallback

        public ColorCallback<ScaleContext> getBackgroundColorCallback()
        Returns the background color callback, if set, otherwise null.
        Returns:
        the background color callback, if set, otherwise null.
      • setBackgroundColor

        public void setBackgroundColor​(ColorCallback<ScaleContext> backgroundColorCallback)
        Sets the background color callback.
        Parameters:
        backgroundColorCallback - the background color callback.
      • setBackgroundColor

        public void setBackgroundColor​(NativeCallback backgroundColorCallback)
        Sets the background color callback.
        Parameters:
        backgroundColorCallback - the background color callback.
      • getReverseCallback

        public ReverseCallback getReverseCallback()
        Returns the user callback that sets the reversed order of tick labels.
        Returns:
        the user callback that sets the reversed order of tick labels.
      • setReverse

        public void setReverse​(ReverseCallback reverseCallback)
        Sets the user callback that sets the reversed order of tick labels.
        Parameters:
        reverseCallback - the user callback that sets the reversed order of tick labels.
      • setReverse

        public void setReverse​(NativeCallback reverseCallback)
        Sets the user callback that sets the reversed order of tick labels.
        Parameters:
        reverseCallback - that sets the reversed order of tick labels.
      • getAlignToPixelsCallback

        public AlignToPixelsCallback getAlignToPixelsCallback()
        Returns the user callback that sets true to align pixel values to device pixels.
        Returns:
        the user callback that sets true to align pixel values to device pixels.
      • setAlignToPixels

        public void setAlignToPixels​(AlignToPixelsCallback alignToPixelsCallback)
        Sets the user callback that sets true to align pixel values to device pixels.
        Parameters:
        alignToPixelsCallback - the user callback that sets true to align pixel values to device pixels.
      • setAlignToPixels

        public void setAlignToPixels​(NativeCallback alignToPixelsCallback)
        Sets the user callback that sets true to align pixel values to device pixels.
        Parameters:
        alignToPixelsCallback - that sets true to align pixel values to device pixels.
      • getWeightCallback

        public ScaleWeightCallback getWeightCallback()
        Returns the user callback that sets the weight used to sort the axis.
        Returns:
        the user callback that sets the weight used to sort the axis.
      • setWeight

        public void setWeight​(ScaleWeightCallback weightCallback)
        Sets the user callback that sets the weight used to sort the axis.
        Parameters:
        weightCallback - the user callback that sets the weight used to sort the axis.
      • setWeight

        public void setWeight​(NativeCallback weightCallback)
        Sets the user callback that sets the weight used to sort the axis.
        Parameters:
        weightCallback - that sets the weight used to sort the axis.
      • getAxisCalculateLabelRotationCallback

        public AxisCalculateLabelRotationCallback getAxisCalculateLabelRotationCallback()
        Returns the user callback that runs before/after tick rotation is determined.
        Returns:
        the user callback that runs before/after tick rotation is determined
      • setAxisCalculateLabelRotationCallback

        public void setAxisCalculateLabelRotationCallback​(AxisCalculateLabelRotationCallback axisCalculateLabelRotationCallback)
        Sets the user callback that runs before/after tick rotation is determined.
        Parameters:
        axisCalculateLabelRotationCallback - the the user callback that runs before/after tick rotation is determined to set
      • getAxisDataLimitsCallback

        public AxisDataLimitsCallback getAxisDataLimitsCallback()
        Returns the user callback that runs before/after data limits are determined.
        Returns:
        the user callback that runs before/after data limits are determined
      • setAxisDataLimitsCallback

        public void setAxisDataLimitsCallback​(AxisDataLimitsCallback axisDataLimitsCallback)
        Sets the user callback that runs before/after data limits are determined.
        Parameters:
        axisDataLimitsCallback - the user callback that runs before/after data limits are determined
      • getAxisDimensionsCallback

        public AxisDimensionsCallback getAxisDimensionsCallback()
        Returns the user callback that runs before/after dimensions are set.
        Returns:
        the user callback that runs before/after dimensions are set
      • setAxisDimensionsCallback

        public void setAxisDimensionsCallback​(AxisDimensionsCallback axisDimensionsCallback)
        Sets the user callback that runs before/after dimensions are set.
        Parameters:
        axisDimensionsCallback - the user callback that runs before/after dimensions are set
      • getAxisFitCallback

        public AxisFitCallback getAxisFitCallback()
        Returns the user callback that runs before/after the scale fits to the canvas.
        Returns:
        the user callback that runs before/after the scale fits to the canvas
      • setAxisFitCallback

        public void setAxisFitCallback​(AxisFitCallback axisFitCallback)
        Sets the user callback that runs before/after the scale fits to the canvas.
        Parameters:
        axisFitCallback - the user callback that runs before/after the scale fits to the canvas
      • getAxisTickToLabelConversionCallback

        public AxisTickToLabelConversionCallback getAxisTickToLabelConversionCallback()
        Returns the user callback that runs before/after ticks are converted in the strings.
        Returns:
        the user callback that runs before/after ticks are converted in the strings
      • setAxisTickToLabelConversionCallback

        public void setAxisTickToLabelConversionCallback​(AxisTickToLabelConversionCallback axisTickToLabelConversionCallback)
        Sets the user callback that runs before/after ticks are converted in the strings.
        Parameters:
        axisTickToLabelConversionCallback - the user callback that runs before/after ticks are converted in the strings
      • getAxisBuildTicksCallback

        public AxisBuildTicksCallback getAxisBuildTicksCallback()
        Returns the user callback that runs before/after of the ticks building.
        Returns:
        the user callback that runs before/after of the ticks building
      • setAxisBuildTicksCallback

        public void setAxisBuildTicksCallback​(AxisBuildTicksCallback axisBuildTicksCallback)
        Sets the user callback that runs before/after of the ticks building.
        Parameters:
        axisBuildTicksCallback - the user callback that runs before/after of the ticks building
      • getAxisUpdateCallback

        public AxisUpdateCallback getAxisUpdateCallback()
        Returns the user callback that runs before/after of the update process.
        Returns:
        the user callback that runs before/after of the update process
      • setAxisUpdateCallback

        public void setAxisUpdateCallback​(AxisUpdateCallback axisUpdateCallback)
        Sets the user callback that runs before/after of the update process.
        Parameters:
        axisUpdateCallback - the user callback that runs before/after of the update process
      • setConfiguration

        protected final void setConfiguration​(T configuration)
        Parameters:
        configuration - the configuration to set
      • getConfiguration

        protected final T getConfiguration()
        Returns the configuration element.
        Returns:
        the configuration element.
      • merge

        public final void merge​(NativeObjectContainer source,
                                String property)
        Merge a native object in the this one with a specific property name.
        This is used by plugins implementation (native java script ones) when they are not using the standard way to add plugin configuration in the options of chart.
        Parameters:
        source - native object container to add
        property - property name
      • toJSON

        public final String toJSON()
        Returns the JSON representation of the object.
        Returns:
        the JSON representation of the object.
      • loadNativeObject

        public final ChartEnvelop<NativeObject> loadNativeObject​(ChartEnvelop<NativeObject> envelop)
        Returns the native object instance inside an envelop.
        It can be called only from org.pepstock.charba.client package.
        Parameters:
        envelop - envelop instance which will contain the native object
        Returns:
        the envelop, passed as argument, loaded with the native object
      • getChart

        public final IsChart getChart()
        Returns the chart instance
        Returns:
        the chart