Class AWTDrawVisitor
- java.lang.Object
-
- org.openscience.cdk.renderer.visitor.AbstractAWTDrawVisitor
-
- org.openscience.cdk.renderer.visitor.AWTDrawVisitor
-
- All Implemented Interfaces:
IRenderingVisitor
,IDrawVisitor
public class AWTDrawVisitor extends AbstractAWTDrawVisitor
Implementation of theIDrawVisitor
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
Constructors Constructor Description AWTDrawVisitor(Graphics2D graphics)
Constructs a newIDrawVisitor
using the AWT widget toolkit, taking aGraphics2D
object to which the chemical content is drawn.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static AWTDrawVisitor
forVectorGraphics(Graphics2D g2)
Create a draw visitor that will be rendering to a vector graphics output.Graphics2D
getGraphics()
Returns theGraphics2D
for for this visitor.RendererModel
getRendererModel()
Returns the currentRendererModel
.Map<Integer,BasicStroke>
getStrokeMap()
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 Detail
-
AWTDrawVisitor
public AWTDrawVisitor(Graphics2D graphics)
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 Detail
-
getRendererModel
public RendererModel getRendererModel()
Returns the currentRendererModel
.- Returns:
- the current model
-
getStrokeMap
public Map<Integer,BasicStroke> getStrokeMap()
Returns the current stroke map.- Returns:
- a
Map
with Integer as keys andBasicStroke
s.
-
getGraphics
public Graphics2D getGraphics()
Returns theGraphics2D
for for this visitor.- Returns:
- the
Graphics2D
object
-
forVectorGraphics
public static AWTDrawVisitor forVectorGraphics(Graphics2D g2)
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
public void visit(IRenderingElement element)
Translates aIRenderingElement
into a widget toolkit specific rendering element.- Parameters:
element
- Abstract rendering element reflecting some part of the chemical drawing.
-
setFontManager
public 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.- Parameters:
fontManager
- theIFontManager
to be used
-
setRendererModel
public void setRendererModel(RendererModel rendererModel)
Sets theRendererModel
thisIDrawVisitor
should use.- Parameters:
rendererModel
- theRendererModel
to be used
-
-