public class GraphicsTool
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.awt.Color |
HALF_TRANSPARENT_WHITE |
static java.awt.Color |
THICK_ARROW_COLOR |
static java.awt.Color |
TRANSPARENT |
Constructor and Description |
---|
GraphicsTool() |
Modifier and Type | Method and Description |
---|---|
static boolean |
arrangeRects(java.awt.Rectangle[] rects,
java.awt.Rectangle bounds,
int unit)
Move any rectangles that overlap.
|
static boolean |
arrangeRects(java.awt.Rectangle[] r,
java.awt.Rectangle bounds,
int unit,
int bufferSize) |
static java.awt.Color |
colorFromString(java.lang.String defsString) |
static java.awt.image.BufferedImage |
convertToBufferedImage(java.awt.Image im) |
static java.awt.image.BufferedImage |
createBufferedImage(int width,
int height,
int transparency)
Create and return a BufferedImage of the desired size and transparency that is compatible with the screen.
|
static double |
distanceFromPointToGeneralPath(java.awt.geom.Point2D p,
java.awt.geom.GeneralPath path)
Return the distance the given point is to the closest segment of the GeneralPath.
|
static double |
distanceFromPointToGeneralPath(java.awt.Point p,
java.awt.geom.GeneralPath path)
Return the distance the given point is to the closest segment of the GeneralPath.
|
static double |
distanceFromPointToRect(java.awt.geom.Point2D p,
java.awt.Rectangle r)
Return the distance the given point is to the closest segment of the Rectangle.
|
static void |
drawArrow(java.awt.Graphics2D g2d,
int fromX,
int fromY,
int toX,
int toY,
float arrowheadSize,
float lineWidth)
Draw an arrow.
|
static void |
drawArrowBetweenPoints(java.awt.Graphics2D g,
java.awt.geom.Point2D p1,
java.awt.geom.Point2D p2,
boolean doubleArrow,
int arrowheadSize,
int lineWidth) |
static void |
drawArrowImage(java.awt.Graphics2D g,
double x,
double y,
double aDir) |
static void |
drawArrowImageConnectingPoints(java.awt.Graphics2D g,
java.awt.Point from,
java.awt.Point to,
boolean doubleArrow) |
static void |
drawArrowImageConnectingShapes(java.awt.Graphics2D g,
java.awt.Shape s1,
java.awt.Shape s2,
boolean doubleArrow) |
static void |
drawArrowImageDouble(java.awt.Graphics2D g,
double x,
double y,
double aDir) |
static void |
drawBoxedString(java.awt.Graphics2D g,
java.lang.String text,
int centeredAtX,
int centeredAtY,
int padding)
Draw a string (using the font set in the Graphics object) inside of a box, centered at the given co-ordinants, with the given padding on all sides.
|
static void |
drawBoxedString(java.awt.Graphics2D g,
java.lang.String text,
int centeredAtX,
int centeredAtY,
int padding,
java.awt.Color outlineColor,
int outlineWidth)
Draw the given text (using the font set in the Graphics object) centered at the point (centeredAtX, centeredAtY) along with a box that contains it.
|
static void |
drawBoxedString(java.awt.Graphics2D g,
java.lang.String text,
int centeredAtX,
int centeredAtY,
int paddingX,
int paddingY,
java.awt.Color boxColor,
java.awt.Color outlineColor,
int outlineWidth)
An upgrading drawBoxedString where it is possible to use a different X and Y padding values, and to specify the color of the box insides.
|
static void |
drawBoxedString(java.awt.Graphics2D g,
java.lang.String text,
int centeredAtX,
int centeredAtY,
int paddingX,
int paddingY,
java.awt.Color boxColor,
java.awt.Color outlineColor,
int outlineWidth,
java.awt.Color textColor)
An upgrading drawBoxedString where it is possible to use a different X and Y padding values, and to specify the color of the box insides.
|
static void |
drawBoxedStringCorneredAt(java.awt.Graphics2D g,
java.lang.String text,
int originX,
int originY,
int paddingX,
int paddingY,
java.awt.Color boxColor,
java.awt.Color outlineColor,
int outlineWidth,
java.awt.Color textColor,
boolean engraveText)
This method is like drawBoxedString, except the specified co-ordinates are the top left corner of where the box should be drawn.
|
static void |
drawDoubleArrowConnectingShapes(java.awt.Graphics2D g,
java.awt.Shape s1,
java.awt.Shape s2,
boolean doubleArrow) |
static void |
drawDoubleArrowConnectingShapesBAD(java.awt.Graphics2D g,
java.awt.Shape s1,
java.awt.Shape s2)
This version uses the basket of points approach using the getMidpointBetweenShapes() method.
|
static void |
drawEngravedString(java.awt.Graphics2D g,
java.lang.String text,
int x,
int y) |
static void |
drawHelperText(java.awt.Graphics2D g,
java.lang.String helperText,
int height) |
static void |
drawLines(java.awt.Graphics2D g,
java.util.List lines,
java.awt.Color defaultColor)
Draw a collection of ExtraLines using their width and color.
|
static void |
drawOutlinedString(java.awt.Graphics2D g,
java.lang.String text,
int x,
int y) |
static void |
drawShadowedString(java.awt.Graphics2D g,
java.lang.String text,
int x,
int y) |
static void |
drawThickArrow(java.awt.Graphics2D g2d,
int fromX,
int fromY,
int toX,
int toY) |
static java.lang.String |
flipPointStringY(java.lang.String pointString,
int height)
Take a String describing a point and return another string of the same point, but with the Y value flipped.
|
static java.awt.geom.GeneralPath |
flipY(java.awt.geom.GeneralPath path,
int height)
Take a GeneralPath and flip it vertically based on the given height.
|
static java.awt.geom.GeneralPath |
generalPathFromString(java.lang.String pathXML)
Take a string with a list of points and returns the GeneralPath it creates.
|
static java.awt.Rectangle |
getBoxedStringRectangle(java.awt.Font font,
java.lang.String text,
int centeredAtX,
int centeredAtY,
int paddingX,
int paddingY,
java.awt.Color boxColor,
java.awt.Color outlineColor,
int outlineWidth,
java.awt.Color textColor)
Return the Rectangle that contains where this boxed string would be drawn.
|
static java.awt.Image |
getBubbleFor(int count,
java.awt.Color color) |
static java.awt.image.BufferedImage |
getBufferedImageFromJAR(java.lang.String name) |
static java.awt.Point |
getCenterOfGeneralPath(java.awt.geom.GeneralPath path) |
static java.awt.Point |
getCenterOfShape(java.awt.Shape shape) |
static java.awt.Point |
getContainedPointAlongLine(java.awt.Point from,
java.awt.Point to,
java.awt.Shape shape)
Get a point just inside the Shape along the given line.
|
static java.awt.Color |
getContrastingBase(java.awt.Color versus)
Return The color WHITE or BLACK, whichever provides more contrast to the given color.
|
static java.awt.Color |
getContrastingBase(java.awt.Color versus,
float brightnessForBlack)
Return The color WHITE or BLACK, whichever provides more contrast to the given color.
|
static java.awt.GraphicsConfiguration |
getDefaultConfiguration() |
static java.awt.Font |
getDejaFontSized(int pointSize) |
static java.awt.Dimension |
getDimensionOfText(java.lang.String text,
java.awt.FontMetrics fontMetrics) |
static java.util.List |
getEllipsePoints(int x,
int y,
double a,
double b,
int numberOfPoints) |
static java.awt.geom.GeneralPath |
getGeneralPathFromXML(java.lang.String pathXML)
Take a String with one or more 'polygon' tag and returns the GeneralPath it creates.
|
static java.lang.String |
getGeneralPathXML(java.awt.geom.GeneralPath path,
int height)
Give an XML representation of the given GeneralPath (and flipping the y values of points).
|
static java.awt.Image |
getImageFromJAR(java.lang.String name) |
static javax.swing.ImageIcon |
getImageIconNamed(java.lang.String name) |
static javax.swing.JLabel |
getJLabelWithFont(java.lang.String foo,
java.awt.Font font) |
static java.awt.Image |
getManagedImage(java.lang.String filename) |
static java.awt.Image |
getManagedImageColored(java.lang.String filename,
java.awt.Color color) |
static java.awt.Image |
getManagedImageColored(java.lang.String filename,
java.awt.Color color,
float transparent) |
static java.awt.Point |
getMidpointBetweenShapes(java.awt.Shape s1,
java.awt.Shape s2,
java.awt.geom.Point2D shape1point,
java.awt.geom.Point2D shape2point)
This method returns the a Point between the 2 shapes that is the closest to them both.
|
static java.awt.Color |
getNextColor()
This method will generate a series of Color objects with an attempt at making them contrast with each other.
|
static javax.swing.JPanel |
getNonOpaqueJPanel() |
static javax.swing.JPanel |
getNonOpaqueJPanel(java.awt.LayoutManager lm) |
static double |
getResizePercentToFitInsideDimension(int startingWidth,
int startingHeight,
double fitIntoWidth,
double fitIntoHeight)
Get the resize percentage to fit the starting dimension size into the fitInto dimension size, while maintaining the width:height ratio.
|
static java.awt.image.BufferedImage |
getScaledInstance(java.awt.image.BufferedImage img,
int targetWidth,
int targetHeight,
java.lang.Object hint,
boolean higherQuality)
Convenience method that returns a scaled instance of the
provided
BufferedImage . |
static java.awt.Font |
getSymbolFont() |
static java.awt.Font |
getSymbolFontForBonus(java.awt.Graphics2D g,
int bonus) |
static java.awt.Polygon |
getThickArrowPolygon(int fromX,
int fromY,
int toX,
int toY) |
static java.awt.Polygon |
getThickArrowPolygon(java.awt.Point from,
java.awt.Point to) |
static void |
initGraphicsTool(java.lang.String supportFolderPath_set,
java.lang.String modernResourcesLocation_set) |
static java.awt.Point |
midpoint(java.awt.geom.Point2D a,
java.awt.geom.Point2D b) |
static java.awt.geom.Point2D |
midpoint2D(java.awt.geom.Point2D a,
java.awt.geom.Point2D b) |
static java.awt.Image |
paintColorOverImage(java.awt.Image sourceImage,
java.awt.Color paintColor) |
static java.awt.Image |
paintColorOverImage(int width,
int height,
java.awt.Image sourceImage,
java.awt.Color paintColor) |
static java.awt.Image |
paintColorOverImage(int width,
int height,
java.awt.Image sourceImage,
java.awt.Color paintColor,
float transparent) |
static java.awt.Point |
pointFromString(java.lang.String loc) |
static void |
printManagedImageList() |
static void |
releaseManagedImage(java.lang.String filename) |
static void |
releaseManagedImages() |
static void |
releaseManagedImagesColored() |
static java.awt.geom.GeneralPath |
resizeShape(java.awt.Shape shape,
double percent) |
static void |
saveComponentAsJPEG(java.awt.Component myComponent,
java.lang.String filename,
boolean thumbnail,
int width,
int height,
boolean isVox)
Save a component into a JPEG.
|
static void |
saveComponentAsMiniPNG(java.awt.Component myComponent,
java.lang.String filename,
int width,
int height) |
static void |
saveComponentAsPNG(java.awt.Component myComponent,
java.lang.String filename,
boolean thumbnail,
int width,
int height) |
static java.awt.Color |
solid(java.awt.Color color) |
static java.lang.String |
stringFromColor(java.awt.Color color) |
static java.lang.String |
stringFromGeneralPath(java.awt.geom.GeneralPath path)
Give a String representation of the given GeneralPath.
|
static java.lang.String |
stringFromGeneralPath(java.awt.geom.GeneralPath path,
int height)
Give a String representation of the given GeneralPath with a flipped Y.
|
static java.lang.String |
stringFromPoint(java.awt.Point p) |
static java.awt.image.BufferedImage |
toBufferedImage(java.awt.Image image,
java.awt.GraphicsConfiguration gc)
Take an Image and return the same as an BufferedImage.
|
static java.awt.Color |
transparent(java.awt.Color color,
float alpha) |
static java.lang.String |
wrapString(java.lang.String text,
int pixelWidth,
java.awt.Font font) |
static int |
xCor(int len,
double dir) |
static int |
yCor(int len,
double dir) |
public static final java.awt.Color HALF_TRANSPARENT_WHITE
public static final java.awt.Color THICK_ARROW_COLOR
public static final java.awt.Color TRANSPARENT
public static boolean arrangeRects(java.awt.Rectangle[] rects, java.awt.Rectangle bounds, int unit)
public static boolean arrangeRects(java.awt.Rectangle[] r, java.awt.Rectangle bounds, int unit, int bufferSize)
public static java.awt.Color colorFromString(java.lang.String defsString)
public static java.awt.image.BufferedImage convertToBufferedImage(java.awt.Image im)
public static java.awt.image.BufferedImage createBufferedImage(int width, int height, int transparency)
public static double distanceFromPointToGeneralPath(java.awt.geom.Point2D p, java.awt.geom.GeneralPath path)
public static double distanceFromPointToGeneralPath(java.awt.Point p, java.awt.geom.GeneralPath path)
public static double distanceFromPointToRect(java.awt.geom.Point2D p, java.awt.Rectangle r)
public static void drawArrow(java.awt.Graphics2D g2d, int fromX, int fromY, int toX, int toY, float arrowheadSize, float lineWidth)
public static void drawArrowBetweenPoints(java.awt.Graphics2D g, java.awt.geom.Point2D p1, java.awt.geom.Point2D p2, boolean doubleArrow, int arrowheadSize, int lineWidth)
public static void drawArrowImage(java.awt.Graphics2D g, double x, double y, double aDir)
public static void drawArrowImageConnectingPoints(java.awt.Graphics2D g, java.awt.Point from, java.awt.Point to, boolean doubleArrow)
public static void drawArrowImageConnectingShapes(java.awt.Graphics2D g, java.awt.Shape s1, java.awt.Shape s2, boolean doubleArrow)
public static void drawArrowImageDouble(java.awt.Graphics2D g, double x, double y, double aDir)
public static void drawBoxedString(java.awt.Graphics2D g, java.lang.String text, int centeredAtX, int centeredAtY, int padding)
public static void drawBoxedString(java.awt.Graphics2D g, java.lang.String text, int centeredAtX, int centeredAtY, int padding, java.awt.Color outlineColor, int outlineWidth)
public static void drawBoxedString(java.awt.Graphics2D g, java.lang.String text, int centeredAtX, int centeredAtY, int paddingX, int paddingY, java.awt.Color boxColor, java.awt.Color outlineColor, int outlineWidth)
public static void drawBoxedString(java.awt.Graphics2D g, java.lang.String text, int centeredAtX, int centeredAtY, int paddingX, int paddingY, java.awt.Color boxColor, java.awt.Color outlineColor, int outlineWidth, java.awt.Color textColor)
public static void drawBoxedStringCorneredAt(java.awt.Graphics2D g, java.lang.String text, int originX, int originY, int paddingX, int paddingY, java.awt.Color boxColor, java.awt.Color outlineColor, int outlineWidth, java.awt.Color textColor, boolean engraveText)
public static void drawDoubleArrowConnectingShapes(java.awt.Graphics2D g, java.awt.Shape s1, java.awt.Shape s2, boolean doubleArrow)
public static void drawDoubleArrowConnectingShapesBAD(java.awt.Graphics2D g, java.awt.Shape s1, java.awt.Shape s2)
public static void drawEngravedString(java.awt.Graphics2D g, java.lang.String text, int x, int y)
public static void drawHelperText(java.awt.Graphics2D g, java.lang.String helperText, int height)
public static void drawLines(java.awt.Graphics2D g, java.util.List lines, java.awt.Color defaultColor)
public static void drawOutlinedString(java.awt.Graphics2D g, java.lang.String text, int x, int y)
public static void drawShadowedString(java.awt.Graphics2D g, java.lang.String text, int x, int y)
public static void drawThickArrow(java.awt.Graphics2D g2d, int fromX, int fromY, int toX, int toY)
public static java.lang.String flipPointStringY(java.lang.String pointString, int height)
public static java.awt.geom.GeneralPath flipY(java.awt.geom.GeneralPath path, int height)
public static java.awt.geom.GeneralPath generalPathFromString(java.lang.String pathXML)
public static java.awt.Rectangle getBoxedStringRectangle(java.awt.Font font, java.lang.String text, int centeredAtX, int centeredAtY, int paddingX, int paddingY, java.awt.Color boxColor, java.awt.Color outlineColor, int outlineWidth, java.awt.Color textColor)
public static java.awt.Image getBubbleFor(int count, java.awt.Color color)
public static java.awt.image.BufferedImage getBufferedImageFromJAR(java.lang.String name)
public static java.awt.Point getCenterOfGeneralPath(java.awt.geom.GeneralPath path)
public static java.awt.Point getCenterOfShape(java.awt.Shape shape)
public static java.awt.Point getContainedPointAlongLine(java.awt.Point from, java.awt.Point to, java.awt.Shape shape)
public static java.awt.Color getContrastingBase(java.awt.Color versus)
public static java.awt.Color getContrastingBase(java.awt.Color versus, float brightnessForBlack)
public static java.awt.GraphicsConfiguration getDefaultConfiguration()
public static java.awt.Font getDejaFontSized(int pointSize)
public static java.awt.Dimension getDimensionOfText(java.lang.String text, java.awt.FontMetrics fontMetrics)
public static java.util.List getEllipsePoints(int x, int y, double a, double b, int numberOfPoints)
public static java.awt.geom.GeneralPath getGeneralPathFromXML(java.lang.String pathXML)
public static java.lang.String getGeneralPathXML(java.awt.geom.GeneralPath path, int height)
public static java.awt.Image getImageFromJAR(java.lang.String name)
public static javax.swing.ImageIcon getImageIconNamed(java.lang.String name)
public static javax.swing.JLabel getJLabelWithFont(java.lang.String foo, java.awt.Font font)
public static java.awt.Image getManagedImage(java.lang.String filename)
public static java.awt.Image getManagedImageColored(java.lang.String filename, java.awt.Color color)
public static java.awt.Image getManagedImageColored(java.lang.String filename, java.awt.Color color, float transparent)
public static java.awt.Point getMidpointBetweenShapes(java.awt.Shape s1, java.awt.Shape s2, java.awt.geom.Point2D shape1point, java.awt.geom.Point2D shape2point)
public static java.awt.Color getNextColor()
public static javax.swing.JPanel getNonOpaqueJPanel()
public static javax.swing.JPanel getNonOpaqueJPanel(java.awt.LayoutManager lm)
public static double getResizePercentToFitInsideDimension(int startingWidth, int startingHeight, double fitIntoWidth, double fitIntoHeight)
public static java.awt.image.BufferedImage getScaledInstance(java.awt.image.BufferedImage img, int targetWidth, int targetHeight, java.lang.Object hint, boolean higherQuality)
BufferedImage
. Taken from:
http://today.java.net/pub/a/today/2007/04/03/perils-of-image-getscaledinstance.htmlimg
- 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
)higherQuality
- if true, this method will use a multi-step
scaling technique that provides higher quality than the usual
one-step technique (only useful in downscaling cases, where
targetWidth
or targetHeight
is
smaller than the original dimensions, and generally only when
the BILINEAR
hint is specified)BufferedImage
public static java.awt.Font getSymbolFont()
public static java.awt.Font getSymbolFontForBonus(java.awt.Graphics2D g, int bonus)
public static java.awt.Polygon getThickArrowPolygon(int fromX, int fromY, int toX, int toY)
public static java.awt.Polygon getThickArrowPolygon(java.awt.Point from, java.awt.Point to)
public static void initGraphicsTool(java.lang.String supportFolderPath_set, java.lang.String modernResourcesLocation_set)
public static java.awt.Point midpoint(java.awt.geom.Point2D a, java.awt.geom.Point2D b)
public static java.awt.geom.Point2D midpoint2D(java.awt.geom.Point2D a, java.awt.geom.Point2D b)
public static java.awt.Image paintColorOverImage(java.awt.Image sourceImage, java.awt.Color paintColor)
public static java.awt.Image paintColorOverImage(int width, int height, java.awt.Image sourceImage, java.awt.Color paintColor)
public static java.awt.Image paintColorOverImage(int width, int height, java.awt.Image sourceImage, java.awt.Color paintColor, float transparent)
public static java.awt.Point pointFromString(java.lang.String loc)
public static void printManagedImageList()
public static void releaseManagedImage(java.lang.String filename)
public static void releaseManagedImages()
public static void releaseManagedImagesColored()
public static java.awt.geom.GeneralPath resizeShape(java.awt.Shape shape, double percent)
public static void saveComponentAsJPEG(java.awt.Component myComponent, java.lang.String filename, boolean thumbnail, int width, int height, boolean isVox)
public static void saveComponentAsMiniPNG(java.awt.Component myComponent, java.lang.String filename, int width, int height)
public static void saveComponentAsPNG(java.awt.Component myComponent, java.lang.String filename, boolean thumbnail, int width, int height)
public static java.awt.Color solid(java.awt.Color color)
public static java.lang.String stringFromColor(java.awt.Color color)
public static java.lang.String stringFromGeneralPath(java.awt.geom.GeneralPath path)
public static java.lang.String stringFromGeneralPath(java.awt.geom.GeneralPath path, int height)
public static java.lang.String stringFromPoint(java.awt.Point p)
public static java.awt.image.BufferedImage toBufferedImage(java.awt.Image image, java.awt.GraphicsConfiguration gc)
public static java.awt.Color transparent(java.awt.Color color, float alpha)
public static java.lang.String wrapString(java.lang.String text, int pixelWidth, java.awt.Font font)
public static int xCor(int len, double dir)
public static int yCor(int len, double dir)