Java Geometry Algorithm checkPoint(Point point, String name)

Here you can find the source of checkPoint(Point point, String name)

Description

Checks a Point.

License

Open Source License

Parameter

Parameter Description
point the Point to be checked.
name the name of the Point.

Exception

Parameter Description
IllegalArgumentException If the Point is null or its x/y is negative.

Declaration

public static void checkPoint(Point point, String name) 

Method Source Code

//package com.java2s;
import java.awt.Point;

public class Main {
    /**/*w w w.jav  a 2  s .co  m*/
     * <p>
     * Checks a Point.
     * If the Point is null or its x/y is negative, throw an <code>IllegalArgumentException</code>.
     * </p>
     *
     * @param point
     *        the Point to be checked.
     * @param name
     *        the name of the Point.
     * @throws IllegalArgumentException
     *         If the Point is null or its x/y is negative.
     */
    public static void checkPoint(Point point, String name) {
        checkNull(point, name);
        checkNegative(point.x, name + "'s x");
        checkNegative(point.y, name + "'s y");
    }

    /**
     * <p>
     * Checks an Object.
     * If the Object is null, throw an <code>IllegalArgumentException</code>.
     * </p>
     *
     * @param obj
     *        the Object to be checked.
     * @param name
     *        the name of the obj.
     * @throws IllegalArgumentException
     *         If the Object is null.
     */
    public static void checkNull(Object obj, String name) {
        if (obj == null) {
            throw new IllegalArgumentException("The [" + name
                    + "] should not be null.");
        }
    }

    /**
     * <p>
     * Checks an int value.
     * If the int value is negative, throw an <code>IllegalArgumentException</code>.
     * </p>
     *
     * @param value
     *        the int value to be checked.
     * @param name
     *        the name of the value.
     * @throws IllegalArgumentException
     *         If the int value is negative.
     */
    public static void checkNegative(int value, String name) {
        if (value < 0) {
            throw new IllegalArgumentException("The [" + name
                    + "] should not be negative.");
        }
    }
}

Related

  1. boundingBox(Vector points)
  2. boundsOf(Collection points)
  3. cap(java.awt.geom.Point2D.Double p1, java.awt.geom.Point2D.Double p2, double radius)
  4. centroid(Vector points)
  5. checkPoint(Point p)
  6. checkWinPossibility(int[][] board, Point p1, Point p2, int playerID)
  7. circleLineIntersection(double theta, double r, double h, double k, Point2D[] result)
  8. clacGradient(Point2D p1, Point2D p2, Point2D p3)
  9. cleanList(List blueList, Polygon borders)