下面列出了java.awt.Dimension#clone ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
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();
}
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;
}
/**
* 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();
}
}
/**
* 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();
}
}
/**
* 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();
}
}
/**
* 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();
}
}
/**
* 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();
}
}
/**
* 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();
}
}
/**
* 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();
}
}
/**
* 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();
}
}
/**
* 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();
}
}
/**
* 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();
}
}
/**
* 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();
}
}
/**
* 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();
}
}
/**
* 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();
}
}
/**
* 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();
}
}
/**
* 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();
}
}
/**
* 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();
}
}
/**
* 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();
}
}
/**
* 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);
}