Class 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 Detail

      • 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 Detail

      • 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