📄 rpflayer.java
字号:
// 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"); } return omGraphicList; } /** * Paints the layer. * * @param g the Graphics context for painting * */ public void paint(java.awt.Graphics g) { Debug.message("rpf", "RpfLayer.paint()"); super.paint(g); if (coverage != null && coverage.isInUse()) { coverage.paint(g); } } //---------------------------------------------------------------------- // GUI //---------------------------------------------------------------------- private transient Box box = null; /** * Provides the palette widgets to control the options of showing * maps, or attribute text. * * @return Component object representing the palette widgets. */ public java.awt.Component getGUI() { if (box == null) { JCheckBox showMapsCheck, showInfoCheck, lockSeriesCheck; box = Box.createVerticalBox(); Box box1 = Box.createVerticalBox(); JPanel topbox = new JPanel(); JPanel subbox2 = new JPanel(); showMapsCheck = new JCheckBox("Show Images", viewAttributes.showMaps); showMapsCheck.setActionCommand(showMapsCommand); showMapsCheck.addActionListener(this); showInfoCheck = new JCheckBox("Show Attributes", viewAttributes.showInfo); showInfoCheck.setActionCommand(showInfoCommand); showInfoCheck.addActionListener(this); String tmpCS = viewAttributes.chartSeries; if (tmpCS == null) { tmpCS = RpfViewAttributes.ANY; } boolean locked = !tmpCS.equalsIgnoreCase(RpfViewAttributes.ANY); String lockedTitle = locked ? (lockedButtonTitle + " - " + tmpCS) : unlockedButtonTitle; lockSeriesCheck = new JCheckBox(lockedTitle, locked); lockSeriesCheck.setActionCommand(lockSeriesCommand); lockSeriesCheck.addActionListener(this); box1.add(showMapsCheck); box1.add(showInfoCheck); box1.add(lockSeriesCheck); if (coverage != null) { JCheckBox showCoverageCheck = new JCheckBox("Show Coverage", coverage.isInUse()); showCoverageCheck.setActionCommand(showCoverageCommand); showCoverageCheck.addActionListener(this); box1.add(showCoverageCheck); } JButton setProperties = new JButton(i18n.get(RpfLayer.class, "setProperties", "Change All Settings")); setProperties.setActionCommand(DisplayPropertiesCmd); setProperties.addActionListener(this); box1.add(setProperties); topbox.add(box1); box.add(topbox); JPanel opaquePanel = PaletteHelper.createPaletteJPanel("Map Opaqueness"); JSlider opaqueSlide = new JSlider(JSlider.HORIZONTAL, 0/* min */, 255/* max */, viewAttributes.opaqueness/* inital */); java.util.Hashtable dict = new java.util.Hashtable(); dict.put(new Integer(0), new JLabel("clear")); dict.put(new Integer(255), new JLabel("opaque")); opaqueSlide.setLabelTable(dict); opaqueSlide.setPaintLabels(true); opaqueSlide.setMajorTickSpacing(50); opaqueSlide.setPaintTicks(true); opaqueSlide.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent ce) { JSlider slider = (JSlider) ce.getSource(); if (slider.getValueIsAdjusting()) { int opaqueval = slider.getValue(); viewAttributes.opaqueness = opaqueval; fireRequestInfoLine("RPF Opaqueness set to " + viewAttributes.opaqueness + " for future requests."); if (coverage != null) { coverage.setOpaqueness(opaqueval); } } } }); opaquePanel.add(opaqueSlide); box.add(opaquePanel); JButton redraw = new JButton("Redraw RPF Layer"); redraw.addActionListener(this); subbox2.add(redraw); box.add(subbox2); } return box; } //---------------------------------------------------------------------- // ActionListener interface implementation //---------------------------------------------------------------------- /** * The Action Listener method, that reacts to the palette widgets * actions. */ public void actionPerformed(ActionEvent e) { super.actionPerformed(e); String cmd = e.getActionCommand(); if (cmd == showMapsCommand) { JCheckBox mapCheck = (JCheckBox) e.getSource(); viewAttributes.showMaps = mapCheck.isSelected(); repaint(); } else if (cmd == showInfoCommand) { JCheckBox infoCheck = (JCheckBox) e.getSource(); viewAttributes.showInfo = infoCheck.isSelected(); repaint(); } else if (cmd == lockSeriesCommand) { JCheckBox lockCheck = (JCheckBox) e.getSource(); boolean locked = lockCheck.isSelected(); if (locked) { Vector vector = getCoverageBoxes(); String seriesName; if (vector == null || vector.size() == 0) { seriesName = RpfViewAttributes.ANY; } else { seriesName = ((RpfCoverageBox) vector.elementAt(0)).chartCode; } if (seriesName == null) { seriesName = RpfViewAttributes.ANY; fireRequestMessage("The " + getName() + " Layer is having trouble determining what kind\nof charts are being displayed. Can't establish lock for charts\ncurrently being viewed."); } lockCheck.setText(lockedButtonTitle + " - " + seriesName); viewAttributes.chartSeries = seriesName; } else { lockCheck.setText(unlockedButtonTitle); viewAttributes.chartSeries = RpfViewAttributes.ANY; } } else if (cmd == showCoverageCommand) { if (coverage != null) { JCheckBox coverageCheck = (JCheckBox) e.getSource(); coverage.setInUse(coverageCheck.isSelected()); if (coverage.isInUse()) { coverage.prepare(frameProvider, getProjection(), viewAttributes.chartSeries); } repaint(); } } else { // Debug.error("RpfLayer: Unknown action command \"" + cmd // + // "\" in RpfLayer.actionPerformed()."); // OK, not really sure what happened, just act like a // reset. doPrepare(); } } /** Print out the contents of a properties file. */ public static void main(String[] argv) { System.out.println("#########################################"); System.out.println("# Properties for the JAVA RpfLayer"); System.out.println("# Mandatory properties:"); System.out.println("layer.class=com.bbn.openmap.layer.rpf.RpfLayer"); System.out.println("layer.prettyName=CADRG"); System.out.println("# This property should reflect the paths to the RPF directories"); System.out.println("layer.paths=<Path to RPF dir>;/cdrom/cdrom0/RPF"); System.out.println("# Optional properties - Defaults will be set for properties not included (defaults are listed):"); System.out.println("# Number between 0-255: 0 is transparent, 255 is opaque"); System.out.println("layer.opaque=255"); System.out.println("# Number of colors to use on the maps - 16, 32, 216"); System.out.println("layer.numberColors=216"); System.out.println("# Display maps on startup"); System.out.println("layer.showMaps=true"); System.out.println("# Display attribute information on startup"); System.out.println("layer.showInfo=false"); System.out.println("# Scale images to match map scale"); System.out.println("layer.scaleImages=true"); System.out.println("# The scale factor to allow when scaling images (2x, 4x, also mean 1/2, 1/4). Default is 4."); System.out.println("rpf.imageScaleFactor=4"); System.out.println("# Reset the cache if layer is removed from map"); System.out.println("layer.killCache=false"); System.out.println("# Limit the display to the chart code specified. (GN, JN, ON, TP, etc.)"); System.out.println("layer.chartSeries=ANY"); System.out.println("# Set the subframe cache size. (Number of subframes to hold on to, 256x256 pixels"); System.out.println("layer.subframeCacheSize=128"); System.out.println("# Get the subframe attribute data from the frame provider."); System.out.println("rpf.autofetchAttributes=false"); System.out.println("#If you want the coverage tool to be available"); System.out.println("layer.coverage=true"); System.out.println("#Then add coverage constants as needed."); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -