Creating a Graphical Browser

In Java, text is just a form of graphics, so we've already been working with graphics. In this next example, I'll create a nontext browser that reads an XML document and uses it to draw graphics figures—circles. Here's what a document that this browser might read, ch11_06.xml, looks like. I'm specifying the (x, y) origin of the circle and the radius of the circle as attributes of the <CIRCLE> element:

Listing . ch11_06.xml
 
<?xml version = "1.0" ?>
<!DOCTYPE DOCUMENT [
<!ELEMENT DOCUMENT (CIRCLE|ELLIPSE)*> <!ELEMENT CIRCLE EMPTY> <!ELEMENT ELLIPSE EMPTY> <!ATTLIST CIRCLE X CDATA #IMPLIED Y CDATA #IMPLIED RADIUS CDATA #IMPLIED> <!ATTLIST ELLIPSE X CDATA #IMPLIED Y CDATA #IMPLIED WIDTH CDATA #IMPLIED HEIGHT CDATA #IMPLIED> ...

Get Real World XML now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.