Java Reference
In-Depth Information
private ArrayList path # new ArrayList(); // the vertices
public MapLink() {}
public void addPoint( int x, int y) {
path.add( new Point2D.Double(x, y));
}
public boolean contains( double x, double y) {
Point2D p1 # (Point2D) path.get(0);
for ( int i # 1; i < path.size(); i !! ) {
//measures the distance between point x,y and the path
Point2D p2 # (Point2D) path.get(i);
double dist # Line2D.ptSegDist(p1.getX(),p1.getY(),
p2.getX(),p2.getY(),x, y);
if (dist < # DIST) return true ;
p1 # p2;
}
return false ;
}
public String toXML() { . . . }
public void paint(Graphics2D g, Color color) { . . . }
}
public class MapArea extends MapEntity {
private Polygon area # new Polygon();
public MapArea() {}
public void addPoint( int x, int y) { area.addPoint(x, y);}
public boolean contains( double x, double y) {
if (area.contains(x, y)) return true ;
return false ;
}
public void paint(Graphics2D g, Color color) { . . . }
public String toXML() { . . . }
}
Classes MapEntitySet , MapLayer and CartographicMap implement the data
structures defined in Figure 15.3 and a set of methods to create the GIS
object model, to select entities, to record their description in XML format,
and to set the visibility of entities and layers. Class CartographicMap extends
class JPanel and represents the main component of the graphical editor. It
implements methods to create, open and save a cartographic map.
public class MapEntitySet {
// the list of geographic entities
private ArrayList entityList # new ArrayList();
private boolean visible # false ;
public void setVisible( boolean visible) {
this .visible # visible;
}
Search WWH ::




Custom Search