public class Drawing extends Object
Constructor and Description |
---|
Drawing() |
Modifier and Type | Method and Description |
---|---|
static void |
appendPath(GeneralPath gp,
PathIterator pi,
boolean connectIn)
Appends path iterator segments to a path.
|
static Point2D.Float |
barCrossing(float[] xPts,
float[] yPts,
int cv,
int v1,
int v2,
float barW,
boolean outer)
Finds a crossing point of two crossing bars.
|
static Point2D.Float |
barEndpoint(float[] xPts,
float[] yPts,
int start,
int end,
float barW,
boolean cw)
Finds the endpoints of a bar.
|
static Color |
convertForTheme(Color color)
Converts a color for use with the current UI theme.
|
static Color[] |
convertForTheme(Color[] colors)
Converts colors for use with the current UI theme.
|
static Color |
createColor(Color baseColor)
Adjusts a color for the current Look&Feel and theme.
|
static Paint |
createPaint(float hue,
float sat,
float valHigh,
float valLow,
float x1,
float y1,
float x2,
float y2)
Creates a paint with colors and gradient adusted for the current Look&Feel
and theme.
|
static void |
drawArrow(Graphics2D g,
int x,
int y,
int size,
int refSize,
Paint paint,
boolean vertical,
boolean reversed,
float aspect,
float tailRatio,
boolean nOL)
Draws an arrow within a square area.
|
static void |
drawBug(Graphics2D g,
int x,
int y,
int w,
int h,
int refSize,
Paint paint,
Color legColor,
Color black,
Color white,
boolean flat,
boolean darkBG)
Draws a bug.
|
static void |
drawCheck(Graphics2D g,
int x,
int y,
int size,
int refSize,
Paint paint,
boolean nOL)
Draws a check.
|
static void |
drawCross(Graphics2D g,
int x,
int y,
int size,
int refSize,
Paint paint,
float aspect,
boolean nOL)
Draws a cross.
|
static void |
drawCurvedArrow(Graphics2D g,
int x,
int y,
int size,
int refSize,
Paint paint,
boolean vertical,
boolean reversed,
boolean tailReversed,
float aspect,
float tailRatio,
float tailEndRatio,
boolean nOL)
Draws a curved arrow within a square area.
|
static void |
drawFloppy(Graphics2D g,
int x,
int y,
int size,
int refSize,
Paint diskPaint,
Paint shadow,
Paint silver,
boolean nOL)
Draws a floppy disk.
|
static Rectangle |
drawFolder(Graphics2D g,
int x,
int y,
int size,
int refSize,
Paint paint,
Paint openPaint,
boolean open,
boolean reversed,
boolean nOL)
Draws a folder.
|
static Rectangle[] |
drawHiddenLinedPage(Graphics2D g,
int x,
int y,
int size,
int refSize,
Paint paint,
Color hiddenBarColor,
Color hiddenOutlineColor,
boolean reversed,
Color lineColor,
int hAlign,
boolean nOL)
Draws a lined page with a "hidden" indicator.
|
static void |
drawJar(Graphics2D g,
int x,
int y,
int w,
int h,
int refSize,
Paint contentsPaint,
Paint emptyPaint,
Paint lidPaint,
float fullFraction,
boolean nOL)
Draws a jar.
|
static Rectangle[] |
drawLinedPage(Graphics2D g,
int x,
int y,
int size,
int refSize,
Paint paint,
boolean reversed,
Color[] lineColors,
int hAlign,
boolean hidden,
boolean nOL)
Draws a lined page with multiple line colors.
|
static Rectangle[] |
drawLinedPage(Graphics2D g,
int x,
int y,
int size,
int refSize,
Paint paint,
boolean reversed,
Color lineColor,
int hAlign,
boolean nOL)
Draws a lined page.
|
static Rectangle[] |
drawNumberedPage(Graphics2D g,
int x,
int y,
int size,
int refSize,
Paint paint,
boolean reversed,
Color numberColor,
int hAlign,
boolean nOL,
boolean off)
Draws a page with page number indicators.
|
static Point2D.Float[] |
drawOpenBook(Graphics2D g,
int x,
int y,
int w,
int h,
int refSize,
Paint pagePaint,
Paint edgePaint,
Paint bottomEdgePaint,
Paint linePaint,
boolean nOL)
Draws an open book.
|
static boolean |
drawOutlines()
Determines if icons should have outlines.
|
static Rectangle[] |
drawPage(Graphics2D g,
int x,
int y,
int size,
int refSize,
Paint paint,
boolean reversed,
int hAlign,
boolean nOL)
Draws a page.
|
static void |
drawRunningMan(Graphics2D g,
int x,
int y,
int w,
int h,
int refSize,
Paint paint,
boolean nOL)
Draws a running man.
|
static void |
drawSpool(Graphics2D g,
int x,
int y,
int w,
int h,
int refSize,
Paint threadPaint,
Color spoolColor,
Color darkColor)
Draws a spool.
|
static Rectangle |
drawTextFolder(Graphics2D g,
int x,
int y,
int size,
int refSize,
Paint paint,
Paint openPaint,
Color textColor,
boolean open,
boolean reversed,
String str,
boolean nOL)
Draws a folder with text.
|
static void |
drawUML(Graphics2D g,
int x,
int y,
int w,
int h,
int refSize,
Paint boxPaint,
Color lineColor,
boolean nOL)
Draws a UML diagram.
|
static void |
drawVertArrow(Graphics2D g,
float x,
int yFrom,
int yTo,
float th)
Draws a solid vertical arrow.
|
static int |
getArrowLength(int size,
int refSize,
float aspect,
float tailRatio,
boolean nOL)
Gets the length of an arrow drawn with
drawArrow() . |
static Color |
getColor(Colors c)
Gets a color.
|
static int |
getColorState()
Gets the Look&Feel and theme state.
|
static int |
getDoubleLineWidth(int size)
Gets a width approximate two line widths.
|
static Color |
getLineColor()
Gets a color to be used for outlines on background.
|
static int |
getLineWidth(int size)
Gets the line width for a drawing.
|
static boolean |
getNoOutline()
Determines if node outlines should be drawn for icons and other
drawings.
|
static Color |
getObjColor(int index)
Gets the background color for viewer objects.
|
static Color |
getObjColor(int index,
boolean unused)
Gets the background color for viewer objects.
|
static int |
getPageWidth(int h)
Gets the width of a drawn page given the height.
|
static int |
getTripleLineWidth(int size)
Gets a width approximate three line widths.
|
static boolean |
isDark()
Determines if the background is dark.
|
static boolean |
isFlat()
Determines if icons should be simplified.
|
static Font |
scaleFontToFit(Font refFont,
String str,
double targetHeight,
double targetWidth,
Graphics2D g)
Gets a font for which a specified string which is as large as possible
and fits in a specified box.
|
static Font |
scaleFontToFit(String fontName,
int fontStyle,
String str,
double targetHeight,
double targetWidth,
Graphics2D g)
Gets a font for which a specified string which is as large as possible
and fits in a specified box.
|
public static void appendPath(GeneralPath gp, PathIterator pi, boolean connectIn)
gp
- the path.pi
- the path iterator that will provide the segments.connectIn
- true if the first segment should be converted from a
"move to" to a "line to", if it is a "move to", false otherwise.public static Point2D.Float barCrossing(float[] xPts, float[] yPts, int cv, int v1, int v2, float barW, boolean outer)
xPts
- x positions.yPts
- y positions.cv
- index of crossing point of the centerlines of the two bars.v1
- index of another point on the centerline of the first bar.v2
- index of another point on the centerline of the second bar.barW
- the width of the bars.outer
- if true the crossing point of the outside angle will be
returned, if false the crossing point of the inside angle will be
returned.public static Point2D.Float barEndpoint(float[] xPts, float[] yPts, int start, int end, float barW, boolean cw)
xPts
- x positions.yPts
- y positions.start
- index of any point other than the endpoint on the centerline
of the bar.end
- index of the endpoint of the centerline of the bar. The
centerline is considered to end barW
before the bar does.barW
- the width of the bars.cw
- if true the point clockwise from the vector from start to end
will be returned, if false the point counterclockwise from the vector
from start to end will be returned.public static void drawArrow(Graphics2D g, int x, int y, int size, int refSize, Paint paint, boolean vertical, boolean reversed, float aspect, float tailRatio, boolean nOL)
g
- the graphics on which to draw.x
- position of left side of drawing area.y
- position of top of drawing area.size
- width and height of drawing area.refSize
- a reference size that corresponds to a typical font height
in the UI.paint
- the paint to use for the fill.vertical
- true if the arrow will be vertical, false if it will be
horizontal.reversed
- true if the arrow will be right-to-left or bottom-to-top,
false if it will be left-to-right or top-to-bottom.aspect
- the ratio of head width to half the drawing area size.tailRatio
- the ratio of tail length to head length.nOL
- true if the arrow should be drawn with no outline, false if
it should have a black outline.public static void drawBug(Graphics2D g, int x, int y, int w, int h, int refSize, Paint paint, Color legColor, Color black, Color white, boolean flat, boolean darkBG)
g
- the graphics on which to draw.x
- position of left side of drawing area.y
- position of top of drawing area.w
- width of the drawing area.h
- height of the drawing area.refSize
- a reference size that corresponds to a typical font height
in the UI.paint
- the paint to use for the bug body.legColor
- the bug leg color.black
- the bug head and spot color.white
- the bug head spot.flat
- true if a simplified version of the bug should be drawn,
false otherwise.darkBG
- true if the bug should be drawn with no outline, false if
it should have a black outline.public static void drawCheck(Graphics2D g, int x, int y, int size, int refSize, Paint paint, boolean nOL)
g
- the graphics on which to draw.x
- position of left side of drawing area.y
- position of top of drawing area.size
- width and height of drawing area.refSize
- a reference size that corresponds to a typical font height
in the UI.paint
- the paint to use for the fill.nOL
- true if the check should be drawn with no outline, false if
it should have a black outline.public static void drawCross(Graphics2D g, int x, int y, int size, int refSize, Paint paint, float aspect, boolean nOL)
g
- the graphics on which to draw.x
- position of left side of drawing area.y
- position of top of drawing area.size
- width and height of drawing area.refSize
- a reference size that corresponds to a typical font height
in the UI.paint
- the paint to use for the fill.aspect
- the cross arm length will be approximately this value times
one third the size.nOL
- true if the cross should be drawn with no outline, false if
it should have a black outline.public static void drawCurvedArrow(Graphics2D g, int x, int y, int size, int refSize, Paint paint, boolean vertical, boolean reversed, boolean tailReversed, float aspect, float tailRatio, float tailEndRatio, boolean nOL)
g
- the graphics on which to draw.x
- position of left side of drawing area.y
- position of top of drawing area.size
- width and height of drawing area.refSize
- a reference size that corresponds to a typical font height
in the UI.paint
- the paint to use for the fill.vertical
- true if the arrow will be vertical, false if it will be
horizontal.reversed
- true if the arrow will be right-to-left or bottom-to-top,
false if it will be left-to-right or top-to-bottom.tailReversed
- true if the tail should curve up or left, false if it
should curve down or right.aspect
- the ratio of head width to half the drawing area size.tailRatio
- the ratio of length of the part of the tail near the
head to head length.tailEndRatio
- the ratio of length of the end of the tail to head
length.nOL
- true if the arrow should be drawn with no outline, false if
it should have a black outline.public static void drawFloppy(Graphics2D g, int x, int y, int size, int refSize, Paint diskPaint, Paint shadow, Paint silver, boolean nOL)
g
- the graphics on which to draw.x
- position of left side of drawing area.y
- position of top of drawing area.size
- width and height of drawing area.refSize
- a reference size that corresponds to a typical font height
in the UI.diskPaint
- the paint to be used for the main part of the disk.shadow
- the paint to be used for the dark parts of the disk.silver
- the paint to be used for the metal parts of the disk.nOL
- true if the arrow should be drawn with no outline, false if
it should have a black outline.public static Rectangle drawFolder(Graphics2D g, int x, int y, int size, int refSize, Paint paint, Paint openPaint, boolean open, boolean reversed, boolean nOL)
g
- the graphics on which to draw.x
- position of left side of drawing area.y
- position of top of drawing area.size
- width and height of drawing area.refSize
- a reference size that corresponds to a typical font height
in the UI.paint
- the paint to use for the main folder fill.openPaint
- the paint to use for to fill the open leaf of the folder
(if the folder is open).open
- true if the folder will be open, false if it will be closed.reversed
- true if the folder tab will be on the right, false if it
will be on the left.nOL
- true if the arrow should be drawn with no outline, false if
it should have a black outline.public static void drawJar(Graphics2D g, int x, int y, int w, int h, int refSize, Paint contentsPaint, Paint emptyPaint, Paint lidPaint, float fullFraction, boolean nOL)
g
- the graphics on which to draw.x
- position of left side of drawing area.y
- position of top of drawing area.w
- width of the drawing area.h
- height of the drawing area.refSize
- a reference size that corresponds to a typical font height
in the UI.contentsPaint
- the paint to be used for the full part of the jar.emptyPaint
- the paint to be used for the empty part of the jar.lidPaint
- the paint to be used for the lid.fullFraction
- the fraction of the jar that is full.nOL
- true if the arrow should be drawn with no outline, false if
it should have a black outline.public static Rectangle[] drawLinedPage(Graphics2D g, int x, int y, int size, int refSize, Paint paint, boolean reversed, Color lineColor, int hAlign, boolean nOL)
g
- the graphics on which to draw.x
- position of left side of drawing area.y
- position of top of drawing area.size
- width and height of drawing area.refSize
- a reference size that corresponds to a typical font height
in the UI.paint
- paint to be used for the page.reversed
- true if the folded corner should be on the left, false if
it should be on the right.lineColor
- the line color.hAlign
- -1 for left alignment within the bounds, 1 for right
alignment within the bounds, 0 for centered horizontally within the
bounds.nOL
- true if the arrow should be drawn with no outline, false if
it should have a black outline.public static Rectangle[] drawHiddenLinedPage(Graphics2D g, int x, int y, int size, int refSize, Paint paint, Color hiddenBarColor, Color hiddenOutlineColor, boolean reversed, Color lineColor, int hAlign, boolean nOL)
g
- the graphics on which to draw.x
- position of left side of drawing area.y
- position of top of drawing area.size
- width and height of drawing area.refSize
- a reference size that corresponds to a typical font height
in the UI.paint
- paint to be used for the page.hiddenBarColor
- the hidden bar color, or null if the bar should be unpainted.hiddenOutlineColor
- the hidden outline color.reversed
- true if the folded corner should be on the left, false if
it should be on the right.lineColor
- the line color.hAlign
- -1 for left alignment within the bounds, 1 for right
alignment within the bounds, 0 for centered horizontally within the
bounds.nOL
- true if the arrow should be drawn with no outline, false if
it should have a black outline.public static Rectangle[] drawLinedPage(Graphics2D g, int x, int y, int size, int refSize, Paint paint, boolean reversed, Color[] lineColors, int hAlign, boolean hidden, boolean nOL)
g
- the graphics on which to draw.x
- position of left side of drawing area.y
- position of top of drawing area.size
- width and height of drawing area.refSize
- a reference size that corresponds to a typical font height
in the UI.paint
- paint to be used for the page.reversed
- true if the folded corner should be on the left, false if
it should be on the right.lineColors
- the line colors. These will be used cyclically for each
line, starting at the top. There will be at least five lines.hAlign
- -1 for left alignment within the bounds, 1 for right
alignment within the bounds, 0 for centered horizontally within the
bounds.hidden
- true if a "hidden" indicator should be added, false
otherwise.nOL
- true if the arrow should be drawn with no outline, false if
it should have a black outline.public static Rectangle[] drawNumberedPage(Graphics2D g, int x, int y, int size, int refSize, Paint paint, boolean reversed, Color numberColor, int hAlign, boolean nOL, boolean off)
g
- the graphics on which to draw.x
- position of left side of drawing area.y
- position of top of drawing area.size
- width and height of drawing area.refSize
- a reference size that corresponds to a typical font height
in the UI.paint
- paint to be used for the page.reversed
- true if the folded corner should be on the left, false if
it should be on the right.numberColor
- the line number color.hAlign
- -1 for left alignment within the bounds, 1 for right
alignment within the bounds, 0 for centered horizontally within the
bounds.nOL
- true if the page should be drawn with no outline, false if
it should have a black outline.off
- true if the numbers should be struck through, false if they
should not be.public static Point2D.Float[] drawOpenBook(Graphics2D g, int x, int y, int w, int h, int refSize, Paint pagePaint, Paint edgePaint, Paint bottomEdgePaint, Paint linePaint, boolean nOL)
g
- the graphics on which to draw.x
- position of left side of drawing area.y
- position of top of drawing area.w
- width of the drawing area.h
- height of the drawing area.refSize
- a reference size that corresponds to a typical font height
in the UI.pagePaint
- the paint to use for the page.edgePaint
- the paint to use for the page side edges.bottomEdgePaint
- the paint to use for the page bottom edges.linePaint
- the paint to use for the text lines.nOL
- true if the arrow should be drawn with no outline, false if
it should have a black outline.public static Rectangle[] drawPage(Graphics2D g, int x, int y, int size, int refSize, Paint paint, boolean reversed, int hAlign, boolean nOL)
g
- the graphics on which to draw.x
- position of left side of drawing area.y
- position of top of drawing area.size
- width and height of drawing area.refSize
- a reference size that corresponds to a typical font height
in the UI.paint
- the paint to use for the fill.reversed
- true if the corner fold will be on the right, false if it
will be on the left.hAlign
- the horizontal alignment. -1 = left, 0 = center, 1 = right.nOL
- true if the arrow should be drawn with no outline, false if
it should have a black outline.public static void drawRunningMan(Graphics2D g, int x, int y, int w, int h, int refSize, Paint paint, boolean nOL)
g
- the graphics on which to draw.x
- position of left side of drawing area.y
- position of top of drawing area.w
- width of the drawing area.h
- height of the drawing area.refSize
- a reference size that corresponds to a typical font height
in the UI.paint
- the paint to use for the mans body.nOL
- true if the folder should be drawn with no outline, false if
it should have a black outline.public static void drawSpool(Graphics2D g, int x, int y, int w, int h, int refSize, Paint threadPaint, Color spoolColor, Color darkColor)
g
- the graphics on which to draw.x
- position of left side of drawing area.y
- position of top of drawing area.w
- width of the drawing area.h
- height of the drawing area.refSize
- a reference size that corresponds to a typical font height
in the UI.threadPaint
- the paint to use for the thread.spoolColor
- color to use for the spool.darkColor
- color to use between threads.public static Rectangle drawTextFolder(Graphics2D g, int x, int y, int size, int refSize, Paint paint, Paint openPaint, Color textColor, boolean open, boolean reversed, String str, boolean nOL)
g
- the graphics on which to draw.x
- position of left side of drawing area.y
- position of top of drawing area.size
- width and height of drawing area.refSize
- a reference size that corresponds to a typical font height
in the UI.paint
- the paint to use for the main folder fill.openPaint
- the paint to use for to fill the open leaf of the folder
(if the folder is open).textColor
- the text color.open
- true if the folder will be open, false if it will be closed.reversed
- true if the folder tab will be on the right, false if it
will be on the left.str
- the text to be displayed on the folder.nOL
- true if the folder should be drawn with no outline, false if
it should have a black outline.public static void drawUML(Graphics2D g, int x, int y, int w, int h, int refSize, Paint boxPaint, Color lineColor, boolean nOL)
g
- the graphics on which to draw.x
- position of left side of drawing area.y
- position of top of drawing area.w
- width of the drawing area.h
- height of the drawing area.refSize
- a reference size that corresponds to a typical font height
in the UI.boxPaint
- the paint to use for the boxes.lineColor
- the color to use for connecting edges.nOL
- true if the icon should be drawn with no outlines, false if
it should have black outlines.public static void drawVertArrow(Graphics2D g, float x, int yFrom, int yTo, float th)
g
- graphics object to render to.x
- center x position of arrow.yFrom
- y position of arrow tail.yTo
- y position of tip of arrowhead.th
- line thickness.public static int getArrowLength(int size, int refSize, float aspect, float tailRatio, boolean nOL)
drawArrow()
.size
- width and height of drawing area.refSize
- a reference size that corresponds to a typical font height
in the UI.aspect
- the ratio of head width to half the drawing area size.tailRatio
- the ratio of tail length to head length.nOL
- true if the arrow should be drawn with no outline, false if
it should have a black outline.public static int getDoubleLineWidth(int size)
size
- the height and width of the drawing area.public static int getLineWidth(int size)
size
- the height and width of the drawing area.public static int getPageWidth(int h)
h
- the page height.public static int getTripleLineWidth(int size)
size
- the height and width of the drawing area.public static Font scaleFontToFit(Font refFont, String str, double targetHeight, double targetWidth, Graphics2D g)
refFont
- a reference font. The font returned will be a scaled
version of this font.str
- the string which must fit into the target rectangle.targetHeight
- the maximum height of the test string when rendered
on the supplied graphics.targetWidth
- the maximum width of the test string when rendered on
the supplied graphics.g
- the graphics on which to render.public static Font scaleFontToFit(String fontName, int fontStyle, String str, double targetHeight, double targetWidth, Graphics2D g)
fontName
- the font name.fontStyle
- the font style.str
- the string which must fit into the target rectangle.targetHeight
- the maximum height of the test string when rendered
on the supplied graphics.targetWidth
- the maximum width of the test string when rendered on
the supplied graphics.g
- the graphics on which to render.public static Paint createPaint(float hue, float sat, float valHigh, float valLow, float x1, float y1, float x2, float y2)
hue
- the hue to be used on a white background with medium contrast.sat
- the saturation to be used on a light background with medium contrast.valHigh
- the value to be used on a light background with medium contrast
at the start of the gradient.valLow
- the value to be used on a light background with medium contrast
at the end of the gradient.x1
- gradient start x coordinate.y1
- gradient start y coordinate.x2
- gradient end x coordinate.y2
- gradient end y coordinate.public static int getColorState()
public static Color getLineColor()
public static Color getColor(Colors c)
c
- the color type.public static boolean drawOutlines()
public static boolean isFlat()
public static boolean isDark()
public static Color createColor(Color baseColor)
baseColor
- the color to be used on a light background with medium
contrast.public static Color convertForTheme(Color color)
color
- the color as would be used in a light, high contrast theme.public static Color[] convertForTheme(Color[] colors)
colors
- the colors as would be used in a light, high contrast theme.public static boolean getNoOutline()
public static Color getObjColor(int index)
index
- index of object class.public static Color getObjColor(int index, boolean unused)
index
- index of object class.unused
- true if the color should be for elements that are "unused",
such as garbage characters in unused buffers or queues, false otherwise.