Logo Search packages:      
Sourcecode: wims version File versions  Download package

Color GenericGraphApplet::getColorParam ( String  paramName,
Color  defaultColor 
) [inline, protected]

Get The value of an applet parameter that specifies a color. The color can be specfied as a list of three numbers in the range 0 to 255 or by one of the standard color names ("black", "red", "blue", "green", "yellow", "cyan", "magenta", "gray", "darkgray", "lightgray", "pink", "orange", "white"). Color names are not case sensitive.

Parameters:
paramName The name of the applet parameter.
defaultColor The value to be returned if getParameter(paramName) is null or is not a valid color.

Definition at line 581 of file GenericGraphApplet.java.

References getNumericParam(), and getParameter().

                                                                       {
      String data = getParameter(paramName);
      if (data == null || data.trim().length() == 0)
         return defaultColor;
      data = data.trim();
      if (Character.isLetter(data.charAt(0))) {
         for (int i = 0; i < colorNames.length; i++)
            if (data.equalsIgnoreCase(colorNames[i]))
               return colors[i];
         return defaultColor;
      }
      else {
         double[] nums = getNumericParam(paramName,null);
         if (nums == null || nums.length < 3)
            return defaultColor;
         if (nums[0] < 0 || nums[0] > 255 || nums[1] < 0 || nums[1] > 255 || nums[2] < 0 || nums[2] > 255)
            return defaultColor;
         return new Color((int)Math.round(nums[0]), (int)Math.round(nums[1]), (int)Math.round(nums[2]));
      }
   }


Generated by  Doxygen 1.6.0   Back to index