Logo Search packages:      
Sourcecode: jlgui version File versions  Download package

AbsoluteConstraints.java

/*
 * AbsoluteConstraints.
 * 
 * JavaZOOM : jlgui@javazoom.net
 *            http://www.javazoom.net
 *
 *-----------------------------------------------------------------------
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU Library General Public License as published
 *   by the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU Library General Public License for more details.
 *
 *   You should have received a copy of the GNU Library General Public
 *   License along with this program; if not, write to the Free Software
 *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *----------------------------------------------------------------------
 */
package javazoom.jlgui.player.amp.skin;

import java.awt.Dimension;
import java.awt.Point;

/**
 * An object that encapsulates position and (optionally) size for
 * Absolute positioning of components.
 */
00032 public class AbsoluteConstraints implements java.io.Serializable
{
    /**
     * generated Serialized Version UID
     */
00037     static final long serialVersionUID = 5261460716622152494L;
    /**
     * The X position of the component
     */
00041     public int x;
    /**
     * The Y position of the component
     */
00045     public int y;
    /**
     * The width of the component or -1 if the component's preferred width should be used
     */
00049     public int width = -1;
    /**
     * The height of the component or -1 if the component's preferred height should be used
     */
00053     public int height = -1;

    /**
     * Creates a new AbsoluteConstraints for specified position.
     *
     * @param pos The position to be represented by this AbsoluteConstraints
     */
00060     public AbsoluteConstraints(Point pos)
    {
        this(pos.x, pos.y);
    }

    /**
     * Creates a new AbsoluteConstraints for specified position.
     *
     * @param x The X position to be represented by this AbsoluteConstraints
     * @param y The Y position to be represented by this AbsoluteConstraints
     */
00071     public AbsoluteConstraints(int x, int y)
    {
        this.x = x;
        this.y = y;
    }

    /**
     * Creates a new AbsoluteConstraints for specified position and size.
     *
     * @param pos  The position to be represented by this AbsoluteConstraints
     * @param size The size to be represented by this AbsoluteConstraints or null
     *             if the component's preferred size should be used
     */
00084     public AbsoluteConstraints(Point pos, Dimension size)
    {
        this.x = pos.x;
        this.y = pos.y;
        if (size != null)
        {
            this.width = size.width;
            this.height = size.height;
        }
    }

    /**
     * Creates a new AbsoluteConstraints for specified position and size.
     *
     * @param x      The X position to be represented by this AbsoluteConstraints
     * @param y      The Y position to be represented by this AbsoluteConstraints
     * @param width  The width to be represented by this AbsoluteConstraints or -1 if the
     *               component's preferred width should be used
     * @param height The height to be represented by this AbsoluteConstraints or -1 if the
     *               component's preferred height should be used
     */
00105     public AbsoluteConstraints(int x, int y, int width, int height)
    {
        this.x = x;
        this.y = y;
        this.width = width;
        this.height = height;
    }

    /**
     * @return The X position represented by this AbsoluteConstraints
     */
00116     public int getX()
    {
        return x;
    }

    /**
     * @return The Y position represented by this AbsoluteConstraints
     */
00124     public int getY()
    {
        return y;
    }

    /**
     * @return The width represented by this AbsoluteConstraints or -1 if the
     *         component's preferred width should be used
     */
00133     public int getWidth()
    {
        return width;
    }

    /**
     * @return The height represented by this AbsoluteConstraints or -1 if the
     *         component's preferred height should be used
     */
00142     public int getHeight()
    {
        return height;
    }

    public String toString()
    {
        return super.toString() + " [x=" + x + ", y=" + y + ", width=" + width + ", height=" + height + "]";
    }
}

Generated by  Doxygen 1.6.0   Back to index