|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectchemaxon.marvin.MolPrinter
public class MolPrinter
Molecule printer. This class can be used to print a molecule to a Graphics context.
Example:
import chemaxon.marvin.MolPrinter;
import chemaxon.struc.Molecule;
import chemaxon.formats.MolImporter;
import java.awt.Color;
import java.awt.Rectangle;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
public class MolPrinterTest {
static BufferedImage createTestImage() throws IOException {
// Create a molecule
Molecule mol = MolImporter.importMol("CN1C=NC2=C1C(=O)N(C)C(=O)N2C");
// Create a writable image
BufferedImage im = new BufferedImage(400, 400,
BufferedImage.TYPE_INT_ARGB);
Graphics2D g = im.createGraphics();
// Clear background
g.setColor(Color.white);
g.fillRect(0, 0, im.getWidth(), im.getHeight());
// Draw the bounding rectangle
g.setColor(Color.red);
Rectangle r = new Rectangle(20, 20, 360, 200);
g.draw(r);
// Paint the molecule
MolPrinter p = new MolPrinter(mol);
p.setScale(p.maxScale(r)); // fit image in the rectangle
p.paint(g, r);
return im;
}
public static void main(String[] args) throws Exception {
BufferedImage im = createTestImage();
ImageIO.write(im, "png", new File("test.png"));
}
}
| Constructor Summary | |
|---|---|
MolPrinter()
Constructs a printer for an empty molecule. |
|
MolPrinter(MDocument d)
Constructs a printer for the specified document. |
|
MolPrinter(MoleculeGraph m)
Constructs a printer for the specified molecule. |
|
| Method Summary | |
|---|---|
double |
getAtomsize()
Get atom size in units of regular bond length. |
double |
getBondSpacing()
Gets the double bond spacing. |
double |
getBondWidth()
Deprecated. as of Marvin 4.1, replaced by getBondSpacing() |
int |
getChiralitySupport()
Gets chirality support level. |
java.lang.String |
getColorScheme()
Gets the color scheme. |
int |
getDispopts()
Gets the display options. |
boolean |
getExplicitH()
Are explicit hydrogens shown? |
java.lang.String |
getImplicitH()
Query the display method of implicit hydrogens. |
double |
getMag()
Deprecated. as of Marvin 2.9.11, replaced by getScale(). |
java.lang.String |
getRendering()
Gets the rendering style. |
double |
getScale()
Gets the scaling factor. |
boolean |
isAtomSymbolsVisible()
Gets the Atom Symbols display option. |
boolean |
isEzVisible()
Gets the E/Z display option. |
boolean |
isSetColoringEnabled()
Is the atom/bond set coloring enabled? |
double |
maxMag(java.awt.Dimension d)
Deprecated. as of Marvin 2.9.11, replaced by maxScale(Dimension). |
double |
maxScale(java.awt.Dimension d)
Calculates the maximum scaling factor for fitting the image in the specified rectangle. |
double |
maxScale(java.awt.Rectangle r)
Calculates the maximum scaling factor for fitting the image in the specified rectangle. |
void |
paint(java.awt.Graphics g,
java.awt.Rectangle r)
Paint molecule into the center of the specified rectangle. |
void |
setAtomsize(double l)
Set atom size in units of regular bond length. |
void |
setAtomSymbolsVisible(boolean v)
Sets the Atom Symbols display option. |
void |
setBackgroundColor(java.awt.Color color)
Sets the background color. |
void |
setBondSpacing(double w)
Sets the double bond spacing. |
void |
setBondWidth(double w)
Deprecated. as of Marvin 4.1, replaced by setBondSpacing(double) |
void |
setChiralitySupport(int l)
Sets chirality support. |
void |
setColorScheme(java.lang.String s)
Sets the color scheme. |
void |
setDispopts(int f)
Sets the display options. |
void |
setDispopts(int f,
int mask)
Sets the display options. |
void |
setDoc(MDocument d)
Sets the current document and calculates its bounds. |
void |
setExplicitH(boolean show)
Sets the display method of explicit hydrogens. |
void |
setEzVisible(boolean v)
Sets the E/Z display option. |
void |
setImplicitH(java.lang.String s)
Sets the display method of implicit hydrogens. |
void |
setMag(double m)
Deprecated. as of Marvin 2.9.11, replaced by setScale(double). |
void |
setMol(Molecule m)
Sets the current molecule and calculate its bounds. |
void |
setMol(java.lang.String s)
Sets the current molecule and calculate its bounds. |
void |
setRendering(java.lang.String s)
Sets the rendering style. |
void |
setScale(double m)
Sets the scaling factor. |
void |
setSetColoringEnabled(boolean v)
Enable or disable atom/bond set coloring. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public MolPrinter()
public MolPrinter(MoleculeGraph m)
m - a molecule graphpublic MolPrinter(MDocument d)
d - the document| Method Detail |
|---|
public int getDispopts()
DispOptConstspublic void setDispopts(int f)
f - display optionsDispOptConsts
public void setDispopts(int f,
int mask)
f - display optionsmask - set bits specified hereDispOptConstspublic double getScale()
public void setScale(double m)
public double maxScale(java.awt.Rectangle r)
r - the rectanglepublic double maxScale(java.awt.Dimension d)
d - the size of the rectanglepublic double getAtomsize()
public void setAtomsize(double l)
public double getBondSpacing()
public void setBondSpacing(double w)
width = w*1.54 Å = w*scale pixels
w - the bond width in C-C bond length units.public java.lang.String getImplicitH()
IMPLICITH_OFF_S,
IMPLICITH_HETERO_S,
IMPLICITH_HETEROTERM_S
or IMPLICITH_ALL_S.DispOptConsts.IMPLICITH_LEVELSpublic void setImplicitH(java.lang.String s)
s - IMPLICITH_OFF_S,
IMPLICITH_HETERO_S,
IMPLICITH_HETEROTERM_S
or IMPLICITH_ALL_S.DispOptConsts.IMPLICITH_LEVELSpublic java.lang.String getColorScheme()
MONO_SCHEME_S,
CPK_SCHEME_S,
SHAPELY_SCHEME_S or
GROUP_SCHEME_S.DispOptConsts.COLOR_SCHEMESpublic void setColorScheme(java.lang.String s)
s - MONO_SCHEME_S,
CPK_SCHEME_S,
SHAPELY_SCHEME_S or
GROUP_SCHEME_S.DispOptConsts.COLOR_SCHEMESpublic boolean isSetColoringEnabled()
public void setSetColoringEnabled(boolean v)
v - true to enable, false to disablepublic java.lang.String getRendering()
WIREFRAME_RENDERING_S,
WIREKNOBS_RENDERING_S,
STICKS_RENDERING_S,
BALLSTICK_RENDERING_S
or SPACEFILL_RENDERING_S.DispOptConsts.RENDERING_STYLESpublic void setRendering(java.lang.String s)
s - WIREFRAME_RENDERING_S,
WIREKNOBS_RENDERING_S,
STICKS_RENDERING_S,
BALLSTICK_RENDERING_S
or SPACEFILL_RENDERING_S.DispOptConsts.RENDERING_STYLESpublic void setBackgroundColor(java.awt.Color color)
color - the bakcground colorpublic boolean isAtomSymbolsVisible()
public void setAtomSymbolsVisible(boolean v)
v - show (true) or hide (false) Atom Symbolspublic boolean getExplicitH()
public void setExplicitH(boolean show)
show - (true) or hide (false) explicit hydrogenspublic int getChiralitySupport()
StereoConstants.CHIRALITYSUPPORT_NONE,
StereoConstants.CHIRALITYSUPPORT_SELECTED,
StereoConstants.CHIRALITYSUPPORT_ALLpublic void setChiralitySupport(int l)
l - chirality support levelStereoConstants.CHIRALITYSUPPORT_NONE,
StereoConstants.CHIRALITYSUPPORT_SELECTED,
StereoConstants.CHIRALITYSUPPORT_ALLpublic boolean isEzVisible()
public void setEzVisible(boolean v)
v - show (true) or hide (false) E/Zpublic void setMol(Molecule m)
m - the molecule
public void setMol(java.lang.String s)
throws MolFormatException
s - string containing the molecule file in some known format
MolFormatException - if the molecule string cannot be importedpublic void setDoc(MDocument d)
d - the document
public void paint(java.awt.Graphics g,
java.awt.Rectangle r)
g - the graphics contextr - the rectanglepublic double getMag()
getScale().
public void setMag(double m)
setScale(double).
public double maxMag(java.awt.Dimension d)
maxScale(Dimension).
public double getBondWidth()
getBondSpacing()
public void setBondWidth(double w)
setBondSpacing(double)
w - bond spacing in bond length units
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||