I’m looking to define a map layer class. What I am wondering is: does this look right? Basically what I am after is to define a collection of geometries under a layer object.
But with my inexperience, I have probably missed some things that will make this work well.
I am aimimg to put this to the screen using OpenGL later.
Any advice would be greatly appreciated!
import java.util.ArrayList;
public class layer {
//Properties for a layer
double mbrMinX;
double mbrMinY;
double mbrMaxX;
double mbrMaxY;
double zoom_level_min;
double zoom_level_max;
ArrayList<geometries> geometries;
public class geometries {
public class point {
double dX;
double dY;
public point(double cX, double cY) {
this.dX = cX;
this.dY = cY;
}
}
public class polyline {
ArrayList<point> polylineList;
public polyline(point p) {
this.polylineList.add(p);
}
}
public class polygon {
ArrayList<point> polygonList;
public polygon(point p) {
this.polygonList.add(p);
}
}
public class multipoint {
ArrayList<point> multipointList;
public multipoint(point p) {
this.multipointList.add(p);
}
}
}
}
A few problems:
Declarations and other references to class objects in java should be capitalized.
example:
public class Layer {...}example:
public Polyline(Point p) {...}Also, your ArrayList objects are declared, but not instantiated.
example:
ArrayList<Point> polygonlist = new ArrayList<Point>();Finally, the overall structure is a bit strange for java. Usually, in java, each class is contained in it’s own file. In this case, you’ve defined nested “inner” classes, which is fine, but normally this is only done if the inner classes only have relevance to the outer class.
You also might want to check out the standard java api for graphics, which an extensive standard library for drawing points, lines, etc.