psdi.webclient.beans.common

Class ChartUtil

  • java.lang.Object
    • psdi.webclient.beans.common.ChartUtil


  • public class ChartUtil
    extends java.lang.Object
    This class contains utility methods for building graphs on the fly.
    • Constructor Summary

      Constructors 
      Constructor and Description
      ChartUtil() 
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      java.util.Vector computeTics(double minVal, double maxVal, int maxTicks, double step)
      This method takes axis range parameters and produces a list of string representations of rounded numbers within the given range.
      java.awt.Color decodeColor(java.lang.String hexValue)
      Decodes color based ona hex value
      java.lang.String formatNum(double number, int numfracdigits)
      Return a string for displaying the specified number using the specified number of digits after the decimal point.
      java.lang.String formatNumber(double dNumber, java.util.Locale userLocale)
      Format the number to make it upto 2 decimal places in fraction and remove trailing zeros
      java.lang.String getChartFont(WebClientSession sc)
      Returns the font to be used in the graph from the resource file
      static ChartUtil getChartUtil()
      Returns the static instance of this class.
      java.lang.String getDefaultColor()
      Get default color
      java.util.Properties getKPIChartColors(WebClientSession wcs)
      Returns a property set as a colors to be used in KPI dial and bar chart
      java.lang.String[] getKPITrendChartColors(WebClientSession wcs)
      Returns string array of colors to be used in KPI trend chart
      java.lang.String[] getResultSetChartColors(WebClientSession wcs)
      Returns string array of colors to be used in KPI trend chart
      void loadChartPropertiesDOM()
      Reads from chartpropreties configuration file and for every chart type loads color info.
      double log(double value, int base)
      Returns log for a given base
      java.lang.String makeColorTableString(java.lang.String[] colorTable)
      Makes color table string for CDL inside the class
      int numberOfDigits(double value, java.util.Locale userLocale)
      Returns number of integer digits in a number
      int numFracDigits(double number)
      Return the number of fractional digits required to display the given number.
      double roundDown(double val) 
      double roundUp(double val)
      Given a number, round up to the nearest power of ten times 1, 2, or 5.
      double roundUpWithLog(double val)
      Given a number, round up to the nearest power of ten times 1, 2, or 5.
      double tic(double minVal, double maxVal, int maxTicks)
      Return the Tic step calculated dynamically
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ChartUtil

        public ChartUtil()
    • Method Detail

      • roundUp

        public double roundUp(double val)
        Given a number, round up to the nearest power of ten times 1, 2, or 5.
        Parameters:
        val - Value to be rounded
      • roundUpWithLog

        public double roundUpWithLog(double val)
        Given a number, round up to the nearest power of ten times 1, 2, or 5.
        Parameters:
        val - Value to be rounded
      • roundDown

        public double roundDown(double val)
      • log

        public double log(double value,
                          int base)
        Returns log for a given base
        Parameters:
        double - - Value to get log of
        int - - base of the log
        Returns:
        logvalue
      • formatNum

        public java.lang.String formatNum(double number,
                                          int numfracdigits)
        Return a string for displaying the specified number using the specified number of digits after the decimal point.
        Parameters:
        double - - Number to format
        int - - Digits after decimal point
      • numFracDigits

        public int numFracDigits(double number)
        Return the number of fractional digits required to display the given number. If number goes larger than 15 is returned).
        Parameters:
        double - - Number to find the fractions in
        Returns:
        int - number of fractional digits
      • computeTics

        public java.util.Vector computeTics(double minVal,
                                            double maxVal,
                                            int maxTicks,
                                            double step)
        This method takes axis range parameters and produces a list of string representations of rounded numbers within the given range. these strings are intended for use as axis tic labels.
        Parameters:
        double - - no tics will be created for less than this value.
        double - - maxVal no tics will be created for greater than this value.
        int - - returned vector will contain no more labels than this number.
        double - - step value between tics
        Returns:
        a Vector containing formatted label strings which should also
      • tic

        public double tic(double minVal,
                          double maxVal,
                          int maxTicks)
        Return the Tic step calculated dynamically
        Parameters:
        double - - no tics will be created for less than this value.
        double - - no tics will be created for greater than this value.
        int - - returned vector that will contain no more labels than this number.
        Returns:
        double - tic step
      • getChartFont

        public java.lang.String getChartFont(WebClientSession sc)
        Returns the font to be used in the graph from the resource file
        Returns:
        String - font name ot be used in chart
      • numberOfDigits

        public int numberOfDigits(double value,
                                  java.util.Locale userLocale)
        Returns number of integer digits in a number
        Parameters:
        double - - number in which digits have to be counted
        Returns:
        int - the number of integer digits
      • getKPITrendChartColors

        public java.lang.String[] getKPITrendChartColors(WebClientSession wcs)
        Returns string array of colors to be used in KPI trend chart
        Parameters:
        wcs - Webclientsession
        Returns:
        String[] array of hex values as strings
      • getKPIChartColors

        public java.util.Properties getKPIChartColors(WebClientSession wcs)
        Returns a property set as a colors to be used in KPI dial and bar chart
        Parameters:
        wcs - Webclientsession
        Returns:
        Properties colors mapped to different types, warning, good, alert etc
      • getResultSetChartColors

        public java.lang.String[] getResultSetChartColors(WebClientSession wcs)
        Returns string array of colors to be used in KPI trend chart
        Parameters:
        wcs - Webclientsession
        Returns:
        String[] array of hex values as strings
      • getChartUtil

        public static ChartUtil getChartUtil()
        Returns the static instance of this class. No need to create new instances.
        Returns:
        ChartUtil
      • loadChartPropertiesDOM

        public void loadChartPropertiesDOM()
        Reads from chartpropreties configuration file and for every chart type loads color info. This may be improved in future to use more properties
      • decodeColor

        public java.awt.Color decodeColor(java.lang.String hexValue)
        Decodes color based ona hex value
        Parameters:
        hexValue - String
        Returns:
        bColor as Color
      • makeColorTableString

        public java.lang.String makeColorTableString(java.lang.String[] colorTable)
        Makes color table string for CDL inside the class
        Parameters:
        colorTable - as String[]
      • getDefaultColor

        public java.lang.String getDefaultColor()
        Get default color
      • formatNumber

        public java.lang.String formatNumber(double dNumber,
                                             java.util.Locale userLocale)
        Format the number to make it upto 2 decimal places in fraction and remove trailing zeros
        Parameters:
        dNumber - double to perform function on
        Returns:
        sNumber string representation of dNumber