ucar.unidata.ui.colortable
Class ColorTableManager

java.lang.Object
  extended by ucar.unidata.util.ResourceManager
      extended by ucar.unidata.ui.colortable.ColorTableManager

public class ColorTableManager
extends ResourceManager

A class to manage a collection of system and user color tables

Version:
$Id: ColorTableManager.java,v 1.25 2007/06/15 19:34:38 jeffmc Exp $
Author:
Metapps Development Team

Field Summary
static PatternFileFilter FILTER_ACT
          File filter used for ACT color tables
static PatternFileFilter FILTER_GEM
          File filter used for Gempak color tables
static PatternFileFilter FILTER_IDV
          File filter used for IDV color tables
static PatternFileFilter FILTER_MCI
          File filter used for McIdas color tables
static PatternFileFilter FILTER_PAL
          File filter used for PAL color tables
static String NAME_DEFAULT
          THe name of the default color table
static String PROP_CANCEL
          The cancel property for PropertyChangeListeners
static String PROP_CLOSE
          The close property for PropertyChangeListeners
static String PROP_COLORTABLE
          The color table property for PropertyChangeListeners
static String PROP_RANGE
          The range property for PropertyChangeListeners
 String TAG_COLORTABLE
          Xml tag name
 String TAG_COLORTABLES
          Xml tag name
 String TAG_NAME
          Xml tag name
 
Fields inherited from class ucar.unidata.util.ResourceManager
listOfResourceLists, log_, LU, nameToObject, PROP_RESOURCECHANGE, PROP_RESOURCEREMOVE, resources, usersList, writablePath
 
Constructor Summary
ColorTableManager()
          Create me
 
Method Summary
 NamedObject doImport(boolean makeUnique)
          Import a color table
 ColorTableEditor edit(ColorTable colorTable, PropertyChangeListener listener)
          Create a ColorTableEditor for editing the given color table
 List getCategories()
          Return a list (String) of the categories defined by the color tables
 ColorTable getColorTable(String name)
          Lookup and return the color table identified by the given name
 List getColorTables()
          Return a list of all ColorTable objects
 ColorTable getDefaultColorTable()
          Find and return the default color table
protected  String getExportContents(NamedObject object, String file)
          When we do an export this method is called to create the String contents that is actually written out.
 JLabel getLabel(String colorTableName)
           
static ColorTableManager getManager()
          Get the singleton
 List getReadFileFilters()
          Return the file filters used for writing a file on an import
 String getTitle()
          Overwrite the base class (ResourceManager) method to return the name of the resource we deal with.
 List getWriteFileFilters()
          Return the file filters used for writing a file on an export
protected  Object initResource(ResourceCollection resources, int index)
          Check to see if these are any of the special resources
static void main(String[] args)
          Merge the programmaticcally created color tables with the ones given on the command line.
 void makeColorTableMenu(ObjectListener listener, List l)
          Make the set of color table menus.
 void makeColorTableMenu(ObjectListener listener, List l, boolean showLocal)
          Make the set of color table menus.
static void setManager(ColorTableManager theManager)
          set the singleton manager
 
Methods inherited from class ucar.unidata.util.ResourceManager
addPropertyChangeListener, addUsers, doExport, doExport, doImport, doImport, doNew, doNew, doNew, doSaveAs, firePropertyChange, firePropertyChange, getDefault, getEncoder, getFileFilters, getFileSuffix, getObject, getResources, getResourceTimestamp, getUsersIndex, getUsersObject, hasUsers, init, initDone, isUsers, processObject, reloadResources, removePropertyChangeListener, removeUsers, resourceExists, shouldWeIgnoreThisXml, toObject, toObject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NAME_DEFAULT

public static final String NAME_DEFAULT
THe name of the default color table

See Also:
Constant Field Values

PROP_COLORTABLE

public static final String PROP_COLORTABLE
The color table property for PropertyChangeListeners

See Also:
Constant Field Values

PROP_RANGE

public static final String PROP_RANGE
The range property for PropertyChangeListeners

See Also:
Constant Field Values

PROP_CANCEL

public static final String PROP_CANCEL
The cancel property for PropertyChangeListeners

See Also:
Constant Field Values

PROP_CLOSE

public static final String PROP_CLOSE
The close property for PropertyChangeListeners

See Also:
Constant Field Values

TAG_COLORTABLES

public String TAG_COLORTABLES
Xml tag name


TAG_COLORTABLE

public String TAG_COLORTABLE
Xml tag name


TAG_NAME

public String TAG_NAME
Xml tag name


FILTER_IDV

public static final PatternFileFilter FILTER_IDV
File filter used for IDV color tables


FILTER_GEM

public static final PatternFileFilter FILTER_GEM
File filter used for Gempak color tables


FILTER_MCI

public static final PatternFileFilter FILTER_MCI
File filter used for McIdas color tables


FILTER_PAL

public static final PatternFileFilter FILTER_PAL
File filter used for PAL color tables


FILTER_ACT

public static final PatternFileFilter FILTER_ACT
File filter used for ACT color tables

Constructor Detail

ColorTableManager

public ColorTableManager()
Create me

Method Detail

setManager

public static void setManager(ColorTableManager theManager)
set the singleton manager

Parameters:
theManager - The singleton manager

getManager

public static ColorTableManager getManager()
Get the singleton

Returns:
The color table manager

getWriteFileFilters

public List getWriteFileFilters()
Return the file filters used for writing a file on an export

Overrides:
getWriteFileFilters in class ResourceManager
Returns:
Write file filters

getReadFileFilters

public List getReadFileFilters()
Return the file filters used for writing a file on an import

Overrides:
getReadFileFilters in class ResourceManager
Returns:
Read file filters

getTitle

public String getTitle()
Overwrite the base class (ResourceManager) method to return the name of the resource we deal with.

Overrides:
getTitle in class ResourceManager
Returns:
The resource title

getColorTables

public List getColorTables()
Return a list of all ColorTable objects

Returns:
List of color tables

getCategories

public List getCategories()
Return a list (String) of the categories defined by the color tables

Returns:
List of color table categories

getDefaultColorTable

public ColorTable getDefaultColorTable()
Find and return the default color table

Returns:
The default color table

getColorTable

public ColorTable getColorTable(String name)
Lookup and return the color table identified by the given name

Parameters:
name - The color table name
Returns:
The color table or null if none found with the given name

edit

public ColorTableEditor edit(ColorTable colorTable,
                             PropertyChangeListener listener)
Create a ColorTableEditor for editing the given color table

Parameters:
colorTable - The color table to edit
listener - Who should get changes sent to (may be null)
Returns:
The new color table editor

makeColorTableMenu

public void makeColorTableMenu(ObjectListener listener,
                               List l)
Make the set of color table menus. On an action event we will call the listeners actionPerformed \ method, passing in the chosen color table.

Parameters:
listener - The listener to pass events to.
l - The list to add the JMenus to

getLabel

public JLabel getLabel(String colorTableName)

makeColorTableMenu

public void makeColorTableMenu(ObjectListener listener,
                               List l,
                               boolean showLocal)
Make the set of color table menus. On an action event we will call the listeners actionPerformed \ method, passing in the chosen color table.

Parameters:
listener - The listener to pass events to.
l - The list to add the JMenus to
showLocal - If true then add "" to the menu item names for local color tables.

main

public static void main(String[] args)
Merge the programmaticcally created color tables with the ones given on the command line. If the first command line argument is "-merge" then don't load in the programmatic color tables, just merge the command line ones.

Parameters:
args - Command line arguments.

getExportContents

protected String getExportContents(NamedObject object,
                                   String file)
When we do an export this method is called to create the String contents that is actually written out. We implement this method here so if we are saving as a Gempak file we can write it out in that format.

Overrides:
getExportContents in class ResourceManager
Parameters:
object - The color table
file - The file name
Returns:
The contents to be written to the file

initResource

protected Object initResource(ResourceCollection resources,
                              int index)
Check to see if these are any of the special resources

Overrides:
initResource in class ResourceManager
Parameters:
resources - resources
index - which one
Returns:
The resource instantiated

doImport

public NamedObject doImport(boolean makeUnique)
Import a color table

Overrides:
doImport in class ResourceManager
Parameters:
makeUnique - If true then we change the name of the color table so it is unique
Returns:
The imported color table