setPaths(paths);
if (frameProvider == null) {
// Doh! no paths were set!
Debug.error(getName()
+ "|RpfLayer.prepare(): null frame provider - either no RPF paths were set, or no frame provider was assigned. The RpfLayer has no way to get RPF data.");
return new OMGraphicList();
}
}
if (this.cache == null) {
Debug.message("rpf", getName() + "|RpfLayer: Creating cache!");
this.cache = new RpfCacheManager(frameProvider, viewAttributes, subframeCacheSize, auxSubframeCacheSize);
}
Projection projection = getProjection();
if (coverage != null && coverage.isInUse()) {
coverage.prepare(frameProvider,
projection,
viewAttributes.chartSeries);
}
// Check to make sure the projection is CADRG
if (!(projection instanceof EqualArc)
&& (viewAttributes.showMaps || viewAttributes.showInfo)) {
fireRequestInfoLine("RpfLayer requires an Equal Arc projection (CADRG/LLXY) for images or attributes!");
return null;
}
Debug.message("basic", getName() + "|RpfLayer.prepare(): doing it");
// Setting the OMGraphicsList for this layer. Remember, the
// OMGraphicList is made up of OMGraphics, which are generated
// (projected) when the graphics are added to the list. So,
// after this call, the list is ready for painting.
// call getRectangle();
if (Debug.debugging("rpf")) {
Debug.output(getName() + "|RpfLayer.prepare(): "
+ "calling getRectangle " + " with projection: "
+ projection + " ul = " + projection.getUpperLeft()
+ " lr = " + projection.getLowerRight());
}
if (frameProvider.needViewAttributeUpdates()) {
frameProvider.setViewAttributes(viewAttributes);
}
Projection cadrgProj = projection;
if (!(projection instanceof CADRG)) {
cadrgProj = new CADRG(projection.getCenter(), projection.getScale(), projection.getWidth(), projection.getHeight());
Point ulp = cadrgProj.forward(projection.getUpperLeft());
Point lrp = cadrgProj.forward(projection.getLowerRight());
int w = (int) Math.abs(lrp.getX() - ulp.getX());
int h = (int) Math.abs(lrp.getY() - ulp.getY());
// float cadrgScale =
// ProjMath.getScale(projection.getUpperLeft(),
// projection.getLowerRight(),
// cadrgProj);
cadrgProj = new CADRG(projection.getCenter(), projection.getScale(), w, h);
}
// Fetch the list with a CADRG projection, generate it with
// the real projection.
OMGraphicList omGraphicList;
try {
omGraphicList = this.cache.getRectangle(cadrgProj);
} catch (java.lang.NullPointerException npe) {
Debug.error(getName()
+ "|RpfLayer.prepare(): Something really bad happened - \n "
+ npe);
npe.printStackTrace();
omGraphicList = new OMGraphicList();
this.cache = null;
}
// ///////////////////
// safe quit
int size = 0;
if (omGraphicList != null) {
size = omGraphicList.size();
if (Debug.debugging("basic")) {
Debug.output("RpfLayer.prepare(): finished with " + size
+ " graphics");
}
// Don't forget to project them. Since they are only
// being recalled if the projection hase changed, then we
// need to force a reprojection of all of them because the
// screen position has changed.
omGraphicList.project(projection, true);
} else {
Debug.message("basic",
"RpfLayer.prepare(): finished with null graphics list");
}