Class AWTDrawVisitor
java.lang.Object
org.openscience.cdk.renderer.visitor.AbstractAWTDrawVisitor
org.openscience.cdk.renderer.visitor.AWTDrawVisitor
- All Implemented Interfaces:
IRenderingVisitor
,IDrawVisitor
Implementation of the
IDrawVisitor
interface for the AWT
widget toolkit, allowing molecules to be rendered with toolkits based on
AWT, like the Java reference graphics platform Swing.- Source code:
- main
- Belongs to CDK module:
- renderawt
-
Field Summary
Fields inherited from class org.openscience.cdk.renderer.visitor.AbstractAWTDrawVisitor
transform
-
Constructor Summary
ConstructorsConstructorDescriptionAWTDrawVisitor
(Graphics2D graphics) Constructs a newIDrawVisitor
using the AWT widget toolkit, taking aGraphics2D
object to which the chemical content is drawn. -
Method Summary
Modifier and TypeMethodDescriptionstatic AWTDrawVisitor
Create a draw visitor that will be rendering to a vector graphics output.Returns theGraphics2D
for for this visitor.Returns the currentRendererModel
.Returns the current stroke map.void
setFontManager
(IFontManager fontManager) The font manager must be set by any renderer that uses this class! This manager is needed to keep track of fonts of the right size.void
setRendererModel
(RendererModel rendererModel) Sets theRendererModel
thisIDrawVisitor
should use.void
setRounding
(boolean val) Set whether we should we round coordinates to ints, this tries to circumvent graphical glitches from AWT where floating points are truncated (e.g.void
visit
(IRenderingElement element) Translates aIRenderingElement
into a widget toolkit specific rendering element.Methods inherited from class org.openscience.cdk.renderer.visitor.AbstractAWTDrawVisitor
getTextBasePoint, getTextBounds, getTextBounds, setTransform, transformPoint, transformPoint
-
Constructor Details
-
AWTDrawVisitor
Constructs a newIDrawVisitor
using the AWT widget toolkit, taking aGraphics2D
object to which the chemical content is drawn.- Parameters:
graphics
-Graphics2D
to which will be drawn
-
-
Method Details
-
getRendererModel
Returns the currentRendererModel
.- Returns:
- the current model
-
getStrokeMap
Returns the current stroke map.- Returns:
- a
Map
with Integer as keys andBasicStroke
s.
-
getGraphics
Returns theGraphics2D
for for this visitor.- Returns:
- the
Graphics2D
object
-
forVectorGraphics
Create a draw visitor that will be rendering to a vector graphics output. This disables the minimum stroke size and stroke caching when drawing lines.- Parameters:
g2
- graphics environment- Returns:
- draw visitor
-
setRounding
public void setRounding(boolean val) Set whether we should we round coordinates to ints, this tries to circumvent graphical glitches from AWT where floating points are truncated (e.g. 1.6 -> 1) which causes notable defect such as parallel lines that aren't parallel.- Parameters:
val
- rounding mode
-
visit
Translates aIRenderingElement
into a widget toolkit specific rendering element.- Parameters:
element
- Abstract rendering element reflecting some part of the chemical drawing.
-
setFontManager
The font manager must be set by any renderer that uses this class! This manager is needed to keep track of fonts of the right size.- Parameters:
fontManager
- theIFontManager
to be used
-
setRendererModel
Sets theRendererModel
thisIDrawVisitor
should use.- Parameters:
rendererModel
- theRendererModel
to be used
-