/** * construct a MapArea from any two opposite corner points * * @param x1 x coord of any corner of the bounding box * @param y1 y coord of the same corner as x1 * @param x2 x coord of opposite corner from x1,y1 * @param y2 y coord of same corner as x2 */ public ProjectionRect(double x1, double y1, double x2, double y2) { double wx0 = 0.5 * (x1 + x2); double wy0 = 0.5 * (y1 + y2); double width = Math.abs(x1 - x2); double height = Math.abs(y1 - y2); setRect(wx0 - width / 2, wy0 - height / 2, width, height); }
/** * Construct a ProjectionRect from any two opposite corner points. * * @param minimum lower left corner, ie the minimum x and y * @param width x width. * @param height y height */ public ProjectionRect(ProjectionPoint minimum, double width, double height) { setRect(minimum.getX(), minimum.getY(), width, height); }
/** * set Y height * * @param h Y height */ public void setHeight(double h) { setRect(getX(), getY(), getWidth(), h); }
/** * set X width * * @param w x width */ public void setWidth(double w) { setRect(getX(), getY(), w, getHeight()); }
/** * set minimum X * * @param x minimum x */ public void setX(double x) { setRect(x, getY(), getWidth(), getHeight()); }
/** * set Y height * * @param h Y height */ public void setHeight(double h) { setRect(getX(), getY(), getWidth(), h); }
/** * set minimum Y * * @param y minimum y */ public void setY(double y) { setRect(getX(), y, getWidth(), getHeight()); }
/** * set minimum Y * * @param y minimum y */ public void setY(double y) { setRect(getX(), y, getWidth(), getHeight()); }
/** * set minimum X * * @param x minimum x */ public void setX(double x) { setRect(x, getY(), getWidth(), getHeight()); }
/** * set minimum Y * * @param y minimum y */ public void setY(double y) { setRect(getX(), y, getWidth(), getHeight()); }
/** * set X width * * @param w x width */ public void setWidth(double w) { setRect(getX(), getY(), w, getHeight()); }
/** * set Y height * * @param h Y height */ public void setHeight(double h) { setRect(getX(), getY(), getWidth(), h); }
/** * set minimum X * * @param x minimum x */ public void setX(double x) { setRect(x, getY(), getWidth(), getHeight()); }
/** * set X width * * @param w x width */ public void setWidth(double w) { setRect(getX(), getY(), w, getHeight()); }
/** * set minimum X * * @param x minimum x */ public void setX(double x) { setRect(x, getY(), getWidth(), getHeight()); }
/** * set X width * * @param w x width */ public void setWidth(double w) { setRect(getX(), getY(), w, getHeight()); }
/** * set minimum Y * * @param y minimum y */ public void setY(double y) { setRect(getX(), y, getWidth(), getHeight()); }
/** * set Y height * * @param h Y height */ public void setHeight(double h) { setRect(getX(), getY(), getWidth(), h); }
public void setRect(ProjectionRect r) { setRect(r.getX(), r.getY(), r.getWidth(), r.getHeight()); }
/** * Read the object from the input stream of the serialized object * * @param s stream to read * @throws ClassNotFoundException couldn't file the class * @throws IOException Problem reading from stream */ private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException { double x = s.readDouble(); double y = s.readDouble(); double w = s.readDouble(); double h = s.readDouble(); setRect(x, y, w, h); }