/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* ImageScalingHelper
*
* @author Created by Jasper Potts (Aug 8, 2007)
*/
class ImageScalingHelper {
/** Enumeration for the types of painting this class can handle. */
enum PaintType {
/**
* Painting type indicating the image should be centered in the space provided. When used the <code>mask</code>
* is ignored.
*/
/**
* Painting type indicating the image should be tiled across the specified width and height. When used the
* <code>mask</code> is ignored.
*/
TILE,
/**
* Painting type indicating the image should be split into nine regions with the top, left, bottom and right
* areas stretched.
*/
/**
* Painting type indicating the image should be split into nine regions with the top, left, bottom and right
* areas tiled.
*/
}
;
/**
* Specifies that all regions should be painted. If this is set any other regions specified will not be painted.
* For example PAINT_ALL | PAINT_CENTER will paint all but the center.
*/
/**
* Paints using the algorightm specified by <code>paintType</code>.
*
* @param g Graphics to render to
* @param x X-coordinate
* @param y Y-coordinate
* @param w Width to render to
* @param h Height to render to
* @param image Image to render from, if <code>null</code> this method will do nothing
* @param sInsets Insets specifying the portion of the image that will be stretched or tiled, if <code>null</code>
* empty <code>Insets</code> will be used.
* @param dInsets Destination insets specifying the portion of the image will be stretched or tiled, if
* <code>null</code> empty <code>Insets</code> will be used.
* @param paintType Specifies what type of algorithm to use in painting
* @param mask Specifies portion of image to render, if <code>PAINT_ALL</code> is specified, any other regions
* specified will not be painted, for example PAINT_ALL | PAINT_CENTER paints everything but the
* center.
*/
return;
}
}
}
// Center the image
// Tile the image
int lastIY = 0;
int lastIX = 0;
}
}
} else {
// Constrain the insets to the size of the image
}
}
// Constrain the insets to the size of the region we're painting
// in.
}
}
}
}
}
}
}
}
}
}
}
}
}
}
/**
* Draws a portion of an image, stretched or tiled.
*
* @param image Image to render.
* @param g Graphics to render to
* @param stretch Whether the image should be stretched or timed in the
* provided space.
* @param dx1 X origin to draw to
* @param dy1 Y origin to draw to
* @param dx2 End x location to draw to
* @param dy2 End y location to draw to
* @param sx1 X origin to draw from
* @param sy1 Y origin to draw from
* @param sx2 Max x location to draw from
* @param sy2 Max y location to draw from
* @param xDirection Used if the image is not stretched. If true it
* indicates the image should be tiled along the x axis.
*/
boolean xDirection) {
// Bogus location, nothing to paint
return;
}
if (stretch) {
}
else {
int deltaX;
int deltaY;
if (xDirection) {
deltaY = 0;
}
else {
deltaX = 0;
}
}
}
}
// PENDING: is this necessary, will G2D do it for me?
// Bogus location, nothing to paint
return;
}
}
}