Java Code Examples for java.awt.Dimension.clone()

The following are Jave code examples for showing how to use clone() of the java.awt.Dimension class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: OpenJSharp   File: ImageReadParam.java   View Source Code Vote up 4 votes
/**
 * If the image is able to be rendered at an arbitrary size, sets
 * the source width and height to the supplied values.  Note that
 * the values returned from the <code>getWidth</code> and
 * <code>getHeight</code> methods on <code>ImageReader</code> are
 * not affected by this method; they will continue to return the
 * default size for the image.  Similarly, if the image is also
 * tiled the tile width and height are given in terms of the default
 * size.
 *
 * <p> Typically, the width and height should be chosen such that
 * the ratio of width to height closely approximates the aspect
 * ratio of the image, as returned from
 * <code>ImageReader.getAspectRatio</code>.
 *
 * <p> If this plug-in does not allow the rendering size to be
 * set, an <code>UnsupportedOperationException</code> will be
 * thrown.
 *
 * <p> To remove the render size setting, pass in a value of
 * <code>null</code> for <code>size</code>.
 *
 * @param size a <code>Dimension</code> indicating the desired
 * width and height.
 *
 * @exception IllegalArgumentException if either the width or the
 * height is negative or 0.
 * @exception UnsupportedOperationException if image resizing
 * is not supported by this plug-in.
 *
 * @see #getSourceRenderSize
 * @see ImageReader#getWidth
 * @see ImageReader#getHeight
 * @see ImageReader#getAspectRatio
 */
public void setSourceRenderSize(Dimension size)
    throws UnsupportedOperationException {
    if (!canSetSourceRenderSize()) {
        throw new UnsupportedOperationException
            ("Can't set source render size!");
    }

    if (size == null) {
        this.sourceRenderSize = null;
    } else {
        if (size.width <= 0 || size.height <= 0) {
            throw new IllegalArgumentException("width or height <= 0!");
        }
        this.sourceRenderSize = (Dimension)size.clone();
    }
}
 
Example 2
Project: jdk8u-jdk   File: ImageReadParam.java   View Source Code Vote up 4 votes
/**
 * If the image is able to be rendered at an arbitrary size, sets
 * the source width and height to the supplied values.  Note that
 * the values returned from the <code>getWidth</code> and
 * <code>getHeight</code> methods on <code>ImageReader</code> are
 * not affected by this method; they will continue to return the
 * default size for the image.  Similarly, if the image is also
 * tiled the tile width and height are given in terms of the default
 * size.
 *
 * <p> Typically, the width and height should be chosen such that
 * the ratio of width to height closely approximates the aspect
 * ratio of the image, as returned from
 * <code>ImageReader.getAspectRatio</code>.
 *
 * <p> If this plug-in does not allow the rendering size to be
 * set, an <code>UnsupportedOperationException</code> will be
 * thrown.
 *
 * <p> To remove the render size setting, pass in a value of
 * <code>null</code> for <code>size</code>.
 *
 * @param size a <code>Dimension</code> indicating the desired
 * width and height.
 *
 * @exception IllegalArgumentException if either the width or the
 * height is negative or 0.
 * @exception UnsupportedOperationException if image resizing
 * is not supported by this plug-in.
 *
 * @see #getSourceRenderSize
 * @see ImageReader#getWidth
 * @see ImageReader#getHeight
 * @see ImageReader#getAspectRatio
 */
public void setSourceRenderSize(Dimension size)
    throws UnsupportedOperationException {
    if (!canSetSourceRenderSize()) {
        throw new UnsupportedOperationException
            ("Can't set source render size!");
    }

    if (size == null) {
        this.sourceRenderSize = null;
    } else {
        if (size.width <= 0 || size.height <= 0) {
            throw new IllegalArgumentException("width or height <= 0!");
        }
        this.sourceRenderSize = (Dimension)size.clone();
    }
}
 
Example 3
Project: openjdk-jdk10   File: ImageReadParam.java   View Source Code Vote up 4 votes
/**
 * If the image is able to be rendered at an arbitrary size, sets
 * the source width and height to the supplied values.  Note that
 * the values returned from the {@code getWidth} and
 * {@code getHeight} methods on {@code ImageReader} are
 * not affected by this method; they will continue to return the
 * default size for the image.  Similarly, if the image is also
 * tiled the tile width and height are given in terms of the default
 * size.
 *
 * <p> Typically, the width and height should be chosen such that
 * the ratio of width to height closely approximates the aspect
 * ratio of the image, as returned from
 * {@code ImageReader.getAspectRatio}.
 *
 * <p> If this plug-in does not allow the rendering size to be
 * set, an {@code UnsupportedOperationException} will be
 * thrown.
 *
 * <p> To remove the render size setting, pass in a value of
 * {@code null} for {@code size}.
 *
 * @param size a {@code Dimension} indicating the desired
 * width and height.
 *
 * @exception IllegalArgumentException if either the width or the
 * height is negative or 0.
 * @exception UnsupportedOperationException if image resizing
 * is not supported by this plug-in.
 *
 * @see #getSourceRenderSize
 * @see ImageReader#getWidth
 * @see ImageReader#getHeight
 * @see ImageReader#getAspectRatio
 */
public void setSourceRenderSize(Dimension size)
    throws UnsupportedOperationException {
    if (!canSetSourceRenderSize()) {
        throw new UnsupportedOperationException
            ("Can't set source render size!");
    }

    if (size == null) {
        this.sourceRenderSize = null;
    } else {
        if (size.width <= 0 || size.height <= 0) {
            throw new IllegalArgumentException("width or height <= 0!");
        }
        this.sourceRenderSize = (Dimension)size.clone();
    }
}