Issue #883 Sorted warning records and prevented altered entries to be in

the same frame as new entries.


Former-commit-id: 457cbcdf95 [formerly 4f2d6630c1] [formerly 6507a97665] [formerly fa7795d17f [formerly 6507a97665 [formerly 5c8c0783c8e054792ac38b4487188495dd0b0319]]]
Former-commit-id: fa7795d17f
Former-commit-id: faff7eb8279d6805bdc05f6ec705924a3bd4c05e [formerly 7ad6329fe0]
Former-commit-id: 3952dfc7ac
This commit is contained in:
Jonathan Sanchez 2012-08-07 14:50:15 -05:00 committed by Steve Harris
parent 4235ad69c1
commit 46b7a35134
5 changed files with 83 additions and 37 deletions

View file

@ -31,7 +31,7 @@ import com.raytheon.viz.warnings.DateUtil;
* Aug 5, 2011 njensen Refactored maps * Aug 5, 2011 njensen Refactored maps
* Aug 22, 2011 10631 njensen Major refactor * Aug 22, 2011 10631 njensen Major refactor
* May 31, 2012 DR14992 mgamazaychikov Changed the order of strings in the * 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 * Jun 04, 2012 DR14992 mgamazaychikov Reversed the previous changes
* *
* </pre> * </pre>
@ -62,6 +62,8 @@ public abstract class AbstractWWAResource extends
this.recordsToLoad = new ArrayList<AbstractWarningRecord>(); this.recordsToLoad = new ArrayList<AbstractWarningRecord>();
} }
protected final WarningRecordComparator comparator = new WarningRecordComparator();
/* /*
* (non-Javadoc) * (non-Javadoc)
* *

View file

@ -236,6 +236,8 @@ public abstract class AbstractWarningResource extends AbstractWWAResource
protected Date timeAltered; protected Date timeAltered;
protected Date frameAltered;
/** /**
* was the alter a partial cancel? if it was then a matching CON should * was the alter a partial cancel? if it was then a matching CON should
* be processed and added * be processed and added
@ -364,7 +366,7 @@ public abstract class AbstractWarningResource extends AbstractWWAResource
int frameIdx = framesInfo.getFrameIndex(); int frameIdx = framesInfo.getFrameIndex();
DataTime[] frameTimes = framesInfo.getFrameTimes(); DataTime[] frameTimes = framesInfo.getFrameTimes();
if (frameIdx < 0 || frameIdx >= frameTimes.length) if (frameIdx < 0 || frameIdx >= frameTimes.length)
return "NO DATA"; return "NO DATA";
DataTime time = frameTimes[frameIdx]; DataTime time = frameTimes[frameIdx];
TimeRange framePeriod = null; 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 // DR14992: reverse the textToPrint array to plot the strings in correct order
String [] textToPrintReversed = new String[textToPrint.length]; String [] textToPrintReversed = new String[textToPrint.length];
for(int i = 0; i < textToPrint.length; i++) { for(int i = 0; i < textToPrint.length; i++) {
textToPrintReversed[i] = textToPrint[textToPrint.length textToPrintReversed[i] = textToPrint[textToPrint.length
- i - 1]; - i - 1];
} }
DrawableString params = new DrawableString(textToPrintReversed, DrawableString params = new DrawableString(textToPrintReversed,
color); color);
@ -627,18 +629,19 @@ public abstract class AbstractWarningResource extends AbstractWWAResource
// check if the warning is cancelled // check if the warning is cancelled
WarningAction action = WarningAction.valueOf(entry.record.getAct()); WarningAction action = WarningAction.valueOf(entry.record.getAct());
if (action == WarningAction.CAN if (action == WarningAction.CAN && refTime.equals(paintTime)) {
&& refTime.equals(paintTime)) {
return false; return false;
// If this entry has been altered/updated, display its pre-altered version // If this entry has been altered/updated, display its pre-altered
// only in the frames prior to the time it was altered // version
} else if (entry.altered){ // only in the frames prior to the time it was altered
if (frameStart.getTime() >= refTime.getTime() && } else if (entry.altered) {
frameStart.getTime() < (entry.timeAltered.getTime())) if (frameStart.getTime() >= refTime.getTime()
return true; && frameStart.getTime() < (entry.timeAltered.getTime())
if (frameStart.getTime() >= (entry.timeAltered.getTime())) && frameStart.getTime() < entry.frameAltered.getTime())
return false; return true;
if (frameStart.getTime() >= (entry.timeAltered.getTime()))
return false;
} else if (refTime.equals(paintTime) } else if (refTime.equals(paintTime)
|| recordPeriod.contains(frameTime) || recordPeriod.contains(frameTime)
|| (framePeriod.contains(centerTime) && (!lastFrame || !entry.altered))) { || (framePeriod.contains(centerTime) && (!lastFrame || !entry.altered))) {

View file

@ -3,11 +3,12 @@ package com.raytheon.viz.warnings.rsc;
import java.util.Comparator; import java.util.Comparator;
import com.raytheon.uf.common.dataplugin.warning.AbstractWarningRecord; 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 * Compares the WarningRecords by phenSig, ETN, action, then starttime
* action * (descending order)
* *
* <pre> * <pre>
* *
@ -24,6 +25,11 @@ import com.raytheon.uf.common.dataplugin.warning.AbstractWarningRecord;
*/ */
public class WarningRecordComparator implements public class WarningRecordComparator implements
Comparator<AbstractWarningRecord> { Comparator<AbstractWarningRecord> {
/**
* Compares the WarningRecords by phenSig, ETN, action, then starttime
* (descending order)
*/
public int compare(AbstractWarningRecord wr1, AbstractWarningRecord wr2) { public int compare(AbstractWarningRecord wr1, AbstractWarningRecord wr2) {
int rval = 0; int rval = 0;
@ -33,10 +39,20 @@ public class WarningRecordComparator implements
rval = Double.compare(Double.parseDouble(wr1.getEtn()), rval = Double.compare(Double.parseDouble(wr1.getEtn()),
Double.parseDouble(wr2.getEtn())); Double.parseDouble(wr2.getEtn()));
if (rval == 0) { if (rval == 0) {
rval = -1 * wr1.getStartTime().compareTo(wr2.getStartTime()); if (wr1.getAct().equals(wr2.getAct())) {
if (rval == 0) { 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()); rval = wr1.getAct().compareTo(wr2.getAct());
} }
if (rval == 0) {
rval = -1
* wr1.getStartTime().compareTo(wr2.getStartTime());
}
} }
} }
return rval; return rval;

View file

@ -20,7 +20,9 @@
package com.raytheon.viz.warnings.rsc; package com.raytheon.viz.warnings.rsc;
import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.Collections;
import java.util.Map; import java.util.Map;
import com.raytheon.uf.common.dataplugin.PluginDataObject; 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.IGraphicsTarget;
import com.raytheon.uf.viz.core.catalog.LayerProperty; import com.raytheon.uf.viz.core.catalog.LayerProperty;
import com.raytheon.uf.viz.core.datastructure.DataCubeContainer; 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.drawables.IWireframeShape;
import com.raytheon.uf.viz.core.exception.VizException; import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.rsc.LoadProperties; import com.raytheon.uf.viz.core.rsc.LoadProperties;
@ -53,10 +56,10 @@ import com.vividsolutions.jts.geom.Geometry;
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Sep 1, 2010 jsanchez Initial creation * Sep 1, 2010 jsanchez Initial creation
* Aug 22, 2011 10631 njensen Major refactor * 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. * warning to start time of update.
* Jun 04, 2012 DR14992 mgamazaychikov Fix the problem with plotting expiration time for * 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> * </pre>
* *
@ -78,6 +81,8 @@ public class WarningsResource extends AbstractWarningResource {
@Override @Override
protected synchronized void updateDisplay(IGraphicsTarget target) { protected synchronized void updateDisplay(IGraphicsTarget target) {
if (!this.recordsToLoad.isEmpty()) { if (!this.recordsToLoad.isEmpty()) {
FramesInfo info = getDescriptor().getFramesInfo();
DataTime[] frames = info.getFrameTimes();
for (AbstractWarningRecord warnrec : recordsToLoad) { for (AbstractWarningRecord warnrec : recordsToLoad) {
WarningAction act = WarningAction.valueOf(warnrec.getAct()); WarningAction act = WarningAction.valueOf(warnrec.getAct());
if (act == WarningAction.CON || act == WarningAction.CAN if (act == WarningAction.CON || act == WarningAction.CAN
@ -93,19 +98,26 @@ public class WarningsResource extends AbstractWarningResource {
if (!entry.altered) { if (!entry.altered) {
// if it's a con, can, exp, or ext mark the // if it's a con, can, exp, or ext mark the
// original one as altered // original one as altered
entry.altered = true; entry.altered = true;
//make note of alteration time without // make note of alteration time without
//changing end time // changing end time
entry.timeAltered = warnrec.getStartTime().getTime(); entry.timeAltered = warnrec.getStartTime()
.getTime();
//if cancellation, set end time to start time // prevents the original entry and the modified
//of this action // entry to be displayed in the same frame
entry.frameAltered = frames[info
// DR14992: fix the problem with plotting expiration time for .getFrameIndex()].getRefTime();
// NEW warning when CAN warning is issued
if(act == WarningAction.CAN && // if cancellation, set end time to start time
WarningAction.valueOf(entry.record.getAct()) == WarningAction.CAN) { // 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 entry.record.setEndTime((Calendar) warnrec
.getStartTime().clone()); .getStartTime().clone());
} }
@ -235,7 +247,22 @@ public class WarningsResource extends AbstractWarningResource {
arr[i] = (PluginDataObject) o; arr[i] = (PluginDataObject) o;
i++; 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()]);
} }
} }

View file

@ -42,8 +42,6 @@ public class WatchesResource extends AbstractWatchesResource {
private Map<String, WeakReference<Geometry>> geometryMap = new HashMap<String, WeakReference<Geometry>>(); private Map<String, WeakReference<Geometry>> geometryMap = new HashMap<String, WeakReference<Geometry>>();
private final WarningRecordComparator comparator = new WarningRecordComparator();
public WatchesResource(WWAResourceData data, LoadProperties props) { public WatchesResource(WWAResourceData data, LoadProperties props) {
super(data, props); super(data, props);
} }