📄 rpflayer.java
字号:
// **********************************************************************// // <copyright>// // BBN Technologies// 10 Moulton Street// Cambridge, MA 02138// (617) 873-8000// // Copyright (C) BBNT Solutions LLC. All rights reserved.// // </copyright>// **********************************************************************// // $Source: /cvs/distapps/openmap/src/openmap/com/bbn/openmap/layer/rpf/RpfLayer.java,v $// $RCSfile: RpfLayer.java,v $// $Revision: 1.12.2.5 $// $Date: 2005/02/11 22:51:26 $// $Author: dietrick $// // **********************************************************************package com.bbn.openmap.layer.rpf;/* Java Core */import java.awt.Point;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.io.Serializable;import java.util.Properties;import java.util.Vector;import javax.swing.Box;import javax.swing.JButton;import javax.swing.JCheckBox;import javax.swing.JLabel;import javax.swing.JPanel;import javax.swing.JSlider;import javax.swing.event.ChangeEvent;import javax.swing.event.ChangeListener;import com.bbn.openmap.I18n;import com.bbn.openmap.event.ProjectionEvent;import com.bbn.openmap.layer.OMGraphicHandlerLayer;import com.bbn.openmap.layer.util.cacheHandler.CacheHandler;import com.bbn.openmap.omGraphics.OMGraphicList;import com.bbn.openmap.proj.CADRG;import com.bbn.openmap.proj.EqualArc;import com.bbn.openmap.proj.Projection;import com.bbn.openmap.util.Debug;import com.bbn.openmap.util.PaletteHelper;import com.bbn.openmap.util.PropUtils;/** * The RpfLayer fills the screen with RPF data. There is also a tool * available that allows you to see the coverage of the available * data. To view theimages, the projection of the map has to be set in * the ARC projection, which OpenMap calls the CADRG projection. The * RpfLayer can use several RPF directories at the same time, and * doesn't require that the data actually be there at runtime. That * way, you can give a location where the data may be mouted during * runtime(i.e. CDROM) and the layer will still use the data. The * scale of the projection does not necessarily have to match the * scale of a map series for that series to be displayed. There are * options, set in the RpfViewAttributes, that allow scaling of the * RPF images to match the map scale. * <P> * * The RpfLayer uses the RpfCacheManager to get the images it needs to * display. Whenever the projection changes, the cache manager takes * the new projection and creates a OMGraphicList with the new image * frames and attribute text. * <P> * * The RpfLayer gets its intial settings from properties. This should * be done right after the RpfLayer is created. The properties list * contains the location of the RPF directories, the opaqueness of the * images, the number of colors to use, and whether to show the images * and/or attributes by default. An example of the RpfLayer * properties: * <P> * * <pre> * * * * * * * * * * * #----------------------------- * # Properties for RpfLayer * #----------------------------- * # Mandatory properties * # This property should reflect the paths to the RPF directories * rpf.paths=/usr/local/matt/data/RPF /usr/local/matt/data/CIB/RPF * * # Optional Properties - the default will be set if these are not * # included in the properties file: * # Number between 0-255: 0 is transparent, 255 is opaque. 255 is default. * rpf.opaque=128 * * # Number of colors to use on the maps - 16, 32, 216. 216 is default. * rpf.numberColors=216 * * # Display maps on startup. Default is true. * rpf.showMaps=true * * # Display attribute information on startup. Default is false. * rpf.showInfo=false * * # Scale charts to match display scale. Default is true. * rpf.scaleImages=true * * # The scale factor to allow when scaling images (2x, 4x, also mean 1/2, 1/4). Default is 4. * rpf.imageScaleFactor=4 * * # Delete the cache if the layer is removed from the map. Default is false. * rpf.killCache=true * # Limit the display to the chart code specified. (GN, JN, ON, TP, etc.). * # Default is ANY * rpf.chartSeries=ANY * # Get the subframe attribute data from the Frame provider. * rpf.autofetchAttributes=false * # Set to true if you want the coverage tool available. * rpf.coverage=true * # Set the subframe cache size. (Number of subframes to hold on to, 256x256 pixels) * rpf.subframeCacheSize=128 * # Then also include coverage properties, which are available in the RpfConstants. * #------------------------------------ * # End of properties for RpfLayer * #------------------------------------ * * * * * * * * * * * </pre> * */public class RpfLayer extends OMGraphicHandlerLayer implements ActionListener, RpfConstants, Serializable { /** * The main source for the images and attribute information. All * requests for graphic objects should go through this cache, and * it will automatically handle getting the frame files, decoding * them, and returning an object list. */ protected transient RpfCacheManager cache = null; /** The paths to the RPF directories, telling where the data is. */ protected String[] paths; /** * The display attributes for the maps. This object should not be * replaced, because the caches all look at it, too. Just adjust * the parameters within it. * * @see RpfViewAttributes */ protected RpfViewAttributes viewAttributes; /** Flag to delete the cache if the layer is removed from the map. */ protected boolean killCache = true; /** The supplier of frame data. */ protected RpfFrameProvider frameProvider; /** The coverage tool for the layer. */ protected RpfCoverage coverage; /** Subframe cache size. Default is 40. */ protected int subframeCacheSize = RpfCacheHandler.SUBFRAME_CACHE_SIZE; /** Auxillary subframe cache size. Default is 10. */ protected int auxSubframeCacheSize = RpfCacheManager.SMALL_CACHE_SIZE; /** * The default constructor for the Layer. All of the attributes * are set to their default values. Use this construct if you are * going to use a standard properties file, which will set the * paths. */ public RpfLayer() { setName("RPF"); viewAttributes = new RpfViewAttributes(); setProjectionChangePolicy(new com.bbn.openmap.layer.policy.ListResetPCPolicy(this)); } /** * The default constructor for the Layer. All of the attributes * are set to their default values. * * @param pathsToRPFDirs paths to the RPF directories that hold * A.TOC files. */ public RpfLayer(String[] pathsToRPFDirs) { this(); setPaths(pathsToRPFDirs); } /** * Set the paths to the RPF directories, which are by default the * parents of the A.TOC table of contents files. Creates the * RpfFrameProvider. * * @param pathsToRPFDirs Array of strings that list the paths to * RPF directories. */ public void setPaths(String[] pathsToRPFDirs) { if (pathsToRPFDirs != null) { setFrameProvider(new RpfFrameCacheHandler(pathsToRPFDirs)); } else { Debug.output("RpfLayer: Need RPF directory paths."); frameProvider = null; } paths = pathsToRPFDirs; this.cache = null; } /** * Get the paths to the RPF directories. * * @return String[] */ public String[] getPaths() { return paths; } /** * Called when the layer is no longer part of the map. In this * case, we should disconnect from the server if we have a link. */ public void removed(java.awt.Container cont) { if (killCache) { Debug.message("rpf", "RpfLayer: emptying cache!"); clearCache(); } // need to reset this for when it gets added again, if it was // removed without the projection actually changing. This // helps when the cache needs to be rebuilt. setProjection((Projection) null); } protected void setDefaultValues() { // defaults paths = null; } /** * Set all the RPF properties from a properties object. */ public void setProperties(String prefix, java.util.Properties properties) { super.setProperties(prefix, properties); prefix = PropUtils.getScopedPropertyPrefix(prefix); paths = PropUtils.initPathsFromProperties(properties, prefix + RpfPathsProperty, paths); viewAttributes.setProperties(prefix, properties); subframeCacheSize = PropUtils.intFromProperties(properties, prefix + CacheSizeProperty, subframeCacheSize); auxSubframeCacheSize = PropUtils.intFromProperties(properties, prefix + CacheSizeProperty, auxSubframeCacheSize); if (viewAttributes.chartSeries == null) viewAttributes.chartSeries = RpfViewAttributes.ANY; killCache = PropUtils.booleanFromProperties(properties, prefix + KillCacheProperty, killCache); if (coverage == null) { setCoverage(new RpfCoverage(this)); } coverage.setProperties(prefix, properties); resetPalette(); } /** * PropertyConsumer method, to fill in a Properties object, * reflecting the current values of the layer. If the layer has a * propertyPrefix set, the property keys should have that prefix * plus a separating '.' prepended to each propery key it uses for * configuration. * * @param props a Properties object to load the PropertyConsumer * properties into. If props equals null, then a new * Properties object should be created. * @return Properties object containing PropertyConsumer property * values. If getList was not null, this should equal * getList. Otherwise, it should be the Properties object * created by the PropertyConsumer. */ public Properties getProperties(Properties props) { props = super.getProperties(props); String prefix = PropUtils.getScopedPropertyPrefix(this); // find out paths... String[] p = getPaths(); StringBuffer pathString = new StringBuffer(); if (p != null) { for (int i = 0; i < p.length; i++) { if (p[i] != null) { pathString.append(p[i]); if (i < p.length - 1) { pathString.append(";"); // separate paths with // ; } } } props.put(prefix + RpfPathsProperty, pathString.toString());
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -