jj2000.j2k
Class ModuleSpec

java.lang.Object
  |
  +--jj2000.j2k.ModuleSpec
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
AnWTFilterSpec, CBlkSizeSpec, CompTransfSpec, GuardBitsSpec, IntegerSpec, MaxShiftSpec, PrecinctSizeSpec, ProgressionSpec, QuantStepSizeSpec, QuantTypeSpec, StringSpec, SynWTFilterSpec

public class ModuleSpec
extends java.lang.Object
implements java.lang.Cloneable

This generic class is used to handle values to be used by a module for each tile and component. It uses attribute to determine which value to use. It should be extended by each module needing this feature. This class might be used for values that are only tile specific or component specific but not both.

The attributes to use are defined by a hierarchy. The hierarchy is:


Field Summary
protected  java.lang.Object[] compDef
          The default value for each component.
protected  java.lang.Object def
          Default value for each tile-component
protected  int nComp
          The number of components
protected  int nTiles
          The number of tiles
static byte SPEC_COMP_DEF
          The identifier for "component default" specification
static byte SPEC_DEF
          The identifier for default specification
static byte SPEC_TILE_COMP
          The identifier for a "tile-component" specification
static byte SPEC_TILE_DEF
          The identifier for "tile default" specification
static byte SPEC_TYPE_COMP
          The identifier for a specification module that applies only to components
static byte SPEC_TYPE_TILE
          The identifier for a specification module that applies only to tiles
static byte SPEC_TYPE_TILE_COMP
          The identifier for a specification module that applies both to tiles and components
protected  int specType
          The type of the specification module
protected  byte[][] specValType
          The spec type for each tile-component.
protected  java.util.Hashtable tileCompVal
          The specific value for each tile-component.
protected  java.lang.Object[] tileDef
          The default value for each tile.
 
Constructor Summary
ModuleSpec(int nt, int nc, byte type)
          Constructs a 'ModuleSpec' object, initializing all the components and tiles to the 'SPEC_DEF' spec val type, for the specified number of components and tiles.
 
Method Summary
protected  java.lang.Object clone()
           
 java.lang.Object getCompDef(int c)
          Gets default value of the specified component.
 ModuleSpec getCopy()
           
 java.lang.Object getDefault()
          Gets default value for this module.
protected  java.lang.Object getSpec(int t, int c)
          Gets value of specified tile-component without knowing if a specific tile-component value has been previously entered.
 byte getSpecValType(int t, int c)
          Return the spec type of the given tile-component.
 java.lang.Object getTileCompVal(int t, int c)
          Gets value of specified tile-component.
 java.lang.Object getTileDef(int t)
          Gets default value of the specified tile.
 boolean isCompSpecified(int c)
          Whether or not specifications have been entered for the given component.
 boolean isTileCompSpecified(int t, int c)
          Whether or not a tile-component specification has been defined
 boolean isTileSpecified(int t)
          Whether or not specifications have been entered for the given tile.
static boolean[] parseIdx(java.lang.String word, int maxIdx)
          This method is responsible of parsing tile indexes set and component indexes set for an option.
 void rotate90(Coord anT)
          Rotate the ModuleSpec instance by 90 degrees (this modifies only tile and tile-component specifications).
 void setCompDef(int c, java.lang.Object value)
          Sets default value for specified component and specValType tag if allowed by its priority.
 void setDefault(java.lang.Object value)
          Sets default value for this module
 void setTileCompVal(int t, int c, java.lang.Object value)
          Sets value for specified tile-component.
 void setTileDef(int t, java.lang.Object value)
          Sets default value for specified tile and specValType tag if allowed by its priority.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SPEC_TYPE_COMP

public static final byte SPEC_TYPE_COMP
The identifier for a specification module that applies only to components

See Also:
Constant Field Values

SPEC_TYPE_TILE

public static final byte SPEC_TYPE_TILE
The identifier for a specification module that applies only to tiles

See Also:
Constant Field Values

SPEC_TYPE_TILE_COMP

public static final byte SPEC_TYPE_TILE_COMP
The identifier for a specification module that applies both to tiles and components

See Also:
Constant Field Values

SPEC_DEF

public static final byte SPEC_DEF
The identifier for default specification

See Also:
Constant Field Values

SPEC_COMP_DEF

public static final byte SPEC_COMP_DEF
The identifier for "component default" specification

See Also:
Constant Field Values

SPEC_TILE_DEF

public static final byte SPEC_TILE_DEF
The identifier for "tile default" specification

See Also:
Constant Field Values

SPEC_TILE_COMP

public static final byte SPEC_TILE_COMP
The identifier for a "tile-component" specification

See Also:
Constant Field Values

specType

protected int specType
The type of the specification module


nTiles

protected int nTiles
The number of tiles


nComp

protected int nComp
The number of components


specValType

protected byte[][] specValType
The spec type for each tile-component. The first index is the tile index, the second is the component index.


def

protected java.lang.Object def
Default value for each tile-component


compDef

protected java.lang.Object[] compDef
The default value for each component. Null if no component specific value is defined


tileDef

protected java.lang.Object[] tileDef
The default value for each tile. Null if no tile specific value is defined


tileCompVal

protected java.util.Hashtable tileCompVal
The specific value for each tile-component. Value of tile 16 component 3 is accessible through the hash value "t16c3". Null if no tile-component specific value is defined

Constructor Detail

ModuleSpec

public ModuleSpec(int nt,
                  int nc,
                  byte type)
Constructs a 'ModuleSpec' object, initializing all the components and tiles to the 'SPEC_DEF' spec val type, for the specified number of components and tiles.

Parameters:
nt - The number of tiles
nc - The number of components
type - the type of the specification module i.e. tile specific, component specific or both.
Method Detail

getCopy

public ModuleSpec getCopy()

clone

protected java.lang.Object clone()
Overrides:
clone in class java.lang.Object

rotate90

public void rotate90(Coord anT)
Rotate the ModuleSpec instance by 90 degrees (this modifies only tile and tile-component specifications).


setDefault

public void setDefault(java.lang.Object value)
Sets default value for this module


getDefault

public java.lang.Object getDefault()
Gets default value for this module.

Returns:
The default value (Must be casted before use)

setCompDef

public void setCompDef(int c,
                       java.lang.Object value)
Sets default value for specified component and specValType tag if allowed by its priority.

Parameters:
c - Component index

getCompDef

public java.lang.Object getCompDef(int c)
Gets default value of the specified component. If no specification have been entered for this component, returns default value.

Parameters:
c - Component index
Returns:
The default value for this component (Must be casted before use)
See Also:
setCompDef(int, java.lang.Object)

setTileDef

public void setTileDef(int t,
                       java.lang.Object value)
Sets default value for specified tile and specValType tag if allowed by its priority.


getTileDef

public java.lang.Object getTileDef(int t)
Gets default value of the specified tile. If no specification has been entered, it returns the default value.

Parameters:
t - Tile index
Returns:
The default value for this tile (Must be casted before use)
See Also:
setTileDef(int, java.lang.Object)

setTileCompVal

public void setTileCompVal(int t,
                           int c,
                           java.lang.Object value)
Sets value for specified tile-component.

Parameters:
t - Tie index
c - Component index

getTileCompVal

public java.lang.Object getTileCompVal(int t,
                                       int c)
Gets value of specified tile-component. This method calls getSpec but has a public access.

Parameters:
t - Tile index
c - Component index
Returns:
The value of this tile-component (Must be casted before use)
See Also:
setTileCompVal(int, int, java.lang.Object), getSpec(int, int)

getSpec

protected java.lang.Object getSpec(int t,
                                   int c)
Gets value of specified tile-component without knowing if a specific tile-component value has been previously entered. It first check if a tile-component specific value has been entered, then if a tile specific value exist, then if a component specific value exist. If not the default value is returned.

Parameters:
t - Tile index
c - Component index
Returns:
Value for this tile component.

getSpecValType

public byte getSpecValType(int t,
                           int c)
Return the spec type of the given tile-component.

Parameters:
t - Tile index
c - Component index

isCompSpecified

public boolean isCompSpecified(int c)
Whether or not specifications have been entered for the given component.

Parameters:
c - Index of the component
Returns:
True if component specification has been defined

isTileSpecified

public boolean isTileSpecified(int t)
Whether or not specifications have been entered for the given tile.

Parameters:
t - Index of the tile
Returns:
True if tile specification has been entered

isTileCompSpecified

public boolean isTileCompSpecified(int t,
                                   int c)
Whether or not a tile-component specification has been defined

Parameters:
t - Tile index
c - Component index
Returns:
True if a tile-component specification has been defined.

parseIdx

public static final boolean[] parseIdx(java.lang.String word,
                                       int maxIdx)
This method is responsible of parsing tile indexes set and component indexes set for an option. Such an argument must follow the following policy:
t<indexes set> or c<indexes set> where tile or component indexes are separated by commas or a dashes.

Example:

  • t0,3,4 means tiles with indexes 0, 3 and 4.
  • t2-4 means tiles with indexes 2,3 and 4.
    It returns a boolean array skteching which tile or component are concerned by the next parameters.

    Parameters:
    word - The word to parse.
    maxIdx - Maximum authorized index
    Returns:
    Indexes concerned by this parameter.