Class AbstractAWTDrawVisitor

  • All Implemented Interfaces:
    IRenderingVisitor, IDrawVisitor
    Direct Known Subclasses:
    AWTDrawVisitor

    public abstract class AbstractAWTDrawVisitor
    extends Object
    implements IDrawVisitor
    Partial 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 Detail

      • transform

        protected AffineTransform transform
        This is initially null, and must be set in the setTransform method!
    • Constructor Detail

      • AbstractAWTDrawVisitor

        public AbstractAWTDrawVisitor()
    • Method Detail

      • transformPoint

        public int[] transformPoint​(double xCoord,
                                    double yCoord)
        Transforms a point according to the current affine transformation, converting a world coordinate into a screen coordinate.
        Parameters:
        xCoord - x-coordinate of the world point to transform
        yCoord - y-coordinate of the world point to transform
        Returns:
        the transformed screen coordinate
      • transformPoint

        public void transformPoint​(double[] xy)
      • getTextBounds

        protected Rectangle2D getTextBounds​(String text,
                                            double xCoord,
                                            double yCoord,
                                            Graphics2D graphics)
        Calculates the boundaries of a text string in screen coordinates.
        Parameters:
        text - the text string
        xCoord - the world x-coordinate of where the text should be placed
        yCoord - the world y-coordinate of where the text should be placed
        graphics - the graphics to which the text is provided as output
        Returns:
        the screen coordinates
      • getTextBasePoint

        protected Point getTextBasePoint​(String text,
                                         double xCoord,
                                         double yCoord,
                                         Graphics2D graphics)
        Calculates the base point where text should be rendered, as text in Java is typically placed using the left-lower corner point in screen coordinates. However, because the Java coordinate system is inverted in the y-axis with respect to scientific coordinate systems (Java has 0,0 in the top left corner, while in science we have 0,0 in the lower left corner), some special action is needed, involving the size of the text.
        Parameters:
        text - the text string
        xCoord - the world x-coordinate of where the text should be placed
        yCoord - the world y-coordinate of where the text should be placed
        graphics - the graphics to which the text is provided as output
        Returns:
        the screen coordinates
      • getTextBounds

        protected Rectangle2D getTextBounds​(String text,
                                            Graphics2D g2)
        Obtain the exact bounding box of the text in the provided graphics environment.
        Parameters:
        text - the text to obtain the bounds of
        g2 - the graphic environment
        Returns:
        bounds of the text
        See Also:
        TextLayout