VLab Issue #4079 - Add Magnetometer timeseries plot support from NCP

Change-Id: Ibd9f495908cbd0db40368207ddc1bea2ea09bdeb

Former-commit-id: 025f1d9436 [formerly 188a5f41da] [formerly 04e7a9e515 [formerly b99088dbb902db49f7eb7df720b5c2bdaa68bb3f]]
Former-commit-id: 04e7a9e515
Former-commit-id: e06cbc844c
This commit is contained in:
Stephen Gilbert 2014-08-05 16:29:21 -04:00
parent 98d91e9a48
commit 71b9932026
71 changed files with 16163 additions and 7132 deletions

View file

@ -314,13 +314,6 @@
version="0.0.0"
unpack="false"/>
<plugin
id="gov.noaa.nws.ncep.viz.timeseries"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="gov.noaa.nws.ncep.viz.ui.remotescript"
download-size="0"
@ -328,4 +321,11 @@
version="0.0.0"
unpack="false"/>
<plugin
id="gov.noaa.nws.ncep.viz.rsc.timeseries"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
</feature>

View file

@ -9,7 +9,6 @@ import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -39,7 +38,8 @@ import com.raytheon.uf.viz.core.exception.VizException;
/**
* Read and create PredefinedAreas from localization. Also
*
* TODO : add methods to save, delete and edit PredefinedAreas at the USER localization level.
* TODO : add methods to save, delete and edit PredefinedAreas at the USER
* localization level.
*
* <pre>
* SOFTWARE HISTORY
@ -68,15 +68,16 @@ public class PredefinedAreaFactory implements INcAreaProviderFactory {
}
@Override
public void initialize( String srcName, String dataLoc, String configData ) throws VizException {
public void initialize(String srcName, String dataLoc, String configData)
throws VizException {
// should have already been created.
AreaSource.createAreaSource(srcName);
try {
readPredefinedAreas();
}
catch ( VizException v ) {
badAreas.add( v ); // should treat this as a real exception instead of just an
} catch (VizException v) {
badAreas.add(v); // should treat this as a real exception instead of
// just an
// invalid area file.
}
}
@ -92,45 +93,49 @@ public class PredefinedAreaFactory implements INcAreaProviderFactory {
if (predefinedAreasMap == null) {
predefinedAreasMap = new HashMap<String, LocalizationFile>();
Map<String,LocalizationFile> areaLocFileMap = NcPathManager.getInstance().listFiles(
NcPathConstants.PREDEFINED_AREAS_DIR, new String[]{".xml"}, false, true);
Map<String, LocalizationFile> areaLocFileMap = NcPathManager
.getInstance().listFiles(
NcPathConstants.PREDEFINED_AREAS_DIR,
new String[] { ".xml" }, false, true);
if (areaLocFileMap.isEmpty()) {
throw new VizException(
"No Predefined Area Files found under: "+NcPathConstants.PREDEFINED_AREAS_DIR);
throw new VizException("No Predefined Area Files found under: "
+ NcPathConstants.PREDEFINED_AREAS_DIR);
}
boolean dfltFound = false;
// to a validity check by unmarshalling each of the files.
// Also replace the localizationName (with the PredefinedArea directory prefix
// Also replace the localizationName (with the PredefinedArea
// directory prefix
// with the name of the area.
for (LocalizationFile locF : areaLocFileMap.values()) {
try {
PredefinedArea area = getPredefinedArea(locF);
if( area.getAreaName().equals( NcDisplayType.NMAP_DISPLAY.getDefaultMap() ) ) {
if (area.getAreaName().equals(
NcDisplayType.NMAP_DISPLAY.getDefaultMap())) {
dfltFound = true;
}
locF.addFileUpdatedObserver(areaFileObserver);
if (predefinedAreasMap.containsKey(area.getAreaName())) {
badAreas.add(
new VizException( "Duplicate Area Name found for :"+ area.getAreaName() ) );
}
else {
badAreas.add(new VizException(
"Duplicate Area Name found for :"
+ area.getAreaName()));
} else {
predefinedAreasMap.put(area.getAreaName(), locF);
}
}
catch( VizException ve ) {
} catch (VizException ve) {
badAreas.add(ve);
}
}
if (!dfltFound) {
System.out.println("Could not find valid Default Predefined Area "+
NcDisplayType.NMAP_DISPLAY.getDefaultMap() );
System.out
.println("Could not find valid Default Predefined Area "
+ NcDisplayType.NMAP_DISPLAY.getDefaultMap());
}
}
}
@ -145,18 +150,24 @@ public class PredefinedAreaFactory implements INcAreaProviderFactory {
return areaNames;
}
// make sure that the default map is first and maps defined for the main menu are next and then all
// make sure that the default map is first and maps defined for the main
// menu are next and then all
// the rest.
//
public static String[] getAllAvailAreasForDisplayType( /*NcDisplayType dispType*/ ) {
public static String[] getAllAvailAreasForDisplayType( /*
* NcDisplayType
* dispType
*/) {
// if dispType is null then return all types
//
if (predefinedAreasMap == null) {
System.out.println("getAllAvailPredefinedAreas() called before Areas have been read in.");
System.out
.println("getAllAvailPredefinedAreas() called before Areas have been read in.");
return new String[0];
}
List<String> areaNamesList = new ArrayList<String>( predefinedAreasMap.keySet() );
List<String> areaNamesList = new ArrayList<String>(
predefinedAreasMap.keySet());
String areaNamesArray[] = areaNamesList.toArray(new String[0]);
return areaNamesArray;
@ -182,8 +193,10 @@ public class PredefinedAreaFactory implements INcAreaProviderFactory {
// return 1;
// }
//
// int a1menuIndx = (areaMenuNames == null ? 999 : (areaMenuNames.contains(a1) ? areaMenuNames.indexOf(a1) : 999) );
// int a2menuIndx = (areaMenuNames == null ? 999 : (areaMenuNames.contains(a2) ? areaMenuNames.indexOf(a2) : 999) );
// int a1menuIndx = (areaMenuNames == null ? 999 :
// (areaMenuNames.contains(a1) ? areaMenuNames.indexOf(a1) : 999) );
// int a2menuIndx = (areaMenuNames == null ? 999 :
// (areaMenuNames.contains(a2) ? areaMenuNames.indexOf(a2) : 999) );
//
// if( a1menuIndx == a2menuIndx ) { // ie both -1
// return a1.compareTo( a2 );
@ -193,10 +206,12 @@ public class PredefinedAreaFactory implements INcAreaProviderFactory {
// }
// // it might be nice create a class specifically to store the predefined
// // area but for now this will just be the Display (we need the zoomLevel and
// // area but for now this will just be the Display (we need the zoomLevel
// and
// // mapCenter as well as the gridGeometry)
// //
public static PredefinedArea getDefaultPredefinedAreaForDisplayType( NcDisplayType dt ) throws VizException {
public static PredefinedArea getDefaultPredefinedAreaForDisplayType(
NcDisplayType dt) throws VizException {
switch (dt) {
case NMAP_DISPLAY:
return getPredefinedArea(dt.getDefaultMap());
@ -204,30 +219,37 @@ public class PredefinedAreaFactory implements INcAreaProviderFactory {
return createDefaultNonMapArea(dt);
case SOLAR_DISPLAY:
return createDefaultNonMapArea(dt);
case GRAPH_DISPLAY:
return createDefaultNonMapArea(dt);
}
return null;
}
public static PredefinedArea getPredefinedArea( String areaName ) throws VizException {
public static PredefinedArea getPredefinedArea(String areaName)
throws VizException {
if (areaName.equals(NcDisplayType.NTRANS_DISPLAY.getDefaultMap())) {
return createDefaultNonMapArea(NcDisplayType.NTRANS_DISPLAY);
}
else if( areaName.equals( NcDisplayType.SOLAR_DISPLAY.getDefaultMap() ) ) {
} else if (areaName.equals(NcDisplayType.SOLAR_DISPLAY.getDefaultMap())) {
return createDefaultNonMapArea(NcDisplayType.SOLAR_DISPLAY);
} else if (areaName.equals(NcDisplayType.GRAPH_DISPLAY.getDefaultMap())) {
return createDefaultNonMapArea(NcDisplayType.GRAPH_DISPLAY);
}
// String key = NcPathConstants.PREDEFINED_AREAS_DIR + File.separator + areaName +".xml";
// String key = NcPathConstants.PREDEFINED_AREAS_DIR + File.separator +
// areaName +".xml";
String key = areaName;
if (!predefinedAreasMap.containsKey(key)) {
throw new VizException("Predefined Area : "+ areaName + ", is not in the Areas Map.");
throw new VizException("Predefined Area : " + areaName
+ ", is not in the Areas Map.");
}
return getPredefinedArea(predefinedAreasMap.get(key));
}
public static PredefinedArea getPredefinedArea( LocalizationFile lFile ) throws VizException {
public static PredefinedArea getPredefinedArea(LocalizationFile lFile)
throws VizException {
try {
PredefinedArea pa = SerializationUtil.jaxbUnmarshalFromXmlFile(
PredefinedArea.class, lFile.getFile());
@ -247,7 +269,8 @@ public class PredefinedAreaFactory implements INcAreaProviderFactory {
}
public static PredefinedArea clonePredefinedArea( PredefinedArea pArea ) throws VizException {
public static PredefinedArea clonePredefinedArea(PredefinedArea pArea)
throws VizException {
try {
File tempRbdFile = File.createTempFile("tempArea-", ".xml");
@ -286,40 +309,42 @@ public class PredefinedAreaFactory implements INcAreaProviderFactory {
public static PredefinedArea createPredefinedArea(IGridGeometryProvider geom) {
if (geom == null) {
return null;
}
else if( geom instanceof PredefinedArea ) {
} else if (geom instanceof PredefinedArea) {
try {
return PredefinedAreaFactory.clonePredefinedArea( (PredefinedArea)geom );
return PredefinedAreaFactory
.clonePredefinedArea((PredefinedArea) geom);
} catch (VizException e) {
System.out.println("Error cloning PA:" + e.getMessage());
return null;
}
}
return createPredefinedArea(
new AreaName( geom.getSource(), geom.getProviderName() ), geom.getGridGeometry(),
geom.getMapCenter(), geom.getZoomLevel() );
new AreaName(geom.getSource(), geom.getProviderName()),
geom.getGridGeometry(), geom.getMapCenter(),
geom.getZoomLevel());
}
public static PredefinedArea createPredefinedArea(
AreaName aName, GeneralGridGeometry geom, double[] mapCntr, String zlvl ) {
PredefinedArea parea = new PredefinedArea( aName.getSource(), aName.getName(),
geom, mapCntr, zlvl, NcDisplayType.NMAP_DISPLAY );
public static PredefinedArea createPredefinedArea(AreaName aName,
GeneralGridGeometry geom, double[] mapCntr, String zlvl) {
PredefinedArea parea = new PredefinedArea(aName.getSource(),
aName.getName(), geom, mapCntr, zlvl,
NcDisplayType.NMAP_DISPLAY);
return parea;
}
public static PredefinedArea createDefaultNonMapArea( NcDisplayType dt, PixelExtent extent ) {
public static PredefinedArea createDefaultNonMapArea(NcDisplayType dt,
PixelExtent extent) {
GeneralEnvelope envelope = new GeneralEnvelope(2);
envelope.setRange(0, extent.getMinX(), extent.getMaxX());
envelope.setRange(1, extent.getMinY(), extent.getMaxY());
envelope.setCoordinateReferenceSystem(DefaultEngineeringCRS.CARTESIAN_2D);
GeneralGridGeometry geom = new GridGeometry2D(
new GeneralGridEnvelope(new int[] { 0, 0 }, new int[] {
(int) extent.getWidth(), (int) extent.getHeight() },
false), envelope);
GeneralGridGeometry geom = new GridGeometry2D(new GeneralGridEnvelope(
new int[] { 0, 0 }, new int[] { (int) extent.getWidth(),
(int) extent.getHeight() }, false), envelope);
return new PredefinedArea( AreaSource.PREDEFINED_AREA, dt.getDefaultMap(),
geom, new double[]{500,500}, "1.0", dt );
return new PredefinedArea(AreaSource.PREDEFINED_AREA,
dt.getDefaultMap(), geom, new double[] { 500, 500 }, "1.0", dt);
}
private static ILocalizationFileObserver areaFileObserver = new ILocalizationFileObserver() {
@ -330,12 +355,14 @@ public class PredefinedAreaFactory implements INcAreaProviderFactory {
}
// first need to remove the entry for the updated file from the
// map. Do it this way to best handle the case when a user changes the
// map. Do it this way to best handle the case when a user changes
// the
// area name in an existing file.
//
String keyToRemove = null;
for( Entry<String,LocalizationFile> areaEntry : predefinedAreasMap.entrySet() ) {
for (Entry<String, LocalizationFile> areaEntry : predefinedAreasMap
.entrySet()) {
LocalizationFile lf = areaEntry.getValue();
// ?? check the context too?
@ -346,63 +373,74 @@ public class PredefinedAreaFactory implements INcAreaProviderFactory {
}
}
try { synchronized ( predefinedAreasMap ) {
try {
synchronized (predefinedAreasMap) {
if (keyToRemove != null) {
predefinedAreasMap.remove(keyToRemove);
}
else { /// ????
System.out.println("sanity check: Area fileUpated(): couldn't find locFile name in the Area Map???");
} else { // / ????
System.out
.println("sanity check: Area fileUpated(): couldn't find locFile name in the Area Map???");
}
// if added or updated, update the loc file in the map.
// else if deleted then check for another version of the file and 'revert'
// else if deleted then check for another version of the
// file and 'revert'
LocalizationFile locFile;
PredefinedArea area;
if( fumsg.getChangeType() == FileChangeType.ADDED ||
fumsg.getChangeType() == FileChangeType.UPDATED ) {
if (fumsg.getChangeType() == FileChangeType.ADDED
|| fumsg.getChangeType() == FileChangeType.UPDATED) {
locFile = NcPathManager.getInstance().getLocalizationFile(
fumsg.getContext(), fumsg.getFileName() );
if( locFile != null ) {
area = getPredefinedArea( locFile );
// since the existing entry should have been removed, this means
// they have changed the name to a name that already exists.
if( predefinedAreasMap.containsKey( area.getAreaName() ) ) {
System.out.println("Area fileUpdated: area "+area.getAreaName() +
" is already defined in another LocalizationFile: "+
predefinedAreasMap.get( area.getAreaName() ).getName() );
} // else ?????
else {
locFile.addFileUpdatedObserver( areaFileObserver );
predefinedAreasMap.put( area.getAreaName(), locFile );
}
}
}
else if( fumsg.getChangeType() == FileChangeType.DELETED ) {
locFile = NcPathManager.getInstance().getStaticLocalizationFile(
locFile = NcPathManager.getInstance()
.getLocalizationFile(fumsg.getContext(),
fumsg.getFileName());
if (locFile != null) {
area = getPredefinedArea(locFile);
// shouldn't happen.
if( locFile.getContext().getLocalizationLevel() ==
LocalizationLevel.USER ) {
System.out.println("sanity check: loc file deleted but still found a user-level version???");
}
// since the existing entry should have been
// removed, this means
// they have changed the name to a name that already
// exists.
if (predefinedAreasMap.containsKey(area
.getAreaName())) {
System.out
.println("Area fileUpdated: area "
+ area.getAreaName()
+ " is already defined in another LocalizationFile: "
+ predefinedAreasMap.get(
area.getAreaName())
.getName());
} // else ?????
else {
locFile.addFileUpdatedObserver(areaFileObserver);
predefinedAreasMap.put( area.getAreaName(), locFile );
predefinedAreasMap.put(area.getAreaName(),
locFile);
}
}
} else if (fumsg.getChangeType() == FileChangeType.DELETED) {
locFile = NcPathManager.getInstance()
.getStaticLocalizationFile(fumsg.getFileName());
if (locFile != null) {
area = getPredefinedArea(locFile);
// shouldn't happen.
if (locFile.getContext().getLocalizationLevel() == LocalizationLevel.USER) {
System.out
.println("sanity check: loc file deleted but still found a user-level version???");
} else {
locFile.addFileUpdatedObserver(areaFileObserver);
predefinedAreasMap.put(area.getAreaName(),
locFile);
}
}
}
}
} catch (VizException e) {
System.out.println("Error Updateing Areas Map from Localization Update???");
System.out
.println("Error Updateing Areas Map from Localization Update???");
return;
}
}
@ -424,41 +462,47 @@ public class PredefinedAreaFactory implements INcAreaProviderFactory {
return badAreas;
}
public static PredefinedArea savePredefinedArea( IGridGeometryProvider geomProv,
String areaname, boolean overwrite ) throws VizException {
public static PredefinedArea savePredefinedArea(
IGridGeometryProvider geomProv, String areaname, boolean overwrite)
throws VizException {
LocalizationFile lfile = predefinedAreasMap.get(areaname);
boolean areaExists = (lfile != null);
if (!overwrite && areaExists) {
throw new VizException("A predefined area, "+areaname+", already exists");
throw new VizException("A predefined area, " + areaname
+ ", already exists");
}
PredefinedArea parea = PredefinedAreaFactory.createPredefinedArea( geomProv );
PredefinedArea parea = PredefinedAreaFactory
.createPredefinedArea(geomProv);
if (parea == null) {
throw new VizException( "Error creating PredefinedArea for: "+
geomProv.getSource()+"/"+geomProv.getProviderName() );
throw new VizException("Error creating PredefinedArea for: "
+ geomProv.getSource() + "/" + geomProv.getProviderName());
}
AreaName pareaName = new AreaName(AreaSource.PREDEFINED_AREA, areaname);
parea.setAreaName(areaname);
parea.setAreaSource(AreaSource.PREDEFINED_AREA.toString());
if (!areaExists) {
LocalizationContext usrCntxt = NcPathManager.getInstance().getContext(
LocalizationType.CAVE_STATIC, LocalizationLevel.USER );
String lname = NcPathConstants.PREDEFINED_AREAS_DIR+File.separator+areaname+".xml";
LocalizationContext usrCntxt = NcPathManager.getInstance()
.getContext(LocalizationType.CAVE_STATIC,
LocalizationLevel.USER);
String lname = NcPathConstants.PREDEFINED_AREAS_DIR
+ File.separator + areaname + ".xml";
lfile = NcPathManager.getInstance().getLocalizationFile( usrCntxt, lname );
lfile = NcPathManager.getInstance().getLocalizationFile(usrCntxt,
lname);
if (lfile == null) {
throw new VizException("Error saving Predefined Area, "+areaname+
": error creatinge localization File.");
throw new VizException("Error saving Predefined Area, "
+ areaname + ": error creatinge localization File.");
}
}
try {
SerializationUtil.jaxbMarshalToXmlFile( parea,
lfile.getFile().getAbsolutePath() );
SerializationUtil.jaxbMarshalToXmlFile(parea, lfile.getFile()
.getAbsolutePath());
lfile.save();
if (!areaExists) {
@ -467,14 +511,12 @@ public class PredefinedAreaFactory implements INcAreaProviderFactory {
}
return parea;
}
catch (LocalizationOpFailedException e) {
throw new VizException("Error saving Predefined Area, "+areaname+
": "+e.getMessage() );
}
catch (SerializationException e) {
throw new VizException("Error saving Predefined Area, "+areaname+
": "+e.getMessage() );
} catch (LocalizationOpFailedException e) {
throw new VizException("Error saving Predefined Area, " + areaname
+ ": " + e.getMessage());
} catch (SerializationException e) {
throw new VizException("Error saving Predefined Area, " + areaname
+ ": " + e.getMessage());
}
}
// @Override

View file

@ -7,7 +7,6 @@ import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
/**
*
* <pre>
@ -21,47 +20,49 @@ import javax.xml.bind.annotation.XmlRootElement;
* @author ghull
* @version 1
*/
// an RBD must be one of these display types and all resources in the RBD must be compatible
// an RBD must be one of these display types and all resources in the RBD must
// be compatible
// with the display type.
@XmlRootElement
@XmlAccessorType(XmlAccessType.NONE)
public enum NcDisplayType {
// could make this a class and populate from an extension point.
NMAP_DISPLAY( "NC-MAP",
// the NcPaneManager knows the display type handles differences appropriately
"gov.noaa.nws.ncep.viz.ui.display.NCPaneManager",
"BasicWX_US",
"OVERLAY/GeoPolitical/default",
true),
NTRANS_DISPLAY( "NTRANS",
"gov.noaa.nws.ncep.viz.ui.display.NCPaneManager",
"DefaultCanvas",
"",
true),
SOLAR_DISPLAY( "SOLAR",
"gov.noaa.nws.ncep.viz.ui.display.NCPaneManager",
"DefaultCanvas",
"",
true),
NMAP_DISPLAY(
"NC-MAP",
// the NcPaneManager knows the display type handles differences
// appropriately
"gov.noaa.nws.ncep.viz.ui.display.NCPaneManager", "BasicWX_US",
"OVERLAY/GeoPolitical/default", true),
NTRANS_DISPLAY("NTRANS", "gov.noaa.nws.ncep.viz.ui.display.NCPaneManager",
"DefaultCanvas", "", true),
SOLAR_DISPLAY("SOLAR", "gov.noaa.nws.ncep.viz.ui.display.NCPaneManager",
"DefaultCanvas", "", true),
// CURRENTLY NOT USED,
NSHARP_DISPLAY("NSHARP",
"gov.noaa.nws.ncep.ui.nsharp.display.NcNsharpPaneManager",
"BasicWX_US",
"OVERLAY/GeoPolitical/default",
false );
"BasicWX_US", "OVERLAY/GeoPolitical/default", false),
GRAPH_DISPLAY("GRAPH", "gov.noaa.nws.ncep.viz.ui.display.NCPaneManager",
"DefaultCanvas", "", true);
// NC_TIME_SERIES_DISPLAY,
// NC_CROSS_SECTION_DISPLAY;
private String dispType;
private String paneManager;
private String defaultArea; // ie the gridGeom/CRS, zoomlevel, mapcenter.
private String baseResource; // if applicable, null if not
private Boolean isSavable; // can this be saved to an rbd.
private NcDisplayType( String dtstr, String pMngr, String area, String baseOvrly, Boolean canSave ) {
private NcDisplayType(String dtstr, String pMngr, String area,
String baseOvrly, Boolean canSave) {
dispType = dtstr;
paneManager = pMngr;
defaultArea = area;

View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<AttributeSetGroup xmlns:ns2="group" xmlns:ns3="http://www.example.org/productType">
<resource>GEOMAG</resource>
<attrSetGroupName>DIRECT</attrSetGroupName>
<attrSetNames>H_Direct,D_Direct,HQdc_Direct,DQdc_Direct</attrSetNames>
</AttributeSetGroup>

View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<AttributeSetGroup xmlns:ns2="group" xmlns:ns3="http://www.example.org/productType">
<resource>GEOMAG</resource>
<attrSetGroupName>DOMSAT</attrSetGroupName>
<attrSetNames>H_Domsat,D_Domsat,HQdc_Domsat,DQdc_Domsat</attrSetNames>
</AttributeSetGroup>

View file

@ -0,0 +1,6 @@
sourceId=101
yAxesData=DQdc
dataColor=light blue
xAxesTitle=Time (hr)
yAxesTitle=DQdc (nT)
yDescription=Baseline

View file

@ -0,0 +1,6 @@
sourceId=103
yAxesData=DQdc
dataColor=light blue
xAxesTitle=Time (hr)
yAxesTitle=DQdc (nT)
yDescription=Baseline

View file

@ -0,0 +1,6 @@
sourceId=101
yAxesData=D
dataColor=dodger blue
xAxesTitle=Time (hr)
yAxesTitle=D (nT)
yDescription=Baseline

View file

@ -0,0 +1,6 @@
sourceId=103
yAxesData=D
dataColor=dodger blue
xAxesTitle=Time (hr)
yAxesTitle=D (nT)
yDescription=Baseline

View file

@ -0,0 +1,6 @@
sourceId=102
yAxesData=D
dataColor=dodger blue
xAxesTitle=Time (hr)
yAxesTitle=D (nT)
yDescription=Baseline

View file

@ -0,0 +1,6 @@
sourceId=101
yAxesData=HQdc
dataColor=pink
xAxesTitle=Time (hr)
yAxesTitle=HQdc (nT)
yDescription=Baseline

View file

@ -0,0 +1,6 @@
sourceId=103
yAxesData=HQdc
dataColor=pink
xAxesTitle=Time (hr)
yAxesTitle=HQdc (nT)
yDescription=Baseline

View file

@ -0,0 +1,6 @@
sourceId=101
yAxesData=H
dataColor=red
xAxesTitle=Time (hr)
yAxesTitle=H (nT)
yDescription=Baseline

View file

@ -0,0 +1,6 @@
sourceId=103
yAxesData=H
dataColor=red
xAxesTitle=Time (hr)
yAxesTitle=H (nT)
yDescription=Baseline

View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<AttributeSetGroup xmlns:ns2="group" xmlns:ns3="http://www.example.org/productType">
<resource>GEOMAG</resource>
<attrSetGroupName>MAGWORM</attrSetGroupName>
<attrSetNames>H_Magworm,D_Magworm,HQdc_Magworm,DQdc_Magworm</attrSetNames>
</AttributeSetGroup>

View file

@ -1446,4 +1446,7 @@
<ResourceDefinitionFilter isEnabled="true" rscDefnName="SOLARFLUX">
<filters>Forecast,SWPC</filters>
</ResourceDefinitionFilter>
<ResourceDefinitionFilter isEnabled="true" rscDefnName="GEOMAG">
<filters>Forecast,SWPC</filters>
</ResourceDefinitionFilter>
</ResourceDefinitionFilters>

View file

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ResourceDefinition xmlns:ns2="group" xmlns:ns3="http://www.example.org/productType">
<resourceDefnName>GEOMAG</resourceDefnName>
<inventoryEnabled>false</inventoryEnabled>
<resourceCategory>TIMESERIES</resourceCategory>
<resourceParameters>
pluginName=geomag
reportType=GEOMAG
</resourceParameters>
<rscImplementation>GeoMag</rscImplementation>
<subTypeGenerator></subTypeGenerator>
<rscTypeGenerator>stationCode</rscTypeGenerator>
<timeMatchMethod>EXACT</timeMatchMethod>
<dfltGraphRange>12</dfltGraphRange>
<dfltHourSnap>3</dfltHourSnap>
<frameSpan>1</frameSpan>
<timelineGenMethod>USE_DATA_TIMES</timelineGenMethod>
<dfltFrameCount>1</dfltFrameCount>
<dfltTimeRange>24</dfltTimeRange>
<dfltGeogArea>BasicWX_US</dfltGeogArea>
</ResourceDefinition>

View file

@ -6,23 +6,22 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.raytheon.uf.common.localization.IPathManager;
import com.raytheon.uf.common.localization.LocalizationContext;
import com.raytheon.uf.common.localization.LocalizationFile;
import com.raytheon.uf.common.localization.PathManagerFactory;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
import com.raytheon.uf.common.localization.LocalizationFile;
import com.raytheon.uf.common.localization.PathManagerFactory;
import com.raytheon.uf.viz.core.localization.CAVELocalizationAdapter;
import com.raytheon.uf.viz.core.localization.LocalizationManager;
/**
* A Facade over the PathManager. This was initially created to create a pathMngr with
* a NatlCntrsLocalizationAdapter but now is just a convenience wrapper around the
* same PathManager as the rest of CAVE.
* A Facade over the PathManager. This was initially created to create a
* pathMngr with a NatlCntrsLocalizationAdapter but now is just a convenience
* wrapper around the same PathManager as the rest of CAVE.
*
Would it be ok/better to derive from PathManager directly and bypass the PathManagerFactory?
* Would it be ok/better to derive from PathManager directly and bypass the
* PathManagerFactory?
*
* <pre>
* SOFTWARE HISTORY
@ -51,7 +50,7 @@ import com.raytheon.uf.viz.core.localization.LocalizationManager;
* 04/10/2013 #958 qzhou Added SOLAR_IMG_STYLE_RULES
* 05/15/2013 #862 Greg Hull AreaMenus tbl to xml
* 11/15/2013 #1051 Greg Hull createDeskLevel() called from NmapCommon and triggered by spring.
*
* 06/18/2014 #1131 qzhou Added DFLT_GRAPH_RBD
* </pre>
*
* @author ghull
@ -60,9 +59,11 @@ import com.raytheon.uf.viz.core.localization.LocalizationManager;
public class NcPathManager {
private static NcPathManager ncPathMngr = null;
private static IPathManager pathMngr = null;
// we could instead read from the extension point to find the relative path for a 'type' of file.
// we could instead read from the extension point to find the relative path
// for a 'type' of file.
//
public static class NcPathConstants {
@ -72,122 +73,258 @@ public class NcPathManager {
public static final String NCEP_ROOT = "ncep" + File.separator;
// Note that these files are in STATIC_COMMON
public static final String NCINVENTORY_DEFNS_DIR = NCEP_ROOT + "NcInventoryDefinitions";
public static final String NCINVENTORY_DEFNS_DIR = NCEP_ROOT
+ "NcInventoryDefinitions";
// static directories.
public static final String SPFS_DIR = NCEP_ROOT + "SPFs"; // the Groups dir
public static final String RSC_TMPLTS_DIR = NCEP_ROOT + "resourceTemplates";
public static final String SPFS_DIR = NCEP_ROOT + "SPFs"; // the Groups
// dir
public static final String RSC_TMPLTS_DIR = NCEP_ROOT
+ "resourceTemplates";
public static final String RSC_DEFNS_DIR = NCEP_ROOT + "ResourceDefns";
public static final String ATTR_SET_GROUPS_DIR = NCEP_ROOT + "AttributeSetGroups";
public static final String PREDEFINED_AREAS_DIR= NCEP_ROOT + "PredefinedAreas";
public static final String ATTR_SET_GROUPS_DIR = NCEP_ROOT
+ "AttributeSetGroups";
public static final String PREDEFINED_AREAS_DIR = NCEP_ROOT
+ "PredefinedAreas";
public static final String COLORBARS_DIR = NCEP_ROOT + "ColorBars";
public static final String COLORMAPS_DIR = NCEP_ROOT + "ColorMaps";
public static final String STATIONS_DIR = NCEP_ROOT + "Stations";
public static final String LOGOS_DIR = NCEP_ROOT + "Logos";
public static final String CURSORS_DIR = NCEP_ROOT + "Cursors";
public static final String PLOT_MODELS_DIR = NCEP_ROOT + "PlotModels";
public static final String PLOT_PARAMETERS_DIR = PLOT_MODELS_DIR + File.separator+"PlotParameters";
public static final String FONT_FILES_DIR = NCEP_ROOT + "fontFiles" + File.separator ;
public static final String LOCATOR_SOURCE_DIR = NCEP_ROOT+"LocatorDataSources";
public static final String RESOURCE_FILTERS = RSC_DEFNS_DIR+ File.separator+"ResourceFilters.xml";
public static final String AREA_MENUS_FILE = PREDEFINED_AREAS_DIR + File.separator+
"menus"+ File.separator+"AreaMenus.xml";
public static final String PLOT_PARAMETERS_DIR = PLOT_MODELS_DIR
+ File.separator + "PlotParameters";
public static final String FONT_FILES_DIR = NCEP_ROOT + "fontFiles"
+ File.separator;
public static final String LOCATOR_SOURCE_DIR = NCEP_ROOT
+ "LocatorDataSources";
public static final String RESOURCE_FILTERS = RSC_DEFNS_DIR
+ File.separator + "ResourceFilters.xml";
public static final String AREA_MENUS_FILE = PREDEFINED_AREAS_DIR
+ File.separator + "menus" + File.separator + "AreaMenus.xml";
// No longer used. location is now a parameter for the
// StaticPgenOverlayResource.
// public static final String PGEN_XML_OVERLAYS = NCEP_ROOT +
// "StaticPgenOverlays";
public static final String STYLE_RULES_DIR = NCEP_ROOT + "styleRules"
+ File.separator;
// No longer used. location is now a parameter for the StaticPgenOverlayResource.
// public static final String PGEN_XML_OVERLAYS = NCEP_ROOT + "StaticPgenOverlays";
public static final String STYLE_RULES_DIR = NCEP_ROOT + "styleRules" + File.separator;
// lpi,spi files for overlays
public static final String BASEMAPS_DIR = NCEP_ROOT + "basemaps";
// static files
public static final String DFLT_RBD = NCEP_ROOT + "DefaultRBDs" + File.separator+"defaultRBD.xml";
public static final String DFLT_NTRANS_RBD = NCEP_ROOT + "DefaultRBDs" + File.separator+"defaultNTransRBD.xml";
public static final String DFLT_SOLAR_RBD = NCEP_ROOT + "DefaultRBDs" + File.separator+"defaultSolarRBD.xml";
public static final String DFLT_RBD = NCEP_ROOT + "DefaultRBDs"
+ File.separator + "defaultRBD.xml";
public static final String LOCATOR_TBL = NCEP_ROOT+"Locator"+File.separator+"locator_tbl.xml";
public static final String LOGOS_TBL = NCEP_ROOT + "Logos" + File.separator + "logos.tbl";
public static final String LOOP_SPEEDS_TBL= NCEP_ROOT + "LoopControls"+
File.separator+"loopSpeeds.tbl";
public static final String LOCKED_CMAP_TBL = NcPathConstants.COLORMAPS_DIR + File.separator + "lockedColorMaps.tbl";
public static final String CURSOR_REFS_TBL= CURSORS_DIR + File.separator + "cursorref_tbl.xml";
public static final String DFLT_NTRANS_RBD = NCEP_ROOT + "DefaultRBDs"
+ File.separator + "defaultNTransRBD.xml";
public static final String CLOUD_HEIGHT_SOUNDING_MODELS =
NCEP_ROOT+"CloudHeight"+File.separator+"SoundingModels.xml";
public static final String DFLT_SOLAR_RBD = NCEP_ROOT + "DefaultRBDs"
+ File.separator + "defaultSolarRBD.xml";
public static final String GEOG_TBL = PREDEFINED_AREAS_DIR + File.separator+
"gempak"+File.separator+"geog.xml";
public static final String SFSTNS_TBL = STATIONS_DIR+File.separator+"sfstns.xml";
public static final String DFLT_GRAPH_RBD = NCEP_ROOT + "DefaultRBDs"
+ File.separator + "defaultGraphRBD.xml";
public static final String CONDITIONAL_FILTERS_DIR = PLOT_MODELS_DIR + File.separator+"ConditionalFilters";
public static final String CONDITIONAL_FILTER_HELP_FILE = NCEP_ROOT + File.separator + "conditionalFilter" + File.separator + "ConditionalFilterHelp.txt";
public static final String CONDITIONAL_FILTER_MINUS_IMG = NCEP_ROOT + File.separator + "conditionalFilter" + File.separator + "minus_red.gif";
public static final String CONDITIONAL_FILTER_PLUS_IMG = NCEP_ROOT + File.separator + "conditionalFilter" + File.separator + "plus_green.gif";
public static final String ADVANCED_ICON_IMG = NCEP_ROOT + File.separator + "advanced" + File.separator + "adv_icon.jpg";
public static final String LOCATOR_TBL = NCEP_ROOT + "Locator"
+ File.separator + "locator_tbl.xml";
public static final String LOGOS_TBL = NCEP_ROOT + "Logos"
+ File.separator + "logos.tbl";
public static final String LOOP_SPEEDS_TBL = NCEP_ROOT + "LoopControls"
+ File.separator + "loopSpeeds.tbl";
public static final String LOCKED_CMAP_TBL = NcPathConstants.COLORMAPS_DIR
+ File.separator + "lockedColorMaps.tbl";
public static final String CURSOR_REFS_TBL = CURSORS_DIR
+ File.separator + "cursorref_tbl.xml";
public static final String CLOUD_HEIGHT_SOUNDING_MODELS = NCEP_ROOT
+ "CloudHeight" + File.separator + "SoundingModels.xml";
public static final String GEOG_TBL = PREDEFINED_AREAS_DIR
+ File.separator + "gempak" + File.separator + "geog.xml";
public static final String SFSTNS_TBL = STATIONS_DIR + File.separator
+ "sfstns.xml";
public static final String CONDITIONAL_FILTERS_DIR = PLOT_MODELS_DIR
+ File.separator + "ConditionalFilters";
public static final String CONDITIONAL_FILTER_HELP_FILE = NCEP_ROOT
+ File.separator + "conditionalFilter" + File.separator
+ "ConditionalFilterHelp.txt";
public static final String CONDITIONAL_FILTER_MINUS_IMG = NCEP_ROOT
+ File.separator + "conditionalFilter" + File.separator
+ "minus_red.gif";
public static final String CONDITIONAL_FILTER_PLUS_IMG = NCEP_ROOT
+ File.separator + "conditionalFilter" + File.separator
+ "plus_green.gif";
public static final String ADVANCED_ICON_IMG = NCEP_ROOT
+ File.separator + "advanced" + File.separator + "adv_icon.jpg";
// migrating code which looked for these filenames
public static final String VORS_STN_TBL = STATIONS_DIR + File.separator+"vors.xml";
public static final String VOLCANO_STN_TBL = STATIONS_DIR + File.separator+"volcano.xml";
public static final String COUNTY_STN_TBL = STATIONS_DIR + File.separator+ "county.xml";
public static final String FFG_ZONES_STN_TBL = STATIONS_DIR + File.separator+"ffgZones.xml";
public static final String SPCWATCH_STN_TBL = STATIONS_DIR + File.separator+"spcwatch.xml";
public static final String VORS_STN_TBL = STATIONS_DIR + File.separator
+ "vors.xml";
public static final String VOLCANO_STN_TBL = STATIONS_DIR
+ File.separator + "volcano.xml";
public static final String COUNTY_STN_TBL = STATIONS_DIR
+ File.separator + "county.xml";
public static final String FFG_ZONES_STN_TBL = STATIONS_DIR
+ File.separator + "ffgZones.xml";
public static final String SPCWATCH_STN_TBL = STATIONS_DIR
+ File.separator + "spcwatch.xml";
public static final String SHAPEFILES_DIR = NCEP_ROOT + "Shapefiles";
public static final String SEEK_STN_TBL = NCEP_ROOT + "Seek"+File.separator+"seekStns.xml";
public static final String SEEK_STN_TBL = NCEP_ROOT + "Seek"
+ File.separator + "seekStns.xml";
// public static final String GRID_DATATYPE_TBL = NCEP_ROOT + "grid"+File.separator+"datatype.tbl";
// public static final String ENSEMBLE_MODELS_TBL= NCEP_ROOT + "grid"+File.separator+"ensemble_models.tbl";
public static final String GEMPAK_MARKER_TYPE = NCEP_ROOT + "Gempak"+File.separator+"gempakMarkerType.tbl";
// public static final String GRID_DATATYPE_TBL = NCEP_ROOT +
// "grid"+File.separator+"datatype.tbl";
// public static final String ENSEMBLE_MODELS_TBL= NCEP_ROOT +
// "grid"+File.separator+"ensemble_models.tbl";
public static final String GEMPAK_MARKER_TYPE = NCEP_ROOT + "Gempak"
+ File.separator + "gempakMarkerType.tbl";
// Note: These are read by Raytheon's code which just takes the directory as input and
// Note: These are read by Raytheon's code which just takes the
// directory as input and
// assumes the filename. So don't change the fileNames.
// the files.
public static final String RADAR_INFO = NCEP_ROOT + "Radar"+File.separator+"radarInfo.txt";
// public static final String MOSAIC_INFO = NCEP_ROOT + "Radar"+File.separator+"mosaicInfo.txt";
public static final String MCIDAS_IMG_STYLE_RULES = STYLE_RULES_DIR + "mcidasSatelliteImageryStyleRules.xml";
public static final String GINI_IMG_STYLE_RULES = STYLE_RULES_DIR + "giniSatelliteImageryStyleRules.xml";
public static final String SOLAR_IMG_STYLE_RULES = STYLE_RULES_DIR + "solarImageryStyleRules.xml";
public static final String RADAR_INFO = NCEP_ROOT + "Radar"
+ File.separator + "radarInfo.txt";
// public static final String MOSAIC_INFO = NCEP_ROOT +
// "Radar"+File.separator+"mosaicInfo.txt";
public static final String MCIDAS_IMG_STYLE_RULES = STYLE_RULES_DIR
+ "mcidasSatelliteImageryStyleRules.xml";
public static final String GINI_IMG_STYLE_RULES = STYLE_RULES_DIR
+ "giniSatelliteImageryStyleRules.xml";
public static final String SOLAR_IMG_STYLE_RULES = STYLE_RULES_DIR
+ "solarImageryStyleRules.xml";
// PGEN Files
public static final String PGEN_ROOT = NCEP_ROOT + "pgen"+File.separator;
public static final String PGEN_SETTINGS_TBL = PGEN_ROOT + "settings_tbl.xml";
public static final String PGEN_LINE_PATTERNS = PGEN_ROOT + "linePatterns.xml";
public static final String PGEN_SYMBOL_PATTERNS = PGEN_ROOT + "symbolPatterns.xml";
public static final String PGEN_PRODUCT_TYPES = PGEN_ROOT + "productTypes.xml";
public static final String PGEN_ROOT = NCEP_ROOT + "pgen"
+ File.separator;
public static final String PGEN_SETTINGS_TBL = PGEN_ROOT
+ "settings_tbl.xml";
public static final String PGEN_LINE_PATTERNS = PGEN_ROOT
+ "linePatterns.xml";
public static final String PGEN_SYMBOL_PATTERNS = PGEN_ROOT
+ "symbolPatterns.xml";
public static final String PGEN_PRODUCT_TYPES = PGEN_ROOT
+ "productTypes.xml";
public static final String PGEN_HELP_FILE = PGEN_ROOT + "PgenHelp.txt";
public static final String PGEN_TCA_ATTR_INFO = PGEN_ROOT + "TCAinfo.xml";
public static final String PGEN_TCA_ATTR_INFO = PGEN_ROOT
+ "TCAinfo.xml";
public static final String PGEN_GFA_ATTR_FILE = PGEN_ROOT + "gfa.xml";
public static final String PGEN_GFA_PROD_XSL = PGEN_ROOT + "xslt"+File.separator+
"airmet"+File.separator+"gfa_product.xsl";
public static final String PGEN_AIRMET_CYCLE_TBL= PGEN_ROOT + "airmetcycle.xml";
public static final String PGEN_ISLND_BRKPTS_TBL= PGEN_ROOT + "IslandBreakpoints.xml";
public static final String PGEN_WATER_BRKPTS_TBL= PGEN_ROOT + "WaterBreakpoints.xml";
public static final String PGEN_COAST_BRKPTS_TBL= PGEN_ROOT + "CoastBreakpoints.xml";
public static final String PGEN_GFA_PROD_XSL = PGEN_ROOT + "xslt"
+ File.separator + "airmet" + File.separator
+ "gfa_product.xsl";
public static final String PGEN_AIRMET_CYCLE_TBL = PGEN_ROOT
+ "airmetcycle.xml";
public static final String PGEN_ISLND_BRKPTS_TBL = PGEN_ROOT
+ "IslandBreakpoints.xml";
public static final String PGEN_WATER_BRKPTS_TBL = PGEN_ROOT
+ "WaterBreakpoints.xml";
public static final String PGEN_COAST_BRKPTS_TBL = PGEN_ROOT
+ "CoastBreakpoints.xml";
public static final String PGEN_SPC_ANCHOR_TBL = SPCWATCH_STN_TBL;
public static final String PGEN_FIR_BOUNDS = SHAPEFILES_DIR +File.separator+ "firbnds"+File.separator+"firbnds.shp";
public static final String PGEN_CCFP_TIMES = PGEN_ROOT + "ccfpTimes.xml";
public static final String PGEN_CCFP_XSLT = PGEN_ROOT + "xslt"+File.separator+
"ccfp"+File.separator+"ccfpXml2Txt.xslt";
public static final String PGEN_FIR_BOUNDS = SHAPEFILES_DIR
+ File.separator + "firbnds" + File.separator + "firbnds.shp";
public static final String PGEN_CCFP_TIMES = PGEN_ROOT
+ "ccfpTimes.xml";
public static final String PGEN_CCFP_XSLT = PGEN_ROOT + "xslt"
+ File.separator + "ccfp" + File.separator + "ccfpXml2Txt.xslt";
public static final String PGEN_VAA_FILE = PGEN_ROOT + "vaa.xml";
public static final String PGEN_VAA_XSLT = PGEN_ROOT + "xslt"+File.separator+
"vaa"+File.separator+"vaaXml2Txt.xslt";
public static final String PGEN_PHENOMENONS = PGEN_ROOT + "phenomenons.xml";
public static final String PGEN_VAA_XSLT = PGEN_ROOT + "xslt"
+ File.separator + "vaa" + File.separator + "vaaXml2Txt.xslt";
public static final String PGEN_PHENOMENONS = PGEN_ROOT
+ "phenomenons.xml";
//
public static final String PGEN_PROD_SCHEMA = PGEN_ROOT + "product.xsd";
public static final String PGEN_RED_CROSS_IMG = PGEN_ROOT + "red_cross.png";
public static final String PGEN_OUTLOOK_TYPE = PGEN_ROOT + "outlooktype.xml";
public static final String PGEN_OUTLOOK_SETTINGS= PGEN_ROOT + "outlooksettings.xml";
public static final String PGEN_OUTLOOK_TIMES = PGEN_ROOT + "outlooktimes.xml";
public static final String PGEN_MNTN_OBSC_STATES= PGEN_ROOT + "mt_obsc_states.xml";
public static final String PGEN_CONTOURS_INFO = PGEN_ROOT + "contoursInfo.xml";
public static final String PGEN_G2G_GRPHGD = PGEN_ROOT + "grphgd.tbl";
public static final String PGEN_FILTER_HOUR = PGEN_ROOT + "filterHour.xml";
public static final String PGEN_FORECASTER = PGEN_ROOT + "forecasters.xml";
public static final String NSHARP_NLIST_FILE = NCEP_ROOT + "nsharp"+File.separator+"nlist.txt";
public static final String NSHARP_SUP_FILE = NCEP_ROOT + "nsharp"+File.separator+"sup.txt";
public static final String PGEN_RED_CROSS_IMG = PGEN_ROOT
+ "red_cross.png";
public static final String PGEN_OUTLOOK_TYPE = PGEN_ROOT
+ "outlooktype.xml";
public static final String PGEN_OUTLOOK_SETTINGS = PGEN_ROOT
+ "outlooksettings.xml";
public static final String PGEN_OUTLOOK_TIMES = PGEN_ROOT
+ "outlooktimes.xml";
public static final String PGEN_MNTN_OBSC_STATES = PGEN_ROOT
+ "mt_obsc_states.xml";
public static final String PGEN_CONTOURS_INFO = PGEN_ROOT
+ "contoursInfo.xml";
public static final String PGEN_G2G_GRPHGD = PGEN_ROOT + "grphgd.tbl";
public static final String PGEN_FILTER_HOUR = PGEN_ROOT
+ "filterHour.xml";
public static final String PGEN_FORECASTER = PGEN_ROOT
+ "forecasters.xml";
public static final String NSHARP_NLIST_FILE = NCEP_ROOT + "nsharp"
+ File.separator + "nlist.txt";
public static final String NSHARP_SUP_FILE = NCEP_ROOT + "nsharp"
+ File.separator + "sup.txt";
// nsharp configuration
public static final String NSHARP_CONFIG = NCEP_ROOT + "nsharp"+ File.separator+"nsharpConfig.xml";
public static final String NSHARP_CONFIG = NCEP_ROOT + "nsharp"
+ File.separator + "nsharpConfig.xml";
}
@ -201,7 +338,8 @@ public class NcPathManager {
private NcPathManager() {
// Uses the same CAVELocalizationAdapter.
pathMngr = PathManagerFactory.getPathManager( new CAVELocalizationAdapter() );
pathMngr = PathManagerFactory
.getPathManager(new CAVELocalizationAdapter());
}
@ -215,10 +353,12 @@ public class NcPathManager {
// sanity check to make sure the order is correct
//
if (LocalizationLevel.SITE.compareTo(DESK) >= 0) {
System.out.println("WARNING: the SITE level order >= the DESK???? ");
System.out
.println("WARNING: the SITE level order >= the DESK???? ");
}
if (LocalizationLevel.USER.compareTo(DESK) <= 0) {
System.out.println("WARNING: the USER level order <= the DESK???? ");
System.out
.println("WARNING: the USER level order <= the DESK???? ");
}
LocalizationManager.getInstance();
@ -239,7 +379,8 @@ public class NcPathManager {
return pathMngr;
}
// Use this method if we don't care or need to know which context the file comes from.
// Use this method if we don't care or need to know which context the file
// comes from.
public File getStaticFile(String fname) {
return pathMngr.getStaticFile(fname);
}
@ -258,10 +399,11 @@ public class NcPathManager {
return pathMngr.getLocalizationFile(context, name);
}
// only include 1 version of each filename. Assume CAVE_STATIC (can change this later)
// only include 1 version of each filename. Assume CAVE_STATIC (can change
// this later)
//
public Map<String, LocalizationFile> listFiles(
String name, String[] filter, boolean recursive, boolean filesOnly ) {
public Map<String, LocalizationFile> listFiles(String name,
String[] filter, boolean recursive, boolean filesOnly) {
LocalizationContext[] contexts = getLocalSearchHierarchy(LocalizationType.CAVE_STATIC);
return listFiles(contexts, name, filter, recursive, filesOnly);
@ -269,24 +411,26 @@ public class NcPathManager {
// created to allow listFiles for COMMON_STATIC contexts
//
public Map<String, LocalizationFile> listFiles( LocalizationContext[] contexts,
String name, String[] filter, boolean recursive, boolean filesOnly ) {
public Map<String, LocalizationFile> listFiles(
LocalizationContext[] contexts, String name, String[] filter,
boolean recursive, boolean filesOnly) {
Map<String, LocalizationFile> lFileMap = new HashMap<String, LocalizationFile>();
List<LocalizationFile> lFilesList =
Arrays.asList(
pathMngr.listFiles( contexts, name, filter, recursive, filesOnly ) );
List<LocalizationFile> lFilesList = Arrays.asList(pathMngr.listFiles(
contexts, name, filter, recursive, filesOnly));
// loop thru the files and add them to the map if there is not already a file
// loop thru the files and add them to the map if there is not already a
// file
// present from a higher level.
//
for (LocalizationFile lFile : lFilesList) {
String lName = lFile.getName();
LocalizationLevel lLvl = lFile.getContext().getLocalizationLevel();
if( !lFileMap.containsKey( lName ) ||
(lFileMap.get( lName ).getContext().getLocalizationLevel().compareTo( lLvl ) < 0) ) {
if (!lFileMap.containsKey(lName)
|| (lFileMap.get(lName).getContext().getLocalizationLevel()
.compareTo(lLvl) < 0)) {
// System.out.println("listFiles "+lFile.getFile().getAbsolutePath());
lFileMap.put(lFile.getName(), lFile);
}
@ -297,8 +441,10 @@ public class NcPathManager {
}
// convienence method to get all the versions of a file. Assume CAVE_STATIC.
public Map<LocalizationLevel, LocalizationFile> getTieredLocalizationFile( String name) {
return pathMngr.getTieredLocalizationFile( LocalizationType.CAVE_STATIC, name );
public Map<LocalizationLevel, LocalizationFile> getTieredLocalizationFile(
String name) {
return pathMngr.getTieredLocalizationFile(LocalizationType.CAVE_STATIC,
name);
}
public LocalizationContext getContext(LocalizationType type,
@ -321,13 +467,16 @@ public class NcPathManager {
// // getTieredLocalizationFile(
// // LocalizationType type,
// String name, String[] filter, boolean recursive, boolean filesOnly ) {
// Map<String, LocalizationFile> map = new HashMap<String, LocalizationFile>();
// Map<String, LocalizationFile> map = new HashMap<String,
// LocalizationFile>();
//
// for( LocalizationLevel level : ncLevels ) {
// LocalizationContext context = getContext( LocalizationType.CAVE_STATIC, level );
// LocalizationContext context = getContext( LocalizationType.CAVE_STATIC,
// level );
//
// LocalizationFile[] lFiles =
// pathMngr.listFiles( getLocalSearchHierarchy( LocalizationType.CAVE_STATIC ),
// pathMngr.listFiles( getLocalSearchHierarchy( LocalizationType.CAVE_STATIC
// ),
// name, filter, recursive, filesOnly );
// // LocalizationFile lf = getLocalizationFile( context, name );
//
@ -339,10 +488,10 @@ public class NcPathManager {
// return map;
// }
// delete the file and also return a superceding file if one exists.
//
// public LocalizationFile revert( File file, LocalizationContext context, String fileName, boolean findReplacement )
// public LocalizationFile revert( File file, LocalizationContext context,
// String fileName, boolean findReplacement )
// throws LocalizationOpFailedException {
// super.delete(file, context, fileName);
//

View file

@ -27,4 +27,5 @@ Export-Package: gov.noaa.nws.ncep.viz.resourceManager,
gov.noaa.nws.ncep.viz.resourceManager.ui.createRbd,
gov.noaa.nws.ncep.viz.resourceManager.ui.loadRbd,
gov.noaa.nws.ncep.viz.resourceManager.ui.manageResources
Import-Package: gov.noaa.nws.ncep.viz.rsc.pgen
Import-Package: gov.noaa.nws.ncep.viz.resourceManager.timeline,
gov.noaa.nws.ncep.viz.rsc.pgen

View file

@ -85,6 +85,7 @@ import com.raytheon.uf.common.time.DataTime;
* 02/11/11 #408 Greg Hull combined with Timeline class (now TimelineControl)
* 06/19/12 #657 Greg Hull removeSpinnerListeners() before setting the
* spinner maxvalues.
* 04/30/2014 #1131 qzhou Add construct for Graph to create graph widgets.
* 06/24/14 TTR1029 J. Wu Distinguish clicks in/outside of the slider box.
* 07/11/14 TTR1032 J. Wu reload data times as necessary to keep timeline current.
*
@ -121,20 +122,20 @@ public class TimelineControl extends Composite {
private final String manualTimelineStr = " Manual Timeline ";
private HashMap<String, ArrayList<AbstractNatlCntrsRequestableResourceData>> availDomResourcesMap = null;
protected HashMap<String, ArrayList<AbstractNatlCntrsRequestableResourceData>> availDomResourcesMap = null;
private AbstractNatlCntrsRequestableResourceData domRscData = null;
protected AbstractNatlCntrsRequestableResourceData domRscData = null;
private Combo dom_rsc_combo = null;
protected Combo dom_rsc_combo = null;
private NCTimeMatcher timeMatcher = null;
protected NCTimeMatcher timeMatcher = null;
public interface IDominantResourceChangedListener {
public void dominantResourceChanged(
AbstractNatlCntrsRequestableResourceData newDomRsc);
}
private Set<IDominantResourceChangedListener> dominantResourceChangedListeners = new HashSet<IDominantResourceChangedListener>();
protected Set<IDominantResourceChangedListener> dominantResourceChangedListeners = new HashSet<IDominantResourceChangedListener>();
// public enum TimeLineBehavior { PREPEND, APPEND };
private enum MODE {
@ -205,7 +206,7 @@ public class TimelineControl extends Composite {
private int sliderMin, sliderMax;
private TimelineData timeData;
protected TimelineData timeData;
private Map<Rectangle, Calendar> availableTimes;
@ -221,8 +222,14 @@ public class TimelineControl extends Composite {
private Shell shell;
public TimelineControl(Composite parent, String rbdName) {
super(parent, SWT.NONE);
// this.rbdName = rbdName;
}
public TimelineControl(Composite parent) {
super(parent, SWT.NONE);
shell = parent.getShell();
timeMatcher = new NCTimeMatcher();
@ -347,6 +354,7 @@ public class TimelineControl extends Composite {
}
return true;
}
public NCTimeMatcher getTimeMatcher() {
@ -616,7 +624,6 @@ public class TimelineControl extends Composite {
//
private void updateTimeline() {
//
if (timeMatcher.getFrameTimes().isEmpty()) {
if (timeMatcher.getDominantResource() == null) {
setTimelineState("No Dominant Resource Selected", true);

View file

@ -16,9 +16,9 @@ import java.util.Set;
import java.util.TreeMap;
/**
* This class maintains an ordered map of data times, where each time
* is mapped to a Boolean value indicating whether that time is "selected" from
* the overall list.
* This class maintains an ordered map of data times, where each time is mapped
* to a Boolean value indicating whether that time is "selected" from the
* overall list.
*
* @author sgilbert
*
@ -29,7 +29,9 @@ public class TimelineData {
/**
* Initializes all available time to non-selected status
* @param timeList list of available data times
*
* @param timeList
* list of available data times
*/
TimelineData(List<Calendar> timeList) {
@ -42,6 +44,7 @@ public class TimelineData {
/**
* checks if the list of available times is empty
*
* @return
*/
public boolean isEmpty() {
@ -50,6 +53,7 @@ public class TimelineData {
/**
* Returns the first available data time in the list
*
* @return
*/
public Calendar getFirstTime() {
@ -58,6 +62,7 @@ public class TimelineData {
/**
* Returns the last available data time in the list
*
* @return
*/
public Calendar getLastTime() {
@ -66,6 +71,7 @@ public class TimelineData {
/**
* Returns a set of all the available data times
*
* @return
*/
public Set<Calendar> getTimes() {
@ -74,12 +80,14 @@ public class TimelineData {
/**
* Returns a list of "selected" data times from the list of available times
*
* @return
*/
public List<Calendar> getSelectedTimes() {
ArrayList<Calendar> list = new ArrayList<Calendar>();
for (Calendar cal : times.keySet()) {
if ( times.get(cal) ) list.add(cal);
if (times.get(cal))
list.add(cal);
}
return list;
}
@ -94,6 +102,7 @@ public class TimelineData {
/**
* Returns the total number of minutes between the first and last available
* data times
*
* @return
*/
public int getTotalMinutes() {
@ -104,8 +113,9 @@ public class TimelineData {
}
/**
* Returns the total number of milliseconds between the first and last available
* data times
* Returns the total number of milliseconds between the first and last
* available data times
*
* @return
*/
public long getTotalMillis() {
@ -115,30 +125,21 @@ public class TimelineData {
}
/*
public void selectFirst(int num) {
int j=0;
Calendar cal = times.firstKey();
while ( cal != null ) {
if ( j++ < num ) times.put(cal, true);
else times.put(cal, false);
cal = times.higherKey( cal );
}
}
public void selectLast(int num) {
int j=0;
Calendar cal = times.lastKey();
while ( cal != null ) {
if ( j++ < num ) times.put(cal, true);
else times.put(cal, false);
cal = times.lowerKey( cal );
}
}
* public void selectFirst(int num) {
*
* int j=0; Calendar cal = times.firstKey(); while ( cal != null ) { if (
* j++ < num ) times.put(cal, true); else times.put(cal, false);
*
* cal = times.higherKey( cal ); } }
*
* public void selectLast(int num) {
*
* int j=0; Calendar cal = times.lastKey(); while ( cal != null ) { if ( j++
* < num ) times.put(cal, true); else times.put(cal, false);
*
* cal = times.lowerKey( cal ); }
*
* }
*/
/**
@ -148,7 +149,8 @@ public class TimelineData {
Map.Entry<Calendar, Boolean> entry = times.firstEntry();
while (entry != null) {
if ( entry.getValue() ) return entry.getKey();
if (entry.getValue())
return entry.getKey();
entry = times.higherEntry(entry.getKey());
}
return null;
@ -156,13 +158,15 @@ public class TimelineData {
/**
* Returns the last selected time in the list
*
* @return
*/
public Calendar getLastSelected() {
Map.Entry<Calendar, Boolean> entry = times.lastEntry();
while (entry != null) {
if ( entry.getValue() ) return entry.getKey();
if (entry.getValue())
return entry.getKey();
entry = times.lowerEntry(entry.getKey());
}
return null;
@ -170,6 +174,7 @@ public class TimelineData {
/**
* Returns the available time just before the specified time
*
* @param cal
* @return
*/
@ -179,6 +184,7 @@ public class TimelineData {
/**
* Returns the available time just after the specified time
*
* @param cal
* @return
*/
@ -188,6 +194,7 @@ public class TimelineData {
/**
* Toggles the "select" indicator for the given time
*
* @param cal
*/
public void toggle(Calendar cal) {
@ -198,34 +205,41 @@ public class TimelineData {
/**
* Returns the number of selected data times
*
* @return
*/
public int numSelected() {
int num = 0;
for (Boolean val : times.values()) {
if ( val ) num++;
if (val)
num++;
}
return num;
}
/**
* Marks the given time as selected
*
* @param cal
*/
public void select(Calendar cal) {
if ( times.containsKey(cal) ) times.put(cal, true);
if (times.containsKey(cal))
times.put(cal, true);
}
/**
* Marks the given time as not selected
*
* @param cal
*/
public void deselect(Calendar cal) {
if ( times.containsKey(cal) ) times.put(cal, false);
if (times.containsKey(cal))
times.put(cal, false);
}
/**
* Returns the number of available times in the list
*
* @return
*/
public int getSize() {
@ -233,31 +247,33 @@ public class TimelineData {
}
/**
* Adds or removes times from the end of the selected list until the specified
* number of times (numFrames) is selected. The skip factor is used to skip
* a specific number of times between each selected time.
* Adds or removes times from the end of the selected list until the
* specified number of times (numFrames) is selected. The skip factor is
* used to skip a specific number of times between each selected time.
*
* @param numFrames
* @param skip
*/
public void appendTimes(int numFrames, int skip) {
if (numFrames > numSelected()) {
if ( numSelected() == 0 ) select(getFirstTime());
if (numSelected() == 0)
select(getFirstTime());
addToLast(numFrames, skip);
if (numFrames > numSelected()) {
addToFirst(numFrames, skip);
}
}
else if ( numFrames < numSelected() ) {
} else if (numFrames < numSelected()) {
removeFromLast(numFrames, skip);
}
}
/**
* Adds times to the end of the selected list until the specified
* number of times (numFrames) is selected. The skip factor is used to skip
* a specific number of times between each selected time.
* Adds times to the end of the selected list until the specified number of
* times (numFrames) is selected. The skip factor is used to skip a specific
* number of times between each selected time.
*
* @param numFrames
* @param skip
*/
@ -268,7 +284,8 @@ public class TimelineData {
Calendar cal = getLastSelected();
for (int j = 0; j <= skip; j++) {
cal = getNextTime(cal);
if ( cal == null) return;
if (cal == null)
return;
}
select(cal);
@ -280,6 +297,7 @@ public class TimelineData {
* Removes times from the end of the selected list until the specified
* number of times (numFrames) is selected. The skip factor is used to skip
* a specific number of times between each selected time.
*
* @param numFrames
* @param skip
*/
@ -294,22 +312,23 @@ public class TimelineData {
}
/**
* Adds or removes times from the beginning of the selected list until the specified
* number of times (numFrames) is selected. The skip factor is used to skip
* a specific number of times between each selected time.
* Adds or removes times from the beginning of the selected list until the
* specified number of times (numFrames) is selected. The skip factor is
* used to skip a specific number of times between each selected time.
*
* @param numFrames
* @param skip
*/
public void prependTimes(int numFrames, int skip) {
if (numFrames > numSelected()) {
if ( numSelected() == 0 ) select(getLastTime());
if (numSelected() == 0)
select(getLastTime());
addToFirst(numFrames, skip);
if (numFrames > numSelected()) {
addToLast(numFrames, skip);
}
}
else if ( numFrames < numSelected() ) {
} else if (numFrames < numSelected()) {
removeFromFirst(numFrames, skip);
}
@ -319,6 +338,7 @@ public class TimelineData {
* Adds times to the beginning of the selected list until the specified
* number of times (numFrames) is selected. The skip factor is used to skip
* a specific number of times between each selected time.
*
* @param numFrames
* @param skip
*/
@ -329,7 +349,8 @@ public class TimelineData {
Calendar cal = getFirstSelected();
for (int j = 0; j <= skip; j++) {
cal = getPreviousTime(cal);
if ( cal == null) return;
if (cal == null)
return;
}
select(cal);
@ -340,6 +361,7 @@ public class TimelineData {
* Removes times from the beginning of the selected list until the specified
* number of times (numFrames) is selected. The skip factor is used to skip
* a specific number of times between each selected time.
*
* @param numFrames
* @param skip
*/
@ -354,8 +376,9 @@ public class TimelineData {
}
/**
* Updates the selected times in the given time range. The skip factor is used to skip
* a specific number of times between each selected time.
* Updates the selected times in the given time range. The skip factor is
* used to skip a specific number of times between each selected time.
*
* @param numFrames
* @param skip
*/
@ -366,24 +389,25 @@ public class TimelineData {
deselectAll();
for (Calendar cal : times.keySet()) {
if ( cal.equals(first) ) loc1 = j;
if ( cal.equals(second) ) loc2 = j;
if (cal.equals(first))
loc1 = j;
if (cal.equals(second))
loc2 = j;
j++;
}
int avail = Math.abs(loc2 - loc1) + 1;
int num = avail / (skip + 1);
if ( num * (skip + 1) < avail ) num++;
if (num * (skip + 1) < avail)
num++;
if (first.before(second)) {
select(first);
addToLast(num, skip);
}
else if ( first.after(second) ) {
} else if (first.after(second)) {
select(first);
addToFirst(num, skip);
}
else {
} else {
select(first);
}

View file

@ -10,6 +10,7 @@ import gov.noaa.nws.ncep.viz.common.display.INcPaneID;
import gov.noaa.nws.ncep.viz.common.display.INcPaneLayout;
import gov.noaa.nws.ncep.viz.common.display.NcDisplayName;
import gov.noaa.nws.ncep.viz.common.display.NcDisplayType;
import gov.noaa.nws.ncep.viz.resourceManager.timeline.GraphTimelineControl;
import gov.noaa.nws.ncep.viz.resourceManager.timeline.TimelineControl;
import gov.noaa.nws.ncep.viz.resourceManager.timeline.TimelineControl.IDominantResourceChangedListener;
import gov.noaa.nws.ncep.viz.resourceManager.ui.createRbd.ResourceSelectionControl.IResourceSelectedListener;
@ -139,7 +140,8 @@ import com.raytheon.viz.ui.editor.AbstractEditor;
* 10/22/2013 #1043 Greg Hull setSelectedResource() if rsc sel dlg is already up.
* 11/25/2013 #1079 Greg Hull adjust size/font of area toolbar based on the text
* 05/07/2014 TTR991 D. Sushon if a different NCP editor is selected, the CreateRDB tab should now adjust.
*
* 05/29/2014 #1131 qzhou Added NcDisplayType
* Modified creating new timelineControl in const and updateGUI
* </pre>
*
* @author ghull
@ -259,6 +261,8 @@ public class CreateRbdControl extends Composite implements IPartListener2 {
private final String ImportFromSPF = "From SPF...";
private Group timeline_grp;
// private final String[] StandardZoomLevels = {"1",
// "1.5","2","3","5","7.5","10","15","20","30"};
@ -305,7 +309,7 @@ public class CreateRbdControl extends Composite implements IPartListener2 {
createRBDGroup();
Group timeline_grp = new Group(sash_form, SWT.SHADOW_NONE);
timeline_grp = new Group(sash_form, SWT.SHADOW_NONE);
timeline_grp.setText("Select Timeline");
gd = new GridData();
gd.grabExcessHorizontalSpace = true;
@ -316,13 +320,21 @@ public class CreateRbdControl extends Composite implements IPartListener2 {
timeline_grp.setLayout(new GridLayout());
if (mngr.getRbdType().equals(NcDisplayType.GRAPH_DISPLAY)) {
timelineControl = (GraphTimelineControl) new GraphTimelineControl(
timeline_grp);
} else {
timelineControl = new TimelineControl(timeline_grp);
}
timelineControl
.addDominantResourceChangedListener(new IDominantResourceChangedListener() {
@Override
public void dominantResourceChanged(
AbstractNatlCntrsRequestableResourceData newDomRsc) {
// System.out.println("**createRbd "
// + rbdMngr.isAutoUpdate() + " "
// + newDomRsc.isAutoUpdateable());
if (newDomRsc == null) {
auto_update_btn.setSelection(rbdMngr.isAutoUpdate());
auto_update_btn.setEnabled(false);
@ -482,7 +494,8 @@ public class CreateRbdControl extends Composite implements IPartListener2 {
disp_type_combo.setItems(new String[] {
NcDisplayType.NMAP_DISPLAY.getName(),
NcDisplayType.NTRANS_DISPLAY.getName(),
NcDisplayType.SOLAR_DISPLAY.getName() });
NcDisplayType.SOLAR_DISPLAY.getName(),
NcDisplayType.GRAPH_DISPLAY.getName() });
disp_type_lbl = new Label(rbd_grp, SWT.None);
disp_type_lbl.setText("RBD Type");
@ -784,7 +797,7 @@ public class CreateRbdControl extends Composite implements IPartListener2 {
edit_span_btn.setLayoutData(form_data);
edit_span_btn.setEnabled(false);
// seld_rscs_grp.pack(true);
seld_rscs_grp.pack(true);
return seld_rscs_grp;
}
@ -1106,7 +1119,7 @@ public class CreateRbdControl extends Composite implements IPartListener2 {
// if replacing existing resources, get the selected
// resources
// (For now just replace the 1st if more than one selected.)
//
if (replace) {
StructuredSelection sel_elems = (StructuredSelection) seld_rscs_lviewer
.getSelection();
@ -1876,7 +1889,42 @@ public class CreateRbdControl extends Composite implements IPartListener2 {
selectPane(rbdMngr.getSelectedPaneId());
timelineControl.clearTimeline();
// timelineControl.clearTimeline();
// create new timelineControl if is Graph
timelineControl.dispose();
if (rbdMngr.getRbdType().equals(NcDisplayType.GRAPH_DISPLAY))
timelineControl = (GraphTimelineControl) new GraphTimelineControl(
timeline_grp);
else
timelineControl = new TimelineControl(timeline_grp);
timelineControl
.addDominantResourceChangedListener(new IDominantResourceChangedListener() {
@Override
public void dominantResourceChanged(
AbstractNatlCntrsRequestableResourceData newDomRsc) {
// System.out.println("**createRbd2 "
// + rbdMngr.isAutoUpdate() + " "
// + newDomRsc.isAutoUpdateable());
if (newDomRsc == null) {
auto_update_btn.setSelection(rbdMngr.isAutoUpdate());
auto_update_btn.setEnabled(false);
} else if (newDomRsc.isAutoUpdateable()) {
auto_update_btn.setEnabled(true);
// auto_update_btn.setSelection(
// rbdMngr.isAutoUpdate() );top_comp
auto_update_btn.setSelection(true);
} else {
auto_update_btn.setSelection(false);
auto_update_btn.setEnabled(false);
}
}
});
// timelineControl.setTimeMatcher(new NCTimeMatcher());
INcPaneLayout paneLayout = rbdMngr.getPaneLayout();
@ -1906,6 +1954,8 @@ public class CreateRbdControl extends Composite implements IPartListener2 {
auto_update_btn.setSelection(false);
auto_update_btn.setEnabled(false);
}
shell.pack();
}
// TODO : we could have the pane buttons indicate whether

View file

@ -3,10 +3,13 @@ package gov.noaa.nws.ncep.viz.resourceManager.ui.loadRbd;
//import gov.noaa.nws.ncep.viz.common.EditorManager;
import gov.noaa.nws.ncep.viz.common.display.INatlCntrsRenderableDisplay;
import gov.noaa.nws.ncep.viz.common.display.INcPaneLayout;
import gov.noaa.nws.ncep.viz.common.display.NcDisplayType;
import gov.noaa.nws.ncep.viz.resourceManager.timeline.GraphTimelineControl;
import gov.noaa.nws.ncep.viz.resourceManager.timeline.TimelineControl;
import gov.noaa.nws.ncep.viz.resourceManager.ui.createRbd.CreateRbdControl;
import gov.noaa.nws.ncep.viz.resources.AbstractNatlCntrsRequestableResourceData;
import gov.noaa.nws.ncep.viz.resources.manager.AbstractRBD;
import gov.noaa.nws.ncep.viz.resources.manager.GraphRBD;
import gov.noaa.nws.ncep.viz.resources.manager.ResourceBndlLoader;
import gov.noaa.nws.ncep.viz.resources.manager.SpfsManager;
import gov.noaa.nws.ncep.viz.resources.time_match.NCTimeMatcher;
@ -162,6 +165,8 @@ public class LoadRbdControl extends Composite {
private EditRbdDialog editRbdDlg = null;
private Group timeline_grp;
public LoadRbdControl(Composite parent) throws VizException {
super(parent, SWT.NONE);
shell = parent.getShell();
@ -315,7 +320,7 @@ public class LoadRbdControl extends Composite {
fd.left = new FormAttachment(auto_update_btn, 0, SWT.LEFT);
geo_sync_panes.setLayoutData(fd);
Group timeline_grp = new Group(sash_form, SWT.SHADOW_NONE);
timeline_grp = new Group(sash_form, SWT.SHADOW_NONE);
timeline_grp.setText("Select Timeline");
fd = new FormData();
fd.top = new FormAttachment(0, 5);
@ -326,7 +331,15 @@ public class LoadRbdControl extends Composite {
timeline_grp.setLayout(new GridLayout());
timelineControl = new TimelineControl(timeline_grp);
if (!seldRbdsList.isEmpty()
&& seldRbdsList.get(0).getDisplayType()
.equals(NcDisplayType.GRAPH_DISPLAY)) { // .getRbdName().equals("Graph"))
// {
timelineControl = new GraphTimelineControl(timeline_grp);
System.out.println("HERE");
} else {
timelineControl = new TimelineControl(timeline_grp);// quan
}
sash_form.setWeights(new int[] { 3, 2 });
@ -690,14 +703,102 @@ public class LoadRbdControl extends Composite {
seldRbdsList.clear();
AbstractRBD<?> rbdSel = null;
// INcPaneLayout paneLayout = rbdMngr.getPaneLayout();
//
// // set the list of available resources for the timeline
// for (int paneIndx = 0; paneIndx < paneLayout.getNumberOfPanes();
// paneIndx++) {
// for (ResourceSelection rscSel : rbdMngr
// .getRscsForPane((NcPaneID) paneLayout
// .createPaneId(paneIndx))) {
//
// if (rscSel.getResourceData() instanceof
// AbstractNatlCntrsRequestableResourceData) {
// timelineControl
// .addAvailDomResource((AbstractNatlCntrsRequestableResourceData)
// rscSel
// .getResourceData());
// }
// }
// }
while (sel_iter.hasNext()) {
rbdSel = (AbstractRBD<?>) sel_iter.next();
// if (rbdSel.getTimeMatcher().getDominantResource() == null) {
// System.out.println("Dominant Resource is null?");
// } else {
// rbdSel.getTimeMatcher().loadTimes(true);
// }
// else {
// rbdSel.getTimeMatcher().loadTimes();
// timelineControl.dispose();
if (rbdSel instanceof GraphRBD) {
updateGUI(rbdSel);
// rbdSel.getDisplayType().equals(NcDisplayType.GRAPH_DISPLAY))
// {//
// timelineControl = (GraphTimelineControl) new
// GraphTimelineControl(
// timeline_grp);
//
// timelineControl
// .addDominantResourceChangedListener(new
// IDominantResourceChangedListener() {
// @Override
// public void dominantResourceChanged(
// AbstractNatlCntrsRequestableResourceData newDomRsc) {
// if (newDomRsc == null) {
// // auto_update_btn.setSelection(rbdMngr.isAutoUpdate());
// auto_update_btn.setEnabled(false);
// } else if (newDomRsc.isAutoUpdateable()) {
// auto_update_btn.setEnabled(true);
// // auto_update_btn.setSelection(
// // rbdMngr.isAutoUpdate() );
// auto_update_btn.setSelection(true);
// } else {
// auto_update_btn.setSelection(false);
// auto_update_btn.setEnabled(false);
// }
// }
// });
//
// // set the list of available resources for the timeline
// // INcPaneLayout paneLayout = rbdSel.getPaneLayout();
// //
// // for (int paneIndx = 0; paneIndx <
// paneLayout.getNumberOfPanes();
// // paneIndx++) {
// // for (ResourceSelection rscSel : rbdMngr
// // .getRscsForPane((NcPaneID) paneLayout
// // .createPaneId(paneIndx))) {
// //
// // if (rbdSel.getrscSel.getResourceData() instanceof
// // AbstractNatlCntrsRequestableResourceData) {
// // timelineControl
// //
// .addAvailDomResource((AbstractNatlCntrsRequestableResourceData)
// // rscSel
// // .getResourceData());
// // }
// // }
// // }
//
// NCTimeMatcher timeMatcher = rbdSel.getTimeMatcher();
// // ArrayList<DataTime> list = new ArrayList<DataTime>();
// // DataTime time = timeMatcher.getRefTime();
// // System.out.println("***time " + time);
// // Calendar cal = (Calendar) time.getValidTime();
// // for (int i = 0; i < 720; i++) {
// // cal.add(Calendar.MINUTE, -1);
// // list.add(new DataTime((Calendar) cal.clone()));
// // }
// // timeMatcher.setFrameTimes(list);
//
// timelineControl.setTimeMatcher(timeMatcher);
// timelineControl.addAvailDomResource(timeMatcher
// .getDominantResource());
} else {
timelineControl = new TimelineControl(timeline_grp);
}
rbdSel.initTimeline();
seldRbdsList.add(rbdSel);
@ -998,4 +1099,41 @@ public class LoadRbdControl extends Composite {
editRbdDlg = null;
}
public void updateGUI(final AbstractRBD<?> rbdSel) {
if (rbdSel instanceof GraphRBD) {
timelineControl.dispose();
// shell.pack();
timelineControl = (GraphTimelineControl) new GraphTimelineControl(
timeline_grp);
// timelineControl
// .addDominantResourceChangedListener(new
// IDominantResourceChangedListener() {
// @Override
// public void dominantResourceChanged(
// AbstractNatlCntrsRequestableResourceData newDomRsc) {
// if (newDomRsc == null) {
// auto_update_btn.setSelection(rbdSel
// .isAutoUpdate());
// auto_update_btn.setEnabled(false);
// } else if (newDomRsc.isAutoUpdateable()) {
// auto_update_btn.setEnabled(true);
// // auto_update_btn.setSelection(
// // rbdMngr.isAutoUpdate() );top_comp
// auto_update_btn.setSelection(true);
// } else {
// auto_update_btn.setSelection(false);
// auto_update_btn.setEnabled(false);
// }
// }
// });
//
// timelineControl.setTimeMatcher(rbdSel.getTimeMatcher());
// timelineControl.addAvailDomResource(rbdSel.getTimeMatcher()
// .getDominantResource());
// shell.pack();
}
}
}

View file

@ -1,7 +1,6 @@
package gov.noaa.nws.ncep.viz.resourceManager.ui.manageResources;
import gov.noaa.nws.ncep.viz.common.StringListAdapter;
import gov.noaa.nws.ncep.viz.localization.NcPathManager;
import gov.noaa.nws.ncep.viz.localization.NcPathManager.NcPathConstants;
import gov.noaa.nws.ncep.viz.resourceManager.ui.manageResources.ManageResourceControl.IEditResourceComposite;
import gov.noaa.nws.ncep.viz.resources.AbstractNatlCntrsRequestableResourceData.TimeMatchMethod;
@ -40,13 +39,10 @@ import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Spinner;
import org.eclipse.swt.widgets.Text;
import com.raytheon.uf.common.localization.LocalizationContext;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
import com.raytheon.uf.common.localization.LocalizationFile;
import com.raytheon.uf.common.time.BinOffset;
import com.raytheon.uf.viz.core.exception.VizException;
/**
*
*
@ -69,7 +65,7 @@ import com.raytheon.uf.viz.core.exception.VizException;
* 04/11/13 #864 Greg Hull new TimelineGenMethods and EVENT TimeMatchMthd
* 06/10/13 #997 Greg Hull Copy AttrSets with RDs
* 07/18/13 #1011 Greg Hull Add ALL_DATA as a frameSpan option.
*
* 06/26/2014 #1136 Quan Zhou Disable dfltNumFramesLbl & dfltNumFramesSpnr when TIMESERIES
* </pre>
*
* @author
@ -77,52 +73,81 @@ import com.raytheon.uf.viz.core.exception.VizException;
*/
class EditResourceTypeComp extends Composite implements IEditResourceComposite {
ResourceDefnsMngr rscDefnMngr;
ManageResourceControl mngrControl; // the parent composite
ResourceName seldRscName = null;
ResourceDefinition seldRscDefn;
Text rscTypeTxt;
Spinner dfltNumFramesSpnr;
Spinner dfltTimeRangeDaysSpnr;
Spinner dfltTimeRangeHrsSpnr;
// Spinner timeIntervalSpnr;
Label frameIntLbl; // either 'Frame Span' or 'Default Frame Interval'
Combo frameSpanCombo;
Label minsLbl2, minsLbl3;
Group timelineGenMthdGrp;
Button useFrameIntrvlBtn;
Button useDataTimesBtn;
Button useFcstDataTimesBtn;
Button useManualTimelineBtn;
Button useFcstFrameIntrvlBtn;
// Combo timelineGenMethodCombo;
Combo timeMatchMethodCombo;
Button binDataBtn;
Spinner binStartIntrvlSpnr;
Spinner binEndIntrvlSpnr;
Label startLbl, endLbl;
Text editParamsTxt;
Label editParamsLbl;
Text filterLabelsTxt;
Label filterLabelsLbl;
Text subTypeGenTxt;
Label subTypeGenLbl;
Text rscImplTxt;
Button newTypeBtn;
Button saveTypeBtn;
Button cancelBtn;
Label dfltNumFramesLbl;
String availFrameSpanStrings[] = { // "N/A",
"1 min", "2 mins", "5 mins", "10 mins", "15 mins", "20 mins", "30 mins",
"1 hr", "90 mins", "2 hrs", "3 hrs", "6 hrs", "12 hrs", "24 hrs", "All Data" };
"1 hr", "90 mins", "2 hrs", "3 hrs", "6 hrs", "12 hrs", "24 hrs",
"All Data" };
int availFrameSpanMins[] = { // 0,
1, 2, 5, 10, 15, 20, 30, 60, 90, 120, 180, 360, 720, 1440, Integer.MAX_VALUE };
1, 2, 5, 10, 15, 20, 30, 60, 90, 120, 180, 360, 720, 1440,
Integer.MAX_VALUE };
public EditResourceTypeComp(Composite parent, int style,
ManageResourceControl mgrCtl) {
@ -130,7 +155,8 @@ class EditResourceTypeComp extends Composite implements IEditResourceComposite {
Composite top_form = this;
FormData fd = new FormData();
fd.top = new FormAttachment( 0, 12 ); // offset from sash so the title shows up
fd.top = new FormAttachment(0, 12); // offset from sash so the title
// shows up
fd.left = new FormAttachment(0, 0);
fd.right = new FormAttachment(100, 0);
fd.bottom = new FormAttachment(100, 0);
@ -165,11 +191,14 @@ class EditResourceTypeComp extends Composite implements IEditResourceComposite {
fd.left = new FormAttachment(rscTypeTxt, 35, SWT.RIGHT);
dfltNumFramesSpnr.setLayoutData(fd);
Label dfltNumFramesLbl = new Label( top_form, SWT.NONE );
dfltNumFramesLbl = new Label(top_form, SWT.NONE);
dfltNumFramesLbl.setText("Num Frames");// Default Num\nFrames");
fd = new FormData();
fd.bottom = new FormAttachment(dfltNumFramesSpnr, -3, SWT.TOP);
fd.left = new FormAttachment( dfltNumFramesSpnr, 0, SWT.LEFT ); //rscTypeTxt, 20, SWT.RIGHT );
fd.left = new FormAttachment(dfltNumFramesSpnr, 0, SWT.LEFT); // rscTypeTxt,
// 20,
// SWT.RIGHT
// );
dfltNumFramesLbl.setLayoutData(fd);
dfltNumFramesSpnr.setMinimum(1);
@ -178,7 +207,8 @@ class EditResourceTypeComp extends Composite implements IEditResourceComposite {
dfltNumFramesSpnr.setIncrement(1);
dfltNumFramesSpnr.setTextLimit(4);
editParamsTxt = new Text( top_form, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL );
editParamsTxt = new Text(top_form, SWT.MULTI | SWT.BORDER
| SWT.V_SCROLL | SWT.H_SCROLL);
fd = new FormData();
fd.height = 120;
fd.left = new FormAttachment(45, 0);
@ -195,8 +225,11 @@ class EditResourceTypeComp extends Composite implements IEditResourceComposite {
fd.right = new FormAttachment(editParamsTxt, 0, SWT.RIGHT);
editParamsLbl.setLayoutData(fd);
filterLabelsTxt = new Text( top_form, SWT.SINGLE | SWT.BORDER ); //| SWT.V_SCROLL | SWT.H_SCROLL );
filterLabelsTxt = new Text(top_form, SWT.SINGLE | SWT.BORDER); // |
// SWT.V_SCROLL
// |
// SWT.H_SCROLL
// );
fd = new FormData();
fd.height = 20;
fd.left = new FormAttachment(editParamsTxt, 0, SWT.LEFT);
@ -205,7 +238,6 @@ class EditResourceTypeComp extends Composite implements IEditResourceComposite {
filterLabelsTxt.setLayoutData(fd);
filterLabelsTxt.setToolTipText("comma-separated labels.");
filterLabelsLbl = new Label(top_form, SWT.NONE);
filterLabelsLbl.setText("Filterable Labels");
fd = new FormData();
@ -232,7 +264,6 @@ class EditResourceTypeComp extends Composite implements IEditResourceComposite {
fd.left = new FormAttachment(rscImplTxt, 0, SWT.LEFT);
rscImplLbl.setLayoutData(fd);
subTypeGenTxt = new Text(top_form, SWT.SINGLE | SWT.BORDER);
fd = new FormData();
fd.width = 140;
@ -251,7 +282,6 @@ class EditResourceTypeComp extends Composite implements IEditResourceComposite {
fd.left = new FormAttachment(subTypeGenTxt, 0, SWT.LEFT);
subTypeGenLbl.setLayoutData(fd);
frameSpanCombo = new Combo(top_form, SWT.DROP_DOWN | SWT.READ_ONLY);
fd = new FormData();
fd.top = new FormAttachment(rscTypeTxt, 40, SWT.BOTTOM);
@ -267,7 +297,6 @@ class EditResourceTypeComp extends Composite implements IEditResourceComposite {
fd.left = new FormAttachment(frameSpanCombo, 0, SWT.LEFT);
frameIntLbl.setLayoutData(fd);
dfltTimeRangeDaysSpnr = new Spinner(top_form, SWT.BORDER);
fd = new FormData();
fd.top = new FormAttachment(frameSpanCombo, 0, SWT.TOP);
@ -349,7 +378,8 @@ class EditResourceTypeComp extends Composite implements IEditResourceComposite {
gd.horizontalSpan = 2;
useFcstFrameIntrvlBtn.setLayoutData(gd);
timeMatchMethodCombo = new Combo( top_form, SWT.DROP_DOWN | SWT.READ_ONLY );
timeMatchMethodCombo = new Combo(top_form, SWT.DROP_DOWN
| SWT.READ_ONLY);
fd = new FormData();
fd.top = new FormAttachment(timelineGenMthdGrp, 40, SWT.BOTTOM);
fd.left = new FormAttachment(timelineGenMthdGrp, 0, SWT.LEFT);
@ -362,7 +392,6 @@ class EditResourceTypeComp extends Composite implements IEditResourceComposite {
fd.left = new FormAttachment(timeMatchMethodCombo, 0, SWT.LEFT);
timeMatchMthdLbl.setLayoutData(fd);
binDataBtn = new Button(top_form, SWT.CHECK);
binDataBtn.setText("Enable Binning");
fd = new FormData();
@ -371,7 +400,8 @@ class EditResourceTypeComp extends Composite implements IEditResourceComposite {
binDataBtn.setLayoutData(fd);
binDataBtn.setEnabled(false); // not implemented yet
// TODO: Remove the bin offset widgets if the frame Span is sufficient to replace it
// TODO: Remove the bin offset widgets if the frame Span is sufficient
// to replace it
binDataBtn.setVisible(false);
binStartIntrvlSpnr = new Spinner(top_form, SWT.BORDER);
@ -451,16 +481,14 @@ class EditResourceTypeComp extends Composite implements IEditResourceComposite {
fd.right = new FormAttachment(saveTypeBtn, -20, SWT.LEFT);
cancelBtn.setLayoutData(fd);
// initialize the combo boxes with selectable items.
//
for (TimeMatchMethod tmm : TimeMatchMethod.values()) {
timeMatchMethodCombo.add(tmm.toString());
}
ArrayList<String> availRscImplementations =
ResourceExtPointMngr.getInstance().getAvailResources();
ArrayList<String> availRscImplementations = ResourceExtPointMngr
.getInstance().getAvailResources();
rscTypeTxt.addModifyListener(new ModifyListener() {
@Override
@ -477,11 +505,11 @@ class EditResourceTypeComp extends Composite implements IEditResourceComposite {
if (newTextStr.isEmpty()) {
saveTypeBtn.setEnabled(false);
newTypeBtn.setEnabled(false);
}
else {
} else {
saveTypeBtn.setEnabled(true);
// if the name has been changed, the 'save' button acts as a 'Rename' or Save As
// if the name has been changed, the 'save' button acts as a
// 'Rename' or Save As
//
// disable the New button if the name hasn't been changed.
//
@ -489,15 +517,16 @@ class EditResourceTypeComp extends Composite implements IEditResourceComposite {
saveTypeBtn.setText("Save");
newTypeBtn.setEnabled(false);
}
else {
} else {
saveTypeBtn.setText("Save As");
newTypeBtn.setEnabled(true);
// disable the Save button if the new name already exists
// disable the Save button if the new name already
// exists
String rscType = newTextStr;
//ResourceDefinition.getResourceType( rscTypeTxt.getText().trim() );
// ResourceDefinition.getResourceType(
// rscTypeTxt.getText().trim() );
if (rscDefnMngr.findResourceDefinition(rscType)) {
saveTypeBtn.setEnabled(false);
@ -509,8 +538,10 @@ class EditResourceTypeComp extends Composite implements IEditResourceComposite {
useFrameIntrvlBtn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent ev) {
// frameIntervalCombo.setEnabled( useTimeIntrvlBtn.getSelection() );
// timeIntervalCombo.setVisible( useTimeIntrvlBtn.getSelection() );
// frameIntervalCombo.setEnabled(
// useTimeIntrvlBtn.getSelection() );
// timeIntervalCombo.setVisible( useTimeIntrvlBtn.getSelection()
// );
// minsLbl1.setVisible( useTimeIntrvlBtn.getSelection() );
}
});
@ -522,7 +553,8 @@ class EditResourceTypeComp extends Composite implements IEditResourceComposite {
startLbl.setVisible(binDataBtn.getSelection());
endLbl.setVisible(binDataBtn.getSelection());
minsLbl2.setVisible(binDataBtn.getSelection());
minsLbl3.setVisible( binDataBtn.getSelection() ); }
minsLbl3.setVisible(binDataBtn.getSelection());
}
});
editParamsTxt.addModifyListener(new ModifyListener() {
@ -588,7 +620,9 @@ class EditResourceTypeComp extends Composite implements IEditResourceComposite {
newTypeBtn.setVisible(true);
saveTypeBtn.setVisible(false);
rscTypeTxt.setEditable(true);
rscTypeTxt.setBackground( editParamsTxt.getBackground() ); // set white to indicate editable
rscTypeTxt.setBackground(editParamsTxt.getBackground()); // set white to
// indicate
// editable
rscTypeTxt.setText("CopyOf" + rscTypeTxt.getText());
rscTypeTxt.setSelection(0, rscTypeTxt.getText().length());
@ -611,24 +645,33 @@ class EditResourceTypeComp extends Composite implements IEditResourceComposite {
if (seldRscName.getRscType().isEmpty()) {
rscTypeTxt.setText("");
saveTypeBtn.setEnabled(false);
} else {
if (seldRscName.getRscCategory().toString().equals("TIMESERIES")) {
dfltNumFramesSpnr.setEnabled(false);
dfltNumFramesLbl.setEnabled(false);
} else {
dfltNumFramesSpnr.setEnabled(true);
dfltNumFramesLbl.setEnabled(true);
}
else {
saveTypeBtn.setEnabled(false);
seldRscDefn = new ResourceDefinition( rscDefnMngr.getResourceDefinition( seldRscName ) );
seldRscDefn = new ResourceDefinition(
rscDefnMngr.getResourceDefinition(seldRscName));
if (seldRscDefn == null) { // ????
System.out.println("Unable to get Resource Defn for:"+seldRscName );
System.out.println("Unable to get Resource Defn for:"
+ seldRscName);
return;
}
String rscTypeGen = seldRscDefn.getRscTypeGenerator();
if (rscTypeGen != null && !rscTypeGen.isEmpty()) {
rscTypeTxt.setText( seldRscName.getRscType() +
":${"+ rscTypeGen + "}");
}
else {
rscTypeTxt.setText(seldRscName.getRscType() + ":${"
+ rscTypeGen + "}");
} else {
rscTypeTxt.setText(seldRscName.getRscType());
}
@ -636,7 +679,8 @@ class EditResourceTypeComp extends Composite implements IEditResourceComposite {
int numFrames = seldRscDefn.getDfltFrameCount();
dfltNumFramesSpnr.setSelection(numFrames);
// if we let any resource select Manual timeline then we need another way to
// if we let any resource select Manual timeline then we need
// another way to
// specify 'Event-type' resources ....
TimelineGenMethod timelineMthd = seldRscDefn.getTimelineGenMethod();
@ -654,17 +698,15 @@ class EditResourceTypeComp extends Composite implements IEditResourceComposite {
if (timelineMthd == TimelineGenMethod.USE_DATA_TIMES) {
useDataTimesBtn.setSelection(true);
}
else if( timelineMthd == TimelineGenMethod.USE_CYCLE_TIME_FCST_HOURS ) {
} else if (timelineMthd == TimelineGenMethod.USE_CYCLE_TIME_FCST_HOURS) {
useFcstDataTimesBtn.setSelection(true);
}
else if( timelineMthd == TimelineGenMethod.USE_FRAME_INTERVAL ) {
} else if (timelineMthd == TimelineGenMethod.USE_FRAME_INTERVAL) {
useFrameIntrvlBtn.setSelection(true);
}
else if( timelineMthd == TimelineGenMethod.USE_MANUAL_TIMELINE ) {
} else if (timelineMthd == TimelineGenMethod.USE_MANUAL_TIMELINE) {
useManualTimelineBtn.setSelection(true);
}
// just for TAF for now. So don't let the user change it and just show
// just for TAF for now. So don't let the user change it and just
// show
else if (timelineMthd == TimelineGenMethod.USE_FCST_FRAME_INTERVAL_FROM_REF_TIME) {
useFcstFrameIntrvlBtn.setEnabled(true);
useFcstFrameIntrvlBtn.setSelection(true);
@ -683,8 +725,10 @@ class EditResourceTypeComp extends Composite implements IEditResourceComposite {
if (seldRscDefn.getTimeMatchMethod() == TimeMatchMethod.EVENT) {
useDataTimesBtn.setSelection(false); // sanity check since
useFrameIntrvlBtn.setSelection( false ); // all event resources should
useManualTimelineBtn.setSelection( true ); // be set to MANUAL anyway
useFrameIntrvlBtn.setSelection(false); // all event resources
// should
useManualTimelineBtn.setSelection(true); // be set to MANUAL
// anyway
useDataTimesBtn.setEnabled(false);
useFcstDataTimesBtn.setEnabled(false);
@ -694,13 +738,15 @@ class EditResourceTypeComp extends Composite implements IEditResourceComposite {
timeMatchMethodCombo.add(TimeMatchMethod.EVENT.toString());
timeMatchMethodCombo.select(0);
// for Event resources the frameSpan is the default Frame Interval
// for Event resources the frameSpan is the default Frame
// Interval
frameIntLbl.setText("Dflt Frame Interval");
// frameSpanCombo.add( "N/A" );
// frameSpanCombo.select(0);
frameSpanCombo.setItems(availFrameSpanStrings);
frameSpanCombo.setToolTipText("For this Event-Type resource the Default Frame Interval is \n"+
"used to set the initial Frame Interval for a Manual timeline." );
frameSpanCombo
.setToolTipText("For this Event-Type resource the Default Frame Interval is \n"
+ "used to set the initial Frame Interval for a Manual timeline.");
int frameSpan = seldRscDefn.getFrameSpan();
frameSpanCombo.deselectAll();
@ -713,17 +759,19 @@ class EditResourceTypeComp extends Composite implements IEditResourceComposite {
}
binDataBtn.setEnabled(false);
}
else {
} else {
for (TimeMatchMethod tmm : TimeMatchMethod.values()) {
timeMatchMethodCombo.add(tmm.toString());
}
TimeMatchMethod timeMatchMthd = seldRscDefn.getTimeMatchMethod();
TimeMatchMethod timeMatchMthd = seldRscDefn
.getTimeMatchMethod();
int comboIndx = 0;
for( comboIndx=0 ; comboIndx < timeMatchMethodCombo.getItemCount() ; comboIndx++ ) {
if( timeMatchMthd.toString().equals( timeMatchMethodCombo.getItem( comboIndx ) ) ) {
for (comboIndx = 0; comboIndx < timeMatchMethodCombo
.getItemCount(); comboIndx++) {
if (timeMatchMthd.toString().equals(
timeMatchMethodCombo.getItem(comboIndx))) {
timeMatchMethodCombo.select(comboIndx);
break;
}
@ -733,8 +781,9 @@ class EditResourceTypeComp extends Composite implements IEditResourceComposite {
frameIntLbl.setText("Frame Span");
frameSpanCombo.setItems(availFrameSpanStrings);
frameSpanCombo.setToolTipText("The Frame Span for a resource is the maximum range of times for "+
"data displayed in the frame." );
frameSpanCombo
.setToolTipText("The Frame Span for a resource is the maximum range of times for "
+ "data displayed in the frame.");
int frameSpan = seldRscDefn.getFrameSpan();
frameSpanCombo.deselectAll();
@ -749,7 +798,6 @@ class EditResourceTypeComp extends Composite implements IEditResourceComposite {
binDataBtn.setEnabled(true);
}
int timeRangeHrs = seldRscDefn.getDfltTimeRange(); // in hours
int timeRangeDays = timeRangeHrs / 24;
timeRangeHrs %= 24;
@ -757,19 +805,18 @@ class EditResourceTypeComp extends Composite implements IEditResourceComposite {
dfltTimeRangeDaysSpnr.setSelection(timeRangeDays);
dfltTimeRangeHrsSpnr.setSelection(timeRangeHrs);
if (seldRscDefn.getResourceParametersAsString().isEmpty()) {
editParamsTxt.setVisible(false);
editParamsLbl.setVisible(false);
}
else {
} else {
editParamsTxt.setVisible(true);
editParamsTxt.setText( seldRscDefn.getResourceParametersAsString() );
editParamsTxt.setText(seldRscDefn
.getResourceParametersAsString());
editParamsLbl.setVisible(true);
}
ResourceDefinitionFilter rdFilt = rscDefnMngr.getResourceDefnFilter(
seldRscDefn.getResourceDefnName() );
ResourceDefinitionFilter rdFilt = rscDefnMngr
.getResourceDefnFilter(seldRscDefn.getResourceDefnName());
StringListAdapter sla = new StringListAdapter();
String filtLabelsStr = "";
@ -779,21 +826,24 @@ class EditResourceTypeComp extends Composite implements IEditResourceComposite {
}
filterLabelsTxt.setText(filtLabelsStr);
filterLabelsLbl.setText("Filterable Labels ("+ rdFilt.getLocLevel().toString() +" Level)");
filterLabelsLbl.setText("Filterable Labels ("
+ rdFilt.getLocLevel().toString() + " Level)");
editParamsLbl.setText( "Edit Parameters for "+seldRscDefn.getRscImplementation() );
editParamsLbl.setText("Edit Parameters for "
+ seldRscDefn.getRscImplementation());
rscImplTxt.setText(seldRscDefn.getRscImplementation());
// if( seldRscDefn.getResourceCategory().equals( ResourceName.RadarRscCategory ) ||
// seldRscDefn.getResourceCategory().equals( ResourceName.SatelliteRscCategory ) ) {
// if( seldRscDefn.getResourceCategory().equals(
// ResourceName.RadarRscCategory ) ||
// seldRscDefn.getResourceCategory().equals(
// ResourceName.SatelliteRscCategory ) ) {
if (!seldRscDefn.getSubTypeGenerator().isEmpty()) {
// subTypeGenTxt.setEnabled( true );
subTypeGenTxt.setVisible(true);
subTypeGenLbl.setVisible(true);
subTypeGenTxt.setText(seldRscDefn.getSubTypeGenerator());
}
else {
} else {
// subTypeGenTxt.setEnabled( false );
subTypeGenTxt.setVisible(false);
subTypeGenLbl.setVisible(false);
@ -831,7 +881,8 @@ class EditResourceTypeComp extends Composite implements IEditResourceComposite {
int indx = rscTypeName.indexOf(":${");
// if there is a type generator then parse the rscType name and the name of the appending generator parameter
// if there is a type generator then parse the rscType name and the name
// of the appending generator parameter
if (indx != -1) {
rscTypeGen = rscTypeName.substring(indx + 2);
rscTypeName = rscTypeName.substring(0, indx);
@ -844,9 +895,9 @@ class EditResourceTypeComp extends Composite implements IEditResourceComposite {
if (rscDefnMngr.getResourceDefinition(rscTypeName) != null) {
MessageDialog confirmDlg = new MessageDialog(getShell(),
"Resource Exist", null,
"The Resource Type " +rscTypeName + " already exists.\n\n"+
"Enter a different name.",
"Resource Exist", null, "The Resource Type " + rscTypeName
+ " already exists.\n\n"
+ "Enter a different name.",
MessageDialog.INFORMATION, new String[] { "OK" }, 0);
confirmDlg.open();
return;
@ -856,45 +907,49 @@ class EditResourceTypeComp extends Composite implements IEditResourceComposite {
setSelectedRscDefnFromGUI(newRscDefn);
// get the filters and create an entry in the filters map and save the file
// get the filters and create an entry in the filters map and save the
// file
//
StringListAdapter strListAdptr = new StringListAdapter();
List<String> filtersList = null;
try {
filtersList = strListAdptr.unmarshal( filterLabelsTxt.getText().trim() );
}
catch (Exception e1) {
MessageDialog warnDlg = new MessageDialog( getShell(),
"Resource", null,
"Unable to parse the filters string.\n"+
"This should be a list of comma separated strings.",
filtersList = strListAdptr.unmarshal(filterLabelsTxt.getText()
.trim());
} catch (Exception e1) {
MessageDialog warnDlg = new MessageDialog(
getShell(),
"Resource",
null,
"Unable to parse the filters string.\n"
+ "This should be a list of comma separated strings.",
MessageDialog.WARNING, new String[] { "OK" }, 0);
warnDlg.open();
}
ResourceDefinitionFilter rdFilt =
rscDefnMngr.getResourceDefnFilter( seldRscDefn.getResourceDefnName() );
ResourceDefinitionFilter rdFilt = rscDefnMngr
.getResourceDefnFilter(seldRscDefn.getResourceDefnName());
rdFilt = new ResourceDefinitionFilter(
newRscDefn.getResourceDefnName(), rdFilt.getIsEnabled(), filtersList,
LocalizationLevel.USER );
rdFilt = new ResourceDefinitionFilter(newRscDefn.getResourceDefnName(),
rdFilt.getIsEnabled(), filtersList, LocalizationLevel.USER);
rscDefnMngr.setResourceDefnFilters(rdFilt);
try {
rscDefnMngr.saveResourceDefnFiltersFile();
}
catch (VizException e1) {
MessageDialog errDlg = new MessageDialog( getShell(),
"Resource", null, "Error saving a new Resource Filters File:\n"+
e1.getMessage(), MessageDialog.ERROR, new String[]{"OK"}, 0);
} catch (VizException e1) {
MessageDialog errDlg = new MessageDialog(getShell(), "Resource",
null, "Error saving a new Resource Filters File:\n"
+ e1.getMessage(), MessageDialog.ERROR,
new String[] { "OK" }, 0);
errDlg.open();
}
// if attrSetGroups apply then we will just create 1 standard attrSetGroup with nothing in
// if attrSetGroups apply then we will just create 1 standard
// attrSetGroup with nothing in
// it. The user will need to edit this later.
// TODO : allow the user to copy all (or some?) of the attributeSetGroups from the
// TODO : allow the user to copy all (or some?) of the
// attributeSetGroups from the
// original rscDefn.
String newLocFilename = seldRscDefn.getLocalizationFile().getName();
@ -904,8 +959,8 @@ class EditResourceTypeComp extends Composite implements IEditResourceComposite {
newLocFilename = newLocFilename.substring(0,
newLocFilename.lastIndexOf(File.separator));
newLocFilename = newLocFilename.substring(0,
newLocFilename.lastIndexOf(File.separator)+1 ) +
rscTypeName + File.separator + rscTypeName + ".xml";
newLocFilename.lastIndexOf(File.separator) + 1)
+ rscTypeName + File.separator + rscTypeName + ".xml";
newRscDefn.setLocalizationFile(null);
newRscDefn.setLocalizationName(newLocFilename);
@ -928,23 +983,27 @@ class EditResourceTypeComp extends Composite implements IEditResourceComposite {
}
// Copy all of the attr sets
else {
List<AttributeSet> availAttrSets = rscDefnMngr.getAttrSetsForResource(seldRscName, false );
List<AttributeSet> availAttrSets = rscDefnMngr
.getAttrSetsForResource(seldRscName, false);
for (AttributeSet attrSet : availAttrSets) {
try {
FileReader fr = new FileReader( attrSet.getFile().getFile() );
char[] attrsSetStr = new char[(int) attrSet.getFile().getFile().length()];
FileReader fr = new FileReader(attrSet.getFile()
.getFile());
char[] attrsSetStr = new char[(int) attrSet.getFile()
.getFile().length()];
fr.read(attrsSetStr);
fr.close();
rscDefnMngr.saveAttrSet(newRscDefn, attrSet.getName(), new String( attrsSetStr ) );
rscDefnMngr.saveAttrSet(newRscDefn, attrSet.getName(),
new String(attrsSetStr));
}
catch (FileNotFoundException fnf ) {
throw new VizException( "file not found for default attr set.");
}
catch (IOException ioe ) {
throw new VizException( "i/o error copying default attr set file.");
} catch (FileNotFoundException fnf) {
throw new VizException(
"file not found for default attr set.");
} catch (IOException ioe) {
throw new VizException(
"i/o error copying default attr set file.");
}
}
}
@ -958,9 +1017,8 @@ class EditResourceTypeComp extends Composite implements IEditResourceComposite {
} catch (VizException e) {
MessageDialog errDlg = new MessageDialog(getShell(),
"New Resource Type", null,
"Error Creating new Type " +rscTypeName + "\n\n"+
e.getMessage(),
"New Resource Type", null, "Error Creating new Type "
+ rscTypeName + "\n\n" + e.getMessage(),
MessageDialog.ERROR, new String[] { "OK" }, 0);
errDlg.open();
return;
@ -982,14 +1040,17 @@ class EditResourceTypeComp extends Composite implements IEditResourceComposite {
try {
String curFiltsStr = listAdpr.marshal(
rscDefnMngr.getResourceDefnFilter( seldRscDefn.getResourceDefnName() ).getFilters() ).trim();
rscDefnMngr.getResourceDefnFilter(
seldRscDefn.getResourceDefnName()).getFilters())
.trim();
if (!curFiltsStr.equals(newFiltsStr)) {
filtersChanged = true;
// save the new filters to the map and the File
ResourceDefinitionFilter rdFilt =
rscDefnMngr.getResourceDefnFilter( seldRscDefn.getResourceDefnName() );
ResourceDefinitionFilter rdFilt = rscDefnMngr
.getResourceDefnFilter(seldRscDefn
.getResourceDefnName());
rdFilt.setFilters(listAdpr.unmarshal(newFiltsStr));
rscDefnMngr.setResourceDefnFilters(rdFilt);
@ -998,8 +1059,8 @@ class EditResourceTypeComp extends Composite implements IEditResourceComposite {
} catch (Exception e) {
MessageDialog errDlg = new MessageDialog(getShell(),
"Save Resource Filters", null,
"Error Saving Filters for Rsc Defn:\n\n"+
e.getMessage(), MessageDialog.ERROR, new String[]{"OK"}, 0);
"Error Saving Filters for Rsc Defn:\n\n" + e.getMessage(),
MessageDialog.ERROR, new String[] { "OK" }, 0);
errDlg.open();
}
@ -1007,10 +1068,15 @@ class EditResourceTypeComp extends Composite implements IEditResourceComposite {
// not we don't need to save it.
if (saveRD.equals(seldRscDefn)) {
if (filtersChanged) {
MessageDialog msgDlg = new MessageDialog( getShell(),
"Saved", null,
"The Filters for " + seldRscDefn.getResourceDefnName() + " have been saved to :.\n"+
NcPathConstants.RESOURCE_FILTERS + ". No changes were made to the Rsc Defn File.",
MessageDialog msgDlg = new MessageDialog(
getShell(),
"Saved",
null,
"The Filters for "
+ seldRscDefn.getResourceDefnName()
+ " have been saved to :.\n"
+ NcPathConstants.RESOURCE_FILTERS
+ ". No changes were made to the Rsc Defn File.",
MessageDialog.INFORMATION, new String[] { "OK" }, 0);
msgDlg.open();
return;
@ -1022,7 +1088,8 @@ class EditResourceTypeComp extends Composite implements IEditResourceComposite {
int indx = rscTypeName.indexOf(":${");
// if there is a type generator then parse the rscType name and the name of the appending generator parameter
// if there is a type generator then parse the rscType name and the name
// of the appending generator parameter
if (indx != -1) {
rscTypeGen = rscTypeName.substring(indx + 2);
rscTypeName = rscTypeName.substring(0, indx);
@ -1035,10 +1102,10 @@ class EditResourceTypeComp extends Composite implements IEditResourceComposite {
LocalizationFile lFile = seldRscDefn.getLocalizationFile();
if (lFile.getContext().getLocalizationLevel() == LocalizationLevel.USER) {
MessageDialog confirmDlg = new MessageDialog( getShell(),
"Confirm", null,
"This will overwrite the current User-Level Resource Type\n"+
"Are you sure you want to do this?",
MessageDialog confirmDlg = new MessageDialog(getShell(), "Confirm",
null,
"This will overwrite the current User-Level Resource Type\n"
+ "Are you sure you want to do this?",
MessageDialog.CONFIRM, new String[] { "Yes", "No" }, 0);
confirmDlg.open();
@ -1047,7 +1114,8 @@ class EditResourceTypeComp extends Composite implements IEditResourceComposite {
}
}
// else { // create a new user-level lFile
// LocalizationContext newContext = NcPathManager.getInstance().getContext(
// LocalizationContext newContext =
// NcPathManager.getInstance().getContext(
// lFile.getContext().getLocalizationType(),
// LocalizationLevel.USER );
// lFile = NcPathManager.getInstance().getLocalizationFile( newContext,
@ -1059,17 +1127,18 @@ class EditResourceTypeComp extends Composite implements IEditResourceComposite {
rscDefnMngr.saveResourceDefn(seldRscDefn);
if (filtersChanged) {
MessageDialog msgDlg = new MessageDialog( getShell(),
"Saved", null,
"The Resource " + rscTypeName + " has been saved to a USER-level file.\n"+
"and the Filters in the "+NcPathConstants.RESOURCE_FILTERS+" file have been updated.",
MessageDialog msgDlg = new MessageDialog(getShell(), "Saved",
null, "The Resource " + rscTypeName
+ " has been saved to a USER-level file.\n"
+ "and the Filters in the "
+ NcPathConstants.RESOURCE_FILTERS
+ " file have been updated.",
MessageDialog.INFORMATION, new String[] { "OK" }, 0);
msgDlg.open();
}
else {
MessageDialog msgDlg = new MessageDialog( getShell(),
"Saved", null,
"The Resource " + rscTypeName + " has been saved.\n",
} else {
MessageDialog msgDlg = new MessageDialog(getShell(), "Saved",
null, "The Resource " + rscTypeName
+ " has been saved.\n",
MessageDialog.INFORMATION, new String[] { "OK" }, 0);
msgDlg.open();
}
@ -1077,9 +1146,9 @@ class EditResourceTypeComp extends Composite implements IEditResourceComposite {
} catch (VizException e) {
MessageDialog confirmDlg = new MessageDialog(getShell(),
"Save Resource Type", null,
"Error Writing new Resource Definitions Table\n\n"+
e.getMessage(),
MessageDialog.ERROR, new String[]{"OK"}, 0);
"Error Writing new Resource Definitions Table\n\n"
+ e.getMessage(), MessageDialog.ERROR,
new String[] { "OK" }, 0);
confirmDlg.open();
}
@ -1103,8 +1172,7 @@ class EditResourceTypeComp extends Composite implements IEditResourceComposite {
if (frameSpanCombo.getText().equals("N/A")) {
rscDefn.setFrameSpan(0);
}
else {
} else {
for (int i = 0; i < availFrameSpanStrings.length; i++) {
if (availFrameSpanStrings[i].equals(frameSpanCombo.getText())) {
rscDefn.setFrameSpan(availFrameSpanMins[i]);
@ -1115,22 +1183,18 @@ class EditResourceTypeComp extends Composite implements IEditResourceComposite {
if (useFrameIntrvlBtn.getSelection()) {
rscDefn.setTimelineGenMethod(TimelineGenMethod.USE_FRAME_INTERVAL);
}
else if( useFcstDataTimesBtn.getSelection() ) {
} else if (useFcstDataTimesBtn.getSelection()) {
rscDefn.setTimelineGenMethod(TimelineGenMethod.USE_CYCLE_TIME_FCST_HOURS);
}
else if( useDataTimesBtn.getSelection() ) {
} else if (useDataTimesBtn.getSelection()) {
rscDefn.setTimelineGenMethod(TimelineGenMethod.USE_DATA_TIMES);
}
else if( useManualTimelineBtn.getSelection() ) {
} else if (useManualTimelineBtn.getSelection()) {
rscDefn.setTimelineGenMethod(TimelineGenMethod.USE_MANUAL_TIMELINE);
}
else if( useFcstFrameIntrvlBtn.getSelection() ) {
} else if (useFcstFrameIntrvlBtn.getSelection()) {
rscDefn.setTimelineGenMethod(TimelineGenMethod.USE_FCST_FRAME_INTERVAL_FROM_REF_TIME);
}
int timeRangeHrs = dfltTimeRangeDaysSpnr.getSelection() * 24 +
dfltTimeRangeHrsSpnr.getSelection();
int timeRangeHrs = dfltTimeRangeDaysSpnr.getSelection() * 24
+ dfltTimeRangeHrsSpnr.getSelection();
rscDefn.setDfltTimeRange(timeRangeHrs);
// The GUI is in minutes and binOffset is in seconds

View file

@ -74,9 +74,12 @@ Export-Package: gov.noaa.nws.ncep.viz.resources;
Import-Package: com.raytheon.uf.common.message.response,
com.raytheon.uf.common.pointdata,
com.raytheon.uf.viz.core.maps,
com.raytheon.uf.viz.xy.graph,
com.raytheon.uf.viz.xy.timeseries.display,
com.raytheon.viz.alerts.observers,
com.raytheon.viz.core.gl,
com.raytheon.viz.core.graphing,
gov.noaa.nws.ncep.common.dataplugin.geomag,
gov.noaa.nws.ncep.common.dataplugin.mcidas,
gov.noaa.nws.ncep.common.dataplugin.ntrans,
gov.noaa.nws.ncep.common.dataplugin.pgen,
@ -84,3 +87,4 @@ Import-Package: com.raytheon.uf.common.message.response,
gov.noaa.nws.ncep.edex.plugin.mosaic.common,
gov.noaa.nws.ncep.gempak.parameters.colorbar,
gov.noaa.nws.ncep.viz.gempak.grid.inv

View file

@ -83,7 +83,7 @@ import com.raytheon.uf.viz.core.rsc.LoadProperties;
* 04/10/2013 #958 qzhou Added autoupdate for solar in isAutoUpdateable
* 07/15/2013 #1011 ghull add MATCH_ALL_DATA timeMatchMethod for PgenResource
* 06/16/2014 TTR1026 jwu sort data time for local radar in getAvailableDataTimes()
*
* 05/15/2014 #1131 qzhou Added GraphRscCategory. Added dfltGraphRange
* </pre>
*
* *
@ -143,6 +143,12 @@ public abstract class AbstractNatlCntrsRequestableResourceData extends
@XmlElement
protected int dfltNumFrames;
@XmlElement
protected int dfltGraphRange;
@XmlElement
protected int dfltHourSnap;
@XmlElement
protected int dfltTimeRange; // in hours
@ -186,6 +192,8 @@ public abstract class AbstractNatlCntrsRequestableResourceData extends
timeMatchMethod = TimeMatchMethod.CLOSEST_BEFORE_OR_AFTER;
timelineGenMethod = TimelineGenMethod.USE_DATA_TIMES;
frameSpan = 60;
dfltGraphRange = 12; // ? quan
dfltHourSnap = 3;
legendColor = new RGB(255, 255, 255);
rscExtPointMngr = ResourceExtPointMngr.getInstance();
}
@ -206,9 +214,11 @@ public abstract class AbstractNatlCntrsRequestableResourceData extends
//
public boolean isAutoUpdateable() {
ResourceCategory rscCat = getResourceName().getRscCategory();
if (rscCat != null && rscCat == ResourceCategory.SatelliteRscCategory
|| rscCat == ResourceCategory.RadarRscCategory
|| rscCat == ResourceCategory.SpaceRscCategory) {
|| rscCat == ResourceCategory.SpaceRscCategory
|| rscCat == ResourceCategory.GraphRscCategory) {
return true;
}
return false;
@ -271,6 +281,22 @@ public abstract class AbstractNatlCntrsRequestableResourceData extends
this.dfltNumFrames = dfltNumFrames;
}
public int getDfltGraphRange() {
return dfltGraphRange;
}
public void setDfltGraphRange(int dfltGraphRange) {
this.dfltGraphRange = dfltGraphRange;
}
public int getDfltHourSnap() {
return dfltHourSnap;
}
public void setDfltHourSnap(int dfltHourSnap) {
this.dfltHourSnap = dfltHourSnap;
}
public int getDfltTimeRange() {
return dfltTimeRange;
}

View file

@ -13,7 +13,6 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Set;
import java.util.TreeMap;
import java.util.concurrent.ConcurrentLinkedQueue;
@ -24,19 +23,14 @@ import com.raytheon.uf.common.time.TimeRange;
import com.raytheon.uf.viz.core.IDisplayPane;
import com.raytheon.uf.viz.core.IGraphicsTarget;
import com.raytheon.uf.viz.core.IRenderableDisplayChangedListener;
import com.raytheon.uf.viz.core.IRenderableDisplayChangedListener.DisplayChangeType;
import com.raytheon.uf.viz.core.catalog.LayerProperty;
import com.raytheon.uf.viz.core.catalog.ScriptCreator;
import com.raytheon.uf.viz.core.comm.Connector;
import com.raytheon.uf.viz.core.drawables.AbstractDescriptor;
import com.raytheon.uf.viz.core.drawables.IDescriptor;
import com.raytheon.uf.viz.core.drawables.IRenderableDisplay;
import com.raytheon.uf.viz.core.drawables.IDescriptor.FrameChangeMode;
import com.raytheon.uf.viz.core.drawables.IDescriptor.FrameChangeOperation;
import com.raytheon.uf.viz.core.drawables.IFrameCoordinator;
import com.raytheon.uf.viz.core.drawables.IRenderableDisplay;
import com.raytheon.uf.viz.core.drawables.PaintProperties;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.map.IMapDescriptor;
import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
import com.raytheon.uf.viz.core.rsc.IResourceDataChanged;
import com.raytheon.uf.viz.core.rsc.LoadProperties;
@ -59,29 +53,34 @@ import com.raytheon.uf.viz.core.rsc.ResourceType;
* 20 Mar 2012 #700 B. Hebbard In processNewRscDataList(), when new frame(s) are created by auto update,
* set frame to LAST and issueRefresh() to force paint (per legacy; TTR 520).
* 06 Feb 2013 #972 G. Hull define on IDescriptor instead of IMapDescriptor
*
* 06/16/2014 #1136 qzhou remove final for paintInternal, since paintFrame does not work for Graph
* </pre>
*
* @author ghull
* @version 1
*/
public abstract class AbstractNatlCntrsResource<T extends AbstractNatlCntrsRequestableResourceData, D extends INatlCntrsDescriptor>
extends AbstractVizResource<AbstractNatlCntrsRequestableResourceData, IDescriptor>
extends
AbstractVizResource<AbstractNatlCntrsRequestableResourceData, IDescriptor>
implements INatlCntrsResource {
// NOT USED now but may make sense to have a displayChange listener for all resources?
private class displayChangeListener implements IRenderableDisplayChangedListener {
// NOT USED now but may make sense to have a displayChange listener for all
// resources?
private class displayChangeListener implements
IRenderableDisplayChangedListener {
@Override
public void renderableDisplayChanged(IDisplayPane pane,
IRenderableDisplay newRenderableDisplay, DisplayChangeType type) {
}
}
public static interface IRscDataObject {
abstract DataTime getDataTime();
}
// a wrapper for the common case when a PluginDataObject is the resource Data Object.
// a wrapper for the common case when a PluginDataObject is the resource
// Data Object.
//
public static class DfltRecordRscDataObj implements IRscDataObject {
private PluginDataObject pdo;
@ -109,14 +108,17 @@ public abstract class AbstractNatlCntrsResource<T extends AbstractNatlCntrsReque
protected DataTime frameTime;
// for resources that need to populated the frames only when the frame is
// for resources that need to populated the frames only when the frame
// is
// first displayed.
protected boolean populated;
protected DataTime startTime; // valid times without a forecast hour
protected DataTime endTime;
protected long startTimeMillis;
protected long endTimeMillis;
// set the frame start and end time based on:
@ -126,8 +128,10 @@ public abstract class AbstractNatlCntrsResource<T extends AbstractNatlCntrsReque
// - the timeMatchMethod.
protected AbstractFrameData(DataTime ftime, int frameInterval) {
// if there is a validPeriod or levels, ignore them and just use the valid time.
this.frameTime = new DataTime( ftime.getRefTime(), ftime.getFcstTime() );
// if there is a validPeriod or levels, ignore them and just use the
// valid time.
this.frameTime = new DataTime(ftime.getRefTime(),
ftime.getFcstTime());
this.populated = false;
long frameMillis = frameTime.getValidTime().getTimeInMillis();
@ -137,29 +141,38 @@ public abstract class AbstractNatlCntrsResource<T extends AbstractNatlCntrsReque
startTime = new DataTime(frameTime.getValidTime());
endTime = new DataTime(frameTime.getValidTime());
}
// Note : Currently this is implemented the same as Exact. (ie the frame time
// must be between the start/end time of an event.) A more general algorithm
// could be implemented to use the frame span and test whether any part of the
// event overlaps with any part of the frame span. But currently, for Event resources,
// the frame span is taken as the default frame interval for a manual timeline and so
// Note : Currently this is implemented the same as Exact. (ie the
// frame time
// must be between the start/end time of an event.) A more general
// algorithm
// could be implemented to use the frame span and test whether any
// part of the
// event overlaps with any part of the frame span. But currently,
// for Event resources,
// the frame span is taken as the default frame interval for a
// manual timeline and so
// this would need to be addressed first.)
case EVENT: {
startTime = new DataTime(frameTime.getValidTime());
endTime = new DataTime(frameTime.getValidTime());
}
case CLOSEST_BEFORE_OR_AFTER: {
startTime = new DataTime( new Date(frameMillis - frameInterval*1000*60/2 ) );
endTime = new DataTime( new Date(frameMillis + frameInterval*1000*60/2-1000 ) );
startTime = new DataTime(new Date(frameMillis - frameInterval
* 1000 * 60 / 2));
endTime = new DataTime(new Date(frameMillis + frameInterval
* 1000 * 60 / 2 - 1000));
break;
}
case CLOSEST_BEFORE_OR_EQUAL: {
startTime = new DataTime( new Date(frameMillis - frameInterval*1000*60 ) );
startTime = new DataTime(new Date(frameMillis - frameInterval
* 1000 * 60));
endTime = new DataTime(frameTime.getValidTime());
break;
}
case CLOSEST_AFTER_OR_EQUAL: {
startTime = new DataTime(frameTime.getValidTime());
endTime = new DataTime( new Date(frameMillis + frameInterval*1000*60-1000 ) );
endTime = new DataTime(new Date(frameMillis + frameInterval
* 1000 * 60 - 1000));
break;
}
case BEFORE_OR_EQUAL: {
@ -183,7 +196,8 @@ public abstract class AbstractNatlCntrsResource<T extends AbstractNatlCntrsReque
return (dataTime == null ? false : timeMatch(dataTime) >= 0);
}
// return -1 if the data doesn't match. if the return value is 0 or positive
// return -1 if the data doesn't match. if the return value is 0 or
// positive
// then this is the number of seconds from the perfect match.
public long timeMatch(DataTime dataTime) {
@ -192,41 +206,49 @@ public abstract class AbstractNatlCntrsResource<T extends AbstractNatlCntrsReque
switch (resourceData.getTimeMatchMethod()) {
case MATCH_ALL_DATA : // everything is a perfect match. (for PGEN Resource)
case MATCH_ALL_DATA: // everything is a perfect match. (for PGEN
// Resource)
return 0;
case EXACT : case EVENT : {
long frameTimeMillis = frameTime.getValidTime().getTimeInMillis();
case EXACT:
case EVENT: {
long frameTimeMillis = frameTime.getValidTime()
.getTimeInMillis();
if (dataTimeRange.isValid()) {
if( dataTimeRange.getStart().getTime() <= frameTimeMillis &&
frameTimeMillis <= dataTimeRange.getEnd().getTime() ) {
if (dataTimeRange.getStart().getTime() <= frameTimeMillis
&& frameTimeMillis <= dataTimeRange.getEnd()
.getTime()) {
return 0;
}
else {
} else {
return -1;
}
}
else {
} else {
return (frameTimeMillis == dataTimeMillis ? 0 : -1);
}
}
// mainly (only?) for lightning. Might be able to remove this timeMatchMethod
// mainly (only?) for lightning. Might be able to remove this
// timeMatchMethod
// if lighting resource is modified?
case BEFORE_OR_EQUAL: {
return ( dataTimeMillis > endTimeMillis ? -1 :
(endTimeMillis-dataTimeMillis)/1000);
return (dataTimeMillis > endTimeMillis ? -1
: (endTimeMillis - dataTimeMillis) / 1000);
}
case CLOSEST_BEFORE_OR_AFTER:
case CLOSEST_BEFORE_OR_EQUAL:
case CLOSEST_AFTER_OR_EQUAL: {
// This should be an invalid case. if this is an event type resource then
// it should be an EXACT time match. Still, for now leave this logic in here.
// This should be an invalid case. if this is an event type
// resource then
// it should be an EXACT time match. Still, for now leave this
// logic in here.
if (dataTimeRange.isValid()) {
System.out.println("Timematching a dataTime with a valid interval with a non-EXACT\n "+
"TimeMatchMethod.");
System.out
.println("Timematching a dataTime with a valid interval with a non-EXACT\n "
+ "TimeMatchMethod.");
return -1;
// long dataStartTimeMillis = dataTimeRange.getStart().getTime();
// long dataEndTimeMillis = dataTimeRange.getEnd().getTime();
// long dataStartTimeMillis =
// dataTimeRange.getStart().getTime();
// long dataEndTimeMillis =
// dataTimeRange.getEnd().getTime();
//
// if( dataStartTimeMillis > endTimeMillis ||
// dataEndTimeMillis <= startTimeMillis ) {
@ -239,33 +261,32 @@ public abstract class AbstractNatlCntrsResource<T extends AbstractNatlCntrsReque
// return -1 if this is not a match.
// (since the start/end times are based on the timeMatchMethod,
// we can just check that the datatime is not within the start/end)
// we can just check that the datatime is not within the
// start/end)
//
if( startTimeMillis >= dataTimeMillis ||
dataTimeMillis > endTimeMillis ) {
if (startTimeMillis >= dataTimeMillis
|| dataTimeMillis > endTimeMillis) {
return -1;
}
//
else if( resourceData.getTimeMatchMethod() ==
TimeMatchMethod.CLOSEST_BEFORE_OR_EQUAL ) {
else if (resourceData.getTimeMatchMethod() == TimeMatchMethod.CLOSEST_BEFORE_OR_EQUAL) {
return (endTimeMillis - dataTimeMillis) / 1000;
}
else if( resourceData.getTimeMatchMethod() ==
TimeMatchMethod.CLOSEST_AFTER_OR_EQUAL ) {
} else if (resourceData.getTimeMatchMethod() == TimeMatchMethod.CLOSEST_AFTER_OR_EQUAL) {
return (dataTimeMillis - startTimeMillis) / 1000;
}
else if( resourceData.getTimeMatchMethod() ==
TimeMatchMethod.CLOSEST_BEFORE_OR_AFTER ) {
return Math.abs( frameTime.getValidTime().getTime().getTime() -
dataTimeMillis) / 1000 ;
} else if (resourceData.getTimeMatchMethod() == TimeMatchMethod.CLOSEST_BEFORE_OR_AFTER) {
return Math.abs(frameTime.getValidTime().getTime()
.getTime()
- dataTimeMillis) / 1000;
}
}
}
return -1;
}
// only return true if the data was added to the frame. It is possible for
// some resources for the data to time match but not be added because there
// only return true if the data was added to the frame. It is possible
// for
// some resources for the data to time match but not be added because
// there
// is already data in the frame that is a better match.
//
public abstract boolean updateFrameData(IRscDataObject rscDataObj);
@ -289,6 +310,7 @@ public abstract class AbstractNatlCntrsResource<T extends AbstractNatlCntrsReque
public boolean isPopulated() {
return populated;
}
public void setPopulated(boolean p) {
populated = p;
}
@ -306,8 +328,10 @@ public abstract class AbstractNatlCntrsResource<T extends AbstractNatlCntrsReque
// to one or more frames.
protected ConcurrentLinkedQueue<IRscDataObject> newRscDataObjsQueue;
// This list caches objects that are ingested and are newer than the latest frame.
// When a frame is later created due to auto updating, these objects are moved to
// This list caches objects that are ingested and are newer than the latest
// frame.
// When a frame is later created due to auto updating, these objects are
// moved to
// the newRscDataObjsQueue.
protected ArrayList<IRscDataObject> autoUpdateCache;
@ -324,7 +348,6 @@ public abstract class AbstractNatlCntrsResource<T extends AbstractNatlCntrsReque
// autoupdate on long after the next frame time has past.
private DataTime nextFrameTime = null;
protected AbstractNatlCntrsResource(T resourceData, LoadProperties props) {
super(resourceData, props);
frameDataMap = new TreeMap<Long, AbstractFrameData>();
@ -334,7 +357,8 @@ public abstract class AbstractNatlCntrsResource<T extends AbstractNatlCntrsReque
newFrameTimesList = new ArrayList<DataTime>();
currFrameTime = null;
// if requestable add a resourceChanged listener that is called by Raytheon's
// if requestable add a resourceChanged listener that is called by
// Raytheon's
// AbstractRequestableResource when update() is called.
if (resourceData instanceof AbstractNatlCntrsRequestableResourceData) {
resourceData.addChangeListener(new IResourceDataChanged() {
@ -342,13 +366,16 @@ public abstract class AbstractNatlCntrsResource<T extends AbstractNatlCntrsReque
public void resourceChanged(ChangeType type, Object object) {
if (object == null) {
System.out.println( "resourceChanged called with null object for "+
getResourceData().getResourceName().toString() );
System.out
.println("resourceChanged called with null object for "
+ getResourceData().getResourceName()
.toString());
return;
}
// TODO : need to make sure that these are the same types of
// objects that are returned by the queryRecords method (or the method
// objects that are returned by the queryRecords method (or
// the method
// that the resource uses to populate the frameData).
//
if (type == ChangeType.DATA_UPDATE) {
@ -358,15 +385,16 @@ public abstract class AbstractNatlCntrsResource<T extends AbstractNatlCntrsReque
newRscDataObjsQueue.add(dataObj);
}
}
}
else {
} else {
for (IRscDataObject dataObj : processRecord(object)) {
newRscDataObjsQueue.add(dataObj);
}
}
// can't call processNewRscDataList here since we are not in the UI thread when
// the AutoUpdater calls us and this will end up updating the status line's
// can't call processNewRscDataList here since we are
// not in the UI thread when
// the AutoUpdater calls us and this will end up
// updating the status line's
// frame time is a new frame is created.
//
autoUpdateReady = true;
@ -376,26 +404,33 @@ public abstract class AbstractNatlCntrsResource<T extends AbstractNatlCntrsReque
}
}
// the timeline (times in the timeMatcher) have changed so we must update the
// frames in the frameDataMap and process any data saved in the autoUpdateCache.
// the timeline (times in the timeMatcher) have changed so we must update
// the
// frames in the frameDataMap and process any data saved in the
// autoUpdateCache.
//
public Boolean updateTimeline() {
NCTimeMatcher timeMatcher = (NCTimeMatcher) descriptor.getTimeMatcher();
List<DataTime> newFrameTimes = timeMatcher.getFrameTimes();
// loop thru all of the new frame times and if the frameDataMap doesn't have an entry for
// loop thru all of the new frame times and if the frameDataMap doesn't
// have an entry for
// this time create a new entry.
for (DataTime frameTime : newFrameTimes) {
if( !frameDataMap.containsKey( frameTime.getValidTime().getTime().getTime() ) ) {
if (!frameDataMap.containsKey(frameTime.getValidTime().getTime()
.getTime())) {
AbstractFrameData newFrame = this.createNewFrame(frameTime,
resourceData.frameSpan);
frameDataMap.put( frameTime.getValidTime().getTime().getTime(), newFrame );
frameDataMap.put(frameTime.getValidTime().getTime().getTime(),
newFrame);
}
}
// loop thru all of the times in the frameDataMap and if the time is not in the
// loop thru all of the times in the frameDataMap and if the time is not
// in the
// new frameTimes then remove the frame from the map.
ArrayList<Long> frameTimesInMap = new ArrayList<Long>( frameDataMap.keySet() );
ArrayList<Long> frameTimesInMap = new ArrayList<Long>(
frameDataMap.keySet());
for (long frameTimeMs : frameTimesInMap) {
if (!newFrameTimes.contains(new DataTime(new Date(frameTimeMs)))) {
@ -412,22 +447,28 @@ public abstract class AbstractNatlCntrsResource<T extends AbstractNatlCntrsReque
return true;
}
// This is the default implementation for the common case where the Resource
// simply wants to process the PluginDataObject itself but some resources may
// want to override this method if a record contains more than one 'data object' and
// these objects are to be time matched. (ex. some sigmet resources have multiple sigmets
// simply wants to process the PluginDataObject itself but some resources
// may
// want to override this method if a record contains more than one 'data
// object' and
// these objects are to be time matched. (ex. some sigmet resources have
// multiple sigmets
// per record and each has a separate valid time.)
//
protected IRscDataObject[] processRecord(Object pdo) {
if (!(pdo instanceof PluginDataObject)) {
System.out.println( "Resource Impl "+getClass().getName() + " must override " +
"the processRecord method to process data objects of class: "+
pdo.getClass().getName() );
System.out
.println("Resource Impl "
+ getClass().getName()
+ " must override "
+ "the processRecord method to process data objects of class: "
+ pdo.getClass().getName());
return null;
}
DfltRecordRscDataObj rscDataObj = new DfltRecordRscDataObj( (PluginDataObject)pdo );
DfltRecordRscDataObj rscDataObj = new DfltRecordRscDataObj(
(PluginDataObject) pdo);
return new DfltRecordRscDataObj[] { rscDataObj };
}
@ -437,7 +478,8 @@ public abstract class AbstractNatlCntrsResource<T extends AbstractNatlCntrsReque
AbstractFrameData frameData = null;
if (dataTime != null) {
frameData = frameDataMap.get( dataTime.getValidTime().getTime().getTime() );
frameData = frameDataMap.get(dataTime.getValidTime().getTime()
.getTime());
}
return frameData;
}
@ -446,7 +488,8 @@ public abstract class AbstractNatlCntrsResource<T extends AbstractNatlCntrsReque
if (currFrameTime == null) {
return null;
}
return frameDataMap.get( currFrameTime.getValidTime().getTime().getTime() );
return frameDataMap.get(currFrameTime.getValidTime().getTime()
.getTime());
}
public DataTime getCurrentFrameTime() {
@ -466,11 +509,13 @@ public abstract class AbstractNatlCntrsResource<T extends AbstractNatlCntrsReque
if (super.getDescriptor() instanceof INatlCntrsDescriptor) {
return (INatlCntrsDescriptor) super.getDescriptor();
}
System.out.println("AbstractNatlCntrResource.getDescriptor() returning null????");
System.out
.println("AbstractNatlCntrResource.getDescriptor() returning null????");
return null;
}
// this should only be called by resources that are instantiated with an NcMapDescriptor
// this should only be called by resources that are instantiated with an
// NcMapDescriptor
protected NCMapDescriptor getNcMapDescriptor() {
if (getDescriptor() instanceof NCMapDescriptor) {
return (NCMapDescriptor) getDescriptor();
@ -480,66 +525,74 @@ public abstract class AbstractNatlCntrsResource<T extends AbstractNatlCntrsReque
}
//
public final void initInternal(IGraphicsTarget grphTarget) throws VizException {
public final void initInternal(IGraphicsTarget grphTarget)
throws VizException {
if (!initialized) {
// create the frameDataMap based on the timeFrames from the timeMatcher.
// create the frameDataMap based on the timeFrames from the
// timeMatcher.
// ArrayList<DataTime> frameTimes
NCTimeMatcher timeMatcher = (NCTimeMatcher)descriptor.getTimeMatcher();
NCTimeMatcher timeMatcher = (NCTimeMatcher) descriptor
.getTimeMatcher();
List<DataTime> frameTimes = timeMatcher.getFrameTimes();
for (DataTime frameTime : frameTimes) {
if (frameTime != null) {
AbstractFrameData newFrame = this.createNewFrame(frameTime,
resourceData.frameSpan);
frameDataMap.put( frameTime.getValidTime().getTime().getTime(), newFrame );
frameDataMap.put(frameTime.getValidTime().getTime()
.getTime(), newFrame);
}
}
// if using a frameInterval to generate the timeline, predict the
// time for the next frame which will be created if auto updating
if( !frameTimes.isEmpty() &&
getResourceData().getTimelineGenMethod() != TimelineGenMethod.USE_DATA_TIMES ) {
if (!frameTimes.isEmpty()
&& getResourceData().getTimelineGenMethod() != TimelineGenMethod.USE_DATA_TIMES) {
nextFrameTime = new DataTime(new Date(frameDataMap.lastKey()),
timeMatcher.getFrameInterval());
}
// This is now done in the NCMapDescriptor when the timeMatcher is set
// This is now done in the NCMapDescriptor when the timeMatcher is
// set
//
// ((AbstractDescriptor) descriptor).getTimeMatchingMap().put(
// this, frameTimes.toArray( new DataTime[0] ) );
((INatlCntrsDescriptor)descriptor).setFrameTimesForResource(
this, frameTimes.toArray( new DataTime[0] ) );
((INatlCntrsDescriptor) descriptor).setFrameTimesForResource(this,
frameTimes.toArray(new DataTime[0]));
// each resource may decide when and how to populate the frameData.
initResource(grphTarget);
initialized = true;
}
}
abstract public void initResource(IGraphicsTarget grphTarget) throws VizException;
abstract public void initResource(IGraphicsTarget grphTarget)
throws VizException;
// don't let derived classes override paintInternal. Override paintFrame()
public final void paintInternal(IGraphicsTarget target, PaintProperties paintProps)
public void paintInternal(IGraphicsTarget target, PaintProperties paintProps)
throws VizException {
if( !newRscDataObjsQueue.isEmpty() ||
(!newFrameTimesList.isEmpty() &&
getDescriptor().isAutoUpdate()) ) {
if (!newRscDataObjsQueue.isEmpty()
|| (!newFrameTimesList.isEmpty() && getDescriptor()
.isAutoUpdate())) {
processNewRscDataList();
}
if (paintProps == null || paintProps.getDataTime() == null) {
// should we still call the resource's paintFrame in case it needs to do something
// should we still call the resource's paintFrame in case it needs
// to do something
// even if there is no time?
return;
}
currFrameTime = paintProps.getDataTime();
AbstractFrameData currFrame = frameDataMap.get(
currFrameTime.getValidTime().getTime().getTime() );
AbstractFrameData currFrame = frameDataMap.get(currFrameTime
.getValidTime().getTime().getTime());
if (currFrame == null) {
System.out.println("paint(): Unable to find Frame Data for current Time "
System.out
.println("paint(): Unable to find Frame Data for current Time "
+ currFrameTime);
return;
}
@ -553,15 +606,17 @@ public abstract class AbstractNatlCntrsResource<T extends AbstractNatlCntrsReque
}
protected abstract void paintFrame(AbstractFrameData frameData,
IGraphicsTarget target, PaintProperties paintProps ) throws VizException;
IGraphicsTarget target, PaintProperties paintProps)
throws VizException;
// loop thru newDataObjectsList and update frameDataMap. If a frame for a given
// loop thru newDataObjectsList and update frameDataMap. If a frame for a
// given
// record time doesn't exist then create a new Frame
//
protected synchronized boolean processNewRscDataList() { // boolean isUpdate ) {
protected synchronized boolean processNewRscDataList() { // boolean isUpdate
// allow resources to pre process the data before it is added to the frames
// allow resources to pre process the data before it is added to the
// frames
preProcessFrameUpdate();
NCTimeMatcher timeMatcher = (NCTimeMatcher) descriptor.getTimeMatcher();
@ -572,7 +627,8 @@ public abstract class AbstractNatlCntrsResource<T extends AbstractNatlCntrsReque
boolean foundFrame = false;
boolean lastFrame = false;
// loop through the frames and add this record to all that it time matches to
// loop through the frames and add this record to all that it time
// matches to
//
for (AbstractFrameData frameData : frameDataMap.values()) {
if (frameData != null) {
@ -589,57 +645,74 @@ public abstract class AbstractNatlCntrsResource<T extends AbstractNatlCntrsReque
}
}
// if not in any frames (or if in the last frame) and if updating and if this the data is
// if not in any frames (or if in the last frame) and if updating
// and if this the data is
// newer than the latest frame then cache the data for auto update.
// NOTE: this will 'drop' (not cache) data from the initial query that doesn't match the
// selected timeline which means that if the user later enables auto-update, this data will
// not be loaded as part of the auto-update. This is by design but could be changed if the
// NOTE: this will 'drop' (not cache) data from the initial query
// that doesn't match the
// selected timeline which means that if the user later enables
// auto-update, this data will
// not be loaded as part of the auto-update. This is by design but
// could be changed if the
// user wants a different behaviour.)
// NOTE: if the data is in the last frame then it may still potentially match the next frame
// when an update occurs. (WAPITA) (Note2: the auto update code is written to update a frame even
// if it is not the last frame. (ie. data is received out of order for some reason.) but this
// will cause any non-dominant data to not be displayed on these frames because we are only
// NOTE: if the data is in the last frame then it may still
// potentially match the next frame
// when an update occurs. (WAPITA) (Note2: the auto update code is
// written to update a frame even
// if it is not the last frame. (ie. data is received out of order
// for some reason.) but this
// will cause any non-dominant data to not be displayed on these
// frames because we are only
// checking for the last frame here.)
long dataTimeMs = getDataTimeMs(rscDataObj);// rscDataObj.getDataTime().getValidTime().getTime().getTime();
if (timeMatcher.isAutoUpdateable()) {
if( (!foundFrame && autoUpdateReady &&
dataTimeMs > frameDataMap.firstKey())
|| lastFrame ) {
// if there is the possibility of auto updating (if the dominant resource
// is a satellite or radar image) then store off the data in the autoUpdateCache
if ((!foundFrame && autoUpdateReady && dataTimeMs > frameDataMap
.firstKey()) || lastFrame) {
// if there is the possibility of auto updating (if the
// dominant resource
// is a satellite or radar image) then store off the data in
// the autoUpdateCache
// and then update the timeline if auto update is enabled..
//
autoUpdateCache.add(rscDataObj);
// if this is the dominantResource, and this data is from a data update alert then
// if this is the dominantResource, and this data is from a
// data update alert then
// determine if a new frame is needed.
//
if (isDominantResource() && autoUpdateReady) {
newFrameTimesList.addAll(
timeMatcher.determineNewFrameTimes( rscDataObj.getDataTime() ) );
newFrameTimesList.addAll(timeMatcher
.determineNewFrameTimes(rscDataObj
.getDataTime()));
}
}
}
}
// allow resources to post-process the data after it is added to the frames
// allow resources to post-process the data after it is added to the
// frames
postProcessFrameUpdate();
autoUpdateReady = false;
// if there is data in the auto update cache and if auto update is now enabled
// if there is data in the auto update cache and if auto update is now
// enabled
// and if this is the dominant resource for the timeline then we need to
// update the timeline and process the data in the cache.
//
if( !newFrameTimesList.isEmpty() &&
getDescriptor().isAutoUpdate() ) {
// timeMatcher.updateTimeline(newFrameTimesList);
if (!newFrameTimesList.isEmpty() && getDescriptor().isAutoUpdate()) {
// update the list of times in the timeMatcher.
// this will then trigger the descriptor to update its datatimes and
// notify its resources (including this one) to create and update the frames
// notify its resources (including this one) to create and update
// the frames
timeMatcher.updateTimeline(newFrameTimesList);
newFrameTimesList.clear();
// advance to the new last frame (per legacy; could change)...
descriptor.getFrameCoordinator().changeFrame(
@ -671,7 +744,8 @@ public abstract class AbstractNatlCntrsResource<T extends AbstractNatlCntrsReque
protected abstract AbstractFrameData createNewFrame(DataTime frameTime,
int frameInterval);
// This method can be used as a convenience if the MetadataMap constraints are
// This method can be used as a convenience if the MetadataMap constraints
// are
// all that is needed to query the data.
public void queryRecords() throws VizException {
@ -704,18 +778,21 @@ public abstract class AbstractNatlCntrsResource<T extends AbstractNatlCntrsReque
public boolean isDominantResource() {
NCTimeMatcher timeMatcher = (NCTimeMatcher) descriptor.getTimeMatcher();
if( timeMatcher != null &&
timeMatcher.getDominantResourceName() != null ) {
if (timeMatcher != null
&& timeMatcher.getDominantResourceName() != null) {
String domRscName = timeMatcher.getDominantResourceName().toString();
String domRscName = timeMatcher.getDominantResourceName()
.toString();
if( domRscName.equals( getResourceData().getResourceName().toString() ) ) {
if (domRscName.equals(getResourceData().getResourceName()
.toString())) {
return true;
}
}
return false;
}
protected void removeAllNewDataObjects() {
newRscDataObjsQueue.clear();
}
@ -726,7 +803,8 @@ public abstract class AbstractNatlCntrsResource<T extends AbstractNatlCntrsReque
public final void remove(DataTime dataTime) {
// super.remove( dataTime );
// remove the given frame and call dispose
// will the system call this for each resource removed? Need all resources to be in sync.
// will the system call this for each resource removed? Need all
// resources to be in sync.
}
// let the resource refresh and do anything else it needs to do after

View file

@ -1,27 +1,25 @@
package gov.noaa.nws.ncep.viz.resources;
import gov.noaa.nws.ncep.viz.common.RGBColorAdapter;
import gov.noaa.nws.ncep.viz.common.display.NcDisplayType;
import gov.noaa.nws.ncep.viz.resources.attributes.ResourceAttrSet;
import gov.noaa.nws.ncep.viz.resources.attributes.ResourceAttrSet.RscAttrValue;
import gov.noaa.nws.ncep.viz.resources.attributes.ResourceExtPointMngr;
import gov.noaa.nws.ncep.viz.resources.attributes.ResourceExtPointMngr.ResourceParamInfo;
import gov.noaa.nws.ncep.viz.resources.attributes.ResourceExtPointMngr.ResourceParamType;
import gov.noaa.nws.ncep.viz.resources.manager.ResourceName;
import gov.noaa.nws.ncep.viz.resources.manager.ResourceName.ResourceNameAdapter;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Set;
import gov.noaa.nws.ncep.viz.common.RGBColorAdapter;
import gov.noaa.nws.ncep.viz.common.display.NcDisplayType;
import gov.noaa.nws.ncep.viz.resources.attributes.ResourceAttrSet;
import gov.noaa.nws.ncep.viz.resources.attributes.ResourceExtPointMngr;
import gov.noaa.nws.ncep.viz.resources.attributes.ResourceAttrSet.RscAttrValue;
import gov.noaa.nws.ncep.viz.resources.attributes.ResourceExtPointMngr.ResourceParamInfo;
import gov.noaa.nws.ncep.viz.resources.attributes.ResourceExtPointMngr.ResourceParamType;
import gov.noaa.nws.ncep.viz.resources.manager.ResourceName;
import gov.noaa.nws.ncep.viz.resources.manager.ResourceName.ResourceNameAdapter;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapters;
import org.eclipse.swt.graphics.RGB;
@ -31,20 +29,22 @@ import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.rsc.AbstractResourceData;
import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
import com.raytheon.uf.viz.core.rsc.LoadProperties;
import com.raytheon.uf.viz.core.rsc.capabilities.ColorableCapability;
/**
* This is the abstract class for all Natl Cntrs (non-requestable) resources. It is very similar to
* the AbstractNatlCntrsRequestableResourceData class with the only real difference being that it
* extends AbstractResourceData instead of AbstractRequestableResourceData.
* The main purpose of this class is to manage the resource's attributes which are stored in a
* named ResourceAttrSet (currently the .prm files) The values in the attrSet can be loaded to and
* from the ResourceData. The edit Attributes dialog uses this to get the attribute values from
* the resource. When an RBD is being created the attribute values are stored in the .prm file and
* in a ResourceData and both are written out to the RBD file along with a flag indicating whether
* the attribute values were edited from the original named attribute set. When the RBD is loaded
* the resource uses this flag to use either the values in the .prm file at load time (which may
* have changed from when the RBD was created) or from the unmarshalled resource.
* This is the abstract class for all Natl Cntrs (non-requestable) resources. It
* is very similar to the AbstractNatlCntrsRequestableResourceData class with
* the only real difference being that it extends AbstractResourceData instead
* of AbstractRequestableResourceData. The main purpose of this class is to
* manage the resource's attributes which are stored in a named ResourceAttrSet
* (currently the .prm files) The values in the attrSet can be loaded to and
* from the ResourceData. The edit Attributes dialog uses this to get the
* attribute values from the resource. When an RBD is being created the
* attribute values are stored in the .prm file and in a ResourceData and both
* are written out to the RBD file along with a flag indicating whether the
* attribute values were edited from the original named attribute set. When the
* RBD is loaded the resource uses this flag to use either the values in the
* .prm file at load time (which may have changed from when the RBD was created)
* or from the unmarshalled resource.
*
* <pre>
*
@ -59,20 +59,24 @@ import com.raytheon.uf.viz.core.rsc.capabilities.ColorableCapability;
* Feb 22, 2013 972 ghull getSupportedDisplayTypes
*
* </pre>
*
* *
*
* @author ghull
* @version 1.0
*/
@XmlAccessorType(XmlAccessType.NONE)
public abstract class AbstractNatlCntrsResourceData extends AbstractResourceData
implements INatlCntrsResourceData, ISerializableObject{
public abstract class AbstractNatlCntrsResourceData extends
AbstractResourceData implements INatlCntrsResourceData,
ISerializableObject {
@XmlElement
@XmlJavaTypeAdapter(RGBColorAdapter.class)
protected RGB legendColor;
// if true then the attribute values are stored in the member variables, if false then
// if true then the attribute values are stored in the member variables, if
// false then
// the attribute values are stored in the rscAttrSet.
@XmlAttribute
protected boolean isEdited;
@ -107,7 +111,8 @@ public abstract class AbstractNatlCntrsResourceData extends AbstractResourceData
return new NcDisplayType[] { NcDisplayType.NMAP_DISPLAY };
}
// Version can be used to test whether an RBD was created with an older version of the resource
// Version can be used to test whether an RBD was created with an older
// version of the resource
// Currently this is not enforced or implemented by any of the resources.
public String getResourceVersion() {
return resourceVersion;
@ -135,30 +140,40 @@ public abstract class AbstractNatlCntrsResourceData extends AbstractResourceData
}
@Override
public AbstractVizResource<?, ?> construct( LoadProperties loadProperties, IDescriptor descriptor)
throws VizException {
AbstractVizResource<?, ?> rsc = constructResource( loadProperties, descriptor );
public AbstractVizResource<?, ?> construct(LoadProperties loadProperties,
IDescriptor descriptor) throws VizException {
AbstractVizResource<?, ?> rsc = constructResource(loadProperties,
descriptor);
// store off the resource. Currently this is done only to be able to update the color
// store off the resource. Currently this is done only to be able to
// update the color
// capability when the color attribute is changed.
if (rsc instanceof INatlCntrsResource) {
// The current design assumes that each ResourceData will only create one Resource. If this
// needs to change then we will either need to store a list of ncRscs or create a new
// AbstractNatlCntrsResource class and put the color update code in it.
// The current design assumes that each ResourceData will only
// create one Resource. If this
// needs to change then we will either need to store a list of
// ncRscs or create a new
// AbstractNatlCntrsResource class and put the color update code in
// it.
if (ncRsc != null) {
System.out.println("Sanity Check: ncRsc != null. A ResourceData is attempting to construct ");
System.out
.println("Sanity Check: ncRsc != null. A ResourceData is attempting to construct ");
System.out.println(" a resource that already exists. ");
}
ncRsc = rsc;
}
else {
System.out.println("A NatlCntrsResourceData is constructing a non-NatlCntrs Resource???");
} else {
System.out
.println("A NatlCntrsResourceData is constructing a non-NatlCntrs Resource???");
}
// if this resource was not edited (ie attribute values changed from the original values in
// the rscAttrSet) then get the values from the rscAttrSet and set the member variables with them.
// In other words, if the attribute values in the rscAttrSet were changed from the time when the
// RBD was created to now we will use the current values.) (This behaviour could be change to
// if this resource was not edited (ie attribute values changed from the
// original values in
// the rscAttrSet) then get the values from the rscAttrSet and set the
// member variables with them.
// In other words, if the attribute values in the rscAttrSet were
// changed from the time when the
// RBD was created to now we will use the current values.) (This
// behaviour could be change to
// only apply to the default attrSet if we wanted to.)
//
// if( rscAttrSet == null && rscAttrSetName != null ) {
@ -167,35 +182,41 @@ public abstract class AbstractNatlCntrsResourceData extends AbstractResourceData
//
// if( rscAttrSet != null ) {
// if( isEdited ) {
// // if the attributes were edited then the values in rscAttrSet are different so update them
// // here. (Note: currently this is not required. We could instead just not create an attrSet.)
// // Or we might want to change the name to prevent inadvertant writing out of edited attributes to
// // if the attributes were edited then the values in rscAttrSet are
// different so update them
// // here. (Note: currently this is not required. We could instead just
// not create an attrSet.)
// // Or we might want to change the name to prevent inadvertant writing
// out of edited attributes to
// // the file.)
// getResourceAttrValues( rscAttrSet );
// }
//
// // call setRscAttrSet instead of setResourceAttrValues since
// // setRscAttrSet may be overridden. This is the case for the overlayResourceGroup and
// // this is how the component maps for the group are updated with the attributes for the group.
// // setRscAttrSet may be overridden. This is the case for the
// overlayResourceGroup and
// // this is how the component maps for the group are updated with the
// attributes for the group.
// setRscAttrSet( rscAttrSet );
// }
return rsc;
}
public abstract AbstractVizResource<?, ?> constructResource( LoadProperties loadProperties,
IDescriptor descriptor) throws VizException ;
public abstract AbstractVizResource<?, ?> constructResource(
LoadProperties loadProperties, IDescriptor descriptor)
throws VizException;
// get a list of the defined attributes for this resource and
//
public ResourceAttrSet getRscAttrSet() {
HashMap<String,ResourceParamInfo> rscImplParamInfo =
rscExtPointMngr.getParameterInfoForRscImplementation( getResourceName() );
HashMap<String, ResourceParamInfo> rscImplParamInfo = rscExtPointMngr
.getParameterInfoForRscImplementation(getResourceName());
if (rscImplParamInfo == null) {
System.out.println("Couldn't find rsc impl parameter info for "+getResourceName() );
System.out.println("Couldn't find rsc impl parameter info for "
+ getResourceName());
return null;
}
@ -211,18 +232,21 @@ public abstract class AbstractNatlCntrsResourceData extends AbstractResourceData
Method[] mthds = this.getClass().getDeclaredMethods();
String attrName = prmInfo.getParamName();
String getMthdName = "get"+attrName.substring(0,1).toUpperCase() +
attrName.substring(1);
String getMthdName = "get" + attrName.substring(0, 1).toUpperCase()
+ attrName.substring(1);
for (Method m : mthds) {
if (m.getName().equals(getMthdName)) {
Class<?>[] params = m.getParameterTypes();
Class<?> rtype = m.getReturnType();
// This would be a nice sanity check but I would have to go back and change all ints and booleans
// in the getters and setters for old resources even though they are compatible with the defined classes
// This would be a nice sanity check but I would have to go
// back and change all ints and booleans
// in the getters and setters for old resources even though
// they are compatible with the defined classes
// if( rtype != attrInfo.getAttrClass() ) {
// System.out.println("Warning: Attribute "+attrName +" is not defined\n"+
// System.out.println("Warning: Attribute "+attrName
// +" is not defined\n"+
// "as correct type:" +rtype.getName() + " != " +
// attrInfo.getAttrClass().getName() );
// }
@ -265,7 +289,6 @@ public abstract class AbstractNatlCntrsResourceData extends AbstractResourceData
return rscAttrSet;
}
// the rscAttrSet should only contain attributes defined for this resource.
//
public boolean setRscAttrSet(ResourceAttrSet newRscAttrSet) {
@ -273,15 +296,17 @@ public abstract class AbstractNatlCntrsResourceData extends AbstractResourceData
return false;
}
HashMap<String,ResourceParamInfo> rscImplParamInfo =
rscExtPointMngr.getParameterInfoForRscImplementation( getResourceName() );
HashMap<String, ResourceParamInfo> rscImplParamInfo = rscExtPointMngr
.getParameterInfoForRscImplementation(getResourceName());
if (rscImplParamInfo == null) {
System.out.println("Couldn't find rsc impl parameter info for "+getResourceName() );
System.out.println("Couldn't find rsc impl parameter info for "
+ getResourceName());
return false;
}
// loop thru the attributes and use Java Bean utils to set the attributes on the resource
// loop thru the attributes and use Java Bean utils to set the
// attributes on the resource
for (ResourceParamInfo prmInfo : rscImplParamInfo.values()) {
if (prmInfo.getParamType() != ResourceParamType.EDITABLE_ATTRIBUTE) {
@ -300,17 +325,17 @@ public abstract class AbstractNatlCntrsResourceData extends AbstractResourceData
Class<?> attrClass = rscAttr.getAttrClass();
if (attrClass != prmInfo.getParamClass()) {
System.out.println("Unable to set Attribute "+attrName+" because it is defined as "+
" the wrong type: "+attrClass.getName()+" != "+
prmInfo.getParamClass().getName() );
System.out.println("Unable to set Attribute " + attrName
+ " because it is defined as " + " the wrong type: "
+ attrClass.getName() + " != "
+ prmInfo.getParamClass().getName());
continue;
}
else if( attrValue == null ) {
} else if (attrValue == null) {
continue;
}
String setMthdName = "set"+attrName.substring(0,1).toUpperCase() +
attrName.substring(1);
String setMthdName = "set" + attrName.substring(0, 1).toUpperCase()
+ attrName.substring(1);
Method[] mthds = this.getClass().getDeclaredMethods();
@ -319,13 +344,17 @@ public abstract class AbstractNatlCntrsResourceData extends AbstractResourceData
Class<?>[] params = m.getParameterTypes();
Class<?> rtype = m.getReturnType();
// This would be a nice sanity check but I would have to go back and change all ints and booleans
// in the getters and setters for old resources even though they are compatible with the defined classes
// This would be a nice sanity check but I would have to go
// back and change all ints and booleans
// in the getters and setters for old resources even though
// they are compatible with the defined classes
// if( params[0].getClass() != attrInfo.getAttrClass() ||
// params.length != 1) {
// System.out.println("Error setting rsc attr "+attrName+" : setter class " +
// System.out.println("Error setting rsc attr "+attrName+" : setter class "
// +
// "has incompatible argument.");
// System.out.println("Warning: Attribute "+attrName +" is not defined\n"+
// System.out.println("Warning: Attribute "+attrName
// +" is not defined\n"+
// "as correct type:" +rtype.getName() + " != " +
// attrInfo.getAttrClass().getName() );
// continue;

View file

@ -71,6 +71,7 @@ import com.raytheon.viz.ui.editor.AbstractEditor;
* 05/14/13 #862 Greg Hull implement INatlCntrsPaneManager
* 11/21/13 #1066 Greg Hull save off Native gridGeometries during clone()
* 10/29/13 #2491 bsteffen Use custom JAXB context instead of SerializationUtil.
* 05/15/2014 #1131 Quan Zhou Added GRAPH_DISPLAY.
* </pre>
*
* @author ghull
@ -78,7 +79,8 @@ import com.raytheon.viz.ui.editor.AbstractEditor;
*/
@XmlRootElement
@XmlAccessorType(XmlAccessType.NONE)
public abstract class AbstractRBD<T extends AbstractRenderableDisplay> implements INatlCntrsPaneManager, Comparable<AbstractRBD<?>> {
public abstract class AbstractRBD<T extends AbstractRenderableDisplay>
implements INatlCntrsPaneManager, Comparable<AbstractRBD<?>> {
private static JAXBManager jaxb;
@XmlElement
@ -152,7 +154,8 @@ public abstract class AbstractRBD<T extends AbstractRenderableDisplay> implement
this.autoUpdate = autoUpdate;
for (T disp : getDisplays()) {
if (disp != null) {
((INatlCntrsDescriptor) disp.getDescriptor()).setAutoUpdate(autoUpdate);
((INatlCntrsDescriptor) disp.getDescriptor())
.setAutoUpdate(autoUpdate);
}
}
}
@ -206,7 +209,8 @@ public abstract class AbstractRBD<T extends AbstractRenderableDisplay> implement
@Override
public IPaneLayoutable getPane(INcPaneID pid) {
if (paneLayout.containsPaneId(pid) && paneLayout.getPaneIndex(pid) < displays.length) {
if (paneLayout.containsPaneId(pid)
&& paneLayout.getPaneIndex(pid) < displays.length) {
T pane = displays[paneLayout.getPaneIndex(pid)];
@ -255,7 +259,8 @@ public abstract class AbstractRBD<T extends AbstractRenderableDisplay> implement
// ncEditor = null;
setPaneLayout(paneLayout);
try {
displays = (T[]) NcDisplayMngr.createDisplaysForNcDisplayType(this, paneLayout);
displays = (T[]) NcDisplayMngr.createDisplaysForNcDisplayType(this,
paneLayout);
} catch (VizException e) {
System.out.println(e.getMessage());
}
@ -263,7 +268,8 @@ public abstract class AbstractRBD<T extends AbstractRenderableDisplay> implement
// protected abstract T[] createDisplays( int num );
public static AbstractRBD<?> clone(AbstractRBD<?> rbdBndl) throws VizException {
public static AbstractRBD<?> clone(AbstractRBD<?> rbdBndl)
throws VizException {
try {
NCTimeMatcher tm = new NCTimeMatcher(rbdBndl.getTimeMatcher());
@ -285,13 +291,17 @@ public abstract class AbstractRBD<T extends AbstractRenderableDisplay> implement
NcGridGeometryAdapter geomAdapter = new NcGridGeometryAdapter();
for (AbstractRenderableDisplay disp : rbdBndl.getDisplays()) {
GeneralGridGeometry geom = disp.getDescriptor().getGridGeometry();
GeneralGridGeometry geom = disp.getDescriptor()
.getGridGeometry();
if (geom.getEnvelope().getCoordinateReferenceSystem().getName().toString().startsWith("MCIDAS")) {
if (geom.getEnvelope().getCoordinateReferenceSystem().getName()
.toString().startsWith("MCIDAS")) {
GridGeometrySerialized ggs = geomAdapter.marshal(geom);
ggsMap.put(((INatlCntrsRenderableDisplay) disp).getPaneId().toString(), ggs);
dispMap.put(((INatlCntrsRenderableDisplay) disp).getPaneId().toString(), disp);
ggsMap.put(((INatlCntrsRenderableDisplay) disp).getPaneId()
.toString(), ggs);
dispMap.put(((INatlCntrsRenderableDisplay) disp)
.getPaneId().toString(), disp);
// DefaultProjectedCRS pCRS =
// (DefaultProjectedCRS)geom.getCoordinateReferenceSystem();
// String crsWkt = pCRS.toWKT();
@ -299,18 +309,25 @@ public abstract class AbstractRBD<T extends AbstractRenderableDisplay> implement
// ((INatlCntrsRenderableDisplay)disp).getPaneId().toString(),
// crsWkt );
// something valid as a placeholder....
disp.getDescriptor().setGridGeometry(PredefinedAreaFactory.getDefaultPredefinedAreaForDisplayType(rbdBndl.getDisplayType()).getGridGeometry());
disp.getDescriptor().setGridGeometry(
PredefinedAreaFactory
.getDefaultPredefinedAreaForDisplayType(
rbdBndl.getDisplayType())
.getGridGeometry());
}
}
getJaxbManager().marshalToXmlFile(rbdBndl, tempRbdFile.getAbsolutePath());
getJaxbManager().marshalToXmlFile(rbdBndl,
tempRbdFile.getAbsolutePath());
AbstractRBD<?> clonedRbd = getRbd(tempRbdFile);
for (AbstractRenderableDisplay disp : clonedRbd.getDisplays()) {
String ggsKey = ((INatlCntrsRenderableDisplay) disp).getPaneId().toString();
String ggsKey = ((INatlCntrsRenderableDisplay) disp)
.getPaneId().toString();
if (ggsMap.containsKey(ggsKey)) {
GeneralGridGeometry geom = geomAdapter.unmarshal(ggsMap.get(ggsKey));
GeneralGridGeometry geom = geomAdapter.unmarshal(ggsMap
.get(ggsKey));
disp.getDescriptor().setGridGeometry(geom);
// another copy (should we save the original and set it
@ -348,7 +365,8 @@ public abstract class AbstractRBD<T extends AbstractRenderableDisplay> implement
} catch (JAXBException e) {
throw new VizException(e);
} catch (VizException e) {
throw new VizException("Error loading rbd " + rbdBndl.rbdName + " :" + e.getMessage());
throw new VizException("Error loading rbd " + rbdBndl.rbdName
+ " :" + e.getMessage());
} catch (IOException e) { // from createTempFile
throw new VizException(e);
} catch (Exception e) {
@ -356,7 +374,8 @@ public abstract class AbstractRBD<T extends AbstractRenderableDisplay> implement
}
}
public static AbstractRBD<?> createEmptyRbdForDisplayType(NcDisplayType dispType, NcPaneLayout pLayout) throws VizException {
public static AbstractRBD<?> createEmptyRbdForDisplayType(
NcDisplayType dispType, NcPaneLayout pLayout) throws VizException {
AbstractRBD<?> rbd = null;
switch (dispType) {
@ -371,6 +390,10 @@ public abstract class AbstractRBD<T extends AbstractRenderableDisplay> implement
rbd = new SolarRBD(pLayout);
rbd.setRbdName("Solar");
break;
case GRAPH_DISPLAY:
rbd = new GraphRBD(pLayout);
rbd.setRbdName("Graph");
break;
}
rbd.setIsDefaultRbd(true);
@ -381,15 +404,19 @@ public abstract class AbstractRBD<T extends AbstractRenderableDisplay> implement
}
private void createDisplays() throws VizException {
displays = (T[]) NcDisplayMngr.createDisplaysForNcDisplayType(this, getPaneLayout());
displays = (T[]) NcDisplayMngr.createDisplaysForNcDisplayType(this,
getPaneLayout());
}
public static AbstractRBD<?> createRbdFromEditor(AbstractEditor ncEditor) throws VizException {
public static AbstractRBD<?> createRbdFromEditor(AbstractEditor ncEditor)
throws VizException {
if (ncEditor == null) {
return null;
}
AbstractRBD<?> rbd = createEmptyRbdForDisplayType(NcEditorUtil.getNcDisplayType(ncEditor), (NcPaneLayout) NcEditorUtil.getPaneLayout(ncEditor));
AbstractRBD<?> rbd = createEmptyRbdForDisplayType(
NcEditorUtil.getNcDisplayType(ncEditor),
(NcPaneLayout) NcEditorUtil.getPaneLayout(ncEditor));
rbd.initRbdFromEditor(ncEditor);
@ -418,10 +445,12 @@ public abstract class AbstractRBD<T extends AbstractRenderableDisplay> implement
geoSyncedPanes = NcEditorUtil.arePanesGeoSynced(ncEditor);
autoUpdate = NcEditorUtil.getAutoUpdate(ncEditor);
displays = (T[]) NcDisplayMngr.createDisplaysForNcDisplayType(this, NcEditorUtil.getPaneLayout(ncEditor));
displays = (T[]) NcDisplayMngr.createDisplaysForNcDisplayType(this,
NcEditorUtil.getPaneLayout(ncEditor));
for (int paneIndx = 0; paneIndx < paneLayout.getNumberOfPanes(); paneIndx++) {
IDisplayPane pane = NcEditorUtil.getDisplayPane(ncEditor, paneLayout.createPaneId(paneIndx));// new NcPaneID(r, c));
IDisplayPane pane = NcEditorUtil.getDisplayPane(ncEditor,
paneLayout.createPaneId(paneIndx));// new NcPaneID(r, c));
T rDispPane = (T) pane.getRenderableDisplay();
@ -431,7 +460,8 @@ public abstract class AbstractRBD<T extends AbstractRenderableDisplay> implement
displays[paneIndx] = rDispPane;
}
setTimeMatcher(new NCTimeMatcher((NCTimeMatcher) displays[0].getDescriptor().getTimeMatcher()));
setTimeMatcher(new NCTimeMatcher((NCTimeMatcher) displays[0]
.getDescriptor().getTimeMatcher()));
}
/**
@ -460,11 +490,13 @@ public abstract class AbstractRBD<T extends AbstractRenderableDisplay> implement
//
public INatlCntrsRenderableDisplay getDisplayPane(INcPaneID pid) {
if (!paneLayout.containsPaneId(pid)) {
System.out.println("NcMapRBD.getDisplayPane: pane id " + pid.toString() + " is out of range.");
System.out.println("NcMapRBD.getDisplayPane: pane id "
+ pid.toString() + " is out of range.");
return null;
}
//
return (INatlCntrsRenderableDisplay) displays[paneLayout.getPaneIndex(pid)];
return (INatlCntrsRenderableDisplay) displays[paneLayout
.getPaneIndex(pid)];
}
public abstract boolean addDisplayPane(T dispPane, NcPaneID pid);
@ -524,7 +556,8 @@ public abstract class AbstractRBD<T extends AbstractRenderableDisplay> implement
// TODO : change/move this to be able to get user-based default RBDs.
//
public static AbstractRBD<?> getDefaultRBD(NcDisplayType displayType) throws VizException {
public static AbstractRBD<?> getDefaultRBD(NcDisplayType displayType)
throws VizException {
String dfltRbdName = "";
@ -539,18 +572,27 @@ public abstract class AbstractRBD<T extends AbstractRenderableDisplay> implement
// one.
case NTRANS_DISPLAY:
dfltRbdName = null; // NcPathConstants.DFLT_NTRANS_RBD;
return AbstractRBD.createEmptyRbdForDisplayType(displayType, new NcPaneLayout(1, 1));
return AbstractRBD.createEmptyRbdForDisplayType(displayType,
new NcPaneLayout(1, 1));
case SOLAR_DISPLAY:
dfltRbdName = null; // NcPathConstants.DFLT_SOLAR_RBD;
return AbstractRBD.createEmptyRbdForDisplayType(displayType, new NcPaneLayout(1, 1));
return AbstractRBD.createEmptyRbdForDisplayType(displayType,
new NcPaneLayout(1, 1));
case GRAPH_DISPLAY:
dfltRbdName = null;
return AbstractRBD.createEmptyRbdForDisplayType(displayType,
new NcPaneLayout(1, 1));
default:
throw new VizException("Unable to find the default RBD name for " + displayType.toString());
throw new VizException("Unable to find the default RBD name for "
+ displayType.toString());
}
File rbdFile = NcPathManager.getInstance().getStaticFile(dfltRbdName);
if (rbdFile == null) {
throw new VizException("Unable to find the default RBD file for " + displayType.toString());
throw new VizException("Unable to find the default RBD file for "
+ displayType.toString());
}
try {
@ -564,7 +606,8 @@ public abstract class AbstractRBD<T extends AbstractRenderableDisplay> implement
return clone(dfltRbd);
} catch (Exception ve) {
throw new VizException("Error getting default RBD: " + ve.getMessage());
throw new VizException("Error getting default RBD: "
+ ve.getMessage());
}
}
@ -577,7 +620,8 @@ public abstract class AbstractRBD<T extends AbstractRenderableDisplay> implement
// older version)
//
if (rbd.displays == null || rbd.displays.length == 0) {
throw new VizException("Error unmarshalling RBD: the renderable display list is null");
throw new VizException(
"Error unmarshalling RBD: the renderable display list is null");
}
// getInitialArea can't return null.
// for( AbstractRenderableDisplay d : rbd.getDisplays() ) {
@ -611,7 +655,8 @@ public abstract class AbstractRBD<T extends AbstractRenderableDisplay> implement
*
* @throws VizException
*/
private static AbstractRBD<?> unmarshalRBD(File fileName, Map<String, String> variables) throws VizException {
private static AbstractRBD<?> unmarshalRBD(File fileName,
Map<String, String> variables) throws VizException {
String s = null;
try {
FileReader fr = new FileReader(fileName);
@ -642,12 +687,15 @@ public abstract class AbstractRBD<T extends AbstractRenderableDisplay> implement
*
* @throws VizException
*/
private static AbstractRBD<?> unmarshalRBD(String bundleStr, Map<String, String> variables) throws VizException {
private static AbstractRBD<?> unmarshalRBD(String bundleStr,
Map<String, String> variables) throws VizException {
try {
String substStr = VariableSubstitutionUtil.processVariables(bundleStr, variables);
String substStr = VariableSubstitutionUtil.processVariables(
bundleStr, variables);
AbstractRBD<?> b = (AbstractRBD<?>) getJaxbManager().unmarshalFromXml(substStr);
AbstractRBD<?> b = (AbstractRBD<?>) getJaxbManager()
.unmarshalFromXml(substStr);
if (b == null) {
System.out.println("Unmarshalled rbd file is not a valid RBD?");
@ -726,16 +774,20 @@ public abstract class AbstractRBD<T extends AbstractRenderableDisplay> implement
* @throws JAXBException
* if there are illegal JAXB annotations.
*/
public static synchronized JAXBManager getJaxbManager() throws JAXBException {
public static synchronized JAXBManager getJaxbManager()
throws JAXBException {
if (jaxb == null) {
SubClassLocator locator = new SubClassLocator();
Collection<Class<?>> classes = JAXBClassLocator.getJAXBClasses(locator, AbstractRBD.class);
Collection<Class<?>> classes = JAXBClassLocator.getJAXBClasses(
locator, AbstractRBD.class);
locator.save();
Class<?>[] jaxbClasses = new Class<?>[classes.size() + 1];
classes.toArray(jaxbClasses);
/* Add JaxbDummyObject at the begining so properties are loaded
* correctly */
/*
* Add JaxbDummyObject at the begining so properties are loaded
* correctly
*/
jaxbClasses[jaxbClasses.length - 1] = jaxbClasses[0];
jaxbClasses[0] = JaxbDummyObject.class;
@ -746,7 +798,8 @@ public abstract class AbstractRBD<T extends AbstractRenderableDisplay> implement
public NCTimeMatcher getTimeMatcher() {
if (timeMatcher == null) {
timeMatcher = (NCTimeMatcher) displays[0].getDescriptor().getTimeMatcher();
timeMatcher = (NCTimeMatcher) displays[0].getDescriptor()
.getTimeMatcher();
}
return timeMatcher;
}
@ -761,7 +814,8 @@ public abstract class AbstractRBD<T extends AbstractRenderableDisplay> implement
if (disp != null) {
disp.getDescriptor().setTimeMatcher(timeMatcher);
timeMatcher.addDescriptor((INatlCntrsDescriptor) disp.getDescriptor());
timeMatcher.addDescriptor((INatlCntrsDescriptor) disp
.getDescriptor());
}
}
}
@ -777,10 +831,12 @@ public abstract class AbstractRBD<T extends AbstractRenderableDisplay> implement
for (int r = 0; r < rl.size(); r++) {
ResourcePair rp = rl.get(r);
if (rp.getResourceData() instanceof AbstractNatlCntrsRequestableResourceData) {
AbstractNatlCntrsRequestableResourceData rscData = (AbstractNatlCntrsRequestableResourceData) rp.getResourceData();
AbstractNatlCntrsRequestableResourceData rscData = (AbstractNatlCntrsRequestableResourceData) rp
.getResourceData();
ResourceName rscName = rscData.getResourceName();
if (rscName.isForecastResource() && rscName.isLatestCycleTime()) {
if (rscName.isForecastResource()
&& rscName.isLatestCycleTime()) {
rscData.getAvailableDataTimes();
@ -789,7 +845,9 @@ public abstract class AbstractRBD<T extends AbstractRenderableDisplay> implement
// to have to be able to handle this case.
//
if (rscName.isLatestCycleTime()) {
System.out.println("Unable to Resolve Latest cycle time for :" + rscName);
System.out
.println("Unable to Resolve Latest cycle time for :"
+ rscName);
}
}
}
@ -806,7 +864,8 @@ public abstract class AbstractRBD<T extends AbstractRenderableDisplay> implement
ResourceName domRscName = timeMatcher.getDominantResourceName();
if (domRscName != null && domRscName.isValid() && timeMatcher.getDominantResource() == null) {
if (domRscName != null && domRscName.isValid()
&& timeMatcher.getDominantResource() == null) {
// loop thru the displays looking for the dominant resource
//
@ -815,9 +874,11 @@ public abstract class AbstractRBD<T extends AbstractRenderableDisplay> implement
for (int r = 0; r < rl.size(); r++) {
ResourcePair rp = rl.get(r);
if (rp.getResourceData() instanceof AbstractNatlCntrsRequestableResourceData) {
AbstractNatlCntrsRequestableResourceData rdata = (AbstractNatlCntrsRequestableResourceData) rp.getResourceData();
AbstractNatlCntrsRequestableResourceData rdata = (AbstractNatlCntrsRequestableResourceData) rp
.getResourceData();
if (domRscName.toString().equals(rdata.getResourceName().toString())) {
if (domRscName.toString().equals(
rdata.getResourceName().toString())) {
timeMatcher.setDominantResourceData(rdata);
return;

View file

@ -0,0 +1,60 @@
package gov.noaa.nws.ncep.viz.resources.manager;
import gov.noaa.nws.ncep.viz.common.display.INatlCntrsDescriptor;
import gov.noaa.nws.ncep.viz.ui.display.NCTimeSeriesRenderableDisplay;
import gov.noaa.nws.ncep.viz.ui.display.NcPaneID;
import gov.noaa.nws.ncep.viz.ui.display.NcPaneLayout;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
/**
* Bundle for Natl Cntrs Resources
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 2014/03/26/ # qzhou Modified
*
* </pre>
*
* @author qzhou
* @version 1
*/
@XmlRootElement
@XmlType(name = "GraphRBD")
@XmlAccessorType(XmlAccessType.NONE)
public class GraphRBD extends AbstractRBD<NCTimeSeriesRenderableDisplay> {
public GraphRBD() {
super();
}
public GraphRBD(NcPaneLayout paneLayout) {
super(paneLayout);
}
@Override
public boolean addDisplayPane(NCTimeSeriesRenderableDisplay dispPane,
NcPaneID pid) {
if (!paneLayout.containsPaneId(pid)) {
System.out.println("NcMapRBD.getDisplayPane: pane id "
+ pid.toString() + " is out of range.");
return false;
}
displays[paneLayout.getPaneIndex(pid)] = dispPane;
// sync the descriptor's auto update with the value of this RBD.
((INatlCntrsDescriptor) displays[paneLayout.getPaneIndex(pid)]
.getDescriptor()).setAutoUpdate(isAutoUpdate());
return true;
}
}

View file

@ -1,20 +1,17 @@
package gov.noaa.nws.ncep.viz.resources.manager;
import gov.noaa.nws.ncep.viz.common.area.AreaName.AreaSource;
import gov.noaa.nws.ncep.viz.common.area.PredefinedArea;
import gov.noaa.nws.ncep.viz.common.area.IGridGeometryProvider.ZoomLevelStrings;
import gov.noaa.nws.ncep.viz.common.area.PredefinedArea;
import gov.noaa.nws.ncep.viz.common.display.INatlCntrsDescriptor;
import gov.noaa.nws.ncep.viz.common.display.INatlCntrsRenderableDisplay;
import gov.noaa.nws.ncep.viz.common.display.INcPaneLayout;
import gov.noaa.nws.ncep.viz.common.display.NcDisplayName;
import gov.noaa.nws.ncep.viz.common.display.NcDisplayType;
import gov.noaa.nws.ncep.viz.resources.time_match.NCTimeMatcher;
import org.eclipse.swt.graphics.Rectangle;
import gov.noaa.nws.ncep.viz.ui.display.NCMapDescriptor;
import gov.noaa.nws.ncep.viz.ui.display.NCMapRenderableDisplay;
import gov.noaa.nws.ncep.viz.ui.display.NcEditorUtil;
import gov.noaa.nws.ncep.viz.ui.display.NcPaneLayout;
import gov.noaa.nws.ncep.viz.ui.display.NcDisplayMngr;
import gov.noaa.nws.ncep.viz.ui.display.NcEditorUtil;
import gov.noaa.nws.ncep.viz.ui.display.NcPaneID;
import java.util.Iterator;
@ -23,28 +20,27 @@ import java.util.concurrent.ConcurrentLinkedQueue;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Display;
import com.raytheon.uf.common.time.DataTime;
import com.raytheon.uf.viz.core.IDisplayPane;
import com.raytheon.uf.viz.core.PixelExtent;
import com.raytheon.uf.viz.core.VizApp;
import com.raytheon.uf.viz.core.drawables.AbstractRenderableDisplay;
import com.raytheon.uf.viz.core.drawables.IDescriptor;
import com.raytheon.uf.viz.core.drawables.ResourcePair;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.map.MapDescriptor;
import com.raytheon.uf.viz.core.rsc.ResourceList;
import com.raytheon.viz.ui.UiPlugin;
import com.raytheon.viz.ui.editor.AbstractEditor;
/**
* Resource Bundle Loader will load RBDs into new or existing map editors.
* (Note that this was originally designed to be in a separate thread but there was a problem
* with the thread loading the RBDs.)
* Resource Bundle Loader will load RBDs into new or existing map editors. (Note
* that this was originally designed to be in a separate thread but there was a
* problem with the thread loading the RBDs.)
*
* TODO : This contains commented out code which will implement a Load Mode option that allows the user to either Append
* RBD resources to a display or to overwrite/replace resources already displayed.
* TODO : This contains commented out code which will implement a Load Mode
* option that allows the user to either Append RBD resources to a display or to
* overwrite/replace resources already displayed.
*
* <pre>
* SOFTWARE HISTORY
@ -80,7 +76,9 @@ public class ResourceBndlLoader implements Runnable { // extends Job {
private final class RbdBundleEditorWrapper {
private AbstractRBD<?> rbdBundle;
private AbstractEditor ncEditor;
private Boolean replaceEditorNameWithRbdName;
RbdBundleEditorWrapper(AbstractRBD<?> theRbdBundle, AbstractEditor ed,
@ -117,7 +115,8 @@ public class ResourceBndlLoader implements Runnable { // extends Job {
seldRBDs.clear();
}
public void addDefaultRBD( NcDisplayType dt, AbstractEditor theEditor ) throws VizException {
public void addDefaultRBD(NcDisplayType dt, AbstractEditor theEditor)
throws VizException {
AbstractRBD<?> rbd = NcMapRBD.getDefaultRBD(NcDisplayType.NMAP_DISPLAY);
rbd.resolveLatestCycleTimes(); // shouldn't be needed but just in case
@ -136,11 +135,14 @@ public class ResourceBndlLoader implements Runnable { // extends Job {
private class ErrorMsg implements Runnable {
String errMsg = "";
ErrorMsg(String em) {
errMsg = em;
}
public void run() {
Status status = new Status(Status.ERROR, UiPlugin.PLUGIN_ID, 0, errMsg, null );
Status status = new Status(Status.ERROR, UiPlugin.PLUGIN_ID, 0,
errMsg, null);
ErrorDialog.openError(Display.getCurrent().getActiveShell(),
"ERROR", errMsg, status);
}
@ -155,12 +157,14 @@ public class ResourceBndlLoader implements Runnable { // extends Job {
// protected IStatus run(IProgressMonitor monitor) {
// public void loadRBDs() {
public void run() {
RbdBundleEditorWrapper[] wrapperClassArray= ( RbdBundleEditorWrapper[] ) seldRBDs.toArray ( new RbdBundleEditorWrapper[0] );
RbdBundleEditorWrapper[] wrapperClassArray = (RbdBundleEditorWrapper[]) seldRBDs
.toArray(new RbdBundleEditorWrapper[0]);
if (loadSelectedPaneOnly) {
if (wrapperClassArray.length > 1) {
System.out.println("Warning: rbdLoader should only load one RBD when"+
"loadSelectedPaneOnly is true??" );
System.out
.println("Warning: rbdLoader should only load one RBD when"
+ "loadSelectedPaneOnly is true??");
}
}
@ -177,25 +181,31 @@ public class ResourceBndlLoader implements Runnable { // extends Job {
throw new VizException("??editor is null in rbdLoader?");
}
// If this editor currently has resources loaded, clear them out except for PGEN
// If this editor currently has resources loaded, clear them out
// except for PGEN
//
for( int paneIndx=0 ; paneIndx<rbdBndl.getPaneLayout().getNumberOfPanes() ; paneIndx++ ) {
NcPaneID paneid = (NcPaneID) rbdBndl.getPaneLayout().createPaneId(paneIndx);
IDisplayPane pane = NcEditorUtil.getDisplayPane( editor, paneid );
for (int paneIndx = 0; paneIndx < rbdBndl.getPaneLayout()
.getNumberOfPanes(); paneIndx++) {
NcPaneID paneid = (NcPaneID) rbdBndl.getPaneLayout()
.createPaneId(paneIndx);
IDisplayPane pane = NcEditorUtil.getDisplayPane(editor,
paneid);
if (pane == null) {
throw new VizException("Could not get pane "+paneid.toString() +
" from the editor.");
throw new VizException("Could not get pane "
+ paneid.toString() + " from the editor.");
}
// don't clear this pane if we are only loading the selected pane and
// don't clear this pane if we are only loading the selected
// pane and
// this isn't it
if( loadSelectedPaneOnly &&
rbdBndl.getSelectedPaneId().compareTo( paneid ) != 0 ) {
if (loadSelectedPaneOnly
&& rbdBndl.getSelectedPaneId().compareTo(paneid) != 0) {
continue;
}
List<ResourcePair> rlist = pane.getRenderableDisplay().getDescriptor().getResourceList();
List<ResourcePair> rlist = pane.getRenderableDisplay()
.getDescriptor().getResourceList();
if (rlist == null) {
throw new VizException("The ResourceList is empty?");
}
@ -203,15 +213,20 @@ public class ResourceBndlLoader implements Runnable { // extends Job {
while (it.hasNext()) {
ResourcePair rp = it.next();
if ( !rp.getResource().getClass().getName().endsWith("PgenResource") ) {
if (rp.getResource() != null) {
if (!rp.getResource().getClass().getName()
.endsWith("PgenResource")) {
rlist.remove(rp);
}
}
}
}
NcEditorUtil.setAutoUpdate(editor, rbdBndl.isAutoUpdate());
NcEditorUtil.setGeoSyncPanesEnabled( editor, rbdBndl.isGeoSyncedPanes() );
NcEditorUtil.setHideShow( editor, false); //init to false, means rsc on
NcEditorUtil.setGeoSyncPanesEnabled(editor,
rbdBndl.isGeoSyncedPanes());
NcEditorUtil.setHideShow(editor, false); // init to false, means
// rsc on
IDisplayPane displayPanes[] = editor.getDisplayPanes();
IDisplayPane seldPane = null;
@ -220,54 +235,69 @@ public class ResourceBndlLoader implements Runnable { // extends Job {
if (loadSelectedPaneOnly) {
if (!playout.containsPaneId(rbdBndl.getSelectedPaneId())) {
// playout.getRows() <= rbdBndl.getSelectedPaneId().getRow() ||
// playout.getColumns() <= rbdBndl.getSelectedPaneId().getColumn() ) {
// playout.getRows() <=
// rbdBndl.getSelectedPaneId().getRow() ||
// playout.getColumns() <=
// rbdBndl.getSelectedPaneId().getColumn() ) {
//
throw new VizException("Error: The Active Display doesn't have enough Panes"+
" for the selected Pane: ");
throw new VizException(
"Error: The Active Display doesn't have enough Panes"
+ " for the selected Pane: ");
}
}
else if( !playout.equals( rbdBndl.getPaneLayout() ) ) {
throw new VizException("PaneLayouts of the RBD and Editor don't match?");
} else if (!playout.equals(rbdBndl.getPaneLayout())) {
throw new VizException(
"PaneLayouts of the RBD and Editor don't match?");
}
// loop thru the panes in the RBD
//
for( int paneIndx=0 ; paneIndx<rbdBndl.getPaneLayout().getNumberOfPanes() ; paneIndx++ ) {
NcPaneID paneid = (NcPaneID)rbdBndl.getPaneLayout().createPaneId( paneIndx );
for (int paneIndx = 0; paneIndx < rbdBndl.getPaneLayout()
.getNumberOfPanes(); paneIndx++) {
NcPaneID paneid = (NcPaneID) rbdBndl.getPaneLayout()
.createPaneId(paneIndx);
// don't load this pane if we are only loading the selected pane and
// don't load this pane if we are only loading the selected
// pane and
// this isn't it
if( loadSelectedPaneOnly &&
rbdBndl.getSelectedPaneId().compareTo( paneid ) != 0 ) {
if (loadSelectedPaneOnly
&& rbdBndl.getSelectedPaneId().compareTo(paneid) != 0) {
continue;
}
IDisplayPane displayPane = NcEditorUtil.getDisplayPane( editor, paneid );
INatlCntrsRenderableDisplay mapDisp = rbdBndl.getDisplayPane( paneid );
IDisplayPane displayPane = NcEditorUtil.getDisplayPane(
editor, paneid);
INatlCntrsRenderableDisplay mapDisp = rbdBndl
.getDisplayPane(paneid);
if (seldPane == null) {
seldPane = displayPane;
}
// if the editor was just created and there was an error, close the editor.
// TODO: if there is an error, prompt if the user wishes to continue.
if( loadResourceBundleDefn( displayPane,
mapDisp, rbdBndl.getTimeMatcher() ) == false ) {
// if the editor was just created and there was an error,
// close the editor.
// TODO: if there is an error, prompt if the user wishes to
// continue.
if (loadResourceBundleDefn(displayPane, mapDisp,
rbdBndl.getTimeMatcher()) == false) {
throw new VizException("Error Loading Pane "+paneid.toString()+
" for RBD "+ rbdBndl.getRbdName() );
throw new VizException("Error Loading Pane "
+ paneid.toString() + " for RBD "
+ rbdBndl.getRbdName());
}
}
// if using the RBD name as the display name, set the tab title
// (this will be the case unless we are loading the default RBD in
// which case the name may be different. ie. NCTEXT, NSHARP or user-defined.
// (this will be the case unless we are loading the default RBD
// in
// which case the name may be different. ie. NCTEXT, NSHARP or
// user-defined.
//
if (thisWrapper.useRbdNameForEditor()) {
NcDisplayName dispName = NcEditorUtil.getDisplayName( editor );
dispName = new NcDisplayName( dispName.getId(), rbdBndl.getRbdName() );
NcDisplayName dispName = NcEditorUtil
.getDisplayName(editor);
dispName = new NcDisplayName(dispName.getId(),
rbdBndl.getRbdName());
NcEditorUtil.setDisplayName(editor, dispName);
editor.setTabTitle(dispName.toString());
@ -275,14 +305,14 @@ public class ResourceBndlLoader implements Runnable { // extends Job {
editor.refresh();
NcEditorUtil.refreshGUIElements(editor);
// flag the editor as 'loaded' so that it is no longer considered 'empty' or available
NcEditorUtil.setDisplayAvailable( editor, rbdBndl.getIsDefaultRbd() );
// flag the editor as 'loaded' so that it is no longer
// considered 'empty' or available
NcEditorUtil.setDisplayAvailable(editor,
rbdBndl.getIsDefaultRbd());
NcDisplayMngr.bringToTop(editor);
}
catch ( VizException vizex ) {
VizApp.runAsync(
new ErrorMsg( vizex.getMessage() ) );
} catch (VizException vizex) {
VizApp.runAsync(new ErrorMsg(vizex.getMessage()));
}
}
@ -302,23 +332,22 @@ public class ResourceBndlLoader implements Runnable { // extends Job {
return false;
}
INatlCntrsDescriptor descr = (INatlCntrsDescriptor) mapDisplay.getDescriptor();
INatlCntrsDescriptor descr = (INatlCntrsDescriptor) mapDisplay
.getDescriptor();
descr.setTimeMatcher(timeMatcher);
descr.setNumberOfFrames(timeMatcher.getNumFrames());
DataTime[] dataTimes = timeMatcher.getFrameTimes().toArray( new DataTime[0] );
DataTime[] dataTimes = timeMatcher.getFrameTimes().toArray(
new DataTime[0]);
if( dataTimes == null ||
dataTimes.length == 0 ) {
if (dataTimes == null || dataTimes.length == 0) {
// descr.setDataTimes( null );
}
else {
} else {
descr.setDataTimes(dataTimes);
if (timeMatcher.isForecast()) {
descr.setFrame(0);
}
else {
} else {
descr.setFrame(dataTimes.length - 1);
}
}
@ -326,15 +355,20 @@ public class ResourceBndlLoader implements Runnable { // extends Job {
ResourceList rscList = descr.getResourceList();
// Add PGEN resource back
if ( !pane.getRenderableDisplay().getDescriptor().getResourceList().isEmpty() ){
rscList.addAll( pane.getRenderableDisplay().getDescriptor().getResourceList());
if (!pane.getRenderableDisplay().getDescriptor().getResourceList()
.isEmpty()) {
rscList.addAll(pane.getRenderableDisplay().getDescriptor()
.getResourceList());
}
rscList.instantiateResources(descr, true);
// TODO : change the resource-capable (ie Satellite) resourceData objects to be able
// to query for the gridCoverage before the resource object is created. We should
// be able to query the mcidas_area_names/mcidas_spatial tables knowing just the info
// TODO : change the resource-capable (ie Satellite) resourceData
// objects to be able
// to query for the gridCoverage before the resource object is created.
// We should
// be able to query the mcidas_area_names/mcidas_spatial tables knowing
// just the info
// in the resourceData object.
// But until then resourceData objects just return dummy coverages and
// we will need to reproject the mapDisplay after the resource is loaded
@ -346,16 +380,16 @@ public class ResourceBndlLoader implements Runnable { // extends Job {
if (initArea.getSource() != AreaSource.PREDEFINED_AREA) {
if( initArea.getZoomLevel().equals( ZoomLevelStrings.SizeOfImage.toString() ) ) {
if (initArea.getZoomLevel().equals(
ZoomLevelStrings.SizeOfImage.toString())) {
Rectangle rect = pane.getBounds();
// mapDisplay.setExtent( new PixelExtent( rect ) );
mapDisplay.setExtent( new PixelExtent(
rect.x, rect.x + rect.width,
rect.y, rect.y + rect.height ) );
mapDisplay.setExtent(new PixelExtent(rect.x, rect.x
+ rect.width, rect.y, rect.y + rect.height));
((NCMapDescriptor) descr).setSuspendZoom(true);
// ZoomUtil.suspendZoom( mapDisplay.getContainer() ) ;
}
else if( initArea.getZoomLevel().equals( ZoomLevelStrings.FitToScreen.toString() ) ) {
} else if (initArea.getZoomLevel().equals(
ZoomLevelStrings.FitToScreen.toString())) {
}
}

View file

@ -18,7 +18,7 @@ import javax.xml.bind.annotation.adapters.XmlAdapter;
* ------------ ---------- ----------- --------------------------
* 02/13/13 #972 Greg Hull Created
* 03/06/13 #958 Greg Hull Added SpaceRscCategory
*
* 05/15/2014 #1131 Quan Zhou Added resource category GraphRscCategory.
* </pre>
*
* @author
@ -28,7 +28,8 @@ import javax.xml.bind.annotation.adapters.XmlAdapter;
@XmlAccessorType(XmlAccessType.NONE)
public class ResourceCategory implements Comparable<ResourceCategory> {
public static class ResourceCategoryAdapter extends XmlAdapter<String, ResourceCategory> {
public static class ResourceCategoryAdapter extends
XmlAdapter<String, ResourceCategory> {
//
@Override
public ResourceCategory unmarshal(String n) throws Exception {
@ -46,20 +47,40 @@ public class ResourceCategory implements Comparable<ResourceCategory> {
private static Map<String, ResourceCategory> catMap = new HashMap<String, ResourceCategory>();
public static ResourceCategory SatelliteRscCategory = createCategory( "SATELLITE", 100 );
public static ResourceCategory RadarRscCategory = createCategory( "RADAR", 200 );
public static ResourceCategory SatelliteRscCategory = createCategory(
"SATELLITE", 100);
public static ResourceCategory RadarRscCategory = createCategory("RADAR",
200);
public static ResourceCategory GridRscCategory = createCategory("GRID", 300);
public static ResourceCategory SurfaceRscCategory = createCategory( "SURFACE", 400 );
public static ResourceCategory UpperAirRscCategory = createCategory( "UPPER_AIR", 500 );
public static ResourceCategory SurfaceRscCategory = createCategory(
"SURFACE", 400);
public static ResourceCategory UpperAirRscCategory = createCategory(
"UPPER_AIR", 500);
public static ResourceCategory PGENRscCategory = createCategory("PGEN", 600);
public static ResourceCategory MiscRscCategory = createCategory("MISC", 700);
public static ResourceCategory EnsembleRscCategory = createCategory( "ENSEMBLE", 800 );
public static ResourceCategory OverlayRscCategory = createCategory( "OVERLAY", 900 );
public static ResourceCategory SpaceRscCategory = createCategory( "SOLARIMAGE", 850 );
public static ResourceCategory EnsembleRscCategory = createCategory(
"ENSEMBLE", 800);
public static ResourceCategory OverlayRscCategory = createCategory(
"OVERLAY", 900);
public static ResourceCategory SpaceRscCategory = createCategory(
"SOLARIMAGE", 850);
public static ResourceCategory GraphRscCategory = createCategory(
"TIMESERIES", 860);
private static int nextCatOrder = OverlayRscCategory.order + 100;
public static ResourceCategory NullCategory = new ResourceCategory( "NULL", -1 );
public static ResourceCategory NullCategory = new ResourceCategory("NULL",
-1);
// NOTE : These are available if the users don't like the SURFACE/UPPER_AIR
// categories as configured in the resourceDefinitions file.
@ -71,8 +92,8 @@ public class ResourceCategory implements Comparable<ResourceCategory> {
// IMAGE, MODEL, WATCH/WARNING
private String catName;
private int order;
private int order;
private ResourceCategory(String name, int ord) {
catName = name;

View file

@ -1,6 +1,7 @@
package gov.noaa.nws.ncep.viz.resources.manager;
import static java.lang.System.out;
import gov.noaa.nws.ncep.common.dataplugin.geomag.GeoMagRecord;
import gov.noaa.nws.ncep.common.dataplugin.mcidas.McidasRecord;
import gov.noaa.nws.ncep.common.dataplugin.ntrans.NtransRecord;
import gov.noaa.nws.ncep.common.dataplugin.pgen.PgenRecord;
@ -83,9 +84,9 @@ import com.raytheon.viz.alerts.observers.ProductAlertObserver;
* 04/2013 #838 B. Hebbard Add special handling (like satellite) for NTRANS compound subType
* 08/2013 #1031 Greg Hull modified inventory query
* 11/2013 #1074 Greg Hull fix bug generating native satellite sub-type
* 05/15/2014 #1131 Quan Zhou Added resource category GraphRscCategory. Added dfltGraphRange, dfltHourSnap
* 06/2014 B. Hebbard Force getInventoryEnabled() to return false except for GRID & ENSEMBLE
* resources, and make all internal read accesses via getter
*
* </pre>
*
* @author ghull
@ -126,6 +127,7 @@ public class ResourceDefinition implements ISerializableObject, IAlertObserver,
// the resource types generated by rscTypeGenerator from either the
// NcInventory or, if the inventory is disabled, the DB.
private ArrayList<String> generatedTypesList;
private ArrayList<String> generatedSubTypesList;
@ -141,6 +143,10 @@ public class ResourceDefinition implements ISerializableObject, IAlertObserver,
private static final int DEFAULT_FRAME_COUNT = 10;
private static final int DEFAULT_GRAPH_RANGE = 12; // in hours quan
private static final int DEFAULT_HOUR_SNAP = 3;
private static final int DEFAULT_TIME_RANGE = 24; // in hours
@XmlElement
@ -150,6 +156,15 @@ public class ResourceDefinition implements ISerializableObject, IAlertObserver,
@XmlElement
private int dfltTimeRange;
// the hours range in graph display.
@XmlElement
private int dfltGraphRange;
// the default hour selection snap number. For example, 3 means hours must
// be select in 0,3,6,9...
@XmlElement
private int dfltHourSnap;
// where/how are the attribute sets located/organized
//
public static enum AttrSetsOrganization {
@ -174,6 +189,7 @@ public class ResourceDefinition implements ISerializableObject, IAlertObserver,
// the user edits the params in the GUI. This are not returned by
// getResourceParameters but it would be nice to have a cleaner way to
// store the comments for a parameter.
@XmlElement
@XmlJavaTypeAdapter(RscParamsJaxBAdapter.class)
private HashMap<String, String> resourceParameters;
@ -184,6 +200,7 @@ public class ResourceDefinition implements ISerializableObject, IAlertObserver,
// implementations
// Default to disabled so it must be explicitly enabled.
@XmlElement
private Boolean inventoryEnabled = false;
@ -207,6 +224,7 @@ public class ResourceDefinition implements ISerializableObject, IAlertObserver,
// This is currently only used for the latestTimes in the attr set list.
// The actual times are still coming from the NcInventory or the DB.
//
@XmlElement
private Boolean addToURICatalog = false;
@ -221,6 +239,8 @@ public class ResourceDefinition implements ISerializableObject, IAlertObserver,
frameSpan = 0;
dfltFrameCount = DEFAULT_FRAME_COUNT;
dfltTimeRange = DEFAULT_TIME_RANGE;
dfltGraphRange = DEFAULT_GRAPH_RANGE;
dfltHourSnap = DEFAULT_HOUR_SNAP;
dfltGeogArea = "";
timeMatchMethod = TimeMatchMethod.CLOSEST_BEFORE_OR_AFTER;
timelineGenMethod = timelineGenMethod.USE_DATA_TIMES;
@ -250,7 +270,8 @@ public class ResourceDefinition implements ISerializableObject, IAlertObserver,
frameSpan = rscDefn.frameSpan;
dfltFrameCount = rscDefn.dfltFrameCount;
dfltTimeRange = rscDefn.dfltTimeRange;
dfltGraphRange = rscDefn.dfltGraphRange;
dfltHourSnap = rscDefn.dfltHourSnap;
timeMatchMethod = rscDefn.timeMatchMethod;
timelineGenMethod = rscDefn.timelineGenMethod;
@ -314,6 +335,7 @@ public class ResourceDefinition implements ISerializableObject, IAlertObserver,
// TODO : Need to change this to return the constraint field instead of
// the generator parameter. Til then all parameters that generate a type
// or sub type must be the same name as the request constraint.
public String getRscTypeGenerator() {
return (rscTypeGenerator == null ? "" : rscTypeGenerator);
}
@ -482,8 +504,7 @@ public class ResourceDefinition implements ISerializableObject, IAlertObserver,
public boolean isForecast() {
// @formatter:off
return (timelineGenMethod == TimelineGenMethod.USE_CYCLE_TIME_FCST_HOURS ||
timelineGenMethod == TimelineGenMethod.USE_FCST_FRAME_INTERVAL_FROM_REF_TIME);
return (timelineGenMethod == TimelineGenMethod.USE_CYCLE_TIME_FCST_HOURS || timelineGenMethod == TimelineGenMethod.USE_FCST_FRAME_INTERVAL_FROM_REF_TIME);
// @formatter:on
// return filterLabels.contains("Forecast");
}
@ -540,6 +561,22 @@ public class ResourceDefinition implements ISerializableObject, IAlertObserver,
this.dfltFrameCount = dfltFrameCount;
}
public int getDfltGraphRange() {
return dfltGraphRange;
}
public void setDfltGraphRange(int dfltGraphRange) {
this.dfltGraphRange = dfltGraphRange;
}
public int getDfltHourSnap() {
return dfltHourSnap;
}
public void setDfltHourSnap(int dfltHourSnap) {
this.dfltHourSnap = dfltHourSnap;
}
public int getDfltTimeRange() {
return dfltTimeRange;
}
@ -573,14 +610,14 @@ public class ResourceDefinition implements ISerializableObject, IAlertObserver,
}
public boolean applyAttrSetGroups() {
if (attrSetOrg == AttrSetsOrganization.DETERMINE_BY_RSC_CATEGORY) {
// @formatter:off
return resourceCategory == ResourceCategory.GridRscCategory ||
resourceCategory == ResourceCategory.RadarRscCategory ||
return resourceCategory == ResourceCategory.GridRscCategory
|| resourceCategory == ResourceCategory.RadarRscCategory
|| resourceCategory == ResourceCategory.GraphRscCategory
// resourceCategory == ResourceCategory.PGENRscCategory ||
resourceCategory == ResourceCategory.EnsembleRscCategory ||
resourceCategory == ResourceCategory.SpaceRscCategory;
// @formatter:on
|| resourceCategory == ResourceCategory.EnsembleRscCategory
|| resourceCategory == ResourceCategory.SpaceRscCategory;
} else if (attrSetOrg == AttrSetsOrganization.BY_ATTR_SET_GROUP) {
return true;
} else {
@ -708,8 +745,8 @@ public class ResourceDefinition implements ISerializableObject, IAlertObserver,
// @formatter:off
return inventoryEnabled &&
// force to false (disabled) for non-grid non-ensemble resources
(resourceCategory.equals(ResourceCategory.GridRscCategory) ||
resourceCategory.equals(ResourceCategory.EnsembleRscCategory));
(resourceCategory.equals(ResourceCategory.GridRscCategory) || resourceCategory
.equals(ResourceCategory.EnsembleRscCategory));
// @formatter:on
}
@ -1790,6 +1827,9 @@ public class ResourceDefinition implements ISerializableObject, IAlertObserver,
.println("Unrecognized PGEN rsc generating subType"
+ subTypeGenerator);
}
} else if (getResourceCategory() == ResourceCategory.GraphRscCategory) {
GeoMagRecord magRec = (GeoMagRecord) pdo;
subType = magRec.getStationCode();
}
// doing this will cause the dataTime query to fail because
@ -1984,6 +2024,10 @@ public class ResourceDefinition implements ISerializableObject, IAlertObserver,
return false;
if (dfltTimeRange != other.dfltTimeRange)
return false;
if (dfltGraphRange != other.dfltGraphRange)
return false;
if (dfltHourSnap != other.dfltHourSnap)
return false;
if (frameSpan != other.frameSpan)
return false;
if (inventoryEnabled == null) {

View file

@ -1,23 +1,19 @@
package gov.noaa.nws.ncep.viz.resources.manager;
import gov.noaa.nws.ncep.viz.common.area.AreaMenus;
import gov.noaa.nws.ncep.viz.common.area.AreaMenus.AreaMenuItem;
import gov.noaa.nws.ncep.viz.common.area.AreaMenusMngr;
import gov.noaa.nws.ncep.viz.common.area.AreaName;
import gov.noaa.nws.ncep.viz.common.area.AreaMenus.AreaMenuItem;
import gov.noaa.nws.ncep.viz.common.area.AreaName.AreaSource;
import gov.noaa.nws.ncep.viz.common.area.IAreaProviderCapable;
import gov.noaa.nws.ncep.viz.common.area.IGridGeometryProvider;
import gov.noaa.nws.ncep.viz.common.area.INcAreaProviderFactory;
import gov.noaa.nws.ncep.viz.common.area.IGridGeometryProvider.ZoomLevelStrings;
import gov.noaa.nws.ncep.viz.common.area.NcAreaProviderMngr;
import gov.noaa.nws.ncep.viz.common.area.PredefinedArea;
import gov.noaa.nws.ncep.viz.common.area.PredefinedAreaFactory;
import gov.noaa.nws.ncep.viz.common.area.IGridGeometryProvider.ZoomLevelStrings;
import gov.noaa.nws.ncep.viz.common.display.INatlCntrsDescriptor;
import gov.noaa.nws.ncep.viz.common.display.INatlCntrsPaneManager;
import gov.noaa.nws.ncep.viz.common.display.INatlCntrsRenderableDisplay;
import gov.noaa.nws.ncep.viz.common.display.INcPaneID;
import gov.noaa.nws.ncep.viz.common.display.INcPaneLayout;
import gov.noaa.nws.ncep.viz.common.display.IPaneLayoutable;
import gov.noaa.nws.ncep.viz.common.display.NcDisplayName;
import gov.noaa.nws.ncep.viz.common.display.NcDisplayType;
import gov.noaa.nws.ncep.viz.common.ui.NmapCommon;
@ -25,14 +21,13 @@ import gov.noaa.nws.ncep.viz.resources.AbstractNatlCntrsRequestableResourceData;
import gov.noaa.nws.ncep.viz.resources.INatlCntrsResourceData;
import gov.noaa.nws.ncep.viz.resources.manager.ResourceFactory.ResourceSelection;
import gov.noaa.nws.ncep.viz.resources.time_match.NCTimeMatcher;
import gov.noaa.nws.ncep.viz.ui.display.NcEditorUtil;
import gov.noaa.nws.ncep.viz.ui.display.NcPaneLayout;
import gov.noaa.nws.ncep.viz.ui.display.NcDisplayMngr;
import gov.noaa.nws.ncep.viz.ui.display.NcEditorUtil;
import gov.noaa.nws.ncep.viz.ui.display.NcPaneID;
import gov.noaa.nws.ncep.viz.ui.display.NcPaneLayout;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -43,13 +38,11 @@ import org.eclipse.jface.dialogs.MessageDialog;
import com.raytheon.uf.viz.core.IDisplayPane;
import com.raytheon.uf.viz.core.drawables.ResourcePair;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.rsc.DisplayType;
import com.raytheon.viz.ui.editor.AbstractEditor;
/**
* Mngr class for the Selection and Creation of RBDs from the Resource
* Bundle Display Dialog.
* Mngr class for the Selection and Creation of RBDs from the Resource Bundle
* Display Dialog.
*
* <pre>
* SOFTWARE HISTORY
@ -84,7 +77,7 @@ import com.raytheon.viz.ui.editor.AbstractEditor;
* and use new areaProvider sources.
* 11/25/2013 #1078 Greg Hull check for FitToScreen and SizeOfImage in setPaneData()
* 11/25/2013 #1079 Greg Hull checkAndUpdateAreaFromResource
*
* 05/15/2014 #1131 Quan Zhou added rbdType GRAPH_DISPLAY
* </pre>
*
* @author ghull
@ -95,7 +88,8 @@ public class RscBundleDisplayMngr {
public static class PaneSelectionData {
private RscBundleDisplayMngr rscBndlMngr = null;
// private class RenderingOrderComparator implements Comparator<ResourceSelection> {
// private class RenderingOrderComparator implements
// Comparator<ResourceSelection> {
//
// @Override
// public int compare(ResourceSelection o1, ResourceSelection o2) {
@ -108,8 +102,10 @@ public class RscBundleDisplayMngr {
private Vector<ResourceSelection> seldResources = new Vector<ResourceSelection>();
// if set with a 'custom' area defined by an RBD then this will
// be set to the custom area. Since it can't be accessed by an areaFactory
// until it is loaded, this is use to reset the area should the user reselect
// be set to the custom area. Since it can't be accessed by an
// areaFactory
// until it is loaded, this is use to reset the area should the user
// reselect
// the custom area from the gui.
private PredefinedArea initialArea = null;
@ -119,14 +115,17 @@ public class RscBundleDisplayMngr {
// the user accidently changes all of them with the geoSync button.
// private String prevSeldGeogArea = null;
public PaneSelectionData( RscBundleDisplayMngr rbdm, NcDisplayType rbdType ) {
public PaneSelectionData(RscBundleDisplayMngr rbdm,
NcDisplayType rbdType) {
rscBndlMngr = rbdm;
seldResources = new Vector<ResourceSelection>();
try {
area = PredefinedAreaFactory.getDefaultPredefinedAreaForDisplayType( rbdType );
area = PredefinedAreaFactory
.getDefaultPredefinedAreaForDisplayType(rbdType);
} catch (VizException e1) {
System.out.println("Error getting default PredefinedArea: "+e1.getMessage() );
System.out.println("Error getting default PredefinedArea: "
+ e1.getMessage());
}
// Reference the same base overlay for multi-pane displays.
@ -143,17 +142,18 @@ public class RscBundleDisplayMngr {
return area;
}
// bit of a hack here. null indicates to reset to a custom area from an rbd
// that was initially set from an earlier call to setArea() where the source
// bit of a hack here. null indicates to reset to a custom area from an
// rbd
// that was initially set from an earlier call to setArea() where the
// source
// was the INITIAL_DISPLAY_AREA from an RBD.
public void setArea(PredefinedArea pa) {
if (pa == null) {
area = initialArea;
}
else {
} else {
area = pa;
if( initialArea == null ||
area.getSource() == AreaSource.INITIAL_DISPLAY_AREA ) {
if (initialArea == null
|| area.getSource() == AreaSource.INITIAL_DISPLAY_AREA) {
initialArea = area;
}
}
@ -191,7 +191,8 @@ public class RscBundleDisplayMngr {
}
//
public boolean replaceSelectedResource( ResourceSelection existingRsc, ResourceSelection newRsc ) {
public boolean replaceSelectedResource(ResourceSelection existingRsc,
ResourceSelection newRsc) {
// find the existing resource and replace it.
int rscIndx = seldResources.indexOf(existingRsc);
@ -199,14 +200,13 @@ public class RscBundleDisplayMngr {
if (rscIndx == -1) {
seldResources.add(newRsc);
return false;
}
else {
} else {
if (existingRsc.isBaseLevelResource()) {
System.out.println("Can't replace the base Overlay :" + existingRsc.getResourceName() );
System.out.println("Can't replace the base Overlay :"
+ existingRsc.getResourceName());
seldResources.add(newRsc);
return false;
}
else {
} else {
seldResources.set(rscIndx, newRsc);
return true;
}
@ -216,18 +216,24 @@ public class RscBundleDisplayMngr {
public void resetPane() {
seldResources.clear();
// if clearing all resources we will remove any edits made to the base overlay.
// if clearing all resources we will remove any edits made to the
// base overlay.
if (baseOverlayResources.containsKey(rscBndlMngr.getRbdType())) {
ResourceSelection baseRsc = baseOverlayResources.get( rscBndlMngr.getRbdType() );
ResourceSelection baseRsc = baseOverlayResources
.get(rscBndlMngr.getRbdType());
if (baseRsc != null) {
if (baseRsc.getResourceData().getIsEdited()) {
try {
baseRsc = ResourceFactory.createResource( baseRsc.getResourceName() );
baseRsc = ResourceFactory.createResource(baseRsc
.getResourceName());
} catch (VizException e) {
System.out.println( "Error creating base overlay for "+
rscBndlMngr.getRbdType().getName()+" RBDs: "+ e.getMessage() );
System.out
.println("Error creating base overlay for "
+ rscBndlMngr.getRbdType()
.getName() + " RBDs: "
+ e.getMessage());
return;
}
}
@ -241,13 +247,13 @@ public class RscBundleDisplayMngr {
public void removeSelectedResource(ResourceSelection selRsc) {
if (selRsc == null) {
resetPane();
}
else {
if( seldResources.contains( selRsc ) ) { // sanity check; this has to be in the list
} else {
if (seldResources.contains(selRsc)) { // sanity check; this has
// to be in the list
if (selRsc.isBaseLevelResource()) {
System.out.println("Can't remove the base Overlay :" + NmapCommon.getBaseOverlay() );
}
else {
System.out.println("Can't remove the base Overlay :"
+ NmapCommon.getBaseOverlay());
} else {
seldResources.remove(selRsc);
}
}
@ -255,29 +261,32 @@ public class RscBundleDisplayMngr {
}
}
public RscBundleDisplayMngr( NcPaneLayout maxPaneLayout, NcDisplayType dispType ) {
public RscBundleDisplayMngr(NcPaneLayout maxPaneLayout,
NcDisplayType dispType) {
for (NcDisplayType dt : NcDisplayType.getRbdSavableDisplayTypes()) {
if( dt.getBaseResource() != null &&
!dt.getBaseResource().isEmpty() ) {
if (dt.getBaseResource() != null && !dt.getBaseResource().isEmpty()) {
ResourceName rscName = new ResourceName(dt.getBaseResource());
try {
if (rscName.isValid()) {
ResourceSelection baseOverlay = ResourceFactory.createResource( rscName );
ResourceSelection baseOverlay = ResourceFactory
.createResource(rscName);
baseOverlay.setIsBaseLevelResource(true);
baseOverlayResources.put(dt, baseOverlay);
}
else {
throw new VizException( "Invalid base overlay name "+rscName.toString()+" for display type: "+dt.toString() );
} else {
throw new VizException("Invalid base overlay name "
+ rscName.toString() + " for display type: "
+ dt.toString());
}
} catch (VizException e) {
MessageDialog errDlg = new MessageDialog(
NcDisplayMngr.getCaveShell(),
"Error", null,
"Error creating base overlay for "+dt.getName()+" RBDs:"+rscName.toString()+"\n"+e.getMessage(),
MessageDialog.ERROR, new String[]{"OK"}, 0);
NcDisplayMngr.getCaveShell(), "Error", null,
"Error creating base overlay for " + dt.getName()
+ " RBDs:" + rscName.toString() + "\n"
+ e.getMessage(), MessageDialog.ERROR,
new String[] { "OK" }, 0);
errDlg.open();
}
}
@ -290,7 +299,8 @@ public class RscBundleDisplayMngr {
// the maximum number of rows & columns
private NcPaneLayout maxLayout = new NcPaneLayout(6, 6);
// an RBD must be one of these display types and all resources in the RBD must be compatible
// an RBD must be one of these display types and all resources in the RBD
// must be compatible
// with the display type.
private NcDisplayType rbdType;
@ -303,8 +313,7 @@ public class RscBundleDisplayMngr {
// this will map the paneID (as a string) to the current area and resource
// information . Note : use a String since the paneIndex is relative to the
// selected paneLayout which may change.
private HashMap<String, PaneSelectionData> paneSelectionDataMap =
new HashMap<String,PaneSelectionData>();
private HashMap<String, PaneSelectionData> paneSelectionDataMap = new HashMap<String, PaneSelectionData>();
// the entry in the paneSelectionDataMap that is currently selected
private PaneSelectionData selectedPaneData = null;
@ -314,14 +323,17 @@ public class RscBundleDisplayMngr {
private static Map<NcDisplayType, ResourceSelection> baseOverlayResources = new HashMap<NcDisplayType, ResourceSelection>();
private boolean geoSyncPanes = false;
private boolean autoUpdate = false;
private boolean multiPane = false;
private String rbdName = "";
// set to true here if any of the resources, currRbdPaneLayout,... is changed. Reset to false here
// if initialized. Set to true from the dialog if a resource is edited or if the rbd is cleared.
// set to true here if any of the resources, currRbdPaneLayout,... is
// changed. Reset to false here
// if initialized. Set to true from the dialog if a resource is edited or if
// the rbd is cleared.
private boolean rbdModified = false;
// the initial timeMatcher from an AbstractRBD<?>. This may be superceded by
@ -416,8 +428,10 @@ public class RscBundleDisplayMngr {
// TODO : Should this set rbdModified? No.
// rbdModified = true;
if (!currRbdPaneLayout.containsPaneId(seldPaneId)) {
System.out.println("Attempting to select a paneID ("+seldPaneId.toString()+
") that is not in the current layout: "+ currRbdPaneLayout.toString() );
System.out.println("Attempting to select a paneID ("
+ seldPaneId.toString()
+ ") that is not in the current layout: "
+ currRbdPaneLayout.toString());
return;
}
selectedPaneId = (NcPaneID) seldPaneId;
@ -425,8 +439,8 @@ public class RscBundleDisplayMngr {
// This will probably be a fatal error. This should never happen.
if (selectedPaneData == null) {
System.out.println("ERROR: could not find the selected pane id ("+
selectedPaneId.toString()+") in the paneLayout Map." );
System.out.println("ERROR: could not find the selected pane id ("
+ selectedPaneId.toString() + ") in the paneLayout Map.");
}
}
@ -441,11 +455,12 @@ public class RscBundleDisplayMngr {
initialTimeMatcher = new NCTimeMatcher();
// make sure there is an entry in the map for each pane and initialize it.
// make sure there is an entry in the map for each pane and initialize
// it.
for (int p = 0; p < maxLayout.getNumberOfPanes(); p++) {
NcPaneID pid = (NcPaneID) maxLayout.createPaneId(p);
paneSelectionDataMap.put(
pid.toString(), new PaneSelectionData( this, rbdType ) );
paneSelectionDataMap.put(pid.toString(), new PaneSelectionData(
this, rbdType));
}
currRbdPaneLayout = new NcPaneLayout(1, 1);
@ -459,7 +474,8 @@ public class RscBundleDisplayMngr {
rbdModified = false;
}
public boolean initFromRbdBundle( AbstractRBD<?> rbdBndl ) throws VizException {
public boolean initFromRbdBundle(AbstractRBD<?> rbdBndl)
throws VizException {
// reset all panes and then set the PaneData for those in the rbd.
init(rbdBndl.getDisplayType());
@ -478,7 +494,8 @@ public class RscBundleDisplayMngr {
setSelectedPaneId(paneId);
INatlCntrsRenderableDisplay dispPane = rbdBndl.getDisplayPane(paneId);
INatlCntrsRenderableDisplay dispPane = rbdBndl
.getDisplayPane(paneId);
setPaneData(dispPane);
}
@ -487,8 +504,7 @@ public class RscBundleDisplayMngr {
if (rbdBndl.getTimeMatcher() == null) {
initialTimeMatcher = new NCTimeMatcher();
}
else {
} else {
initialTimeMatcher = rbdBndl.getTimeMatcher();
}
@ -500,7 +516,8 @@ public class RscBundleDisplayMngr {
// used when importing a single pane. In this case the display-defined
// area has not been added as an available selection.
//
public void setPaneData( INatlCntrsRenderableDisplay dispPane ) throws VizException {
public void setPaneData(INatlCntrsRenderableDisplay dispPane)
throws VizException {
// NOTE: the currently selected paneId doesn't have to match the
// dispPane's paneId.
@ -510,97 +527,119 @@ public class RscBundleDisplayMngr {
for (ResourcePair rp : dispPane.getDescriptor().getResourceList()) {
if (rp.getResourceData() instanceof INatlCntrsResourceData) {
try {
ResourceSelection rscSel = ResourceFactory.createResource( rp );
ResourceSelection rscSel = ResourceFactory
.createResource(rp);
addSelectedResource(rscSel);
if (rscSel.getResourceData() instanceof AbstractNatlCntrsRequestableResourceData) {
// timelineControl.addAvailDomResource( (AbstractNatlCntrsRequestableResourceData) rbt.getResourceData() );
// timelineControl.addAvailDomResource(
// (AbstractNatlCntrsRequestableResourceData)
// rbt.getResourceData() );
}
}
catch( VizException ve ) {
System.out.println("Unable to add selected Resource:"+
((INatlCntrsResourceData)rp.getResourceData()).getResourceName().toString() );
} catch (VizException ve) {
System.out.println("Unable to add selected Resource:"
+ ((INatlCntrsResourceData) rp.getResourceData())
.getResourceName().toString());
continue;
}
}
else if( !rp.getProperties().isSystemResource() ) {
System.out.println("Unable to load non-NC non-System Resource:"+rp.getResourceData().toString() );
} else if (!rp.getProperties().isSystemResource()) {
System.out.println("Unable to load non-NC non-System Resource:"
+ rp.getResourceData().toString());
}
}
// how to set size-of-image if the imported zoom level is not -1? we can't even tell if
// how to set size-of-image if the imported zoom level is not -1? we
// can't even tell if
// it has been changed from the original size-of-image???
//
// set the selected areaname from the display using the following rules.
// if this is from a current editor display and the current area has been changed from the initial area
// that the display was loaded with then the selected area will be the current area of the display
// (the source is DISPLAY_AREA and the areaname is the name of the display pane)
// if from a current editor and the current and initial areas are the same then use the
// if this is from a current editor display and the current area has
// been changed from the initial area
// that the display was loaded with then the selected area will be the
// current area of the display
// (the source is DISPLAY_AREA and the areaname is the name of the
// display pane)
// if from a current editor and the current and initial areas are the
// same then use the
// name of the area initially used to load the display.
// if this display pane is imported from and RBD then the initial area and the current area
// if this display pane is imported from and RBD then the initial area
// and the current area
// should be the same.
// AreaName seldAreaName = new AreaName( AreaSource.PREDEFINED_AREA, rbdType.getDefaultMap() );
// AreaName seldAreaName = new AreaName( AreaSource.PREDEFINED_AREA,
// rbdType.getDefaultMap() );
PredefinedArea initialArea = dispPane.getInitialArea();
// AreaName seldAreaName = new AreaName( initialArea.getSource(), initialArea.getAreaName() );
// AreaName seldAreaName = new AreaName( initialArea.getSource(),
// initialArea.getAreaName() );
PredefinedArea seldPredefinedArea = initialArea;
// if the display's current area is different than its initial area then
// set the display as the selected area otherwise use the name of the area
// set the display as the selected area otherwise use the name of the
// area
// originally used to set the display's area.
NcDisplayName dispName = dispPane.getPaneName().getDispName();
if( dispName.getId() > 0 && //dispPane.getPaneManager() instanceof NCPaneManager &&
if (dispName.getId() > 0 && // dispPane.getPaneManager() instanceof
// NCPaneManager &&
dispPane instanceof IAreaProviderCapable) {
// the name of the display's area will be the name of the pane.
AreaName currDispAreaName = new AreaName(AreaSource.DISPLAY_AREA,
((IAreaProviderCapable) dispPane).getAreaName());
try {
IGridGeometryProvider currGeom = NcAreaProviderMngr.createGeomProvider( currDispAreaName );
IGridGeometryProvider currGeom = NcAreaProviderMngr
.createGeomProvider(currDispAreaName);
// the name of the selected area will be the current area of the imported display
// unless the area has not been changed and the initial area is a predefined area
// the name of the selected area will be the current area of the
// imported display
// unless the area has not been changed and the initial area is
// a predefined area
if (currGeom != null && initialArea != null) { // sanity check
PredefinedArea currArea = PredefinedAreaFactory.createPredefinedArea(currGeom);
PredefinedArea currArea = PredefinedAreaFactory
.createPredefinedArea(currGeom);
// The areAreasEqual method doesn't work on SizeOfImage. This will lock the zoom
// so we will assume that if the initial area is SizeOfImage that the initial area
// The areAreasEqual method doesn't work on SizeOfImage.
// This will lock the zoom
// so we will assume that if the initial area is SizeOfImage
// that the initial area
// is the
if( !initialArea.getZoomLevel().equals( ZoomLevelStrings.SizeOfImage.toString() ) &&
!initialArea.getZoomLevel().equals( ZoomLevelStrings.FitToScreen.toString() ) ) {
if (!initialArea.getZoomLevel().equals(
ZoomLevelStrings.SizeOfImage.toString())
&& !initialArea.getZoomLevel().equals(
ZoomLevelStrings.FitToScreen.toString())) {
// use the area of the current display if the areas are different
// or if the same but the initial area is not a named/saved area name.
// use the area of the current display if the areas are
// different
// or if the same but the initial area is not a
// named/saved area name.
//
if (PredefinedArea.areAreasEqual(initialArea, currArea)) {
if (initialArea.getSource() == AreaSource.INITIAL_DISPLAY_AREA) {
// seldAreaName = currDispAreaName;
seldPredefinedArea = currArea;
}
}
else {
} else {
// seldAreaName = currDispAreaName;
seldPredefinedArea = currArea;
}
}
}
}
catch ( VizException ve ) {
System.out.println("error getting curr area for "+dispPane.getPaneName() );
} catch (VizException ve) {
System.out.println("error getting curr area for "
+ dispPane.getPaneName());
}
}
try {
setSelectedArea(seldPredefinedArea);
}
catch ( VizException ve ) {
setSelectedAreaName(
new AreaName( AreaSource.PREDEFINED_AREA, rbdType.getDefaultMap() ) );
} catch (VizException ve) {
setSelectedAreaName(new AreaName(AreaSource.PREDEFINED_AREA,
rbdType.getDefaultMap()));
}
// setSelectedPaneId( paneId );
@ -614,11 +653,14 @@ public class RscBundleDisplayMngr {
if (!paneSelectionDataMap.containsKey(paneId.toString())) {
return new ResourceSelection[] {};
}
return paneSelectionDataMap.get( paneId.toString() ).getSelectedResources();
return paneSelectionDataMap.get(paneId.toString())
.getSelectedResources();
}
// if any of the selected areas (any pane) is resource-defined then check to make sure
// it is still available and if not reset to the given rsc or the default if null.
// if any of the selected areas (any pane) is resource-defined then check to
// make sure
// it is still available and if not reset to the given rsc or the default if
// null.
// return true if an area was changed.
//
public Boolean checkAndUpdateAreaFromResource(ResourceSelection rscSel) {
@ -632,10 +674,9 @@ public class RscBundleDisplayMngr {
if (isGeoSyncPanes()) {
PredefinedArea seldArea = getSelectedArea();
seldAreaNames.put( getSelectedPaneId().toString(),
new AreaName( seldArea.getSource(), seldArea.getAreaName() ) );
}
else {
seldAreaNames.put(getSelectedPaneId().toString(), new AreaName(
seldArea.getSource(), seldArea.getAreaName()));
} else {
seldAreaNames = getAllSelectedAreaNames();
}
@ -646,31 +687,35 @@ public class RscBundleDisplayMngr {
// all available resource defined areas (from all panes)
List<AreaMenuItem> availRscAreas = getResourceProvidedAreas();
if( rscSel != null &&
rscSel.getResourceData() instanceof IAreaProviderCapable ) {
if (rscSel != null
&& rscSel.getResourceData() instanceof IAreaProviderCapable) {
// NOTE : assume that the rscSel is valid. Dont need to check that
// it is in the availRscAreas list.
IAreaProviderCapable aProv = (IAreaProviderCapable)rscSel.getResourceData();
resetAreaName = new AreaName( aProv.getSourceProvider(), aProv.getAreaName() );
IAreaProviderCapable aProv = (IAreaProviderCapable) rscSel
.getResourceData();
resetAreaName = new AreaName(aProv.getSourceProvider(),
aProv.getAreaName());
// if replaceing a rsc-defined area with another in a single pane or
// in a geo-synced multipane then go ahead and replace the area
//
if (!isMultiPane() || isGeoSyncPanes()) {
if( seldAreaNames.get( getSelectedPaneId().toString() ).getSource().isImagedBased() ) {
if (seldAreaNames.get(getSelectedPaneId().toString())
.getSource().isImagedBased()) {
try {
setSelectedAreaName(resetAreaName);
return true;
} catch (VizException e) {
System.out.println("Error reseting area??? : "+e.getMessage() );
System.out.println("Error reseting area??? : "
+ e.getMessage());
return false;
}
}
}
}
else {
resetAreaName = new AreaName( AreaSource.PREDEFINED_AREA, rbdType.getDefaultMap() );
} else {
resetAreaName = new AreaName(AreaSource.PREDEFINED_AREA,
rbdType.getDefaultMap());
}
// loop thru the panes and check for resource-defined areas
@ -686,8 +731,9 @@ public class RscBundleDisplayMngr {
for (AreaMenuItem ami : availRscAreas) {
// if we have found the resource for the given area
// then continue to the next pane
if( AreaSource.getAreaSource( ami.getSource()) == areaName.getSource() &&
ami.getAreaName().equals( areaName.getName() ) ) {
if (AreaSource.getAreaSource(ami.getSource()) == areaName
.getSource()
&& ami.getAreaName().equals(areaName.getName())) {
areaRscIsAvailable = true;
break;
}
@ -697,7 +743,8 @@ public class RscBundleDisplayMngr {
continue;
}
// reset this pane's area to either the default or to the given rsc (ie a replace.
// reset this pane's area to either the default or to the given rsc
// (ie a replace.
// note : if geosync is set then this will reset all of the areas
//
try {
@ -710,10 +757,9 @@ public class RscBundleDisplayMngr {
areaChanged = true;
}
catch (VizException e) {
System.out.println("Error resetting area to "+resetAreaName.toString()+
": "+ e.getMessage() );
} catch (VizException e) {
System.out.println("Error resetting area to "
+ resetAreaName.toString() + ": " + e.getMessage());
}
}
@ -727,23 +773,27 @@ public class RscBundleDisplayMngr {
List<AreaMenuItem> amiList;
AreaName areaName;
// ?? create area factories for NTRANS and SOLAR (just one 'default' area for now...)
if( rbdType == NcDisplayType.NTRANS_DISPLAY ||
rbdType == NcDisplayType.SOLAR_DISPLAY ) {
// ?? create area factories for NTRANS and SOLAR (just one 'default'
// area for now...)
if (rbdType == NcDisplayType.NTRANS_DISPLAY
|| rbdType == NcDisplayType.SOLAR_DISPLAY
|| rbdType == NcDisplayType.GRAPH_DISPLAY) {
areaMenuItems.add(new ArrayList<AreaMenuItem>());
areaMenuItems.get(0).add(
new AreaMenuItem( new AreaName( AreaSource.PREDEFINED_AREA, rbdType.getDefaultMap() ) ) );
new AreaMenuItem(new AreaName(AreaSource.PREDEFINED_AREA,
rbdType.getDefaultMap())));
return areaMenuItems;
}
// first is the selected area (not in a submenu)
amiList = new ArrayList<AreaMenuItem>();
areaName = new AreaName( getSelectedArea().getSource(), getSelectedArea().getAreaName() );
areaName = new AreaName(getSelectedArea().getSource(),
getSelectedArea().getAreaName());
if (areaName.getSource() == AreaSource.INITIAL_DISPLAY_AREA) {
seldami = new AreaMenuItem( "Custom", "", areaName.getName(), areaName.getSource().toString() );
}
else {
seldami = new AreaMenuItem("Custom", "", areaName.getName(),
areaName.getSource().toString());
} else {
seldami = new AreaMenuItem(areaName);
}
@ -752,14 +802,15 @@ public class RscBundleDisplayMngr {
amiList = new ArrayList<AreaMenuItem>();
// if the initial area is custom and not seleced then add it since it won't be saved
// if the initial area is custom and not seleced then add it since it
// won't be saved
//
PredefinedArea initArea = selectedPaneData.getInitialArea();
if( initArea != null && initArea != getSelectedArea() &&
initArea.getSource() == AreaSource.INITIAL_DISPLAY_AREA ) {
if (initArea != null && initArea != getSelectedArea()
&& initArea.getSource() == AreaSource.INITIAL_DISPLAY_AREA) {
seldami = new AreaMenuItem( "Custom", "",
initArea.getAreaName(), initArea.getSource().toString() );
seldami = new AreaMenuItem("Custom", "", initArea.getAreaName(),
initArea.getSource().toString());
amiList.add(seldami);
areaMenuItems.add(amiList);
}
@ -767,29 +818,33 @@ public class RscBundleDisplayMngr {
// the default next if its not selected.
if (getSelectedArea().getAreaName().equals(rbdType.getDefaultMap())) {
dfltami = seldami;
}
else {
} else {
amiList = new ArrayList<AreaMenuItem>();
areaName = new AreaName( AreaSource.PREDEFINED_AREA, rbdType.getDefaultMap() );
areaName = new AreaName(AreaSource.PREDEFINED_AREA,
rbdType.getDefaultMap());
dfltami = new AreaMenuItem(areaName);
amiList.add(dfltami);
areaMenuItems.add(amiList);
}
// next areas from the current display (if multipane then put in a submenu)
// next areas from the current display (if multipane then put in a
// submenu)
amiList = new ArrayList<AreaMenuItem>();
AbstractEditor ed = NcDisplayMngr.getActiveNatlCntrsEditor();
if (ed != null && NcEditorUtil.getNcDisplayType(ed) == rbdType) {
IDisplayPane[] panes = ( NcEditorUtil.arePanesGeoSynced( ed ) ?
NcEditorUtil.getSelectedPanes(ed) : ed.getDisplayPanes() );
IDisplayPane[] panes = (NcEditorUtil.arePanesGeoSynced(ed) ? NcEditorUtil
.getSelectedPanes(ed) : ed.getDisplayPanes());
for (IDisplayPane pane : panes) {
if (pane.getRenderableDisplay() instanceof IAreaProviderCapable) {
IAreaProviderCapable aPrv = (IAreaProviderCapable)pane.getRenderableDisplay();
IAreaProviderCapable aPrv = (IAreaProviderCapable) pane
.getRenderableDisplay();
ami = new AreaMenuItem(aPrv.getAreaName(),
(panes.length > 1 ? "Display" : ""), aPrv.getAreaName(), aPrv.getSourceProvider().toString() );
(panes.length > 1 ? "Display" : ""),
aPrv.getAreaName(), aPrv.getSourceProvider()
.toString());
amiList.add(ami);
}
@ -811,11 +866,12 @@ public class RscBundleDisplayMngr {
}
// finally add the areas from the areaMenus file.
Map<String,List<AreaMenuItem>> areaMenusMap = AreaMenusMngr.getInstance().getPredefinedAreasForMenus();
Map<String, List<AreaMenuItem>> areaMenusMap = AreaMenusMngr
.getInstance().getPredefinedAreasForMenus();
for (List<AreaMenuItem> alst : areaMenusMap.values()) {
if( alst == null || alst.isEmpty() ||
alst.get(0).getSubMenuName().isEmpty() ) {
if (alst == null || alst.isEmpty()
|| alst.get(0).getSubMenuName().isEmpty()) {
continue;
}
areaMenuItems.add(alst);
@ -825,8 +881,7 @@ public class RscBundleDisplayMngr {
if (areaMenusMap.containsKey("")) {
for (AreaMenuItem i : areaMenusMap.get("")) {
if( !seldami.equals( i ) &&
!dfltami.equals( i ) ) {
if (!seldami.equals(i) && !dfltami.equals(i)) {
amiList.add(i);
}
}
@ -847,24 +902,27 @@ public class RscBundleDisplayMngr {
List<AreaMenuItem> amiList = new ArrayList<AreaMenuItem>();
for (int paneIndx = 0; paneIndx < currRbdPaneLayout.getNumberOfPanes(); paneIndx++) {
PaneSelectionData paneData = paneSelectionDataMap.get(
currRbdPaneLayout.createPaneId( paneIndx ).toString() );
PaneSelectionData paneData = paneSelectionDataMap
.get(currRbdPaneLayout.createPaneId(paneIndx).toString());
for (ResourceSelection rscSel : paneData.getSelectedResources()) {
if (rscSel.getResourceData() instanceof IAreaProviderCapable) {
IAreaProviderCapable areaRsc = (IAreaProviderCapable)rscSel.getResourceData();
IAreaProviderCapable areaRsc = (IAreaProviderCapable) rscSel
.getResourceData();
AreaName areaName = new AreaName( areaRsc.getSourceProvider(),
areaRsc.getAreaName() );
AreaName areaName = new AreaName(
areaRsc.getSourceProvider(), areaRsc.getAreaName());
// ami = new AreaMenuItem( areaName );
AreaMenuItem ami = new AreaMenuItem(areaRsc.getAreaName(),
"Resource", areaRsc.getAreaName(), areaRsc.getSourceProvider().toString() );
"Resource", areaRsc.getAreaName(), areaRsc
.getSourceProvider().toString());
// use the source name as the sub menu name
// if( rscItems == null ) {
// rscItems = new ArrayList<AreaMenuItem>();
// areaMenuItems.put( areaRsc.getSourceProvider().toString(), rscItems );
// areaMenuItems.put(
// areaRsc.getSourceProvider().toString(), rscItems );
// }
if (!amiList.contains(ami)) {
@ -877,9 +935,11 @@ public class RscBundleDisplayMngr {
}
public boolean addSelectedResource(ResourceSelection rsel) {
NcDisplayType[] type = rsel.getSupportedDisplayTypes();
if (!Arrays.asList(rsel.getSupportedDisplayTypes()).contains(rbdType)) {
System.out.println("??Can't add resource "+rsel.getRscLabel()+" because it is not"+
" supported for display type "+rbdType.getName() );
System.out.println("??Can't add resource " + rsel.getRscLabel()
+ " because it is not" + " supported for display type "
+ rbdType.getName());
return false;
}
@ -900,15 +960,18 @@ public class RscBundleDisplayMngr {
return true;
}
public boolean replaceSelectedResource( ResourceSelection existingRsc, ResourceSelection newRsc ) {
public boolean replaceSelectedResource(ResourceSelection existingRsc,
ResourceSelection newRsc) {
if (!Arrays.asList(newRsc.getSupportedDisplayTypes()).contains(rbdType)) {
System.out.println("??Can't add resource "+newRsc.getRscLabel()+" because it is not"+
" supported for display type "+rbdType.getName() );
System.out.println("??Can't add resource " + newRsc.getRscLabel()
+ " because it is not" + " supported for display type "
+ rbdType.getName());
return false;
}
rbdModified = true;
boolean retval = selectedPaneData.replaceSelectedResource( existingRsc, newRsc );
boolean retval = selectedPaneData.replaceSelectedResource(existingRsc,
newRsc);
checkAndUpdateAreaFromResource(newRsc);
@ -940,7 +1003,6 @@ public class RscBundleDisplayMngr {
// }
// }
public NcDisplayType getRbdType() {
return rbdType;
}
@ -957,20 +1019,24 @@ public class RscBundleDisplayMngr {
return selectedPaneData.getArea();// .getAreaName();//GeoAreaName();
}
// return a map of all the currently selected areanames (with pane id as the key)
// return a map of all the currently selected areanames (with pane id as the
// key)
public Map<String, AreaName> getAllSelectedAreaNames() {
Map<String, AreaName> areasMap = new HashMap<String, AreaName>();
for (int paneIndx = 0; paneIndx < currRbdPaneLayout.getNumberOfPanes(); paneIndx++) {
NcPaneID paneId = (NcPaneID)currRbdPaneLayout.createPaneId(paneIndx);
NcPaneID paneId = (NcPaneID) currRbdPaneLayout
.createPaneId(paneIndx);
PaneSelectionData psd = paneSelectionDataMap.get(paneId.toString());
areasMap.put( paneId.toString(), new AreaName( psd.getArea().getSource(), psd.getArea().getAreaName() ) );
areasMap.put(paneId.toString(), new AreaName(psd.getArea()
.getSource(), psd.getArea().getAreaName()));
}
return areasMap;
}
// called when initializing the pane data
// If multi-pane and if geoSync is set then we will need to update all of the panes
// If multi-pane and if geoSync is set then we will need to update all of
// the panes
public void setSelectedArea(PredefinedArea seldArea) throws VizException {
rbdModified = true;
@ -978,8 +1044,7 @@ public class RscBundleDisplayMngr {
for (PaneSelectionData paneData : paneSelectionDataMap.values()) {
paneData.setArea(seldArea);
}
}
else {
} else {
selectedPaneData.setArea(seldArea);
}
@ -991,12 +1056,14 @@ public class RscBundleDisplayMngr {
// if Custom then use null as a flag to reset to the saved initial area
if (areaName.getSource() == AreaSource.INITIAL_DISPLAY_AREA) {
setSelectedArea(null);
}
else {
IGridGeometryProvider geom = NcAreaProviderMngr.createGeomProvider(areaName);
PredefinedArea seldArea = PredefinedAreaFactory.createPredefinedArea( geom );
} else {
IGridGeometryProvider geom = NcAreaProviderMngr
.createGeomProvider(areaName);
PredefinedArea seldArea = PredefinedAreaFactory
.createPredefinedArea(geom);
if (seldArea == null) {
throw new VizException("Unable to set the Area to "+areaName.toString() );
throw new VizException("Unable to set the Area to "
+ areaName.toString());
}
setSelectedArea(seldArea);
@ -1008,8 +1075,7 @@ public class RscBundleDisplayMngr {
for (PaneSelectionData paneData : paneSelectionDataMap.values()) {
paneData.setZoomLevel(zl);
}
}
else {
} else {
selectedPaneData.setZoomLevel(zl);
}
@ -1057,10 +1123,12 @@ public class RscBundleDisplayMngr {
}
// Create the RBD
// get the resources, overlays and map background bundle files. Load each bundle and re-bundle
// get the resources, overlays and map background bundle files. Load each
// bundle and re-bundle
// them into an RBD bundle file.
//
public AbstractRBD<?> createRbdBundle( String rbdName, NCTimeMatcher timeMatcher ) throws VizException {
public AbstractRBD<?> createRbdBundle(String rbdName,
NCTimeMatcher timeMatcher) throws VizException {
NcPaneLayout rbdPaneLayout = new NcPaneLayout(1, 1);
@ -1070,7 +1138,8 @@ public class RscBundleDisplayMngr {
((NcPaneLayout) currRbdPaneLayout).getColumns());
}
AbstractRBD<?> rbdBndl = AbstractRBD.createEmptyRbdForDisplayType( rbdType, rbdPaneLayout );
AbstractRBD<?> rbdBndl = AbstractRBD.createEmptyRbdForDisplayType(
rbdType, rbdPaneLayout);
if (rbdBndl == null) {
throw new VizException("Unsupported RBD type");
}
@ -1082,7 +1151,8 @@ public class RscBundleDisplayMngr {
rbdBndl.setTimeMatcher(timeMatcher);
}
rbdBndl.setSelectedPaneId( (isMultiPane() ? selectedPaneId : new NcPaneID()) );
rbdBndl.setSelectedPaneId((isMultiPane() ? selectedPaneId
: new NcPaneID()));
rbdBndl.setAutoUpdate(autoUpdate);
rbdBndl.setGeoSyncedPanes(geoSyncPanes);
@ -1090,7 +1160,8 @@ public class RscBundleDisplayMngr {
for (int paneIndx = 0; paneIndx < rbdPaneLayout.getNumberOfPanes(); paneIndx++) {
NcPaneID paneId = (NcPaneID) rbdPaneLayout.createPaneId(paneIndx);
PaneSelectionData paneData = paneSelectionDataMap.get( paneId.toString() );
PaneSelectionData paneData = paneSelectionDataMap.get(paneId
.toString());
PredefinedArea pArea = paneData.getArea();
@ -1100,20 +1171,22 @@ public class RscBundleDisplayMngr {
pArea.setAreaName(rbdName);
}
INatlCntrsRenderableDisplay iNcRendDisp = rbdBndl.getDisplayPane( paneId );
INatlCntrsRenderableDisplay iNcRendDisp = rbdBndl
.getDisplayPane(paneId);
iNcRendDisp.setInitialArea(pArea);
INatlCntrsDescriptor descr = (INatlCntrsDescriptor)iNcRendDisp.getDescriptor();
INatlCntrsDescriptor descr = (INatlCntrsDescriptor) iNcRendDisp
.getDescriptor();
// auto update is set for the AbstractRBD<?> and is also set for each descriptor
// auto update is set for the AbstractRBD<?> and is also set for
// each descriptor
descr.setAutoUpdate(autoUpdate);
if (descr.getResourceList() == null) {
VizException ve = new VizException("getResourceList is null??.");
throw ve;
}
else {
} else {
descr.getResourceList().clear();
}
@ -1122,17 +1195,20 @@ public class RscBundleDisplayMngr {
for (ResourceSelection rbt : paneData.getSelectedResources()) {
ResourcePair rscPair = rbt.getResourcePair();
// if( dfltDomRscName == null &&
// rscPair.getResourceData() instanceof AbstractNatlCntrsRequestableResourceData ) {
// rscPair.getResourceData() instanceof
// AbstractNatlCntrsRequestableResourceData ) {
// dfltDomRscName = ((INatlCntrsResourceData)
// rscPair.getResourceData()).getFullResourceName();
// }
// if( rbt.isDominant() ) {
// selDomRsc = (AbstractNatlCntrsRequestableResourceData) rscPair.getResourceData();
// selDomRsc = (AbstractNatlCntrsRequestableResourceData)
// rscPair.getResourceData();
// }
descr.getResourceList().add(rscPair);
}
// set the timeMatcher for the Descriptor (This will be the same timeMatcher
// set the timeMatcher for the Descriptor (This will be the same
// timeMatcher
// for all panes.
descr.setTimeMatcher(timeMatcher);

View file

@ -0,0 +1,159 @@
package gov.noaa.nws.ncep.viz.resources.time_match;
/**
* Time matching for Natl Cntrs is based on the dominant source. The data times
* defined by it are the times for all of the resources. Other resources will
* need to time match their data to this list of data times.
*
* <pre>
*
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 05/02/14 #1131 qzhou Initial creation
*
* </pre>
*
* @author qzhou
* @version 1.0
*/
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import com.raytheon.uf.common.time.DataTime;
public class GraphTimelineUtil {
/*
* Convert UTC calendar time to next hourSnap point
*/
public static Calendar snapTimeToNext(Calendar refTimeCal, int snap) {
Calendar dup = (Calendar) refTimeCal.clone();
if (snap == 0)
return dup;
int hourOfDay = refTimeCal.get(Calendar.HOUR_OF_DAY);
int hour = refTimeCal.get(Calendar.HOUR);
int min = refTimeCal.get(Calendar.MINUTE);
boolean flag = true;
if (hourOfDay != hour)
flag = false;
if (!(hourOfDay % snap == 0 && min == 0))
hourOfDay = (hourOfDay / snap) * snap + snap;
dup.set(Calendar.HOUR_OF_DAY, hourOfDay);
if (flag)
dup.set(Calendar.HOUR, hourOfDay);
else
dup.set(Calendar.HOUR, hourOfDay - 12);
dup.set(Calendar.MINUTE, 0);
return dup;
}
/*
* Convert UTC calendar time to next hourSnap point
*/
public static Calendar snapTimeToPrevious(Calendar refTimeCal, int snap) {
Calendar dup = (Calendar) refTimeCal.clone();
if (snap == 0)
return dup;
int hourOfDay = refTimeCal.get(Calendar.HOUR_OF_DAY);
int hour = refTimeCal.get(Calendar.HOUR);
int min = refTimeCal.get(Calendar.MINUTE);
boolean flag = true;
if (hourOfDay != hour)
flag = false;
if (!(hourOfDay % snap == 0 && min == 0))
hourOfDay = (hourOfDay / snap) * snap;
dup.set(Calendar.HOUR_OF_DAY, hourOfDay);
if (flag)
dup.set(Calendar.HOUR, hourOfDay);
else
dup.set(Calendar.HOUR, hourOfDay - 12);
dup.set(Calendar.MINUTE, 0);
return dup;
}
/*
* Convert UTC calendar time to closest hourSnap point
*/
public static Calendar snapTimeToClosest(Calendar refTimeCal, int snap) {
Calendar dup = (Calendar) refTimeCal.clone();
if (snap == 0)
return dup;
int hourOfDay = refTimeCal.get(Calendar.HOUR_OF_DAY);
int hour = refTimeCal.get(Calendar.HOUR);
int min = refTimeCal.get(Calendar.MINUTE);
boolean flag = true;
if (hourOfDay != hour)
flag = false;
if (!(hourOfDay % snap == 0 && min == 0)) {
if (hourOfDay % snap == 0 || (hourOfDay % snap == 1 && min < 30))
hourOfDay = (hourOfDay / snap) * snap;
else
hourOfDay = (hourOfDay / snap) * snap + snap;
}
dup.set(Calendar.HOUR_OF_DAY, hourOfDay);
if (flag)
dup.set(Calendar.HOUR, hourOfDay);
else
dup.set(Calendar.HOUR, hourOfDay - 12);
dup.set(Calendar.MINUTE, 0);
return dup;
}
/*
* Move UTC selected calendar time to previous hourSnap point
*/
// public static Calendar slideSelectedTimeToRightBysnap(Calendar
// refTimeCal,
// int snap) {
//
// }
/**
* sort on datatime
*/
public static void sortAvailableData(List<DataTime> timeList) {// quan
Collections.sort(timeList, new Comparator<DataTime>() {
@Override
public int compare(DataTime t1, DataTime t2) {
return t1.compareTo(t2);
}
});
}
/**
* sort on datatime
*/
public static void sortAvailableCalendar(List<Calendar> timeList) {// quan
Collections.sort(timeList, new Comparator<Calendar>() {
@Override
public int compare(Calendar t1, Calendar t2) {
return t1.compareTo(t2);
}
});
}
}

View file

@ -13,6 +13,7 @@ import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.TimeZone;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
@ -56,6 +57,7 @@ import com.raytheon.uf.viz.core.rsc.LoadProperties;
* 02/12/13 972 Greg Hull changed to work with INatlCntrsDescriptor
* 04/24/13 689 Xiaochuan Loop length in slctFrames that is set based on default
* or size of selectableDataTimes.
* 05/14/14 1131 Quan Zhou Added graphRange and hourSnap. MouModified generateTimeline
* 07/11/14 TTR1032 J. Wu No timeline needed if no data times available.
*
* </pre>
@ -76,6 +78,12 @@ public class NCTimeMatcher extends AbstractTimeMatcher implements
@XmlAttribute
protected int numFrames;
@XmlAttribute
protected int graphRange;
@XmlAttribute
protected int hourSnap;
@XmlAttribute
protected int skipValue;
@ -94,7 +102,7 @@ public class NCTimeMatcher extends AbstractTimeMatcher implements
// all the times in the db based on the dominant resource
private List<DataTime> allAvailDataTimes;
// all the times in the db based on the dominant resource
// all the times in the time line based on the dominant resource
private List<DataTime> selectableDataTimes;
// the frame times that will be used for the RBD
@ -106,6 +114,10 @@ public class NCTimeMatcher extends AbstractTimeMatcher implements
private final int dfltNumFrames = 0;
private final int dfltGraphRange = 0;
private final int dfltHourSnap = 0;
private final int dfltSkipFrames = 0;
private boolean timesLoaded = false;
@ -126,6 +138,8 @@ public class NCTimeMatcher extends AbstractTimeMatcher implements
selectableDataTimes = new ArrayList<DataTime>();
frameTimes = new ArrayList<DataTime>();
numFrames = dfltNumFrames;
graphRange = dfltGraphRange;
hourSnap = dfltHourSnap;
skipValue = dfltSkipFrames;
timeRange = 0; // set from dominant resource
frameInterval = -1;
@ -144,6 +158,8 @@ public class NCTimeMatcher extends AbstractTimeMatcher implements
frameTimes = new ArrayList<DataTime>(tm.frameTimes);
timesLoaded = tm.timesLoaded;
numFrames = tm.numFrames;
graphRange = tm.graphRange;
hourSnap = tm.hourSnap;
skipValue = tm.skipValue;
timeRange = tm.timeRange;
refTime = (tm.refTime == null ? null : new DataTime(
@ -193,6 +209,22 @@ public class NCTimeMatcher extends AbstractTimeMatcher implements
this.numFrames = numFrames;
}
public int getHourSnap() {
return hourSnap;
}
public void setHourSnap(int hourSnap) {
this.hourSnap = hourSnap;
}
public int getGraphRange() {
return graphRange;
}
public void setGraphRange(int graphRange) {
this.graphRange = graphRange;
}
public int getSkipValue() {
return skipValue;
}
@ -223,15 +255,21 @@ public class NCTimeMatcher extends AbstractTimeMatcher implements
public void setFrameTimes(ArrayList<DataTime> ft) {
frameTimes = ft;
// do we always want to set numFrames here?
if (!this.getDominantResourceName().getRscCategory().getCategoryName()
.equals("TIMESERIES"))
numFrames = frameTimes.size();
else
numFrames = this.getGraphRange() * 60;
}
public List<DataTime> getSelectableDataTimes() {
return selectableDataTimes;
}
public void setSelectableDataTimes(ArrayList<DataTime> selDataTimes) {
void setSelectableDataTimes(ArrayList<DataTime> selDataTimes) {
this.selectableDataTimes = selDataTimes;
}
@ -292,6 +330,7 @@ public class NCTimeMatcher extends AbstractTimeMatcher implements
frameTimes.clear();
selectableDataTimes.clear();
numFrames = 0;
graphRange = 0;
frameInterval = -1;
timeRange = 0;
isForecast = false;
@ -300,7 +339,8 @@ public class NCTimeMatcher extends AbstractTimeMatcher implements
}
numFrames = dominantRscData.getDfltNumFrames();
graphRange = dominantRscData.getDfltGraphRange();
hourSnap = dominantRscData.getDfltHourSnap();
timeRange = dominantRscData.getDfltTimeRange();
skipValue = 0; // no default but reset to 0
@ -337,8 +377,7 @@ public class NCTimeMatcher extends AbstractTimeMatcher implements
}
// if refTime is null, then either use the most recent data as the refTime
// or the cycle
// time for forecast data.
// or the cycle time for forecast data.
public boolean generateTimeline() {
frameTimes.clear();
selectableDataTimes.clear();
@ -356,6 +395,7 @@ public class NCTimeMatcher extends AbstractTimeMatcher implements
// refTime is marshalled out to the bundle file and may be null
// or 'latest' or a time set by the user.
long refTimeMillisecs = 0;
Calendar refTimeCal = null;
// if (isForecast) {
// check cycleTime instead of isForecast since some resources may
@ -369,12 +409,13 @@ public class NCTimeMatcher extends AbstractTimeMatcher implements
} else if (isCurrentRefTime()) {
refTimeMillisecs = Calendar.getInstance().getTimeInMillis();
refTimeCal = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
} else if (isLatestRefTime()) {
refTimeMillisecs = 0;
} else {
refTimeCal = refTime.getRefTimeAsCalendar();
refTimeMillisecs = refTime.getRefTime().getTime();
}
/*
* Always check all available times. If none of the available data times
* falls within the specified time range, then no time line should be
@ -403,13 +444,16 @@ public class NCTimeMatcher extends AbstractTimeMatcher implements
// if we need to get the cycle time for a forecast resource, then
// we will need to query the times of the dominant resource.
if (refTimeMillisecs == 0 || frameInterval == -1) {
// allAvailDataTimes = dominantRscData.getAvailableDataTimes();
// allAvailDataTimes = dominantRscData.getAvailableDataTimes(); //??
if (allAvailDataTimes == null) { // no data
allAvailDataTimes = new ArrayList<DataTime>(); //
return false;
}
// added sort
GraphTimelineUtil.sortAvailableData(allAvailDataTimes);
// if refTime is not given (ie Latest) then get it from the data
if (refTimeMillisecs == 0) {
if (!allAvailDataTimes.isEmpty()) {
@ -419,15 +463,24 @@ public class NCTimeMatcher extends AbstractTimeMatcher implements
// this
// save the sentinel value and get latest when the rbd is
// loaded?
//
refTime = allAvailDataTimes.get((isForecast ? 0
: allAvailDataTimes.size() - 1));
refTimeCal = refTime.getRefTimeAsCalendar();
refTimeMillisecs = refTime.getRefTime().getTime();
} else {
return false;
}
}
// extend refTime to the snap point
if (this.getDominantResourceName().getRscCategory()
.getCategoryName().equals("TIMESERIES")
&& this.getHourSnap() != 0) {
refTimeMillisecs = GraphTimelineUtil.snapTimeToNext(refTimeCal,
this.getHourSnap()).getTimeInMillis();
}
// if generating times from the data then get only those times in
// the selected range.
if (frameInterval == -1) {
@ -502,6 +555,14 @@ public class NCTimeMatcher extends AbstractTimeMatcher implements
} else {
int skipCount = 0;
// set the initial frameTimes from the skip value and numFrames
GraphTimelineUtil.sortAvailableData(selectableDataTimes);
/*
* For graph display, numFrames = 1
*/
if (this.getDominantResourceName().getRscCategory()
.getCategoryName().equals("TIMESERIES"))
numFrames = 1;
for (skipCount = 0; skipCount < selectableDataTimes.size(); skipCount++) {
if (skipCount % (skipValue + 1) == 0) {
@ -552,6 +613,7 @@ public class NCTimeMatcher extends AbstractTimeMatcher implements
if (frameInterval == -1) {
if (!frameTimes.contains(newFrameTime)) {
newFrameTimes.add(newFrameTime);
//System.out.println("**newFrameTime " + newFrameTime);
}
} else if (frameInterval != 0) { // if MANUAL or FRAME_TIMES
// TODO : we could add forecast updates but right now it doesn't

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View file

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>gov.noaa.nws.ncep.viz.rsc.timeseries</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View file

@ -0,0 +1,8 @@
#Mon Feb 13 16:11:02 EST 2012
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.6

View file

@ -0,0 +1,46 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: timeseries
Bundle-SymbolicName: gov.noaa.nws.ncep.viz.rsc.timeseries;singleton:=true
Eclipse-RegisterBuddy: gov.noaa.nws.ncep.viz.resources, com.raytheon.viz.core, com.raytheon.uf.viz.core, com.raytheon.viz.ui, com.raytheon.edex.common, com.raytheon.uf.common.serialization
Eclipse-BuddyPolicy: ext, global
Bundle-Version: 1.0.0.qualifier
Bundle-Activator: gov.noaa.nws.ncep.viz.rsc.timeseries.Activator
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
com.raytheon.uf.viz.core;bundle-version="1.12.1174",
com.raytheon.uf.common.dataplugin;bundle-version="1.12.1174",
com.raytheon.uf.common.time;bundle-version="1.12.1174",
org.apache.commons.lang;bundle-version="2.3.0",
org.geotools;bundle-version="2.6.4",
com.raytheon.uf.common.geospatial;bundle-version="1.12.1174",
com.raytheon.uf.viz.xy;bundle-version="1.12.1174",
com.raytheon.viz.ui;bundle-version="1.12.1174",
gov.noaa.nws.ncep.common.dataplugin.geomag,
gov.noaa.nws.ncep.viz.localization;bundle-version="1.0.0",
com.raytheon.viz.core.graphing;bundle-version="1.12.1174",
com.raytheon.uf.viz.d2d.ui;bundle-version="1.12.1174",
com.raytheon.uf.viz.d2d.core;bundle-version="1.12.1174",
com.raytheon.uf.common.datastorage;bundle-version="1.12.1174",
com.raytheon.uf.common.colormap;bundle-version="1.12.1174",
com.raytheon.viz.core;bundle-version="1.12.1174",
javax.measure;bundle-version="1.0.0",
gov.noaa.nws.ncep.viz.common,
gov.noaa.nws.ncep.viz.resources;bundle-version="1.0.0",
com.raytheon.uf.common.style;bundle-version="1.0.0",
com.raytheon.uf.viz.xy.timeseries
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Import-Package: com.raytheon.uf.viz.xy.timeseries.adapter,
com.raytheon.uf.viz.xy.timeseries.display,
com.raytheon.uf.viz.xy.timeseries.graph,
gov.noaa.nws.ncep.common.dataplugin.geomag,
gov.noaa.nws.ncep.common.dataplugin.geomag.calculation,
gov.noaa.nws.ncep.common.dataplugin.geomag.exception,
gov.noaa.nws.ncep.common.dataplugin.geomag.request,
gov.noaa.nws.ncep.common.dataplugin.geomag.table,
gov.noaa.nws.ncep.common.dataplugin.geomag.util,
gov.noaa.nws.ncep.viz.ui.display
Export-Package: gov.noaa.nws.ncep.viz.rsc.timeseries,
gov.noaa.nws.ncep.viz.rsc.timeseries.rsc

View file

@ -0,0 +1 @@
gov.noaa.nws.ncep.viz.rsc.timeseries.rsc.GeoMagResourceData

View file

@ -0,0 +1,6 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
plugin.xml,\
localization/

View file

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<resourceGroup xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<resource>
<loadProperties loadWithoutData="true"/>
<properties isSystemResource="false"
isBlinking="false" isMapLayer="false" isHoverOn="false"
isVisible="true" />
<resourceData xsi:type="GeoMagResourceData"
isUpdatingOnMetadataOnly="false"
isRequeryNecessaryOnTimeMatch="false">
<frameSpan>${frameSpan}</frameSpan>
<dfltNumFrames>${dfltNumFrames}</dfltNumFrames>
<dfltTimeRange>${dfltTimeRange}</dfltTimeRange>
<timeMatchMethod>${timeMatchMethod}</timeMatchMethod>
<timelineGenMethod>${timelineGenMethod}</timelineGenMethod>
<yAxesData>${yAxesData}</yAxesData>
<dataColor>${dataColor}</dataColor>
<xAxesTitle>${xAxesTitle}</xAxesTitle>
<yAxesTitle>${yAxesTitle}</yAxesTitle>
<yDescription>${yDescription}</yDescription>
<metadataMap>
<mapping key="pluginName">
<constraint constraintValue="${pluginName}" constraintType="EQUALS" />
</mapping>
<mapping key="stationCode">
<constraint constraintValue="${stationCode}" constraintType="EQUALS" />
</mapping>
<mapping key="sourceId">
<constraint constraintValue="${sourceId}" constraintType="EQUALS" />
</mapping>
<mapping key="reportType">
<constraint constraintValue="${reportType}" constraintType="EQUALS"/>
</mapping>
</metadataMap>
</resourceData>
</resource>
</resourceGroup>

View file

@ -0,0 +1,170 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
point="gov.noaa.nws.ncep.viz.resources.NC-Resource">
<nc-resource
class="gov.noaa.nws.ncep.viz.rsc.timeseries.rsc.GeoMagResourceData"
editDialogClass="gov.noaa.nws.ncep.viz.rsc.timeseries.rsc.EditTimeSeriesAttrsDialog"
name="GeoMag">
</nc-resource>
</extension>
<extension
point="com.raytheon.uf.viz.core.resource">
<resource
class="gov.noaa.nws.ncep.viz.rsc.timeseries.rsc.GeoMagResource"
recordClass="gov.noaa.nws.ncep.common.dataplugin.geomag.GeoMagRecord"
name="GeoMagResource"
renderingOrderId="PLOT"
resourceType="PLAN_VIEW"/>
</extension>
<extension
point="gov.noaa.nws.ncep.viz.resources.NC-ResourceParameter">
<!-- since this is given in the attribute sets it must have a default
value given so that the code can 'validate' a rsc defn up front (ie w/o an attr set)-->
<nc-resourceParameter
ncResourceName="GeoMag"
paramClass="String"
paramName="pluginName"
defaultValue=""
paramType="REQUEST_CONSTRAINT">
</nc-resourceParameter>
<nc-resourceParameter
ncResourceName="GeoMag"
paramClass="String"
paramName="reportType"
defaultValue=""
paramType="REQUEST_CONSTRAINT">
</nc-resourceParameter>
<nc-resourceParameter
ncResourceName="GeoMag"
paramClass="String"
paramName="stationCode"
defaultValue="BOU"
paramType="REQUEST_CONSTRAINT">
</nc-resourceParameter>
<nc-resourceParameter
ncResourceName="GeoMag"
paramClass="String"
paramName="sourceId"
defaultValue="101"
paramType="REQUEST_CONSTRAINT">
</nc-resourceParameter>
<nc-resourceParameter
ncResourceName="GeoMag"
paramClass="String"
paramName="yAxesData"
defaultValue=""
paramType="EDITABLE_ATTRIBUTE">
</nc-resourceParameter>
<nc-resourceParameter
ncResourceName="GeoMag"
paramClass="RGB"
paramName="dataColor"
defaultValue=""
paramType="EDITABLE_ATTRIBUTE">
</nc-resourceParameter>
<nc-resourceParameter
ncResourceName="GeoMag"
paramClass="String"
paramName="xAxesTitle"
defaultValue=""
paramType="EDITABLE_ATTRIBUTE">
</nc-resourceParameter>
<nc-resourceParameter
ncResourceName="GeoMag"
paramClass="String"
paramName="yAxesTitle"
defaultValue=""
paramType="EDITABLE_ATTRIBUTE">
</nc-resourceParameter>
<nc-resourceParameter
ncResourceName="GeoMag"
paramClass="String"
paramName="yDescription"
defaultValue=""
paramType="EDITABLE_ATTRIBUTE">
</nc-resourceParameter>
<nc-resourceParameter
ncResourceName="GeoMag"
paramClass="RGB"
paramName="legendColor"
defaultValue="RGB {200, 200, 200}"
paramType="IMPLEMENTATION_PARAM">
</nc-resourceParameter>
</extension>
<extension
point="org.eclipse.ui.commands">
<command
id="gov.noaa.nws.ncep.viz.rsc.timeseries.view.KTableAction"
name="K-index and Gamma">
</command>
<command
id="gov.noaa.nws.ncep.viz.rsc.timeseries.view"
name="GeoMag">
</command>
</extension>
<extension
point="org.eclipse.ui.handlers">
<handler
class="gov.noaa.nws.ncep.viz.rsc.timeseries.view.KTableAction"
commandId="gov.noaa.nws.ncep.viz.rsc.timeseries.view">
</handler>
</extension>
<extension
point="org.eclipse.ui.views">
<category
id="gov.noaa.nws.ncep.viz.ui.nmap"
name="GEOMAG"/>
<view
category="gov.noaa.nws.ncep.viz.ui.nmap"
allowMultiple="false"
restorable="true"
class="gov.noaa.nws.ncep.viz.rsc.timeseries.view.KTableView"
id="gov.noaa.nws.ncep.viz.rsc.timeseries.view.KTableView"
name="K-Index and Gamma values in the synoptic periods"/>
<view
category="gov.noaa.nws.ncep.viz.ui.nmap"
allowMultiple="false"
restorable="true"
class="gov.noaa.nws.ncep.viz.rsc.timeseries.view.SamplingView"
id="gov.noaa.nws.ncep.viz.rsc.timeseries.view.SamplingView"
name="Readout"/>
</extension>
<extension
point="com.raytheon.viz.ui.contextualMenu">
<contextualMenu
actionClass="gov.noaa.nws.ncep.viz.rsc.timeseries.actions.EnableSamplingAction"
capabilityInterface="gov.noaa.nws.ncep.viz.rsc.timeseries.rsc.GeoMagResource"
name="SamplingView"
sortID="14">
</contextualMenu>
</extension>
<extension
point="com.raytheon.viz.ui.contextualMenu">
<contextualMenu
actionClass="gov.noaa.nws.ncep.viz.rsc.timeseries.actions.EnableKTableViewAction"
capabilityInterface="gov.noaa.nws.ncep.viz.rsc.timeseries.rsc.GeoMagResource"
capabilityClass="gov.noaa.nws.ncep.viz.rsc.timeseries.rsc.GeoMagResource"
name="KTableView"
sortID="15">
</contextualMenu>
</extension>
<!--extension
point="com.raytheon.uf.viz.core.descriptor">
<descriptor
class="gov.noaa.nws.ncep.viz.rsc.timeseries.GeoMagDescriptor"
editor="gov.noaa.nws.ncep.viz.ui.display.GraphDisplay"
name="GeoMagDescriptor">
</descriptor>
</extension-->
</plugin>

View file

@ -0,0 +1,72 @@
package gov.noaa.nws.ncep.viz.rsc.timeseries;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
/**
* The activator class controls the plug-in life cycle
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 02/21/2013 958 qzhou, sgurung Initial creation
* 03/06/2013 958 ghull rm preferenceStore
*
* </pre>
*
* @author qzhou, sgurung
* @version 1.0
*/
public class Activator extends AbstractUIPlugin {
// The plug-in ID
public static final String PLUGIN_ID = "gov.noaa.nws.ncep.viz.rsc.timeSeries"; //$NON-NLS-1$
private IPreferenceStore myprefs = null;
// The shared instance
private static Activator plugin;
/**
* The constructor
*/
public Activator() {
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext
* )
*/
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext
* )
*/
public void stop(BundleContext context) throws Exception {
plugin = null;
super.stop(context);
}
/**
* Returns the shared instance
*
* @return the shared instance
*/
public static Activator getDefault() {
return plugin;
}
}

View file

@ -0,0 +1,134 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package gov.noaa.nws.ncep.viz.rsc.timeseries;
import gov.noaa.nws.ncep.viz.common.display.INatlCntrsDescriptor;
import gov.noaa.nws.ncep.viz.resources.time_match.NCTimeMatcher;
import gov.noaa.nws.ncep.viz.ui.display.NCTimeSeriesDescriptor;
import gov.noaa.nws.ncep.viz.ui.display.NCTimeSeriesRenderableDisplay;
import gov.noaa.nws.ncep.viz.ui.display.NcDisplayMngr;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.viz.core.IDisplayPane;
import com.raytheon.uf.viz.core.PixelExtent;
import com.raytheon.uf.viz.core.drawables.AbstractDescriptor;
import com.raytheon.uf.viz.core.drawables.ResourcePair;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.xy.graph.IGraph;
import com.raytheon.viz.ui.editor.AbstractEditor;
/**
* Geomag descriptor, needed so loading bundles know what editor to load with
* this descriptor.
*
* <pre>
*
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------ ---------- ---------- --------------------------
* 06/13/2014 #1136 qzhou Initial creation
* Added functions to set it up.
* </pre>
*
* @author qzhou
* @version 1.0
*/
@XmlAccessorType(XmlAccessType.NONE)
public class GeoMagDescriptor extends NCTimeSeriesDescriptor implements
INatlCntrsDescriptor {
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(AbstractDescriptor.class);
public GeoMagDescriptor() {
super();
}
public GeoMagDescriptor(PixelExtent pixelExtent) {
super(pixelExtent);
}
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.viz.xy.graph.XyGraphDescriptor#constructGraph()
*/
@Override
public IGraph constructGraph() {
return new GeoMagGraph(this);
}
public static IDisplayPane[] getDisplayPane() {
// get the pane of the selected resource.
AbstractEditor editor = NcDisplayMngr.getActiveNatlCntrsEditor();
return (IDisplayPane[]) editor.getDisplayPanes();
}
public void addDescriptor(GeoMagDescriptor desc, IDisplayPane pane) {
NCTimeSeriesRenderableDisplay rendDisp = (NCTimeSeriesRenderableDisplay) pane
.getRenderableDisplay();
if (!(rendDisp instanceof NCTimeSeriesRenderableDisplay)) {
try {
throw new VizException(
"Error: can't zoom to resource in the renderable display : "
+ rendDisp.getClass().getName());
} catch (VizException e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
e);
}
}
rendDisp.setDescriptor(desc);
}
public void setResourcePair(GeoMagDescriptor desc, IDisplayPane pane) {
List<ResourcePair> rlist = pane.getRenderableDisplay().getDescriptor()
.getResourceList();
if (rlist != null) {
ResourcePair[] rp = rlist.toArray(new ResourcePair[rlist.size()]);
desc.setSerializableResources(rp);
}
}
public void setNCTimeMatcher(GeoMagDescriptor desc, IDisplayPane pane) {
NCTimeMatcher tm = (NCTimeMatcher) pane.getDescriptor()
.getTimeMatcher();
desc.setTimeMatcher(tm);
}
}

View file

@ -0,0 +1,704 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package gov.noaa.nws.ncep.viz.rsc.timeseries;
import gov.noaa.nws.ncep.common.dataplugin.geomag.table.KStationCoefficient;
import gov.noaa.nws.ncep.common.dataplugin.geomag.util.KStationCoefficientLookup;
import gov.noaa.nws.ncep.viz.resources.time_match.NCTimeMatcher;
import gov.noaa.nws.ncep.viz.rsc.timeseries.rsc.GeoMagResource;
import gov.noaa.nws.ncep.viz.rsc.timeseries.rsc.GeoMagResourceData;
import gov.noaa.nws.ncep.viz.ui.display.NCTimeSeriesGraph;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.TimeZone;
import org.eclipse.swt.graphics.RGB;
import com.raytheon.uf.common.time.DataTime;
import com.raytheon.uf.viz.core.DrawableString;
import com.raytheon.uf.viz.core.IGraphicsTarget;
import com.raytheon.uf.viz.core.IGraphicsTarget.HorizontalAlignment;
import com.raytheon.uf.viz.core.IGraphicsTarget.LineStyle;
import com.raytheon.uf.viz.core.IGraphicsTarget.TextStyle;
import com.raytheon.uf.viz.core.IGraphicsTarget.VerticalAlignment;
import com.raytheon.uf.viz.core.PixelExtent;
import com.raytheon.uf.viz.core.RGBColors;
import com.raytheon.uf.viz.core.drawables.IFont;
import com.raytheon.uf.viz.core.drawables.PaintProperties;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
import com.raytheon.uf.viz.core.rsc.AbstractVizResource.ResourceStatus;
import com.raytheon.uf.viz.xy.graph.GraphLabelComparator;
import com.raytheon.uf.viz.xy.graph.XyGraphDescriptor;
import com.raytheon.uf.viz.xy.graph.axis.GraphAxis;
import com.raytheon.uf.viz.xy.graph.axis.IAxis;
import com.raytheon.uf.viz.xy.graph.axis.LinearAxisPlacer;
import com.raytheon.uf.viz.xy.graph.labeling.DataTimeLabel;
import com.raytheon.uf.viz.xy.graph.labeling.IGraphLabel;
import com.raytheon.uf.viz.xy.map.rsc.IGraphableResource;
import com.raytheon.viz.core.graphing.xy.XYImageData;
import com.vividsolutions.jts.geom.Coordinate;
/**
* The geomag graph, needs to be extracted into AbstractGraph
*
* <pre>
*
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 06/10/2014 1136 qzhou Changed graphExtent for time series 1000*400
* Added getStationLocalTime. Added paintBorderRect, Added paintMidnightNoon,
* Added paintXTitle. Modified paintTitles. Added ticks on yAxes.
* </pre>
*
* @author qzhou
* @version 1.0
*/
public class GeoMagGraph extends NCTimeSeriesGraph {
private SimpleDateFormat sdf;
private int duration;
private double deltaMax = 0.0;
public GeoMagGraph(XyGraphDescriptor descriptor) {
super(descriptor);
sdf = new SimpleDateFormat("HHmm");
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
}
@Override
protected void createAxes() {
/*
* graphExtent(25,999,25,875) is not wide enough for time sereis panes.
* Make the wide as 2.5 times of height. Make new extent graphExtent(0,
* 1000, 300, 700).
*/
graphExtent = new PixelExtent(0, 1000, 300, 700);
double minX = graphExtent.getMinX();
double maxX = graphExtent.getMaxX();
double minY = graphExtent.getMinY();
double maxY = graphExtent.getMaxY();
// Set up the bounding box axes
minXAxis.setStartLoc(new Coordinate(minX, maxY, 0));
minXAxis.setEndLoc(new Coordinate(maxX, maxY, 0));
maxXAxis.setStartLoc(new Coordinate(minX, minY, 0));
maxXAxis.setEndLoc(new Coordinate(maxX, minY, 0));
minYAxis.setStartLoc(new Coordinate(minX, maxY, 0));
minYAxis.setEndLoc(new Coordinate(minX, minY, 0));
maxYAxis.setStartLoc(new Coordinate(maxX, maxY, 0));
maxYAxis.setEndLoc(new Coordinate(maxX, minY, 0));
// Create the Axis if they do not exist
double halfDelta = getDeltaMax() / 2.0;
xAxes = new IAxis[5]; // fixed 5
for (int i = 0; i < xAxes.length; ++i) {
xAxes[i] = new GraphAxis();
xAxes[i].setLineStyle(LineStyle.DOTTED);
xAxes[i].setDrawAxis(true);
if (i < xAxes.length / 2)
xAxes[i].setDiscreteValue(-halfDelta / (i + 1));
else if (i > xAxes.length / 2)
xAxes[i].setDiscreteValue(halfDelta / (xAxes.length - i));
else if (i == xAxes.length / 2)
xAxes[i].setDiscreteValue(00.0);
}
xAxisPlacer.setPixelWidth(graphExtent.getHeight());
yAxisPlacer.setPixelWidth(graphExtent.getWidth());
// Place the data axes
double[] offsets = xAxisPlacer.placeAxes(xAxes);
for (int i = 0; i < offsets.length; ++i) {
double offset = offsets[i];
xAxes[i].setStartLoc(new Coordinate(minX, maxY - offset, 0));
xAxes[i].setEndLoc(new Coordinate(maxX, maxY - offset, 0));
}
createVerticalAxes();
}
private void createVerticalAxes() {
double start = 0;
double end = 0;
if (xLabels.size() > 0) {
start = xLabels.get(0).getDiscreteValue();
end = xLabels.get(xLabels.size() - 1).getDiscreteValue();
}
double diff = end - start;
double numint = xLabels.size() - 1;
yAxes = new IAxis[xLabels.size()];
for (int i = 0; i < xLabels.size(); ++i) {
yAxes[i] = new GraphAxis();
yAxes[i].setLineStyle(LineStyle.SOLID);
yAxes[i].setDrawAxis(true);
yAxes[i].setDiscreteValue(start + (diff * i / numint));
}
double maxX = graphExtent.getMaxX();
double maxY = graphExtent.getMaxY();
double[] offsets = yAxisPlacer.placeAxes(yAxes);
for (int i = 0; i < offsets.length; ++i) {
double offset = offsets[i];
yAxes[i].setStartLoc(new Coordinate(maxX - offset, maxY, 0));
yAxes[i].setEndLoc(new Coordinate(maxX - offset, maxY, 0));
}
}
@Override
protected boolean canHandleResoruce(IGraphableResource<?, ?> rsc) {
// Can only handle graphing of GeoMagResources
return (rsc instanceof GeoMagResource);
}
@Override
protected void paintUnits(IGraphicsTarget target, PaintProperties paintProps)
throws VizException {
RGB colorToUse = null;
List<DrawableString> strings = new ArrayList<DrawableString>();
for (IGraphableResource<?, ?> grsc : graphResource) {
GeoMagResource rsc = (GeoMagResource) grsc;
if (rsc == null) {
continue;
} else if (rsc.getData() == null) {
continue;
} else if (rsc.getData().getData() == null) {
continue;
} else if (rsc.getData().getData().size() < 1) {
continue;
}
if (rsc.getProperties().isVisible()) {
colorToUse = RGBColors.getRGBColor("white");
if (rsc.getData() == null
|| rsc.getData().getData().size() == 0
|| !(rsc.getData().getData().get(0) instanceof XYImageData)) {
for (int i = 0; i < xAxes.length; i++) {
Coordinate[] coords = xAxes[i].getCoordinates();
if (coords[0].y < graphExtent.getMinY()) {
continue;
}
DrawableString parameters = new DrawableString("",
colorToUse);
parameters.font = unitsFont;
parameters.textStyle = TextStyle.DROP_SHADOW;
parameters.horizontalAlignment = HorizontalAlignment.RIGHT;
parameters.magnification = this.currentMagnification;
String value = df.format(xAxes[i].getDiscreteValue());
if (i == 0) {
parameters.verticallAlignment = VerticalAlignment.BOTTOM;
} else {
parameters.verticallAlignment = VerticalAlignment.MIDDLE;
}
parameters.setText(value, colorToUse);
parameters.setCoordinates(coords[0].x, coords[0].y,
coords[0].z);
strings.add(parameters);
}
}
}
}
target.drawStrings(strings);
paintDataTimeUnits(target, paintProps, xLabels);
}
@Override
public void constructVirtualExtent() {
// make sure all resources are initialized
for (IGraphableResource<?, ?> grsc : graphResource) {
GeoMagResource rsc = (GeoMagResource) grsc;
if (rsc.getStatus() != ResourceStatus.INITIALIZED) {
return;
}
}
// Loop through resources and create extent then call
// updateVirtualExtent
double[] minMaxY = new double[2];
xLabels.clear();
getXaxisIntervals(xLabels);
double minX = 0;
double maxX = 0;
minMaxY[0] = 0;
minMaxY[1] = 0;
double delta = getDeltaMax();
minMaxY[0] = -1. * delta / 2.0;
minMaxY[1] = delta / 2.0;
if (xLabels.size() > 0) {
minX = xLabels.get(0).getDiscreteValue();
maxX = xLabels.get(xLabels.size() - 1).getDiscreteValue();
}
// normalizeAxis now takes into accout data that will never be
// negative like wind speed.
// normalizeAxis(minMaxY);
xAxisPlacer = new LinearAxisPlacer(graphExtent.getHeight(), minMaxY[0],
minMaxY[1]);
yAxisPlacer = new LinearAxisPlacer(graphExtent.getWidth(), minX, // q
maxX);
updateVirtualExtent();
newResources = false;
}
private void getXaxisIntervals(List<IGraphLabel<DataTime>> xLabels) {
for (IGraphableResource<?, ?> grsc : graphResource) {
if (grsc instanceof GeoMagResource) {
GeoMagResource rsc = (GeoMagResource) grsc;
DataTime[] range = rsc.getDataTimes();
if (range == null || range.length == 0)
continue;
DataTime start = range[0];
xLabels.add(new DataTimeLabel(start));
DataTime end = range[range.length - 1];
xLabels.add(new DataTimeLabel(end));
NCTimeMatcher tm = (NCTimeMatcher) rsc.getDescriptor()
.getTimeMatcher();
if (tm != null)
duration = tm.getGraphRange();
int numInterval = 4;
if (duration > 12 & duration < 72)
numInterval = duration / 3;
else if (duration >= 72 & duration < 168)
numInterval = duration / 6;
else if (duration >= 168)
numInterval = duration / 12;
long diff = end.getRefTime().getTime()
- start.getRefTime().getTime();
for (int i = 1; i < numInterval; i++) {
long startTime = start.getRefTime().getTime();
long newTime = startTime + (diff * i / numInterval);
DataTime dtime = new DataTime(new Date(newTime));
xLabels.add(new DataTimeLabel(dtime));
}
}
for (IGraphLabel<DataTime> label : xLabels) {
label.setResource((AbstractVizResource<?, ?>) grsc);
}
}
Collections.sort(xLabels, new GraphLabelComparator());
}
private double getDeltaFromResource() {
double delta = 0.0;
for (IGraphableResource<?, ?> grsc : graphResource) {
if (grsc instanceof GeoMagResource) {
GeoMagResource rsc = (GeoMagResource) grsc;
delta = Math.max(delta, rsc.getDelta());
}
}
return delta;
}
private double getDeltaMax() {
if (deltaMax < getDeltaFromResource())
deltaMax = getDeltaFromResource();
return deltaMax;
}
@Override
protected void paintTitles(IGraphicsTarget target,
PaintProperties paintProps) throws VizException {
RGB colorToUse = RGBColors.getRGBColor("white");
List<String> baselineAndColor = new ArrayList<String>();
// paint first x title
for (IGraphableResource<?, ?> grsc : graphResource) {
GeoMagResource rsc = (GeoMagResource) grsc;
if (rsc.getProperties().isVisible()) {
if (((GeoMagResourceData) rsc.getResourceData())
.getYAxesTitle().substring(1, 2).equals(" ")) {
String color = ((GeoMagResourceData) rsc.getResourceData())
.getDataColor();
colorToUse = RGBColors.getRGBColor(color);
paintXTitle(target, paintProps,
((GeoMagResourceData) rsc.getResourceData())
.getXAxesTitle(), colorToUse);
}
// break;
}
}
for (IGraphableResource<?, ?> grsc : graphResource) {
GeoMagResource rsc = (GeoMagResource) grsc;
if (rsc.getProperties().isVisible()
&& ((GeoMagResourceData) rsc.getResourceData())
.getYAxesTitle().substring(1, 2).equals(" ")) {// H,D
String color = ((GeoMagResourceData) rsc.getResourceData())
.getDataColor();
colorToUse = RGBColors.getRGBColor(color);
NCTimeMatcher tm = (NCTimeMatcher) rsc.getDescriptor()
.getTimeMatcher();
String rscTitle = rsc.getTitle();
if (!baselineAndColor.contains((rscTitle + "," + color))) {
baselineAndColor.add(rscTitle + "," + color);
}
}
}
// consider autoUpdate, only last H or D title will be displayed
List<String> baseline = new ArrayList<String>();
List<String> baselinePrint = new ArrayList<String>();
for (int i = baselineAndColor.size() - 1; i >= 0; i--) {
String[] string = baselineAndColor.get(i).split(",");
String str1 = string[0].substring(0, string[0].indexOf(" "));
if (!baseline.contains(str1)) {
baseline.add(str1);
baselinePrint.add(baselineAndColor.get(i));
}
}
for (int i = 0; i < baselinePrint.size(); i++) {
String[] string = baselinePrint.get(i).split(",");
if (string.length == 2)
paintYTitle(target, paintProps, string[0],
RGBColors.getRGBColor(string[1]), i + 1);
}
paintBorderRect(target, paintProps, xLabels);
}
protected void paintXTitle(IGraphicsTarget target,
PaintProperties paintProps, String title, RGB titleColor)
throws VizException {
DrawableString titleString = new DrawableString(title, titleColor);
titleString.textStyle = TextStyle.DROP_SHADOW;
titleString.horizontalAlignment = HorizontalAlignment.CENTER;
titleString.verticallAlignment = VerticalAlignment.TOP;
titleString.magnification = this.currentMagnification;
double x = graphExtent.getMinX() + graphExtent.getWidth() / 2;
double y = graphExtent.getMaxY() + 100;
titleString.setCoordinates(x, y);
target.drawStrings(titleString);
}
@Override
protected void paintDataTimeUnits(IGraphicsTarget target,
PaintProperties paintProps, List<IGraphLabel<DataTime>> xLabels)
throws VizException {
List<DrawableString> strings = new ArrayList<DrawableString>(
xLabels.size());
for (IGraphLabel<DataTime> xLabel : xLabels) {
double val = xLabel.getDiscreteValue();
Date date = xLabel.getUnderlyingObject().getRefTime();
RGB labelColor = RGBColors.getRGBColor("white");
DrawableString parameters = new DrawableString(sdf.format(date),
labelColor);
unitsFont = target.initializeFont((String) null, 14.0f,
new IFont.Style[] {});
parameters.font = unitsFont;
parameters.horizontalAlignment = HorizontalAlignment.CENTER;
parameters.verticallAlignment = VerticalAlignment.TOP;
parameters.magnification = this.currentMagnification;
double offset = yAxisPlacer.getPixelLoc(val);
Coordinate loc = new Coordinate(graphExtent.getMinX() + offset,
graphExtent.getMaxY(), 0);
parameters.setCoordinates(loc.x, loc.y, loc.z);
strings.add(parameters);
}
target.drawStrings(strings);
paintMidnightNoon(target, paintProps, xLabels);
paintTicks(target, paintProps, xLabels);
}
private void paintBorderRect(IGraphicsTarget target,
PaintProperties paintProps, List<IGraphLabel<DataTime>> xLabels)
throws VizException {
target.drawRect(graphExtent, RGBColors.getRGBColor("white"), 1, 1);
}
private void paintMidnightNoon(IGraphicsTarget target,
PaintProperties paintProps, List<IGraphLabel<DataTime>> xLabels)
throws VizException {
double start = 0;
double end = 0;
if (xLabels.size() > 0) {
start = xLabels.get(0).getDiscreteValue();
end = xLabels.get(xLabels.size() - 1).getDiscreteValue();
}
if (xLabels == null || xLabels.isEmpty()) // q
return;
String string = xLabels.get(0).getResource().getName();
// Example: string = BOU - H_Component - Begin: 0000 UTC 06 May 2013
double localTime = getStationLocalTime(string.substring(0, 3));
for (int i = 0; i < xLabels.size(); i++) {
int hour = xLabels.get(i).getUnderlyingObject().getValidTime()
.get(Calendar.HOUR_OF_DAY);
// print midnight= orange. noon=yellow
if (hour == 0) {
double val = xLabels.get(i).getDiscreteValue() + localTime
* 3600 * 1000;
if (val >= start && val <= end) {
double offset = yAxisPlacer.getPixelLoc(val);
target.drawLine(graphExtent.getMinX() + offset,
graphExtent.getMinY(), 0, graphExtent.getMinX()
+ offset, graphExtent.getMaxY(), 0,
RGBColors.getRGBColor("orange"), 1,
LineStyle.DASHED);
target.drawString(unitsFont, "M", graphExtent.getMinX()
+ offset, graphExtent.getMinY(), 0.0,
TextStyle.DROP_SHADOW,
RGBColors.getRGBColor("orange"),
HorizontalAlignment.CENTER,
VerticalAlignment.BOTTOM, 0.0);
} else if (val < start) {
val = val + 12;// noon
double offset = yAxisPlacer.getPixelLoc(val);
target.drawLine(graphExtent.getMinX() + offset,
graphExtent.getMinY(), 0, graphExtent.getMinX()
+ offset, graphExtent.getMaxY(), 0,
RGBColors.getRGBColor("yellow"), 1,
LineStyle.DASHED);
target.drawString(unitsFont, "N", graphExtent.getMinX()
+ offset, graphExtent.getMinY(), 0.0,
TextStyle.DROP_SHADOW,
RGBColors.getRGBColor("yellow"),
HorizontalAlignment.CENTER,
VerticalAlignment.BOTTOM, 0.0);
// } else if (val > end) { // sometimes get an extra line
// val = val - 12;// noon
// double offset = yAxisPlacer.getPixelLoc(val);
//
// target.drawLine(graphExtent.getMinX() + offset,
// graphExtent.getMinY(), 0, graphExtent.getMinX()
// + offset, graphExtent.getMaxY(), 0,
// RGBColors.getRGBColor("yellow"), 1,
// LineStyle.DASHED);
}
} else if (hour == 12) {
double val = xLabels.get(i).getDiscreteValue() + localTime
* 3600 * 1000;
if (val > start && val < end) {
double offset = yAxisPlacer.getPixelLoc(val);
target.drawLine(graphExtent.getMinX() + offset,
graphExtent.getMinY(), 0, graphExtent.getMinX()
+ offset, graphExtent.getMaxY(), 0,
RGBColors.getRGBColor("yellow"), 1,
LineStyle.DASHED);
target.drawString(unitsFont, "N", graphExtent.getMinX()
+ offset, graphExtent.getMinY(), 0.0,
TextStyle.DROP_SHADOW,
RGBColors.getRGBColor("yellow"),
HorizontalAlignment.CENTER,
VerticalAlignment.BOTTOM, 0.0);
} else if (val < start) {
val = val + 12;// noon
double offset = yAxisPlacer.getPixelLoc(val);
target.drawLine(graphExtent.getMinX() + offset,
graphExtent.getMinY(), 0, graphExtent.getMinX()
+ offset, graphExtent.getMaxY(), 0,
RGBColors.getRGBColor("orange"), 1,
LineStyle.DASHED);
target.drawString(unitsFont, "M", graphExtent.getMinX()
+ offset, graphExtent.getMinY(), 0.0,
TextStyle.DROP_SHADOW,
RGBColors.getRGBColor("orange"),
HorizontalAlignment.CENTER,
VerticalAlignment.BOTTOM, 0.0);
// } else if (val > end) {
// val = val - 12;// noon
// double offset = yAxisPlacer.getPixelLoc(val);
// target.drawLine(graphExtent.getMinX() + offset,
// graphExtent.getMinY(), 0, graphExtent.getMinX()
// + offset, graphExtent.getMaxY(), 0,
// RGBColors.getRGBColor("orange"), 1,
// LineStyle.DASHED);
}
}
}
}
/*
* get station local time based on longitude. return the local time when utc
* time hour is 0.
*/
private double getStationLocalTime(String stnCode) {
double local = 0;
KStationCoefficientLookup lookup = KStationCoefficientLookup
.getInstance();
KStationCoefficient coefficient = lookup.getStationByCode(stnCode);
String longitude = coefficient.getLongitude();
double lon = Float.parseFloat(longitude);
local = 24 - (lon / 15);
return local;
}
private void paintTicks(IGraphicsTarget target, PaintProperties paintProps,
List<IGraphLabel<DataTime>> xLabels) throws VizException {
// X Axes ticks
if (duration <= 24) {
int count = 0;
double temp = 0;
for (int i = 0; i < xLabels.size(); i++) {
if (temp != xLabels.get(i).getDiscreteValue()) {
temp = xLabels.get(i).getDiscreteValue();
count++;
}
}
int size = (count - 1) * 3 + 1;
double start = 0;
double end = 0;
if (xLabels.size() > 0) {
start = xLabels.get(0).getDiscreteValue();
end = xLabels.get(xLabels.size() - 1).getDiscreteValue();
}
double diff = end - start;
for (int i = 0; i < size; ++i) {
double val = start + (diff * i / (size - 1));
double offset = yAxisPlacer.getPixelLoc(val);
if (i % 3 == 0)
target.drawLine(graphExtent.getMinX() + offset,
graphExtent.getMaxY() - 15, 0,
graphExtent.getMinX() + offset,
graphExtent.getMaxY(), 0,
RGBColors.getRGBColor("white"), 1, LineStyle.SOLID);
else
target.drawLine(graphExtent.getMinX() + offset,
graphExtent.getMaxY() - 10, 0,
graphExtent.getMinX() + offset,
graphExtent.getMaxY(), 0,
RGBColors.getRGBColor("white"), 1, LineStyle.SOLID);
}
} else {
for (int i = 0; i < xLabels.size(); ++i) {
double val = xLabels.get(i).getDiscreteValue();
double offset = yAxisPlacer.getPixelLoc(val);
target.drawLine(graphExtent.getMinX() + offset,
graphExtent.getMaxY() - 15, 0, graphExtent.getMinX()
+ offset, graphExtent.getMaxY(), 0,
RGBColors.getRGBColor("white"), 1, LineStyle.SOLID);
}
}
// Y Axes ticks, fixed 9
for (int i = 0; i < 9; ++i) {
double offset = (graphExtent.getMaxY() - graphExtent.getMinY())
/ (9 - 1);
target.drawLine(graphExtent.getMinX(), graphExtent.getMinY()
+ offset * i, 0, graphExtent.getMinX() + 10,
graphExtent.getMinY() + offset * i, 0,
RGBColors.getRGBColor("white"), 1, LineStyle.SOLID);
}
}
}

View file

@ -0,0 +1,70 @@
package gov.noaa.nws.ncep.viz.rsc.timeseries.actions;
import gov.noaa.nws.ncep.viz.rsc.timeseries.rsc.GeoMagResource;
import com.raytheon.uf.viz.core.drawables.ResourcePair;
import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
import com.raytheon.viz.ui.cmenu.AbstractRightClickAction;
/**
*
* Enable/Disable KTableView for GeoMagResource
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 07/07/2014 R4079 qzhou Initial Creation.
*
* </pre>
*
* @author qzhou
* @version 1
*/
public class EnableKTableViewAction extends AbstractRightClickAction {
boolean isEnabled;
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.action.Action#run()
*/
@Override
public void run() {
AbstractVizResource<?, ?> rsc = getSelectedRsc();
if (rsc instanceof GeoMagResource) {
((GeoMagResource) rsc).reopenKTableView();
}
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.viz.ui.cmenu.AbstractRightClickAction#setSelectedRsc(com
* .raytheon.uf.viz.core.rsc.AbstractVizResource)
*/
@Override
public void setSelectedRsc(ResourcePair selectedRsc) {
super.setSelectedRsc(selectedRsc);
AbstractVizResource<?, ?> rsc = getSelectedRsc();
if (rsc instanceof GeoMagResource) {
}
}
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.action.Action#getText()
*/
@Override
public String getText() {
return "Open KTableView";
}
}

View file

@ -0,0 +1,69 @@
package gov.noaa.nws.ncep.viz.rsc.timeseries.actions;
import gov.noaa.nws.ncep.viz.rsc.timeseries.rsc.GeoMagResource;
import com.raytheon.uf.viz.core.drawables.ResourcePair;
import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
import com.raytheon.viz.ui.cmenu.AbstractRightClickAction;
/**
*
* Enable/Disable Sampling for GeoMagResource
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 07/07/2014 R4079 qzhou Initial Creation.
*
* </pre>
*
* @author qzhou
* @version 1
*/
public class EnableSamplingAction extends AbstractRightClickAction {
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.action.Action#run()
*/
@Override
public void run() {
AbstractVizResource<?, ?> rsc = getSelectedRsc();
if (rsc instanceof GeoMagResource) {
((GeoMagResource) rsc).reopenSamplingView();
}
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.viz.ui.cmenu.AbstractRightClickAction#setSelectedRsc(com
* .raytheon.uf.viz.core.rsc.AbstractVizResource)
*/
@Override
public void setSelectedRsc(ResourcePair selectedRsc) {
super.setSelectedRsc(selectedRsc);
AbstractVizResource<?, ?> rsc = getSelectedRsc();
if (rsc instanceof GeoMagResource) {
}
}
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.action.Action#getText()
*/
@Override
public String getText() {
return "Open Readout";
}
}

View file

@ -0,0 +1,84 @@
package gov.noaa.nws.ncep.viz.rsc.timeseries.rsc;
import gov.noaa.nws.ncep.viz.resources.INatlCntrsResourceData;
import gov.noaa.nws.ncep.viz.resources.attributes.AbstractEditResourceAttrsInteractiveDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Shell;
/**
* An interface to edit TimeSeries resource attributes.
*
* <pre>
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 06/18/2014 #1136 qzhou Initial Creation.
*
* </pre>
*
* @author qzhou
* @version 1
*/
public class EditTimeSeriesAttrsDialog extends
AbstractEditResourceAttrsInteractiveDialog {
public EditTimeSeriesAttrsDialog(Shell parentShell,
INatlCntrsResourceData r, Boolean apply) {
super(parentShell, r, apply);
resourceData = r;
}
private INatlCntrsResourceData resourceData;
@Override
public Composite createDialog(Composite topComp) {
FormLayout layout0 = new FormLayout();
topComp.setLayout(layout0);
Composite top = topComp;
GridLayout mainLayout = new GridLayout(1, true);
mainLayout.marginHeight = 1;
mainLayout.marginWidth = 1;
top.setLayout(mainLayout);
Group colorsGroup = new Group(top, SWT.SHADOW_NONE);
colorsGroup.setText("Colors");
GridData gd = new GridData();
gd.grabExcessHorizontalSpace = true;
gd.grabExcessVerticalSpace = true;
gd.horizontalAlignment = SWT.FILL;
colorsGroup.setLayoutData(gd);
initializeComponents(colorsGroup);
return topComp;
}
public void initializeComponents(final Group colorsGroup) {
colorsGroup.setLayout(new GridLayout(2, true));
}
@Override
public void initWidgets() {
// done in createDialog
}
@Override
protected void dispose() {
super.dispose();
}
}

View file

@ -0,0 +1,268 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package gov.noaa.nws.ncep.viz.rsc.timeseries.rsc;
import gov.noaa.nws.ncep.viz.common.display.NcDisplayType;
import gov.noaa.nws.ncep.viz.resources.AbstractNatlCntrsRequestableResourceData;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
import com.raytheon.uf.common.dataplugin.PluginDataObject;
import com.raytheon.uf.common.dataquery.requests.RequestConstraint;
import com.raytheon.uf.common.time.DataTime;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.rsc.AbstractNameGenerator;
import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
import com.raytheon.uf.viz.core.rsc.IPointsToolContainer;
import com.raytheon.uf.viz.core.rsc.LoadProperties;
import com.vividsolutions.jts.geom.Coordinate;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 06/24/2014 #1136 qzhou Initial creation
*
* </pre>
*
* @author qzhou
* @version 1.0
*/
@XmlAccessorType(XmlAccessType.NONE)
@XmlType(name = "GeoMagResourceData")
public class GeoMagResourceData extends
AbstractNatlCntrsRequestableResourceData implements
IPointsToolContainer {
private static final String stationCodeParam = "stationCode";
private static final String sourceIdParam = "sourceId";
@XmlElement
private String sourceId;
@XmlElement
private String yAxesData;
@XmlElement
private String xAxesTitle;
@XmlElement
private String yAxesTitle;
@XmlElement
private String yDescription;
@XmlElement
private String dataColor;
@XmlElement
private Coordinate coordinate;
protected DataTime startTime;
protected DataTime endTime;
/**
*
*/
public GeoMagResourceData() {
super();
// called by AbstractVizResource.getName()
// and we delegate back to the resource
this.nameGenerator = new AbstractNameGenerator() {
@Override
public String getName(AbstractVizResource<?, ?> resource) {
return ((GeoMagResource) resource).getLegendStr();
}
};
}
@Override
public NcDisplayType[] getSupportedDisplayTypes() {
return new NcDisplayType[] { NcDisplayType.GRAPH_DISPLAY };
}
@Override
protected AbstractVizResource<?, ?> constructResource(
LoadProperties loadProperties, PluginDataObject[] objects)
throws VizException {
return new GeoMagResource(this, loadProperties);
}
/*
* Copied here from TimeSeriesResourceData since it is declared private. Can
* remove this if changed to protected.
*/
private static final String TIME_SERIES_ADAPTER_EXTENSION = "com.raytheon.uf.viz.xy.timeseries.timeseriesadapter";
public String getStation() {
RequestConstraint rc = getMetadataMap().get("stationCode");
return rc.getConstraintValue();
}
@Override
public DataTime[] getAvailableTimes() throws VizException {
DataTime[] times = super.getAvailableTimes();
// if (updating) {
// this.startTime = calculateStartTime();
// }
// times = filterTimes(times, startTime, getEndTime()); quan start
// =current time
// System.out.println("START = " + startTime);
// System.out.println(" END = " + getEndTime());
return times;
}
/**
* Given the times, filter them to only return times between given times
*
* @param times
* @param start
* @param end
* @return
*/
public DataTime[] filterTimes(DataTime[] times, DataTime startTime,
DataTime endTime) {
List<DataTime> validTimes = new ArrayList<DataTime>();
for (DataTime time : times) {
if (time.compareTo(startTime) >= 0 && time.compareTo(endTime) <= 0) {
validTimes.add(time);
}
}
return validTimes.toArray(new DataTime[validTimes.size()]);
}
// private DataTime calculateStartTime() {
// Calendar ttime = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
// ttime.set(Calendar.MINUTE, 0);
// ttime.set(Calendar.SECOND, 0);
// ttime.set(Calendar.MILLISECOND, 0);
// int currentHour = ttime.get(Calendar.HOUR_OF_DAY);
// // Find next synoptic time as endtime
// int hoursToAdd = 3 - (currentHour % 3);
// ttime.add(Calendar.HOUR_OF_DAY, hoursToAdd);
// // subtract plot length time to get starttime
// ttime.add(Calendar.HOUR_OF_DAY, -plotLengthInHours);
// // long tmilli = ttime.getTimeInMillis();
// // tmilli -= plotLengthInHours * MILLISECONDS_PER_HOUR;
//
// return new DataTime(ttime.getTime());
// }
public DataTime getStartTime() {
return startTime;
}
public void setStartTime(DataTime startTime) {
this.startTime = startTime;
}
// public boolean isUpdating() {
// return updating;
// }
//
// public void setUpdating(boolean updating) {
// this.updating = updating;
// }
public String getStationCode() {
return (metadataMap.containsKey(stationCodeParam) ? metadataMap.get(
stationCodeParam).getConstraintValue() : "");
}
public String getSourceId() {
return (metadataMap.containsKey(sourceIdParam) ? metadataMap.get(
sourceIdParam).getConstraintValue() : "");
}
public String getYAxesData() {
return yAxesData;
}
public void setYAxesData(String yAxesData) {
this.yAxesData = yAxesData;
}
public String getXAxesTitle() {
return xAxesTitle;
}
public void setXAxesTitle(String xAxesTitle) {
this.xAxesTitle = xAxesTitle;
}
public String getYAxesTitle() {
return yAxesTitle;
}
public void setYAxesTitle(String yAxesTitle) {
this.yAxesTitle = yAxesTitle;
}
public String getYDescription() {
return yDescription;
}
public void setYDescription(String yDescription) {
this.yDescription = yDescription;
}
public String getDataColor() {
return dataColor;
}
public void setDataColor(String dataColor) {
this.dataColor = dataColor;
}
@Override
public void setPointCoordinate(Coordinate pointCoordinate) {
this.coordinate = pointCoordinate;
}
@Override
public Coordinate getPointCoordinate() {
return coordinate;
}
@Override
public void setPointLetter(String pointLetter) {
// this.pointLetter = pointLetter;
}
@Override
public String getPointLetter() {
return null;
}
}

View file

@ -0,0 +1,220 @@
package gov.noaa.nws.ncep.viz.rsc.timeseries.rsc;
import gov.noaa.nws.ncep.common.dataplugin.geomag.GeoMagAvg;
import gov.noaa.nws.ncep.common.dataplugin.geomag.GeoMagK1min;
import gov.noaa.nws.ncep.common.dataplugin.geomag.GeoMagRecord;
import gov.noaa.nws.ncep.common.dataplugin.geomag.exception.GeoMagException;
import gov.noaa.nws.ncep.common.dataplugin.geomag.request.RetrieveHrAvgRequest;
import gov.noaa.nws.ncep.common.dataplugin.geomag.request.RetrieveK1minRequest;
import gov.noaa.nws.ncep.common.dataplugin.geomag.request.RetrieveSingleK1minRequest;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.TimeZone;
import com.raytheon.uf.common.time.DataTime;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.requests.ThriftClient;
/**
*
* Utility class containing static methods to retrieve and store PGEN Activities
* in EDEX
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 2014/02/12 qzhou initiate
*
* </pre>
*
* @author qzhou
* @version 1.0
*/
public class RetrieveUtils {
/**
* Retrieves the k index
*
* @param stationCode
* @param startTime
* @param endTime
* @return GeoMagK1min record list
* @throws GeoMagException
*/
@SuppressWarnings("unchecked")
public static List<GeoMagK1min> retrieveK1minRecord(String stationCode,
Date startTime, Date endTime) throws GeoMagException {
RetrieveK1minRequest req = new RetrieveK1minRequest(stationCode,
startTime, endTime);
List<GeoMagK1min> resultList = null;
try {
resultList = (List<GeoMagK1min>) ThriftClient.sendRequest(req);
} catch (VizException e) {
throw new GeoMagException(
"Unable to retrieve geomag k-index Activities.", e);
}
return resultList;
}
@SuppressWarnings("unchecked")
public static List<GeoMagK1min> retrieveSingleK1minRecord(
String stationCode, Date startTime) throws GeoMagException {
RetrieveSingleK1minRequest req = new RetrieveSingleK1minRequest(
stationCode, startTime);
List<GeoMagK1min> resultList = null;
try {
resultList = (List<GeoMagK1min>) ThriftClient.sendRequest(req);
} catch (VizException e) {
throw new GeoMagException(
"Unable to retrieve geomag k-index Activities.", e);
}
return resultList;
}
/**
* Retrieves the hHrAvg and dHrAvg
*
* @param stationCode
* @param startTime
* @param endTime
* @return avgList
* @throws GeoMagException
*/
@SuppressWarnings("unchecked")
public static List<GeoMagAvg> retrieveHrAvgs(String stationCode,
Date startTime, Date endTime) throws GeoMagException {
List<GeoMagAvg> avgList = new ArrayList<GeoMagAvg>();
try {
RetrieveHrAvgRequest request = new RetrieveHrAvgRequest(
stationCode, startTime, endTime);// startTime-1
avgList = (List<GeoMagAvg>) ThriftClient.sendRequest(request);
} catch (Exception e) {
throw new GeoMagException(
"Unable to retrieve geomag average Activities.", e);
}
return avgList;
}
// @SuppressWarnings("unchecked")
// public static List<GeoMagRecord> retrieveGeoMag(String stationCode,
// Date startTime, Date endTime) throws GeoMagException {
//
// List<GeoMagRecord> geoMagList = new ArrayList<GeoMagRecord>();
//
// try {
// RetrieveGeoMagRequest request = new RetrieveGeoMagRequest(
// stationCode, startTime, endTime);
// geoMagList = (List<GeoMagRecord>) ThriftClient.sendRequest(request);
//
// } catch (Exception e) {
// throw new GeoMagException(
// "Unable to retrieve geomag average Activities.", e);
//
// }
//
// return geoMagList;
//
// }
public static Date getUtcDate(Calendar cal) {
// cal in GMT timezone
TimeZone z = TimeZone.getDefault();
int offset = z.getOffset(cal.getTimeInMillis());
Date date = new Date(cal.getTimeInMillis() - offset);
return date;
}
public static Calendar getUtcCalendar(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setTimeZone(TimeZone.getTimeZone("GMT"));
calendar.setTimeInMillis(date.getTime());
return calendar;
}
public static String hourTo2DigetStr(Calendar calendar) {
int hour = calendar.get(Calendar.HOUR_OF_DAY);
if (hour == 24)
hour = 0;
String hourStr = String.valueOf(hour);
if (hourStr.length() == 1)
hourStr = '0' + hourStr;
return hourStr;
}
public static Calendar moveToNextSynop(Calendar cal, int synop) {
Calendar calendar = (Calendar) cal.clone();
calendar.add(Calendar.HOUR_OF_DAY, synop);
return calendar;
}
public static DataTime moveToNextSynop(DataTime dataTime, int synop) {
Calendar cal = dataTime.getValidTime();
Calendar calendar = moveToNextSynop(cal, synop);
DataTime newDataTime = new DataTime(calendar);
return newDataTime;
}
public static float[] getMedian(List<GeoMagRecord> records) {
if (records == null || records.size() == 0)
return new float[] { 0f, 0f };
int size = records.size();
float[] hComps = new float[size];
float[] dComps = new float[size];
for (int i = 0; i < size; i++) {
hComps[i] = records.get(i).getComponent_1();
dComps[i] = records.get(i).getComponent_2();
}
Arrays.sort(hComps);
Arrays.sort(dComps);
float hMedian = 0f;
float dMedian = 0f;
if (size % 2 == 0) {
hMedian = (hComps[hComps.length / 2] + hComps[hComps.length / 2 - 1]) / 2;
dMedian = (dComps[dComps.length / 2] + dComps[dComps.length / 2 - 1]) / 2;
} else {
hMedian = hComps[(hComps.length - 1) / 2];
dMedian = dComps[(dComps.length - 1) / 2];
}
return new float[] { hMedian, dMedian };
}
}

View file

@ -0,0 +1,481 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package gov.noaa.nws.ncep.viz.rsc.timeseries.rsc;
import java.awt.geom.Rectangle2D;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.swt.graphics.RGB;
import com.raytheon.uf.common.geospatial.ReferencedCoordinate;
import com.raytheon.uf.viz.core.IExtent;
import com.raytheon.uf.viz.core.IGraphicsTarget;
import com.raytheon.uf.viz.core.IGraphicsTarget.HorizontalAlignment;
import com.raytheon.uf.viz.core.IGraphicsTarget.TextStyle;
import com.raytheon.uf.viz.core.IGraphicsTarget.VerticalAlignment;
import com.raytheon.uf.viz.core.drawables.AbstractRenderableDisplay;
import com.raytheon.uf.viz.core.drawables.IDescriptor;
import com.raytheon.uf.viz.core.drawables.IFont;
import com.raytheon.uf.viz.core.drawables.PaintProperties;
import com.raytheon.uf.viz.core.drawables.ResourcePair;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
import com.raytheon.uf.viz.core.rsc.AbstractVizResource.ResourceStatus;
import com.raytheon.uf.viz.core.rsc.ResourceList;
import com.raytheon.uf.viz.core.rsc.ResourceProperties;
import com.raytheon.uf.viz.core.rsc.capabilities.ColorableCapability;
import com.vividsolutions.jts.geom.Coordinate;
/**
* Sampling resource, draws sample text to the screen. also picks up mouse
* events
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 07/21/2014 R4079 qzhou Initial creation
*
* </pre>
*
* @author qzhou
* @version 1.0
*/
public class Sampling {
/**
* The result of a hover operation: a set of strings and corresponding
* colors
*
*/
protected static class SampleResult {
public SampleResult() {
}
public String[] labels;
public RGB[] colors;
}
private IFont hoverFont = null;
private boolean errorInHovering = false;
private VerticalAlignment verticalAlignment = VerticalAlignment.TOP;
public Sampling() {
}
protected SampleResult doHover(ReferencedCoordinate coord,
ResourceList resources) throws VizException {
SampleResult result = new SampleResult();
List<String> labelList = new ArrayList<String>();
List<RGB> colorList = new ArrayList<RGB>();
try {
int size = resources.size();
for (int i = size - 1; i >= 0; --i) {
ResourcePair rp = resources.get(i);
String retVal = recursiveHoverSearch(rp, coord);
if (retVal != null && retVal.length() > 0) {
RGB color = null;
if (rp.getResource().hasCapability(
ColorableCapability.class)) {
color = rp.getResource()
.getCapability(ColorableCapability.class)
.getColor();
}
int p1, p2;
p1 = 0;
while ((p2 = retVal.indexOf('\n', p1)) >= 0) {
colorList.add(color);
labelList.add(retVal.substring(p1, p2));
p1 = p2 + 1;
}
String s = retVal.substring(p1);
if (s.length() > 0) {
colorList.add(color);
labelList.add(retVal.substring(p1));
}
break;
}
}
} catch (Throwable t) {
/*
* statusHandler.handle(Priority.PROBLEM,
* "Error sampling resources: " + t.getLocalizedMessage(), t);
*/
}
result.labels = labelList.toArray(new String[labelList.size()]);
result.colors = colorList.toArray(new RGB[colorList.size()]);
return result;
}
private String recursiveHoverSearch(ResourcePair rp,
ReferencedCoordinate coordinate) throws VizException {
ResourceProperties props = rp.getProperties();
AbstractVizResource<?, ?> rsc = rp.getResource();
if (rsc != null && rsc.getStatus() == ResourceStatus.INITIALIZED
&& props.isVisible()) {
String curVal = rsc.inspect(coordinate);
if (curVal != null && curVal.length() > 0) {
return curVal;
}
}
return null;
}
/**
* Display sampling on a view, or not on the original screen.
*/
protected void getResult(IGraphicsTarget target, IDescriptor descriptor,
PaintProperties paintProps, ReferencedCoordinate coord)
throws VizException {
if (hoverFont == null) {
hoverFont = target.initializeFont(target.getDefaultFont()
.getFontName(), 10, null);
hoverFont.setSmoothing(false);
hoverFont.setScaleFont(false);
}
doHover(coord, descriptor.getResourceList());
}
/**
* Display sampling on the original screen.
*/
protected void paintResult(IGraphicsTarget target, IDescriptor descriptor,
PaintProperties paintProps, ReferencedCoordinate coord)
throws VizException {
if (hoverFont == null) {
hoverFont = target.initializeFont(target.getDefaultFont()
.getFontName(), 10, null);
hoverFont.setSmoothing(false);
hoverFont.setScaleFont(false);
}
SampleResult result = doHover(coord, descriptor.getResourceList());
verticalAlignment = VerticalAlignment.TOP;
target.clearClippingPlane();
try {
if (result != null) {
double[] world = new double[] { coord.getObject().x,
coord.getObject().y };
double[] pixel = descriptor.worldToPixel(world);
Coordinate c = new Coordinate(pixel[0], pixel[1]);
int canvasWidth = paintProps.getCanvasBounds().width;
double extentWidth = paintProps.getView().getExtent()
.getWidth();
double ratioX = canvasWidth / extentWidth;
if (result.labels.length > 0) {
List<String[]> strsToUse = new ArrayList<String[]>();
List<RGB> colorsToUse = new ArrayList<RGB>();
HorizontalAlignment[] alignments = new HorizontalAlignment[result.labels.length];
boolean[] modified = new boolean[result.labels.length];
for (int i = 0; i < modified.length; ++i) {
modified[i] = false;
alignments[i] = HorizontalAlignment.LEFT;
String[] tmp = new String[] { result.labels[i],
result.labels[i] };
strsToUse.add(tmp);
}
adjustStrings(target, paintProps, strsToUse, modified,
alignments, c, ratioX, null);
HorizontalAlignment horizontalAlignment = alignments[0];
boolean good = true;
for (int i = 1; i < alignments.length && good; ++i) {
if (horizontalAlignment != alignments[i]) {
good = false;
}
}
if (!good) {
// not all the same, figure out alignments!!!
int maxLen = 0;
int i = 0;
for (String[] s : strsToUse) {
if (s[0].length() > maxLen) {
maxLen = s[0].length();
horizontalAlignment = alignments[i];
}
++i;
}
adjustStrings(target, paintProps, strsToUse, modified,
alignments, c, ratioX, horizontalAlignment);
}
List<String> actualStrs = new ArrayList<String>();
for (int i = 0; i < strsToUse.size(); ++i) {
String[] strs = strsToUse.get(i);
for (int j = 1; j < strs.length; ++j) {
actualStrs.add(strs[j]);
colorsToUse.add(result.colors[i]);
}
}
String[] newStrs = actualStrs.toArray(new String[actualStrs
.size()]);
double referencePtY = adjustLabelWrapY(
target,
newStrs,
c.y
+ ((AbstractRenderableDisplay.CURSOR_HEIGHT) / ratioX),
paintProps.getView().getExtent(), ratioX);
if (horizontalAlignment == HorizontalAlignment.RIGHT) {
c.x -= (target.getStringBounds(hoverFont, newStrs,
TextStyle.BLANKED).getWidth() / ratioX);
}
target.drawStrings(hoverFont, newStrs, c.x, referencePtY,
0.0, IGraphicsTarget.TextStyle.BLANKED,
colorsToUse.toArray(new RGB[colorsToUse.size()]),
HorizontalAlignment.LEFT, verticalAlignment);
}
}
errorInHovering = false;
} catch (Exception e) {
// if (errorInHovering) {
// // Keep down the number of error messages
// /*
// * statusHandler.handle( Priority.PROBLEM,
// * "Error painting sample text: " + e.getLocalizedMessage(), e);
// */
// }
errorInHovering = true;
}
}
private void adjustStrings(IGraphicsTarget target,
PaintProperties paintProps, List<String[]> strsToUse,
boolean[] modified, HorizontalAlignment[] alignments, Coordinate c,
double ratio, HorizontalAlignment targetAlignment) {
List<String[]> strsToUseInternal = new ArrayList<String[]>();
for (int i = 0; i < strsToUse.size(); ++i) {
String str = strsToUse.get(i)[0];
String[] split = str.split("[ ]");
boolean done = false;
int divideBy = strsToUse.get(i).length - 1;
int maxDivisions = 0;
for (int j = 0; j < split.length; ++j) {
if (split[j].isEmpty() == false) {
++maxDivisions;
}
}
if (alignments[i] == targetAlignment) {
strsToUseInternal.add(strsToUse.get(i));
} else {
String[] test = new String[] { str };
while (!done) {
if (divideBy > maxDivisions
|| alignments[i] == targetAlignment) {
done = true;
continue;
}
int approxLenPerStr = str.length() / divideBy;
List<String> strs = new ArrayList<String>();
for (int j = 0; j < split.length;) {
String line = split[j++];
while (j < split.length) {
String s = split[j];
if (s.length() + line.length() <= approxLenPerStr) {
if (!s.isEmpty()) {
if (j == split.length - 1
&& split[1].equalsIgnoreCase("=")) {
line = split[split.length - 1];
} else {
line += " " + s;
}
} else {
line += " ";
}
++j;
} else {
break;
}
}
strs.add(line);
}
test = strs.toArray(new String[strs.size()]);
HorizontalAlignment alignment = adjustLabelWrapX(target,
test, c.x, paintProps.getView().getExtent(), ratio,
alignments[i]);
if (alignment == alignments[i]
&& (targetAlignment == null || alignment == targetAlignment)) {
// the alignment was not changed and we are the target
// alignment, we are done
done = true;
} else {
if (targetAlignment == null) {
// alignment changed, check to see if it changes
// back
HorizontalAlignment tmpAlignment = alignment;
alignment = adjustLabelWrapX(target, test, c.x,
paintProps.getView().getExtent(), ratio,
alignment);
if (alignment != tmpAlignment) {
// we moved back, we need to divide and
// conquer
alignments[i] = HorizontalAlignment.LEFT;
modified[i] = true;
divideBy++;
} else {
// we are good at this alignment
alignments[i] = alignment;
done = true;
}
} else {
// we need to be the targetAlignment
alignment = adjustLabelWrapX(target, test, c.x,
paintProps.getView().getExtent(), ratio,
targetAlignment);
if (alignment == targetAlignment) {
// we are fine at other alignment also, use it:
alignments[i] = alignment;
done = true;
} else {
alignments[i] = targetAlignment;
modified[i] = true;
divideBy++;
}
}
}
}
String[] addTo = new String[test.length + 1];
addTo[0] = str;
for (int j = 0; j < test.length; ++j) {
addTo[j + 1] = test[j];
}
strsToUseInternal.add(addTo);
}
}
strsToUse.clear();
strsToUse.addAll(strsToUseInternal);
}
/**
* Adjusts the x label if the width of the longest label extends the extent
*
* @param target
* @param labels
* @param x
* @param extent
* @param ratio
* @return
*/
private HorizontalAlignment adjustLabelWrapX(IGraphicsTarget target,
String[] labels, double x, IExtent extent, double ratio,
HorizontalAlignment horizontalAlignment) {
double referencePoint = x;
// Find the max width of the label in pixels
double maxWidth = 0;
IFont font = hoverFont;
for (String label : labels) {
Rectangle2D bounds = target.getStringBounds(font, label);
if (bounds.getWidth() > maxWidth) {
maxWidth = bounds.getWidth();
}
}
// Get the width in gl space
double widthInGl = maxWidth / ratio;
if (horizontalAlignment == HorizontalAlignment.LEFT) {
// Check to see if text extends screen extent
if (referencePoint + widthInGl > extent.getMaxX()) {
horizontalAlignment = HorizontalAlignment.RIGHT;
}
} else {
// Check to see if text extends screen extent
if (referencePoint - widthInGl < extent.getMinX()) {
horizontalAlignment = HorizontalAlignment.LEFT;
}
}
return horizontalAlignment;
}
/**
* Adjusts the y label position if the stacked labels exceeds the screen
* extent height
*
* @param target
* @param labels
* @param y
* @param extent
* @param ratio
* @return
*/
private double adjustLabelWrapY(IGraphicsTarget target, String[] labels,
double y, IExtent extent, double ratio) {
double referencePoint = y;
double totalHeight = target.getStringBounds(hoverFont, labels,
TextStyle.BLANKED).getHeight();
// convert to gl space
double maxHeightInGl = (totalHeight) / ratio;
// check to see if height extends map height
if (referencePoint + maxHeightInGl > extent.getMaxY()) {
verticalAlignment = VerticalAlignment.BOTTOM;
referencePoint -= (AbstractRenderableDisplay.CURSOR_HEIGHT + 2)
/ ratio;
}
// return adjusted point
return referencePoint;
}
public void dispose() {
if (hoverFont != null) {
hoverFont.dispose();
}
}
}

View file

@ -0,0 +1,155 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package gov.noaa.nws.ncep.viz.rsc.timeseries.rsc;
import gov.noaa.nws.ncep.viz.ui.display.NcDisplayMngr;
import org.eclipse.swt.widgets.Event;
import com.raytheon.uf.common.geospatial.ReferencedCoordinate;
import com.raytheon.uf.viz.core.IDisplayPane;
import com.raytheon.uf.viz.core.IDisplayPaneContainer;
import com.raytheon.uf.viz.core.drawables.ResourcePair;
import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
import com.raytheon.uf.viz.core.rsc.ResourceList;
import com.raytheon.viz.ui.editor.AbstractEditor;
import com.raytheon.viz.ui.input.InputAdapter;
import com.vividsolutions.jts.geom.Coordinate;
/**
* Default input handler for timeseries/geomag sampling
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 07/16/2014 R4079 qzhou Initial creation
*
* </pre>
*
* @author qzhou
* @version 1.0
*/
public class SamplingInputAdapter<T extends GeoMagResource> extends
InputAdapter {
private T resource;
public SamplingInputAdapter(T resource) {
this.resource = resource;
}
@Override
public boolean handleMouseMove(int x, int y) {
IDisplayPaneContainer container = resource.getResourceContainer();
Coordinate c = container.translateClick(x, y);
boolean isActiveResource = false;
AbstractEditor editor = NcDisplayMngr.getActiveNatlCntrsEditor();
IDisplayPane activePane = editor.getActiveDisplayPane();
ResourceList acResources = activePane.getDescriptor().getResourceList();
int acRscSize = acResources.size();
for (int i = acRscSize - 1; i >= 0; i--) {
ResourcePair rp = acResources.get(i);
AbstractVizResource<?, ?> activeRsc = rp.getResource();
if (activeRsc != null
&& activeRsc instanceof GeoMagResource
&& rp.getProperties().isVisible()
&& !((GeoMagResource) activeRsc).getLegendStr().equals(
"No Data")) {
if (activeRsc.equals(resource)) {
isActiveResource = true;
}
break;
}
}
if (resource.getResourceContainer().getDisplayPanes().length > 1) {
// Coordinate latLonCoord = ((GeoMagResource) resource)
// .getLatLonFromPixel(c);
for (IDisplayPane pane : resource.getResourceContainer()
.getDisplayPanes()) {
if (!pane.equals(activePane) && isActiveResource) {
ResourceList resources = pane.getDescriptor()
.getResourceList();
int size = resources.size();
for (int i = 0; i < size && size > 1; i++) {
ResourcePair rp = resources.get(i);
AbstractVizResource<?, ?> rsc = rp.getResource();
if (rsc != null && rsc instanceof GeoMagResource
&& rp.getProperties().isVisible()) {
// ((GeoMagResource) rsc)
// .setVirtualCursor(latLonCoord);
((GeoMagResource) rsc).issueRefresh();
}
}
}
}
}
if (isActiveResource) {
if (c != null) {
resource.sampleCoord = new ReferencedCoordinate(c);
} else {
resource.sampleCoord = null;
}
}
// The sampling is always true for geomag
resource.issueRefresh();
return false;
}
@Override
public boolean handleMouseDownMove(int x, int y, int mouseButton) {
return handleMouseMove(x, y);
}
public boolean handleMouseExit(Event event) {
resource.sampleCoord = null;
// resource.virtualCursor = null;
resource.issueRefresh();
return false;
}
public boolean handleMouseEnter(Event event) {
return handleMouseMove(event.x, event.y);
}
}

View file

@ -0,0 +1,59 @@
package gov.noaa.nws.ncep.viz.rsc.timeseries.view;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PlatformUI;
/**
*
* KTableView Action for GeoMagResource
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 07/07/2014 R4079 qzhou Initial Creation.
*
* </pre>
*
* @author qzhou
* @version 1
*/
public class KTableAction extends AbstractHandler {
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
/*
* The viewID string is in the XML file for extension point.
*/
IWorkbenchPage wpage = PlatformUI.getWorkbench()
.getActiveWorkbenchWindow().getActivePage();
IViewPart vpart = wpage.findView(KTableView.kTableId);
try {
if (vpart == null) {
vpart = wpage.showView(KTableView.kTableId);
} else {
if (!wpage.isPartVisible(vpart))
vpart = wpage.showView(KTableView.kTableId);
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
}

View file

@ -0,0 +1,394 @@
package gov.noaa.nws.ncep.viz.rsc.timeseries.view;
import gov.noaa.nws.ncep.common.dataplugin.geomag.GeoMagK1min;
import gov.noaa.nws.ncep.common.dataplugin.geomag.GeoMagRecord;
import gov.noaa.nws.ncep.common.dataplugin.geomag.exception.GeoMagException;
import gov.noaa.nws.ncep.viz.rsc.timeseries.rsc.RetrieveUtils;
import gov.noaa.nws.ncep.viz.ui.display.NcDisplayMngr;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.IPartListener;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IViewSite;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.part.ViewPart;
/**
*
* Display KTableView for GeoMagResource
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 07/07/2014 R4079 qzhou Initial Creation.
*
* </pre>
*
* @author qzhou
* @version 1
*/
public class KTableView extends ViewPart implements SelectionListener,
DisposeListener, IPartListener {
public static final String kTableId = "gov.noaa.nws.ncep.viz.rsc.timeseries.view.KTableView";//
public Composite composite = null;
private Text text;
private boolean isEditorVisible = true;
private static KTableView kTableView = null;
public static KTableView getAccess() {
return kTableView;
}
public KTableView() {
super();
if (kTableView == null)
kTableView = this;
else {
KTableView tmp = kTableView;
kTableView = this;
}
}
/**
* Invoked by the workbench to initialize this View.
*/
public void init(IViewSite site) {
try {
super.init(site);
} catch (PartInitException pie) {
pie.printStackTrace();
}
// GeoMagResource.registerMouseHandler();
// page = site.getPage();
// page.addPartListener(this);
}
/**
* Disposes resource. invoked by the workbench
*/
public void dispose() {
if (!isEditorVisible) {
// GeoMagResource.unregisterMouseHandler();
return;
} else {
super.dispose();
// NatlCntrsEditor editor = GeoMagResource.getMapEditor();
//
// if (editor != null) {
// for (IRenderableDisplay display : UiUtil
// .getDisplaysFromContainer(editor)) {
// // System.out.println("display " + display.toString());
// for (ResourcePair rp : display.getDescriptor()
// .getResourceList()) {
// if (rp.getResource() instanceof GeoMagResource) {
// GeoMagResource rsc = (GeoMagResource) rp
// .getResource();
// rsc.unload();
// }
// }
// }
// }
kTableView = null;
/*
* remove the workbench part listener
*/
// page.removePartListener(this);
}
}
private void close() {
IWorkbenchPage wpage = PlatformUI.getWorkbench()
.getActiveWorkbenchWindow().getActivePage();
IViewPart vpart = wpage.findView(kTableId);
wpage.hideView(vpart);
NcDisplayMngr.setPanningMode();
}
@Override
public void createPartControl(Composite parent) {
parent.setLayout(new GridLayout(1, false));
Composite composite = new Composite(parent, SWT.NONE);
composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 4,
1));
composite.setLayout(new GridLayout(2, false));
createTextArea(composite);
}
public void createTextArea(Composite parent) {
// Text display area
text = new Text(parent, SWT.V_SCROLL | SWT.H_SCROLL);
GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
text.setLayoutData(data);
Font font = text.getFont();
FontData[] fontData = font.getFontData();
for (int i = 0; i < fontData.length; i++) {
fontData[i].setStyle(1);
fontData[i].setName("courier");
}
Font newFont = new Font(font.getDevice(), fontData);
text.setFont(newFont);
text.setEditable(false);
// RGB color = RGBColors.getRGBColor("black");
// Device device = parent.getDisplay();
// text.setBackground(new Color(device, color));
}
public void paintKTable(List<GeoMagRecord> recordsList) {
text.setText("");
List<String[]> kList = getKValues(recordsList);
// Add title to kList
String t0 = " ";
String t1 = " K ";
String t2 = " Gamma ";
String t3 = " HK ";
String t4 = " H-Gamma ";
String t5 = " DK ";
String t6 = " D-Gamma ";
// StringBuffer drawStrings = new StringBuffer();
for (int j = 0; j < 7; j++) {
// add title for each j
if (j == 0)
text.append(t0);
else if (j == 1)
text.append(t1);
else if (j == 2)
text.append(t2);
else if (j == 3)
text.append(t3);
else if (j == 4)
text.append(t4);
else if (j == 5)
text.append(t5);
else if (j == 6)
text.append(t6);
// add rest for each j.
for (int i = 0; i < kList.size(); i++) {
String[] drawStr = kList.get(i);
text.append(String.format("%12s", drawStr[j]));
}
text.append("\n");
}
// text.setText(drawStrings.toString());
text.setVisible(true);
}
public List<String[]> getKValues(List<GeoMagRecord> recordsList) {
List<GeoMagK1min> k1minList = null;
List<String[]> kList = new ArrayList<String[]>();
Calendar synTime = null;
for (int i = 1; i < recordsList.size(); i++) { // omit the first
Calendar calInstant = recordsList.get(i).getDataTime()
.getValidTime();
if (i == recordsList.size() - 1) {
if (calInstant.get(Calendar.MINUTE) == 0)
synTime = recordsList.get(recordsList.size() - 2)
.getDataTime().getValidTime();
else
synTime = recordsList.get(recordsList.size() - 1)
.getDataTime().getValidTime();
try {
k1minList = RetrieveUtils.retrieveSingleK1minRecord(
recordsList.get(0).getStationCode(), new Date(
synTime.getTimeInMillis())); // RetrieveUtils.getUtcTime(synTime));
} catch (GeoMagException e) {
System.out
.println("GeoMag KTableView: Error retrieving k1min record.");
}
if (k1minList != null && k1minList.size() > 0) {
GeoMagK1min k1min = k1minList.get(0);
String[] temp = new String[7];
Date d = k1min.getRefTime();
Calendar cal = RetrieveUtils.getUtcCalendar(d);
// deal with recordsList.size()
if (cal.get(Calendar.MINUTE) != 0) {
if (cal.get(Calendar.HOUR_OF_DAY) % 3 == 1)
cal.add(Calendar.HOUR_OF_DAY, 2);
else if (cal.get(Calendar.HOUR_OF_DAY) % 3 == 2)
cal.add(Calendar.HOUR_OF_DAY, 1);
cal.set(Calendar.MINUTE, 0);
}
String end = RetrieveUtils.hourTo2DigetStr(cal);
// minus 3 hour becomes previous synaptic point
cal.add(Calendar.HOUR_OF_DAY, -3);
String start = RetrieveUtils.hourTo2DigetStr(cal);
temp[0] = start + " - " + end;
temp[1] = String.valueOf(k1min.getKestIndex());
temp[2] = String.valueOf((int) k1min.getKestGamma());
temp[3] = String.valueOf(k1min.getHkIndex());
temp[4] = String.valueOf((int) k1min.getHkGamma());
temp[5] = String.valueOf(k1min.getDkIndex());
temp[6] = String.valueOf((int) k1min.getDkGamma());
kList.add(temp);
}
} else if (!(calInstant.get(Calendar.HOUR_OF_DAY) % 3 == 0 && calInstant
.get(Calendar.MINUTE) == 0)) {
synTime = calInstant;
} else {
try {
k1minList = RetrieveUtils.retrieveSingleK1minRecord(
recordsList.get(0).getStationCode(), new Date(
synTime.getTimeInMillis())); // RetrieveUtils.getUtcTime(synTime));
} catch (GeoMagException e) {
System.out
.println("GeoMag KTableView: Error retrieving k1min record.");
}
if (k1minList != null && k1minList.size() > 0) {
GeoMagK1min k1min = k1minList.get(0);
String[] temp = new String[7];
Date d = k1min.getRefTime();
Calendar cal = RetrieveUtils.getUtcCalendar(d);
// adding 1 minute becomes next synaptic point
cal.add(Calendar.MINUTE, 1);
String end = RetrieveUtils.hourTo2DigetStr(cal);
// minus 3 hour becomes previous synaptic point
cal.add(Calendar.HOUR_OF_DAY, -3);
String start = RetrieveUtils.hourTo2DigetStr(cal);
temp[0] = start + " - " + end;
temp[1] = String.valueOf(k1min.getKestIndex());
temp[2] = String.valueOf((int) k1min.getKestGamma());
temp[3] = String.valueOf(k1min.getHkIndex());
temp[4] = String.valueOf((int) k1min.getHkGamma());
temp[5] = String.valueOf(k1min.getDkIndex());
temp[6] = String.valueOf((int) k1min.getDkGamma());
kList.add(temp);
}
}
}
return kList;
}
public Text getText() {
return text;
}
public void setText(Text text) {
this.text = text;
}
@Override
public void setFocus() {
}
@Override
public void partActivated(IWorkbenchPart part) {
}
@Override
public void partBroughtToTop(IWorkbenchPart part) {
}
@Override
public void partClosed(IWorkbenchPart part) {
}
@Override
public void partDeactivated(IWorkbenchPart part) {
}
@Override
public void partOpened(IWorkbenchPart part) {
}
@Override
public void widgetDisposed(DisposeEvent e) {
}
@Override
public void widgetSelected(SelectionEvent e) {
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
}
public void setEditorVisible(boolean isVisible) {
this.isEditorVisible = isVisible;
}
public boolean getEditorVisible() {
return this.isEditorVisible;
}
}

View file

@ -0,0 +1,59 @@
package gov.noaa.nws.ncep.viz.rsc.timeseries.view;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PlatformUI;
/**
*
* Sampling readout Action for GeoMagResource
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 07/07/2014 R4079 qzhou Initial Creation.
*
* </pre>
*
* @author qzhou
* @version 1
*/
public class SamplingAction extends AbstractHandler {
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
/*
* The viewID string is in the XML file for extension point.
*/
IWorkbenchPage wpage = PlatformUI.getWorkbench()
.getActiveWorkbenchWindow().getActivePage();
IViewPart vpart = wpage.findView(SamplingView.samplingId);
try {
if (vpart == null) {
vpart = wpage.showView(SamplingView.samplingId);
} else {
if (!wpage.isPartVisible(vpart))
vpart = wpage.showView(SamplingView.samplingId);
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
}

View file

@ -0,0 +1,374 @@
package gov.noaa.nws.ncep.viz.rsc.timeseries.view;
import gov.noaa.nws.ncep.common.dataplugin.geomag.GeoMagRecord;
import gov.noaa.nws.ncep.viz.rsc.timeseries.rsc.RetrieveUtils;
import gov.noaa.nws.ncep.viz.ui.display.NcDisplayMngr;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StyleRange;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Device;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.IPartListener;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IViewSite;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.part.ViewPart;
/**
*
* Display sampling readout for GeoMagResource
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 07/07/2014 R4079 qzhou Initial Creation.
*
* </pre>
*
* @author qzhou
* @version 1
*/
public class SamplingView extends ViewPart implements SelectionListener,
DisposeListener, IPartListener {
public static final String samplingId = "gov.noaa.nws.ncep.viz.rsc.timeseries.view.SamplingView";
public Composite composite = null;
private StyledText text;
private boolean isEditorVisible = true;
private static SamplingView samplingView = null;
private Device device;
private Color textColor;
private Color currColor;
private final SimpleDateFormat timeSampleFormat = new SimpleDateFormat(
"yyyy/MM/dd'T'HH':'mm");
public static SamplingView getAccess() {
return samplingView;
}
public SamplingView() {
super();
if (samplingView == null)
samplingView = this;
else {
SamplingView tmp = samplingView;
samplingView = this;
}
}
/**
* Invoked by the workbench to initialize this View.
*/
public void init(IViewSite site) {
try {
super.init(site);
} catch (PartInitException pie) {
pie.printStackTrace();
}
}
/**
* Disposes resource. invoked by the workbench
*/
public void dispose() {
if (!isEditorVisible) {
// GeoMagResource.unregisterMouseHandler();
return;
} else {
super.dispose();
// NatlCntrsEditor editor = GeoMagResource.getMapEditor();
//
// if (editor != null) {
// for (IRenderableDisplay display : UiUtil
// .getDisplaysFromContainer(editor)) {
// // System.out.println("display " + display.toString());
// for (ResourcePair rp : display.getDescriptor()
// .getResourceList()) {
// if (rp.getResource() instanceof GeoMagResource) {
// GeoMagResource rsc = (GeoMagResource) rp
// .getResource();
// rsc.unload();
// }
// }
// }
// }
samplingView = null;
// remove the workbench part listener
// page.removePartListener(this);
}
}
private void close() {
IWorkbenchPage wpage = PlatformUI.getWorkbench()
.getActiveWorkbenchWindow().getActivePage();
IViewPart vpart = wpage.findView(samplingId);
wpage.hideView(vpart);
NcDisplayMngr.setPanningMode();
}
@Override
public void createPartControl(Composite parent) {
parent.setLayout(new GridLayout(1, false));
Composite composite = new Composite(parent, SWT.NONE);
composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 4,
1));
composite.setLayout(new GridLayout(2, false));
createTextArea(composite);
}
public void createTextArea(Composite parent) {
// Text display area
text = new StyledText(parent, SWT.V_SCROLL | SWT.H_SCROLL);
GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
text.setLayoutData(data);
Font font = text.getFont();
FontData[] fontData = font.getFontData();
for (int i = 0; i < fontData.length; i++) {
// fontData[i].setHeight(12);
fontData[i].setName("courier");
fontData[i].setStyle(1);
}
Font newFont = new Font(font.getDevice(), fontData);
text.setFont(newFont);
text.setEditable(false);
device = parent.getDisplay();
textColor = new Color(device, 0, 0, 0); // RGBColors.getRGBColor("black"));
currColor = new Color(device, 255, 0, 0); // RGBColors.getRGBColor("red"));
}
public void paintSampling(List<GeoMagRecord> recordsList,
List<Float> hQdcList, List<Float> dQdcList, Calendar cal) {
StyleRange[] styleRanges = new StyleRange[2];
List<String[]> list = new ArrayList<String[]>();
List<GeoMagRecord> geoMagList = getSamplingRecords(recordsList, cal);
// hdev = h_data91440:2879] - h_qdc
List<float[]> devList = getSamplingDevs(recordsList, hQdcList,
dQdcList, cal);
float[] median = RetrieveUtils.getMedian(recordsList);
String timeStr = timeSampleFormat.format(RetrieveUtils.getUtcDate(cal));
text.setText("");
text.append(" Readout H D HDev DDev\n");
for (int i = 0; i < geoMagList.size(); i++) {
GeoMagRecord geomag = geoMagList.get(i);
String[] temp = new String[5];
Calendar calendar = geomag.getDataTime().getValidTime();
temp[0] = timeSampleFormat.format(RetrieveUtils
.getUtcDate(calendar));
temp[1] = String.format("%6.1f",
(geomag.getComponent_1() - median[0]));
temp[2] = String.format("%6.1f",
(geomag.getComponent_2() - median[1]));
temp[3] = String.format("%6.1f",
(geomag.getComponent_1() - devList.get(i)[0]));
temp[4] = String.format("%6.1f",
(geomag.getComponent_2() - devList.get(i)[1]));
// testing
// temp[3] = String.format("%.1f", (devList.get(i)[0] - median[0]));
// temp[4] = String.format("%.1f", (devList.get(i)[1] - median[1]));
list.add(temp);
}
int textLength = 0;
// print the list.
for (int i = 0; i < list.size(); i++) {
String[] drawStr = list.get(i);
for (int j = 0; j < 5; j++) {
if (j == 0) {
// add indent
if (list.get(i)[0].equals(timeStr)) {
textLength = text.getText().length();
text.append("=>" + drawStr[j]);
} else {
text.append(" " + drawStr[j]);
}
} else {
// text.append(String.format("%6s", drawStr[j]));
text.append(drawStr[j]);
}
}
text.append("\n");
}
styleRanges[0] = new StyleRange(0, textLength, currColor, null);
styleRanges[1] = new StyleRange(textLength,
text.getText().length() + 1, textColor, null);
// text.setText(text.getText());
text.setStyleRanges(styleRanges);
text.setVisible(true);
}
public List<float[]> getSamplingDevs(List<GeoMagRecord> recordsList,
List<Float> hQdcList, List<Float> dQdcList, Calendar cal) {
List<float[]> devList = new ArrayList<float[]>();
// according to cal, build displaying List<float[]> devList,
// which is 14 minutes before and after cal
Calendar calStart = (Calendar) cal.clone();
calStart.add(Calendar.MINUTE, -14 - 1); // seconds and round to 1min
Calendar calEnd = (Calendar) cal.clone();
calEnd.add(Calendar.MINUTE, 14);
for (int i = 0; i < recordsList.size(); i++) {
if (recordsList.get(i).getDataTime().getValidTime()
.getTimeInMillis() >= calStart.getTimeInMillis()
&& recordsList.get(i).getDataTime().getValidTime()
.getTimeInMillis() <= calEnd.getTimeInMillis()) {
float hTemp = hQdcList.get(i);
float dTemp = dQdcList.get(i);
devList.add(new float[] { hTemp, dTemp });
}
}
return devList;
}
public List<GeoMagRecord> getSamplingRecords(
List<GeoMagRecord> recordsList, Calendar cal) {
// according to cal, build displaying List<GeoMagRecord> sampRecord,
// which is 14 minutes before and after cal
Calendar calStart = (Calendar) cal.clone();
calStart.add(Calendar.MINUTE, -14 - 1); // seconds and round to 1min
Calendar calEnd = (Calendar) cal.clone();
calEnd.add(Calendar.MINUTE, 14);
// System.out.println("**start " + calStart + " " + calEnd);
List<GeoMagRecord> sampRecord = new ArrayList<GeoMagRecord>();
for (int i = 0; i < recordsList.size(); i++) {
if (recordsList.get(i).getDataTime().getValidTime()
.getTimeInMillis() >= calStart.getTimeInMillis()
&& recordsList.get(i).getDataTime().getValidTime()
.getTimeInMillis() <= calEnd.getTimeInMillis())
sampRecord.add(recordsList.get(i));
}
return sampRecord;
}
public StyledText getText() {
return text;
}
public void setText(StyledText text) {
this.text = text;
}
@Override
public void setFocus() {
}
@Override
public void partActivated(IWorkbenchPart part) {
}
@Override
public void partBroughtToTop(IWorkbenchPart part) {
}
@Override
public void partClosed(IWorkbenchPart part) {
}
@Override
public void partDeactivated(IWorkbenchPart part) {
}
@Override
public void partOpened(IWorkbenchPart part) {
}
@Override
public void widgetDisposed(DisposeEvent e) {
}
@Override
public void widgetSelected(SelectionEvent e) {
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
}
public void setEditorVisible(boolean isVisible) {
this.isEditorVisible = isVisible;
}
public boolean getEditorVisible() {
return this.isEditorVisible;
}
}

View file

@ -16,12 +16,18 @@ Require-Bundle: org.eclipse.ui,
gov.noaa.nws.ncep.viz.localization;bundle-version="1.0.0",
com.raytheon.uf.common.style;bundle-version="1.0.0",
com.raytheon.viz.core.graphing;bundle-version="1.12.1174",
com.raytheon.uf.viz.core.maps;bundle-version="1.12.1174"
com.raytheon.uf.viz.core.maps;bundle-version="1.12.1174",
com.raytheon.uf.viz.xy.timeseries,
com.raytheon.uf.viz.xy;bundle-version="1.12.1174"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Export-Package: gov.noaa.nws.ncep.viz.ui.display
Import-Package: com.raytheon.uf.common.topo,
com.raytheon.uf.viz.core.rsc.legend,
com.raytheon.uf.viz.xy.timeseries.graph,
gov.noaa.nws.ncep.common.dataplugin.geomag.table,
gov.noaa.nws.ncep.common.dataplugin.geomag.util,
gov.noaa.nws.ncep.gempak.parameters.colorbar,
javax.measure.unit,
javax.vecmath

View file

@ -21,6 +21,12 @@
id= "gov.noaa.nws.ncep.viz.ui.display.NTransDisplay"
name="NTRANS Display">
</editor>
<editor
class="gov.noaa.nws.ncep.viz.ui.display.NatlCntrsEditor"
default="true"
id= "gov.noaa.nws.ncep.viz.ui.display.GraphDisplay"
name="GRAPH Display">
</editor>
</extension>
<extension
@ -49,6 +55,11 @@
class="gov.noaa.nws.ncep.viz.ui.display.NCNonMapDescriptor"
editor="gov.noaa.nws.ncep.viz.ui.display.NTransDisplay">
</descriptor>
<descriptor
name="NCTimeSeriesDescriptor"
class="gov.noaa.nws.ncep.viz.ui.display.NCTimeSeriesDescriptor"
editor="gov.noaa.nws.ncep.viz.ui.display.GraphDisplay">
</descriptor>
</extension>
<extension

View file

@ -69,7 +69,7 @@ import com.vividsolutions.jts.geom.Coordinate;
* 09/13/12 ? B. Yin Refresh only for multiple panes
* 01/28/12 #972 Greg Hull created from NCPaneManager minus remove PaneLayout code.
* 12/16/13 #958 sgurung Do not set virtual cursor for NcNonMapRenderableDisplay
*
* 05/16/2014 #1136 qzhou Add NCTimeseries for Graph.
* </pre>
*
* @author ghull
@ -236,6 +236,9 @@ public abstract class AbstractNcPaneManager extends PaneManager implements
return "gov.noaa.nws.ncep.viz.ui.display.NTransDisplay";
} else if (displayType == NcDisplayType.SOLAR_DISPLAY) {
return "gov.noaa.nws.ncep.viz.ui.display.SolarDisplay";
} else if (displayType == NcDisplayType.GRAPH_DISPLAY) {
return "gov.noaa.nws.ncep.viz.ui.display.GraphDisplay";
}
return "Unsupported displayType: " + displayType.toString();
}
@ -248,6 +251,9 @@ public abstract class AbstractNcPaneManager extends PaneManager implements
return "gov.noaa.nws.ncep.viz.ui.display.NCNonMapRenderableDisplay";
} else if (displayType == NcDisplayType.SOLAR_DISPLAY) {
return "gov.noaa.nws.ncep.viz.ui.display.NCNonMapRenderableDisplay";
} else if (displayType == NcDisplayType.GRAPH_DISPLAY) {
return "gov.noaa.nws.ncep.viz.ui.display.NCTimeSeriesRenderableDisplay";
}
return "Unsupported displayTyep: " + displayType.toString();
}
@ -259,6 +265,8 @@ public abstract class AbstractNcPaneManager extends PaneManager implements
return "gov.noaa.nws.ncep.viz.ui.display.NCNonMapDescriptor";
} else if (displayType == NcDisplayType.SOLAR_DISPLAY) {
return "gov.noaa.nws.ncep.viz.ui.display.NCNonMapDescriptor";
} else if (displayType == NcDisplayType.GRAPH_DISPLAY) {
return "gov.noaa.nws.ncep.viz.ui.display.NCTimeSeriesDescriptor";
}
return "Unsupported displayTyep: " + displayType.toString();
}

View file

@ -20,11 +20,11 @@
package gov.noaa.nws.ncep.viz.ui.display;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Event;
import com.raytheon.uf.viz.core.IDisplayPane;
import com.raytheon.uf.viz.core.drawables.IRenderableDisplay;
import com.raytheon.uf.viz.core.drawables.ResourcePair;
@ -36,10 +36,9 @@ import com.raytheon.uf.viz.core.rsc.capabilities.EditableCapability;
import com.raytheon.viz.ui.editor.AbstractEditor;
import com.raytheon.viz.ui.input.EditableManager;
/**
* This handler is responsible for picking up mouse clicks and key press events on resources in
* the legend
* This handler is responsible for picking up mouse clicks and key press events
* on resources in the legend
*
* <pre>
*
@ -84,7 +83,6 @@ public class NCLegendHandler extends AbstractNCLegendInputHandler {
private static boolean isFirstTime = true;
@Override
public boolean handleMouseDown(int x, int y, int mouseButton) {
@ -96,8 +94,8 @@ public class NCLegendHandler extends AbstractNCLegendInputHandler {
IDisplayPane activePane = editor.getActiveDisplayPane();
IRenderableDisplay display = editor.getActiveDisplayPane()
.getRenderableDisplay();
mouseDownRsc = resource.checkLabelSpace(display.getDescriptor(),
activePane.getTarget(), x, y);
mouseDownRsc = resource.checkLabelSpace(
display.getDescriptor(), activePane.getTarget(), x, y);
}
}
return false;
@ -112,8 +110,8 @@ public class NCLegendHandler extends AbstractNCLegendInputHandler {
IDisplayPane activePane = editor.getActiveDisplayPane();
IRenderableDisplay display = editor.getActiveDisplayPane()
.getRenderableDisplay();
ResourcePair rsc = resource.checkLabelSpace(display.getDescriptor(),
activePane.getTarget(), x, y);
ResourcePair rsc = resource.checkLabelSpace(
display.getDescriptor(), activePane.getTarget(), x, y);
if (rsc != null && rsc == mouseDownRsc) {
@ -124,11 +122,11 @@ public class NCLegendHandler extends AbstractNCLegendInputHandler {
return true;
}
}
}
else if (mouseButton == 2 ){
} else if (mouseButton == 2) {
if (mouseDownRsc != null && mouseDownRsc.getResource()
.hasCapability(EditableCapability.class)) {
if (mouseDownRsc != null
&& mouseDownRsc.getResource().hasCapability(
EditableCapability.class)) {
// check / make editable
EditableManager.makeEditable(
mouseDownRsc.getResource(),
@ -149,22 +147,28 @@ public class NCLegendHandler extends AbstractNCLegendInputHandler {
public boolean handleDoubleClick(int x, int y, int mouseButton) {
return false;
}
@Override
public boolean handleMouseDownMove(int x, int y, int mouseButton) {
return (mouseDownRsc != null);
}
public boolean handleMouseHover(int x, int y) {
return false;
}
public boolean handleMouseMove(int x, int y) {
return false;
}
public boolean handleMouseWheel(Event event, int x, int y) {
return false;
}
public boolean handleMouseExit(Event event) {
return false;
}
public boolean handleMouseEnter(Event event) {
return false;
}
@ -172,25 +176,26 @@ public class NCLegendHandler extends AbstractNCLegendInputHandler {
@Override
public boolean handleKeyUp(int keyCode) {
if ( keyCode != SWT.SHIFT && keyCode != SWT.ARROW_UP && keyCode != SWT.ARROW_DOWN ) {
if (keyCode != SWT.SHIFT && keyCode != SWT.ARROW_UP
&& keyCode != SWT.ARROW_DOWN) {
return false;
}
if (keyCode == SWT.SHIFT) {
isShiftDown = true;
}
AbstractEditor editor = NcDisplayMngr.getActiveNatlCntrsEditor();
ResourceList theMainList = editor.getActiveDisplayPane().getDescriptor().getResourceList();
ResourceList theMainList = editor.getActiveDisplayPane()
.getDescriptor().getResourceList();
List<ResourcePair> subListOfResourcesToToggle = new ArrayList<ResourcePair>(0);
List<ResourcePair> subListOfResourcesToToggle = new ArrayList<ResourcePair>(
0);
if (isShiftDown) {
/*
* Pressing the Shift key with either the up or the down arrow key makes
* all the non-system/non map layer resources visible.
* Pressing the Shift key with either the up or the down arrow key
* makes all the non-system/non map layer resources visible.
*/
if ((keyCode == SWT.ARROW_UP || keyCode == SWT.ARROW_DOWN)) {
for (ResourcePair resPair : theMainList) {
@ -211,9 +216,11 @@ public class NCLegendHandler extends AbstractNCLegendInputHandler {
if (!resPair.getProperties().isSystemResource()
&& !resPair.getProperties().isMapLayer()
&& resPair.getResource().getClass().getSimpleName().compareTo("PgenResource") != 0){
&& resPair.getResource().getClass().getSimpleName()
.compareTo("PgenResource") != 0) {
subListOfResourcesToToggle.add(resPair);
allVisible = allVisible && resPair.getProperties().isVisible();
allVisible = allVisible
&& resPair.getProperties().isVisible();
resPair.getProperties().setVisible(false);
}
}
@ -227,15 +234,17 @@ public class NCLegendHandler extends AbstractNCLegendInputHandler {
int listSize = subListOfResourcesToToggle.size();
if (keyCode == SWT.ARROW_UP) {
/*The navigation seems counter-intuitive. Yet this works since
/*
* The navigation seems counter-intuitive. Yet this works since
* the elements displayed in the legend resource are listed from
* bottom-up
*
*The very first time either the up arrow is pressed
*the currentRscIndex gets initialized to the first element in the list
*Subsequently, if the up arrow is pressed, the index is incremented.
*If it points beyond the index of the last resource,
*then it gets reset to the index of the first resource
* The very first time either the up arrow is pressedthe
* currentRscIndex gets initialized to the first element in the
* listSubsequently, if the up arrow is pressed, the index is
* incremented.If it points beyond the index of the last
* resource,then it gets reset to the index of the first
* resource
*/
if (isFirstTime || isShiftDown)
currentRscIndex = 0;
@ -245,15 +254,14 @@ public class NCLegendHandler extends AbstractNCLegendInputHandler {
currentRscIndex = 0;
}
} else if (keyCode == SWT.ARROW_DOWN) {
/*
*The very first time either the down arrow is pressed
*the currentRscIndex gets initialized to the index of the last
*resource in the list
*Subsequently, if the down arrow is pressed, the index is decremented.
*If it points beyond the index of the first resource,
*then it gets set to the index of the last resource
* The very first time either the down arrow is pressedthe
* currentRscIndex gets initialized to the index of the last
* resource in the listSubsequently, if the down arrow is
* pressed, the index is decremented.If it points beyond the
* index of the first resource,then it gets set to the index of
* the last resource
*/
if (isFirstTime || isShiftDown)
@ -267,14 +275,18 @@ public class NCLegendHandler extends AbstractNCLegendInputHandler {
}
/* Make the resource visible */
ResourcePair rscToSetVisible = subListOfResourcesToToggle.get(currentRscIndex);
ResourcePair rscToSetVisible = subListOfResourcesToToggle
.get(currentRscIndex);
rscToSetVisible.getProperties().setVisible(true);
// some resources may have an associated colorBar resource. This will
// be toggled when the resource's propertiesChanged() method is called.
// some resources may have an associated colorBar resource. This
// will
// be toggled when the resource's propertiesChanged() method is
// called.
// This is triggered by setVisible();
if ( isFirstTime && ( ( keyCode == SWT.ARROW_DOWN ) || ( keyCode == SWT.ARROW_UP ) ))
if (isFirstTime
&& ((keyCode == SWT.ARROW_DOWN) || (keyCode == SWT.ARROW_UP)))
isFirstTime = false;
}
@ -283,10 +295,10 @@ public class NCLegendHandler extends AbstractNCLegendInputHandler {
if (isShiftDown) {
/*
*If the shift key was used to make all the resources
*visible again, the isFirstTime boolean is set to true
*So in effect the currentRscIndex is reset to either the first or the last
*non system/non map layer resource depending on which arrow key is
* If the shift key was used to make all the resourcesvisible again,
* the isFirstTime boolean is set to trueSo in effect the
* currentRscIndex is reset to either the first or the lastnon
* system/non map layer resource depending on which arrow key is
* subsequently pressed.
*/
isShiftDown = false;
@ -340,40 +352,3 @@ public class NCLegendHandler extends AbstractNCLegendInputHandler {
rp.getProperties().setVisible(!rp.getProperties().isVisible());
}
}

View file

@ -0,0 +1,249 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package gov.noaa.nws.ncep.viz.ui.display;
import gov.noaa.nws.ncep.viz.common.display.INatlCntrsDescriptor;
import java.lang.reflect.Method;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.TimeZone;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import com.raytheon.uf.common.time.DataTime;
import com.raytheon.uf.viz.core.AbstractTimeMatcher;
import com.raytheon.uf.viz.core.PixelExtent;
import com.raytheon.uf.viz.core.drawables.IDescriptor;
import com.raytheon.uf.viz.core.drawables.ResourcePair;
import com.raytheon.uf.viz.core.rsc.AbstractRequestableResourceData;
import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
import com.raytheon.uf.viz.xy.graph.IGraph;
import com.raytheon.uf.viz.xy.graph.XyGraphDescriptor;
/**
* Time Series descriptor, needed so loading bundles know what editor to load
* with this descriptor.
*
* <pre>
*
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 04/21/2014 #1136 qzhou Initial creation
* 05/21/2014 #1136 qzhou Added override getCurrentFrame, getFrameCount
* </pre>
*
* @author qzhou
* @version 1.0
*/
@XmlAccessorType(XmlAccessType.NONE)
@XmlType(name = "NCTimeSeriesDescriptor")
@XmlRootElement
public class NCTimeSeriesDescriptor extends XyGraphDescriptor implements
INatlCntrsDescriptor {
@XmlElement
private Boolean autoUpdate = false;
@XmlElement
private Boolean suspendZoom = false;
public NCTimeSeriesDescriptor() {
super();
}
public NCTimeSeriesDescriptor(PixelExtent pixelExtent) {
super(pixelExtent);
}
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.viz.xy.graph.XyGraphDescriptor#constructGraph()
*/
@Override
public IGraph constructGraph() {
return new NCTimeSeriesGraph(this);
}
@Override
public Boolean isAutoUpdate() {
return autoUpdate;
}
@Override
public void setAutoUpdate(Boolean autoUpdate) {
this.autoUpdate = autoUpdate;
if (getTimeMatcher() != null) {
// getTimeMatcher().setAutoUpdate( autoUpdate );
}
}
@Override
public Boolean getSuspendZoom() {
return suspendZoom;
}
@Override
public void setSuspendZoom(Boolean suspendZoom) {
this.suspendZoom = suspendZoom;
}
// would rather have add the descriptor to the timeMatcher here but this
// creates a cyclical dependency between display and resources.
@Override
public void setTimeMatcher(AbstractTimeMatcher timeMatcher) {
// if( this.timeMatcher != null ) {
// ((NCTimeMatcher)this.timeMatcher).removeDescriptor( this );
// }
super.setTimeMatcher(timeMatcher);
// ((AbstractDescriptor) descriptor).getTimeMatchingMap().put(
// this, frameTimes.toArray( new DataTime[0] ) );
// timeMatcher.addDescriptor();
}
@Override
public void synchronizeTimeMatching(IDescriptor other) {
}
@Override
public void setFrameTimesForResource(AbstractVizResource<?, ?> rsc,
DataTime[] frameTimes) {
timeMatchingMap.put(rsc, frameTimes);
}
@Override
public int getCurrentFrame() {
return 0;
}
@Override
public int getFrameCount() {
return 1;
}
// notify all of the resources in the resourceList that the timeline has
// changed so
// that they can update there frameDataMap.
//
// TODO : currently we can't reference classes in the resources project
// since this
// causes a cyclical dependency. This works around the problem by calling
// the update()
// method which is defined in AbstractResourceData (not a gov class) but a
// better solution
// would involve resolving the cyclical dependency issue and creating a
// method in
// AbstractNatlCntrsRequestableResourceData.
@Override
public void updateDataTimes(DataTime[] dataTimes) {
setDataTimes(dataTimes); // this also resets bad frames.
try {
//
for (ResourcePair rp : resourceList) {
if (rp.getResourceData() instanceof AbstractRequestableResourceData) {
if (rp.getResource() != null) {
timeMatchingMap.put(rp.getResource(), dataTimes);
}
// HACK ALERT : currently there is a cyclical dependency bug
// that prevents the display project from referencing the
// resources project. So we will use java reflection to get
// around this
//
Method[] mthds = rp.getResource().getClass().getMethods();
for (Method m : mthds) {
// System.out.println( m.getName() );
if (m.getName().equals("updateTimeline")) {
if (m.getReturnType() == Boolean.class
&& m.getParameterTypes().length == 0) {
m.invoke(rp.getResource());
break;
}
}
}
}
}
} catch (Exception e) {
System.out.println(e.getMessage());
}
}
/***
* Provides the time of the frame, given the index of the frame in the
* DataTime array
*
* <pre>
* The time of the frame is displayed in the format:
* Day yyMMdd/HHmm
* Example: Fri 100402/0505
* The time displayed is in GMT
* </pre>
*
* @param currentIndex
* - The index of the frame whose time needs to be determined
* @return The valid time for the frame
*/
@Override
public String getValidTime(int currentIndex) {
Calendar cal;
String strTimeFrame = "";
DataTime[] frameTimeArray = super.getFrames();
if (frameTimeArray != null) {
cal = frameTimeArray[currentIndex].getValidTime();
strTimeFrame = new String(getFrameDateFormat()
.format(cal.getTime()));
}
return strTimeFrame.toUpperCase();
}
public static SimpleDateFormat getFrameDateFormat() {
FRAME_DATE_FORMAT.setTimeZone(TimeZone.getTimeZone("GMT"));
return FRAME_DATE_FORMAT;
}
// only 1 instance
@Override
public void addFrameChangedListener(IFrameChangedListener listener) {
synchronized (listener) {
if (!listeners.contains(listener)) {
super.addFrameChangedListener(listener);
}
}
}
}

View file

@ -0,0 +1,219 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package gov.noaa.nws.ncep.viz.ui.display;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.swt.graphics.RGB;
import com.raytheon.uf.common.time.DataTime;
import com.raytheon.uf.viz.core.DrawableString;
import com.raytheon.uf.viz.core.IGraphicsTarget;
import com.raytheon.uf.viz.core.IGraphicsTarget.HorizontalAlignment;
import com.raytheon.uf.viz.core.IGraphicsTarget.LineStyle;
import com.raytheon.uf.viz.core.IGraphicsTarget.TextStyle;
import com.raytheon.uf.viz.core.IGraphicsTarget.VerticalAlignment;
import com.raytheon.uf.viz.core.drawables.PaintProperties;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.xy.graph.AbstractGraph;
import com.raytheon.uf.viz.xy.graph.XyGraphDescriptor;
import com.raytheon.uf.viz.xy.graph.axis.GraphAxis;
import com.raytheon.uf.viz.xy.graph.axis.IAxis;
import com.raytheon.uf.viz.xy.graph.axis.LinearAxisPlacer;
import com.raytheon.uf.viz.xy.graph.labeling.IGraphLabel;
import com.raytheon.uf.viz.xy.map.rsc.IGraphableResource;
import com.vividsolutions.jts.geom.Coordinate;
/**
* The NC Time Series graph
*
* <pre>
*
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 4/18/2014 qzhou Similar to TimeSeriesGraph
*
* </pre>
*
* @author qzhou
* @version 1.0
*/
public class NCTimeSeriesGraph extends AbstractGraph {
protected static final DecimalFormat df = new DecimalFormat("#.0###");
/** The x labels */
protected List<IGraphLabel<DataTime>> xLabels;
public NCTimeSeriesGraph(XyGraphDescriptor descriptor) {
super(descriptor);
xLabels = new ArrayList<IGraphLabel<DataTime>>();
}
@Override
protected void createAxes() {
// Create the Axis if they do not exist
if (xAxes.length == 0) {
xAxes = new IAxis[11];
for (int i = 0; i < xAxes.length; ++i) {
xAxes[i] = new GraphAxis();
xAxes[i].setLineStyle(LineStyle.DASHED);
xAxes[i].setDrawAxis(true);
}
}
// Update the values
double inc = xAxisPlacer.getDataWidth() / 10;
double val = Math.ceil(xAxisPlacer.getMinDataValue() / inc) * inc;
for (int i = 0; i < xAxes.length; i++) {
xAxes[i].setDiscreteValue(val + inc * i);
}
// Place them
double minX = graphExtent.getMinX();
double maxX = graphExtent.getMaxX();
double maxY = graphExtent.getMaxY();
xAxisPlacer.setPixelWidth(graphExtent.getHeight());
yAxisPlacer.setPixelWidth(graphExtent.getWidth());
// Place the data axes
double[] offsets = xAxisPlacer.placeAxes(xAxes);
for (int i = 0; i < offsets.length; ++i) {
double offset = offsets[i];
xAxes[i].setStartLoc(new Coordinate(minX, maxY - offset, 0));
xAxes[i].setEndLoc(new Coordinate(maxX, maxY - offset, 0));
}
}
@Override
protected boolean canHandleResoruce(IGraphableResource<?, ?> rsc) {
// TODO Auto-generated method stub
return false;
}
@Override
protected void paintTitles(IGraphicsTarget target,
PaintProperties paintProps) throws VizException {
}
@Override
protected void paintUnits(IGraphicsTarget target, PaintProperties paintProps)
throws VizException {
RGB colorToUse = null;
List<DrawableString> strings = new ArrayList<DrawableString>();
for (IGraphableResource<?, ?> grsc : graphResource) {
for (int i = 0; i < xAxes.length; i++) {
Coordinate[] coords = xAxes[i].getCoordinates();
if (coords[0].y < graphExtent.getMinY()) {
continue;
}
DrawableString parameters = new DrawableString("", colorToUse);
parameters.font = unitsFont;
parameters.textStyle = TextStyle.DROP_SHADOW;
parameters.horizontalAlignment = HorizontalAlignment.RIGHT;
parameters.magnification = this.currentMagnification;
String value = df.format(xAxes[i].getDiscreteValue());
if (i == 0) {
parameters.verticallAlignment = VerticalAlignment.BOTTOM;
} else {
parameters.verticallAlignment = VerticalAlignment.MIDDLE;
}
parameters.setText(value, colorToUse);
parameters
.setCoordinates(coords[0].x, coords[0].y, coords[0].z);
strings.add(parameters);
}
}
target.drawStrings(strings);
paintDataTimeUnits(target, paintProps, xLabels);
}
@Override
public void constructVirtualExtent() { // IGraphicsTarget target) {
// TODO: Loop through resources and create extent then call
// updateVirtualExtent
double[] minMaxY = new double[2];
xLabels.clear();
ArrayList<IGraphLabel<Double>> yLabels = new ArrayList<IGraphLabel<Double>>();
getRangeData(xLabels, yLabels);
double minX = 0;
double maxX = 0;
minMaxY[0] = 0;
minMaxY[1] = 0;
if (yLabels.size() > 0) {
minMaxY[0] = yLabels.get(0).getDiscreteValue();
minMaxY[1] = yLabels.get(yLabels.size() - 1).getDiscreteValue();
}
if (xLabels.size() > 0) {
minX = xLabels.get(0).getDiscreteValue();
maxX = xLabels.get(xLabels.size() - 1).getDiscreteValue();
}
// normalizeAxis now takes into accout data that will never be
// negative like wind speed.
normalizeAxis(minMaxY);
xAxisPlacer = new LinearAxisPlacer(graphExtent.getHeight(), minMaxY[0],
minMaxY[1]);
yAxisPlacer = new LinearAxisPlacer(graphExtent.getWidth(), minX, maxX);
updateVirtualExtent();
newResources = false;
}
@Override
public void zoom(int index, Coordinate gridCoord) {
yAxisPlacer.zoom(gridCoord.x - graphExtent.getMinX(), index);
xAxisPlacer.zoom(graphExtent.getMaxY() - gridCoord.y, index);
double inc = xAxisPlacer.getDataWidth() / 10;
double newMin = (int) (xAxisPlacer.getMinDataValue() / inc) * inc;
xAxisPlacer.pan(xAxisPlacer.getPixelLoc(newMin));
updateVirtualExtent();
}
@Override
public void pan(double xDist, double yDist, boolean panning) {
yAxisPlacer.pan(xDist);
xAxisPlacer.pan(-yDist);
if (!panning) {
double inc = xAxisPlacer.getDataWidth() / 10;
double newMin = Math.round(xAxisPlacer.getMinDataValue() / inc)
* inc;
xAxisPlacer.pan(xAxisPlacer.getPixelLoc(newMin));
}
updateVirtualExtent();
}
}

View file

@ -0,0 +1,341 @@
package gov.noaa.nws.ncep.viz.ui.display;
import gov.noaa.nws.ncep.viz.common.area.PredefinedArea;
import gov.noaa.nws.ncep.viz.common.area.PredefinedAreaFactory;
import gov.noaa.nws.ncep.viz.common.display.INatlCntrsPaneManager;
import gov.noaa.nws.ncep.viz.common.display.INatlCntrsRenderableDisplay;
import gov.noaa.nws.ncep.viz.common.display.INcPaneID;
import gov.noaa.nws.ncep.viz.common.display.NcDisplayName.NcPaneName;
import gov.noaa.nws.ncep.viz.common.display.NcDisplayType;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import org.geotools.coverage.grid.GeneralGridEnvelope;
import org.geotools.coverage.grid.GeneralGridGeometry;
import org.geotools.coverage.grid.GridGeometry2D;
import org.geotools.geometry.GeneralEnvelope;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import com.raytheon.uf.common.colormap.prefs.ColorMapParameters;
import com.raytheon.uf.common.serialization.ISerializableObject;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.viz.core.IDisplayPaneContainer;
import com.raytheon.uf.viz.core.IExtent;
import com.raytheon.uf.viz.core.PixelExtent;
import com.raytheon.uf.viz.core.drawables.ResourcePair;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
import com.raytheon.uf.viz.core.rsc.AbstractVizResource.ResourceStatus;
import com.raytheon.uf.viz.core.rsc.GenericResourceData;
import com.raytheon.uf.viz.core.rsc.IResourceGroup;
import com.raytheon.uf.viz.core.rsc.LoadProperties;
import com.raytheon.uf.viz.core.rsc.ResourceList;
import com.raytheon.uf.viz.core.rsc.ResourceList.AddListener;
import com.raytheon.uf.viz.core.rsc.ResourceProperties;
import com.raytheon.uf.viz.core.rsc.capabilities.ColorMapCapability;
import com.raytheon.uf.viz.xy.graph.AbstractXyRenderableDisplay;
import com.raytheon.uf.viz.xy.map.rsc.GraphResource;
import com.raytheon.uf.viz.xy.map.rsc.GraphResourceData;
import com.raytheon.viz.ui.editor.AbstractEditor;
/**
* MapRenderableDisplay for NatlCntrs
*
* <pre>
*
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 04/21/2014 #1136 qzhou Initial creation
*
* </pre>
*
* @author qzhou
* @version 1.0
* @param
*/
@XmlAccessorType(XmlAccessType.NONE)
@XmlType(name = "NCTimeSeriesRenderableDisplay")
@XmlRootElement
public class NCTimeSeriesRenderableDisplay extends AbstractXyRenderableDisplay
implements AddListener, INatlCntrsRenderableDisplay,
ISerializableObject {
@XmlElement
private NcPaneID paneId;
// either the RBD or the Display's paneManager
private INatlCntrsPaneManager paneContainer;
// the initial area that the display is set to. This is used for the unzoom.
// after the display is loaded the user may pan/zoom in which case the
// current
// area(gridGeometry,zoom,mapcenter) will be different than the initial
// area.
//
// @XmlElement
private PredefinedArea initialArea;
public static final GenericResourceData legendRscData = new GenericResourceData(
NCLegendResource.class);
public static final GenericResourceData selectedRscData = new GenericResourceData(
NcSelectedPaneResource.class);
public NCTimeSeriesRenderableDisplay() {
this(new NcPaneID(), new PixelExtent(0, 1000, 0, 1000));
}
public NCTimeSeriesRenderableDisplay(NcPaneID pid, PixelExtent pe) {
super(pe, new NCTimeSeriesDescriptor());
this.setPaneId(pid);
}
@Override
public double[] getMapCenter() {
return getExtent().getCenter();
}
// this shouldn't be called from NCP but override as a sanity check since
// AbstractXYRenderableDisplay's setTabTitle() calls getEditor which assumes
// an XyEditor
public void setTabTitle(String tabTitle) {
// tabTitle = tabTitle;
// if (getEditor() != null) {
// getEditor().setTabTitle(tabTitle);
// }
}
@Override
public void dispose() {
if (this.descriptor != null) {// && editorInstanceNum <= 1) {
descriptor.getResourceList().clear();
this.descriptor.getResourceList().removePostAddListener(
this.listener);
this.descriptor.getResourceList().removePostRemoveListener(
this.listener);
}
}
@Override
public NcPaneName getPaneName() {
if (getPaneManager().getPaneLayout().getNumberOfPanes() == 1) {
return new NcPaneName(getPaneManager().getDisplayName());
} else {
return new NcPaneName(getPaneManager().getDisplayName(),
getPaneId());
}
}
@Override
public NcPaneID getPaneId() {
if (paneId == null) {
paneId = new NcPaneID();
}
return paneId;
}
@Override
public void setPaneId(INcPaneID pid) {
paneId = (NcPaneID) pid;
}
// TODO? if null then set to the descriptors gridGeom??
@Override
public NCTimeSeriesDescriptor getDescriptor() {
if (super.getDescriptor() instanceof NCTimeSeriesDescriptor) {
return (NCTimeSeriesDescriptor) super.getDescriptor();
} else {
super.getDescriptor();
}
return null;
}
@Override
public void setExtent(IExtent pe) {
super.setExtent(pe);
}
//
@Override
public PredefinedArea getInitialArea() {
if (initialArea == null) {
try {
initialArea = PredefinedAreaFactory
.getDefaultPredefinedAreaForDisplayType(NcDisplayType.GRAPH_DISPLAY);
} catch (VizException e) {
}
}
return initialArea;
}
private GeneralGridGeometry createGridGeometry(IExtent extent,
CoordinateReferenceSystem crs) {
// copied from AbstractDescriptor since it was protected
GeneralEnvelope envelope = new GeneralEnvelope(2);
envelope.setRange(0, extent.getMinX(), extent.getMaxX());
envelope.setRange(1, extent.getMinY(), extent.getMaxY());
envelope.setCoordinateReferenceSystem(crs);
return new GridGeometry2D(
new GeneralGridEnvelope(new int[] { 0, 0 }, new int[] {
(int) extent.getWidth(), (int) extent.getHeight() },
false), envelope);
}
@Override
public double getZoomLevel() {
return 1.0;
}
@Override
public void setInitialArea(PredefinedArea area) {
initialArea = area;
try {
// setPredefinedArea( initialArea );
getDescriptor().setGridGeometry(area.getGridGeometry());
// if( initialArea.getMapCenter() == null ) {
// initialArea.setMapCenter( getMapCenter() );
// }
} catch (VizException e) {
System.out
.println("Error setting initial area of renderable display:"
+ e.getMessage());
}
// if this is actually called/needed then check that the crs is 2d
// Cartesian
// and set the extents.
// System.out.println("setInitialArea not implemented for non-map display");
}
@Override
protected void customizeResourceList(ResourceList resourceList) {
// resourceList. // check if already in the list???
super.customizeResourceList(resourceList);
// Add time series graph resource
GraphResourceData grd = new GraphResourceData("Time series");
GraphResource gr = null;
LoadProperties lprops = new LoadProperties();
ResourceProperties rprops = new ResourceProperties();
rprops.setMapLayer(true);
try {
gr = grd.construct(lprops, getDescriptor());
grd.setOverlayMode(GraphResourceData.OverlayMode.OVERLAY);
ResourcePair rp = new ResourcePair();
rp.setResourceData(grd);
rp.setResource(gr);
rp.setProperties(rprops);
rp.setLoadProperties(lprops);
resourceList.add(rp);
} catch (VizException e) {
statusHandler.handle(Priority.PROBLEM,
"Error constructing time series Graph", e);
}
resourceList.add(ResourcePair
.constructSystemResourcePair(legendRscData));
resourceList.add(ResourcePair
.constructSystemResourcePair(selectedRscData));
resourceList.addPostAddListener(this);
}
@Override
public void notifyAdd(ResourcePair rp) throws VizException {
// TODO : any checks on the type of resource here.
AbstractNcPaneManager pm = NcEditorUtil
.getNcPaneManager((AbstractEditor) container);
if (pm != null) {
pm.setDisplayAvailable(false);
}
}
protected boolean shouldDisplay(ResourcePair pair, int displayWidth) {
AbstractVizResource<?, ?> rsc = pair.getResource();
ResourceProperties properties = pair.getProperties();
if (rsc == null) {
return false;
}
ResourceStatus status = rsc.getStatus();
if (status == ResourceStatus.DISPOSED) {
return false;
}
boolean doNotDrawBecauseOfBlinking = false;
if (properties.isBlinking()) {
if (!rsc.hasCapability(ColorMapCapability.class)) {
// Not a colormapped image...
doNotDrawBecauseOfBlinking = !getCurrentBlinkState();
} else {
ColorMapParameters params = rsc.getCapability(
ColorMapCapability.class).getColorMapParameters();
params.setUseMask(!getCurrentBlinkState());
// notify the resource it is blinking.
rsc.issueRefresh();
}
}
if (!doNotDrawBecauseOfBlinking) {
if (pair.getResource() instanceof IResourceGroup) {
for (ResourcePair rp : ((IResourceGroup) pair.getResource())
.getResourceList()) {
doNotDrawBecauseOfBlinking &= shouldDisplay(rp,
displayWidth);
}
}
}
boolean drawBecauseItsNew = status == ResourceStatus.NEW;
if (!drawBecauseItsNew) {
if (pair.getResource() instanceof IResourceGroup) {
for (ResourcePair rp : ((IResourceGroup) pair.getResource())
.getResourceList()) {
if (rp.getResource() != null) {
drawBecauseItsNew |= rp.getResource().getStatus() == ResourceStatus.NEW;
}
}
}
}
return (drawBecauseItsNew || properties.isDisplayable(displayWidth))
&& !doNotDrawBecauseOfBlinking;
}
@Override
public void setPaneManager(INatlCntrsPaneManager pm) {
paneContainer = pm;
}
@Override
public void setContainer(IDisplayPaneContainer container) {
super.setContainer(container);
if (container instanceof AbstractEditor) {
INatlCntrsPaneManager pm = NcEditorUtil
.getNcPaneManager((AbstractEditor) container);
setPaneManager(pm);
}
}
@Override
public INatlCntrsPaneManager getPaneManager() {
return paneContainer;
}
}

View file

@ -618,7 +618,19 @@
</reference>
</visibleWhen>
</command>
<command
commandId="gov.noaa.nws.ncep.viz.rsc.timeseries.view"
icon="icons/aodt.gif"
id="gov.noaa.nws.ncep.viz.rsc.timeseries.view"
label="timeseries"
style="push"
tooltip="KTable">
<visibleWhen>
<reference
definitionId="gov.noaa.nws.ncep.viz.ui.personalities.inNCActionSet">
</reference>
</visibleWhen>
</command>
<!--command
commandId="com.raytheon.viz.ui.actions.notImplemented"
icon="icons/aodt.gif"

View file

@ -9,7 +9,6 @@ import com.raytheon.uf.viz.core.IDisplayPane;
import com.raytheon.uf.viz.core.IDisplayPaneContainer;
import com.raytheon.viz.ui.cmenu.AbstractRightClickAction;
/**
* The National Centers perspective window layout
*
@ -20,7 +19,7 @@ import com.raytheon.viz.ui.cmenu.AbstractRightClickAction;
* 12/2008 22 M. Li initial creation
* 03/2009 75 B. Hebbard Bring forward from TO9; rename all NMAP-->NC
* 09/27/2009 169 G. Hull require NCMapEditor
*
* 07/07/2014 R4079 Q. Zhou Add timeseries view
* </pre>
*
* @author
@ -31,11 +30,12 @@ public class NCPerspective implements IPerspectiveFactory {
/** <code>ID_PERSPECTIVE</code> field */
public static final String ID_PERSPECTIVE = "gov.noaa.nws.ncep.viz.ui.NCPerspective"; //$NON-NLS-1$
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.IPerspectiveFactory#createInitialLayout(org.eclipse.ui.IPageLayout)
* @see
* org.eclipse.ui.IPerspectiveFactory#createInitialLayout(org.eclipse.ui
* .IPageLayout)
*/
public void createInitialLayout(IPageLayout layout) {
@ -56,24 +56,38 @@ public class NCPerspective implements IPerspectiveFactory {
// long t3 = System.currentTimeMillis();
// System.out.println("Time to add Placeholder: " + (t3-t2) + " ms");
layout.addPlaceholder("gov.noaa.nws.ncep.ui.nsharp", IPageLayout.LEFT, 0.15f, refId);
layout.addPlaceholder("gov.noaa.nws.ncep.ui.nsharp", IPageLayout.LEFT,
0.15f, refId);
// long t4 = System.currentTimeMillis();
// System.out.println("Time to add Placeholder for NSHARP: " + (t4-t3) + " ms");
// System.out.println("Time to add Placeholder for NSHARP: " + (t4-t3)
// + " ms");
layout.addPlaceholder(
"gov.noaa.nws.ncep.viz.rsc.timeseries.view.SamplingView",
IPageLayout.LEFT, 0.25f, refId);
layout.addPlaceholder(
"gov.noaa.nws.ncep.viz.rsc.timeseries.view.KTableView",
IPageLayout.BOTTOM, 0.75f, refId);
layout.addActionSet("gov.noaa.nws.ncep.viz.ui.personalities.NCActionSet");
long t5 = System.currentTimeMillis();
// System.out.println("Time to add Action set: " + (t5-t4) + " ms");
System.out.println("Time to Create NCP perspective layout: " + (t5-t0) + " ms");
System.out.println("Time to Create NCP perspective layout: "
+ (t5 - t0) + " ms");
}
/*
* (non-Javadoc)
*
* @see com.raytheon.viz.ui.IVizPerspectiveFactory#getEditorContributions(com.raytheon.viz.core.IDisplayPaneContainer,
* @see
* com.raytheon.viz.ui.IVizPerspectiveFactory#getEditorContributions(com
* .raytheon.viz.core.IDisplayPaneContainer,
* com.raytheon.viz.core.IDisplayPane)
*/
// [TO10 HOLD] @Override
// [TO10 HOLD] Following is no longer in IVizPerspectiveFactory as of TO10 --
// [TO10 HOLD] Following is no longer in IVizPerspectiveFactory as of TO10
// --
// [TO10 HOLD] need to understand the implications of this
public AbstractRightClickAction[] getEditorContributions(
IDisplayPaneContainer container, IDisplayPane pane) {