J.A.D.E.: The Java Addition to the Default Environment 
by Jean-Marie Dautelle


Listing One
package com.dautelle.geom2d;
public class Point {
  double x;
  double y;
  // XML constructor.
  public Point(Attributes attributes, Elements content) {
    x = attributes.getDouble("x");
    y = attributes.getDouble("y");
  }
}
public abstract class Surface {}

public class Ellipse extends Surface {
  Point center;
  double width;
  double height; 
  // XML constructor.
  public Ellipse(Attributes attributes, Elements content) {
    center = (Point) content.get(0);
    width = attributes.getDouble("width");
    height = attributes.getDouble("height");
  }
}
public class Polygon extends Surface {
  Point [] vertices;
  // XML constructor.
  public Polygon(Attributes attributes, Elements content) {
    vertices = new Point[content.size()];
    content.toArray(vertices);
  }
}
public class Area extends Surface {
  Surface [] surfaces;
  // XML constructor.
  public Area(Attributes attributes, Elements content) {
    surfaces = new Surface[content.size()];
    content.toArray(surfaces);
  }
}


Listing Two
<?xml version='1.0'?>
<com.dautelle.geom2d.Area>
  <com.dautelle.geom2d.Ellipse width="1.0" height="20.0">
    <com.dautelle.geom2d.Point x= "0.0" y="0.0"/>
  </com.dautelle.geom2d.Ellipse>
  <com.dautelle.geom2d.Polygon>
    <com.dautelle.geom2d.Point x= "-1.0" y="-1.0"/>
    <com.dautelle.geom2d.Point x= "0.0" y="1.0"/>
    <com.dautelle.geom2d.Point x= "1.0" y="-1.0"/>
  </com.dautelle.geom2d.Polygon>
  <com.dautelle.geom2d.Area>
    <com.dautelle.geom2d.Ellipse width="1.0" height="20.0">
       <com.dautelle.geom2d.Point x= "0.0" y="0.0"/>
    </com.dautelle.geom2d.Ellipse>
  </com.dautelle.geom2d.Area>
</com.dautelle.geom2d.Area>


Listing Three
<?xml version='1.0'?>
<Area xmlns="java:com.dautelle.geom2d">
  <Ellipse width="1.0" height="20.0">
    <Point x= "0.0" y="0.0"/>
  </Ellipse>
  <Polygon>
    <Point x= "-1.0" y="-1.0"/>
    <Point x= "0.0" y="1.0"/>
    <Point x= "1.0" y="-1.0"/>
  </Polygon>
  <Area>
    <Ellipse width="1.0" height="20.0">
       <Point x= "0.0" y="0.0"/>
    </Ellipse>
  </Area>
</Area>


Listing Four
package com.dautelle.geom2d;
import com.dautelle.xml.*;
public class Point extends Representable {
  double x;
  double y;
  public Attributes getAttributes() {
    Attributes attributes = new Attributes();
    attributes.add("x", x);
    attributes.add("y", y);
    return attributes;
  }
  public Representable[] getContent() {
    return null;
  }
}
public abstract class Surface extends Representable {}

public class Ellipse extends Surface {
  Point center;
  double width;
  double height; 
  public Attributes getAttributes() {
    Attributes attributes = new Attributes();
    attributes.add("width", width);
    attributes.add("height", height);
    return attributes;
  }
  public Representable[] getContent() {
    return new Representable[] { center };
  }
}
public class Polygon extends Surface {
  Point [] vertices;
  public Attributes getAttributes() {
    return null;
  }
  public Representable[] getContent() {
    return vertices;
  }
}
public class Area extends Surface {
  Surface [] surfaces;
  public Attributes getAttributes() {
    return null;
  }
  public Representable[] getContent() {
    return surfaces;
  }
}




3

