📄 compoundtracker.java
字号:
package org.placelab.client.tracker;import java.util.Enumeration;import java.util.Hashtable;import java.util.Vector;import org.placelab.core.Measurement;import org.placelab.core.Types;/** * A CompoundTracker encapsulates multiple {@link Tracker} objects * in a single Tracker. * This is useful primarily for comparing multiple Trackers against * one another. For instance, using a CompoundTracker with a * {@link org.placelab.demo.mapview.TrackedMapView} will produce multiple position reticles * on the map, one for each Tracker in the CompoundTracker. */public class CompoundTracker extends Tracker { private Vector trackers; public CompoundTracker() { trackers = new Vector(); } /** * Adds a {@link Tracker} to the CompoundTracker * All trackers added will be forwarded all requests to * update, either with or without Measurement. * @param t the {@link Tracker} to add */ public void addTracker(Tracker t) { trackers.addElement(t); } /** * Gets a Vector of all Trackers in this CompoundTracker */ public Vector getTrackers() { return trackers; } /** * Removes all the Trackers from the CompoundTracker. The Trackers * will not be reset and may continue to be used elsewhere, but they * will no longer be updated with by the CompoundTracker and their estimates * will no longer be included in the CompoundTracker's {@link CompoundEstimate} * results. */ public void clearTrackers() { trackers.removeAllElements(); } Hashtable badAPs = new Hashtable(); public void updateEstimateImpl(Measurement m) { for (Enumeration it = trackers.elements(); it.hasMoreElements();) { Tracker t = (Tracker)it.nextElement(); t.updateEstimate(m); } } public Estimate getEstimate() { if (trackers.size() > 0) { Enumeration it = trackers.elements(); Tracker t = (Tracker) it.nextElement(); CompoundEstimate rv = new CompoundEstimate(t.getEstimate()); while (it.hasMoreElements()) { t = (Tracker) it.nextElement(); rv.addEstimate(t.getEstimate()); } return rv; } else { return new CompoundEstimate(Types.newEstimate(0L,Types.newCoordinate(),"0.0")); } } public boolean acceptableMeasurement(Measurement m) { for (Enumeration it = trackers.elements(); it.hasMoreElements();) { Tracker t = (Tracker)it.nextElement(); if (t.acceptableMeasurement(m)) { return true; } } return false; } public void updateWithoutMeasurement(long durationMillis) { for (Enumeration it = trackers.elements(); it.hasMoreElements();) { Tracker t = (Tracker)it.nextElement(); t.updateWithoutMeasurement(durationMillis); } } public void resetImpl() { for (Enumeration it = trackers.elements(); it.hasMoreElements();) { Tracker t = (Tracker)it.nextElement(); t.reset(); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -