Class SparklineParameters


  • public class SparklineParameters
    extends Object
    Sparkline rendering settings:
    • Width and height of the graphic in pixels
    • Line color. Blue by default if null
    • Optional area color under the line, no area by default
    • Color for the background of the graphic. White by default if null
    • Highlight colors with a dot for min and max values, null (no highlight) by default
    • Highlight colors with a dot for a value closest to the given x pixel position(highlightedValueXPosition), magenta by default if null and highlightedValueXPosition is not null
    • Highlighted value text color, used if highlightedValueXPosition is provided. By default (x,y) values are shown, use highlightTextMode to control this.
    • Highlighted value text box color, used if highlightedValueXPosition and highlightTextColor are provided
    Several constructors are provided for various use cases.
    Author:
    Eduardo Ramos
    See Also:
    SparklineGraph
    • Field Detail

      • DEFAULT_LINE_COLOR

        public static final Color DEFAULT_LINE_COLOR
      • DEFAULT_AREA_COLOR

        public static final Color DEFAULT_AREA_COLOR
      • DEFAULT_BACKGROUND_COLOR

        public static final Color DEFAULT_BACKGROUND_COLOR
      • DEFAULT_HIGHLIGHT_VALUE_COLOR

        public static final Color DEFAULT_HIGHLIGHT_VALUE_COLOR
      • DEFAULT_TEXT_COLOR

        public static final Color DEFAULT_TEXT_COLOR
      • DEFAULT_TEXT_BOX_COLOR

        public static final Color DEFAULT_TEXT_BOX_COLOR
      • width

        private int width
      • height

        private int height
      • lineColor

        private Color lineColor
      • areaColor

        private Color areaColor
      • backgroundColor

        private Color backgroundColor
      • transparentBackground

        private boolean transparentBackground
      • drawArea

        private boolean drawArea
      • highlightMinColor

        private Color highlightMinColor
      • highlightMaxColor

        private Color highlightMaxColor
      • highlightedValueXPosition

        private Integer highlightedValueXPosition
      • highligtValueColor

        private Color highligtValueColor
      • highlightTextColor

        private Color highlightTextColor
      • highlightTextBoxColor

        private Color highlightTextBoxColor
    • Constructor Detail

      • SparklineParameters

        public SparklineParameters​(int width,
                                   int height)
        Create a simple sparkline parameters with only lines
        Parameters:
        width - Width in pixels
        height - Height in pixels
      • SparklineParameters

        public SparklineParameters​(int width,
                                   int height,
                                   Color lineColor)
        Create a simple sparkline parameters with only lines and a specific line color
        Parameters:
        width - Width in pixels
        height - Height in pixels
        lineColor - Lines color
      • SparklineParameters

        public SparklineParameters​(int width,
                                   int height,
                                   Color lineColor,
                                   Color backgroundColor)
        Create a simple sparkline parameters with only lines and a specific line color and background color
        Parameters:
        width - Width in pixels
        height - Height in pixels
        lineColor - Lines color
        backgroundColor - Background color
      • SparklineParameters

        public SparklineParameters​(int width,
                                   int height,
                                   Color lineColor,
                                   Color backgroundColor,
                                   Color highlightMinColor,
                                   Color highlightMaxColor)
        Create a sparkline parameters specifying colors for line, background, and max/min highlight colors (no highlight if null)
        Parameters:
        width - Width in pixels
        height - Height in pixels
        lineColor - Lines color
        backgroundColor - Background color
        highlightMinColor - Min value highlight color or null
        highlightMaxColor - Max value highlight color or null
      • SparklineParameters

        public SparklineParameters​(int width,
                                   int height,
                                   Color lineColor,
                                   Color backgroundColor,
                                   Color highlightMinColor,
                                   Color highlightMaxColor,
                                   Integer highlightedValueXPosition)
        Create a sparkline parameters specifying colors for line, background, and max/min highlight colors (no highlight if null) and a x pixel position to highlight closest value with default highlight text and text box colors and default HighlightTextMode.
        Parameters:
        width - Width in pixels
        height - Height in pixels
        lineColor - Lines color
        backgroundColor - Background color
        highlightMinColor - Min value highlight color or null
        highlightMaxColor - Max value highlight color or null
        highlightedValueXPosition - X position in pixels to find closest value in the sparkline
      • SparklineParameters

        public SparklineParameters​(int width,
                                   int height,
                                   Color lineColor,
                                   Color backgroundColor,
                                   Color highlightMinColor,
                                   Color highlightMaxColor,
                                   Integer highlightedValueXPosition,
                                   Color highligtValueColor,
                                   Color highlightTextColor,
                                   Color highlightTextBoxColor,
                                   SparklineParameters.HighlightTextMode highlightTextMode)
        Create a sparkline parameters specifying colors for line, background, and max/min highlight colors (no highlight if null) and a x pixel position to highlight closest value with specific highlight text and text box colors and HighlightTextMode.
        Parameters:
        width - Width in pixels
        height - Height in pixels
        lineColor - Lines color
        backgroundColor - Background color
        highlightMinColor - Min value highlight color or null
        highlightMaxColor - Max value highlight color or null
        highlightedValueXPosition - X position in pixels to find closest value in the sparkline
        highligtValueColor - Highlighted value color (Magenta if null)
        highlightTextColor - Highlighted value text color or null
        highlightTextBoxColor - Highlighted value text box color or null
        highlightTextMode - What to show on the highlight text (x and/or y values)
    • Method Detail

      • getBackgroundColor

        public Color getBackgroundColor()
        Returns current background color.
        Returns:
        Current background color
      • setBackgroundColor

        public void setBackgroundColor​(Color backgroundColor)
        Set background color. If null and transparent background is not enabled, white will be used by default.
        Parameters:
        backgroundColor - New background color
      • getHeight

        public int getHeight()
        Returns current height for the sparkline in pixels.
        Returns:
        Current height for the sparkline in pixels
      • setHeight

        public void setHeight​(int height)
        Set height for the sparkline in pixels.
        Parameters:
        height - Height in pixels
      • getHighlightTextBoxColor

        public Color getHighlightTextBoxColor()
        Returns current color for the highlighted value text bounding box.
        Returns:
        Current highlightTextBoxColor
      • setHighlightTextBoxColor

        public void setHighlightTextBoxColor​(Color highlightTextBoxColor)
        Set color for the highlighted value text bounding box, or null to draw no box. Used only if highlightedValueXPosition is not null.
        Parameters:
        highlightTextBoxColor - New highlightTextBoxColor or null
      • getHighlightTextColor

        public Color getHighlightTextColor()
        Returns current color for the highlighted value text.
        Returns:
        Current highlightTextColor
      • setHighlightTextColor

        public void setHighlightTextColor​(Color highlightTextColor)
        Set color for the highlighted value text, or null to draw no text. Used only if highlightedValueXPosition is not null.
        Parameters:
        highlightTextColor - New highlightTextColor or null
      • getHighligtValueColor

        public Color getHighligtValueColor()
        Returns current color for the highlighted value.
        Returns:
        Current highligtValueColor
      • setHighligtValueColor

        public void setHighligtValueColor​(Color highligtValueColor)
        Set color for the value highlight, magenta is used if it is null. Used only if highlightedValueXPosition is not null.
        Parameters:
        highligtValueColor - New highligtValueColor
      • getHighlightMaxColor

        public Color getHighlightMaxColor()
        Returns current highlightMaxColor.
        Returns:
        Current highlightMaxColor
      • setHighlightMaxColor

        public void setHighlightMaxColor​(Color highlightMaxColor)
        Set color for the maximum value highlight, or null to draw no highlight.
        Parameters:
        highlightMaxColor - New highlightMaxColor
      • getHighlightMinColor

        public Color getHighlightMinColor()
        Returns current highlightMinColor.
        Returns:
        Current highlightMinColor
      • setHighlightMinColor

        public void setHighlightMinColor​(Color highlightMinColor)
        Set color for the minimum value highlight, or null to draw no highlight.
        Parameters:
        highlightMinColor - New highlightMinColor
      • getHighlightedValueXPosition

        public Integer getHighlightedValueXPosition()
        Returns current X position for highlighting the closest value.
        Returns:
        Current highlightedValueXPosition in pixels
      • setHighlightedValueXPosition

        public void setHighlightedValueXPosition​(Integer highlightedValueXPosition)

        Set a X position in pixels to find closest value in the sparkline and highlight it.

        If null or out of the sparkline width range, no value is highlighted.

        Parameters:
        highlightedValueXPosition - New highlightedValueXPosition in pixels
      • getLineColor

        public Color getLineColor()
        Returns current color for the sparkline line.
        Returns:
        Current line color
      • setLineColor

        public void setLineColor​(Color lineColor)
        Set color for the sparkline line. If null, blue will be used by default.
        Parameters:
        lineColor - New lineColor
      • getWidth

        public int getWidth()
        Returns current width for the sparkline in pixels.
        Returns:
        Current width for the sparkline in pixels
      • setWidth

        public void setWidth​(int width)
        Set width for the sparkline in pixels.
        Parameters:
        width - width in pixels
      • isTransparentBackground

        public boolean isTransparentBackground()
        Checks if transparent background is enabled.
        Returns:
        transparent background enabled
      • setTransparentBackground

        public void setTransparentBackground​(boolean transparentBackground)
        Set transparent background. If true, background color is ignored and no background is drawn.
        Parameters:
        transparentBackground - transparent background enabled
      • getAreaColor

        public Color getAreaColor()
        Returns current areaColor.
        Returns:
        Current areaColor
      • setAreaColor

        public void setAreaColor​(Color areaColor)
        Set color to fill the area under the line. If null, semi-transparent default line color will be used. Used only if draw area is enabled.
        Parameters:
        areaColor - New areaColor
      • isDrawArea

        public boolean isDrawArea()
        Checks if the area under the line is enabled.
        Returns:
        draw area enabled
      • setDrawArea

        public void setDrawArea​(boolean drawArea)
        Set draw area. If true, the area under the line is filled with areaColor.
        Parameters:
        drawArea - draw area enabled