Documentation of 'org.jhotdraw.draw.GridConstrainer' Java class
GridConstrainer
org.jhotdraw.draw

Class GridConstrainer

    • Constructor Detail

      • GridConstrainer

        public GridConstrainer()
        Creates a new instance with a grid of 1x1.
      • GridConstrainer

        public GridConstrainer(double width,
                               double height)
        Creates a new instance with the specified grid size, and by 11.25° (in degrees) for rotations. The grid is visible.
        Parameters:
        width - The width of a grid cell.
        height - The height of a grid cell.
      • GridConstrainer

        public GridConstrainer(double width,
                               double height,
                               boolean visible)
        Creates a new instance with the specified grid size. and by 11.25° (in degrees) for rotations.
        Parameters:
        width - The width of a grid cell.
        height - The height of a grid cell.
        visible - Wether the grid is visible or not.
      • GridConstrainer

        public GridConstrainer(double width,
                               double height,
                               double theta,
                               boolean visible)
        Creates a new instance with the specified grid size.
        Parameters:
        width - The width of a grid cell.
        height - The height of a grid cell.
        theta - The theta for rotations in radians.
        visible - Wether the grid is visible or not.
    • Method Detail

      • getWidth

        public double getWidth()
      • getHeight

        public double getHeight()
      • getTheta

        public double getTheta()
      • setWidth

        public void setWidth(double newValue)
      • setHeight

        public void setHeight(double newValue)
      • setTheta

        public void setTheta(double newValue)
      • constrainPoint

        public java.awt.geom.Point2D.Double constrainPoint(java.awt.geom.Point2D.Double p)
        Constrains a point to the closest grid point in any direction.
        Parameters:
        p - A point on the drawing.
        Returns:
        Returns the constrained point.
      • translatePoint

        public java.awt.geom.Point2D.Double translatePoint(java.awt.geom.Point2D.Double p,
                                                           TranslationDirection dir)
        Moves a point to the closest grid point in a direction.
        Parameters:
        p - A point on the drawing.
        dir - A direction.
        Returns:
        Returns the constrained point.
      • constrainRectangle

        public java.awt.geom.Rectangle2D.Double constrainRectangle(java.awt.geom.Rectangle2D.Double r)
        Description copied from interface: Constrainer
        Constrains the placement of a rectangle towards the closest constrainment in any direction.

        This method changes the location of the rectangle which is passed as a parameter. This method does not change the size of the rectangle.

        Parameters:
        r - A rectangle on the drawing.
        Returns:
        Returns the constrained rectangle.
      • translateRectangle

        public java.awt.geom.Rectangle2D.Double translateRectangle(java.awt.geom.Rectangle2D.Double r,
                                                                   TranslationDirection dir)
        Description copied from interface: Constrainer
        Moves a rectangle to the closest constrained location in the specified direction.

        This method changes the location of the rectangle which is passed as a parameter. This method only performs a translation - it does not change the size of the rectangle.

        Parameters:
        r - A rectangle on the drawing.
        dir - A direction.
        Returns:
        Returns the constrained rectangle.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • isVisible

        public boolean isVisible()
      • setVisible

        public void setVisible(boolean newValue)
      • getMajorGridSpacing

        public int getMajorGridSpacing()
        Spacing between major grid lines.
      • setMajorGridSpacing

        public void setMajorGridSpacing(int newValue)
        Spacing between major grid lines.
      • draw

        public void draw(java.awt.Graphics2D g,
                         DrawingView view)
        Description copied from interface: Constrainer
        Draws the constrainer grid for the specified drawing view.
      • constrainAngle

        public double constrainAngle(double angle)
        Description copied from interface: Constrainer
        Constrains the given angle (in radians). This method changes the angle which is passed as a parameter.
        Parameters:
        angle - The angle (in radians).
        Returns:
        The closest constrained angle (in radians).
      • rotateAngle

        public double rotateAngle(double angle,
                                  RotationDirection dir)
        Description copied from interface: Constrainer
        Moves the given angle (in radians) to the closest constrained orientation in the specified direction.
        Parameters:
        angle - The angle (in radians).
        Returns:
        The closest constrained angle (in radians) in the specified direction.

DataMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.