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

The following examples show how to use java.awt.Dimension#clone() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ActiveBagContentControlPanel.java    From jclic with GNU General Public License v2.0 6 votes vote down vote up
private boolean shaperEditBtnActionPerformed() {
  if (abc == null)
    return false;
  AbstractBox bx = parent.abcpp.getAbstractBox(visualIndex);
  Dimension d = new Dimension((int) bx.getWidth(), (int) bx.getHeight());
  Dimension dBak = (Dimension) d.clone();
  Shaper sh = abc.shaper.edit(this, options, d, abc.img, bx.getBoxBaseResolve());
  if (sh == null)
    return false;
  abc.setShaper(sh);
  abc.ncw = Math.max(1, sh.getNumColumns());
  abc.nch = Math.max(1, sh.getNumRows());
  nColsEdit.setValue(abc.ncw);
  nRowsEdit.setValue(abc.nch);
  abc.checkCells();

  if (!dBak.equals(d)) {
    abc.w = d.width / abc.ncw;
    abc.h = d.height / abc.nch;
  }
  return true;
}
 
Example 2
Source File: EngineParam.java    From jenetics with Apache License 2.0 6 votes vote down vote up
private EngineParam(
	final int populationSize,
	final int tournamentSize,
	final float mutationRate,
	final float mutationMultitude,
	final int polygonLength,
	final int polygonCount,
	final Dimension referenceImageSize
) {
	_populationSize = populationSize;
	_tournamentSize = tournamentSize;
	_mutationRate = mutationRate;
	_mutationMultitude = mutationMultitude;
	_polygonLength = polygonLength;
	_polygonCount = polygonCount;
	_referenceImageSize = (Dimension)referenceImageSize.clone();
}
 
Example 3
Source File: ImageReadParam.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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 4
Source File: ImageReadParam.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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 5
Source File: ImageReadParam.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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 6
Source File: ImageReadParam.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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 7
Source File: ImageReadParam.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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 8
Source File: ImageReadParam.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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 9
Source File: ImageReadParam.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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 10
Source File: ImageReadParam.java    From Java8CN with Apache License 2.0 4 votes vote down vote up
/**
 * 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 11
Source File: ImageReadParam.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
/**
 * 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 12
Source File: ImageReadParam.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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();
    }
}
 
Example 13
Source File: ImageReadParam.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
/**
 * 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();
    }
}
 
Example 14
Source File: ImageReadParam.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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 15
Source File: ImageReadParam.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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 16
Source File: ImageReadParam.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
/**
 * 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 17
Source File: ImageReadParam.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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 18
Source File: ImageReadParam.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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 19
Source File: ImageReadParam.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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 20
Source File: GifWriter.java    From pumpernickel with MIT License 3 votes vote down vote up
/**
 * Constructs a <code>GifWriter</code> with a global color table.
 * 
 * @param out
 *            the output stream to write to. This object will <i>not</i>
 *            close the output stream when it is finished.
 * @param size
 *            the bounds of this animation. Images larger than this value
 *            will be cut off. (Images smaller than this value will have
 *            dead space surrounding them.)
 * @param globalColorModel
 *            a byte-based <code>IndexColorModel</code> to use as a global
 *            color palette.
 * @param loopCount
 *            how many times this GIF file should loop. If this is zero (or
 *            negative), then this GIF will not loop. If this is greater
 *            than 65535, then this GIF will loop forever.
 * @param backgroundColorIndex
 *            the index in the global color table to use as a background
 *            color
 * @param customEncoder
 *            an optional encoder. If null (which is encouraged), then
 *            <code>GifEncoderFactory.get().createEncoder()</code> is used.
 * @throws IOException
 *             if the underlying <code>OutputStream</code> has trouble
 *             writing any of the GIF header information.
 */
public GifWriter(OutputStream out, Dimension size,
		IndexColorModel globalColorModel, int loopCount,
		int backgroundColorIndex, GifEncoder customEncoder)
		throws IOException {
	this.out = out;
	this.size = (Dimension) size.clone();
	this.backgroundColorIndex = backgroundColorIndex;
	encoder = customEncoder == null ? GifEncoderFactory.get()
			.createEncoder() : customEncoder;
	this.globalColorModel = globalColorModel;
	writeHeader(loopCount);
}