    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.graphics3d;
    034
    035import java.awt.Graphics2D;
    036import java.awt.geom.Rectangle2D;
    037
    038import com.orsoncharts.Chart3D;
    039import com.orsoncharts.graphics3d.swing.Panel3D;
    040
    041/**
    042 * A three dimensional scene that can be viewed from an arbitrary viewpoint
    043 * and rendered to any {@link Graphics2D} instance.  The {@link Chart3D} class
    044 * implements this interface.
    045 *
    046 * @see Panel3D
    047 */
    048public interface Drawable3D {
    049
    050    /**
    051     * Returns the aggregate dimensions of the objects in the 3D scene.  This
    052     * will be a bounding box for all the objects.  One use for this
    053     * information is to determine a suitable default viewing distance for
    054     * a given scene (one that sizes the 2D projection to something appropriate
    055     * for the available drawing space).
    056     *
    057     * @return The dimensions (never {@code null}).
    058     */
    059    Dimension3D getDimensions();
    060
    061    /**
    062     * Returns the point from which the 3D scene is viewed.  The viewing point
    063     * determines how the 3D scene is projected onto the 2D viewing plane in
    064     * the {@link #draw(java.awt.Graphics2D, java.awt.geom.Rectangle2D)} method.
    065     *
    066     * @return The view point (never {@code null}).
    067     */
    068    ViewPoint3D getViewPoint();
    069
    070    /**
    071     * Sets a new view point.  Note that the {@code ViewPoint3D} class is
    072     * implemented so that its position and orientation can be updated directly,
    073     * so you should use this method only when you want to set an entirely
    074     * new view point.
    075     *
    076     * @param viewPoint  the view point ({@code null} not permitted).
    077     */
    078    void setViewPoint(ViewPoint3D viewPoint);
    079
    080    /**
    081     * Returns the projection distance.  A typical value is {@code 1500},
    082     * higher numbers flatten out the perspective and reduce distortion in the
    083     * projected image.
    084     *
    085     * @return The projection distance.
    086     *
    087     * @since 1.2
    088     */
    089    double getProjDistance();
    090
    091    /**
    092     * Sets the projection distance.  A typical value is {@code 1500} (but this
    093     * will depend on the dimensions of the scene), higher numbers flatten out
    094     * the perspective and reduce distortion in the projected image.
    095     *
    096     * @param dist  the distance.
    097     *
    098     * @since 1.2
    099     */
    100    void setProjDistance(double dist);
    101
    102    /**
    103     * Returns the 2D offset for the scene.  Normally this will default
    104     * to {@code (0, 0)}.
    105     *
    106     * @return The translation offset (never {@code null}).
    107     */
    108    Offset2D getTranslate2D();
    109
    110    /**
    111     * Sets the translation offset.  This is typically used to allow the user
    112     * to modify the offset of a 2D projection on-screen by dragging with the
    113     * mouse.
    114     *
    115     * @param offset  the translation offset ({@code null} not permitted).
    116     */
    117    void setTranslate2D(Offset2D offset);
    118
    119    /**
    120     * Draws the scene to the supplied {@code Graphics2D} target and returns
    121     * an object containing state information about the rendering.
    122     *
    123     * @param g2  the graphics target ({@code null} not permitted).
    124     * @param bounds  the bounds ({@code null} not permitted).
    125     *
    126     * @return State information about the 3D scene that has been drawn
    127     *         (never {@code null}).
    128     */
    129    RenderingInfo draw(Graphics2D g2, Rectangle2D bounds);
    130
    131}