📄 rpfcachemanager.java
字号:
// Need to update the view attributes of the frame provider if // it is remote. if (frameProvider != null && frameProvider.needViewAttributeUpdates()) { frameProvider.setViewAttributes(viewAttributes); } // Hand off coordinates and scale to RpfCacheHandler. // Then the RpfCacheHandler will figure out the frames to load // and add to the display list. // This next bit of mumbo jumbo is to handle the equator and // dateline: Worst case, crossing both, treat each area // separately, so it is the same as handling four requests for // data - above and below the equator, and left and right of // the dateline. Normal case, there is only one box. Two // boxes if crossing only one of the boundaries. int xa = 2; int ya = 2; int lat_minus = 2; int lon_minus = 2; // Set up checks for equator and dateline LatLonPoint ll1 = proj.getUpperLeft(); LatLonPoint ll2 = proj.getLowerRight(); lat[0] = ll1.getLatitude(); lon[0] = ll1.getLongitude(); lat[1] = ll2.getLatitude(); lon[1] = ll2.getLongitude(); lat[2] = ll2.getLatitude(); lon[2] = ll2.getLongitude(); if (lon[0] > 0 && lon[2] < 0) { lon[1] = -179.999f; // put a little breather on the // dateline lon_minus = 1; } if (lat[0] > 0 && lat[2] < 0) { lat[1] = -0.0001f; // put a little breather on the equator lat_minus = 1; } if (Debug.debugging("rpf")) { Debug.output("RpfCacheManager - for:"); Debug.output("\tlat[0] " + lat[0]); Debug.output("\tlon[0] " + lon[0]); Debug.output("\tlat[1] " + lat[1]); Debug.output("\tlon[1] " + lon[1]); Debug.output("\tlat[2] " + lat[2]); Debug.output("\tlon[2] " + lon[2]); Debug.output("\tlat_minus = " + lat_minus); Debug.output("\tlon_minus = " + lon_minus); } /* * Worst case, there are four boxes on the screen. Best case, * there is one. The things that create boxes and dictates how * large they are are the equator and the dateline. When the * screen straddles one or both of these lat/lon lines, * lon_minus and lat_minus get adjusted, causing two or four * different calls to the tochandler to get the data * above/below the equator, and left/right of the dateline. * Plus, each path gets checked until the required boxes are * filled. */ // Normal (maybe) box[0] gets filled every time - bottom right // box. caches[0].setCache(lat[ya - lat_minus], lon[xa - lon_minus], lat[ya], lon[xa], viewAttributes.proj); if (Debug.debugging("rpf")) Debug.output("RpfCacheManager: main (1) cache used."); // Dateline split if (lon_minus == 1) { if (caches[1] == null) { caches[1] = new RpfCacheHandler(frameProvider, viewAttributes, auxCacheSize); } caches[1].setCache(lat[ya - lat_minus], lon[0], lat[ya], -1f * lon[1], viewAttributes.proj); // -1 to make it // 180 if (Debug.debugging("rpf")) Debug.output("-- second cache used"); } else { caches[1] = null; } // Equator Split if (lat_minus == 1) { if (caches[2] == null) { caches[2] = new RpfCacheHandler(frameProvider, viewAttributes, auxCacheSize); } caches[2].setCache(lat[0], lon[xa - lon_minus], -1f * lat[1], // flip // breather lon[xa], viewAttributes.proj); if (Debug.debugging("rpf")) Debug.output("-- third cache used"); } else { caches[2] = null; } // Both!! if (lon_minus == 1 && lat_minus == 1) { if (caches[3] == null) { caches[3] = new RpfCacheHandler(frameProvider, viewAttributes, auxCacheSize); } caches[3].setCache(lat[0], lon[0], -1f * lat[1],// flip // breather -1f * lon[1], viewAttributes.proj);// -1 to make // it 180, not // -180 if (Debug.debugging("rpf")) Debug.output("-- fourth cache used"); } else { caches[3] = null; } OMGraphicList gl = new OMGraphicList(); gl.add(getSubframes()); return gl; } /** * Creates the OMGraphicList by cycling through the caches, * getting the images and attribute infomation. */ protected OMGraphic getSubframes() { // graphics = new RpfMaps(viewAttributes); graphics.clear(); if (Debug.debugging("rpf")) { Debug.output("RpfCacheManager: show maps: " + viewAttributes.showMaps + ", showInfo: " + viewAttributes.showInfo); } if (!(viewAttributes.showMaps || viewAttributes.showInfo)) { return graphics; } for (int nbox = 0; nbox < MAX_NUM_BOXES; nbox++) { if (caches[nbox] != null && caches[nbox].getGoodData()) { int subframeRunningCount = 0; for (int subx = caches[nbox].start.x; subx <= caches[nbox].end.x; subx++) { for (int suby = caches[nbox].start.y; suby <= caches[nbox].end.y; suby++) { /////// RpfSubframe subframe = caches[nbox].getCached(subx, suby, subframeRunningCount); /////// if (subframe == null) { if (Debug.debugging("rpf")) { Debug.output("RpfCacheManager: checking other TOCs for subframe."); } subframe = caches[nbox].getSubframeFromOtherTOC(subx, suby, subframeRunningCount); } if (subframe != null) { graphics.addInfo(subframe.information); graphics.addInfo(subframe.rectangle); graphics.addMap(subframe.image); if (Debug.debugging("rpf")) Debug.output("RpfCacheManager: Adding subframe " + subx + ", " + suby); } else { if (Debug.debugging("rpf")) Debug.output("RpfCacheManager: subframe " + subx + ", " + suby + " empty"); } subframeRunningCount++; } } } } if (Debug.debugging("rpf")) { Debug.output("RpfCacheManager: done."); } return graphics; } public class RpfMaps extends OMGraphic { public RpfViewAttributes atts; public OMGraphicList maps = new OMGraphicList(); public OMGraphicList infos = new OMGraphicList(); public RpfMaps(RpfViewAttributes rva) { atts = rva; } public void clear() { maps.clear(); infos.clear(); } public void addMap(OMGraphic graphic) { maps.add(graphic); } public void addInfo(OMGraphic graphic) { infos.add(graphic); } public boolean generate(Projection proj) { maps.generate(proj); infos.generate(proj); return true; } public void render(java.awt.Graphics g) { if (atts.showMaps) { maps.render(g); } if (atts.showInfo) { infos.render(g); } } public float distance(int x, int y) { return Float.MAX_VALUE; } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -