chemaxon.marvin.space
Class SurfaceColoring

java.lang.Object
  extended by chemaxon.marvin.space.SurfaceColoring

public class SurfaceColoring
extends java.lang.Object

SurfaceColoring is an easy-to-use tool to map different properties as colors onto surfaces.
Examples of typical usages:

 

 See also SurfaceColoringInUse.html for more examples.
 


Field Summary
static int ATOM_PROPERTY_MAPPING
          Coloring by mapping atom based property values to the surface.
static int BUILT_IN_CHAIN_MAPPING
          Coloring by built-in chain colors.
static int BUILT_IN_CPK_MAPPING
          Coloring by built-in cpk colors.
static int BUILT_IN_RAINBOW_MAPPING
          Coloring by built-in rainbow colors.
static int BUILT_IN_RESIDUE_MAPPING
          Coloring by built-in residue colors.
static int BUILT_IN_SECONDARY_STRUCTURE_MAPPING
          Coloring by built-in secondary structure colors.
static int COLOR_MAPPER_BLUE_TO_GREEN
          Built-in blue-cyan-green palette will be used.
static int COLOR_MAPPER_BLUE_TO_RED
          Built-in blue-lightgray-red palette will be used.
static int COLOR_MAPPER_FIRE
          Built-in "fire" palette will be used.
static int COLOR_MAPPER_GREEN_TO_BLUE
          Built-in green-cyan-blue palette will be used.
static int COLOR_MAPPER_RAINBOW
          Built-in rainbow palette will be used.
static int COLOR_MAPPER_RED_TO_BLUE
          Built-in red-lightgray-blue palette will be used.
static int COLOR_MAPPER_REVERSE_RAINBOW
          Built-in reverse rainbow palette will be used.
static int DECREASE_LINEAR
          The property values will decrease when getting farther from the atom center.
static int DECREASE_RECIPROCAL_SQUARE
          The property values will decrease when getting farther from the atom center.
static int DECREASE_SQUARE
          The property values will decrease when getting farther from the atom center.
static int DISTANCE_CONSTANT
          Is the distance measured from the atom center extended by a constant value.
static int DISTANCE_FROM_VDW
          In case of distance weighted property mapping is the distance measured from the atom center extended by the van der Waals radius.
static int DISTANCE_FROM_VDW_EXTENDED
          Is the distance measured from the atom center extended by the van der Waals radius plus a constant, typically the probe radius.
static int DISTANCE_WEIGHTED
          Will all affecting properties be mapped onto the surface weighted by atom distances.
static int GRID_MAPPING
          Coloring by mapping values form a grid to the surface.
static int MEAN_VALUE
          Will the mean of the affecting properties be mapped onto the surface.
static int NEAREST_VALUE
          Will only the property of the nearest atom be mapped onto the surface.
static int NO_DECREASE
          The property values will not decrease when getting farther from the atom center.
static int RADIUS_CONSTANT
          Is the atom property range a fix value
static int RADIUS_VDW
          Is the atom property range the van der Waals radius
static int RADIUS_VDW_EXTENDED
          Is the atom property range the van der Waals radius plus a fix value (for example the probe radius)
static int SUM_OF_VALUES
          Will the sum of the affecting properties be mapped onto the surface.
 
Constructor Summary
SurfaceColoring(java.util.ArrayList molecules, SurfaceComponent surface)
          The given surface of the given molecules is to be colored after the parametrization.
SurfaceColoring(java.util.ArrayList molecules, SurfaceComponent surface, float step)
          The given surface of the given molecules is to be colored after the parametrization.
SurfaceColoring(SurfaceComponent surface)
          The given surface is to be colored after the parametrization.
 
Method Summary
 void changeColorMapperColors(int mode)
          Switches to another built-in color palette and leaves minimum, maximum and cutoff values unchanged.
 void doColoring()
          This function has to be called after proper parametrization of the SurfaceColoring object in case of custom properties.
 void doColoring(int mappingMode)
          This function has to be called after proper parametrization of the SurfaceColoring object in case of built-in properties.
protected  void finalize()
           
static byte[][] getBuiltInPalette(int paletteId)
          Returns the colors of a built-in palette.
static byte[][] getBuiltInPalette(java.lang.Object paletteId)
          Returns the colors of a built-in palette.
static java.lang.String[] getBuiltInPalettes()
          Returns the string identifiers of the built-in palettes.
 double getMaximumValue()
          Returns the greatest property value of the surface vertices.
 double getMinimumValue()
          Returns the lowest property value of the surface vertices.
 void reset()
          Resets all parameters to the default.
 void setAtomRadiusExtension(float r)
          In case of {#RADIUS_VDW_EXTENDED} mode the extension can be set.
 void setBuiltInColorMapperMethod(int mode)
          Selection of built-in color palettes through their identifier.
 void setBuiltInColorMapperMethod(int mode, boolean twoPolePalette)
          Selection of built-in color palettes through their identifier.
 void setConstantAtomRadius(float r)
          In case of {#RADIUS_CONSTANT} mode the constant radius can be set.
 void setConstantDistanceRadius(float r)
          In case of distance weighted property values constant radius can be set.
 void setDistanceRadiusExtension(float r)
          In case of distance weighted property values radius extension can be set.
 void setDistanceRadiusMode(int pvs)
          In case of distance weighted property values the distance computation can be set differently from the property radius but in the same way.
 void setEnrtyRadiusMode(int pvs)
          Atom properties will effect surface vertices being closer than a certain radius.
 void setHomogeneousPaletteColors(byte[][] colorArray)
          This is an easy way to create a homogenous palette and use it as a color mapper.
 void setLowerCutoffValue(double v)
          Cutoff values can be set to the built-in two pole palettes.
 void setMaximumValue(double v)
          Sets the greatest property value of the surface vertices considered.
 void setMinimumValue(double v)
          Sets the lowest property value of the surface vertices considered.
 void setProgressBar(chemaxon.marvin.space.ProgressBarInterface progressBar)
           
 void setPropertyColorMapperMethod(java.lang.reflect.Method m)
          Colors will be got by this method.
 void setPropertyColorMapperRange(double min, double max)
          Sets the range of the built-in palette.
 void setPropertyColorObject(java.lang.Object o)
          Colors will be got from this object.
 void setPropertyMethod(java.lang.reflect.Method m)
          Atom properties will be got by this method.
 void setPropertyObject(java.lang.Object o, int mappingMode)
          Atom properties will be get from this object.
 void setPropertyValueDecreasement(int pvd)
          Atom property values can decrease when getting farhter from the atom center.
 void setReciprocalConstant(double c)
          Atom property values will decrease by (1.0/(4*PI*c)) * (v/(d*d)).
 void setSmoothColoringToCutoffValues(boolean b)
          See Palette.smoothColorToCutoffValues(boolean).
 void setSurface(SurfaceComponent surface)
          Sets the surface for coloring.
 void setUpperCutoffValue(double v)
          Cutoff values can be set to the built-in two pole palettes.
 void setWeightMode(int mode)
          Way of handling values when multiple atoms have effect on one surface vertex.
 void updateColors()
          Useful fast updating method when the atom properties have not changed, but there is a change in the way of coloring.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RADIUS_VDW

public static final int RADIUS_VDW
Is the atom property range the van der Waals radius

See Also:
Constant Field Values

RADIUS_VDW_EXTENDED

public static final int RADIUS_VDW_EXTENDED
Is the atom property range the van der Waals radius plus a fix value (for example the probe radius)

See Also:
Constant Field Values

RADIUS_CONSTANT

public static final int RADIUS_CONSTANT
Is the atom property range a fix value

See Also:
Constant Field Values

NEAREST_VALUE

public static final int NEAREST_VALUE
Will only the property of the nearest atom be mapped onto the surface.

See Also:
Constant Field Values

SUM_OF_VALUES

public static final int SUM_OF_VALUES
Will the sum of the affecting properties be mapped onto the surface.

See Also:
Constant Field Values

MEAN_VALUE

public static final int MEAN_VALUE
Will the mean of the affecting properties be mapped onto the surface.

See Also:
Constant Field Values

DISTANCE_WEIGHTED

public static final int DISTANCE_WEIGHTED
Will all affecting properties be mapped onto the surface weighted by atom distances.

See Also:
Constant Field Values

DISTANCE_FROM_VDW

public static final int DISTANCE_FROM_VDW
In case of distance weighted property mapping is the distance measured from the atom center extended by the van der Waals radius. Example:
A surface vertex is affected by 2 atoms, a hydrogen and a carbon. The vertex lies exactly where the two atom spheres intersect. Thus it is nearer to the H, but the 2 atoms have to effect equally. If the distance is computed as the distance from the van der Walls radius, it will be 0 to both atoms getting equal weight properly.

See Also:
Constant Field Values

DISTANCE_FROM_VDW_EXTENDED

public static final int DISTANCE_FROM_VDW_EXTENDED
Is the distance measured from the atom center extended by the van der Waals radius plus a constant, typically the probe radius.

See Also:
Constant Field Values

DISTANCE_CONSTANT

public static final int DISTANCE_CONSTANT
Is the distance measured from the atom center extended by a constant value.

See Also:
Constant Field Values

BUILT_IN_CPK_MAPPING

public static final int BUILT_IN_CPK_MAPPING
Coloring by built-in cpk colors.

See Also:
Constant Field Values

BUILT_IN_RESIDUE_MAPPING

public static final int BUILT_IN_RESIDUE_MAPPING
Coloring by built-in residue colors.

See Also:
Constant Field Values

BUILT_IN_CHAIN_MAPPING

public static final int BUILT_IN_CHAIN_MAPPING
Coloring by built-in chain colors.

See Also:
Constant Field Values

BUILT_IN_SECONDARY_STRUCTURE_MAPPING

public static final int BUILT_IN_SECONDARY_STRUCTURE_MAPPING
Coloring by built-in secondary structure colors.

See Also:
Constant Field Values

BUILT_IN_RAINBOW_MAPPING

public static final int BUILT_IN_RAINBOW_MAPPING
Coloring by built-in rainbow colors.

See Also:
Constant Field Values

ATOM_PROPERTY_MAPPING

public static final int ATOM_PROPERTY_MAPPING
Coloring by mapping atom based property values to the surface.

See Also:
Constant Field Values

GRID_MAPPING

public static final int GRID_MAPPING
Coloring by mapping values form a grid to the surface.

See Also:
Constant Field Values

NO_DECREASE

public static final int NO_DECREASE
The property values will not decrease when getting farther from the atom center.

See Also:
Constant Field Values

DECREASE_LINEAR

public static final int DECREASE_LINEAR
The property values will decrease when getting farther from the atom center.

See Also:
Constant Field Values

DECREASE_SQUARE

public static final int DECREASE_SQUARE
The property values will decrease when getting farther from the atom center.

See Also:
Constant Field Values

DECREASE_RECIPROCAL_SQUARE

public static final int DECREASE_RECIPROCAL_SQUARE
The property values will decrease when getting farther from the atom center.

See Also:
Constant Field Values

COLOR_MAPPER_RAINBOW

public static final int COLOR_MAPPER_RAINBOW
Built-in rainbow palette will be used.

See Also:
Constant Field Values

COLOR_MAPPER_REVERSE_RAINBOW

public static final int COLOR_MAPPER_REVERSE_RAINBOW
Built-in reverse rainbow palette will be used.

See Also:
Constant Field Values

COLOR_MAPPER_RED_TO_BLUE

public static final int COLOR_MAPPER_RED_TO_BLUE
Built-in red-lightgray-blue palette will be used.

See Also:
Constant Field Values

COLOR_MAPPER_BLUE_TO_RED

public static final int COLOR_MAPPER_BLUE_TO_RED
Built-in blue-lightgray-red palette will be used.

See Also:
Constant Field Values

COLOR_MAPPER_GREEN_TO_BLUE

public static final int COLOR_MAPPER_GREEN_TO_BLUE
Built-in green-cyan-blue palette will be used.

See Also:
Constant Field Values

COLOR_MAPPER_BLUE_TO_GREEN

public static final int COLOR_MAPPER_BLUE_TO_GREEN
Built-in blue-cyan-green palette will be used.

See Also:
Constant Field Values

COLOR_MAPPER_FIRE

public static final int COLOR_MAPPER_FIRE
Built-in "fire" palette will be used.

See Also:
Constant Field Values
Constructor Detail

SurfaceColoring

public SurfaceColoring(SurfaceComponent surface)
The given surface is to be colored after the parametrization.

Parameters:
surface - surface to be colored

SurfaceColoring

public SurfaceColoring(java.util.ArrayList molecules,
                       SurfaceComponent surface)
The given surface of the given molecules is to be colored after the parametrization.

Parameters:
molecules - set of MoleculeInterfaces
surface - surface to be colored

SurfaceColoring

public SurfaceColoring(java.util.ArrayList molecules,
                       SurfaceComponent surface,
                       float step)
The given surface of the given molecules is to be colored after the parametrization.

Parameters:
molecules - set of MoleculeInterfaces
surface - surface to be colored
step - precision value, it is an approximate value of distances between surface vertices
Method Detail

finalize

protected void finalize()
                 throws java.lang.Throwable
Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable

setProgressBar

public void setProgressBar(chemaxon.marvin.space.ProgressBarInterface progressBar)

setSurface

public void setSurface(SurfaceComponent surface)
Sets the surface for coloring. This is useful when the surface has been changed, but the grid and molecules are the same, especially in case of isosurfaces.

Parameters:
surface -

reset

public void reset()
Resets all parameters to the default. Useful when coloring the same surface multiple times by different parameters.


setPropertyObject

public void setPropertyObject(java.lang.Object o,
                              int mappingMode)
Atom properties will be get from this object. Typically it can be a grid.

Parameters:
o - object that has the property method
mappingMode - either GRID_MAPPING or ATOM_PROPERTY_MAPPING indicating {int} or {float, float, float} arguments to the property method

setPropertyMethod

public void setPropertyMethod(java.lang.reflect.Method m)
                       throws java.lang.Exception
Atom properties will be got by this method. The method will get atom type or atom index or x-y-z values as argument, depending the mapping mode was a built-in mapping or ATOM_PROPERTY_MAPPING or GRID_MAPPING. By default the parameter will be atom type. It has to return a property value.

Parameters:
m - custom method that computes the atom properties
Throws:
java.lang.Exception - in case of illegal method or illegal arguments

setBuiltInColorMapperMethod

public void setBuiltInColorMapperMethod(int mode)
                                 throws java.lang.Exception
Selection of built-in color palettes through their identifier.

Parameters:
mode - See {#COLOR_MAPPER_RAINBOW}, {#COLOR_MAPPER_RED_AND_BLUE}.
Throws:
java.lang.Exception

setBuiltInColorMapperMethod

public void setBuiltInColorMapperMethod(int mode,
                                        boolean twoPolePalette)
                                 throws java.lang.Exception
Selection of built-in color palettes through their identifier.

Parameters:
mode - See {#COLOR_MAPPER_RAINBOW}, {#COLOR_MAPPER_RED_AND_BLUE}. "param twoPolePalette if the palette should handle negative and positive values separately
Throws:
java.lang.Exception

changeColorMapperColors

public void changeColorMapperColors(int mode)
Switches to another built-in color palette and leaves minimum, maximum and cutoff values unchanged.

Parameters:
mode - internal id of the newly set color palette

setPropertyColorMapperRange

public void setPropertyColorMapperRange(double min,
                                        double max)
Sets the range of the built-in palette.

Parameters:
min - Sets the minimum value the palette assignes color to.
max - Sets the maximum value the palette assignes color to.

setPropertyColorMapperMethod

public void setPropertyColorMapperMethod(java.lang.reflect.Method m)
                                  throws java.lang.Exception
Colors will be got by this method. The method will get atom properties as an argument and has to return byte[] colors.

Parameters:
m - custom method that returns a color to an atom property
Throws:
java.lang.Exception - in case of illegal method or illegal arguments

setPropertyColorObject

public void setPropertyColorObject(java.lang.Object o)
Colors will be got from this object. Typically it can be a custom pelette.

Parameters:
o - object that has the color mapper method

doColoring

public void doColoring()
                throws java.lang.Exception
This function has to be called after proper parametrization of the SurfaceColoring object in case of custom properties.

Throws:
java.lang.Exception

doColoring

public void doColoring(int mappingMode)
                throws java.lang.Exception
This function has to be called after proper parametrization of the SurfaceColoring object in case of built-in properties.

Parameters:
mappingMode - identifier of the built-in method, see {#BUILT_IN_CPK_MAPPING}, {#BUILT_IN_RESIDUE_MAPPING}, {#BUILT_IN_CHAIN_MAPPING}
Throws:
java.lang.Exception

setEnrtyRadiusMode

public void setEnrtyRadiusMode(int pvs)
Atom properties will effect surface vertices being closer than a certain radius. The mode of getting this radius can be set here, namely van der Waals radius of the atoms, van der Waals radius plus a constant value (e.g. probe radius), or a constant radius.

Parameters:
pvs - See {#RADIUS_VDW}, {#RADIUS_VDW_EXTENDED}, {#RADIUS_CONSTANT}.

setAtomRadiusExtension

public void setAtomRadiusExtension(float r)
In case of {#RADIUS_VDW_EXTENDED} mode the extension can be set.

Parameters:
r - radius extension in angstroms

setConstantAtomRadius

public void setConstantAtomRadius(float r)
In case of {#RADIUS_CONSTANT} mode the constant radius can be set.

Parameters:
r - radius in angstroms

setDistanceRadiusMode

public void setDistanceRadiusMode(int pvs)
In case of distance weighted property values the distance computation can be set differently from the property radius but in the same way. Example: "I would like to set 1.0 weight if the distance of the surface vertex and the atom center is the van der Waals radius, though the atom still has effect farther from the atom center."

Parameters:
pvs - mode as distance is computed, see {#DISTANCE_FROM_VDW}, {#DISTANCE_FROM_VDW_EXTENDED}, {#DISTANCE_CONSTANT}.

setDistanceRadiusExtension

public void setDistanceRadiusExtension(float r)
In case of distance weighted property values radius extension can be set.

Parameters:
r - distance radius extension in angstroms

setConstantDistanceRadius

public void setConstantDistanceRadius(float r)
In case of distance weighted property values constant radius can be set.

Parameters:
r - constant distance radius in angstroms

setPropertyValueDecreasement

public void setPropertyValueDecreasement(int pvd)
Atom property values can decrease when getting farhter from the atom center. The way of decreasement can be set here.

Parameters:
pvd - See {#NO_DECREASE}, {#DECREASE_LINEAR}, {#DECREASE_SQUARE}, {#DECREASE_RECIPROCAL_SQUARE}.

setReciprocalConstant

public void setReciprocalConstant(double c)
Atom property values will decrease by (1.0/(4*PI*c)) * (v/(d*d)).

Parameters:
c -

setWeightMode

public void setWeightMode(int mode)
Way of handling values when multiple atoms have effect on one surface vertex.

Parameters:
mode - See {#NEAREST_VALUE}, {#SUM_OF_VALUES}, {#MEAN_VALUE}, {#DISTANCE_WEIGHTED}.

setHomogeneousPaletteColors

public void setHomogeneousPaletteColors(byte[][] colorArray)
This is an easy way to create a homogenous palette and use it as a color mapper. There is no need to call {#setPropertyColorMapperMethod()} or {#setPropertyColorObject()}.

Parameters:
colorArray - array of byte[] colors.

getBuiltInPalettes

public static java.lang.String[] getBuiltInPalettes()
Returns the string identifiers of the built-in palettes.

Returns:
array of palette names

getBuiltInPalette

public static byte[][] getBuiltInPalette(int paletteId)
Returns the colors of a built-in palette. See {#COLOR_MAPPER_RAINBOW}, {#COLOR_MAPPER_RED_AND_BLUE}, etc.

Parameters:
paletteId - int identifier of a built-in palette
Returns:
array of the rgb colors represented as byte arrays

getBuiltInPalette

public static byte[][] getBuiltInPalette(java.lang.Object paletteId)
Returns the colors of a built-in palette.

Parameters:
paletteId - string identifier of a built-in palette
Returns:
array of the rgb colors represented as byte arrays

getMinimumValue

public double getMinimumValue()
Returns the lowest property value of the surface vertices.

Returns:
minimum weighted value

getMaximumValue

public double getMaximumValue()
Returns the greatest property value of the surface vertices.

Returns:
maximum weighted value

setMinimumValue

public void setMinimumValue(double v)
Sets the lowest property value of the surface vertices considered.

Parameters:
v - minimum weighted value

setMaximumValue

public void setMaximumValue(double v)
Sets the greatest property value of the surface vertices considered.

Parameters:
v - maximum weighted value

setLowerCutoffValue

public void setLowerCutoffValue(double v)
Cutoff values can be set to the built-in two pole palettes. Values greater than the lower cutoff value and lesser than the upper cutoff value are uniformly colored.

Parameters:
v - lower cutoff value

setUpperCutoffValue

public void setUpperCutoffValue(double v)
Cutoff values can be set to the built-in two pole palettes. Values greater than the lower cutoff value and lesser than the upper cutoff value are uniformly colored.

Parameters:
v - upper cutoff value

setSmoothColoringToCutoffValues

public void setSmoothColoringToCutoffValues(boolean b)
See Palette.smoothColorToCutoffValues(boolean).

Parameters:
b -

updateColors

public void updateColors()
                  throws java.lang.Exception
Useful fast updating method when the atom properties have not changed, but there is a change in the way of coloring. Typically when setting a new palette, setting cutoff values, etc.

Throws:
java.lang.Exception