Class Bounds

  • All Implemented Interfaces:
    IRenderingElement

    public final class Bounds
    extends Object
    implements IRenderingElement
    Defines a bounding box element which the renderer can use to determine the true drawing limits. Using only atom coordinates adjuncts (e.g. hydrogen labels) may be truncated. If a generator provide a bounding box element, then the min/max bounds of all bounding boxes are utilised.
    Author:
    John May
    Source code:
    main
    Belongs to CDK module:
    renderbasic
    • Field Detail

      • minX

        public double minX
        Minimum x/y coordinates.
      • minY

        public double minY
        Minimum x/y coordinates.
      • maxX

        public double maxX
        Maximum x/y coordinates.
      • maxY

        public double maxY
        Maximum x/y coordinates.
    • Constructor Detail

      • Bounds

        public Bounds​(double x1,
                      double y1,
                      double x2,
                      double y2)
        Specify the min/max coordinates of the bounding box.
        Parameters:
        x1 - min x coordinate
        y1 - min y coordinate
        x2 - max x coordinate
        y2 - max y coordinate
      • Bounds

        public Bounds()
        An empty bounding box.
      • Bounds

        public Bounds​(IRenderingElement element)
        An bounding box around the specified element.
    • Method Detail

      • add

        public void add​(IRenderingElement element)
        Add the specified element bounds.
      • add

        public void add​(double x,
                        double y)
        Ensure the point x,y is included in the bounding box.
        Parameters:
        x - x-coordinate
        y - y-coordinate
      • add

        public void add​(Bounds bounds)
        Add one bounds to another.
        Parameters:
        bounds - other bounds
      • root

        public IRenderingElement root()
        Access the root rendering element, it contains all elements added to the bounds so far.
        Returns:
        root rendering element
      • width

        public double width()
        Specifies the width of the bounding box.
        Returns:
        the width of the bounding box
      • height

        public double height()
        Specifies the height of the bounding box.
        Returns:
        the height of the bounding box
      • isEmpty

        public boolean isEmpty()
        The bounds are empty and contain no elements.
        Returns:
        bounds are empty (true) or not (false)