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 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
  • Constructor Details

    • AWTDrawVisitor

      public AWTDrawVisitor(Graphics2D graphics)
      Constructs a new IDrawVisitor using the AWT widget toolkit, taking a Graphics2D object to which the chemical content is drawn.
      Parameters:
      graphics - Graphics2D to which will be drawn
  • Method Details

    • getRendererModel

      public RendererModel getRendererModel()
      Returns the current RendererModel.
      Returns:
      the current model
    • getStrokeMap

      public Map<Integer,BasicStroke> getStrokeMap()
      Returns the current stroke map.
      Returns:
      a Map with Integer as keys and BasicStrokes.
    • getGraphics

      public Graphics2D getGraphics()
      Returns the Graphics2D 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 a IRenderingElement 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 - the IFontManager to be used
    • setRendererModel

      public void setRendererModel(RendererModel rendererModel)
      Sets the RendererModel this IDrawVisitor should use.
      Parameters:
      rendererModel - the RendererModel to be used