The JDisplay Java Applet
displays the large program listings on this web page.
JDisplay requires an up-to-date
browser and Java version
1.8+, preferably 1.8.0_131.
If you can’t see the listings, or if you just want to learn
more about JDisplay, click
Use Firefox for best results.
Graphics Object
The Graphics class is abstract. It is just a collection of
specifications for low-level drawing methods. The graphics object also contains a
reference to the area of ram where the bit image will be constructed and it also
contains the current clipping region. It is used for all types of painting including
placing components, canvas drawing and laying out text.
The most often use the Graphics object is as a
parameter to your paint, paintComponent or print method. You often
cast the abstract Graphics to an actual Graphics2D object to access additional methods. Have a look at the
Screws application to
understand the basics of drawing.
Graphics has methods drawRoundRect and drawRoundRect to draw
rectangles with rounded corners, but there are no built-in methods to do the same for
arbitrary polygons, including triangles. Here is the code taken from the connectors downloadable package to
do it:
The math behind that program may be a bit baffling. This diagram might help. The
technique for computing the rounding uses elementary geometry, the Pythagorean
theorem and elementary trigonometry.
Oracle’s Javadoc on setClip class : Graphics.setClip replaces the clip region. clip merges/intersecs this clip with the existing clip region. : available:
Oracle’s Javadoc on Graphics.drawString : the Graphics. drawString method behaves differently from other drawing methods. Usually the x,y is the upper left corner. For drawString, it is the left end of the string baseline. : available:
Oracle’s Javadoc on Graphics.drawArc : Beware. Angles are measured in degrees counter clockwise from 3 o’clock. It does not take start and end angle but start angle and arc size in degrees (end-start). Angles may be negative. : available:
Oracle’s Javadoc on Graphics.fillArc : Beware. Angles are measured in degrees counter clockwise from 3 o’clock. It does not take start and end angle but start angle and arc size in degrees (end-start). Angles may be negative. : available:
Oracle’s Javadoc on Ellipse2D.Double : This is an inner class to describe an ellipse or circle. Note that you specify the upper left corner of the enclosing rectangle, not the centre. : available:
Oracle’s Javadoc on Shape class : Interface you can pass to draw for drawing arbitrary shape outlines, solids and clip regions. Check out the long list of implementors. : available:
Please read the feedback from other visitors,
or send your own feedback about the site. Contact Roedy.
Please feel free to link to this page without explicit permission.
Canadian
Mind
Products
IP:[65.110.21.43]
Your face IP:[3.133.137.10]