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;
@ -37,10 +36,11 @@ import com.raytheon.uf.viz.core.PixelExtent;
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.
*
* Read and create PredefinedAreas from localization. Also
*
* TODO : add methods to save, delete and edit PredefinedAreas at the USER
* localization level.
*
* <pre>
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
@ -58,429 +58,471 @@ import com.raytheon.uf.viz.core.exception.VizException;
* @author ghull
* @version 1
*/
public class PredefinedAreaFactory implements INcAreaProviderFactory {
private static Map<String,LocalizationFile> predefinedAreasMap = null;
private static List<VizException> badAreas = new ArrayList<VizException>();
public PredefinedAreaFactory() {
}
@Override
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
// invalid area file.
}
}
// read the NMAP areas from localization.
// currently, only NcMAP areas are read from localization allow this
// could be changed in the future to allow for NonMap NTRANS and
// for SWPC displays to have more than the 1 default area.
//
private void readPredefinedAreas() throws VizException {
// only null the first time. Empty if read and error.
if( predefinedAreasMap == null ) {
predefinedAreasMap = new HashMap<String, LocalizationFile>();
Map<String,LocalizationFile> areaLocFileMap = NcPathManager.getInstance().listFiles(
NcPathConstants.PREDEFINED_AREAS_DIR, new String[]{".xml"}, false, true);
public class PredefinedAreaFactory implements INcAreaProviderFactory {
if( areaLocFileMap.isEmpty() ) {
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
// with the name of the area.
for( LocalizationFile locF : areaLocFileMap.values() ) {
try {
PredefinedArea area = getPredefinedArea( locF );
if( area.getAreaName().equals( NcDisplayType.NMAP_DISPLAY.getDefaultMap() ) ) {
dfltFound = true;
}
private static Map<String, LocalizationFile> predefinedAreasMap = null;
locF.addFileUpdatedObserver( areaFileObserver );
private static List<VizException> badAreas = new ArrayList<VizException>();
if( predefinedAreasMap.containsKey( area.getAreaName() ) ) {
badAreas.add(
new VizException( "Duplicate Area Name found for :"+ area.getAreaName() ) );
}
else {
predefinedAreasMap.put( area.getAreaName(), locF );
}
}
catch( VizException ve ) {
badAreas.add( ve );
}
}
if( !dfltFound ) {
System.out.println("Could not find valid Default Predefined Area "+
NcDisplayType.NMAP_DISPLAY.getDefaultMap() );
}
}
}
@Override
public List<AreaName> getAvailableAreaNames() {
List<AreaName> areaNames = new ArrayList<AreaName>();
for( String aname : getAllAvailAreasForDisplayType() ) {
areaNames.add( new AreaName( getAreaSource(), aname ) );
}
return areaNames;
}
public PredefinedAreaFactory() {
}
// 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*/ ) {
// if dispType is null then return all types
//
if( predefinedAreasMap == null ) {
System.out.println("getAllAvailPredefinedAreas() called before Areas have been read in.");
return new String[0];
}
List<String> areaNamesList = new ArrayList<String>( predefinedAreasMap.keySet() );
String areaNamesArray[] = areaNamesList.toArray( new String[0] );
return areaNamesArray;
}
// // to sort the list of area names. The default goes first
// public static class AreaNamesComparator implements Comparator<String> {
// private NcDisplayType dispType=NcDisplayType.NMAP_DISPLAY;
//
// public AreaNamesComparator( NcDisplayType dt ) {
// dispType = dt;
// }
//
// @Override
// public int compare(String a1, String a2) {
// if( a1.equals(a2) ) {
// return 0;
// }
// if( a1.equals( dispType.getDefaultMap() ) ) {
// return -1;
// }
// if( a2.equals( dispType.getDefaultMap() ) ) {
// 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) );
//
// if( a1menuIndx == a2menuIndx ) { // ie both -1
// return a1.compareTo( a2 );
// }
// return (a1menuIndx < a2menuIndx ? -1 : 1 );
// }
// }
// // 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
// // mapCenter as well as the gridGeometry)
// //
public static PredefinedArea getDefaultPredefinedAreaForDisplayType( NcDisplayType dt ) throws VizException {
switch( dt ) {
case NMAP_DISPLAY :
return getPredefinedArea( dt.getDefaultMap() );
case NTRANS_DISPLAY :
return createDefaultNonMapArea( dt );
case SOLAR_DISPLAY :
return createDefaultNonMapArea( dt );
}
return null;
}
@Override
public void initialize(String srcName, String dataLoc, String configData)
throws VizException {
// should have already been created.
AreaSource.createAreaSource(srcName);
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() ) ) {
return createDefaultNonMapArea(NcDisplayType.SOLAR_DISPLAY );
}
// 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.");
}
return getPredefinedArea( predefinedAreasMap.get( key ) );
}
public static PredefinedArea getPredefinedArea( LocalizationFile lFile ) throws VizException {
try {
PredefinedArea pa = SerializationUtil.jaxbUnmarshalFromXmlFile(
PredefinedArea.class, lFile.getFile() );
// Todo : could fill this in with the filename???
if( pa.getAreaName().isEmpty() ) {
VizException ve = new VizException(
"Error unmarshaling PredefinedArea: missing AreaName" );
throw ve;
}
return pa;
} catch (SerializationException e) {
throw new VizException( e );
}
try {
readPredefinedAreas();
} catch (VizException v) {
badAreas.add(v); // should treat this as a real exception instead of
// just an
// invalid area file.
}
}
}
public static PredefinedArea clonePredefinedArea( PredefinedArea pArea ) throws VizException {
// read the NMAP areas from localization.
// currently, only NcMAP areas are read from localization allow this
// could be changed in the future to allow for NonMap NTRANS and
// for SWPC displays to have more than the 1 default area.
//
private void readPredefinedAreas() throws VizException {
try {
File tempRbdFile = File.createTempFile("tempArea-", ".xml");
boolean mapCntrIsNull = (pArea.getMapCenter() == null);
SerializationUtil.jaxbMarshalToXmlFile( pArea,
tempRbdFile.getAbsolutePath() );
String s = null;
FileReader fr = new FileReader( tempRbdFile );
char[] b = new char[ (int)tempRbdFile.length() ];
fr.read(b);
fr.close();
s = new String(b);
// only null the first time. Empty if read and error.
if (predefinedAreasMap == null) {
predefinedAreasMap = new HashMap<String, LocalizationFile>();
pArea = SerializationUtil.unmarshalFromXml( PredefinedArea.class, s );
tempRbdFile.delete();
// if null this will unmarshall as 0,0
if( mapCntrIsNull )
pArea.setMapCenter( null );
return pArea;
} catch (SerializationException e) {
throw new VizException( e );
} catch (IOException e) { // from createTempFile
throw new VizException( e );
} catch (JAXBException e) {
throw new VizException( e );
}
}
public static PredefinedArea createDefaultNonMapArea( NcDisplayType dt ) {
PixelExtent extent = new PixelExtent(0,1000,0,1000);
return createDefaultNonMapArea( dt, extent );
}
public static PredefinedArea createPredefinedArea( IGridGeometryProvider geom ) {
if( geom == null ) {
return null;
}
else if( geom instanceof PredefinedArea ) {
try {
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() );
}
Map<String, LocalizationFile> areaLocFileMap = NcPathManager
.getInstance().listFiles(
NcPathConstants.PREDEFINED_AREAS_DIR,
new String[] { ".xml" }, false, true);
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 ) {
if (areaLocFileMap.isEmpty()) {
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
// with the name of the area.
for (LocalizationFile locF : areaLocFileMap.values()) {
try {
PredefinedArea area = getPredefinedArea(locF);
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 {
predefinedAreasMap.put(area.getAreaName(), locF);
}
} catch (VizException ve) {
badAreas.add(ve);
}
}
if (!dfltFound) {
System.out
.println("Could not find valid Default Predefined Area "
+ NcDisplayType.NMAP_DISPLAY.getDefaultMap());
}
}
}
@Override
public List<AreaName> getAvailableAreaNames() {
List<AreaName> areaNames = new ArrayList<AreaName>();
for (String aname : getAllAvailAreasForDisplayType()) {
areaNames.add(new AreaName(getAreaSource(), aname));
}
return areaNames;
}
// 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
*/) {
// if dispType is null then return all types
//
if (predefinedAreasMap == null) {
System.out
.println("getAllAvailPredefinedAreas() called before Areas have been read in.");
return new String[0];
}
List<String> areaNamesList = new ArrayList<String>(
predefinedAreasMap.keySet());
String areaNamesArray[] = areaNamesList.toArray(new String[0]);
return areaNamesArray;
}
// // to sort the list of area names. The default goes first
// public static class AreaNamesComparator implements Comparator<String> {
// private NcDisplayType dispType=NcDisplayType.NMAP_DISPLAY;
//
// public AreaNamesComparator( NcDisplayType dt ) {
// dispType = dt;
// }
//
// @Override
// public int compare(String a1, String a2) {
// if( a1.equals(a2) ) {
// return 0;
// }
// if( a1.equals( dispType.getDefaultMap() ) ) {
// return -1;
// }
// if( a2.equals( dispType.getDefaultMap() ) ) {
// 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) );
//
// if( a1menuIndx == a2menuIndx ) { // ie both -1
// return a1.compareTo( a2 );
// }
// return (a1menuIndx < a2menuIndx ? -1 : 1 );
// }
// }
// // 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
// // mapCenter as well as the gridGeometry)
// //
public static PredefinedArea getDefaultPredefinedAreaForDisplayType(
NcDisplayType dt) throws VizException {
switch (dt) {
case NMAP_DISPLAY:
return getPredefinedArea(dt.getDefaultMap());
case NTRANS_DISPLAY:
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 {
if (areaName.equals(NcDisplayType.NTRANS_DISPLAY.getDefaultMap())) {
return createDefaultNonMapArea(NcDisplayType.NTRANS_DISPLAY);
} 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 = areaName;
if (!predefinedAreasMap.containsKey(key)) {
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 {
try {
PredefinedArea pa = SerializationUtil.jaxbUnmarshalFromXmlFile(
PredefinedArea.class, lFile.getFile());
// Todo : could fill this in with the filename???
if (pa.getAreaName().isEmpty()) {
VizException ve = new VizException(
"Error unmarshaling PredefinedArea: missing AreaName");
throw ve;
}
return pa;
} catch (SerializationException e) {
throw new VizException(e);
}
}
public static PredefinedArea clonePredefinedArea(PredefinedArea pArea)
throws VizException {
try {
File tempRbdFile = File.createTempFile("tempArea-", ".xml");
boolean mapCntrIsNull = (pArea.getMapCenter() == null);
SerializationUtil.jaxbMarshalToXmlFile(pArea,
tempRbdFile.getAbsolutePath());
String s = null;
FileReader fr = new FileReader(tempRbdFile);
char[] b = new char[(int) tempRbdFile.length()];
fr.read(b);
fr.close();
s = new String(b);
pArea = SerializationUtil.unmarshalFromXml(PredefinedArea.class, s);
tempRbdFile.delete();
// if null this will unmarshall as 0,0
if (mapCntrIsNull)
pArea.setMapCenter(null);
return pArea;
} catch (SerializationException e) {
throw new VizException(e);
} catch (IOException e) { // from createTempFile
throw new VizException(e);
} catch (JAXBException e) {
throw new VizException(e);
}
}
public static PredefinedArea createDefaultNonMapArea(NcDisplayType dt) {
PixelExtent extent = new PixelExtent(0, 1000, 0, 1000);
return createDefaultNonMapArea(dt, extent);
}
public static PredefinedArea createPredefinedArea(IGridGeometryProvider geom) {
if (geom == null) {
return null;
} else if (geom instanceof PredefinedArea) {
try {
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());
}
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) {
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);
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);
return new PredefinedArea( AreaSource.PREDEFINED_AREA, dt.getDefaultMap(),
geom, new double[]{500,500}, "1.0", dt );
}
private static ILocalizationFileObserver areaFileObserver = new ILocalizationFileObserver() {
@Override
public void fileUpdated( FileUpdatedMessage fumsg) {
if( predefinedAreasMap == null ) {
return;// should be impossible
}
return new PredefinedArea(AreaSource.PREDEFINED_AREA,
dt.getDefaultMap(), geom, new double[] { 500, 500 }, "1.0", dt);
}
// 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
// area name in an existing file.
//
String keyToRemove = null;
for( Entry<String,LocalizationFile> areaEntry : predefinedAreasMap.entrySet() ) {
LocalizationFile lf = areaEntry.getValue();
// ?? check the context too?
if( fumsg.getFileName().equals( lf.getName() ) ) {
lf.removeFileUpdatedObserver( areaFileObserver );
keyToRemove = areaEntry.getKey();
break;
}
}
try { synchronized ( predefinedAreasMap ) {
private static ILocalizationFileObserver areaFileObserver = new ILocalizationFileObserver() {
@Override
public void fileUpdated(FileUpdatedMessage fumsg) {
if (predefinedAreasMap == null) {
return;// should be impossible
}
if( keyToRemove != null ) {
predefinedAreasMap.remove( keyToRemove );
}
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'
LocalizationFile locFile;
PredefinedArea area;
// 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
// area name in an existing file.
//
String keyToRemove = null;
if( fumsg.getChangeType() == FileChangeType.ADDED ||
fumsg.getChangeType() == FileChangeType.UPDATED ) {
for (Entry<String, LocalizationFile> areaEntry : predefinedAreasMap
.entrySet()) {
LocalizationFile lf = areaEntry.getValue();
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 );
// ?? check the context too?
if (fumsg.getFileName().equals(lf.getName())) {
lf.removeFileUpdatedObserver(areaFileObserver);
keyToRemove = areaEntry.getKey();
break;
}
}
predefinedAreasMap.put( area.getAreaName(), locFile );
}
}
}
else if( fumsg.getChangeType() == FileChangeType.DELETED ) {
locFile = NcPathManager.getInstance().getStaticLocalizationFile(
fumsg.getFileName() );
if( locFile != null ) {
area = getPredefinedArea( locFile );
try {
synchronized (predefinedAreasMap) {
// 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 );
if (keyToRemove != null) {
predefinedAreasMap.remove(keyToRemove);
} else { // / ????
System.out
.println("sanity check: Area fileUpated(): couldn't find locFile name in the Area Map???");
}
predefinedAreasMap.put( area.getAreaName(), locFile );
}
}
}
}
} catch (VizException e) {
System.out.println("Error Updateing Areas Map from Localization Update???");
return;
}
}
};
// if added or updated, update the loc file in the map.
// else if deleted then check for another version of the
// file and 'revert'
LocalizationFile locFile;
PredefinedArea area;
@Override
public AreaSource getAreaSource() {
return AreaSource.PREDEFINED_AREA;//areaSource;
}
if (fumsg.getChangeType() == FileChangeType.ADDED
|| fumsg.getChangeType() == FileChangeType.UPDATED) {
@Override
public IGridGeometryProvider createGeomProvider( String areaName )
throws VizException {
return getPredefinedArea( areaName );
}
locFile = NcPathManager.getInstance()
.getLocalizationFile(fumsg.getContext(),
fumsg.getFileName());
if (locFile != null) {
area = getPredefinedArea(locFile);
@Override
public List<VizException> getInitializationExceptions() {
return badAreas;
}
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");
}
// 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);
PredefinedArea parea = PredefinedAreaFactory.createPredefinedArea( geomProv );
if( parea == null ) {
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";
lfile = NcPathManager.getInstance().getLocalizationFile( usrCntxt, lname );
predefinedAreasMap.put(area.getAreaName(),
locFile);
}
}
} else if (fumsg.getChangeType() == FileChangeType.DELETED) {
locFile = NcPathManager.getInstance()
.getStaticLocalizationFile(fumsg.getFileName());
if (locFile != null) {
area = getPredefinedArea(locFile);
if( lfile == null ) {
throw new VizException("Error saving Predefined Area, "+areaname+
": error creatinge localization File.");
}
}
try {
SerializationUtil.jaxbMarshalToXmlFile( parea,
lfile.getFile().getAbsolutePath() );
lfile.save();
// 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);
if( !areaExists ) {
lfile.addFileUpdatedObserver( areaFileObserver );
predefinedAreasMap.put( areaname, lfile );
}
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() );
}
}
// @Override
// public void setInitializationData(IConfigurationElement config,
// String propertyName, Object data) throws CoreException {
// System.out.println("setInitializationData called with propertyName "+
// propertyName+ " = "+(data == null ? "null" : data.toString()) );
// }
predefinedAreasMap.put(area.getAreaName(),
locFile);
}
}
}
}
} catch (VizException e) {
System.out
.println("Error Updateing Areas Map from Localization Update???");
return;
}
}
};
@Override
public AreaSource getAreaSource() {
return AreaSource.PREDEFINED_AREA;// areaSource;
}
@Override
public IGridGeometryProvider createGeomProvider(String areaName)
throws VizException {
return getPredefinedArea(areaName);
}
@Override
public List<VizException> getInitializationExceptions() {
return badAreas;
}
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");
}
PredefinedArea parea = PredefinedAreaFactory
.createPredefinedArea(geomProv);
if (parea == null) {
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";
lfile = NcPathManager.getInstance().getLocalizationFile(usrCntxt,
lname);
if (lfile == null) {
throw new VizException("Error saving Predefined Area, "
+ areaname + ": error creatinge localization File.");
}
}
try {
SerializationUtil.jaxbMarshalToXmlFile(parea, lfile.getFile()
.getAbsolutePath());
lfile.save();
if (!areaExists) {
lfile.addFileUpdatedObserver(areaFileObserver);
predefinedAreasMap.put(areaname, lfile);
}
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());
}
}
// @Override
// public void setInitializationData(IConfigurationElement config,
// String propertyName, Object data) throws CoreException {
// System.out.println("setInitializationData called with propertyName "+
// propertyName+ " = "+(data == null ? "null" : data.toString()) );
// }
}

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>
@ -15,92 +14,94 @@ import javax.xml.bind.annotation.XmlRootElement;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 02/10/13 #972 Greg Hull Created
*
*
* </pre>
*
* @author ghull
* @version 1
*/
// an RBD must be one of these display types and all resources in the RBD must be compatible
// with the display type.
// 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),
// CURRENTLY NOT USED,
NSHARP_DISPLAY( "NSHARP",
"gov.noaa.nws.ncep.ui.nsharp.display.NcNsharpPaneManager",
"BasicWX_US",
"OVERLAY/GeoPolitical/default",
false );
// NC_TIME_SERIES_DISPLAY,
// NC_CROSS_SECTION_DISPLAY;
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),
// CURRENTLY NOT USED,
NSHARP_DISPLAY("NSHARP",
"gov.noaa.nws.ncep.ui.nsharp.display.NcNsharpPaneManager",
"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) {
dispType = dtstr;
paneManager = pMngr;
defaultArea = area;
baseResource = baseOvrly;
isSavable = canSave;
}
public String getName() {
return dispType;
}
public static NcDisplayType getDisplayType(String dts) {
for (NcDisplayType dt : NcDisplayType.values()) {
if (dts.equalsIgnoreCase(dt.getName())) {
return dt;
}
}
return null;
}
public static List<NcDisplayType> getRbdSavableDisplayTypes() {
List<NcDisplayType> dtl = new ArrayList<NcDisplayType>();
for (NcDisplayType dt : values()) {
if (dt.isSavable) {
dtl.add(dt);
}
}
return dtl;
}
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 ) {
dispType = dtstr;
paneManager = pMngr;
defaultArea = area;
baseResource = baseOvrly;
isSavable = canSave;
}
public String getName() {
return dispType;
}
public static NcDisplayType getDisplayType( String dts ) {
for( NcDisplayType dt : NcDisplayType.values() ) {
if( dts.equalsIgnoreCase( dt.getName() ) ) {
return dt;
}
}
return null;
}
public static List<NcDisplayType> getRbdSavableDisplayTypes() {
List<NcDisplayType> dtl = new ArrayList<NcDisplayType>();
for( NcDisplayType dt : values() ) {
if( dt.isSavable ) {
dtl.add( dt );
}
}
return dtl;
}
public String getPaneManager() {
return paneManager;
}
return paneManager;
}
public void setPaneManager(String paneManager) {
this.paneManager = paneManager;
}
public void setPaneManager(String paneManager) {
this.paneManager = paneManager;
}
public String getDefaultMap() {
public String getDefaultMap() {
return defaultArea;
}
@ -108,7 +109,7 @@ public enum NcDisplayType {
return baseResource;
}
public Boolean getIsRbdSavable() {
return isSavable;
}
public Boolean getIsRbdSavable() {
return isSavable;
}
}

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>
</ResourceDefinitionFilters>
<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.
*
Would it be ok/better to derive from PathManager directly and bypass the PathManagerFactory?
* 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?
*
* <pre>
* SOFTWARE HISTORY
@ -51,308 +50,458 @@ 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
* @author ghull
* @version 1
*/
public class NcPathManager {
private static NcPathManager ncPathMngr = null;
private static IPathManager pathMngr = null;
private static NcPathManager ncPathMngr = null;
// we could instead read from the extension point to find the relative path for a 'type' of file.
//
public static class NcPathConstants {
private static IPathManager pathMngr = null;
public static final String DESK_LEVEL = "DESK";
// the root of NCEP file hierarchy (below base/user/site/desk)
public static final String NCEP_ROOT = "ncep"+File.separator;
// we could instead read from the extension point to find the relative path
// for a 'type' of file.
//
public static class NcPathConstants {
// Note that these files are in STATIC_COMMON
public static final String NCINVENTORY_DEFNS_DIR = NCEP_ROOT + "NcInventoryDefinitions";
public static final String DESK_LEVEL = "DESK";
// 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 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 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";
// the root of NCEP file hierarchy (below base/user/site/desk)
public static final String NCEP_ROOT = "ncep" + File.separator;
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;
// 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 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";
// Note that these files are in STATIC_COMMON
public static final String NCINVENTORY_DEFNS_DIR = NCEP_ROOT
+ "NcInventoryDefinitions";
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 SHAPEFILES_DIR = NCEP_ROOT + "Shapefiles";
// static directories.
public static final String SPFS_DIR = NCEP_ROOT + "SPFs"; // the Groups
// dir
public static final String SEEK_STN_TBL = NCEP_ROOT + "Seek"+File.separator+"seekStns.xml";
public static final String RSC_TMPLTS_DIR = NCEP_ROOT
+ "resourceTemplates";
// 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
// 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";
// 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_HELP_FILE = PGEN_ROOT + "PgenHelp.txt";
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_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_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_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";
//nsharp configuration
public static final String NSHARP_CONFIG = NCEP_ROOT + "nsharp"+ File.separator+"nsharpConfig.xml";
public static final String RSC_DEFNS_DIR = NCEP_ROOT + "ResourceDefns";
}
public static synchronized NcPathManager getInstance() {
if( ncPathMngr == null ) {
ncPathMngr = new NcPathManager();
}
return ncPathMngr;
}
private NcPathManager() {
// Uses the same CAVELocalizationAdapter.
pathMngr = PathManagerFactory.getPathManager( new CAVELocalizationAdapter() );
}
public void createDeskLevelLocalization( String deskName ) {
// SITE < DESK < USER
// NOTE : order of 650 is between SITE(order=500) and USER(order=1000).
LocalizationLevel DESK = LocalizationLevel.createLevel(
NcPathConstants.DESK_LEVEL, 650 );
public static final String ATTR_SET_GROUPS_DIR = NCEP_ROOT
+ "AttributeSetGroups";
// 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???? ");
}
if( LocalizationLevel.USER.compareTo( DESK ) <= 0 ) {
System.out.println("WARNING: the USER level order <= the DESK???? ");
}
public static final String PREDEFINED_AREAS_DIR = NCEP_ROOT
+ "PredefinedAreas";
LocalizationManager.getInstance();
public static final String COLORBARS_DIR = NCEP_ROOT + "ColorBars";
LocalizationManager.registerContextName( DESK, deskName );
}
public LocalizationLevel getDeskLevel() {
return LocalizationLevel.valueOf( NcPathConstants.DESK_LEVEL );
}
public LocalizationContext getDeskContext() {
return getContext( LocalizationType.CAVE_STATIC, getDeskLevel() );
}
public static final String COLORMAPS_DIR = NCEP_ROOT + "ColorMaps";
// same thing as calling PathManagerFactory.getPathManager();
public IPathManager getPathManager() {
return pathMngr;
}
// 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 );
}
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";
// 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_GRAPH_RBD = NCEP_ROOT + "DefaultRBDs"
+ File.separator + "defaultGraphRBD.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 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 SHAPEFILES_DIR = NCEP_ROOT + "Shapefiles";
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";
// 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";
// 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_HELP_FILE = PGEN_ROOT + "PgenHelp.txt";
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_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_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_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";
// nsharp configuration
public static final String NSHARP_CONFIG = NCEP_ROOT + "nsharp"
+ File.separator + "nsharpConfig.xml";
// Use this method if we don't care which context the file comes from but we
// need to know which one it was from.
//
public LocalizationFile getStaticLocalizationFile( String name ) {
return pathMngr.getStaticLocalizationFile( name );
}
// This can be used to create a new LocalizationFile.
//
public LocalizationFile getLocalizationFile( LocalizationContext context,
String name) {
return pathMngr.getLocalizationFile( context, name);
}
// 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 ) {
LocalizationContext[] contexts = getLocalSearchHierarchy( LocalizationType.CAVE_STATIC );
return listFiles( contexts, name, filter, recursive, filesOnly );
public static synchronized NcPathManager getInstance() {
if (ncPathMngr == null) {
ncPathMngr = new NcPathManager();
}
return ncPathMngr;
}
private NcPathManager() {
// Uses the same CAVELocalizationAdapter.
pathMngr = PathManagerFactory
.getPathManager(new CAVELocalizationAdapter());
}
public void createDeskLevelLocalization(String deskName) {
// SITE < DESK < USER
// NOTE : order of 650 is between SITE(order=500) and USER(order=1000).
LocalizationLevel DESK = LocalizationLevel.createLevel(
NcPathConstants.DESK_LEVEL, 650);
// 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???? ");
}
if (LocalizationLevel.USER.compareTo(DESK) <= 0) {
System.out
.println("WARNING: the USER level order <= the DESK???? ");
}
LocalizationManager.getInstance();
LocalizationManager.registerContextName(DESK, deskName);
}
public LocalizationLevel getDeskLevel() {
return LocalizationLevel.valueOf(NcPathConstants.DESK_LEVEL);
}
public LocalizationContext getDeskContext() {
return getContext(LocalizationType.CAVE_STATIC, getDeskLevel());
}
// same thing as calling PathManagerFactory.getPathManager();
public IPathManager getPathManager() {
return pathMngr;
}
// 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);
}
// Use this method if we don't care which context the file comes from but we
// need to know which one it was from.
//
public LocalizationFile getStaticLocalizationFile(String name) {
return pathMngr.getStaticLocalizationFile(name);
}
// This can be used to create a new LocalizationFile.
//
public LocalizationFile getLocalizationFile(LocalizationContext context,
String name) {
return pathMngr.getLocalizationFile(context, name);
}
// 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) {
LocalizationContext[] contexts = getLocalSearchHierarchy(LocalizationType.CAVE_STATIC);
return listFiles(contexts, name, filter, recursive, filesOnly);
}
// 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
// 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) ) {
//System.out.println("listFiles "+lFile.getFile().getAbsolutePath());
lFileMap.put( lFile.getName(), lFile );
}
}
return lFileMap;
}
// 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)) {
// System.out.println("listFiles "+lFile.getFile().getAbsolutePath());
lFileMap.put(lFile.getName(), lFile);
}
}
return lFileMap;
}
// 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 LocalizationContext getContext( LocalizationType type,
public Map<LocalizationLevel, LocalizationFile> getTieredLocalizationFile(
String name) {
return pathMngr.getTieredLocalizationFile(LocalizationType.CAVE_STATIC,
name);
}
public LocalizationContext getContext(LocalizationType type,
LocalizationLevel level) {
return pathMngr.getContext(type, level);
}
public String[] getContextList(LocalizationLevel level) {
return pathMngr.getContextList(level);
return pathMngr.getContextList(level);
}
public LocalizationContext[] getLocalSearchHierarchy(LocalizationType type) {
return pathMngr.getLocalSearchHierarchy( type );
return pathMngr.getLocalSearchHierarchy(type);
}
// return a map of all files from all contexts
// this would make it easier to 'revert' files
//
// public Map<String, LocalizationFile> listFilesFromAllContexts(
// // getTieredLocalizationFile(
// // LocalizationType type,
// String name, String[] filter, boolean recursive, boolean filesOnly ) {
// Map<String, LocalizationFile> map = new HashMap<String, LocalizationFile>();
//
// for( LocalizationLevel level : ncLevels ) {
// LocalizationContext context = getContext( LocalizationType.CAVE_STATIC, level );
//
// LocalizationFile[] lFiles =
// pathMngr.listFiles( getLocalSearchHierarchy( LocalizationType.CAVE_STATIC ),
// name, filter, recursive, filesOnly );
//// LocalizationFile lf = getLocalizationFile( context, name );
//
// if( lf.exists() ) {
// map.put(, lf);
// }
// }
//
// return map;
// }
//
// public Map<String, LocalizationFile> listFilesFromAllContexts(
// // getTieredLocalizationFile(
// // LocalizationType type,
// String name, String[] filter, boolean recursive, boolean filesOnly ) {
// Map<String, LocalizationFile> map = new HashMap<String,
// LocalizationFile>();
//
// for( LocalizationLevel level : ncLevels ) {
// LocalizationContext context = getContext( LocalizationType.CAVE_STATIC,
// level );
//
// LocalizationFile[] lFiles =
// pathMngr.listFiles( getLocalSearchHierarchy( LocalizationType.CAVE_STATIC
// ),
// name, filter, recursive, filesOnly );
// // LocalizationFile lf = getLocalizationFile( context, name );
//
// if( lf.exists() ) {
// map.put(, lf);
// }
// }
//
// 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 )
// throws LocalizationOpFailedException {
// super.delete(file, context, fileName);
//
// if( findReplacement ) {
//// LocalizationContext superContext = new LocalizationContext(
//// context.getLocalizationType(),
//// LocalizationManager.getInstance().get
// }
//
// return null;
// }
//
// public LocalizationFile revert( File file, LocalizationContext context,
// String fileName, boolean findReplacement )
// throws LocalizationOpFailedException {
// super.delete(file, context, fileName);
//
// if( findReplacement ) {
// // LocalizationContext superContext = new LocalizationContext(
// // context.getLocalizationType(),
// // LocalizationManager.getInstance().get
// }
//
// return null;
// }
}

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,386 +16,410 @@ 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
*
*
*/
public class TimelineData {
private TreeMap<Calendar,Boolean> times;
private TreeMap<Calendar, Boolean> times;
/**
* Initializes all available time to non-selected status
* @param timeList list of available data times
*/
TimelineData( List<Calendar> timeList ) {
/**
* Initializes all available time to non-selected status
*
* @param timeList
* list of available data times
*/
TimelineData(List<Calendar> timeList) {
times = new TreeMap<Calendar,Boolean>();
for ( Calendar cal : timeList ) {
times.put(cal, false);
}
times = new TreeMap<Calendar, Boolean>();
for (Calendar cal : timeList) {
times.put(cal, false);
}
}
/**
* checks if the list of available times is empty
* @return
*/
public boolean isEmpty() {
return times.isEmpty();
}
}
/**
* Returns the first available data time in the list
* @return
*/
public Calendar getFirstTime() {
return times.firstKey();
}
/**
* Returns the last available data time in the list
* @return
*/
public Calendar getLastTime() {
return times.lastKey();
}
/**
* checks if the list of available times is empty
*
* @return
*/
public boolean isEmpty() {
return times.isEmpty();
}
/**
* Returns a set of all the available data times
* @return
*/
public Set<Calendar> getTimes() {
return times.keySet();
}
/**
* 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);
}
return list;
}
/**
* Returns the first available data time in the list
*
* @return
*/
public Calendar getFirstTime() {
return times.firstKey();
}
/**
* Checks if the specified time is selected
*/
public boolean isSelected(Calendar cal) {
return times.get(cal);
}
/**
* Returns the total number of minutes between the first and last available
* data times
* @return
*/
public int getTotalMinutes() {
Calendar first = getFirstTime();
Calendar last = getLastTime();
long timeLength = last.getTimeInMillis() - first.getTimeInMillis();
return (int)(timeLength/60000);
}
/**
* Returns the last available data time in the list
*
* @return
*/
public Calendar getLastTime() {
return times.lastKey();
}
/**
* Returns the total number of milliseconds between the first and last available
* data times
* @return
*/
public long getTotalMillis() {
Calendar first = getFirstTime();
Calendar last = getLastTime();
return last.getTimeInMillis() - first.getTimeInMillis();
}
/**
* Returns a set of all the available data times
*
* @return
*/
public Set<Calendar> getTimes() {
return times.keySet();
}
/*
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) {
/**
* 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);
}
return list;
}
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 );
}
}
*/
/**
* Checks if the specified time is selected
*/
public boolean isSelected(Calendar cal) {
return times.get(cal);
}
/**
* Returns the first selected time in the list
*/
public Calendar getFirstSelected() {
Map.Entry<Calendar, Boolean> entry = times.firstEntry();
while ( entry != null ) {
if ( entry.getValue() ) return entry.getKey();
entry = times.higherEntry( entry.getKey() );
}
return null;
}
/**
* Returns the total number of minutes between the first and last available
* data times
*
* @return
*/
public int getTotalMinutes() {
Calendar first = getFirstTime();
Calendar last = getLastTime();
long timeLength = last.getTimeInMillis() - first.getTimeInMillis();
return (int) (timeLength / 60000);
}
/**
* 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();
entry = times.lowerEntry( entry.getKey() );
}
return null;
}
/**
* Returns the total number of milliseconds between the first and last
* available data times
*
* @return
*/
public long getTotalMillis() {
Calendar first = getFirstTime();
Calendar last = getLastTime();
return last.getTimeInMillis() - first.getTimeInMillis();
}
/**
* Returns the available time just before the specified time
* @param cal
* @return
*/
public Calendar getPreviousTime(Calendar cal) {
return 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 ); }
*
* }
*/
/**
* Returns the available time just after the specified time
* @param cal
* @return
*/
public Calendar getNextTime(Calendar cal) {
return times.higherKey(cal);
}
/**
* Returns the first selected time in the list
*/
public Calendar getFirstSelected() {
/**
* Toggles the "select" indicator for the given time
* @param cal
*/
public void toggle(Calendar cal) {
if ( times.containsKey(cal) ) {
times.put( cal, !times.get(cal) );
}
}
Map.Entry<Calendar, Boolean> entry = times.firstEntry();
while (entry != null) {
if (entry.getValue())
return entry.getKey();
entry = times.higherEntry(entry.getKey());
}
return null;
}
/**
* Returns the number of selected data times
* @return
*/
public int numSelected() {
int num = 0;
for ( Boolean val : times.values() ) {
if ( val ) num++;
}
return num;
}
/**
* Returns the last selected time in the list
*
* @return
*/
public Calendar getLastSelected() {
/**
* Marks the given time as selected
* @param cal
*/
public void select(Calendar cal) {
if ( times.containsKey(cal) ) times.put(cal, true);
}
Map.Entry<Calendar, Boolean> entry = times.lastEntry();
while (entry != null) {
if (entry.getValue())
return entry.getKey();
entry = times.lowerEntry(entry.getKey());
}
return null;
}
/**
* Marks the given time as not selected
* @param cal
*/
public void deselect(Calendar cal) {
if ( times.containsKey(cal) ) times.put(cal, false);
}
/**
* Returns the available time just before the specified time
*
* @param cal
* @return
*/
public Calendar getPreviousTime(Calendar cal) {
return times.lowerKey(cal);
}
/**
* Returns the number of available times in the list
* @return
*/
public int getSize() {
return times.size();
}
/**
* Returns the available time just after the specified time
*
* @param cal
* @return
*/
public Calendar getNextTime(Calendar cal) {
return times.higherKey(cal);
}
/**
* 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());
addToLast( numFrames, skip );
if ( numFrames > numSelected() ) {
addToFirst( numFrames, skip );
}
}
else if ( numFrames < numSelected() ) {
removeFromLast( numFrames, skip);
}
}
/**
* Toggles the "select" indicator for the given time
*
* @param cal
*/
public void toggle(Calendar cal) {
if (times.containsKey(cal)) {
times.put(cal, !times.get(cal));
}
}
/**
* 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
*/
private void addToLast(int numFrames, int skip) {
/**
* Returns the number of selected data times
*
* @return
*/
public int numSelected() {
int num = 0;
for (Boolean val : times.values()) {
if (val)
num++;
}
return num;
}
while ( numSelected() < numFrames ) {
Calendar cal = getLastSelected();
for ( int j=0; j <= skip; j++ ) {
cal = getNextTime(cal);
if ( cal == null) return;
}
select(cal);
}
}
/**
* Marks the given time as selected
*
* @param cal
*/
public void select(Calendar cal) {
if (times.containsKey(cal))
times.put(cal, true);
}
/**
* 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
*/
private void removeFromLast(int numFrames, int skip) {
/**
* Marks the given time as not selected
*
* @param cal
*/
public void deselect(Calendar cal) {
if (times.containsKey(cal))
times.put(cal, false);
}
int count = numSelected();
while ( count > numFrames ) {
Calendar cal = getLastSelected();
deselect(cal);
count = numSelected();
}
}
/**
* Returns the number of available times in the list
*
* @return
*/
public int getSize() {
return times.size();
}
/**
* 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) {
/**
* 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(getLastTime());
addToFirst( numFrames, skip );
if ( numFrames > numSelected() ) {
addToLast( numFrames, skip );
}
}
else if ( numFrames < numSelected() ) {
removeFromFirst( numFrames, skip);
}
}
if (numFrames > numSelected()) {
if (numSelected() == 0)
select(getFirstTime());
addToLast(numFrames, skip);
if (numFrames > numSelected()) {
addToFirst(numFrames, skip);
}
} else if (numFrames < numSelected()) {
removeFromLast(numFrames, skip);
}
/**
* 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
*/
private void addToFirst(int numFrames, int skip) {
}
while ( numSelected() < numFrames ) {
Calendar cal = getFirstSelected();
for ( int j=0; j <= skip; j++ ) {
cal = getPreviousTime(cal);
if ( cal == null) return;
}
select(cal);
}
}
/**
* 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
*/
private void addToLast(int numFrames, int skip) {
/**
* 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
*/
private void removeFromFirst(int numFrames, int skip) {
int count = numSelected();
while ( count > numFrames ) {
Calendar cal = getFirstSelected();
deselect(cal);
count = numSelected();
}
}
while (numSelected() < numFrames) {
/**
* 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
*/
public void updateRange(Calendar first, Calendar second, int skip) {
Calendar cal = getLastSelected();
for (int j = 0; j <= skip; j++) {
cal = getNextTime(cal);
if (cal == null)
return;
}
select(cal);
int j=0, loc1=0, loc2=0;
deselectAll();
for ( Calendar cal : times.keySet() ) {
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 ( first.before(second) ) {
select(first);
addToLast( num, skip);
}
else if ( first.after(second) ) {
select(first);
addToFirst( num, skip);
}
else {
select(first);
}
}
}
/**
* Marks all times in the list as not selected
*/
public void deselectAll() {
for ( Calendar cal : times.keySet() ) {
deselect(cal);
}
}
/**
* 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
*/
private void removeFromLast(int numFrames, int skip) {
int count = numSelected();
while (count > numFrames) {
Calendar cal = getLastSelected();
deselect(cal);
count = numSelected();
}
}
/**
* 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());
addToFirst(numFrames, skip);
if (numFrames > numSelected()) {
addToLast(numFrames, skip);
}
} else if (numFrames < numSelected()) {
removeFromFirst(numFrames, skip);
}
}
/**
* 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
*/
private void addToFirst(int numFrames, int skip) {
while (numSelected() < numFrames) {
Calendar cal = getFirstSelected();
for (int j = 0; j <= skip; j++) {
cal = getPreviousTime(cal);
if (cal == null)
return;
}
select(cal);
}
}
/**
* 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
*/
private void removeFromFirst(int numFrames, int skip) {
int count = numSelected();
while (count > numFrames) {
Calendar cal = getFirstSelected();
deselect(cal);
count = numSelected();
}
}
/**
* 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
*/
public void updateRange(Calendar first, Calendar second, int skip) {
int j = 0, loc1 = 0, loc2 = 0;
deselectAll();
for (Calendar cal : times.keySet()) {
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 (first.before(second)) {
select(first);
addToLast(num, skip);
} else if (first.after(second)) {
select(first);
addToFirst(num, skip);
} else {
select(first);
}
}
/**
* Marks all times in the list as not selected
*/
public void deselectAll() {
for (Calendar cal : times.keySet()) {
deselect(cal);
}
}
}

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());
timelineControl = new TimelineControl(timeline_grp);
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
@ -2815,4 +2865,4 @@ public class CreateRbdControl extends Composite implements IPartListener2 {
public void partInputChanged(IWorkbenchPartReference partRef) {
// Auto-generated method stub
}
}
}

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 ) {
// 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

@ -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

@ -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,340 +59,369 @@ 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
// the attribute values are stored in the rscAttrSet.
@XmlAttribute
protected boolean isEdited;
protected ResourceExtPointMngr rscExtPointMngr = null;
// the full name/path of the resource with its category, sub-category...
@XmlAttribute
@XmlJavaTypeAdapter(ResourceNameAdapter.class)
ResourceName resourceName = null;
@XmlElement
protected String resourceVersion = ""; // TODO : not implemented
private AbstractVizResource<?, ?> ncRsc;
@XmlElement
@XmlJavaTypeAdapter(RGBColorAdapter.class)
protected RGB legendColor;
// 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;
protected ResourceExtPointMngr rscExtPointMngr = null;
// the full name/path of the resource with its category, sub-category...
@XmlAttribute
@XmlJavaTypeAdapter(ResourceNameAdapter.class)
ResourceName resourceName = null;
@XmlElement
protected String resourceVersion=""; // TODO : not implemented
private AbstractVizResource<?, ?> ncRsc;
public AbstractNatlCntrsResourceData() {
super();
isEdited = false;
resourceVersion = null;
ncRsc = null;
legendColor = new RGB(255,255,255);
legendColor = new RGB(255, 255, 255);
rscExtPointMngr = ResourceExtPointMngr.getInstance();
}
// implement here as a convienience since almost all of our
// implement here as a convienience since almost all of our
// resources are on map based displays. Other resources
// that are written to draw to differendt display types will
// that are written to draw to differendt display types will
// need to override this.
public NcDisplayType[] getSupportedDisplayTypes() {
return new NcDisplayType[] { NcDisplayType.NMAP_DISPLAY };
}
// 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;
}
public void setResourceVersion(String resourceVersion) {
this.resourceVersion = resourceVersion;
}
// get/set for isEdited
public void setIsEdited( boolean e ) {
isEdited = e;
public NcDisplayType[] getSupportedDisplayTypes() {
return new NcDisplayType[] { NcDisplayType.NMAP_DISPLAY };
}
// 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;
}
public void setResourceVersion(String resourceVersion) {
this.resourceVersion = resourceVersion;
}
// get/set for isEdited
public void setIsEdited(boolean e) {
isEdited = e;
}
public boolean getIsEdited() {
return isEdited;
}
return isEdited;
}
public final ResourceName getResourceName() {
return resourceName;
}
public final ResourceName getResourceName() {
return resourceName;
}
public void setResourceName( ResourceName rscName ) {
resourceName = new ResourceName( rscName );
}
public void setResourceName(ResourceName rscName) {
resourceName = new ResourceName(rscName);
}
@Override
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
// 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.
if( ncRsc != null ) {
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???");
}
// 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
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
// 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.
if (ncRsc != null) {
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???");
}
// 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 ) {
// rscAttrSet = new ResourceAttrSet( rscAttrSetName );
// }
//
// 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
// // 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( rscAttrSet );
// }
// if( rscAttrSet == null && rscAttrSetName != null ) {
// rscAttrSet = new ResourceAttrSet( rscAttrSetName );
// }
//
// 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
// // 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( rscAttrSet );
// }
return rsc;
return rsc;
}
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() );
if( rscImplParamInfo == null ) {
System.out.println("Couldn't find rsc impl parameter info for "+getResourceName() );
return null;
}
public abstract AbstractVizResource<?, ?> constructResource(
LoadProperties loadProperties, IDescriptor descriptor)
throws VizException;
ResourceAttrSet rscAttrSet = new ResourceAttrSet(
resourceName.getRscAttrSetName() );
// get a list of the defined attributes for this resource and
//
public ResourceAttrSet getRscAttrSet() {
for( ResourceParamInfo prmInfo : rscImplParamInfo.values() ) {
if( prmInfo.getParamType() != ResourceParamType.EDITABLE_ATTRIBUTE ) {
continue;
}
HashMap<String, ResourceParamInfo> rscImplParamInfo = rscExtPointMngr
.getParameterInfoForRscImplementation(getResourceName());
Method[] mthds = this.getClass().getDeclaredMethods();
String attrName = prmInfo.getParamName();
if (rscImplParamInfo == null) {
System.out.println("Couldn't find rsc impl parameter info for "
+ getResourceName());
return null;
}
String getMthdName = "get"+attrName.substring(0,1).toUpperCase() +
attrName.substring(1);
ResourceAttrSet rscAttrSet = new ResourceAttrSet(
resourceName.getRscAttrSetName());
for( Method m : mthds ) {
if( m.getName().equals( getMthdName ) ) {
Class<?>[] params = m.getParameterTypes();
Class<?> rtype = m.getReturnType();
for (ResourceParamInfo prmInfo : rscImplParamInfo.values()) {
// 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"+
// "as correct type:" +rtype.getName() + " != " +
// attrInfo.getAttrClass().getName() );
// }
if (prmInfo.getParamType() != ResourceParamType.EDITABLE_ATTRIBUTE) {
continue;
}
if( params.length == 0 ) {
Object attrVal=null;
try {
attrVal = m.invoke( this );
Method[] mthds = this.getClass().getDeclaredMethods();
String attrName = prmInfo.getParamName();
Constructor<?> cc = rtype.getConstructor( rtype );
if( cc != null ) {
attrVal = cc.newInstance( attrVal );
}
String getMthdName = "get" + attrName.substring(0, 1).toUpperCase()
+ attrName.substring(1);
rscAttrSet.setAttrValue( attrName, attrVal );
for (Method m : mthds) {
if (m.getName().equals(getMthdName)) {
Class<?>[] params = m.getParameterTypes();
Class<?> rtype = m.getReturnType();
} catch (NoSuchMethodException e) {
// if there is no copy constructor go ahead and set
// the attribute value
rscAttrSet.setAttrValue( attrName, attrVal );
// 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"+
// "as correct type:" +rtype.getName() + " != " +
// attrInfo.getAttrClass().getName() );
// }
} catch( IllegalAccessException iae ) {
System.out.println(iae.getMessage());
} catch( IllegalArgumentException iae ) {
System.out.println(iae.getMessage());
} catch( InvocationTargetException ite ) {
System.out.println(ite.getMessage());
} catch( ClassCastException cce ) {
System.out.println(cce.getMessage());
} catch (SecurityException e) {
System.out.println(e.getMessage());
} catch (InstantiationException e) {
System.out.println(e.getMessage());
}
}
}
}
}
return rscAttrSet;
}
if (params.length == 0) {
Object attrVal = null;
try {
attrVal = m.invoke(this);
Constructor<?> cc = rtype.getConstructor(rtype);
if (cc != null) {
attrVal = cc.newInstance(attrVal);
}
// the rscAttrSet should only contain attributes defined for this resource.
//
public boolean setRscAttrSet( ResourceAttrSet newRscAttrSet ) {
if( newRscAttrSet == null ) {
return false;
}
rscAttrSet.setAttrValue(attrName, attrVal);
HashMap<String,ResourceParamInfo> rscImplParamInfo =
rscExtPointMngr.getParameterInfoForRscImplementation( getResourceName() );
if( rscImplParamInfo == null ) {
System.out.println("Couldn't find rsc impl parameter info for "+getResourceName() );
return false;
}
} catch (NoSuchMethodException e) {
// if there is no copy constructor go ahead and set
// the attribute value
rscAttrSet.setAttrValue(attrName, attrVal);
// loop thru the attributes and use Java Bean utils to set the attributes on the resource
for( ResourceParamInfo prmInfo : rscImplParamInfo.values() ) {
} catch (IllegalAccessException iae) {
System.out.println(iae.getMessage());
} catch (IllegalArgumentException iae) {
System.out.println(iae.getMessage());
} catch (InvocationTargetException ite) {
System.out.println(ite.getMessage());
} catch (ClassCastException cce) {
System.out.println(cce.getMessage());
} catch (SecurityException e) {
System.out.println(e.getMessage());
} catch (InstantiationException e) {
System.out.println(e.getMessage());
}
}
}
}
}
if( prmInfo.getParamType() != ResourceParamType.EDITABLE_ATTRIBUTE ) {
continue;
}
return rscAttrSet;
}
String attrName = prmInfo.getParamName();
// make sure that this attrSet has this attributeName
if( !newRscAttrSet.hasAttrName(attrName) ) {
continue;
}
RscAttrValue rscAttr = newRscAttrSet.getRscAttr( attrName );
Object attrValue = rscAttr.getAttrValue();
Class<?> attrClass = rscAttr.getAttrClass();
// the rscAttrSet should only contain attributes defined for this resource.
//
public boolean setRscAttrSet(ResourceAttrSet newRscAttrSet) {
if (newRscAttrSet == null) {
return false;
}
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() );
continue;
}
else if( attrValue == null ) {
continue;
}
HashMap<String, ResourceParamInfo> rscImplParamInfo = rscExtPointMngr
.getParameterInfoForRscImplementation(getResourceName());
String setMthdName = "set"+attrName.substring(0,1).toUpperCase() +
attrName.substring(1);
if (rscImplParamInfo == null) {
System.out.println("Couldn't find rsc impl parameter info for "
+ getResourceName());
return false;
}
Method[] mthds = this.getClass().getDeclaredMethods();
// loop thru the attributes and use Java Bean utils to set the
// attributes on the resource
for (ResourceParamInfo prmInfo : rscImplParamInfo.values()) {
for( Method m : mthds ) {
if( m.getName().equals( setMthdName ) ) {
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
// if( params[0].getClass() != attrInfo.getAttrClass() ||
// params.length != 1) {
// System.out.println("Error setting rsc attr "+attrName+" : setter class " +
// "has incompatible argument.");
// System.out.println("Warning: Attribute "+attrName +" is not defined\n"+
// "as correct type:" +rtype.getName() + " != " +
// attrInfo.getAttrClass().getName() );
// continue;
// }
if (prmInfo.getParamType() != ResourceParamType.EDITABLE_ATTRIBUTE) {
continue;
}
try {
m.invoke( this, attrValue );
} catch( IllegalAccessException iae ) {
System.out.println(iae.getMessage());
} catch( IllegalArgumentException iae ) {
System.out.println(iae.getMessage());
} catch( InvocationTargetException ite ) {
System.out.println(ite.getMessage());
} catch( ClassCastException cce ) {
System.out.println(cce.getMessage());
}
}
}
}
if( ncRsc != null ) {
((INatlCntrsResource)ncRsc).resourceAttrsModified();
}
String attrName = prmInfo.getParamName();
// make sure that this attrSet has this attributeName
if (!newRscAttrSet.hasAttrName(attrName)) {
continue;
}
RscAttrValue rscAttr = newRscAttrSet.getRscAttr(attrName);
Object attrValue = rscAttr.getAttrValue();
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());
continue;
} else if (attrValue == null) {
continue;
}
String setMthdName = "set" + attrName.substring(0, 1).toUpperCase()
+ attrName.substring(1);
Method[] mthds = this.getClass().getDeclaredMethods();
for (Method m : mthds) {
if (m.getName().equals(setMthdName)) {
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
// if( params[0].getClass() != attrInfo.getAttrClass() ||
// params.length != 1) {
// System.out.println("Error setting rsc attr "+attrName+" : setter class "
// +
// "has incompatible argument.");
// System.out.println("Warning: Attribute "+attrName
// +" is not defined\n"+
// "as correct type:" +rtype.getName() + " != " +
// attrInfo.getAttrClass().getName() );
// continue;
// }
try {
m.invoke(this, attrValue);
} catch (IllegalAccessException iae) {
System.out.println(iae.getMessage());
} catch (IllegalArgumentException iae) {
System.out.println(iae.getMessage());
} catch (InvocationTargetException ite) {
System.out.println(ite.getMessage());
} catch (ClassCastException cce) {
System.out.println(cce.getMessage());
}
}
}
}
if (ncRsc != null) {
((INatlCntrsResource) ncRsc).resourceAttrsModified();
}
return true;
}
return true;
}
@Override
public void update(Object updateData) {
// Do nothing version for those resources that don't need this method
}
public void setLegendColor( RGB legClr ) {
legendColor = legClr;
public void setLegendColor(RGB legClr) {
legendColor = legClr;
}
public RGB getLegendColor() {
return legendColor;
return legendColor;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
AbstractNatlCntrsResourceData other = (AbstractNatlCntrsResourceData) obj;
if (isEdited != other.isEdited)
return false;
if (legendColor == null) {
if (other.legendColor != null)
return false;
} else if (!legendColor.equals(other.legendColor))
return false;
if (resourceName == null) {
if (other.resourceName != null)
return false;
} else if (!resourceName.equals(other.resourceName))
return false;
if (resourceVersion == null) {
if (other.resourceVersion != null)
return false;
} else if (!resourceVersion.equals(other.resourceVersion))
return false;
return true;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
AbstractNatlCntrsResourceData other = (AbstractNatlCntrsResourceData) obj;
if (isEdited != other.isEdited)
return false;
if (legendColor == null) {
if (other.legendColor != null)
return false;
} else if (!legendColor.equals(other.legendColor))
return false;
if (resourceName == null) {
if (other.resourceName != null)
return false;
} else if (!resourceName.equals(other.resourceName))
return false;
if (resourceVersion == null) {
if (other.resourceVersion != null)
return false;
} else if (!resourceVersion.equals(other.resourceVersion))
return false;
return true;
}
}

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
@ -71,298 +67,336 @@ import com.raytheon.viz.ui.editor.AbstractEditor;
* 02/01/13 #972 Greg Hull RbdBundleEditorWrapper doesn't need to be a generic
* 02/12/13 #972 Greg Hull NcDisplayType and NatlCntrsEditor
* 11/26/13 #1078 Greg Hull Size Of Image fix (PixelExtent constructor)
*
*
* </pre>
*
* @version 1
*/
public class ResourceBndlLoader implements Runnable { // extends Job {
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,
Boolean useRBDName) {
rbdBundle = theRbdBundle;
ncEditor = ed;
NcEditorUtil.setDisplayAvailable(ed, false);
replaceEditorNameWithRbdName = useRBDName;
}
public AbstractRBD<?> getRbdBundle() {
return rbdBundle;
}
public AbstractEditor getNcEditor() {
return ncEditor;
}
public Boolean useRbdNameForEditor() {
return replaceEditorNameWithRbdName;
}
}
private final class RbdBundleEditorWrapper {
private AbstractRBD<?> rbdBundle;
private AbstractEditor ncEditor;
private Boolean replaceEditorNameWithRbdName;
RbdBundleEditorWrapper(AbstractRBD<?> theRbdBundle, AbstractEditor ed,
Boolean useRBDName ){
rbdBundle = theRbdBundle;
ncEditor = ed;
NcEditorUtil.setDisplayAvailable( ed, false );
replaceEditorNameWithRbdName = useRBDName;
}
public AbstractRBD<?> getRbdBundle() {
return rbdBundle;
}
public AbstractEditor getNcEditor() {
return ncEditor;
}
public Boolean useRbdNameForEditor() {
return replaceEditorNameWithRbdName;
}
}
private final ConcurrentLinkedQueue<RbdBundleEditorWrapper> seldRBDs;
// when set we will only load the selected Pane
private boolean loadSelectedPaneOnly = false;
public void setLoadSelectedPaneOnly() {
loadSelectedPaneOnly = true;
loadSelectedPaneOnly = true;
}
public void removeAllSeldRBDs() {
seldRBDs.clear();
}
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
seldRBDs.add( new RbdBundleEditorWrapper( rbd, theEditor, false ) );
seldRBDs.clear();
}
public void addRBD( AbstractRBD<?> newRBD, AbstractEditor theEditor ) {
seldRBDs.add( new RbdBundleEditorWrapper( newRBD, theEditor, true ) );
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
seldRBDs.add(new RbdBundleEditorWrapper(rbd, theEditor, false));
}
public void addRBD(AbstractRBD<?> newRBD, AbstractEditor theEditor) {
seldRBDs.add(new RbdBundleEditorWrapper(newRBD, theEditor, true));
}
public ResourceBndlLoader(String name) { // name of the Job
// super(name);
seldRBDs = new ConcurrentLinkedQueue<RbdBundleEditorWrapper>();
}
public ResourceBndlLoader( String name ) { // name of the Job
//super(name);
seldRBDs = new ConcurrentLinkedQueue<RbdBundleEditorWrapper>();
}
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 );
ErrorDialog.openError(Display.getCurrent().getActiveShell(),
"ERROR", errMsg, status);
}
}
// check that the
String errMsg = "";
ErrorMsg(String em) {
errMsg = em;
}
public void run() {
Status status = new Status(Status.ERROR, UiPlugin.PLUGIN_ID, 0,
errMsg, null);
ErrorDialog.openError(Display.getCurrent().getActiveShell(),
"ERROR", errMsg, status);
}
}
// check that the
public boolean areSeldRBDsGeoSyncCompatible() {
return true;
return true;
}
// @Override
// protected IStatus run(IProgressMonitor monitor) {
//public void loadRBDs() {
public void run() {
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??" );
}
}
for ( RbdBundleEditorWrapper thisWrapper : wrapperClassArray ) {
try {
AbstractRBD<?> rbdBndl = thisWrapper.getRbdBundle();
// the editor should have already be created with the right
// number of displays and matching paneLayouts
AbstractEditor editor = thisWrapper.getNcEditor();
if( editor == null ) {
throw new VizException("??editor is null in rbdLoader?");
}
// 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 );
if( pane == null ) {
throw new VizException("Could not get pane "+paneid.toString() +
" from the editor.");
}
// @Override
// protected IStatus run(IProgressMonitor monitor) {
// public void loadRBDs() {
public void run() {
RbdBundleEditorWrapper[] wrapperClassArray = (RbdBundleEditorWrapper[]) seldRBDs
.toArray(new RbdBundleEditorWrapper[0]);
// 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 ) {
continue;
}
List<ResourcePair> rlist = pane.getRenderableDisplay().getDescriptor().getResourceList();
if( rlist == null ) {
throw new VizException("The ResourceList is empty?");
}
Iterator<ResourcePair> it = rlist.iterator();
while( it.hasNext() ){
ResourcePair rp = it.next();
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
IDisplayPane displayPanes[] = editor.getDisplayPanes();
IDisplayPane seldPane = null;
INcPaneLayout playout = NcEditorUtil.getPaneLayout( editor );
if( loadSelectedPaneOnly ) {
if( !playout.containsPaneId( rbdBndl.getSelectedPaneId() ) ) {
// 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: ");
}
}
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 );
if (loadSelectedPaneOnly) {
if (wrapperClassArray.length > 1) {
System.out
.println("Warning: rbdLoader should only load one RBD when"
+ "loadSelectedPaneOnly is true??");
}
}
// 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 ) {
continue;
}
for (RbdBundleEditorWrapper thisWrapper : wrapperClassArray) {
IDisplayPane displayPane = NcEditorUtil.getDisplayPane( editor, paneid );
INatlCntrsRenderableDisplay mapDisp = rbdBndl.getDisplayPane( paneid );
try {
AbstractRBD<?> rbdBndl = thisWrapper.getRbdBundle();
if( seldPane == null ) {
seldPane = displayPane;
}
// the editor should have already be created with the right
// number of displays and matching paneLayouts
AbstractEditor editor = thisWrapper.getNcEditor();
// 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 (editor == null) {
throw new VizException("??editor is null in rbdLoader?");
}
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.
//
if( thisWrapper.useRbdNameForEditor() ) {
// 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);
NcDisplayName dispName = NcEditorUtil.getDisplayName( editor );
dispName = new NcDisplayName( dispName.getId(), rbdBndl.getRbdName() );
NcEditorUtil.setDisplayName( editor, dispName);
editor.setTabTitle( dispName.toString() );
}
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() );
if (pane == null) {
throw new VizException("Could not get pane "
+ paneid.toString() + " from the editor.");
}
NcDisplayMngr.bringToTop( editor );
}
catch ( VizException vizex ) {
VizApp.runAsync(
new ErrorMsg( vizex.getMessage() ) );
}
}
removeAllSeldRBDs();
// this.cancel(); if a Job
// return null;
// 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) {
continue;
}
List<ResourcePair> rlist = pane.getRenderableDisplay()
.getDescriptor().getResourceList();
if (rlist == null) {
throw new VizException("The ResourceList is empty?");
}
Iterator<ResourcePair> it = rlist.iterator();
while (it.hasNext()) {
ResourcePair rp = it.next();
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
IDisplayPane displayPanes[] = editor.getDisplayPanes();
IDisplayPane seldPane = null;
INcPaneLayout playout = NcEditorUtil.getPaneLayout(editor);
if (loadSelectedPaneOnly) {
if (!playout.containsPaneId(rbdBndl.getSelectedPaneId())) {
// 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: ");
}
} 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);
// 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) {
continue;
}
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) {
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.
//
if (thisWrapper.useRbdNameForEditor()) {
NcDisplayName dispName = NcEditorUtil
.getDisplayName(editor);
dispName = new NcDisplayName(dispName.getId(),
rbdBndl.getRbdName());
NcEditorUtil.setDisplayName(editor, dispName);
editor.setTabTitle(dispName.toString());
}
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());
NcDisplayMngr.bringToTop(editor);
} catch (VizException vizex) {
VizApp.runAsync(new ErrorMsg(vizex.getMessage()));
}
}
removeAllSeldRBDs();
// this.cancel(); if a Job
// return null;
}
//
//
public boolean loadResourceBundleDefn( IDisplayPane pane,
INatlCntrsRenderableDisplay mapDisplay, NCTimeMatcher timeMatcher ) {
public boolean loadResourceBundleDefn(IDisplayPane pane,
INatlCntrsRenderableDisplay mapDisplay, NCTimeMatcher timeMatcher) {
if( timeMatcher == null ) {
System.out.println("Error Loading Timeline???");
return false;
}
INatlCntrsDescriptor descr = (INatlCntrsDescriptor) mapDisplay.getDescriptor();
if (timeMatcher == null) {
System.out.println("Error Loading Timeline???");
return false;
}
descr.setTimeMatcher( timeMatcher );
descr.setNumberOfFrames( timeMatcher.getNumFrames() );
DataTime[] dataTimes = timeMatcher.getFrameTimes().toArray( new DataTime[0] );
INatlCntrsDescriptor descr = (INatlCntrsDescriptor) mapDisplay
.getDescriptor();
if( dataTimes == null ||
dataTimes.length == 0 ) {
// descr.setDataTimes( null );
}
else {
descr.setDataTimes( dataTimes );
if( timeMatcher.isForecast() ) {
descr.setFrame( 0 );
}
else {
descr.setFrame( dataTimes.length-1 );
}
}
descr.setTimeMatcher(timeMatcher);
descr.setNumberOfFrames(timeMatcher.getNumFrames());
DataTime[] dataTimes = timeMatcher.getFrameTimes().toArray(
new DataTime[0]);
ResourceList rscList = descr.getResourceList();
if (dataTimes == null || dataTimes.length == 0) {
// descr.setDataTimes( null );
} else {
descr.setDataTimes(dataTimes);
// Add PGEN resource back
if ( !pane.getRenderableDisplay().getDescriptor().getResourceList().isEmpty() ){
rscList.addAll( pane.getRenderableDisplay().getDescriptor().getResourceList());
}
if (timeMatcher.isForecast()) {
descr.setFrame(0);
} else {
descr.setFrame(dataTimes.length - 1);
}
}
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
// 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
// if the area is to be set from a resource-defined area, we need
//
pane.setRenderableDisplay( mapDisplay );
PredefinedArea initArea = mapDisplay.getInitialArea();
ResourceList rscList = descr.getResourceList();
if( initArea.getSource() != AreaSource.PREDEFINED_AREA ) {
// Add PGEN resource back
if (!pane.getRenderableDisplay().getDescriptor().getResourceList()
.isEmpty()) {
rscList.addAll(pane.getRenderableDisplay().getDescriptor()
.getResourceList());
}
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 ) );
((NCMapDescriptor)descr).setSuspendZoom( true );
// ZoomUtil.suspendZoom( mapDisplay.getContainer() ) ;
}
else if( initArea.getZoomLevel().equals( ZoomLevelStrings.FitToScreen.toString() ) ) {
rscList.instantiateResources(descr, true);
}
}
pane.setZoomLevel( mapDisplay.getZoomLevel() );
pane.refresh();
// 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
// if the area is to be set from a resource-defined area, we need
//
pane.setRenderableDisplay(mapDisplay);
return true;
}
PredefinedArea initArea = mapDisplay.getInitialArea();
if (initArea.getSource() != AreaSource.PREDEFINED_AREA) {
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));
((NCMapDescriptor) descr).setSuspendZoom(true);
// ZoomUtil.suspendZoom( mapDisplay.getContainer() ) ;
} else if (initArea.getZoomLevel().equals(
ZoomLevelStrings.FitToScreen.toString())) {
}
}
pane.setZoomLevel(mapDisplay.getZoomLevel());
pane.refresh();
return true;
}
}

View file

@ -18,101 +18,122 @@ 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
* @author
* @version 1
*/
@XmlRootElement
@XmlAccessorType(XmlAccessType.NONE)
public class ResourceCategory implements Comparable<ResourceCategory> {
public static class ResourceCategoryAdapter extends XmlAdapter<String, ResourceCategory> {
//
@Override
public ResourceCategory unmarshal(String n) throws Exception {
if( ResourceCategory.getCategory( n ) == ResourceCategory.NullCategory ) {
ResourceCategory.createCategory( n );
}
return ResourceCategory.getCategory( n );
}
@Override
public String marshal(ResourceCategory rc) throws Exception {
return rc.toString();
}
}
public static class ResourceCategoryAdapter extends
XmlAdapter<String, ResourceCategory> {
//
@Override
public ResourceCategory unmarshal(String n) throws Exception {
if (ResourceCategory.getCategory(n) == ResourceCategory.NullCategory) {
ResourceCategory.createCategory(n);
}
return ResourceCategory.getCategory(n);
}
@Override
public String marshal(ResourceCategory rc) throws Exception {
return rc.toString();
}
}
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 GridRscCategory = createCategory( "GRID", 300 );
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 );
private static int nextCatOrder = OverlayRscCategory.order+100;
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.
//
// SurfaceFcstRscCategory = "SURF_FCST";
// UpperAirFcstRscCategory = "UAIR_FCST";
// SurfaceObsRscCategory = "SURF_OBS";
// UpperAirObsRscCategory = "UAIR_OBS";
// IMAGE, MODEL, WATCH/WARNING
public static ResourceCategory SatelliteRscCategory = createCategory(
"SATELLITE", 100);
private String catName;
private int order;
public static ResourceCategory RadarRscCategory = createCategory("RADAR",
200);
private ResourceCategory( String name, int ord ) {
catName = name;
order = ord;
}
public static ResourceCategory getCategory( String name ) {
ResourceCategory rc = catMap.get( name.trim().toUpperCase() );
return (rc == null ? ResourceCategory.NullCategory : rc );
}
public static ResourceCategory createCategory( String name ) {
return createCategory( name, nextCatOrder++ );
}
public static ResourceCategory createCategory( String name, int ord ) {
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 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 GraphRscCategory = createCategory(
"TIMESERIES", 860);
private static int nextCatOrder = OverlayRscCategory.order + 100;
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.
//
// SurfaceFcstRscCategory = "SURF_FCST";
// UpperAirFcstRscCategory = "UAIR_FCST";
// SurfaceObsRscCategory = "SURF_OBS";
// UpperAirObsRscCategory = "UAIR_OBS";
// IMAGE, MODEL, WATCH/WARNING
private String catName;
private int order;
private ResourceCategory(String name, int ord) {
catName = name;
order = ord;
}
public static ResourceCategory getCategory(String name) {
ResourceCategory rc = catMap.get(name.trim().toUpperCase());
return (rc == null ? ResourceCategory.NullCategory : rc);
}
public static ResourceCategory createCategory(String name) {
return createCategory(name, nextCatOrder++);
}
public static ResourceCategory createCategory(String name, int ord) {
name = String.valueOf(name).toUpperCase().trim();
ResourceCategory rCat = catMap.get( name );
if( rCat == null ) {
rCat = new ResourceCategory( name, ord );
catMap.put( name, rCat );
ResourceCategory rCat = catMap.get(name);
if (rCat == null) {
rCat = new ResourceCategory(name, ord);
catMap.put(name, rCat);
}
return rCat;
}
public String getCategoryName() {
return catName;
}
public Boolean isPgenCategory() {
return this == PGENRscCategory;
}
}
public String toString() {
return catName;
}
public static ResourceCategory[] values() {
ResourceCategory[] cats = catMap.values().toArray(
public String getCategoryName() {
return catName;
}
public Boolean isPgenCategory() {
return this == PGENRscCategory;
}
public String toString() {
return catName;
}
public static ResourceCategory[] values() {
ResourceCategory[] cats = catMap.values().toArray(
new ResourceCategory[catMap.size()]);
Arrays.sort(cats);
return cats;
@ -140,8 +161,8 @@ public class ResourceCategory implements Comparable<ResourceCategory> {
return true;
}
@Override
public int compareTo(ResourceCategory c) {
return order - c.order;
}
@Override
public int compareTo(ResourceCategory c) {
return order - c.order;
}
}

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 ||
// resourceCategory == ResourceCategory.PGENRscCategory ||
resourceCategory == ResourceCategory.EnsembleRscCategory ||
resourceCategory == ResourceCategory.SpaceRscCategory;
// @formatter:on
return resourceCategory == ResourceCategory.GridRscCategory
|| resourceCategory == ResourceCategory.RadarRscCategory
|| resourceCategory == ResourceCategory.GraphRscCategory
// resourceCategory == ResourceCategory.PGENRscCategory ||
|| resourceCategory == ResourceCategory.EnsembleRscCategory
|| resourceCategory == ResourceCategory.SpaceRscCategory;
} else if (attrSetOrg == AttrSetsOrganization.BY_ATTR_SET_GROUP) {
return true;
} else {
@ -660,11 +697,11 @@ public class ResourceDefinition implements ISerializableObject, IAlertObserver,
// else {
// 'LIKE' doesn't work for integers. Just leave this out.
// if (prmInfo.getParamClass() == Integer.class) {
// inventoryConstraints.put (cnstrName,
// RequestConstraint.WILDCARD);
// inventoryConstraints.put (cnstrName,
// RequestConstraint.WILDCARD);
// }
// inventoryConstraints.put (cnstrName,
// RequestConstraint.WILDCARD);
// RequestConstraint.WILDCARD);
// }
// @formatter:on
}
@ -707,9 +744,9 @@ public class ResourceDefinition implements ISerializableObject, IAlertObserver,
public Boolean getInventoryEnabled() {
// @formatter:off
return inventoryEnabled &&
// force to false (disabled) for non-grid non-ensemble resources
(resourceCategory.equals(ResourceCategory.GridRscCategory) ||
resourceCategory.equals(ResourceCategory.EnsembleRscCategory));
// force to false (disabled) for non-grid non-ensemble resources
(resourceCategory.equals(ResourceCategory.GridRscCategory) || resourceCategory
.equals(ResourceCategory.EnsembleRscCategory));
// @formatter:on
}
@ -1056,24 +1093,24 @@ public class ResourceDefinition implements ISerializableObject, IAlertObserver,
// private void initInventory (Boolean reload) throws VizException {
//
// if (!usesInventory()) {
// return;
// return;
// }
// else if (getPluginName() == null) {
// throw new VizException ("Error creating ResourceDefn (" +
// resourceDefnName +
// ") The pluginName must be given as a resource parameter." );
// throw new VizException ("Error creating ResourceDefn (" +
// resourceDefnName +
// ") The pluginName must be given as a resource parameter." );
// }
// else if (getPluginName().equals(GempakGrid.gempakPluginName)) {
// return;
// return;
// }
// else if (isInventoryInitialized() && !reload) {
// return;
// return;
// }
// else if (!isInventoryInitialized() && reload) {
// // can't reload if not created yet
// //reload =
// }
// return;
// return;
// }
// @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) {
@ -2028,4 +2072,4 @@ public class ResourceDefinition implements ISerializableObject, IAlertObserver,
return false;
return true;
}
}
}

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?
numFrames = frameTimes.size();
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>
*
@ -58,9 +57,9 @@ import com.raytheon.viz.ui.input.EditableManager;
* 10/19/2012 897 S. Gurung Updated handleKeyUp() to not toggle PgenResource and added code to
* refresh the editor after handling events.
* 12/19/2012 960 G. Hull use propertiesChanged() to toggle colorBar resources
*
*
*
*
*
*
* </pre>
*
* @author sgurung
@ -68,243 +67,256 @@ import com.raytheon.viz.ui.input.EditableManager;
*/
public class NCLegendHandler extends AbstractNCLegendInputHandler {
/**
* @param resource
*/
protected NCLegendHandler(NCLegendResource resource) {
super(resource);
}
private ResourcePair mouseDownRsc = null;
private static int currentRscIndex = 0;
private boolean isShiftDown = false;
private static boolean isFirstTime = true;
private boolean isShiftDown = false;
@Override
private static boolean isFirstTime = true;
@Override
public boolean handleMouseDown(int x, int y, int mouseButton) {
if (mouseButton ==1 || mouseButton ==2) {
//IDisplayPaneContainer editor = getResourceContainer();
//if (prefManager.handleClick(HIDE_RESOURCE_PREF, mouseButton)) {
AbstractEditor editor = NcDisplayMngr.getActiveNatlCntrsEditor();
if( editor != null && editor instanceof AbstractNcEditor ) {
IDisplayPane activePane = editor.getActiveDisplayPane();
IRenderableDisplay display = editor.getActiveDisplayPane()
.getRenderableDisplay();
mouseDownRsc = resource.checkLabelSpace(display.getDescriptor(),
activePane.getTarget(), x, y);
}
}
return false;
if (mouseButton == 1 || mouseButton == 2) {
// IDisplayPaneContainer editor = getResourceContainer();
// if (prefManager.handleClick(HIDE_RESOURCE_PREF, mouseButton)) {
AbstractEditor editor = NcDisplayMngr.getActiveNatlCntrsEditor();
if (editor != null && editor instanceof AbstractNcEditor) {
IDisplayPane activePane = editor.getActiveDisplayPane();
IRenderableDisplay display = editor.getActiveDisplayPane()
.getRenderableDisplay();
mouseDownRsc = resource.checkLabelSpace(
display.getDescriptor(), activePane.getTarget(), x, y);
}
}
return false;
}
@Override
public boolean handleMouseUp(int x, int y, int mouseButton) {
AbstractEditor editor = NcDisplayMngr.getActiveNatlCntrsEditor();
if (mouseButton ==1) {
if( editor != null && editor instanceof AbstractNcEditor ) {
IDisplayPane activePane = editor.getActiveDisplayPane();
IRenderableDisplay display = editor.getActiveDisplayPane()
.getRenderableDisplay();
ResourcePair rsc = resource.checkLabelSpace(display.getDescriptor(),
activePane.getTarget(), x, y);
if (rsc != null && rsc == mouseDownRsc) {
mouseDownRsc = null;
toggleVisibility(rsc);
editor.refresh();
return true;
}
}
}
else if (mouseButton == 2 ){
if (mouseDownRsc != null && mouseDownRsc.getResource()
.hasCapability(EditableCapability.class)) {
AbstractEditor editor = NcDisplayMngr.getActiveNatlCntrsEditor();
if (mouseButton == 1) {
if (editor != null && editor instanceof AbstractNcEditor) {
IDisplayPane activePane = editor.getActiveDisplayPane();
IRenderableDisplay display = editor.getActiveDisplayPane()
.getRenderableDisplay();
ResourcePair rsc = resource.checkLabelSpace(
display.getDescriptor(), activePane.getTarget(), x, y);
if (rsc != null && rsc == mouseDownRsc) {
mouseDownRsc = null;
toggleVisibility(rsc);
editor.refresh();
return true;
}
}
} else if (mouseButton == 2) {
if (mouseDownRsc != null
&& mouseDownRsc.getResource().hasCapability(
EditableCapability.class)) {
// check / make editable
EditableManager.makeEditable(
mouseDownRsc.getResource(),
mouseDownRsc.getResource(),
!mouseDownRsc.getResource()
.getCapability(EditableCapability.class)
.isEditable());
mouseDownRsc = null;
mouseDownRsc = null;
editor.refresh();
return true;
}
}
return false;
}
return false;
}
@Override
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 handleMouseDownMove(int x, int y, int mouseButton) {
return (mouseDownRsc != null);
}
public boolean handleMouseHover(int x, int y) {
return false;
return false;
}
public boolean handleMouseMove(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 handleMouseWheel(Event event, int x, int y) {
return false;
}
public boolean handleMouseExit(Event event) {
return false;
public boolean handleMouseExit(Event event) {
return false;
}
public boolean handleMouseEnter(Event event) {
return false;
public boolean handleMouseEnter(Event event) {
return false;
}
@Override
public boolean handleKeyUp(int keyCode) {
if ( keyCode != SWT.SHIFT && keyCode != SWT.ARROW_UP && keyCode != SWT.ARROW_DOWN ) {
public boolean handleKeyUp(int keyCode) {
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();
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.
*/
if (( keyCode == SWT.ARROW_UP || keyCode == SWT.ARROW_DOWN)){
for ( ResourcePair resPair : theMainList){
resPair.getProperties().setVisible(true);
}
}
if (keyCode == SWT.SHIFT) {
isShiftDown = true;
}
AbstractEditor editor = NcDisplayMngr.getActiveNatlCntrsEditor();
ResourceList theMainList = editor.getActiveDisplayPane()
.getDescriptor().getResourceList();
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.
*/
if ((keyCode == SWT.ARROW_UP || keyCode == SWT.ARROW_DOWN)) {
for (ResourcePair resPair : theMainList) {
resPair.getProperties().setVisible(true);
}
}
}else{
} else {
/*
* Create 2 sublists.One for the colorbar resources and one for the
* requestable resources (non-system and non-map layer resources)
* Create 2 sublists.One for the colorbar resources and one for the
* requestable resources (non-system and non-map layer resources)
* Set the visibility for all the resources in both lists to false.
*/
boolean allVisible = true;
for ( ResourcePair resPair : theMainList){
if ( ! resPair.getProperties().isSystemResource()
&& !resPair.getProperties().isMapLayer()
&& resPair.getResource().getClass().getSimpleName().compareTo("PgenResource") != 0){
subListOfResourcesToToggle.add(resPair);
allVisible = allVisible && resPair.getProperties().isVisible();
resPair.getProperties().setVisible(false);
}
}
if(subListOfResourcesToToggle.isEmpty())
return false;
if (allVisible)
isFirstTime = true;
int listSize = subListOfResourcesToToggle.size();
if ( keyCode == SWT.ARROW_UP ){
/*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
*/
if ( isFirstTime || isShiftDown)
currentRscIndex = 0;
else{
currentRscIndex++;
if(currentRscIndex > (listSize - 1))
currentRscIndex = 0;
}
}else if (keyCode == SWT.ARROW_DOWN ){
for (ResourcePair resPair : theMainList) {
if (!resPair.getProperties().isSystemResource()
&& !resPair.getProperties().isMapLayer()
&& resPair.getResource().getClass().getSimpleName()
.compareTo("PgenResource") != 0) {
subListOfResourcesToToggle.add(resPair);
allVisible = allVisible
&& resPair.getProperties().isVisible();
resPair.getProperties().setVisible(false);
}
}
if (subListOfResourcesToToggle.isEmpty())
return false;
if (allVisible)
isFirstTime = true;
int listSize = subListOfResourcesToToggle.size();
if (keyCode == SWT.ARROW_UP) {
/*
*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
*/
if(isFirstTime || isShiftDown)
currentRscIndex = listSize - 1;
else{
currentRscIndex--;
if( currentRscIndex < 0 )
currentRscIndex = listSize - 1;
}
}
/*Make the resource visible*/
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.
// This is triggered by setVisible();
if ( isFirstTime && ( ( keyCode == SWT.ARROW_DOWN ) || ( keyCode == SWT.ARROW_UP ) ))
isFirstTime = false;
* 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 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;
else {
currentRscIndex++;
if (currentRscIndex > (listSize - 1))
currentRscIndex = 0;
}
} else if (keyCode == SWT.ARROW_DOWN) {
/*
* 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)
currentRscIndex = listSize - 1;
else {
currentRscIndex--;
if (currentRscIndex < 0)
currentRscIndex = listSize - 1;
}
}
/* Make the resource visible */
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.
// This is triggered by setVisible();
if (isFirstTime
&& ((keyCode == SWT.ARROW_DOWN) || (keyCode == SWT.ARROW_UP)))
isFirstTime = false;
}
editor.refresh();
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
*subsequently pressed.
*/
isShiftDown = false;
isFirstTime = true;
}
return false;
}
@Override
public boolean handleKeyDown(int keyCode) {
if ( keyCode == SWT.SHIFT ) {
isShiftDown = true;
return false;
}
return false;
}
editor.refresh();
if (isShiftDown) {
/*
* 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;
isFirstTime = true;
}
return false;
}
@Override
public boolean handleKeyDown(int keyCode) {
if (keyCode == SWT.SHIFT) {
isShiftDown = true;
return false;
}
return false;
}
private void toggleVisibility(ResourcePair rp) {
AbstractVizResource<?, ?> rsc = rp.getResource();
if (rsc != null) {
@ -333,47 +345,10 @@ public class NCLegendHandler extends AbstractNCLegendInputHandler {
.toggle(rp);
}
}
return;
}
}
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,66 +19,81 @@ 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
* @author
* @version 1
*/
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) {
String refId = layout.getEditorArea();
String refId = layout.getEditorArea();
// Get the editor area.
long t0 = System.currentTimeMillis();
long t0 = System.currentTimeMillis();
layout.getEditorArea();
// long t1 = System.currentTimeMillis();
// System.out.println("Time to get Editor Area: " + (t1-t0) + " ms");
// long t1 = System.currentTimeMillis();
// System.out.println("Time to get Editor Area: " + (t1-t0) + " ms");
layout.setFixed(false);
// long t2 = System.currentTimeMillis();
// System.out.println("Time to set Fixed: " + (t2-t1) + " ms");
// long t2 = System.currentTimeMillis();
// System.out.println("Time to set Fixed: " + (t2-t1) + " ms");
layout.addPlaceholder(PgenUtil.VIEW_ID, IPageLayout.LEFT, 0.15f, refId);
// 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);
// long t4 = System.currentTimeMillis();
// System.out.println("Time to add Placeholder for NSHARP: " + (t4-t3) + " ms");
// 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);
// long t4 = System.currentTimeMillis();
// 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 add Action set: " + (t5-t4) + " 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,
* com.raytheon.viz.core.IDisplayPane)
* @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) {
// zoomMenuAction.setContainer(container);
// return new AbstractRightClickAction[] { zoomMenuAction };
return null;
// zoomMenuAction.setContainer(container);
// return new AbstractRightClickAction[] { zoomMenuAction };
return null;
}
}