public class Static2DTools extends Object
| Modifier and Type | Field and Description |
|---|---|
static int |
BOTTOM |
static int |
CENTER |
static int |
HORIZONTAL |
static int |
LEFT |
static int |
RIGHT |
static int |
TOP |
static int |
VERTICAL |
| Constructor and Description |
|---|
Static2DTools() |
| Modifier and Type | Method and Description |
|---|---|
static BufferedImage |
appendImage(Image base,
Image append)
Appends the second image to the first image.
|
static Icon |
borderIcon(Icon icon,
int left,
int right,
int top,
int bottom)
DOCUMENT ME!
|
static ImageIcon |
createOverlayIcon(ImageIcon overlayIcon,
int width,
int heigth)
DOCUMENT ME!
|
static Color |
getAlphaColor(Color c,
int alpha)
DOCUMENT ME!
|
static BufferedImage |
getFasterScaledInstance(BufferedImage img,
int targetWidth,
int targetHeight,
Object hint,
boolean progressiveBilinear)
Convenience method that returns a scaled instance of the provided BufferedImage.
|
static Color |
getOffsetAlphaColor(Color c,
Color offset,
int alpha)
DOCUMENT ME!
|
static Color |
getOffsetAlphaColor(Color c,
int offset,
int alpha)
DOCUMENT ME!
|
static boolean |
hasAlpha(Image image)
This method returns true if the specified image has transparent pixels.
|
static Icon |
joinIcons(Icon[] icons,
int gap,
int orientation,
int alignment)
DOCUMENT ME!
|
static Icon |
mergeIcons(Icon base,
Icon overlay)
DOCUMENT ME!
|
static Image |
removeUnusedBorder(Image i,
int borderPixelsAfterwards,
double scalingFactor)
DOCUMENT ME!
|
static BufferedImage |
rotate(BufferedImage image,
double angle,
boolean radian,
Color backgroundColor)
Rotates the given
BufferedImage in the given angle around the icon's center point. |
static ImageIcon |
rotate(ImageIcon icon,
double angle,
boolean radian)
Rotates the given
ImageIcon in the given angle around the icon's center point. |
static Image |
scaleImage(Image i,
double scalingFactor)
DOCUMENT ME!
|
static BufferedImage |
toBufferedImage(Image image)
Creates a
BufferedImage from the given Image. |
static BufferedImage |
toCompatibleImage(Image image)
DOCUMENT ME!
|
public static int HORIZONTAL
public static int VERTICAL
public static int LEFT
public static int RIGHT
public static int TOP
public static int BOTTOM
public static int CENTER
public static Icon joinIcons(Icon[] icons, int gap, int orientation, int alignment)
icons - DOCUMENT ME!gap - DOCUMENT ME!orientation - DOCUMENT ME!alignment - DOCUMENT ME!IllegalArgumentException - DOCUMENT ME!public static ImageIcon createOverlayIcon(ImageIcon overlayIcon, int width, int heigth)
overlayIcon - DOCUMENT ME!width - DOCUMENT ME!heigth - DOCUMENT ME!public static Icon mergeIcons(Icon base, Icon overlay)
base - DOCUMENT ME!overlay - DOCUMENT ME!public static BufferedImage toBufferedImage(Image image)
BufferedImage from the given Image.image - the Image to be turned intoBufferedImage that is identical to the given Imagepublic static boolean hasAlpha(Image image)
image - the image to test for alpha valuespublic static ImageIcon rotate(ImageIcon icon, double angle, boolean radian)
ImageIcon in the given angle around the icon's center point. Rotation is clock-wise if
the given angle is positive or counter clock-wise if the given angle is negative. There is no necessity to stick
to the bounds described for the angle parameter but there is no sense to rotate in an angle of e.g
765 degrees because in this case a rotation in an angle of 45 degrees is more senseful. However, this method will
accept any double values as an angle. Special double values such as Double.NaN
Double.NEGATIVE_INFINITY and Double.POSITIVE_INFINITY will be handle as if angle is
0.icon - the ImageIcon to rotateangle - the rotation angle, presumably a value between 0 and +/-PI if angle is in radian measure or 0
and +/-180 degrees.radian - determines whether the given angle will be handles as an radian measure or notImageIconIllegalArgumentException - if the given icon is nullpublic static BufferedImage rotate(BufferedImage image, double angle, boolean radian, Color backgroundColor)
BufferedImage in the given angle around the icon's center point. Rotation is clock-wise
if the given angle is positive or counter clock-wise if the given angle is negative. There is no necessity to
stick to the bounds described for the angle parameter but there is no sense to rotate in an angle of
e.g 765 degrees because in this case a rotation in an angle of 45 degrees is more senseful. However, this method
will accept any double values as an angle. Special double values such as Double.NaN
Double.NEGATIVE_INFINITY and Double.POSITIVE_INFINITY will be handle as if angle is
0.
This method uses AffineTransform to rotate the image, but without using any AffineTransform.rotate()
method. It's not that easy to specify the rotation center of the given image, because you have to use whether
(image.getHeight() / 2, image.getHeight() / 2) or (image.getWidth() / 2, image.getWidth() / 2) depending on the
angle. It's easier to simulate the steps necessary to rotate the image. See
http://stackoverflow.com/questions/2257141/problems-rotating-bufferedimage for further information.
image - the BufferedImage to rotateangle - the rotation angle, presumably a value between 0 and +/-PI if angle is in radian
measure or 0 and +/-180 degrees.radian - determines whether the given angle will be handles as an radian measure or notbackgroundColor - the color to be used as backgroundBufferedImageIllegalArgumentException - if the given image is nullpublic static Icon borderIcon(Icon icon, int left, int right, int top, int bottom)
icon - DOCUMENT ME!left - DOCUMENT ME!right - DOCUMENT ME!top - DOCUMENT ME!bottom - DOCUMENT ME!public static Image removeUnusedBorder(Image i, int borderPixelsAfterwards, double scalingFactor)
i - DOCUMENT ME!borderPixelsAfterwards - DOCUMENT ME!scalingFactor - DOCUMENT ME!public static Image scaleImage(Image i, double scalingFactor)
i - DOCUMENT ME!scalingFactor - DOCUMENT ME!public static BufferedImage toCompatibleImage(Image image)
image - DOCUMENT ME!public static Color getAlphaColor(Color c, int alpha)
c - DOCUMENT ME!alpha - DOCUMENT ME!public static Color getOffsetAlphaColor(Color c, int offset, int alpha)
c - DOCUMENT ME!offset - DOCUMENT ME!alpha - DOCUMENT ME!public static Color getOffsetAlphaColor(Color c, Color offset, int alpha)
c - DOCUMENT ME!offset - DOCUMENT ME!alpha - DOCUMENT ME!public static BufferedImage getFasterScaledInstance(BufferedImage img, int targetWidth, int targetHeight, Object hint, boolean progressiveBilinear)
img - the original image to be scaledtargetWidth - the desired width of the scaled instance, in pixelstargetHeight - the desired height of the scaled instance, in pixelshint - one of the rendering hints that corresponds to RenderingHints.KEY_INTERPOLATION
(e.g. RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR,
RenderingHints.VALUE_INTERPOLATION_BILINEAR,
RenderingHints.VALUE_INTERPOLATION_BICUBIC)progressiveBilinear - if true, this method will use a multi-step scaling technique that provides higher
quality than the usual one-step technique (only useful in down-scaling cases, where
targetWidth or targetHeight is smaller than the original dimensions)public static BufferedImage appendImage(Image base, Image append)
base - the base imageappend - the image that should be appended to the baseCopyright © 2012–2026 cismet GmbH. All rights reserved.