Package com.actelion.research.chem
Class AbstractDepictor<T>
- java.lang.Object
-
- com.actelion.research.chem.AbstractDepictor<T>
-
- Direct Known Subclasses:
Depictor
,Depictor2D
,GenericDepictor
,JFXCanvasDepictor
,SVGDepictor
public abstract class AbstractDepictor<T> extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AbstractDepictor.DepictorDot
static class
AbstractDepictor.DepictorLine
-
Field Summary
-
Constructor Summary
Constructors Constructor Description AbstractDepictor(StereoMolecule mol)
AbstractDepictor(StereoMolecule mol, int displayMode)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
applyTransformation(DepictorTransformation t)
protected abstract void
drawBlackLine(AbstractDepictor.DepictorLine theLine)
protected void
drawDot(double x, double y)
protected abstract void
drawDottedLine(AbstractDepictor.DepictorLine theLine)
protected abstract void
drawPolygon(GenericPolygon p)
protected abstract void
drawString(java.lang.String theString, double x, double y)
protected abstract void
fillCircle(double x, double y, double d)
java.awt.geom.Rectangle2D.Double
getBoundingRect()
protected abstract double
getLineWidth()
protected abstract double
getStringWidth(java.lang.String theString)
protected abstract int
getTextSize()
DepictorTransformation
getTransformation()
protected void
init()
protected void
onDrawAtom(int atom, java.lang.String symbol, double x, double y)
protected void
onDrawBond(int bond, double x1, double y1, double x2, double y2)
void
paint(T context)
void
setAtomHighlightColors(int[] argb)
If you want this tructure view to also draw an atom background with specific colors for every atom, then you need to call this method before calling paint().void
setAtomText(java.lang.String[] atomText)
Defines additional atom text to be displayed in top right position of some/all atom label.void
setColor(int theColor)
protected abstract void
setColor(java.awt.Color theColor)
void
setDisplayMode(int displayMode)
void
setFactorTextSize(double factor)
Sets a multiplication factor to the text size of all labels.void
setForegroundColor(java.awt.Color foreground, java.awt.Color background)
If the foreground color is set, the molecule is drawn in the foreground color except for non carbon atoms, which are drawn in atomicNo specific colors.protected abstract void
setLineWidth(double lineWidth)
void
setOverruleColor(java.awt.Color foreground, java.awt.Color background)
If the overrule color is set, the entire molecule is drawn in the foreground color neglecting any atom color information.protected abstract void
setTextSize(int theSize)
void
setTransformation(DepictorTransformation t)
DepictorTransformation
simpleUpdateCoords(java.awt.geom.Rectangle2D.Double viewRect, int mode)
Returns full transformation that moves/scales original molecule into viewRect.DepictorTransformation
simpleValidateView(java.awt.geom.Rectangle2D.Double viewRect, int mode)
DepictorTransformation
updateCoords(T context, java.awt.geom.Rectangle2D.Double viewRect, int mode)
Returns full transformation that moves/scales original molecule into viewRect.DepictorTransformation
validateView(T context, java.awt.geom.Rectangle2D.Double viewRect, int mode)
A depictor maintains a DepictorTransformation object, which defines translation and scaling of molecule coordinates into the viewRect.
-
-
-
Field Detail
-
COLOR_BLUE
public static final java.awt.Color COLOR_BLUE
-
COLOR_RED
public static final java.awt.Color COLOR_RED
-
COLOR_GREEN
public static final java.awt.Color COLOR_GREEN
-
COLOR_MAGENTA
public static final java.awt.Color COLOR_MAGENTA
-
COLOR_ORANGE
public static final java.awt.Color COLOR_ORANGE
-
COLOR_DARK_GREEN
public static final java.awt.Color COLOR_DARK_GREEN
-
COLOR_DARK_RED
public static final java.awt.Color COLOR_DARK_RED
-
cOptAvBondLen
public static final int cOptAvBondLen
- See Also:
- Constant Field Values
-
cColorGray
public static final int cColorGray
- See Also:
- Constant Field Values
-
cModeMaxBondLength
protected static final int cModeMaxBondLength
- See Also:
- Constant Field Values
-
cModeInflateToAVBL
protected static final int cModeInflateToAVBL
- See Also:
- Constant Field Values
-
cModeInflateToMaxAVBL
public static final int cModeInflateToMaxAVBL
- See Also:
- Constant Field Values
-
cModeInflateToHighResAVBL
public static final int cModeInflateToHighResAVBL
- See Also:
- Constant Field Values
-
cModeChiralTextBelowMolecule
public static final int cModeChiralTextBelowMolecule
- See Also:
- Constant Field Values
-
cModeChiralTextAboveMolecule
public static final int cModeChiralTextAboveMolecule
- See Also:
- Constant Field Values
-
cModeChiralTextOnFrameTop
public static final int cModeChiralTextOnFrameTop
- See Also:
- Constant Field Values
-
cModeChiralTextOnFrameBottom
public static final int cModeChiralTextOnFrameBottom
- See Also:
- Constant Field Values
-
cDModeNoTabus
public static final int cDModeNoTabus
- See Also:
- Constant Field Values
-
cDModeAtomNo
public static final int cDModeAtomNo
- See Also:
- Constant Field Values
-
cDModeBondNo
public static final int cDModeBondNo
- See Also:
- Constant Field Values
-
cDModeHiliteAllQueryFeatures
public static final int cDModeHiliteAllQueryFeatures
- See Also:
- Constant Field Values
-
cDModeShowMapping
public static final int cDModeShowMapping
- See Also:
- Constant Field Values
-
cDModeSuppressChiralText
public static final int cDModeSuppressChiralText
- See Also:
- Constant Field Values
-
cDModeSuppressCIPParity
public static final int cDModeSuppressCIPParity
- See Also:
- Constant Field Values
-
cDModeSuppressESR
public static final int cDModeSuppressESR
- See Also:
- Constant Field Values
-
cDModeShowSymmetrySimple
public static final int cDModeShowSymmetrySimple
- See Also:
- Constant Field Values
-
cDModeShowSymmetryDiastereotopic
public static final int cDModeShowSymmetryDiastereotopic
- See Also:
- Constant Field Values
-
cDModeShowSymmetryEnantiotopic
public static final int cDModeShowSymmetryEnantiotopic
- See Also:
- Constant Field Values
-
cDModeNoImplicitAtomLabelColors
public static final int cDModeNoImplicitAtomLabelColors
- See Also:
- Constant Field Values
-
cDModeNoStereoProblem
public static final int cDModeNoStereoProblem
- See Also:
- Constant Field Values
-
cDModeNoColorOnESRAndCIP
public static final int cDModeNoColorOnESRAndCIP
- See Also:
- Constant Field Values
-
cDModeNoImplicitHydrogen
public static final int cDModeNoImplicitHydrogen
- See Also:
- Constant Field Values
-
mContext
protected T mContext
-
-
Constructor Detail
-
AbstractDepictor
public AbstractDepictor(StereoMolecule mol)
-
AbstractDepictor
public AbstractDepictor(StereoMolecule mol, int displayMode)
-
-
Method Detail
-
setDisplayMode
public void setDisplayMode(int displayMode)
-
setAtomText
public void setAtomText(java.lang.String[] atomText)
Defines additional atom text to be displayed in top right position of some/all atom label. If the atom is charged, then the atom text follows the charge information.- Parameters:
atomText
- null or String array matching atom indexes (may contain null entries)
-
setForegroundColor
public void setForegroundColor(java.awt.Color foreground, java.awt.Color background)
If the foreground color is set, the molecule is drawn in the foreground color except for non carbon atoms, which are drawn in atomicNo specific colors. If a background color is given, then atom coloring and highlighting is optimized to achieve good contrasts.- Parameters:
foreground
- null (black) or color to be used for molecule drawingbackground
- null (white) or color on which the molecule is drawn
-
setOverruleColor
public void setOverruleColor(java.awt.Color foreground, java.awt.Color background)
If the overrule color is set, the entire molecule is drawn in the foreground color neglecting any atom color information. The background color is used to construct a proper bond hilite color, if bond hiliting is used.- Parameters:
foreground
- null or color to be used for molecule drawingbackground
- may be null
-
setAtomHighlightColors
public void setAtomHighlightColors(int[] argb)
If you want this tructure view to also draw an atom background with specific colors for every atom, then you need to call this method before calling paint().- Parameters:
argb
- values with a==0 are not considered (may be null)
-
setTransformation
public void setTransformation(DepictorTransformation t)
-
setFactorTextSize
public void setFactorTextSize(double factor)
Sets a multiplication factor to the text size of all labels. The default is 1.0.- Parameters:
factor
- text size factor
-
getTransformation
public DepictorTransformation getTransformation()
-
applyTransformation
public void applyTransformation(DepictorTransformation t)
-
updateCoords
public DepictorTransformation updateCoords(T context, java.awt.geom.Rectangle2D.Double viewRect, int mode)
Returns full transformation that moves/scales original molecule into viewRect. This method considers atom labels when generating the bounding box. This includes atom labels of drawn implicit hydrogen atoms.- Parameters:
context
-viewRect
-mode
- is typically (cModeInflateToMaxAVBL | maximum_desired_bond_length)- Returns:
-
simpleUpdateCoords
public DepictorTransformation simpleUpdateCoords(java.awt.geom.Rectangle2D.Double viewRect, int mode)
Returns full transformation that moves/scales original molecule into viewRect. This simple method creates a transformation that places all atom coordinates in the viewRect.- Parameters:
viewRect
-mode
-- Returns:
-
validateView
public DepictorTransformation validateView(T context, java.awt.geom.Rectangle2D.Double viewRect, int mode)
A depictor maintains a DepictorTransformation object, which defines translation and scaling of molecule coordinates into the viewRect. This method updates the depictor's transformation such that the molecule is centered in viewRect and reduced in size if it doesn't fit. If mode contains cModeInflateToMaxAVBL, then it is scaled to reach the desired mean bond length, or to fill viewRect, whatever is reached first.- Parameters:
context
-viewRect
-mode
- (<0> or cModeInflateToMaxAVBL) +- Returns:
- incremental transformation being applied to depictor's current transformation
-
simpleValidateView
public DepictorTransformation simpleValidateView(java.awt.geom.Rectangle2D.Double viewRect, int mode)
-
onDrawBond
protected void onDrawBond(int bond, double x1, double y1, double x2, double y2)
-
onDrawAtom
protected void onDrawAtom(int atom, java.lang.String symbol, double x, double y)
-
getBoundingRect
public final java.awt.geom.Rectangle2D.Double getBoundingRect()
-
init
protected void init()
-
paint
public void paint(T context)
-
drawDot
protected void drawDot(double x, double y)
-
setColor
public void setColor(int theColor)
-
drawBlackLine
protected abstract void drawBlackLine(AbstractDepictor.DepictorLine theLine)
-
drawDottedLine
protected abstract void drawDottedLine(AbstractDepictor.DepictorLine theLine)
-
drawPolygon
protected abstract void drawPolygon(GenericPolygon p)
-
drawString
protected abstract void drawString(java.lang.String theString, double x, double y)
-
fillCircle
protected abstract void fillCircle(double x, double y, double d)
-
getLineWidth
protected abstract double getLineWidth()
-
getStringWidth
protected abstract double getStringWidth(java.lang.String theString)
-
getTextSize
protected abstract int getTextSize()
-
setTextSize
protected abstract void setTextSize(int theSize)
-
setLineWidth
protected abstract void setLineWidth(double lineWidth)
-
setColor
protected abstract void setColor(java.awt.Color theColor)
-
-