net.sf.drawj2d.cmd
Class API
- java.lang.Object
-
- net.sf.drawj2d.cmd.API
-
public class API extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor and Description API(java.awt.Graphics2D g)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidarc(double radius, double startangle, double endangle)Draw an arc.voidarc(double x1, double y1, double radius, double startangle, double endangle)Draw an arc.voidarrow(double x0, double y0, double x1, double y1)Draw an arrow from the first coordinate to the second one.voidarrowrel(double dx, double dy)Draw an arrow from the actual cursor position to the given relative position.voidarrows(double x0, double y0, double x1, double y1)Draw a double headed arrow from the first coordinate to the second one.voidarrowsrel(double dx, double dy)Draw a double headed arrow from the actual cursor position to the given relative position.voidarrowsto(double x1, double y1)Draw a double headed arrow from the actual cursor position to the given coordinate.voidarrowto(double x1, double y1)Draw an arrow from the actual cursor position to the given coordinate.intblock()Create a block.voidcircle(double radius)Draw a circle.voidcircle(double x1, double y1, double radius)Draw a circle.voidcubiccurve(double x0, double y0, double x0Ctrl, double y0Ctrl, double x1Ctrl, double y1Ctrl, double x1, double y1)Draw a cubic parabola from the first coordinate to the last one.voiddecdigits(int nb)Set number format for dimension linesvoiddecdigitsangle(int nb)Set number format for dimension anglesvoiddimangle(double x0, double y0, double xP, double yP, double xQ, double yQ, boolean isTeX)Draw a dimension arc at a vertex.voiddimangle(double x0, double y0, double xP, double yP, double xQ, double yQ, boolean isTeX, java.lang.String lb)Draw a dimension arc at a vertex.voiddimline(double x0, double y0, double x1, double y1, boolean isTeX)Draw a dimension line (double headed arrow) and label it by its length (in drawing units).voiddimline(double x0, double y0, double x1, double y1, java.lang.String lb, boolean isTeX)Draw a dimension line (double headed arrow) and label it.voiddimlinerel(double dx, double dy, boolean isTeX)Draw a dimension line (double headed arrow) from the cursor position to a relative position and label by its length (in drawing units).voiddimlinerel(double dx, double dy, java.lang.String lb, boolean isTeX)Draw a dimension line (double headed arrow) from the cursor position to a relative position and label it.voiddimlineto(double x1, double y1, boolean isTeX)Draw a dimension line (double headed arrow) from the cursor position to the given position and label by its length (in drawing units).voiddimlineto(double x1, double y1, java.lang.String lb, boolean isTeX)Draw a dimension line (double headed arrow) from the cursor position to the given position and label it.voidellipse(double radius1, double radius2, double angle1)Draw an ellipse.intendblock()End a block.doubleexpr(java.lang.String str)Evaluate a mathematical expression.voidfillcircle(double radius)Fill a circle.voidfillellipse(double radius1, double radius2, double angle1)Fill an ellipse.voidfillpolygon(double[] x, double[] y)Fill a polygon.voidfillrect(double dx, double dy)Fill a rectangle.voidfillrod(double L, double w, double α)Fill a rod.voidfillsegment(double radius, double startangle, double endangle)Fill a segment (arc).booleanflip()Mirror vertically.voidfont()voidfont(java.lang.String font, int style, int size)voidforce(double Fx, double Fy, boolean isTeX)Draw a force arrow (pointing away).voidforce(double Fx, double Fy, java.lang.String lb, boolean isTeX)Draw a force arrow (pointing away).voidforce2(double Fx, double Fy, boolean isTeX)Draw a force arrow (pointing to the cursor).voidforce2(double Fx, double Fy, java.lang.String lb, boolean isTeX)Draw a force arrow (pointing to the cursor).voidforceunitlength(double mm, int decdigits)Force unit lengthdoublefu(double kN)force unit to unit length conversion.double[]here()Tells where the cursor is.voidimage(java.lang.String filename, double dpi, double pxX, double pxY, double massstab)Draw an image.voidlabel(java.lang.String label)Label the position of the cursor.voidlabel(java.lang.String label, java.lang.String relpos)Label the position of the cursor.voidlabelline(double x0, double y0, double x1, double y1, java.lang.String lb)Label a line.voidline(double x0, double y0, double x1, double y1)Draw a line from the first coordinate to the second one.voidlinemid(double L, double α)Draw a line given its length and direction.voidlinepolar(double dL, double α)Draw a line given its length and direction relative to the actual position.voidlinerel(double dx, double dy)Draw a line from the actual cursor position to the given relative position.voidlineto(double x1, double y1)Draw a line from the actual cursor position to the given coordinate.voidlinetox(double x1)Draw a line from the actual cursor position in x-direction.voidlinetoy(double y1)Draw a line from the actual cursor position in y-direction.doublemm(double mm)mm to unit length conversion.voidmovepolar(double dL, double α)Move the cursor in polar direction relative to the actual position.voidmoverel(double dx, double dy)Move the cursor relative to the actual position.voidmoveto(double[] xy)Move the cursor to a new position.voidmoveto(double x1, double y1)Move the cursor to a new position.voidmovetox(double x1)Move the cursor to a new x-coordinate while keeping the y-coordinate.voidmovetoy(double y1)Move the cursor to a new y-coordinate while keeping the x-coordinate.voidoffset(double dX, double dY)Offset the origin (0/0) coordinate.voidopacity(float opacity)Set the opacity.voidpen()Reset the pen to black solid line with standard stroke with.voidpen(java.awt.Color color)Set the line and font color.voidpen(float size)Set the line stroke width.voidpen(int linetype)Set the line typevoidpoint()Mark a point.voidpoint(double x1, double y1)Mark a point at the given coordinate.voidpolygon(double[] x, double[] y)Draw a polygon.voidquadcurve(double x0, double y0, double xCtrl, double yCtrl, double x1, double y1)Draw a parabola from the first coordinate to the third one.voidrect(double dx, double dy)Draw a rectangle.voidrod(double L, double w, double α)Draw a rod.booleanrotate(double α)Rotate the coordinate axes.booleanscale(double sx, double sy)Scale the axes.voidtexlabel(java.lang.String latex)Label the position of the cursor using TeX input.voidtexlabel(java.lang.String latex, java.lang.String relpos)Label the position of the cursor using TeX input.voidtexlabelline(double x0, double y0, double x1, double y1, java.lang.String latex)Label a line using TeX input.voidtext(java.lang.String text)Write some text, break lines at previously used width.voidtext(java.lang.String text, double availablewidth, boolean justified)Write some text, break lines.voidunitlength(double mm)Set the scale.voidunitlength(double scale, double unit)Set the scale and unit.
-
-
-
Method Detail
-
pen
public void pen(java.awt.Color color)
Set the line and font color.- Parameters:
color-
-
pen
public void pen(float size)
Set the line stroke width.- Parameters:
size-
-
pen
public void pen(int linetype)
Set the line type- Parameters:
linetype- DASHED, DOTTED, DASHDOTTED, SOLID
-
pen
public final void pen()
Reset the pen to black solid line with standard stroke with.
-
opacity
public final void opacity(float opacity)
Set the opacity.- Parameters:
opacity- 1.0f is opaque.
-
font
public void font(java.lang.String font, int style, int size) throws java.awt.FontFormatException, java.io.IOException- Throws:
java.awt.FontFormatExceptionjava.io.IOException
-
font
public final void font()
-
unitlength
public void unitlength(double mm)
Set the scale. The natural unit is assumed to be [mm] (has impact on image import).- Parameters:
mm- The length on the sheet for one drawing unit.
-
unitlength
public void unitlength(double scale, double unit)Set the scale and unit. Tne unit length on sheet is the product of both.- Parameters:
scale- The length on the sheet for one drawing unit.unit- natural unit mesured in mm. E.g. for [m] set 1000 [mm]
-
mm
public double mm(double mm)
mm to unit length conversion.- Parameters:
mm- in mm- Returns:
- length in equivalent unit size
-
forceunitlength
public void forceunitlength(double mm, int decdigits)Force unit length- Parameters:
mm- length of force unit. Usually kN.decdigits- number of decimal decdigits (Kommastellen)
-
fu
public double fu(double kN)
force unit to unit length conversion.- Parameters:
kN- in force unit. Usually kN.- Returns:
- length in equivalent unit size
-
expr
public double expr(java.lang.String str)
Evaluate a mathematical expression.- Parameters:
str- expression- Returns:
- double value
-
offset
public void offset(double dX, double dY)Offset the origin (0/0) coordinate. Offset is relative to previous origin position.- Parameters:
dX- in drawing unitsdY- in drawing units
-
rotate
public boolean rotate(double α)
Rotate the coordinate axes. Use allowed only within blocks. Rotation has its center at the origin (0/0). The coursor remains, thus the coordinates of current position do change.- Parameters:
α- in degrees- Returns:
- false if called from outside a block
-
flip
public boolean flip()
Mirror vertically. Use allowed only within blocks. The y-axis points upwards. Labels will also be mirrored. The coursor remains, thus the coordinates of current position do change.- Returns:
- false if called from outside a block
-
scale
public boolean scale(double sx, double sy)Scale the axes. Use allowed only within blocks. The coursor remains, thus the coordinates of current position do change.- Parameters:
sx- scale factor for x-axissy- scale factor for y-axis- Returns:
- false if called from outside a block
-
block
public int block()
Create a block. Puts the current AffineTransform and the current position onto a stack. The block has its own coordinate space, (0,0) at the current position.- Returns:
- new size of the block stack
-
endblock
public int endblock()
End a block. Resets the AffineTransform and the current position. Takes both from the block stack.- Returns:
- remaining size of the block stack. -1 if stack was empty!
-
moveto
public void moveto(double x1, double y1)Move the cursor to a new position.- Parameters:
x1-y1-
-
moveto
public void moveto(double[] xy)
Move the cursor to a new position.- Parameters:
xy- array {x1, xy}
-
movetox
public void movetox(double x1)
Move the cursor to a new x-coordinate while keeping the y-coordinate.- Parameters:
x1-
-
movetoy
public void movetoy(double y1)
Move the cursor to a new y-coordinate while keeping the x-coordinate.- Parameters:
y1-
-
here
public double[] here()
Tells where the cursor is.- Returns:
- the current position of the cursor
-
moverel
public void moverel(double dx, double dy)Move the cursor relative to the actual position.- Parameters:
dx-dy-
-
movepolar
public void movepolar(double dL, double α)Move the cursor in polar direction relative to the actual position.- Parameters:
dL-α- direction from actual position, in degrees, clock-wise
-
lineto
public void lineto(double x1, double y1)Draw a line from the actual cursor position to the given coordinate. Sets the cursor to the given coordinate.- Parameters:
x1-y1-
-
linetox
public void linetox(double x1)
Draw a line from the actual cursor position in x-direction. New x-coordinate while keeping the y-coordinate.- Parameters:
x1-
-
linetoy
public void linetoy(double y1)
Draw a line from the actual cursor position in y-direction. New y-coordinate while keeping the x-coordinate.- Parameters:
y1-
-
line
public void line(double x0, double y0, double x1, double y1)Draw a line from the first coordinate to the second one. Sets the cursor to the end of the line (second coordinate x1/y1).- Parameters:
x0-y0-x1-y1-
-
linerel
public void linerel(double dx, double dy)Draw a line from the actual cursor position to the given relative position. Sets the cursor to the end of the line.- Parameters:
dx-dy-
-
linepolar
public void linepolar(double dL, double α)Draw a line given its length and direction relative to the actual position. Sets the cursor to the end of the line.- Parameters:
dL-α- direction from actual position, in degrees, clock-wise
-
linemid
public void linemid(double L, double α)Draw a line given its length and direction. The middle of the line is set at the cursor position. The cursor does not move.- Parameters:
L-α-
-
point
public void point()
Mark a point.
-
point
public void point(double x1, double y1)Mark a point at the given coordinate. Sets the cursor to the point.- Parameters:
x1-y1-
-
arrowto
public void arrowto(double x1, double y1)Draw an arrow from the actual cursor position to the given coordinate. Sets the cursor to the given coordinate.- Parameters:
x1-y1-
-
arrowrel
public void arrowrel(double dx, double dy)Draw an arrow from the actual cursor position to the given relative position. Sets the cursor to the arrow head.- Parameters:
dx-dy-
-
arrow
public void arrow(double x0, double y0, double x1, double y1)Draw an arrow from the first coordinate to the second one. Sets the cursor to the arrow head (second coordinate x1/y1).- Parameters:
x0-y0-x1-y1-
-
arrowsto
public void arrowsto(double x1, double y1)Draw a double headed arrow from the actual cursor position to the given coordinate. Sets the cursor to the given coordinate.- Parameters:
x1-y1-
-
arrowsrel
public void arrowsrel(double dx, double dy)Draw a double headed arrow from the actual cursor position to the given relative position. Sets the cursor to the new position.- Parameters:
dx-dy-
-
arrows
public void arrows(double x0, double y0, double x1, double y1)Draw a double headed arrow from the first coordinate to the second one. Sets the cursor to the second coordinate x1/y1.- Parameters:
x0-y0-x1-y1-
-
force
public void force(double Fx, double Fy, boolean isTeX)Draw a force arrow (pointing away). The label is its absolute value. Sets the cursor to the arrow head.- Parameters:
Fx-Fy-isTeX-- See Also:
forceunitlength
-
force
public void force(double Fx, double Fy, java.lang.String lb, boolean isTeX)Draw a force arrow (pointing away). Sets the cursor to the arrow head.- Parameters:
Fx-Fy-lb-isTeX-- See Also:
forceunitlength
-
force2
public void force2(double Fx, double Fy, boolean isTeX)Draw a force arrow (pointing to the cursor). The label is its absolute value.- Parameters:
Fx-Fy-isTeX-- See Also:
forceunitlength
-
force2
public void force2(double Fx, double Fy, java.lang.String lb, boolean isTeX)Draw a force arrow (pointing to the cursor).- Parameters:
Fx-Fy-lb-isTeX-- See Also:
forceunitlength
-
circle
public void circle(double radius)
Draw a circle.- Parameters:
radius-
-
circle
public void circle(double x1, double y1, double radius)Draw a circle. Sets the cursor to the center.- Parameters:
x1-y1-radius-
-
ellipse
public void ellipse(double radius1, double radius2, double angle1)Draw an ellipse.- Parameters:
radius1-radius2-angle1- Angle of direction 1 to x-axis
-
fillellipse
public void fillellipse(double radius1, double radius2, double angle1)Fill an ellipse.- Parameters:
radius1-radius2-angle1- Angle of direction 1 to x-axis
-
arc
public void arc(double radius, double startangle, double endangle)Draw an arc. Zero angle is where the x-axis points to. Clock-wise, consistent with coord sys.- Parameters:
radius-startangle- in degrees, clock-wiseendangle- in degrees, clock-wise
-
arc
public void arc(double x1, double y1, double radius, double startangle, double endangle)Draw an arc. Zero angle is where the x-axis points to. Clock-wise, consistent with coord sys. Sets the cursor to the center.- Parameters:
x1- centery1- centerradius-startangle- in degrees, clock-wiseendangle- in degrees, clock-wise
-
fillsegment
public void fillsegment(double radius, double startangle, double endangle)Fill a segment (arc). Zero angle is where the x-axis points to. Clock-wise, consistent with coord sys.- Parameters:
radius-startangle- in degrees, clock-wiseendangle- in degrees, clock-wise
-
quadcurve
public void quadcurve(double x0, double y0, double xCtrl, double yCtrl, double x1, double y1)Draw a parabola from the first coordinate to the third one. The second is the control point (intersection of tangets). Sets the cursor to the end of the line (second coordinate x1/y1).- Parameters:
x0-y0-xCtrl- Control point (intersection of tangents)yCtrl- Control point (intersection of tangents)x1-y1-
-
cubiccurve
public void cubiccurve(double x0, double y0, double x0Ctrl, double y0Ctrl, double x1Ctrl, double y1Ctrl, double x1, double y1)Draw a cubic parabola from the first coordinate to the last one. The second and third are the control points (on the tangets). Sets the cursor to the end of the line (second coordinate x1/y1).- Parameters:
x0-y0-x0Ctrl- Control point (on first tangent)y0Ctrl- Control point (on first tangent)x1Ctrl- Control point (on second tangent)y1Ctrl- Control point (on second tangent)x1-y1-
-
rect
public void rect(double dx, double dy)Draw a rectangle.- Parameters:
dx-dy-
-
fillrect
public void fillrect(double dx, double dy)Fill a rectangle.- Parameters:
dx-dy-
-
rod
public void rod(double L, double w, double α)Draw a rod. Actually a rectangle defined by its axis (starting point and orientation), length and width. Sets the cursor to the end point on the axis, L from the starting point.- Parameters:
L- lengthw- widthα- orientation, in degrees, clock-wise
-
fillrod
public void fillrod(double L, double w, double α)Fill a rod. Actually a rectangle defined by its axis (starting point and orientation), length and width. Sets the cursor to the end point on the axis, L from the starting point.- Parameters:
L- lengthw- widthα- orientation, in degrees, clock-wise
-
polygon
public void polygon(double[] x, double[] y)Draw a polygon. Sets the cursor to the first vertex x0/y0. polygon A-B-C-D is equivalent to lines A-B-C-D-A- Parameters:
x- x coordinates of polygon verticesy- y coordinates of polygon vertices
-
fillpolygon
public void fillpolygon(double[] x, double[] y)Fill a polygon. Sets the cursor to the first vertex x0/y0. polygon A-B-C-D is equivalent to lines A-B-C-D-A- Parameters:
x- x coordinates of polygon verticesy- y coordinates of polygon vertices
-
fillcircle
public void fillcircle(double radius)
Fill a circle.- Parameters:
radius-
-
label
public void label(java.lang.String label)
Label the position of the cursor. The text is placed at the upper right (NE).- Parameters:
label- text
-
label
public void label(java.lang.String label, java.lang.String relpos)Label the position of the cursor. The placement of the text is defined by relpos.- Parameters:
label- textrelpos- N, NW, W, SW, S, SE, E, NE, C, BL
-
texlabel
public void texlabel(java.lang.String latex)
Label the position of the cursor using TeX input. The text is placed at the upper right (NE).- Parameters:
latex- text
-
texlabel
public void texlabel(java.lang.String latex, java.lang.String relpos)Label the position of the cursor using TeX input. The placement of the text is defined by relpos.- Parameters:
latex- textrelpos- N, NW, W, SW, S, SE, E, NE, C, BL
-
text
public void text(java.lang.String text)
Write some text, break lines at previously used width.- Parameters:
text- text
-
text
public void text(java.lang.String text, double availablewidth, boolean justified)Write some text, break lines.- Parameters:
text- textwidth- available width in drawing unitsjustified- whether justified text or left aligned
-
decdigits
public void decdigits(int nb)
Set number format for dimension lines- Parameters:
nb- number of decimal digits
-
dimlineto
public void dimlineto(double x1, double y1, boolean isTeX)Draw a dimension line (double headed arrow) from the cursor position to the given position and label by its length (in drawing units). Set cursor to the new position.- Parameters:
x1-y1-isTeX-
-
dimlineto
public void dimlineto(double x1, double y1, java.lang.String lb, boolean isTeX)Draw a dimension line (double headed arrow) from the cursor position to the given position and label it. Set cursor to the new position.- Parameters:
x1-y1-lb-isTeX-
-
dimlinerel
public void dimlinerel(double dx, double dy, boolean isTeX)Draw a dimension line (double headed arrow) from the cursor position to a relative position and label by its length (in drawing units). Set cursor to the new position.- Parameters:
dx-dy-isTeX-
-
dimlinerel
public void dimlinerel(double dx, double dy, java.lang.String lb, boolean isTeX)Draw a dimension line (double headed arrow) from the cursor position to a relative position and label it. Set cursor to the new position.- Parameters:
dx-dy-lb-isTeX-
-
dimline
public void dimline(double x0, double y0, double x1, double y1, boolean isTeX)Draw a dimension line (double headed arrow) and label it by its length (in drawing units). Sets the cursor to the new position (second coordinate x1/y1).- Parameters:
x0-y0-x1-y1-isTeX-
-
dimline
public void dimline(double x0, double y0, double x1, double y1, java.lang.String lb, boolean isTeX)Draw a dimension line (double headed arrow) and label it. Sets the cursor to the new position (second coordinate x1/y1).- Parameters:
x0-y0-x1-y1-lb- textisTeX-
-
labelline
public void labelline(double x0, double y0, double x1, double y1, java.lang.String lb)Label a line. Does not draw a line. Does not move the cursor.- Parameters:
x0-y0-x1-y1-lb-
-
texlabelline
public void texlabelline(double x0, double y0, double x1, double y1, java.lang.String latex)Label a line using TeX input. Does not draw a line. Does not move the cursor.- Parameters:
x0-y0-x1-y1-latex- Label using TeX math syntax
-
decdigitsangle
public void decdigitsangle(int nb)
Set number format for dimension angles- Parameters:
nb- number of decimal digits
-
dimangle
public void dimangle(double x0, double y0, double xP, double yP, double xQ, double yQ, boolean isTeX)Draw a dimension arc at a vertex. The label is either its angle in degrees or any text. Clock-wise. Sets the cursor to the vertex (x0/y0).- Parameters:
x0- vertex x-coordy0- vertex y-coordxP-yP-xQ-yQ-isTeX-
-
dimangle
public void dimangle(double x0, double y0, double xP, double yP, double xQ, double yQ, boolean isTeX, java.lang.String lb)Draw a dimension arc at a vertex. The label is either its angle in degrees or any text. Clock-wise. Sets the cursor to the vertex (x0/y0).- Parameters:
x0- vertex x-coordy0- vertex y-coordxP-yP-xQ-yQ-isTeX-lb- Label. \".\" for right angle sign
-
image
public void image(java.lang.String filename, double dpi, double pxX, double pxY, double massstab) throws java.io.FileNotFoundException, java.io.IOExceptionDraw an image.- Parameters:
filename-dpi- dots per inchpxX- image dots from the left to the insertion pointpxY- image dots from the top to the insertion pointmassstab- scale of the plan (image). 0 does not do any scaling- Throws:
java.io.FileNotFoundExceptionjava.io.IOException
-
-
DataMelt 3.0 © DataMelt by jWork.ORG