Draw a simple image
// Draw line2d.double
g2.draw (new line2d.double (x, y reccTheight-1,
X RectWidth, Y));
// Draw Rectangle2D.double
g2.setstroke (stroke);
G2.draw (New Rectangle2D.double (x, y,
RectWidth,
RectHeight));
// Draw roundRectangle2d.double
g2.setstroke (dashed);
g2.draw (New RoundRectangle2d.double (x, y,
RectWidth,
RectHeight,
10, 10));
// Draw arc2d.double
g2.setstroke (WideStroke);
g2.draw (new arc2d.double (x, y,
RectWidth,
RectHeight,
90, 135,
Arc2d.open);
// Draw Ellipse2D.double
g2.setstroke (stroke);
g2.draw (new elipse2d.double (x, y,
RectWidth,
RectHeight));
// Draw generalpath (Polygon)
Int x1points [] = {x, x reccTwidth,
X, X RectWidth};
Int Y1Points [] = {y, y RectHeight,
Y RectHeight, Y};
GeneralPath Polygon = New
GeneralPath (GeneralPath.Wind_Even_ODD,
X1Points.Length);
Polygon.moveto (X1Points [0], Y1Points [0]);
For (int index = 1;
Index INDEX ) { Polygon.Lineto (X1Points [index], Y1Points [INDEX]); } Polygon.closepath (); g2.draw (polygon); // Draw generalpath (polyline) Int x2points [] = {x, x reccTwidth, x, X RectWidth}; Int y2points [] = {y, y reccTheight, Y RectHeight, Y}; GeneralPath POLYLINE = New GeneralPath (GeneralPath.Wind_Even_ODD, X2Points.Length; POLYLINE.MOVETO (X2Points [0], Y2Points [0]); For (int index = 1; Index INDEX ) { POLYLINE.LINETO (X2Points [Index], Y2Points [index]); } g2.draw (pot "; // Fill Rectangle2d.double (Red) G2.SETPAINT (RED); g2.fill (New Rectangle2D.double (x, y, RectWidth, RectHeight)); // Fill RoundRectangle2d.double G2.SETPAINT (Redtowhite); g2.fill (New RoundRectangle2d.double (x, y, RectWidth, RectHeight, 10, 10)); // Fill Arc2d G2.SETPAINT (RED); G2.fill (new arc2d.double (x, y, rectwidth, RectHeight, 90, 135, Arc2D.Open); // Fill Ellipse2D.double G2.SETPAINT (Redtowhite); G2.fill (new elipse2d.double (x, y, RectWidth, RectHeight)); // Fill and stroke generalpath INT X3Points [] = {x, x reccTwidth, X, X RectWidth}; Int Y3Points [] = {y, y reccTheight, Y RectHeight, Y}; GeneralPath FilledPolygon = New GeneralPath (GeneralPath.Wind_Even_ODD, X3Points.Length; FilledPolygon.moveto (x3points [0], Y3Points [0]); For (int index = 1; Index INDEX ) { FilledPolygon.Lineto (X3Points [index], Y3Points [index]); } FilledPolygon.Closepath (); G2.SETPAINT (RED); g2.fill (FilledPolygon); The above is a simple API and the effect stroke, it is to define line wide / line types.