Package chemaxon.marvin.space
Class SurfaceColoring
java.lang.Object
chemaxon.marvin.space.SurfaceColoring
SurfaceColoring is an easy-to-use tool to map different properties as colors
onto surfaces.
Examples of typical usages:
Examples of typical usages:
- Mapping simple float values from a property grid (for example Gaussian Cube grid) to a surface.
SurfaceColoring sc = new SurfaceColoring(surface);
sc.setPropertyObject(myGrid);
sc.setPropertyMethod(myGrid.getClass().getMethod("get", new Class[] {float.class, float.class, float.class} ));
sc.addColors( blue, cyan, green, yellow, red );
- Mapping own atom properties.
SurfaceColoring sc = new SurfaceColoring(molecules, surface);
sc.setPropertyMethod( MoleculeWrapper.getClass().getMethod("getAtomType", new Class[] {int.class}) );
// it has to have 1 int argument
// it will be called through getAtomProperty() of MoleculeInterface:
// ((MoleculeInterface)molecules.get(i)).getAtomProperty().getAtomType(atomIndex);
sc.setPropertyColorMapperMethod( getMethod( "getAtomColor", new Class[] {float.class} ) );
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Coloring by mapping atom based property values to the surface.static final int
Coloring by built-in chain colors.static final int
Coloring by built-in cpk colors.static final int
Coloring by built-in rainbow colors.static final int
Coloring by built-in residue colors.static final int
Coloring by built-in secondary structure colors.static final int
Built-in blue-cyan-green palette will be used.static final int
Built-in blue-lightgray-red palette will be used.static final int
Built-in "fire" palette will be used.static final int
Built-in green-cyan-blue palette will be used.static final int
Built-in rainbow palette will be used.static final int
Built-in red-lightgray-blue palette will be used.static final int
Built-in reverse rainbow palette will be used.static final int
The property values will decrease when getting farther from the atom center.static final int
The property values will decrease when getting farther from the atom center.static final int
The property values will decrease when getting farther from the atom center.static final int
Is the distance measured from the atom center extended by a constant value.static final int
In case of distance weighted property mapping is the distance measured from the atom center extended by the van der Waals radius.static final int
Is the distance measured from the atom center extended by the van der Waals radius plus a constant, typically the probe radius.static final int
Will all affecting properties be mapped onto the surface weighted by atom distances.static final int
Coloring by mapping values form a grid to the surface.static final int
Will the mean of the affecting properties be mapped onto the surface.static final int
Will only the property of the nearest atom be mapped onto the surface.static final int
The property values will not decrease when getting farther from the atom center.static final int
Is the atom property range a fix valuestatic final int
Is the atom property range the van der Waals radiusstatic final int
Is the atom property range the van der Waals radius plus a fix value (for example the probe radius)static final int
Will the sum of the affecting properties be mapped onto the surface. -
Constructor Summary
ConstructorDescriptionSurfaceColoring
(SurfaceComponent surface) The given surface is to be colored after the parametrization.SurfaceColoring
(ArrayList molecules, SurfaceComponent surface) The given surface of the given molecules is to be colored after the parametrization.SurfaceColoring
(ArrayList molecules, SurfaceComponent surface, float step) The given surface of the given molecules is to be colored after the parametrization. -
Method Summary
Modifier and TypeMethodDescriptionvoid
changeColorMapperColors
(int mode) Switches to another built-in color palette and leaves minimum, maximum and cutoff values unchanged.void
This function has to be called after proper parametrization of theSurfaceColoring
object in case of custom properties.void
doColoring
(int mappingMode) This function has to be called after proper parametrization of theSurfaceColoring
object in case of built-in properties.static byte[][]
getBuiltInPalette
(int paletteId) Returns the colors of a built-in palette.static byte[][]
getBuiltInPalette
(Object paletteId) Returns the colors of a built-in palette.static String[]
Returns the string identifiers of the built-in palettes.double
Returns the greatest property value of the surface vertices.double
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
Colors will be got by this method.void
setPropertyColorMapperRange
(double min, double max) Sets the range of the built-in palette.void
Colors will be got from this object.void
Atom properties will be got by this method.void
setPropertyObject
(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) SeePalette.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
Useful fast updating method when the atom properties have not changed, but there is a change in the way of coloring.
-
Field Details
-
RADIUS_VDW
public static final int RADIUS_VDWIs the atom property range the van der Waals radius- See Also:
-
RADIUS_VDW_EXTENDED
public static final int RADIUS_VDW_EXTENDEDIs the atom property range the van der Waals radius plus a fix value (for example the probe radius)- See Also:
-
RADIUS_CONSTANT
public static final int RADIUS_CONSTANTIs the atom property range a fix value- See Also:
-
NEAREST_VALUE
public static final int NEAREST_VALUEWill only the property of the nearest atom be mapped onto the surface.- See Also:
-
SUM_OF_VALUES
public static final int SUM_OF_VALUESWill the sum of the affecting properties be mapped onto the surface.- See Also:
-
MEAN_VALUE
public static final int MEAN_VALUEWill the mean of the affecting properties be mapped onto the surface.- See Also:
-
DISTANCE_WEIGHTED
public static final int DISTANCE_WEIGHTEDWill all affecting properties be mapped onto the surface weighted by atom distances.- See Also:
-
DISTANCE_FROM_VDW
public static final int DISTANCE_FROM_VDWIn 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:
-
DISTANCE_FROM_VDW_EXTENDED
public static final int DISTANCE_FROM_VDW_EXTENDEDIs the distance measured from the atom center extended by the van der Waals radius plus a constant, typically the probe radius.- See Also:
-
DISTANCE_CONSTANT
public static final int DISTANCE_CONSTANTIs the distance measured from the atom center extended by a constant value.- See Also:
-
BUILT_IN_CPK_MAPPING
public static final int BUILT_IN_CPK_MAPPINGColoring by built-in cpk colors.- See Also:
-
BUILT_IN_RESIDUE_MAPPING
public static final int BUILT_IN_RESIDUE_MAPPINGColoring by built-in residue colors.- See Also:
-
BUILT_IN_CHAIN_MAPPING
public static final int BUILT_IN_CHAIN_MAPPINGColoring by built-in chain colors.- See Also:
-
BUILT_IN_SECONDARY_STRUCTURE_MAPPING
public static final int BUILT_IN_SECONDARY_STRUCTURE_MAPPINGColoring by built-in secondary structure colors.- See Also:
-
BUILT_IN_RAINBOW_MAPPING
public static final int BUILT_IN_RAINBOW_MAPPINGColoring by built-in rainbow colors.- See Also:
-
ATOM_PROPERTY_MAPPING
public static final int ATOM_PROPERTY_MAPPINGColoring by mapping atom based property values to the surface.- See Also:
-
GRID_MAPPING
public static final int GRID_MAPPINGColoring by mapping values form a grid to the surface.- See Also:
-
NO_DECREASE
public static final int NO_DECREASEThe property values will not decrease when getting farther from the atom center.- See Also:
-
DECREASE_LINEAR
public static final int DECREASE_LINEARThe property values will decrease when getting farther from the atom center.- See Also:
-
DECREASE_SQUARE
public static final int DECREASE_SQUAREThe property values will decrease when getting farther from the atom center.- See Also:
-
DECREASE_RECIPROCAL_SQUARE
public static final int DECREASE_RECIPROCAL_SQUAREThe property values will decrease when getting farther from the atom center.- See Also:
-
COLOR_MAPPER_RAINBOW
public static final int COLOR_MAPPER_RAINBOWBuilt-in rainbow palette will be used.- See Also:
-
COLOR_MAPPER_REVERSE_RAINBOW
public static final int COLOR_MAPPER_REVERSE_RAINBOWBuilt-in reverse rainbow palette will be used.- See Also:
-
COLOR_MAPPER_RED_TO_BLUE
public static final int COLOR_MAPPER_RED_TO_BLUEBuilt-in red-lightgray-blue palette will be used.- See Also:
-
COLOR_MAPPER_BLUE_TO_RED
public static final int COLOR_MAPPER_BLUE_TO_REDBuilt-in blue-lightgray-red palette will be used.- See Also:
-
COLOR_MAPPER_GREEN_TO_BLUE
public static final int COLOR_MAPPER_GREEN_TO_BLUEBuilt-in green-cyan-blue palette will be used.- See Also:
-
COLOR_MAPPER_BLUE_TO_GREEN
public static final int COLOR_MAPPER_BLUE_TO_GREENBuilt-in blue-cyan-green palette will be used.- See Also:
-
COLOR_MAPPER_FIRE
public static final int COLOR_MAPPER_FIREBuilt-in "fire" palette will be used.- See Also:
-
-
Constructor Details
-
SurfaceColoring
The given surface is to be colored after the parametrization.- Parameters:
surface
- surface to be colored
-
SurfaceColoring
The given surface of the given molecules is to be colored after the parametrization.- Parameters:
molecules
- set ofMoleculeInterface
ssurface
- surface to be colored
-
SurfaceColoring
The given surface of the given molecules is to be colored after the parametrization.- Parameters:
molecules
- set ofMoleculeInterface
ssurface
- surface to be coloredstep
- precision value, it is an approximate value of distances between surface vertices
-
-
Method Details
-
setProgressBar
public void setProgressBar(chemaxon.marvin.space.ProgressBarInterface progressBar) -
setSurface
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. -
reset
public void reset()Resets all parameters to the default. Useful when coloring the same surface multiple times by different parameters. -
setPropertyObject
Atom properties will be get from this object. Typically it can be a grid.- Parameters:
o
- object that has the property methodmappingMode
- eitherGRID_MAPPING
orATOM_PROPERTY_MAPPING
indicating {int} or {float, float, float} arguments to the property method
-
setPropertyMethod
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:
Exception
- in case of illegal method or illegal arguments
-
setBuiltInColorMapperMethod
Selection of built-in color palettes through their identifier.- Parameters:
mode
- See {#COLOR_MAPPER_RAINBOW}, {#COLOR_MAPPER_RED_AND_BLUE}.- Throws:
Exception
-
setBuiltInColorMapperMethod
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:
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
Colors will be got by this method. The method will get atom properties as an argument and has to returnbyte[]
colors.- Parameters:
m
- custom method that returns a color to an atom property- Throws:
Exception
- in case of illegal method or illegal arguments
-
setPropertyColorObject
Colors will be got from this object. Typically it can be a custom pelette.- Parameters:
o
- object that has the color mapper method
-
doColoring
This function has to be called after proper parametrization of theSurfaceColoring
object in case of custom properties.- Throws:
Exception
-
doColoring
This function has to be called after proper parametrization of theSurfaceColoring
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:
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)). -
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 ofbyte[]
colors.
-
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
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) SeePalette.smoothColorToCutoffValues(boolean)
. -
updateColors
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:
Exception
-