|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.xj.anylogic.engine.presentation.UtilitiesDrawing
public final class UtilitiesDrawing
This is a collection of static functions which could be useful for drawing.
| Method Summary | |
|---|---|
static boolean |
arcContains(double px,
double py,
double radiusX,
double radiusY,
double anglestart,
double angle)
Tests if the arc (pie type) with the given attributes contains the point with coordinates (x,y) relative to the arc center. |
static boolean |
curveContains(double px,
double py,
int nPoints,
double[] dx,
double[] dy)
Tests if the curve with given base points contains the point with coordinates (x,y) relative to the polyline first base point. |
static void |
drawArc(Panel panel,
java.awt.Graphics2D g,
java.awt.geom.AffineTransform xform,
double x,
double y,
double rotation,
double scalex,
double scaley,
java.awt.Color lineColor,
java.awt.Color fillColor,
double radiusx,
double radiusy,
double anglestart,
double angle,
double lineWidth,
int lineStyle)
Draws an arc. |
static void |
drawCurve(Panel panel,
java.awt.Graphics2D g,
java.awt.geom.AffineTransform xform,
double x,
double y,
double rotation,
double scalex,
double scaley,
java.awt.Color lineColor,
java.awt.Color fillColor,
int npoints,
boolean manualControlPoints,
double[] dx,
double[] dy,
boolean closed,
double lineWidth,
int lineStyle)
Draws a curve as a sequence of cubic splines. |
static void |
drawCurve(Panel panel,
java.awt.Graphics2D g,
java.awt.geom.AffineTransform xform,
double x,
double y,
double rotation,
double scalex,
double scaley,
java.awt.Color lineColor,
java.awt.Color fillColor,
int npoints,
double[] dx,
double[] dy,
boolean closed,
double lineWidth,
int lineStyle)
Deprecated. use drawCurve(Panel, Graphics2D, AffineTransform, double, double, double, double, double, Color, Color, int, boolean, double[], double[], boolean, double, int) |
static void |
drawImage(Panel panel,
java.awt.Graphics2D g,
java.awt.geom.AffineTransform xform,
double x,
double y,
double rotation,
double scalex,
double scaley,
double width,
double height,
Presentable p,
java.lang.String packagePrefix,
java.lang.String filename)
Draws an image. |
static void |
drawLine(Panel panel,
java.awt.Graphics2D g,
java.awt.geom.AffineTransform xform,
double x,
double y,
double rotation,
double scalex,
double scaley,
java.awt.Color color,
double dx,
double dy,
double width,
int style)
Draws a line. |
static void |
drawOval(Panel panel,
java.awt.Graphics2D g,
java.awt.geom.AffineTransform xform,
double x,
double y,
double rotation,
double scalex,
double scaley,
java.awt.Color lineColor,
java.awt.Color fillColor,
double radiusx,
double radiusy,
double lineWidth,
int lineStyle)
Draws an oval. |
static void |
drawPixel(Panel panel,
java.awt.Graphics2D g,
java.awt.geom.AffineTransform xform,
double x,
double y,
java.awt.Color color)
Draws a pixel. |
static void |
drawPolyLine(Panel panel,
java.awt.Graphics2D g,
java.awt.geom.AffineTransform xform,
double x,
double y,
double rotation,
double scalex,
double scaley,
java.awt.Color lineColor,
java.awt.Color fillColor,
int npoints,
double[] dx,
double[] dy,
boolean closed,
double lineWidth,
int lineStyle)
Draws a polyline. |
static void |
drawRectangle(Panel panel,
java.awt.Graphics2D g,
java.awt.geom.AffineTransform xform,
double x,
double y,
double rotation,
double scalex,
double scaley,
java.awt.Color lineColor,
java.awt.Color fillColor,
double width,
double height,
double lineWidth,
int lineStyle)
Draws a rectangle. |
static void |
drawRoundedRectangle(Panel panel,
java.awt.Graphics2D g,
java.awt.geom.AffineTransform xform,
double x,
double y,
double rotation,
double scalex,
double scaley,
java.awt.Color lineColor,
java.awt.Color fillColor,
double width,
double height,
double radius,
double lineWidth,
int lineStyle)
Draws a rounded rectangle. |
static void |
drawText(Panel panel,
java.awt.Graphics2D g,
java.awt.geom.AffineTransform xform,
double x,
double y,
double rotation,
double scalex,
double scaley,
java.awt.Color color,
java.lang.String text,
java.awt.Font font,
int alignment)
Draws a text. |
static int |
getAdjustedFontSize(int original)
Adjusts font size depending on the platform. |
static java.awt.Font |
getDefaultFont()
Returns the default font used in presentation graphics |
static java.awt.Font |
getDefaultFont(int style)
Returns the default font of a particular style |
static java.awt.BasicStroke |
getDefaultStroke()
Returns the Default stroke: solid line, width 1.0, CAP_SQUARE, JOIN_MITER, a miter limit of 4.0. |
static java.awt.BasicStroke |
getThinnestStroke()
Returns the thinnest possible stroke: solid line, width 0.0 CAP_SQUARE, JOIN_MITER, a miter limit of 10.0. |
static boolean |
ovalContains(double px,
double py,
double radiusX,
double radiusY)
Tests if the oval with the given attributes contains the point with coordinates (x,y) relative to the oval center. |
static boolean |
polyLineContains(double px,
double py,
int nPoints,
double[] dx,
double[] dy)
Tests if the polygon with given base points contains the point with coordinates (x,y) relative to the polygon first base point. |
static boolean |
rectangleContains(double px,
double py,
double width,
double height)
Tests if the rectangle with the given attributes contains the point with coordinates (x,y) relative to the rectangle "upper left" corner. |
static boolean |
roundedRectangleContains(double px,
double py,
double width,
double height,
double radius)
Tests if the rounded rectangle with the given attributes contains the point with coordinates (x,y) relative to the rectangle "upper left" corner. |
static void |
setDefaultFonts()
Deprecated. this method shouldn't be called by user and will be removed in the next release |
static boolean |
textContains(double px,
double py,
java.lang.String text,
java.awt.Font font,
int alignment)
Tests if a (possibly, multi-line) text with given font and alignment contains the point with coordinates (x,y) relative to the text base point (which is NOT the beginning of the baseline, but top left, right or center of text, depending on alignment). |
static double |
transformX(double px,
double py,
double x,
double y,
double rotation,
double scalex)
Transforms the x coordinate of a given point according to the base coordinates, rotation and scale. |
static double |
transformY(double px,
double py,
double x,
double y,
double rotation,
double scaley)
Transforms the y coordinate of a given point according to the base coordinates, rotation and scale. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static java.awt.Font getDefaultFont()
public static java.awt.Font getDefaultFont(int style)
public static int getAdjustedFontSize(int original)
original - the original font size
public static java.awt.BasicStroke getDefaultStroke()
public static java.awt.BasicStroke getThinnestStroke()
@Deprecated public static void setDefaultFonts()
public static boolean arcContains(double px,
double py,
double radiusX,
double radiusY,
double anglestart,
double angle)
px - the x coordinate of the pointpy - the y coordinate of the pointradiusX - "horizontal" radius of the arcradiusY - "vertical" radius of the arcanglestart - the starting angle of the arc (0 means 12 o'clock) in radians,
clockwiseangle - the angular extent of the arc in radians, clockwise
public static boolean curveContains(double px,
double py,
int nPoints,
double[] dx,
double[] dy)
px - the x coordinate of the pointpy - the y coordinate of the pointnPoints - the number of base pointsdx - the array of (at least nPoints) base points x coordinates
relative to the start pointdy - the array of (at least nPoints) base points y coordinates
relative to the start point
public static void drawArc(Panel panel,
java.awt.Graphics2D g,
java.awt.geom.AffineTransform xform,
double x,
double y,
double rotation,
double scalex,
double scaley,
java.awt.Color lineColor,
java.awt.Color fillColor,
double radiusx,
double radiusy,
double anglestart,
double angle,
double lineWidth,
int lineStyle)
panel - the presentation panelg - the graphics where the drawing takes placexform - the "original" transform that must be restored before drawingx - the x coordinate of the arc centery - the y coordinate of the arcrotation - the rotation of the arc (in radians) around its centerscalex - the scale of the arc along x axisscaley - the scale of the arc along y axislineColor - line color of the arcfillColor - fill color of the arcradiusx - "horizontal" radius of the arcradiusy - "vertical" radius of the arcanglestart - the starting angle of the arc (0 means 12 o'clock) in radians,
clockwiseangle - the anglular extent of the arc in radians, clockwiselineWidth - line widthlineStyle - line stroke style (solid, dotted, dashed)
@Deprecated
public static void drawCurve(Panel panel,
java.awt.Graphics2D g,
java.awt.geom.AffineTransform xform,
double x,
double y,
double rotation,
double scalex,
double scaley,
java.awt.Color lineColor,
java.awt.Color fillColor,
int npoints,
double[] dx,
double[] dy,
boolean closed,
double lineWidth,
int lineStyle)
drawCurve(Panel, Graphics2D, AffineTransform, double, double, double, double, double, Color, Color, int, boolean, double[], double[], boolean, double, int)
public static void drawCurve(Panel panel,
java.awt.Graphics2D g,
java.awt.geom.AffineTransform xform,
double x,
double y,
double rotation,
double scalex,
double scaley,
java.awt.Color lineColor,
java.awt.Color fillColor,
int npoints,
boolean manualControlPoints,
double[] dx,
double[] dy,
boolean closed,
double lineWidth,
int lineStyle)
panel - the presentation panelg - the graphics where the drawing takes placexform - the "original" transform that must be restored before drawingx - the x coordinate of the curve start pointy - the y coordinate of the curve start pointrotation - the rotation of the curve (in radians) around its start pointscalex - the scale of the curve along x axisscaley - the scale of the curve along y axislineColor - line color of the curvefillColor - fill color of the curvenpoints - the number of points in the curvedx - the array of curve base points x coordinates relative to the
start point (if controlPointsIncluded == true,
with control points, in triplets: p0x, p0c1x, p0c2x, p1x,
p1c1x, p1c2x... )dy - the array of curve base points y coordinates relative to the
start point (if controlPointsIncluded == true,
with control points, in triplets: p0y, p0c1y, p0c2y, p1y,
p1c1y, p1c2y... )manualControlPoints - if true curve is drawn using control points
specified in the dx and dy
arraysclosed - if true, the curve is drawn as closedlineWidth - line widthlineStyle - line stroke style (solid, dotted, dashed)
public static void drawImage(Panel panel,
java.awt.Graphics2D g,
java.awt.geom.AffineTransform xform,
double x,
double y,
double rotation,
double scalex,
double scaley,
double width,
double height,
Presentable p,
java.lang.String packagePrefix,
java.lang.String filename)
panel - the presentation panelg - the graphics where the drawing takes placexform - the "original" transform that must be restored before drawingx - the x coordinate of the imagey - the y coordinate of the imagerotation - the rotation of the image (in radians) around its upper left
cornerscalex - the scale of the image along x axisscaley - the scale of the image along y axiswidth - the requested width of the image, -1 for original widthheight - the requested height of the image, -1 for original heightp - the presentable object owning the imagepackagePrefix - the package name of original active object where this image is
defined, formatted using '/' characters; with '/' character at
the beginningfilename - the file name of the image, relative to the class of p
public static void drawLine(Panel panel,
java.awt.Graphics2D g,
java.awt.geom.AffineTransform xform,
double x,
double y,
double rotation,
double scalex,
double scaley,
java.awt.Color color,
double dx,
double dy,
double width,
int style)
panel - the presentation panelg - the graphics where the drawing takes placexform - the "original" transform that must be restored before drawingx - the x coordinate of the line start pointy - the y coordinate of the line start pointrotation - the rotation of the line (in radians) around its start pointscalex - the scale of the line along x axisscaley - the scale of the line along y axiscolor - color of the linedx - the difference of x coordinates of the line end and start
pointsdy - the difference of y coordinates of the line end and start
pointswidth - line widthstyle - line stroke style (solid, dotted, dashed)
public static void drawOval(Panel panel,
java.awt.Graphics2D g,
java.awt.geom.AffineTransform xform,
double x,
double y,
double rotation,
double scalex,
double scaley,
java.awt.Color lineColor,
java.awt.Color fillColor,
double radiusx,
double radiusy,
double lineWidth,
int lineStyle)
panel - the presentation panelg - the graphics where the drawing takes placexform - the "original" transform that must be restored before drawingx - the x coordinate of the oval centery - the y coordinate of the oval centerrotation - the rotation of the oval (in radians) around its centerscalex - the scale of the oval along x axisscaley - the scale of the oval along y axislineColor - line color of the ovalfillColor - fill color of the ovalradiusx - "horizontal" radius of the ovalradiusy - "vertical" radius of the ovallineWidth - line widthlineStyle - line stroke style (solid, dotted, dashed)
public static void drawPixel(Panel panel,
java.awt.Graphics2D g,
java.awt.geom.AffineTransform xform,
double x,
double y,
java.awt.Color color)
panel - the presentation panelg - the graphics where the drawing takes placexform - the "original" transform that must be restored before drawingx - the x coordinate of the pixely - the x coordinate of the pixelcolor - color of the pixel
public static void drawPolyLine(Panel panel,
java.awt.Graphics2D g,
java.awt.geom.AffineTransform xform,
double x,
double y,
double rotation,
double scalex,
double scaley,
java.awt.Color lineColor,
java.awt.Color fillColor,
int npoints,
double[] dx,
double[] dy,
boolean closed,
double lineWidth,
int lineStyle)
panel - the presentation panelg - the graphics where the drawing takes placexform - the "original" transform that must be restored before drawingx - the x coordinate of the polyline start pointy - the y coordinate of the polyline start pointrotation - the rotation of the polyline (in radians) around its start
pointscalex - the scale of the polyline along x axisscaley - the scale of the polyline along y axislineColor - line color of the polylinefillColor - fill color of the polylinenpoints - the number of points in the polylinedx - the array of (at least npoints) polyline points x coordinates
relative to the start pointdy - the array of (at least npoints) polyline points y coordinates
relative to the start pointclosed - if true, the polyline is drawn as closedlineWidth - line widthlineStyle - line stroke style (solid, dotted, dashed)
public static void drawRectangle(Panel panel,
java.awt.Graphics2D g,
java.awt.geom.AffineTransform xform,
double x,
double y,
double rotation,
double scalex,
double scaley,
java.awt.Color lineColor,
java.awt.Color fillColor,
double width,
double height,
double lineWidth,
int lineStyle)
panel - the presentation panelg - the graphics where the drawing takes placexform - the "original" transform that must be restored before drawingx - the x coordinate of the rectangley - the y coordinate of the rectanglerotation - the rotation of the rectangle (in radians) around its upper
left cornerscalex - the scale of the rectangle along x axisscaley - the scale of the rectangle along y axislineColor - line color of the rectanglefillColor - fill color of the rectanglewidth - width of the rectangleheight - height of the rectanglelineWidth - line widthlineStyle - line stroke style (solid, dotted, dashed)
public static void drawRoundedRectangle(Panel panel,
java.awt.Graphics2D g,
java.awt.geom.AffineTransform xform,
double x,
double y,
double rotation,
double scalex,
double scaley,
java.awt.Color lineColor,
java.awt.Color fillColor,
double width,
double height,
double radius,
double lineWidth,
int lineStyle)
panel - the presentation panelg - the graphics where the drawing takes placexform - the "original" transform that must be restored before drawingx - the x coordinate of the rounded rectangley - the y coordinate of the rounded rectanglerotation - the rotation of the rounded rectangle (in radians) around its
upper left cornerscalex - the scale of the rounded rectangle along x axisscaley - the scale of the rounded rectangle along y axislineColor - line color of the rounded rectanglefillColor - fill color of the rounded rectanglewidth - width of the rounded rectangleheight - height of the rounded rectangleradius - of corners of the rounded rectanglelineWidth - line widthlineStyle - line stroke style (solid, dotted, dashed)
public static void drawText(Panel panel,
java.awt.Graphics2D g,
java.awt.geom.AffineTransform xform,
double x,
double y,
double rotation,
double scalex,
double scaley,
java.awt.Color color,
java.lang.String text,
java.awt.Font font,
int alignment)
panel - the presentation panelg - the graphics where the drawing takes placexform - the "original" transform that must be restored before drawingx - the x coordinate of the text start pointy - the y coordinate of the text start point (baseline - ascent)rotation - the rotation of the text (in radians) around its start pointscalex - the scale of the text along x axisscaley - the scale of the text along y axiscolor - color of the texttext - the text string to be drawnfont - font to usealignment - the alignment of the text
public static boolean ovalContains(double px,
double py,
double radiusX,
double radiusY)
px - the x coordinate of the pointpy - the y coordinate of the pointradiusX - "horizontal" radius of the ovalradiusY - "vertical" radius of the oval
public static boolean polyLineContains(double px,
double py,
int nPoints,
double[] dx,
double[] dy)
px - the x coordinate of the pointpy - the y coordinate of the pointnPoints - the number of base pointsdx - the array of (at least nPoints) base points x coordinates
relative to the start pointdy - the array of (at least nPoints) base points y coordinates
relative to the start point
public static boolean rectangleContains(double px,
double py,
double width,
double height)
px - the x coordinate of the pointpy - the y coordinate of the pointwidth - the width of the rectangleheight - the height of the rectangle
public static boolean roundedRectangleContains(double px,
double py,
double width,
double height,
double radius)
px - the x coordinate of the pointpy - the y coordinate of the pointwidth - the width of the rounded rectangleheight - the height of the rounded rectangleradius - the corner radius of the rounded rectangle
public static boolean textContains(double px,
double py,
java.lang.String text,
java.awt.Font font,
int alignment)
px - the x coordinate of the pointtext - the textfont - the text fontalignment - the text alignment
public static double transformX(double px,
double py,
double x,
double y,
double rotation,
double scalex)
px - the x coordinate of the pointpy - the y coordinate of the pointx - the base x coordinatey - the base y coordinaterotation - the base rotationscalex - the base x scale
public static double transformY(double px,
double py,
double x,
double y,
double rotation,
double scaley)
px - the x coordinate of the pointpy - the y coordinate of the pointx - the base x coordinatey - the base y coordinaterotation - the base rotationscaley - the base y scale
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||