Class DitherTheme

All Implemented Interfaces:
Visibility, EditableTableModel, Serializable, Comparator, TableModel

public class DitherTheme extends ChoroplethTheme
This theme colors a map by creating color swatches that contain colors in a random pattern that are proportional to the values within each feature.

For each feature to be symbolized, this theme will read in all of the classification values. The values will be summed, and proportions for each value are determined. A swatch (icon) will be generated that has colors assigned according to the proportions of each value. The pattern of the colors in the swatch are randomly reassigned each time the feature is redrawn.

Use the addElement(String,Color,String) method to add labels, colors and expressions to the classification.

Use the generateSymbols(String,Window,int,Layer) method to automatically generate classifications that match a given column name prefix.

See Also:
Serialized Form
  • Constructor Details

  • Method Details

    • getColumnName

      public String getColumnName(int columnIndex)
      Specified by:
      getColumnName in interface TableModel
      Specified by:
      getColumnName in class Theme
    • setSwatchSize

      public void setSwatchSize(int size)
      Set the size of the swatch that will be generated and used to paint the dithered pattern.
    • getSwatchSize

      public int getSwatchSize()
      Get the size of the swatch that will be generated and used to paint the dithered pattern.
    • getSubEditor

      public ThemeEditor getSubEditor(Layer lle)
      Description copied from class: ChoroplethTheme
      Retrive an editor object that will cusomtize the theme.
      Specified by:
      getSubEditor in class ChoroplethTheme
      Parameters:
      lle - the parent layer
    • compile

      public void compile(Layer layer, AttributeStore store, String fieldname) throws Exception
      Description copied from class: ChoroplethTheme
      Prepare the theme for use with this layer. If the theme specified a field or expression then the expression will be compiled, possibly resulting in an Exception.

      This method will not change the thematic symbols. In order to automatically build a new list of symbols use the generateSymbols method of the appropriate theme.

      The symbols for unclassified data values and selected features will be adjusted if the underlying feature type changes (e.g. from Polygon to Line).

      Overrides:
      compile in class ChoroplethTheme
      Parameters:
      layer - the parent layer
      store - the attribute table to compile the expression against
      fieldname - the fieldname or expression to use to lookup values for this theme
      Throws:
      Exception
    • updateKeys

      public void updateKeys()
    • getSymbol

      public Symbol getSymbol(int row, int period) throws Exception
      Description copied from class: Theme
      Get a symbol for a given object id and period. This method only gets the raw symbol type, and is usually called by other methods that will take unclassified values and visibility parameters in to account.
      Overrides:
      getSymbol in class ChoroplethTheme
      Parameters:
      row - the row number or object id for the feature or grid value
      period - the period of interest
      Throws:
      Exception
    • getSymbol

      public Symbol getSymbol(Object key)
      Description copied from class: Theme
      Get a symbol for a specific key. This method only gets the raw symbol type, and is usually called by other methods that will take unclassified values and visibility parameters in to account.
      Specified by:
      getSymbol in class Theme
      Parameters:
      key - the key value used to look up the appropriate symbol
    • getDataValueAt

      public Number getDataValueAt(int row, int period)
      Description copied from class: ChoroplethTheme
      Get the data value for the given object id and period. Themes may override this method to apply normalization or other adjustments.
      Specified by:
      getDataValueAt in class ChoroplethTheme
    • getSymbol

      public Symbol getSymbol(AttributeStore as, Layer layer, int row, double scale, int period) throws Exception
      Description copied from class: ChoroplethTheme
      Get a symbol for the given layer state
      Overrides:
      getSymbol in class ChoroplethTheme
      Parameters:
      as - the underlying attribute table
      layer - the parent layer
      row - the object id
      scale - the world to page scale
      period - the period of interest
      Throws:
      Exception
    • getValueAt

      public Object getValueAt(int row, int column)
      Specified by:
      getValueAt in interface TableModel
      Overrides:
      getValueAt in class ChoroplethTheme
    • setValueAt

      public void setValueAt(Object aValue, int rowIndex, int columnIndex)
      Specified by:
      setValueAt in interface TableModel
      Overrides:
      setValueAt in class ChoroplethTheme
    • addRow

      public void addRow(Component comp)
      Description copied from interface: EditableTableModel
      Add a row to the table using default values. Optionally provide a reference to the parent window in case a dialog needs to be shown.
      Specified by:
      addRow in interface EditableTableModel
      Overrides:
      addRow in class ChoroplethTheme
    • removeRow

      public void removeRow(int row)
      Description copied from interface: EditableTableModel
      Remove the row specified by the row number.
      Specified by:
      removeRow in interface EditableTableModel
      Overrides:
      removeRow in class ChoroplethTheme
    • setFieldname

      @Deprecated public void setFieldname(String fieldname)
      Deprecated.
      Description copied from class: ChoroplethTheme
      Set the column name or expression that will categorize each feature. This method is deprecated. Associate the fieldname to use with the theme by using the GeoRelLayer(GeoRelationalStore,ChoroplethTheme,String) constructor.
      Specified by:
      setFieldname in class ChoroplethTheme
    • generateSymbols

      public void generateSymbols(String prefix, Window owner, int period, Layer layer) throws Exception
      Generate a new dithering classification based on all fields that match the specified prefix.
      Specified by:
      generateSymbols in class ChoroplethTheme
      Parameters:
      prefix - the colum name prefix. This will be used to identify all columns having a similar prefix and to add them to the classification.
      owner - the window of the controling window, or null if called from a scripting context
      period - the period of interest
      layer - the parent layer
      Throws:
      Exception
    • addElement

      public void addElement(String name, Color c, String field)
      Add an element (row) to the classification
      Parameters:
      name - a label to use in the legend
      c - the color to associate with this field
      field - the field or expression to obtain the values for this classification
    • isDynamic

      public boolean isDynamic()
      Description copied from class: Theme
      By default themes are static and do not change over time. Override this method if a change in period should result in the theme being redrawn.
      Overrides:
      isDynamic in class Theme
    • clone

      public Object clone()
      Description copied from class: Theme
      Return a deep copy of the object as appropriate for each theme type
      Specified by:
      clone in class Theme
    • resetSelectionContext

      public void resetSelectionContext()
      Description copied from class: Theme
      Selection contexts can cache results of time consuming selection operations involved in some spatial quary operators. This method will release the cached selection values so that the query will be recalculated.
      Specified by:
      resetSelectionContext in class Theme
    • hasSelectionContext

      public boolean hasSelectionContext()
      Description copied from class: Theme
      Ask if theme makes use of cached spatial queries to speed up operations.
      Specified by:
      hasSelectionContext in class Theme