Class ColorTableDefaults

java.lang.Object
ucar.unidata.ui.colortable.ColorTableDefaults

public class ColorTableDefaults extends Object
A class to provide color tables suitable for data displays. Uses some code by Ugo Taddei. All methods are static.
Version:
$Id: ColorTableDefaults.java,v 1.15 2007/05/04 19:56:06 jeffmc Exp $
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    The name of the "default" color table
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static final float[][]
    Make a color table representing this color.
    static final float[][]
    allOneColor(Color color, boolean addAlpha)
    Make a color table representing this color.
    static final float[][]
    Make 12 color bright spectrum; blue (lo) to red (hi)
    static final float[][]
    Make 14 color bright spectrum; blue (lo) to red (hi)
    static final float[][]
    Make 16 color bright spectrum; blue (lo) to red (hi)
    static final float[][]
    Make a 38-color bright spectrum; blue (low values) to red (high values).
    static ColorTable
    createColorTable(String name, String category, float[][] table)
    Create a ColorTable and add it to the given list
    static ColorTable
    createColorTable(ArrayList l, String name, String category, float[][] table)
    Create a ColorTable and add it to the given list
    static ColorTable
    createColorTable(ArrayList l, String name, String category, float[][] table, boolean tableFlipped)
    Create a ColorTable and add it to the given list
    static ColorTable
    createColorTable(ArrayList l, String name, String category, float[][] table, boolean tableFlipped, Range range)
    Create a ColorTable and add it to the given list
    static ArrayList
    Create the default color tables
    static final float[][]
    DZ1()
    Make a color table for radar reflectivity as close as possible to the one used by the NWS in their web page displays of same.
    static final float[][]
    DZ2()
    A 2nd color table for radar reflectivity, better than DZ1 for VisAD.
    static final float[][]
    grayTable(int numColors, boolean inverse)
    Make a color table ranging from black to white; linear changes in RGB amounts.
    static final float[][]
    grayTable1(int len)
    Make a color table ranging from black to white; linear changes in RGB amounts.
    static final float[][]
    invRainbow(int len)
    Make the standard VisAD inverse rainbow (red to blue) table with definable length; created by by Ugo Taddei.
    static void
    main(String[] args)
    Main method
    static List
    makeAwips2ColorTables(String name, String category, String file)
    Convert a AWIPS II ".cmap" file to an IDV ColorTable and add the new color table to the ColorTableManager.
    static List
    makeGempakColorTables(String name, String category, String file)
    Make GEMPAK color tables
    static List
    makeNclRgbColorTables(String name, String cat, String file, String contents)
    Make ColorTables from NCAR Command Language (NCL) RGB files
    static List
    Make color tables from RGB files
    static List
    makeRgbColorTables(String name, String cat, String file, List lines, String delimiter)
    Make color tables from RGB tuples in a file
    static final float[][]
    Read in and process the act color table
    static final float[][]
    Read in and process the mcidas color table
    static final float[][]
    makeTableFromET(String name, boolean fromAuxdata)
    Read in and process the mcidas color table
    static final float[][]
    Read in and process the pal color table
    static final float[][]
    Read in and process the pal1 color table
    static final float[][]
    Read in and process the pal2 color table
    static final float[][]
    percentBlue(int len)
    Make a color table ranging from white to dark blue, typically for parms with 0 to 100%.
    static final float[][]
    Make a color table ranging from yellow to blue, through green; typically for parms with values spanning 0 to 100 %.
    static final float[][]
    Make a color table ranging from yellow to dark blue, typically for parms with 0 to 100%.
    static final float[][]
    Make The first standard Unidata MetApps liquid precip amount color table.
    static final float[][]
    rainbow(int len)
    Make the standard VisAD rainbow (blue lo to red high) color table with definable length.
    static final float[][]
    Make the first temperature color table.
    static final float[][]
    Make a bright temperature spectrum; blue (lo) to red (hi) 5 deg C steps or bands; some duplicate colors below 0 Length is fixed at 21 for now.
    static final float[][]
    Make a third temperature spectrum; NEEDS WORK setRange() to -55 to 50 Celsius
    static final float[][]
    Make the fourth temperature color table.
    static final float[][]
    Provide a color table suitable for topography
    static final float[][]
    make the nominal wind speed color table, based on color table temperatureCT4.
    static final float[][]
    windSpeed(int len)
    Make a color table ranging from white to dark blue (negatives); white to green going 0 to large positive.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • ColorTableDefaults

      public ColorTableDefaults()
  • Method Details

    • createColorTable

      public static ColorTable createColorTable(String name, String category, float[][] table)
      Create a ColorTable and add it to the given list
      Parameters:
      name - The CT name
      category - Its category
      table - The actual data
      Returns:
      The color table
    • createColorTable

      public static ColorTable createColorTable(ArrayList l, String name, String category, float[][] table)
      Create a ColorTable and add it to the given list
      Parameters:
      l - List to add the ColorTable to
      name - The CT name
      category - Its category
      table - The actual data
      Returns:
      The color table
    • createColorTable

      public static ColorTable createColorTable(ArrayList l, String name, String category, float[][] table, boolean tableFlipped)
      Create a ColorTable and add it to the given list
      Parameters:
      l - List to add the ColorTable to
      name - The CT name
      category - Its category
      table - The actual data
      tableFlipped - If true then the table data is not in row major order
      Returns:
      The color table
    • createColorTable

      public static ColorTable createColorTable(ArrayList l, String name, String category, float[][] table, boolean tableFlipped, Range range)
      Create a ColorTable and add it to the given list
      Parameters:
      l - List to add the ColorTable to
      name - The CT name
      category - Its category
      table - The actual data
      tableFlipped - If true then the table data is not in row major order
      range - the color table range
      Returns:
      The color table
    • createColorTables

      public static ArrayList createColorTables()
      Create the default color tables
      Returns:
      List of color tables
    • rainbow

      public static final float[][] rainbow(int len) throws IllegalArgumentException
      Make the standard VisAD rainbow (blue lo to red high) color table with definable length.
      Parameters:
      len - length; how many entries desired in the color table.
      Returns:
      float[3][len] the color table
      Throws:
      IllegalArgumentException - from construction of VisAd objects
    • temperatureCT1

      public static final float[][] temperatureCT1() throws IllegalArgumentException
      Make the first temperature color table. Pale blue to dark blue in lower bins, for below 0 C or 273.15 Kelvin; white thru yellow, orange, red-orange to red in upper bins over 0 C to 50C. designed for 5-degrees-wide Celcius bands. SHOULD do scalarMap.setRange -85 to +50 Celsius.
      Returns:
      float[3][27] the color table
      Throws:
      IllegalArgumentException - from construction of VisAd objects
    • temperatureCT4

      public static final float[][] temperatureCT4() throws IllegalArgumentException
      Make the fourth temperature color table. This is notably better than temperature color tables CT1, CT2, or CT3. SHOULD also set the data's scalarMap.setRange -90 to +45 Celsius. for temperature to lock blue transition to freezing point. also happens to make a good color table for wind speed 0 to 60 m/s or so.
      Returns:
      float[3][135] the color table
      Throws:
      IllegalArgumentException - from construction of VisAd objects
    • temperatureCT2

      public static final float[][] temperatureCT2()
      Make a bright temperature spectrum; blue (lo) to red (hi) 5 deg C steps or bands; some duplicate colors below 0 Length is fixed at 21 for now. setRange() to -55 to 50 Celsius This looks better than tempCT1 in VisAD 3D surfaces; worse in 2D.
      Returns:
      float[3][21] the color table
    • temperatureCT3

      public static final float[][] temperatureCT3()
      Make a third temperature spectrum; NEEDS WORK setRange() to -55 to 50 Celsius
      Returns:
      float[2][21] the color table
    • precipCT1

      public static final float[][] precipCT1() throws IllegalArgumentException
      Make The first standard Unidata MetApps liquid precip amount color table. Pale blue to dark blue to green to yellow, to orange, to red-orange to red. Length 100. SHOULD also do Contour2DDisplayable::setRangeforColor(0.0, 25.0) so that first color band (above black) starts at 25/100 = 0.25.
      Returns:
      float[3][100] the color table
      Throws:
      IllegalArgumentException - from construction of VisAd objects
    • invRainbow

      public static final float[][] invRainbow(int len) throws IllegalArgumentException
      Make the standard VisAD inverse rainbow (red to blue) table with definable length; created by by Ugo Taddei.
      Parameters:
      len - length; how many entries desired in the color table.
      Returns:
      float[3][len] the color table
      Throws:
      IllegalArgumentException - from construction of VisAd objects
    • percentBlue

      public static final float[][] percentBlue(int len) throws IllegalArgumentException
      Make a color table ranging from white to dark blue, typically for parms with 0 to 100%. setRange of values 0.0 to 100.0 Used for relative humidity, probability of precip (rain, snow); fog.
      Parameters:
      len - length; how many entries desired in the color table.
      Returns:
      float[3][len] the color table
      Throws:
      IllegalArgumentException - from construction of VisAd objects
    • grayTable

      public static final float[][] grayTable(int numColors, boolean inverse) throws IllegalArgumentException
      Make a color table ranging from black to white; linear changes in RGB amounts.
      Parameters:
      numColors - number of descrete colors for the table
      inverse - true for white to black instead of black to white
      Returns:
      float[3][len] the color table
      Throws:
      IllegalArgumentException - from construction of VisAd objects
    • grayTable1

      public static final float[][] grayTable1(int len) throws IllegalArgumentException
      Make a color table ranging from black to white; linear changes in RGB amounts. Offset; begins at X gray25, RGB = 64, 64, 64 out of 255
      Parameters:
      len - length; how many entries desired in the color table.
      Returns:
      float[3][len] the color table
      Throws:
      IllegalArgumentException - from construction of VisAd objects
    • percentYellowBlue

      public static final float[][] percentYellowBlue(int len) throws IllegalArgumentException
      Make a color table ranging from yellow to dark blue, typically for parms with 0 to 100%. setRange of values 0.0 to 100.0 Can use for relative humidity, probability of precip. Problem: 50% RH color is dull grey; see percentYelGrnBlue()
      Parameters:
      len - length; how many entries desired in the color table.
      Returns:
      float[3][len] the color table
      Throws:
      IllegalArgumentException - from construction of VisAd objects
    • percentYelGrnBlue

      public static final float[][] percentYelGrnBlue(int len) throws IllegalArgumentException
      Make a color table ranging from yellow to blue, through green; typically for parms with values spanning 0 to 100 %. setRange of values 0.0 to 100.0. Can use for relative humidity, probability of precip, etc. Espcially good where a higher percewnt is associated with mnore moisture.
      Parameters:
      len - length; how many entries desired in the color table.
      Returns:
      float[3][len] the color table
      Throws:
      IllegalArgumentException - from construction of VisAd objects
    • windSpeed

      public static final float[][] windSpeed(int len) throws IllegalArgumentException
      Make a color table ranging from white to dark blue (negatives); white to green going 0 to large positive. center SetRange of values on 0.0 for proper alignment with colors. Used for speed of wind components u and v, which can have negative speeds.
      Parameters:
      len - length; how many entries desired in the color table.
      Returns:
      float[3][len] the color table
      Throws:
      IllegalArgumentException - from construction of VisAd objects
    • bright38

      public static final float[][] bright38()
      Make a 38-color bright spectrum; blue (low values) to red (high values). These are close to or at the brightest possible colors. Good for general purpose with higher values needing warmer colors.
      Returns:
      float[3][38] the color table
    • bright16

      public static final float[][] bright16()
      Make 16 color bright spectrum; blue (lo) to red (hi)
      Returns:
      float[3][16] the color table
    • bright14

      public static final float[][] bright14()
      Make 14 color bright spectrum; blue (lo) to red (hi)
      Returns:
      float[3][14] the color table
    • bright12

      public static final float[][] bright12()
      Make 12 color bright spectrum; blue (lo) to red (hi)
      Returns:
      float[3][12] the color table
    • topographyCT

      public static final float[][] topographyCT()
      Provide a color table suitable for topography
      Returns:
      float[3][256] the color table
    • allOneColor

      public static final float[][] allOneColor(Color color)
      Make a color table representing this color.
      Parameters:
      color - color to use
      Returns:
      the color table this color
    • allOneColor

      public static final float[][] allOneColor(Color color, boolean addAlpha)
      Make a color table representing this color.
      Parameters:
      color - color to use
      addAlpha - true to add an alpha channel
      Returns:
      the color table this color
    • DZ1

      public static final float[][] DZ1()
      Make a color table for radar reflectivity as close as possible to the one used by the NWS in their web page displays of same. It turns out that this color table used in VisAD makes a crummy appearence (due to VisAD blurring colors between values?). Smoother transistions of color do much better in VisAD displays, such as in color table DZ2 below. for data displayed, setRange() 0 to 80 (dbz); 16 bins
      Returns:
      float[3][16] the color table
    • DZ2

      public static final float[][] DZ2()
      A 2nd color table for radar reflectivity, better than DZ1 for VisAD. for data displayed, setRange() -10.0 to 60.0 (dbz); 16 bins. by Stu Wier.
      Returns:
      float[3][16] the color table
    • windspeed

      public static final float[][] windspeed() throws IllegalArgumentException
      make the nominal wind speed color table, based on color table temperatureCT4. set the data's scalarMap.setRange from 0.0 to say 70 or 80.0 m/s
      Returns:
      float[3][70] the color table
      Throws:
      IllegalArgumentException - from construction of VisAd objects
    • makeTableFromET

      public static final float[][] makeTableFromET(String name) throws IllegalArgumentException
      Read in and process the mcidas color table
      Parameters:
      name - File name
      Returns:
      The processed CT data
      Throws:
      IllegalArgumentException
    • makeTableFromET

      public static final float[][] makeTableFromET(String name, boolean fromAuxdata) throws IllegalArgumentException
      Read in and process the mcidas color table
      Parameters:
      name - File name
      fromAuxdata - Is this file from the auxdata dir
      Returns:
      The processed CT data
      Throws:
      IllegalArgumentException - When bad things happen
    • makeTableFromPal1

      public static final float[][] makeTableFromPal1(String name) throws IOException
      Read in and process the pal1 color table
      Parameters:
      name - File name
      Returns:
      The processed CT data
      Throws:
      IOException - On badness
    • makeTableFromPal2

      public static final float[][] makeTableFromPal2(String name) throws IOException
      Read in and process the pal2 color table
      Parameters:
      name - File name
      Returns:
      The processed CT data
      Throws:
      IOException - On badness
    • makeGempakColorTables

      public static List makeGempakColorTables(String name, String category, String file)
      Make GEMPAK color tables
      Parameters:
      name - name of the table
      category - the category
      file - the file to read
      Returns:
      a list of colors in the table (why a list, I don't know)
    • main

      public static void main(String[] args) throws Exception
      Main method
      Parameters:
      args - arguments
      Throws:
      Exception - something bad happened
    • makeNclRgbColorTables

      public static List makeNclRgbColorTables(String name, String cat, String file, String contents) throws IOException
      Make ColorTables from NCAR Command Language (NCL) RGB files
      Parameters:
      name - name of table
      cat - category
      file - the file
      contents - the file contents
      Returns:
      the color table in a List
      Throws:
      IOException - problem opening file
    • makeRgbColorTables

      public static List makeRgbColorTables(String name, String cat, String file, List lines, String delimiter)
      Make color tables from RGB tuples in a file
      Parameters:
      name - the name of the color table
      cat - the category
      file - the file to read
      lines - the lines
      delimiter - the rgb tuple delimiters
      Returns:
      the color table in a list
    • makeRgbColorTables

      public static List makeRgbColorTables(String name, String cat, String file) throws IOException
      Make color tables from RGB files
      Parameters:
      name - name of the color table
      cat - category
      file - the file to read
      Returns:
      the color table in a List
      Throws:
      IOException - problem reading the file
    • makeTableFromAct

      public static final float[][] makeTableFromAct(String name) throws IOException
      Read in and process the act color table
      Parameters:
      name - File name
      Returns:
      The processed CT data
      Throws:
      IOException - On badness
    • makeTableFromPal

      public static final float[][] makeTableFromPal(String name) throws IOException
      Read in and process the pal color table
      Parameters:
      name - File name
      Returns:
      The processed CT data
      Throws:
      IOException - On badness
    • makeAwips2ColorTables

      public static List makeAwips2ColorTables(String name, String category, String file)
      Convert a AWIPS II ".cmap" file to an IDV ColorTable and add the new color table to the ColorTableManager.
      Parameters:
      name - Name to use in the color table manager.
      category - Category of the color table.
      file - Path to AWIPS II ".cmap" file.
      Returns:
      Either a List containing the newly created ColorTable or null if the conversion failed.