|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.jscience.chemistry.gui.extended.molecule.Renderer
public class Renderer
An implementation of a JViewer's renderer interface for drawing and manipulating a Molecule.
IRenderer| Field Summary | |
|---|---|
protected float |
AB_DEV
Aromatic bond separation |
static int |
ALL_ATOMS_ONE_COLOR
DOCUMENT ME! |
protected java.awt.Color |
atombg
Color of default atom background |
protected java.awt.Font |
atomFont
Font to display atom labels |
protected java.awt.Color |
bondColor
Default color to display bonds |
static int |
COLOR_BY_ATOM_TYPE
Coloring scheme constants |
protected int |
colorScheme
draw atom color according to which coloring scheme |
protected float |
DB_DEV
Double bond separation |
protected float |
findRadius
Upper bound of the distance (in pixel) between an atom (or bond) and the pick-location if the atom (or bond) is considered picked |
protected java.awt.Color |
highlightColor
Color to display highlighted atoms |
protected int |
hTreatment
Flag indicating how to handle the display of hydrogens |
protected Molecule |
mol
molecule to be drawn |
static int |
PICK_ATOM_FIRST
Indicate the atom is preferred picked object when an atom and a bond both lie close enough to a single-picking location |
static int |
PICK_ATOM_ONLY
Indicate only atoms are pickable, bond picking is not interested |
static int |
PICK_BOND_FIRST
Indicate the bond is preferred picked object when an atom and a bond both lie close enough to a single-picking location |
static int |
PICK_BOND_ONLY
Indicate only bonds are pickable, atom picking is not interested |
protected boolean |
pickHiddenAtom
Indicate whether hidden atoms are pickable |
protected boolean |
pickHiddenBond
Indicate whether hidden atoms are pickable |
int |
pickPreference
Indicate the picking preference is on atom, bond or distance |
protected java.awt.Color |
selectColor
Color to display selected atoms |
static int |
SHORTEST_WIN
Indicate distance is used to break the tie when an atom and a bond both lie close enough to a single-picking locaition |
static int |
SHOW_ALL_H
Display all hydrogens |
static int |
SHOW_NO_H
Don't display any hydrogens |
static int |
SHOW_NON_C_H
Display hydrogens not attached to carbons |
protected boolean |
showAtomLabels
Indicates whether atom labels should be displayed |
protected float |
TB_DEV
Triple bond separation |
protected float |
WB_DEV
Wedge bond separation |
| Constructor Summary | |
|---|---|
Renderer()
Default constructor |
|
Renderer(Molecule mol)
Constructor |
|
Renderer(Renderer r)
Copy constructor |
|
| Method Summary | |
|---|---|
java.lang.Object |
copy()
DOCUMENT ME! |
void |
draw(java.awt.Graphics g)
Draw the Molecule. |
protected void |
drawAnyBond(java.awt.Graphics g,
java.awt.Color c1,
java.awt.Color c2,
float x1,
float y1,
float x2,
float y2)
Draws an any bond |
protected void |
drawAromaticBond(java.awt.Graphics g,
java.awt.Color c1,
java.awt.Color c2,
float x1,
float y1,
float x2,
float y2)
Draws an aromatic bond |
void |
drawAtom(java.awt.Graphics g,
Atom a)
Draws an atom. |
void |
drawBond(java.awt.Graphics g,
Bond b)
Draws a bond |
protected void |
drawDashBond(java.awt.Graphics g,
float x1,
float y1,
float x2,
float y2)
Draws a dashed wedge bond (assumes black & white) |
protected void |
drawSingleBond(java.awt.Graphics g,
java.awt.Color c1,
java.awt.Color c2,
float x1,
float y1,
float x2,
float y2)
Draws a single bond |
protected void |
drawWedgeBond(java.awt.Graphics g,
float x1,
float y1,
float x2,
float y2)
Draws a wedge bond |
Atom |
findAtom(float tx,
float ty)
|
void |
findAtoms(java.awt.Polygon pickPolygon,
java.util.Vector resultVector)
Find a list of atoms within the given polygon |
Bond |
findBond(float tx,
float ty)
|
void |
findBonds(java.awt.Polygon pickPolygon,
java.util.Vector resultVector)
Find a list of bonds within the given polygon |
java.lang.Object |
findObject(float tx,
float ty)
Find an object given location |
java.util.Vector |
findObjects(java.awt.Polygon pickPolygon)
Return a list of objects that are within the given polygon |
float |
getAB_DEV()
Return aromatic bond separation |
java.awt.Color |
getAtombg()
Return atom background color |
java.awt.Font |
getAtomFont()
Return atom font |
float[] |
getBBox()
Return the bounding box of the Molecule. |
java.awt.Color |
getBondColor()
Return bond color |
boolean |
getColorByAtomType()
Return flag that indicates whether to paint the atom according to its type |
int |
getColorScheme()
Return color scheme |
float |
getDB_DEV()
Return double bond separation |
java.awt.Color |
getHighlightColor()
Return color to paint hightlighted atoms |
int |
getHTreatment()
Return hydrogen treatment |
Molecule |
getMol()
Return the molecule. |
boolean |
getPickHiddenAtom()
|
boolean |
getPickHiddenBond()
|
java.awt.Color |
getSelectColor()
Return color to paint selected atoms |
boolean |
getShowAtomLabels()
Return flag that indicates whether atom labels should display |
float |
getTB_DEV()
Return triple bond separation |
float |
getWB_DEV()
Return wedge bond separation |
boolean |
isHidden(Atom atom)
|
void |
matMult(Matrix3D rhs)
Multiply the Molecule's transformation matrix by the matrix specified. |
void |
matScale(float xf,
float yf,
float zf)
Apply the specified scale to the Molecule's transformation matrix. |
void |
matTransform()
Apply the Molecule's transformation matrix to its atoms. |
void |
matTranslate(float xt,
float yt,
float zt)
Apply the specified translation to the Molecule's transformation matrix. |
void |
matUnit()
Reset the Molecule's transformation matrix to the identity matrix. |
void |
setAB_DEV(float abDev)
Set aromatic bond separation |
void |
setAtombg(java.awt.Color color)
Set atom background color |
void |
setAtomFont(java.awt.Font font)
Set atom font |
void |
setBondColor(java.awt.Color color)
Set bond color |
void |
setColorByAtomType(boolean bool)
Set flag to indicate whether to paint the atom according to its type As data member colorByAtomType, this method is redundent, but is kept to be compatible with pre-existing code |
void |
setColorScheme(int colorScheme)
Set color scheme |
void |
setDB_DEV(float dbDev)
Set double bond separation |
void |
setFindRadius(float findRadius)
Set the findRadius |
void |
setHighlightColor(java.awt.Color color)
Set color to paint hightlighted atoms |
void |
setHTreatment(int hTreatment)
Set hydrogen treatment |
void |
setMol(Molecule mol)
Set the molecule |
void |
setPickHiddenAtom(boolean pickHiddenAtom)
Set the policy whether hidden atoms are pickable |
void |
setPickHiddenBond(boolean pickHiddenBond)
Set the policy whether hidden bonds are pickable |
void |
setPickPreference(int pickPreference)
Set the pickPreference policy |
void |
setSelectColor(java.awt.Color color)
Set color to paint selected atoms |
void |
setShowAtomLabels(boolean bool)
Set flag to indicate whether atom labels should display or not |
void |
setTB_DEV(float tbDev)
Set triple bond separation |
void |
setWB_DEV(float wbDev)
Set wedge bond separation |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int SHOW_ALL_H
public static final int SHOW_NO_H
public static final int SHOW_NON_C_H
public static final int COLOR_BY_ATOM_TYPE
public static final int ALL_ATOMS_ONE_COLOR
public static final int PICK_ATOM_FIRST
public static final int PICK_BOND_FIRST
public static final int SHORTEST_WIN
public static final int PICK_ATOM_ONLY
public static final int PICK_BOND_ONLY
protected Molecule mol
protected int hTreatment
protected float DB_DEV
protected float TB_DEV
protected float AB_DEV
protected float WB_DEV
protected java.awt.Font atomFont
protected java.awt.Color bondColor
protected boolean showAtomLabels
protected int colorScheme
protected java.awt.Color selectColor
protected java.awt.Color highlightColor
protected java.awt.Color atombg
protected float findRadius
protected boolean pickHiddenAtom
protected boolean pickHiddenBond
public int pickPreference
| Constructor Detail |
|---|
public Renderer()
public Renderer(Molecule mol)
mol - the Molecule drawn and manipulated by this renderer.public Renderer(Renderer r)
r - Renderer| Method Detail |
|---|
public Molecule getMol()
public void setMol(Molecule mol)
mol - Moleculepublic float[] getBBox()
getBBox in interface IRendererpublic void matUnit()
matUnit in interface IRenderer
public void matTranslate(float xt,
float yt,
float zt)
matTranslate in interface IRendererxt - x component of translationyt - y component of translationzt - z component of translation
public void matScale(float xf,
float yf,
float zf)
matScale in interface IRendererxf - x scale factoryf - y scale factorzf - z scale factorpublic void matMult(Matrix3D rhs)
matMult in interface IRendererrhs - matrix to be multiplied to Molecule's matrix: M = M * rhspublic void matTransform()
matTransform in interface IRenderer
public void drawAtom(java.awt.Graphics g,
Atom a)
a - atomg - graphics contextdraw(java.awt.Graphics)
public void drawBond(java.awt.Graphics g,
Bond b)
b - bondg - graphics contextdraw(java.awt.Graphics),
drawSingleBond(java.awt.Graphics, java.awt.Color, java.awt.Color, float, float, float, float),
drawAromaticBond(java.awt.Graphics, java.awt.Color, java.awt.Color, float, float, float, float),
drawWedgeBond(java.awt.Graphics, float, float, float, float),
drawDashBond(java.awt.Graphics, float, float, float, float),
drawAnyBond(java.awt.Graphics, java.awt.Color, java.awt.Color, float, float, float, float)
protected void drawSingleBond(java.awt.Graphics g,
java.awt.Color c1,
java.awt.Color c2,
float x1,
float y1,
float x2,
float y2)
g - graphics contextc1 - color of the first half of the bondc2 - color of the second half of the bondx1 - x coord of from atomy1 - y coord of from atomx2 - x coord of to atomy2 - y coord of to atomdrawBond(java.awt.Graphics, org.jscience.chemistry.gui.extended.molecule.Bond)
protected void drawAromaticBond(java.awt.Graphics g,
java.awt.Color c1,
java.awt.Color c2,
float x1,
float y1,
float x2,
float y2)
g - graphics contextc1 - color of the first half of the bondc2 - color of the second half of the bondx1 - x coord of from atomy1 - y coord of from atomx2 - x coord of to atomy2 - y coord of to atomdrawBond(java.awt.Graphics, org.jscience.chemistry.gui.extended.molecule.Bond)
protected void drawWedgeBond(java.awt.Graphics g,
float x1,
float y1,
float x2,
float y2)
drawBond(java.awt.Graphics, org.jscience.chemistry.gui.extended.molecule.Bond)
protected void drawDashBond(java.awt.Graphics g,
float x1,
float y1,
float x2,
float y2)
drawBond(java.awt.Graphics, org.jscience.chemistry.gui.extended.molecule.Bond)
protected void drawAnyBond(java.awt.Graphics g,
java.awt.Color c1,
java.awt.Color c2,
float x1,
float y1,
float x2,
float y2)
g - graphics contextc1 - color of the first half of the bondc2 - color of the second half of the bondx1 - x coord of from atomy1 - y coord of from atomx2 - x coord of to atomy2 - y coord of to atomdrawBond(java.awt.Graphics, org.jscience.chemistry.gui.extended.molecule.Bond)public void draw(java.awt.Graphics g)
draw in interface IRendererg - the graphics context.
public java.lang.Object findObject(float tx,
float ty)
IRenderer
findObject in interface IRenderertx - transformed x coordinatety - transformed y coordinate
pickPreference
public Atom findAtom(float tx,
float ty)
tx - transformed x coordinatety - transformed y coordinate
public Bond findBond(float tx,
float ty)
tx - transformed x coordinatety - transformed y coordinate
public java.util.Vector findObjects(java.awt.Polygon pickPolygon)
findObjects in interface IRendererpickPolygon - the polygon within which objects are considered picked
public void findAtoms(java.awt.Polygon pickPolygon,
java.util.Vector resultVector)
pickPolygon - the polygon with which atoms are considerred pickedresultVector - vector into which the found atoms are put
public void findBonds(java.awt.Polygon pickPolygon,
java.util.Vector resultVector)
pickPolygon - the polygon with which bonds are considerred pickedresultVector - vector into which the found bonds are putpublic boolean isHidden(Atom atom)
atom - the atom to be check whether it is hidden
public int getHTreatment()
public float getDB_DEV()
public float getTB_DEV()
public float getAB_DEV()
public float getWB_DEV()
public java.awt.Font getAtomFont()
public java.awt.Color getBondColor()
public boolean getShowAtomLabels()
public boolean getColorByAtomType()
public int getColorScheme()
public java.awt.Color getSelectColor()
public java.awt.Color getHighlightColor()
public java.awt.Color getAtombg()
public boolean getPickHiddenAtom()
public boolean getPickHiddenBond()
public void setHTreatment(int hTreatment)
hTreatment - int one of ( SHOW_ALL_H, SHOW_NO_H, SHOW_NON_C_H )public void setDB_DEV(float dbDev)
dbDev - floatpublic void setTB_DEV(float tbDev)
tbDev - floatpublic void setAB_DEV(float abDev)
abDev - floatpublic void setWB_DEV(float wbDev)
wbDev - floatpublic void setAtomFont(java.awt.Font font)
font - Font to paint atom labelpublic void setBondColor(java.awt.Color color)
color - Color to draw bondpublic void setShowAtomLabels(boolean bool)
bool - booleanpublic void setColorByAtomType(boolean bool)
bool - booleanpublic void setColorScheme(int colorScheme)
colorScheme - intpublic void setSelectColor(java.awt.Color color)
color - Colorpublic void setHighlightColor(java.awt.Color color)
color - Colorpublic void setAtombg(java.awt.Color color)
color - Colorpublic void setPickHiddenAtom(boolean pickHiddenAtom)
pickHiddenAtom - the policy whether hidden atoms are pickablepublic void setPickHiddenBond(boolean pickHiddenBond)
pickHiddenBond - the policy whether hidden bonds are pickablepublic void setFindRadius(float findRadius)
findRadius - the upper bound of distance between a mouse click
location and the atom (or bond) when the atom (or bond) is a candidate
of the picked object.public void setPickPreference(int pickPreference)
pickPreference - one of the picking policies among ATOM_FIRST,
BOND_FIRST, SHORTEST_WIN, ATOM_ONLY and BOND_ONLYpublic java.lang.Object copy()
copy in interface IRenderer
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||