Thursday, 12 February 2009

Java™ How to Program, Sixth Edition - Part12

Few weeks back i started reading Java™ How to Program, Sixth Edition By H. M. Deitel - Deitel & Associates, Inc., P. J. Deitel - Deitel & Associates, Inc.

Nice book written By H. M. Deitel - Deitel & Associates, Inc., P. J. Deitel - Deitel & Associates, Inc.

I wanted to share few quotations found the book from the 12th chapter.

1) Java's coordinate system is a scheme for identifying every point on the screen.

2) A coordinate pair is composed of an x-coordinate (the horizontal coordinate) and a y-coordinate (the vertical coordinate).

3) Text and shapes are displayed on the screen by specifying coordinates. The coordinates are used to indicate where graphics should be displayed on a screen.

4) Coordinate units are measured in pixels. A pixel is a display monitor's smallest unit of resolution.

5) A Java graphics context enables drawing on the screen.

6) Class Graphics contains methods for drawing strings, lines, rectangles and other shapes. Methods are also included for font manipulation and color manipulation.

7) A Graphics object manages a graphics context and draws pixels on the screen that represent text and other graphical object (e.g., lines, ellipses, rectangles and other polygons).

8) Class Graphics is an abstract class. This contributes to Java's portabilitywhen Java is implemented on a platform, a subclass of Graphics is created that implements the drawing capabilities. This implementation is hidden from us by class Graphics, which supplies the interface that enables us to use graphics in a platform-independent manner.

9) Class JComponent contains a paintComponent method that can be used to draw graphics in a Swing component.

10) Method paintComponent takes a Graphics object as an argument. This object is passed to the paintComponent method by the system when a lightweight Swing component needs to be repainted.

11) Method paintComponent is seldom called directly by the programmer because drawing graphics is an event-driven process. When an application executes, the application container calls method paintComponent. For paintComponent to be called again, an event must occur.

12) When a JComponent is displayed, its paintComponent method is called.

13) Programmers call method repaint to update the graphics drawn on the Swing component.

15) Class Color declares methods and constants for manipulating colors in a Java program.

16) Every color is created from a red, a green and a blue component. Together these components are called RGB values.

17) The first RGB component specifies the amount of red, the second the amount of green and the third the amount of blue. The larger the RGB value, the greater the amount of that particular color.

18) Color methods getred, getGreen and getBlue return integer values from 0 to 255 representing the amount of red, green and blue, respectively.

19) Graphics method getColor returns a Color object representing the current drawing color.

20) Graphics method setColor sets the current drawing color.

21) Graphics method fillRect draws a rectangle that is filled by the current color of the Graphics object.

22) Graphics method drawString draws a String in the current color.

23) The JColorChooser GUI component enables application users to select colors.

24) Class JColorChooser provides the static convenience method showDialog that creates a JColorChooser object, attaches it to a dialog box and displays the dialog.

25) While the color chooser dialog is on the screen, the user cannot interact with the parent component. This type of dialog is called a modal dialog.

26) Class Font contains methods and constants for manipulating fonts.

27) Class Font's constructor takes three argumentsthe font name, font style and font size.

28) A Font's font style can be Font.PLAIN, Font.ITALIC or Font.BOLD (each is a static field of class Font). Font styles can be used in combination (e.g., Font.ITALIC + Font.BOLD).

29) The font size is measured in points. A point is 1/72 of an inch.

30) Graphics method setFont sets the current drawing fontthe font in which text will be displayed.

31) Font method getStyle returns an integer value representing the current Font 's style.

32) Font method getSize returns the font size in points.

33) Font method getName returns the current font name as a string.

34) Font method getFamily returns the name of the font family to which the current font belongs. The name of the font family is platform specific.

35) Class FontMetrics contains methods for obtaining font information.

36) Font metrics include height, descent (the amount a character dips below the baseline), ascent (the amount a character rises above the baseline) and leading (the difference between the descent of one line of text and the ascent of the line of text below itthat is, the interline spacing).

37) Graphics methods fillRoundRect and drawRoundRect draw rectangles with rounded corners.

38) Graphics methods draw3DRect and fill3DRect draw three-dimensional rectangles.

39) Graphics methods drawOval and fillOval draw ovals.

40) An arc is drawn as a portion of an oval.

41) Arcs sweep (i.e., move along a curve) from a starting angle by the number of degrees specified by their arc angle.

42) Graphics methods drawArc and fillArc are used for drawing arcs.

43) Class Polygon contains methods for creating polygons.

44) Polygons are closed multisided shapes composed of straight line segments.

45) Polylines are a sequence of connected points.

46) Graphics method drawPolyline displays a series of connected lines.

47) Graphics methods drawPolygon and fillPolygon are used to draw polygons.

48) Polygon method addPoint of class Polygon adds pairs of x- and y-coordinates to the Polygon.

49) The Java 2D API provides advanced two-dimensional graphics capabilities for programmers who require detailed and complex graphical manipulations.

50) Class Graphics2D, which extends class Graphics, is used for drawing with the Java 2D API.

51) The Java 2D API contains several classes for drawing shapes, including Line2D.Double, Rectangle2D.Double, RoundRectangle2D.Double, Arc2D.Double and Ellipse2D.Double.

52) Class GradientPaint helps draw a shape in gradually changing colorscalled a gradient.

53) Graphics2D method fill draws a filled Shape objectan object that implements interface Shape.

54) Class BasicStroke helps specify the drawing characteristics of lines.

55) Graphics2D method draw is used to draw a Shape object.

56) Classes GradientPaint and TexturePaint help specify the characteristics for filling shapes with colors or patterns.

57) A general path is a shape constructed from straight lines and complex curves.

58) A general path is represented with an object of class GeneralPath.

59) GeneralPath method moveTo specifies the first point in a general path.

60) GeneralPath method lineTo draws a line to the next point in the path. Each new call to lineTo draws a line from the previous point to the current point.

61) GeneralPath method closePath draws a line from the last point to the point specified in the last call to moveTo. This completes the general path.

62) Graphics2D method translate is used to move the drawing origin to a new location.

63) Graphics2D method rotate is used to rotate the next displayed shape.

About the Authors

Dr. Harvey M. Deitel, Chairman and Chief Strategy Officer of Deitel & Associates, Inc., has 43 years experience in the computing field, including extensive industry and academic experience. Dr. Deitel earned B.S. and M.S. degrees from the Massachusetts Institute of Technology and a Ph.D. from Boston University. He worked on the pioneering virtual-memory operating-systems projects at IBM and MIT that developed techniques now widely implemented in systems such as UNIX, Linux and Windows XP. He has 20 years of college teaching experience, including earning tenure and serving as the Chairman of the Computer Science Department at Boston College before founding Deitel & Associates, Inc., with his son, Paul J. Deitel. He and Paul are the co-authors of several dozen books and multimedia packages and they are writing many more. With translations published in Japanese, German, Russian, Spanish, Traditional Chinese, Simplified Chinese, Korean, French, Polish, Italian, Portuguese, Greek, Urdu and Turkish, the Deitels' texts have earned international recognition. Dr. Deitel has delivered hundreds of professional seminars to major corporations, academic institutions, government organizations and the military.

Paul J. Deitel, CEO and Chief Technical Officer of Deitel & Associates, Inc., is a graduate of the MIT's Sloan School of Management, where he studied Information Technology. Through Deitel & Associates, Inc., he has delivered Java, C, C++, Internet and World Wide Web courses to industry clients, including IBM, Sun Microsystems, Dell, Lucent Technologies, Fidelity, NASA at the Kennedy Space Center, the National Severe Storm Laboratory, Compaq, White Sands Missile Range, Rogue Wave Software, Boeing, Stratus, Cambridge Technology Partners, Open Environment Corporation, One Wave, Hyperion Software, Adra Systems, Entergy, CableData Systems and many other organizations. Paul is one of the most experienced Java corporate trainers having taught about 100 professional Java training courses. He has also lectured on C++ and Java for the Boston Chapter of the Association for Computing Machinery. He and his father, Dr. Harvey M. Deitel, are the world's best-selling Computer Science textbook authors.

No comments: