Chapter 12. Media: Graphics, Audio, Video
Introduction
The Graphics class and the Component method paint() have survived virtually unchanged since the early days of Java. Together they provide a basic but quite functional graphics capability. The first printing API was put forward in 1.1, and it was promptly replaced in 1.2, and again in 1.4. These printing APIs, fortunately, are based on the Graphics object, so drawing code did not have to change; only the details of getting the right kind of Graphics object changed. The 2D (two-dimensional graphics) package is also based on Graphics; Graphics2D is a subclass of Graphics.
To put the 2D graphics in perspective, think about the tremendous boost that the Adobe PostScript language gave to desktop publishing and printing. PostScript is both a scripting language and a marking engine: it has the capability to make a terrific variety of marks on paper. Because Java is already a comprehensive programming language, the 2D API needed only to add the marking engine. This it did very well, using several ideas imported from PostScript via Adobe’s participation in the early design.
Also present from the beginning was the AudioClip class, which
represents a playable sound file. This was soon extended to
support additional formats (including MIDI) and to be usable from
within an application as well. Meanwhile, the Java Media
Framework (extension javax.media) and the newer JavaFX framework provide for playing audio, video, and possibly other media ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access