Issue #883 Sorted warning records and prevented altered entries to be in
the same frame as new entries. Former-commit-id:fa7795d17f
[formerly 5c8c0783c8e054792ac38b4487188495dd0b0319] Former-commit-id:6507a97665
This commit is contained in:
parent
8cd83e1571
commit
4f2d6630c1
5 changed files with 83 additions and 37 deletions
|
@ -31,7 +31,7 @@ import com.raytheon.viz.warnings.DateUtil;
|
|||
* Aug 5, 2011 njensen Refactored maps
|
||||
* Aug 22, 2011 10631 njensen Major refactor
|
||||
* May 31, 2012 DR14992 mgamazaychikov Changed the order of strings in the
|
||||
* String array returned from getText method
|
||||
* String array returned from getText method
|
||||
* Jun 04, 2012 DR14992 mgamazaychikov Reversed the previous changes
|
||||
*
|
||||
* </pre>
|
||||
|
@ -62,6 +62,8 @@ public abstract class AbstractWWAResource extends
|
|||
this.recordsToLoad = new ArrayList<AbstractWarningRecord>();
|
||||
}
|
||||
|
||||
protected final WarningRecordComparator comparator = new WarningRecordComparator();
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
|
|
|
@ -236,6 +236,8 @@ public abstract class AbstractWarningResource extends AbstractWWAResource
|
|||
|
||||
protected Date timeAltered;
|
||||
|
||||
protected Date frameAltered;
|
||||
|
||||
/**
|
||||
* was the alter a partial cancel? if it was then a matching CON should
|
||||
* be processed and added
|
||||
|
@ -364,7 +366,7 @@ public abstract class AbstractWarningResource extends AbstractWWAResource
|
|||
int frameIdx = framesInfo.getFrameIndex();
|
||||
DataTime[] frameTimes = framesInfo.getFrameTimes();
|
||||
if (frameIdx < 0 || frameIdx >= frameTimes.length)
|
||||
return "NO DATA";
|
||||
return "NO DATA";
|
||||
DataTime time = frameTimes[frameIdx];
|
||||
|
||||
TimeRange framePeriod = null;
|
||||
|
@ -580,9 +582,9 @@ public abstract class AbstractWarningResource extends AbstractWWAResource
|
|||
// DR14992: reverse the textToPrint array to plot the strings in correct order
|
||||
String [] textToPrintReversed = new String[textToPrint.length];
|
||||
for(int i = 0; i < textToPrint.length; i++) {
|
||||
textToPrintReversed[i] = textToPrint[textToPrint.length
|
||||
- i - 1];
|
||||
}
|
||||
textToPrintReversed[i] = textToPrint[textToPrint.length
|
||||
- i - 1];
|
||||
}
|
||||
|
||||
DrawableString params = new DrawableString(textToPrintReversed,
|
||||
color);
|
||||
|
@ -627,18 +629,19 @@ public abstract class AbstractWarningResource extends AbstractWWAResource
|
|||
|
||||
// check if the warning is cancelled
|
||||
WarningAction action = WarningAction.valueOf(entry.record.getAct());
|
||||
if (action == WarningAction.CAN
|
||||
&& refTime.equals(paintTime)) {
|
||||
if (action == WarningAction.CAN && refTime.equals(paintTime)) {
|
||||
return false;
|
||||
// If this entry has been altered/updated, display its pre-altered version
|
||||
// only in the frames prior to the time it was altered
|
||||
} else if (entry.altered){
|
||||
if (frameStart.getTime() >= refTime.getTime() &&
|
||||
frameStart.getTime() < (entry.timeAltered.getTime()))
|
||||
return true;
|
||||
if (frameStart.getTime() >= (entry.timeAltered.getTime()))
|
||||
return false;
|
||||
|
||||
// If this entry has been altered/updated, display its pre-altered
|
||||
// version
|
||||
// only in the frames prior to the time it was altered
|
||||
} else if (entry.altered) {
|
||||
if (frameStart.getTime() >= refTime.getTime()
|
||||
&& frameStart.getTime() < (entry.timeAltered.getTime())
|
||||
&& frameStart.getTime() < entry.frameAltered.getTime())
|
||||
return true;
|
||||
if (frameStart.getTime() >= (entry.timeAltered.getTime()))
|
||||
return false;
|
||||
|
||||
} else if (refTime.equals(paintTime)
|
||||
|| recordPeriod.contains(frameTime)
|
||||
|| (framePeriod.contains(centerTime) && (!lastFrame || !entry.altered))) {
|
||||
|
|
|
@ -3,11 +3,12 @@ package com.raytheon.viz.warnings.rsc;
|
|||
import java.util.Comparator;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.warning.AbstractWarningRecord;
|
||||
import com.raytheon.uf.common.dataplugin.warning.WarningRecord.WarningAction;
|
||||
|
||||
/**
|
||||
*
|
||||
* Sorts the WarningRecords by phenSig, ETN, starttime (descending order), then
|
||||
* action
|
||||
* Compares the WarningRecords by phenSig, ETN, action, then starttime
|
||||
* (descending order)
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
|
@ -24,6 +25,11 @@ import com.raytheon.uf.common.dataplugin.warning.AbstractWarningRecord;
|
|||
*/
|
||||
public class WarningRecordComparator implements
|
||||
Comparator<AbstractWarningRecord> {
|
||||
|
||||
/**
|
||||
* Compares the WarningRecords by phenSig, ETN, action, then starttime
|
||||
* (descending order)
|
||||
*/
|
||||
public int compare(AbstractWarningRecord wr1, AbstractWarningRecord wr2) {
|
||||
int rval = 0;
|
||||
|
||||
|
@ -33,10 +39,20 @@ public class WarningRecordComparator implements
|
|||
rval = Double.compare(Double.parseDouble(wr1.getEtn()),
|
||||
Double.parseDouble(wr2.getEtn()));
|
||||
if (rval == 0) {
|
||||
rval = -1 * wr1.getStartTime().compareTo(wr2.getStartTime());
|
||||
if (rval == 0) {
|
||||
if (wr1.getAct().equals(wr2.getAct())) {
|
||||
rval = 0;
|
||||
} else if (wr1.getAct().equals(WarningAction.NEW.toString())) {
|
||||
rval = -1;
|
||||
} else if (wr2.getAct().equals(WarningAction.NEW.toString())) {
|
||||
rval = 1;
|
||||
} else {
|
||||
rval = wr1.getAct().compareTo(wr2.getAct());
|
||||
}
|
||||
|
||||
if (rval == 0) {
|
||||
rval = -1
|
||||
* wr1.getStartTime().compareTo(wr2.getStartTime());
|
||||
}
|
||||
}
|
||||
}
|
||||
return rval;
|
||||
|
|
|
@ -20,7 +20,9 @@
|
|||
|
||||
package com.raytheon.viz.warnings.rsc;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.PluginDataObject;
|
||||
|
@ -35,6 +37,7 @@ import com.raytheon.uf.common.time.DataTime;
|
|||
import com.raytheon.uf.viz.core.IGraphicsTarget;
|
||||
import com.raytheon.uf.viz.core.catalog.LayerProperty;
|
||||
import com.raytheon.uf.viz.core.datastructure.DataCubeContainer;
|
||||
import com.raytheon.uf.viz.core.drawables.IDescriptor.FramesInfo;
|
||||
import com.raytheon.uf.viz.core.drawables.IWireframeShape;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
import com.raytheon.uf.viz.core.rsc.LoadProperties;
|
||||
|
@ -53,10 +56,10 @@ import com.vividsolutions.jts.geom.Geometry;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Sep 1, 2010 jsanchez Initial creation
|
||||
* Aug 22, 2011 10631 njensen Major refactor
|
||||
* May 3, 2012 DR 14741 porricel Stop setting end time of orig.
|
||||
* May 3, 2012 DR 14741 porricel Stop setting end time of orig.
|
||||
* warning to start time of update.
|
||||
* Jun 04, 2012 DR14992 mgamazaychikov Fix the problem with plotting expiration time for
|
||||
* NEW warning when CAN warning is issued
|
||||
* NEW warning when CAN warning is issued
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -78,6 +81,8 @@ public class WarningsResource extends AbstractWarningResource {
|
|||
@Override
|
||||
protected synchronized void updateDisplay(IGraphicsTarget target) {
|
||||
if (!this.recordsToLoad.isEmpty()) {
|
||||
FramesInfo info = getDescriptor().getFramesInfo();
|
||||
DataTime[] frames = info.getFrameTimes();
|
||||
for (AbstractWarningRecord warnrec : recordsToLoad) {
|
||||
WarningAction act = WarningAction.valueOf(warnrec.getAct());
|
||||
if (act == WarningAction.CON || act == WarningAction.CAN
|
||||
|
@ -93,19 +98,26 @@ public class WarningsResource extends AbstractWarningResource {
|
|||
|
||||
if (!entry.altered) {
|
||||
// if it's a con, can, exp, or ext mark the
|
||||
// original one as altered
|
||||
// original one as altered
|
||||
entry.altered = true;
|
||||
//make note of alteration time without
|
||||
//changing end time
|
||||
entry.timeAltered = warnrec.getStartTime().getTime();
|
||||
|
||||
//if cancellation, set end time to start time
|
||||
//of this action
|
||||
|
||||
// DR14992: fix the problem with plotting expiration time for
|
||||
// NEW warning when CAN warning is issued
|
||||
if(act == WarningAction.CAN &&
|
||||
WarningAction.valueOf(entry.record.getAct()) == WarningAction.CAN) {
|
||||
// make note of alteration time without
|
||||
// changing end time
|
||||
entry.timeAltered = warnrec.getStartTime()
|
||||
.getTime();
|
||||
// prevents the original entry and the modified
|
||||
// entry to be displayed in the same frame
|
||||
entry.frameAltered = frames[info
|
||||
.getFrameIndex()].getRefTime();
|
||||
|
||||
// if cancellation, set end time to start time
|
||||
// of this action
|
||||
|
||||
// DR14992: fix the problem with plotting
|
||||
// expiration time for
|
||||
// NEW warning when CAN warning is issued
|
||||
if (act == WarningAction.CAN
|
||||
&& WarningAction.valueOf(entry.record
|
||||
.getAct()) == WarningAction.CAN) {
|
||||
entry.record.setEndTime((Calendar) warnrec
|
||||
.getStartTime().clone());
|
||||
}
|
||||
|
@ -235,7 +247,22 @@ public class WarningsResource extends AbstractWarningResource {
|
|||
arr[i] = (PluginDataObject) o;
|
||||
i++;
|
||||
}
|
||||
addRecord(arr);
|
||||
addRecord(sort(arr));
|
||||
}
|
||||
|
||||
private PluginDataObject[] sort(PluginDataObject[] pdos) {
|
||||
ArrayList<AbstractWarningRecord> sortedWarnings = new ArrayList<AbstractWarningRecord>();
|
||||
for (Object o : pdos) {
|
||||
if (((PluginDataObject) o) instanceof AbstractWarningRecord) {
|
||||
AbstractWarningRecord record = (AbstractWarningRecord) o;
|
||||
sortedWarnings.add(record);
|
||||
}
|
||||
}
|
||||
|
||||
/* Sorts by phensig, etn, starttime (descending), act */
|
||||
Collections.sort(sortedWarnings, comparator);
|
||||
return sortedWarnings.toArray(new AbstractWarningRecord[sortedWarnings
|
||||
.size()]);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -42,8 +42,6 @@ public class WatchesResource extends AbstractWatchesResource {
|
|||
|
||||
private Map<String, WeakReference<Geometry>> geometryMap = new HashMap<String, WeakReference<Geometry>>();
|
||||
|
||||
private final WarningRecordComparator comparator = new WarningRecordComparator();
|
||||
|
||||
public WatchesResource(WWAResourceData data, LoadProperties props) {
|
||||
super(data, props);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue