    001/* ===========================================================
    002 * Orson Charts : a 3D chart library for the Java(tm) platform
    003 * ===========================================================
    004 *
    005 * (C)opyright 2013-2016, by Object Refinery Limited.  All rights reserved.
    006 *
    007 * http://www.object-refinery.com/orsoncharts/index.html
    008 *
    009 * This program is free software: you can redistribute it and/or modify
    010 * it under the terms of the GNU General Public License as published by
    011 * the Free Software Foundation, either version 3 of the License, or
    012 * (at your option) any later version.
    013 *
    014 * This program is distributed in the hope that it will be useful,
    015 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    017 * GNU General Public License for more details.
    018 *
    019 * You should have received a copy of the GNU General Public License
    020 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
    021 *
    022 * [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
    023 * Other names may be trademarks of their respective owners.]
    024 *
    025 * If you do not wish to be bound by the terms of the GPL, an alternative
    026 * commercial license can be purchased.  For details, please see visit the
    027 * Orson Charts home page:
    028 *
    029 * http://www.object-refinery.com/orsoncharts/index.html
    030 *
    031 */
    032
    033package com.orsoncharts.util;
    034
    035/**
    036 * An enumeration of reference points within a rectangle.  These reference
    037 * points are used to place titles, legends and other labels.
    038 *
    039 * @see Anchor2D
    040 */
    041public enum RefPt2D {
    042
    043    /** The top-left corner of a rectangle. */
    044    TOP_LEFT,
    045
    046    /** The middle of a rectangle at the top. */
    047    TOP_CENTER,
    048
    049    /** The top-right corner of a rectangle. */
    050    TOP_RIGHT,
    051
    052    /** The middle of a rectangle at the left side. */
    053    CENTER_LEFT,
    054
    055    /** The center of a rectangle. */
    056    CENTER,
    057
    058    /** The middle of a rectangle at the right side. */
    059    CENTER_RIGHT,
    060
    061    /** The bottom-left corner of a rectangle. */
    062    BOTTOM_LEFT,
    063
    064    /** The middle of a rectangle at the bottom. */
    065    BOTTOM_CENTER,
    066
    067    /** The bottom-right corner of a rectangle. */
    068    BOTTOM_RIGHT;
    069
    070    /**
    071     * Returns {@code true} if the reference point is at the left, and
    072     * {@code false} otherwise.
    073     *
    074     * @return A boolean.
    075     */
    076    public boolean isLeft() {
    077        return (this == TOP_LEFT || this == CENTER_LEFT || this == BOTTOM_LEFT);
    078    }
    079
    080    /**
    081     * Returns {@code true} if the reference point is at the right, and
    082     * {@code false} otherwise.
    083     *
    084     * @return A boolean.
    085     */
    086    public boolean isRight() {
    087        return (this == TOP_RIGHT || this == CENTER_RIGHT
    088                || this == BOTTOM_RIGHT);
    089    }
    090
    091    /**
    092     * Returns {@code true} if the reference point is at the center
    093     * horizontally, and {@code false} otherwise.
    094     *
    095     * @return A boolean.
    096     */
    097    public boolean isHorizontalCenter() {
    098        return (this == TOP_CENTER || this == CENTER
    099                || this == BOTTOM_CENTER);
    100    }
    101
    102    /**
    103     * Returns {@code true} if the reference point is at the top, and
    104     * {@code false} otherwise.
    105     *
    106     * @return A boolean.
    107     */
    108    public boolean isTop() {
    109        return (this == TOP_LEFT || this == TOP_CENTER || this == TOP_RIGHT);
    110    }
    111
    112    /**
    113     * Returns {@code true} if the reference point is at the bottom, and
    114     * {@code false} otherwise.
    115     *
    116     * @return A boolean.
    117     */
    118    public boolean isBottom() {
    119        return (this == BOTTOM_LEFT || this == BOTTOM_CENTER
    120                || this == BOTTOM_RIGHT);
    121    }
    122
    123    /**
    124     * Returns {@code true} if the reference point is at the center
    125     * vertically, and {@code false} otherwise.
    126     *
    127     * @return A boolean.
    128     */
    129    public boolean isVerticalCenter() {
    130        return (this == CENTER_LEFT || this == CENTER
    131                || this == CENTER_RIGHT);
    132    }
    133}