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

The following examples show how to use java.awt.Dimension#clone() . These examples are extracted from open source projects. 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 Project: jenetics   File: EngineParam.java    License: 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 2
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 3
/**
 * 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
/**
 * 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
/**
 * 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
/**
 * 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 Project: JDKSourceCode1.8   File: ImageReadParam.java    License: 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 8
/**
 * 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
/**
 * 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 Project: Bytecoder   File: ImageReadParam.java    License: 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 11
/**
 * 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 12
/**
 * 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 13
Source Project: Java8CN   File: ImageReadParam.java    License: 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 14
/**
 * 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
/**
 * 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
/**
 * 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
/**
 * 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
/**
 * 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
/**
 * 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 Project: pumpernickel   File: GifWriter.java    License: 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);
}