📄 scenariographicloader.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/graphicLoader/scenario/ScenarioGraphicLoader.java,v $// $RCSfile: ScenarioGraphicLoader.java,v $// $Revision: 1.4.2.4 $// $Date: 2005/09/15 14:38:57 $// $Author: dietrick $// // **********************************************************************package com.bbn.openmap.graphicLoader.scenario;import java.awt.Container;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.awt.event.ComponentEvent;import java.awt.event.ComponentListener;import java.beans.PropertyChangeSupport;import java.net.MalformedURLException;import java.net.URL;import java.text.ParseException;import java.text.SimpleDateFormat;import java.util.Date;import java.util.Hashtable;import java.util.Iterator;import java.util.LinkedList;import java.util.Properties;import java.util.Vector;import javax.swing.Box;import javax.swing.ImageIcon;import javax.swing.JLabel;import javax.swing.JPanel;import javax.swing.JSlider;import javax.swing.JToggleButton;import javax.swing.SwingConstants;import com.bbn.openmap.Layer;import com.bbn.openmap.PropertyConsumer;import com.bbn.openmap.graphicLoader.MMLGraphicLoader;import com.bbn.openmap.gui.Tool;import com.bbn.openmap.gui.time.RealTimeHandler;import com.bbn.openmap.gui.time.TimeConstants;import com.bbn.openmap.gui.time.TimeSliderSupport;import com.bbn.openmap.gui.time.TimerControlButtonPanel;import com.bbn.openmap.gui.time.TimerRateComboBox;import com.bbn.openmap.io.CSVFile;import com.bbn.openmap.layer.location.LocationHandler;import com.bbn.openmap.omGraphics.DrawingAttributes;import com.bbn.openmap.omGraphics.OMGraphic;import com.bbn.openmap.omGraphics.OMGraphicHandler;import com.bbn.openmap.omGraphics.OMGraphicList;import com.bbn.openmap.proj.Projection;import com.bbn.openmap.util.DataBounds;import com.bbn.openmap.util.DataBoundsProvider;import com.bbn.openmap.util.Debug;import com.bbn.openmap.util.PropUtils;/** * The ScenarioGraphicLoader contains all the ScenarioGraphics and * manages the time for the scenario. The different organization * objects are represented in a location file that lists a name and an * icon URL. An activities file lists the different steps for the * organizations - where they are (lat/lon) and when. A timer in the * loader positions the organizations for that time, interpolating * location for times between time/location definitions. If an * organization stops to wait in a position, two activity locations * should be defined for that stop, for when the organization arrived * to that spot and when then left. Different properties need to be * set for the ScenarioGraphicLoader to let it know how the files, * Comma Separated Value (CSV) files, should be interpreted. * <p> * * The ScenarioGraphicLoader also lets you define different steps for * how to control the time, i.e. the timer rate. The clock interval * for the timer rate is measured in milliseconds, specifying how * often the map should be updated. Note that the more often the map * is updated, the more unresponsive the map can become. The pace for * the timer rate is how much 'senario time' passes for each time the * clock updates. You can define those steps in different formats, but * the default format for the pace is hh:mm:ss for * hours:minutes:seconds. * <p> * * Sample properties: * * <pre> * * * scenario.class=com.bbn.openmap.graphicLoader.scenario.ScenarioGraphicLoader * scenario.prettyName=Test Scenario * scenario.locationFile=org-list.csv * scenario.locationFileHasHeader=true * scenario.nameIndex=0 * scenario.iconIndex=5 * scenario.activityFile=org-activities.csv * scenario.activityFileHasHeader=true * scenario.activityNameIndex=1 * scenario.latIndex=9 * scenario.lonIndex=10 * scenario.timeFormat=d-MMM-yyyy HH:mm * scenario.timeIndex=7 * # If no icon defined, used for org. location markers edge. * scenario.lineColor=aaaaaa33 * # If no icon defined, used for org. location markers fill. * scenario.fillColor=aaaaaa33 * # Used for lines for total scenario paths * scenario.selectColor=aaaa0000 * * scenario.timerRates=vs s m a q f vf * scenario.vs.prettyName=Very Slow * scenario.vs.clockIntervalMillis=2000 * scenario.vs.pace=00:06:00 * scenario.s.prettyName=Slow * scenario.s.clockIntervalMillis=1000 * scenario.s.pace=00:06:00 * scenario.m.prettyName=Moderate * scenario.m.clockIntervalMillis=400 * scenario.m.pace=00:06:00 * scenario.a.prettyName=Average * scenario.a.clockIntervalMillis=200 * scenario.a.pace=00:06:00 * scenario.q.prettyName=Quick * scenario.q.clockIntervalMillis=100 * scenario.q.pace=00:06:00 * scenario.f.prettyName=Fast * scenario.f.clockIntervalMillis=40 * scenario.f.pace=00:06:00 * scenario.vf.prettyName=Very Fast * scenario.vf.clockIntervalMillis=10 * scenario.vf.pace=01:00:00 * * </pre> */public class ScenarioGraphicLoader extends MMLGraphicLoader implements Tool, ComponentListener, DataBoundsProvider, RealTimeHandler, TimeConstants { public final static String TOTAL_SCENARIO_MODE = "TOTAL_SCENARIO"; public final static String SNAPSHOT_SCENARIO_MODE = "SNAPSHOT_SCENARIO"; public final static String SCENARIO_MODE_CMD = "SCENARIO_MODE_CMD"; public final static String DefaultTimerIntervalFormat = "HH:mm:ss"; public final static String DefaultPaceBaselineString = "00:00:00"; protected String totalScenarioIconName = "totalScenarioTime.png"; protected String snapshotIconName = "snapshotScenarioTime.png"; /** locationFile */ public final static String LocationFileProperty = "locationFile"; /** locationFileHasHeader */ public final static String LocationHeaderProperty = "locationFileHasHeader"; /** iconIndex */ public final static String IconIndexProperty = "iconIndex"; /** nameIndex */ public final static String NameIndexProperty = "nameIndex"; /** activityFile */ public final static String ActivityFileProperty = "activityFile"; /** activityNameIndex */ public final static String ActivityNameIndexProperty = "activityNameIndex"; /** activityFileHasHeader */ public final static String ActivityHeaderProperty = "activityFileHasHeader"; /** latIndex */ public final static String LatIndexProperty = "latIndex"; /** lonIndex */ public final static String LonIndexProperty = "lonIndex"; /** timeIndex */ public final static String TimeIndexProperty = "timeIndex"; /** eastIsNeg */ public final static String EastIsNegProperty = "eastIsNeg"; /** showNames */ public final static String ShowNamesProperty = LocationHandler.ShowNamesProperty; /** defaultURL */ public final static String DefaultIconURLProperty = "defaultURL"; /** timeFormat */ public final static String TimeFormatProperty = "timeFormat"; /** timerInvervalFormat */ public final static String TimerIntervalFormatProperty = "timerIntervalFormat"; /** timerPaceBaseline */ public final static String TimerPaceBaselineProperty = "timerPaceBaseline"; /** clockIntervalMillis */ public final static String ClockIntervalProperty = "clockIntervalMillis"; /** pace */ public final static String PaceProperty = "pace"; /** timerRates */ public final static String TimerRatesProperty = "timerRates"; protected String locationFile; protected boolean locationHeader = true; protected int nameIndex; protected int iconIndex; protected String activityFile; protected boolean activityHeader = true; protected int activityNameIndex; protected int latIndex; protected int lonIndex; protected int timeIndex; protected boolean eastIsNeg = false; /** * TimeFormat default is similar to IETF standard date syntax: * "Sat, 12 Aug 1995 13:30:00 GMT" represented by (EEE, d MMM yyyy * HH:mm:ss z), except for the local timezone. */ protected SimpleDateFormat timeFormat = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss z"); /** * The TimerIntervalFormat controls how the pace can be specified * for the rate settings. The default is HH:mm:ss, you can use the * timerIntervalFormat property to set it to something else. */ protected SimpleDateFormat timerIntervalFormat = new SimpleDateFormat(DefaultTimerIntervalFormat); protected String timerPaceBaselineString = DefaultPaceBaselineString; protected long startTime = Long.MAX_VALUE; protected long endTime = Long.MIN_VALUE; protected long time = 0; protected int timeIncrement = 1; protected String mode = TOTAL_SCENARIO_MODE; protected boolean timeWrap = (mode == SNAPSHOT_SCENARIO_MODE); protected int clockDirection = 1; /** Icon URL for points to use as default. May be null. */ protected String defaultIconURL; protected boolean showNames = false; protected PropertyChangeSupport pcs = new PropertyChangeSupport(this); protected ScenarioGraphicList scenarioGraphics = null; protected LinkedList timerRates; protected DrawingAttributes drawingAttributes = null; protected DataBounds dataBounds = null; protected Date timeDate = null; // / GUI ToolPanel widgets. Kept here to make their visibility // adjustable. protected JToggleButton timeWrapToggle; protected JLabel timeLabel; protected TimerControlButtonPanel timerControl; protected TimerRateComboBox timerRateControl; protected JSlider timeSlider; protected TimeSliderSupport timeSliderSupport; public ScenarioGraphicLoader() { drawingAttributes = new DrawingAttributes(); dataBounds = new DataBounds(); setUpdateInterval(500); // Default 1/2 second. } /** * The main method call in the ScenarioGraphicLoader that actually * modifies the OMGraphics and updates the map. */ public synchronized void manageGraphics() { Projection p = getProjection(); OMGraphicHandler receiver = getReceiver(); boolean DEBUG = Debug.debugging("scenario"); if (receiver != null && p != null) { if (scenarioGraphics == null) { scenarioGraphics = createData(); // Update limits if (timeSliderSupport != null) { timeSliderSupport.setStartTime(startTime); timeSliderSupport.setEndTime(endTime); } } long currentTime = getTime(); if (DEBUG) { Debug.output("ScenarioGraphicLoader (" + getName() + ") snapshot at " + currentTime); } scenarioGraphics.generate(p, currentTime, getMode() == TOTAL_SCENARIO_MODE); if (DEBUG) { Debug.output("ScenarioGraphicLoader (" + getName() + ") setting list of " + scenarioGraphics.size() + " scenario graphics"); } receiver.setList(scenarioGraphics); } else { Debug.output("ScenarioGraphicLoader (" + getName() + ") doesn't have a connection to the map."); } } // RealTimeHandler methods.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -