Omaha #3368 - Move ohd plugin to new repository

Former-commit-id: 28e88dfe7e [formerly 8c467a9fa5 [formerly 56dfed379b0e41c435a3226c3f02b9bc5232b4fd]]
Former-commit-id: 8c467a9fa5
Former-commit-id: aec275dc31
This commit is contained in:
Steve Harris 2014-08-21 11:04:08 -05:00
parent b77eb54d1f
commit 849aac396b
1832 changed files with 0 additions and 450527 deletions

View file

@ -1,17 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry exported="true" kind="lib" path="externaljars/bsf.jar"/>
<classpathentry exported="true" kind="lib" path="externaljars/bsh-2.0b4.jar"/>
<classpathentry exported="true" kind="lib" path="externaljars/ChartDirector.jar"/>
<classpathentry exported="true" kind="lib" path="externaljars/fldat.jar"/>
<classpathentry exported="true" kind="lib" path="externaljars/ihfsdb.jar"/>
<classpathentry exported="true" kind="lib" path="externaljars/jcchart.jar"/>
<classpathentry exported="true" kind="lib" path="externaljars/jdom.jar"/>
<classpathentry exported="true" kind="lib" path="externaljars/junit.jar"/>
<classpathentry exported="true" kind="lib" path="externaljars/netcdfUI-2.2.22.jar"/>
<classpathentry exported="true" kind="lib" path="externaljars/postgresql-8.3-603.jdbc3.jar"/>
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View file

@ -1,28 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>ohd.hseb.common</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.jdt.core.javanature</nature>
<nature>org.eclipse.pde.PluginNature</nature>
</natures>
</projectDescription>

View file

@ -1,7 +0,0 @@
#Thu Mar 26 11:33:13 CDT 2009
eclipse.preferences.version=1
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

@ -1,251 +0,0 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: RiverAppsCommon Plug-in
Bundle-SymbolicName: ohd.hseb.common
Bundle-Version: 1.0.0.qualifier
Bundle-Vendor: Raytheon
Export-Package: ChartDirector,
RTi.Util.GUI,
RTi.Util.IO,
RTi.Util.Message,
RTi.Util.String,
bsh,
bsh.classpath,
bsh.collection,
bsh.commands,
bsh.org.objectweb.asm,
bsh.reflect,
bsh.servlet,
bsh.util,
bsh.util.lib,
com.klg.jclass,
com.klg.jclass.beans,
com.klg.jclass.beans.resources,
com.klg.jclass.cell,
com.klg.jclass.cell.renderers,
com.klg.jclass.cell.swing,
com.klg.jclass.chart,
com.klg.jclass.chart.applet,
com.klg.jclass.chart.beans,
com.klg.jclass.chart.beans.resources,
com.klg.jclass.chart.customizer,
com.klg.jclass.chart.customizer.resources,
com.klg.jclass.chart.data,
com.klg.jclass.chart.property,
com.klg.jclass.chart.property.html,
com.klg.jclass.chart.resources,
com.klg.jclass.util,
com.klg.jclass.util.graphics,
com.klg.jclass.util.internal,
com.klg.jclass.util.io,
com.klg.jclass.util.io.resources,
com.klg.jclass.util.legend,
com.klg.jclass.util.legend.resources,
com.klg.jclass.util.progress,
com.klg.jclass.util.resources,
com.klg.jclass.util.swing,
com.klg.jclass.util.swing.beans,
com.klg.jclass.util.swing.beans.resources,
com.klg.jclass.util.swing.encode,
com.klg.jclass.util.swing.encode.resources,
com.klg.jclass.util.swing.icons,
com.klg.jclass.util.swing.resources,
com.klg.jclass.util.value,
com.klg.jclass.util.xml,
com.sitraka.licensing,
com.sitraka.licensing.util,
gov.noaa.FWGUI,
gov.noaa.FloodWav.Component,
gov.noaa.flddb,
gov.noaa.fldwav,
gov.noaa.fldwav.component,
gov.noaa.fldwav.controller,
gov.noaa.fldwav.gui,
gov.noaa.fldwav.parser,
gov.noaa.hec.parser,
junit.awtui,
junit.extensions,
junit.framework,
junit.runner,
junit.swingui,
junit.swingui.icons,
junit.textui,
ohd.hseb.bias_trans,
ohd.hseb.color_chooser,
ohd.hseb.damcrest,
ohd.hseb.db,
ohd.hseb.fcstservice,
ohd.hseb.fp_vtec_info,
ohd.hseb.geomap.contour,
ohd.hseb.geomap.model,
ohd.hseb.geomap.projection,
ohd.hseb.grid,
ohd.hseb.gui.util,
ohd.hseb.ihfsdb.generated,
ohd.hseb.measurement,
ohd.hseb.model,
ohd.hseb.model.mkcapi,
ohd.hseb.model.sacsma,
ohd.hseb.pdc_pp,
ohd.hseb.pdc_pp.sample_data_set,
ohd.hseb.prism,
ohd.hseb.timeserieslite,
ohd.hseb.timeserieslite.gui.drawing,
ohd.hseb.timeserieslite.pdc,
ohd.hseb.timeserieslite.rivermon,
ohd.hseb.util,
ohd.hseb.util.gui,
ohd.hseb.util.gui.drawing,
ohd.hseb.util.gui.jchecktree,
ohd.hseb.util.gui.jtable,
ohd.hseb.util.io,
ohd.hseb.util.test,
org.apache.bsf,
org.apache.bsf.dbline,
org.apache.bsf.debug,
org.apache.bsf.debug.clientImpl,
org.apache.bsf.debug.jsdi,
org.apache.bsf.debug.meta,
org.apache.bsf.debug.serverImpl,
org.apache.bsf.debug.util,
org.apache.bsf.engines.jacl,
org.apache.bsf.engines.javascript,
org.apache.bsf.engines.jython,
org.apache.bsf.engines.netrexx,
org.apache.bsf.engines.xslt,
org.apache.bsf.util,
org.apache.bsf.util.cf,
org.apache.bsf.util.event,
org.apache.bsf.util.event.adapters,
org.apache.bsf.util.event.generator,
org.apache.bsf.util.type,
org.apache.taglibs.bsf,
org.jdom,
org.jdom.adapters,
org.jdom.filter,
org.jdom.input,
org.jdom.output,
org.jdom.transform,
org.jdom.xpath,
org.postgresql,
org.postgresql.core,
org.postgresql.core.types,
org.postgresql.core.v2,
org.postgresql.core.v3,
org.postgresql.ds,
org.postgresql.ds.common,
org.postgresql.ds.jdbc23,
org.postgresql.fastpath,
org.postgresql.geometric,
org.postgresql.jdbc2,
org.postgresql.jdbc2.optional,
org.postgresql.jdbc3,
org.postgresql.largeobject,
org.postgresql.ssl,
org.postgresql.translation,
org.postgresql.util,
org.postgresql.xa,
resources.nj22.coords,
resources.nj22.schemas,
resources.nj22.tables,
resources.nj22.ui.icons,
resources.nj22.ui.maps,
resources.nj22.ui.pix,
resources.thredds.dl,
resources.thredds.schemas,
thredds.catalog,
thredds.catalog.crawl,
thredds.catalog.dl,
thredds.catalog.parser.jdom,
thredds.catalog.query,
thredds.catalog.search,
thredds.catalog.search.ui,
thredds.catalog.ui,
thredds.catalog.ui.query,
thredds.catalog.ui.tools,
thredds.cataloggen,
thredds.cataloggen.catalogrefexpander,
thredds.cataloggen.config,
thredds.cataloggen.datasetenhancer,
thredds.cataloggen.inserter,
thredds.crawlabledataset,
thredds.crawlabledataset.filter,
thredds.crawlabledataset.sorter,
thredds.datamodel.gis,
thredds.datatype,
thredds.datatype.prefs,
thredds.dqc,
thredds.ui,
thredds.util,
thredds.util.net,
thredds.viewer.gis,
thredds.viewer.gis.shapefile,
thredds.viewer.gis.worldmap,
thredds.viewer.ui,
thredds.viewer.ui.event,
thredds.viewer.ui.geoloc,
thredds.viewer.ui.table,
thredds.wcs,
ucar.atd.dorade,
ucar.ma2,
ucar.nc2,
ucar.nc2.adde,
ucar.nc2.dataset,
ucar.nc2.dataset.conv,
ucar.nc2.dataset.grid,
ucar.nc2.dataset.transform,
ucar.nc2.dods,
ucar.nc2.dt,
ucar.nc2.dt.fmr,
ucar.nc2.dt.fmrc,
ucar.nc2.dt.grid,
ucar.nc2.dt.image,
ucar.nc2.dt.point,
ucar.nc2.dt.point.decode,
ucar.nc2.dt.radial,
ucar.nc2.dt.trajectory,
ucar.nc2.geotiff,
ucar.nc2.iosp.bufr,
ucar.nc2.iosp.cinrad,
ucar.nc2.iosp.dmsp,
ucar.nc2.iosp.dorade,
ucar.nc2.iosp.gini,
ucar.nc2.iosp.grib,
ucar.nc2.iosp.nexrad2,
ucar.nc2.iosp.nids,
ucar.nc2.ncml,
ucar.nc2.thredds,
ucar.nc2.thredds.server,
ucar.nc2.ui,
ucar.nc2.ui.grid,
ucar.nc2.ui.image,
ucar.nc2.ui.point,
ucar.nc2.units,
ucar.nc2.util,
ucar.unidata.geoloc,
ucar.unidata.geoloc.projection,
ucar.unidata.geoloc.vertical,
ucar.unidata.io,
ucar.unidata.io.bzip2,
ucar.unidata.io.http,
ucar.unidata.util,
ucar.units,
ucar.util.prefs,
ucar.util.prefs.ui
Bundle-ActivationPolicy: lazy
Require-Bundle: ohd.hseb.ihfsdb,
org.postgres
Bundle-ClassPath: externaljars/bsf.jar,
externaljars/bsh-2.0b4.jar,
externaljars/ChartDirector.jar,
externaljars/fldat.jar,
externaljars/ihfsdb.jar,
externaljars/jcchart.jar,
externaljars/jdom.jar,
externaljars/junit.jar,
externaljars/netcdfUI-2.2.22.jar,
externaljars/nlog4j-1.2.21.jar,
externaljars/postgresql-8.3-603.jdbc3.jar,
.
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Import-Package: com.raytheon.uf.common.ohd

View file

@ -1,19 +0,0 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
bin/ohd/,\
externaljars/,\
dist/,\
externaljars/bsf.jar,\
externaljars/bsh-2.0b4.jar,\
externaljars/ChartDirector.jar,\
externaljars/fldat.jar,\
externaljars/ihfsdb.jar,\
externaljars/jcchart.jar,\
externaljars/jdom.jar,\
externaljars/junit.jar,\
externaljars/netcdfUI-2.2.22.jar,\
externaljars/nlog4j-1.2.21.jar,\
externaljars/postgresql-8.3-603.jdbc3.jar
src.includes = externaljars/

View file

@ -1,12 +0,0 @@
<?xml version="1.0"?>
<project default="jar" basedir=".">
<target name="jar" depends="compile">
<jar destfile="${basedir}/dist/ohd_hseb_common.jar">
<fileset dir="${basedir}/bin" includes="**/**.class"></fileset>
</jar>
</target>
<target name="compile">
<javac destdir="${basedir}/bin" srcdir="${basedir}/src"></javac>
</target>
</project>

Binary file not shown.

View file

@ -1,658 +0,0 @@
package ohd.hseb.bias_trans;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.EOFException;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import ohd.hseb.db.Database;
import ohd.hseb.db.DbTimeHelper;
import ohd.hseb.ihfsdb.generated.RWBiasDynRecord;
import ohd.hseb.ihfsdb.generated.RWBiasDynTable;
import ohd.hseb.ihfsdb.generated.RWBiasStatRecord;
import ohd.hseb.ihfsdb.generated.RWBiasStatTable;
import ohd.hseb.ihfsdb.generated.RadarLocRecord;
import ohd.hseb.ihfsdb.generated.RadarLocTable;
import com.raytheon.uf.common.ohd.AppsDefaults;
/**
*
* This class is the bridge between the database and the radar bias message for
* the BiasMessageCreator and the BiasMessageReader programs.
*
* @author lawrence
*
*/
public class BiasDataMgr implements RfcBiasConstants {
private Database _db;
// private DataOutputStream _outFile;
private File _file;
private String _fxaLocalSite;
private String _jdbcUrl;
private String _rfcId;
private String _fileName;
private String _outputFilePath;
private final String RFC_BIAS_MESSAGE_DIR_TOK = "rfc_bias_output_dir";
private final String FXA_LOCAL_SITE_TOK = "FXA_LOCAL_SITE";
private List _radarIdList = null;
public BiasDataMgr(String jdbcUrl) throws Exception {
_jdbcUrl = jdbcUrl;
_db = new Database();
// Create a database connection.
_db.connectWithDriverSearch(_jdbcUrl);
// Get Tokens needed for queries and to build the file path.
getBiasTokens();
}
public RadarBias getRadarBias(String dateTime) throws Exception {
RadarBias radarBias = new RadarBias();
radarBias.setDateTime(dateTime);
radarBias.setMemorySpanGroup(getMemorySpanGroup());
List radarIdList = getRadarIdList();
radarBias
.setBiasDynGroupList(getBiasDynGroupList(radarIdList, dateTime));
return radarBias;
}
private DataOutputStream openOutputFile(String dateTime)
throws FileNotFoundException {
DataOutputStream outFile = null;
// Create the file path
_fileName = _rfcId + dateTime + "z";
File file = new File(_outputFilePath, _fileName);
// Open the bias message file.
try {
outFile = new DataOutputStream(new BufferedOutputStream(
new FileOutputStream(file)));
} catch (FileNotFoundException e) {
System.out.println("Could not open file " + file.toString());
throw e;
}
System.out.println("Opened file " + file.toString());
return outFile;
}
private DataInputStream openInputFile(File filePath)
throws FileNotFoundException {
DataInputStream inputStream = null;
try {
_file = filePath;
inputStream = new DataInputStream(new BufferedInputStream(
new FileInputStream(filePath)));
} catch (FileNotFoundException e) {
System.out.println("Could not open file " + filePath.toString());
throw e;
}
System.out.println("Opened file " + filePath.toString());
return inputStream;
}
private void getBiasTokens() throws Exception {
AppsDefaults apps_defaults = AppsDefaults.getInstance();
String token;
token = apps_defaults.getToken(RFC_BIAS_MESSAGE_DIR_TOK);
if (token == null || token.length() == 0) {
String message = "Token " + RFC_BIAS_MESSAGE_DIR_TOK
+ " not defined.";
throw new Exception(message);
}
_outputFilePath = token;
token = apps_defaults.getToken(FXA_LOCAL_SITE_TOK);
if (token == null || token.length() == 0) {
String message = "Token " + FXA_LOCAL_SITE_TOK + " not defined.";
throw new Exception(message);
}
_rfcId = token.toUpperCase();
_fxaLocalSite = _rfcId;
}
private MemorySpanGroup getMemorySpanGroup() throws Exception {
List biasStatList = null;
RWBiasStatTable biasStat = new RWBiasStatTable(_db);
RWBiasStatRecord record = null;
MemorySpanGroup rwBiasStat = null;
try {
biasStatList = biasStat.select("WHERE office_id = '"
+ _fxaLocalSite + "'");
if (!biasStatList.isEmpty()) {
record = (RWBiasStatRecord) biasStatList.get(0);
rwBiasStat = getRWBiasStatFromRecord(record);
} else {
throw new Exception("The RWBiasStat table is empty.");
}
} catch (SQLException e) {
System.out.println(e.getMessage());
throw e;
}
return rwBiasStat;
}
private List loadRadarIdList() {
// List recordList = null;;
RadarLocTable table = new RadarLocTable(_db);
List radarIdList = new ArrayList();
try {
List<RadarLocRecord> recordList = table
.select("WHERE use_radar = 'T' ORDER BY radid ASC");
// Iterator iterator = recordList.iterator();
// while ( iterator.hasNext())
for (RadarLocRecord record : recordList) {
// RadarLocRecord record = (RadarLocRecord) iterator.next();
radarIdList.add(record.getRadid());
}
} catch (SQLException e) {
System.out.println(e.getMessage());
return null;
}
if (radarIdList.size() == 0) {
System.out.println("No radars found in the RadarLoc table.");
}
return radarIdList;
}
public Set loadRadarIdSetForGivenOffice() {
List recordList = null;
RadarLocTable table = new RadarLocTable(_db);
Set radarIdSet = new HashSet();
try {
recordList = table.select("WHERE use_radar = 'T' AND office_id = '"
+ _rfcId + "' ORDER BY radid ASC");
Iterator iterator = recordList.iterator();
while (iterator.hasNext()) {
RadarLocRecord record = (RadarLocRecord) iterator.next();
radarIdSet.add(record.getRadid());
}
} catch (SQLException e) {
System.out.println(e.getMessage());
return null;
}
if (radarIdSet.size() == 0) {
System.out.println("No radars found for " + _rfcId
+ " in RadarLoc Table.");
}
return radarIdSet;
}
// ----------------------------------------------------------------------------------
private List getBiasDynGroupList(List radarIdList, String _dateTime) {
Iterator biasDynIterator = null;
Iterator radarIdIterator = null;
List recordList = null;
List biasDynGroupList = new ArrayList();
RWBiasDynRecord record;
RWBiasDynTable table = new RWBiasDynTable(_db);
String obsTime;
String radarId;
/*
* Format the obstime as YYYY-MM-DD HH:MM:SS for use in the RWBiasDyn
* query.
*/
obsTime = _dateTime.substring(0, NUM_DIGITS_IN_YEAR)
+ "-"
+ _dateTime.substring(NUM_DIGITS_IN_YEAR, NUM_DIGITS_IN_YEAR
+ NUM_DIGITS_IN_MONTH)
+ "-"
+ _dateTime.substring(NUM_DIGITS_IN_YEAR + NUM_DIGITS_IN_MONTH,
NUM_DIGITS_IN_YEAR + NUM_DIGITS_IN_MONTH
+ NUM_DIGITS_IN_DAY)
+ " "
+ _dateTime.substring(NUM_DIGITS_IN_YEAR + NUM_DIGITS_IN_MONTH
+ NUM_DIGITS_IN_DAY, NUM_DIGITS_IN_YEAR
+ NUM_DIGITS_IN_MONTH + NUM_DIGITS_IN_DAY
+ NUM_DIGITS_IN_HOUR) + ":00:00";
radarIdIterator = radarIdList.iterator();
while (radarIdIterator.hasNext()) {
List biasDynSetList = new ArrayList();
radarId = (String) radarIdIterator.next();
try {
recordList = table.select("WHERE radid='" + radarId + "' AND "
+ " obstime = '" + obsTime + "' AND office_id = '"
+ _fxaLocalSite + "' ORDER BY " + "memspan_ind ASC");
biasDynIterator = recordList.iterator();
while (biasDynIterator.hasNext()) {
record = (RWBiasDynRecord) biasDynIterator.next();
biasDynSetList.add(getRWBiasDynFromRecord(record));
}
} catch (SQLException e) {
System.out.println(e.getMessage());
return null;
}
BiasDynGroup biasDynGroup = new BiasDynGroup();
biasDynGroup.setRadarId(radarId);
biasDynGroup.setBiasDynSetList(biasDynSetList);
biasDynGroupList.add(biasDynGroup);
}
return biasDynGroupList;
}
public List getRadarIdList() {
if (_radarIdList == null) {
_radarIdList = loadRadarIdList();
}
return _radarIdList;
}
private MemorySpanGroup getRWBiasStatFromRecord(RWBiasStatRecord record) {
MemorySpanGroup rwBiasStat = new MemorySpanGroup();
rwBiasStat.setMinGrValueBias(record.getMin_gr_value_bias());
rwBiasStat.setNpairBiasSelect(record.getNpair_bias_select());
rwBiasStat.setNpairSvarUpdate(record.getNpair_svar_update());
rwBiasStat.setNumSpan(record.getNum_span());
rwBiasStat.setStdCut(record.getStd_cut());
rwBiasStat.setBiasQcOpt(record.getBias_qc_opt());
rwBiasStat.setInitSpan(record.getInit_span());
rwBiasStat.setLagCut(record.getLag_cut());
rwBiasStat.setMemSpan1(record.getMem_span1());
rwBiasStat.setMemSpan2(record.getMem_span2());
rwBiasStat.setMemSpan3(record.getMem_span3());
rwBiasStat.setMemSpan4(record.getMem_span4());
rwBiasStat.setMemSpan5(record.getMem_span5());
rwBiasStat.setMemSpan6(record.getMem_span6());
rwBiasStat.setMemSpan7(record.getMem_span7());
rwBiasStat.setMemSpan8(record.getMem_span8());
rwBiasStat.setMemSpan9(record.getMem_span9());
rwBiasStat.setMemSpan10(record.getMem_span10());
return rwBiasStat;
}
private BiasDynSet getRWBiasDynFromRecord(RWBiasDynRecord record) {
BiasDynSet biasDynSet = new BiasDynSet();
biasDynSet.setMeanFieldBias(record.getBias());
biasDynSet.setMemSpanIndex(record.getMemspan_ind());
biasDynSet.setGageRadarPairCount(record.getNumpairs());
biasDynSet.setSumOfGageValues(record.getSumgag());
biasDynSet.setSumOfRadarValues(record.getSumrad());
return biasDynSet;
}
public void writeRadarBiasToFile(RadarBias radarBias, String dateTime)
throws Exception {
// Open the file
DataOutputStream outFile = openOutputFile(dateTime);
// Write Header
writeHeader(radarBias, dateTime, outFile);
// Write body
writeBody(radarBias, outFile);
// Close File
outFile.close();
}
private void writeHeader(RadarBias radarBias, String dateTime,
DataOutputStream outFile) throws IOException {
outFile.writeUTF("BIAS");
outFile.writeUTF(_rfcId);
outFile.writeUTF(dateTime);
MemorySpanGroup memorySpanGroup = radarBias.getMemorySpanGroup();
outFile.writeFloat(memorySpanGroup.getMinGrValueBias());
outFile.writeInt(memorySpanGroup.getNpairBiasSelect());
outFile.writeInt(memorySpanGroup.getNpairSvarUpdate());
outFile.writeInt(memorySpanGroup.getStdCut());
outFile.writeInt(memorySpanGroup.getLagCut());
outFile.writeInt(memorySpanGroup.getInitSpan());
outFile.writeInt(memorySpanGroup.getBiasQcOpt());
outFile.writeInt(memorySpanGroup.getNumSpan());
outFile.writeFloat(memorySpanGroup.getMemSpan1());
outFile.writeFloat(memorySpanGroup.getMemSpan2());
outFile.writeFloat(memorySpanGroup.getMemSpan3());
outFile.writeFloat(memorySpanGroup.getMemSpan4());
outFile.writeFloat(memorySpanGroup.getMemSpan5());
outFile.writeFloat(memorySpanGroup.getMemSpan6());
outFile.writeFloat(memorySpanGroup.getMemSpan7());
outFile.writeFloat(memorySpanGroup.getMemSpan8());
outFile.writeFloat(memorySpanGroup.getMemSpan9());
outFile.writeFloat(memorySpanGroup.getMemSpan10());
}
private void writeBody(RadarBias radarBias, DataOutputStream outFile)
throws IOException {
List biasDynGroupList = radarBias.getBiasDynGroupList();
for (int i = 0; i < biasDynGroupList.size(); ++i) {
BiasDynGroup biasDynGroup = (BiasDynGroup) biasDynGroupList.get(i);
outFile.writeUTF(biasDynGroup.getRadarId());
List biasDynSetList = biasDynGroup.getBiasDynSetList();
outFile.writeInt(biasDynSetList.size());
for (int j = 0; j < biasDynSetList.size(); ++j) {
BiasDynSet biasDynSet = (BiasDynSet) biasDynSetList.get(j);
outFile.writeShort(biasDynSet.getMemSpanIndex());
outFile.writeDouble(biasDynSet.getGageRadarPairCount());
outFile.writeFloat(biasDynSet.getSumOfGageValues());
outFile.writeFloat(biasDynSet.getSumOfRadarValues());
outFile.writeFloat(biasDynSet.getMeanFieldBias());
}
}
}
private void readHeader(DataInputStream inputStream, RadarBias radarBias)
throws IOException {
String biasIndicator;
try {
biasIndicator = inputStream.readUTF();
if (biasIndicator.compareTo("BIAS") != 0) {
throw new IOException("Invalid bias message indicator field "
+ biasIndicator);
}
_rfcId = inputStream.readUTF();
/*
* If, for some reason, this message originated from this office do
* not process any further.
*/
System.out.println("RFC ID " + _rfcId + " FXA_LOCAL_SITE "
+ _fxaLocalSite);
if (_rfcId.compareTo(_fxaLocalSite) == 0) {
throw new IOException(_file.getPath()
+ " originated from this office - " + _fxaLocalSite
+ "\nThis file will not be processed.");
}
radarBias.setDateTime(inputStream.readUTF());
MemorySpanGroup memorySpanGroup = new MemorySpanGroup();
memorySpanGroup.setMinGrValueBias(inputStream.readFloat());
memorySpanGroup.setNpairBiasSelect(inputStream.readInt());
memorySpanGroup.setNpairSvarUpdate(inputStream.readInt());
memorySpanGroup.setStdCut(inputStream.readInt());
memorySpanGroup.setLagCut(inputStream.readInt());
memorySpanGroup.setInitSpan(inputStream.readInt());
memorySpanGroup.setBiasQcOpt(inputStream.readInt());
memorySpanGroup.setNumSpan(inputStream.readInt());
memorySpanGroup.setMemSpan1(inputStream.readFloat());
memorySpanGroup.setMemSpan2(inputStream.readFloat());
memorySpanGroup.setMemSpan3(inputStream.readFloat());
memorySpanGroup.setMemSpan4(inputStream.readFloat());
memorySpanGroup.setMemSpan5(inputStream.readFloat());
memorySpanGroup.setMemSpan6(inputStream.readFloat());
memorySpanGroup.setMemSpan7(inputStream.readFloat());
memorySpanGroup.setMemSpan8(inputStream.readFloat());
memorySpanGroup.setMemSpan9(inputStream.readFloat());
memorySpanGroup.setMemSpan10(inputStream.readFloat());
radarBias.setMemorySpanGroup(memorySpanGroup);
} catch (IOException e) {
e.printStackTrace();
throw e;
}
}
/**
* @param inputStream
* @param radarBias
*/
private void readBody(DataInputStream inputStream, RadarBias radarBias)
throws IOException {
boolean completeGroup = true;
int biasSetSize;
/* List biasDynGroupList = radarBias.getBiasDynGroupList(); */
ArrayList biasDynGroupList = new ArrayList();
try {
while (true) {
BiasDynGroup biasDynGroup = new BiasDynGroup();
/* Read a Radar Id. Are there any left? */
biasDynGroup.setRadarId(inputStream.readUTF());
completeGroup = false;
biasSetSize = inputStream.readInt();
ArrayList biasDynSetList = new ArrayList();
for (int i = 0; i < biasSetSize; ++i) {
BiasDynSet biasDynSet = new BiasDynSet();
biasDynSet.setMemSpanIndex(inputStream.readShort());
biasDynSet.setGageRadarPairCount(inputStream.readDouble());
biasDynSet.setSumOfGageValues(inputStream.readFloat());
biasDynSet.setSumOfRadarValues(inputStream.readFloat());
biasDynSet.setMeanFieldBias(inputStream.readFloat());
biasDynSetList.add(biasDynSet);
}
completeGroup = true;
biasDynGroup.setBiasDynSetList(biasDynSetList);
biasDynGroupList.add(biasDynGroup);
}
} catch (EOFException e) {
if (!completeGroup) {
throw new IOException("Error reading bias message file");
}
}
radarBias.setBiasDynGroupList(biasDynGroupList);
}
public RadarBias readRadarBiasFromFile(File filePath) throws Exception {
RadarBias radarBias = new RadarBias();
// Attempt to open the input file.
DataInputStream inputStream = openInputFile(filePath);
// Read the file header.
readHeader(inputStream, radarBias);
// Read the file body.
readBody(inputStream, radarBias);
inputStream.close();
return radarBias;
}
public void writeRadarBiasToDatabase(RadarBias radarBias) throws Exception {
/* Retrieve the list of offices for which to process bias information. */
Set radarIdSet = loadRadarIdSetForGivenOffice();
if (radarIdSet.size() != 0) {
/* Write to the RWBiasStat table. */
writeMemorySpanGroup(radarBias);
/* Write to the RWBiasDyn table. */
writeBiasDynSet(radarBias, radarIdSet);
} else {
System.out.println("No radars to process for office " + _rfcId
+ ".");
}
}
private void writeMemorySpanGroup(RadarBias radarBias) throws Exception {
/*
* The memory span data from the RadarBias object to the RWBiasStat
* Record.
*/
RWBiasStatRecord record = null;
try {
RWBiasStatTable table = new RWBiasStatTable(_db);
record = getRecordFromMemorySpan(radarBias.getMemorySpanGroup());
table.insertOrUpdate(record);
} catch (SQLException e) {
System.out
.println("Could not insert/update record in RWBiasStat table.");
throw e;
}
}
private void writeBiasDynSet(RadarBias radarBias, Set radarIdSet)
throws Exception {
RWBiasDynRecord record = null;
List biasDynGroupList = radarBias.getBiasDynGroupList();
List biasDynSetList = null;
BiasDynSet biasDynSet = null;
BiasDynGroup biasDynGroup = null;
try {
RWBiasDynTable table = new RWBiasDynTable(_db);
/* Construct the obstime into the proper format. */
String obstimeYYYYMMDD = radarBias.getDateTime();
String obstimeSQL = obstimeYYYYMMDD
.substring(0, NUM_DIGITS_IN_YEAR)
+ "-"
+ obstimeYYYYMMDD.substring(NUM_DIGITS_IN_YEAR,
NUM_DIGITS_IN_YEAR + NUM_DIGITS_IN_MONTH)
+ "-"
+ obstimeYYYYMMDD.substring(NUM_DIGITS_IN_YEAR
+ NUM_DIGITS_IN_MONTH, NUM_DIGITS_IN_YEAR
+ NUM_DIGITS_IN_MONTH + NUM_DIGITS_IN_DAY)
+ " "
+ obstimeYYYYMMDD.substring(NUM_DIGITS_IN_YEAR
+ NUM_DIGITS_IN_MONTH + NUM_DIGITS_IN_DAY,
NUM_DIGITS_IN_YEAR + NUM_DIGITS_IN_MONTH
+ NUM_DIGITS_IN_DAY + NUM_DIGITS_IN_HOUR)
+ ":00:00";
// System.out.println("obstimeSQL:" + obstimeSQL);
for (int i = 0; i < biasDynGroupList.size(); ++i) {
biasDynGroup = (BiasDynGroup) biasDynGroupList.get(i);
/* Check if this BiasDyn group radar is in the radar map. */
if (radarIdSet.contains(biasDynGroup.getRadarId())) {
biasDynSetList = biasDynGroup.getBiasDynSetList();
for (int j = 0; j < biasDynSetList.size(); ++j) {
biasDynSet = (BiasDynSet) biasDynSetList.get(j);
record = getRecordFromBiasDynSet(biasDynGroup
.getRadarId(), obstimeSQL, biasDynSet);
table.insertOrUpdate(record);
}
} else {
System.out.println("Bias information from office " + _rfcId
+ " not stored for Radar "
+ biasDynGroup.getRadarId() + ".");
}
}
} catch (SQLException e) {
System.out.println("Could not insert/update the RWBiasDynTable.");
throw e;
}
}
private RWBiasStatRecord getRecordFromMemorySpan(
MemorySpanGroup memorySpanGroup) {
RWBiasStatRecord record = new RWBiasStatRecord();
record.setBias_qc_opt(memorySpanGroup.getBiasQcOpt());
record.setInit_span(memorySpanGroup.getInitSpan());
record.setLag_cut(memorySpanGroup.getLagCut());
record.setMem_span1(memorySpanGroup.getMemSpan1());
record.setMem_span2(memorySpanGroup.getMemSpan2());
record.setMem_span3(memorySpanGroup.getMemSpan3());
record.setMem_span4(memorySpanGroup.getMemSpan4());
record.setMem_span5(memorySpanGroup.getMemSpan5());
record.setMem_span6(memorySpanGroup.getMemSpan6());
record.setMem_span7(memorySpanGroup.getMemSpan7());
record.setMem_span8(memorySpanGroup.getMemSpan8());
record.setMem_span9(memorySpanGroup.getMemSpan9());
record.setMem_span10(memorySpanGroup.getMemSpan10());
record.setMin_gr_value_bias(memorySpanGroup.getMinGrValueBias());
record.setNpair_bias_select(memorySpanGroup.getNpairBiasSelect());
record.setNpair_svar_update(memorySpanGroup.getNpairSvarUpdate());
record.setNum_span(memorySpanGroup.getNumSpan());
record.setStd_cut(memorySpanGroup.getStdCut());
record.setOffice_id(_rfcId);
return record;
}
private RWBiasDynRecord getRecordFromBiasDynSet(String radarId,
String obstimeSQL, BiasDynSet biasDynSet) {
RWBiasDynRecord record = new RWBiasDynRecord();
record.setBias(biasDynSet.getMeanFieldBias());
record.setMemspan_ind(biasDynSet.getMemSpanIndex());
record.setNumpairs(biasDynSet.getGageRadarPairCount());
record.setObstime(DbTimeHelper
.getLongTimeFromDateTimeString(obstimeSQL));
record.setRadid(radarId);
record.setSumgag(biasDynSet.getSumOfGageValues());
record.setSumrad(biasDynSet.getSumOfRadarValues());
record.setOffice_id(_rfcId);
return record;
}
}

View file

@ -1,46 +0,0 @@
package ohd.hseb.bias_trans;
import java.util.List;
public class BiasDynGroup
{
private String _radarId;
private List _biasDynSetList;
public BiasDynGroup ( )
{
}
public void setRadarId(String radarId)
{
_radarId = radarId;
}
public String getRadarId()
{
return _radarId;
}
public void setBiasDynSetList(List biasDynSetList)
{
_biasDynSetList = biasDynSetList;
}
public List getBiasDynSetList()
{
return _biasDynSetList;
}
public String toString ()
{
StringBuffer outputBuffer = new StringBuffer ("_radarId = " + _radarId +"\n");
for ( int i = 0; i < _biasDynSetList.size(); ++i )
{
outputBuffer.append ( _biasDynSetList.get(i));
}
return outputBuffer.toString();
}
}

View file

@ -1,68 +0,0 @@
package ohd.hseb.bias_trans;
public class BiasDynSet
{
private short _memSpanIndex; /* usually 0 - 9. */
private double _gageRadarPairCount;
private float _sumOfGageValues;
private float _sumOfRadarValues;
private float _meanFieldBias;
public void setMemSpanIndex(short memSpanIndex)
{
_memSpanIndex = memSpanIndex;
}
public short getMemSpanIndex()
{
return _memSpanIndex;
}
public void setGageRadarPairCount(double numPairs)
{
_gageRadarPairCount = numPairs;
}
public double getGageRadarPairCount()
{
return _gageRadarPairCount;
}
public void setSumOfGageValues(float sumGag)
{
_sumOfGageValues = sumGag;
}
public float getSumOfGageValues()
{
return _sumOfGageValues;
}
public void setSumOfRadarValues(float sumRad)
{
_sumOfRadarValues = sumRad;
}
public float getSumOfRadarValues()
{
return _sumOfRadarValues;
}
public void setMeanFieldBias(float bias)
{
_meanFieldBias = bias;
}
public float getMeanFieldBias()
{
return _meanFieldBias;
}
public String toString ()
{
String output = "_memspanInd = " + _memSpanIndex + " _numPairs = " + _gageRadarPairCount + " " +
" _sumGag = " + _sumOfGageValues + " _sumRad = " + _sumOfRadarValues + " _bias = " + _meanFieldBias + "\n";
return output;
}
}

View file

@ -1,123 +0,0 @@
package ohd.hseb.bias_trans;
import ohd.hseb.db.DbTimeHelper;
import ohd.hseb.util.CodeTimer;
public class BiasMessageCreator
{
public static final String VERSION = "OB82";
public static final String RELEASE_DATE = "April 11, 2007";
public static final String PROGRAM_NAME = "BiasMessageCreator";
private static final String _usage = "Usage: " + PROGRAM_NAME +
" <database_name> <YYYYMMDDHH>";
private BiasDataMgr _dataMgr = null;
private String _dateTime; // YYYYMMDDHH
private String _jdbcUrl;
// -----------------------------------------------------------------------------------------------------
public BiasMessageCreator ( String[] args ) throws Exception
{
getBiasArguments ( args );
// Create the data manager
setDataMgr( new BiasDataMgr ( _jdbcUrl ));
}
// -----------------------------------------------------------------------------------------------------
private void getBiasArguments ( String args [ ]) throws Exception
{
boolean failed = false;
int datetimeAsInteger;
if ( args.length != 2)
{
failed = true;
}
else
{
// Process the database name supplied as the first argument.
_jdbcUrl = args[0];
_dateTime = args[1];
// Make sure the time string is the correct length.
if ( _dateTime.length() != RfcBiasConstants.DATEHOUR_LENGTH )
{
failed = true;
}
// Make sure the time string is an integer.
try
{
datetimeAsInteger = Integer.parseInt(_dateTime);
}
catch ( NumberFormatException e)
{
failed = true;
}
}
if ( failed )
{
throw new Exception (_usage);
}
}
// -----------------------------------------------------------------------------------------------------
private void setDataMgr(BiasDataMgr dataMgr)
{
_dataMgr = dataMgr;
}
// -----------------------------------------------------------------------------------------------------
private BiasDataMgr getDataMgr()
{
return _dataMgr;
}
// -----------------------------------------------------------------------------------------------------
public void process () throws Exception
{
RadarBias radarBias = _dataMgr.getRadarBias( _dateTime );
System.out.println ("Bias Message Retrieved.\n" + radarBias );
_dataMgr.writeRadarBiasToFile ( radarBias, _dateTime );
}
// -----------------------------------------------------------------------------------------------------
/**
* @param args
*/
public static void main(String[] args)
{
long startingTime = System.currentTimeMillis();
String startingTimeString = DbTimeHelper.getDateTimeStringFromLongTime(startingTime);
System.out.println("The Starting Time is: " + startingTimeString);
try
{
CodeTimer codeTimer = new CodeTimer();
codeTimer.start();
BiasMessageCreator messageCreator = new BiasMessageCreator( args);
System.out.println("Starting Program " + PROGRAM_NAME );
System.out.println("Version: " + VERSION + " Release Date: " +
RELEASE_DATE );
messageCreator.process();
codeTimer.stop("Create_rfc_bias_message completed in ");
}
catch ( Exception e)
{
System.out.println (e.getMessage());
System.out.println (e.getStackTrace());
}
}
}

View file

@ -1,106 +0,0 @@
package ohd.hseb.bias_trans;
import java.io.File;
import ohd.hseb.db.DbTimeHelper;
import ohd.hseb.util.CodeTimer;
public class BiasMessageReader
{
private static final String VERSION = "OB82";
private static final String RELEASE_DATE = "April 11, 2007";
private static final String PROGRAM_NAME = "BiasMessageReader";
private static final String _usage = "Usage: " + PROGRAM_NAME +
" <database_name> <filepath>";
private BiasDataMgr _dataMgr = null;
private String _jdbcUrl = null;
private File _filePath = null;
public BiasMessageReader ( String[] args, String PROGRAM_NAME ) throws Exception
{
getBiasArguments ( args, PROGRAM_NAME);
// Create the data manager
setDataMgr( new BiasDataMgr ( _jdbcUrl ));
}
/**
* @param args
*/
private void getBiasArguments ( String args [ ], final String program_name ) throws Exception
{
boolean failed = false;
if (args.length != 2)
{
failed = true;
}
else
{
// Process the database name supplied via the -d argument.
_jdbcUrl = args[0];
// Process the filename/path supplied via the -f argument.
_filePath = new File ( args[1] );
System.out.println ("File path for file reader = " + _filePath);
}
if ( failed )
{
throw new Exception (_usage);
}
}
public void process ( ) throws Exception
{
RadarBias radarBias = _dataMgr.readRadarBiasFromFile ( _filePath );
System.out.println ("Bias Message Retrieved.\n" + radarBias );
_dataMgr.writeRadarBiasToDatabase ( radarBias );
}
public static void main(String[] args)
{
long startingTime = System.currentTimeMillis();
String startingTimeString = DbTimeHelper.getDateTimeStringFromLongTime(startingTime);
System.out.println("The Starting Time is: " + startingTimeString);
try
{
CodeTimer codeTimer = new CodeTimer();
codeTimer.start();
BiasMessageReader messageReader = new BiasMessageReader( args, PROGRAM_NAME);
System.out.println("Starting Program " + PROGRAM_NAME );
System.out.println("Version: " + VERSION + " Release Date: " +
RELEASE_DATE );
messageReader.process();
codeTimer.stop("process_rfc_bias_message completed in ");
}
catch ( Exception e)
{
System.out.println (e.getMessage());
System.out.println (e.getStackTrace());
}
}
public void setDataMgr(BiasDataMgr dataMgr)
{
_dataMgr = dataMgr;
}
public BiasDataMgr getDataMgr()
{
return _dataMgr;
}
}

View file

@ -1,224 +0,0 @@
package ohd.hseb.bias_trans;
public class MemorySpanGroup
{
private float _minGrValueBias;
private int _npairBiasSelect;
private int _npairSvarUpdate;
private int _stdCut;
private int _lagCut;
private int _initSpan;
private int _biasQcOpt;
private int _numSpan;
private float _memSpan1;
private float _memSpan2;
private float _memSpan3;
private float _memSpan4;
private float _memSpan5;
private float _memSpan6;
private float _memSpan7;
private float _memSpan8;
private float _memSpan9;
private float _memSpan10;
public MemorySpanGroup ( )
{
}
public void setMinGrValueBias(float minGrValueBias)
{
this._minGrValueBias = minGrValueBias;
}
public float getMinGrValueBias()
{
return _minGrValueBias;
}
public void setNpairBiasSelect(int npairBiasSelect)
{
this._npairBiasSelect = npairBiasSelect;
}
public int getNpairBiasSelect()
{
return _npairBiasSelect;
}
public void setNpairSvarUpdate(int npairSvarUpdate)
{
this._npairSvarUpdate = npairSvarUpdate;
}
public int getNpairSvarUpdate()
{
return _npairSvarUpdate;
}
public void setStdCut(int stdCut)
{
this._stdCut = stdCut;
}
public int getStdCut()
{
return _stdCut;
}
public void setLagCut(int lagCut)
{
this._lagCut = lagCut;
}
public int getLagCut()
{
return _lagCut;
}
public void setInitSpan(int initSpan)
{
this._initSpan = initSpan;
}
public int getInitSpan()
{
return _initSpan;
}
public void setBiasQcOpt(int biasQcOpt)
{
this._biasQcOpt = biasQcOpt;
}
public int getBiasQcOpt()
{
return _biasQcOpt;
}
public void setNumSpan(int numSpan)
{
this._numSpan = numSpan;
}
public int getNumSpan()
{
return _numSpan;
}
public void setMemSpan1(float memSpan1)
{
this._memSpan1 = memSpan1;
}
public float getMemSpan1()
{
return _memSpan1;
}
public void setMemSpan2(float memSpan2)
{
this._memSpan2 = memSpan2;
}
public float getMemSpan2()
{
return _memSpan2;
}
public void setMemSpan3(float memSpan3)
{
this._memSpan3 = memSpan3;
}
public float getMemSpan3()
{
return _memSpan3;
}
public void setMemSpan4(float memSpan4)
{
this._memSpan4 = memSpan4;
}
public float getMemSpan4()
{
return _memSpan4;
}
public void setMemSpan5(float memSpan5)
{
this._memSpan5 = memSpan5;
}
public float getMemSpan5()
{
return _memSpan5;
}
public void setMemSpan6(float memSpan6)
{
this._memSpan6 = memSpan6;
}
public float getMemSpan6()
{
return _memSpan6;
}
public void setMemSpan7(float memSpan7)
{
this._memSpan7 = memSpan7;
}
public float getMemSpan7()
{
return _memSpan7;
}
public void setMemSpan8(float memSpan8)
{
this._memSpan8 = memSpan8;
}
public float getMemSpan8()
{
return _memSpan8;
}
public void setMemSpan9(float memSpan9)
{
this._memSpan9 = memSpan9;
}
public float getMemSpan9()
{
return _memSpan9;
}
public void setMemSpan10(float memSpan10)
{
this._memSpan10 = memSpan10;
}
public float getMemSpan10()
{
return _memSpan10;
}
public String toString ( )
{
String output;
output = "Memory Span Info:\n";
output += "_minGrValueBias = " + _minGrValueBias + "\n" + "_npairBiasSelect = " + _npairBiasSelect +"\n";
output += "_npairSvarUpdate = " + _npairSvarUpdate + "\n" + "_stdCut = " + _stdCut + "\n";
output += "_lagCut = " + _lagCut + "\n" + "_initSpan = " + _initSpan + "\n";
output += "_biasQcOpt = " + _biasQcOpt + "\n" + "_numSpan = " + _numSpan + "\n";
output += "_memSpan1 = " + _memSpan1 + "\n" + "_memSpan2 = " + _memSpan2 + "\n";
output += "_memSpan3 = " + _memSpan3 + "\n" + "_memSpan4 = " + _memSpan4 + "\n";
output += "_memSpan5 = " + _memSpan5 + "\n" + "_memSpan6 = " + _memSpan6 + "\n";
output += "_memSpan7 = " + _memSpan7 + "\n" + "_memSpan8 = " + _memSpan8 + "\n";
output += "_memSpan9 = " + _memSpan9 + "\n" + "_memSpan10 = " + _memSpan10 + "\n";
return output;
}
}

View file

@ -1,53 +0,0 @@
package ohd.hseb.bias_trans;
import java.util.List;
public class RadarBias
{
private String _dateTime;
private MemorySpanGroup _memorySpanGroup;
private List _biasDynGroupList;
public void setMemorySpanGroup(MemorySpanGroup memorySpanGroup)
{
_memorySpanGroup = memorySpanGroup;
}
public MemorySpanGroup getMemorySpanGroup()
{
return _memorySpanGroup;
}
public void setBiasDynGroupList(List biasDynGroupList)
{
_biasDynGroupList = biasDynGroupList;
}
public List getBiasDynGroupList()
{
return _biasDynGroupList;
}
public String toString ()
{
String output ="Radar Bias Info: " + "\nDate:" + _dateTime +"\n" + _memorySpanGroup;
for ( int i = 0; i < _biasDynGroupList.size(); ++i )
{
output += _biasDynGroupList.get(i);
}
return output;
}
public void setDateTime(String dateTime)
{
_dateTime = dateTime;
}
public String getDateTime()
{
return _dateTime;
}
}

View file

@ -1,10 +0,0 @@
package ohd.hseb.bias_trans;
public interface RfcBiasConstants
{
public final int DATEHOUR_LENGTH = 10;
public final int NUM_DIGITS_IN_YEAR = 4;
public final int NUM_DIGITS_IN_MONTH = 2;
public final int NUM_DIGITS_IN_DAY = 2;
public final int NUM_DIGITS_IN_HOUR = 2;
}

View file

@ -1,33 +0,0 @@
package ohd.hseb.bias_trans;
public class RfcBiasMessage implements RfcBiasConstants
{
public RfcBiasMessage ( )
{
}
int write_bias_message ( BiasDataMgr dataMgr )
{
write_bias_message_header ( dataMgr );
// Retrieve the list of radars to get bias information for.
write_bias_message_header ( dataMgr );
write_bias_message_body ( dataMgr );
return 0;
}
private int write_bias_message_header ( BiasDataMgr dataMgr )
{
return 0;
}
private int write_bias_message_body ( BiasDataMgr dataMgr )
{
return 0;
}
}

View file

@ -1,593 +0,0 @@
package ohd.hseb.color_chooser;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeSet;
import ohd.hseb.db.Database;
import ohd.hseb.ihfsdb.generated.ColorNameRecord;
import ohd.hseb.ihfsdb.generated.ColorNameTable;
import ohd.hseb.ihfsdb.generated.ColorValueRecord;
import ohd.hseb.ihfsdb.generated.ColorValueTable;
import ohd.hseb.util.CodeTimer;
import ohd.hseb.util.Logger;
import ohd.hseb.util.StringParser;
import com.raytheon.uf.common.ohd.AppsDefaults;
public class ColorChooserDialogDataMgr {
private Database _db = null;
private Logger _logger = null;
private String _applicationName = null;
private List _defaultColorScaleValueSetList = new ArrayList();
private List _colorValueTableColorScaleValueSetList = new ArrayList();
private HashMap _rgbColorMap = new HashMap();
private HashMap _hardCodedColorUseToDatabaseColorUseMap = new HashMap();
private String _userID = null;
private String _defaultColorFilePath = null;
private String _rgbColorFilePath = null;
public ColorChooserDialogDataMgr(String baseConnectionString,
Logger logger, String applicationName, String defaultColorFilePath,
String rgbColorFilePath) {
super();
_db = new Database();
_logger = logger;
_applicationName = applicationName;
_defaultColorFilePath = defaultColorFilePath;
_rgbColorFilePath = rgbColorFilePath;
_db.connectWithDriverSearch(baseConnectionString);
readRGBTextFile();
readHydroViewDefaultColorFile();
readColorValuesFromDatabase();
// testRgbTextVersusColorNameTable();
}
public String getHardCodedColorUse(String colorUse) {
return (String) _hardCodedColorUseToDatabaseColorUseMap.get(colorUse);
}
public void disconnect() {
_db.disconnect();
}
// ------------------------------------------------------------------------
@Override
public void finalize() {
disconnect();
}
public void readColorValuesFromDatabase() {
ColorValueTable table = new ColorValueTable(_db);
ColorValue colorValue = new ColorValue();
int i = 0;
/*
* String whereClause = "WHERE application_name='" + _applicationName +
* "' AND userid != 'default' " +
* "AND userid != 'factory_default' ORDER BY color_use_name, userid, duration, "
* + "threshold_value";
*/
String whereClause = "WHERE application_name='" + _applicationName
+ "' AND userid != 'factory_default' "
+ "ORDER BY color_use_name, userid, duration, threshold_value";
List colorValueRecordsList = null;
ColorScaleValueSet colorScaleValueSet = new ColorScaleValueSet();
ColorSet colorSet = null;
// Color colorObject = null;
ScaleValueSet scaleValueSet = null;
// double scaleValue = 0;
String currentIndexString = null, prevIndexString = null;
CodeTimer timer = new CodeTimer();
timer.start();
CodeTimer timer2 = new CodeTimer();
String colorUseString = null;
try {
colorValueRecordsList = table.select(whereClause);
} catch (SQLException e) {
e.printStackTrace();
}
timer.stop("Finished reading the ColorValue table in ");
timer2.start();
for (i = 0; i < colorValueRecordsList.size(); i++) {
colorValue = getColorValueFromColorValueRecord((ColorValueRecord) colorValueRecordsList
.get(i));
if (i == 0) {
prevIndexString = getColorValueKeyString(colorValue);
scaleValueSet = new ScaleValueSet();
colorSet = new ColorSet();
scaleValueSet.addScaleValue(colorValue.getThresholdValue());
colorSet.addNamedColor(getNamedColorByName(colorValue
.getColorName()));
colorUseString = (String) _hardCodedColorUseToDatabaseColorUseMap
.get(colorValue.getColorUseName());
if (colorUseString != null) {
colorScaleValueSet.setColorUseString(colorUseString);
} else {
colorScaleValueSet.setColorUseString(colorValue
.getColorUseName());
}
colorScaleValueSet.setDuration(colorValue.getDuration());
colorScaleValueSet.setUserID(colorValue.getUserID());
} else if (i == (colorValueRecordsList.size() - 1)) // Last entry in
// the records
// list
{
scaleValueSet.addScaleValue(colorValue.getThresholdValue());
colorSet.addNamedColor(getNamedColorByName(colorValue
.getColorName()));
colorScaleValueSet.setColorSet(colorSet);
colorScaleValueSet.setScaleValueSet(scaleValueSet);
_colorValueTableColorScaleValueSetList.add(colorScaleValueSet);
} else {
currentIndexString = getColorValueKeyString(colorValue);
if (currentIndexString.equalsIgnoreCase(prevIndexString)) // same
// index
{
scaleValueSet.addScaleValue(colorValue.getThresholdValue());
colorSet.addNamedColor(getNamedColorByName(colorValue
.getColorName()));
} else // new index
{
colorScaleValueSet.setColorSet(colorSet);
colorScaleValueSet.setScaleValueSet(scaleValueSet);
_colorValueTableColorScaleValueSetList
.add(colorScaleValueSet);
prevIndexString = currentIndexString;
scaleValueSet = new ScaleValueSet();
colorSet = new ColorSet();
colorScaleValueSet = new ColorScaleValueSet();
scaleValueSet.addScaleValue(colorValue.getThresholdValue());
colorSet.addNamedColor(getNamedColorByName(colorValue
.getColorName()));
colorUseString = (String) _hardCodedColorUseToDatabaseColorUseMap
.get(colorValue.getColorUseName());
if (colorUseString != null) {
colorScaleValueSet.setColorUseString(colorUseString);
} else {
colorScaleValueSet.setColorUseString(colorValue
.getColorUseName());
}
colorScaleValueSet.setDuration(colorValue.getDuration());
colorScaleValueSet.setUserID(colorValue.getUserID());
}
}
}
timer2.stop("Finished processing the ColorValue table in ");
}
private NamedColor getNamedColorByName(String colorName) {
NamedColor namedColor = (NamedColor) getRGBColorMap().get(colorName);
return namedColor;
}
private String getColorValueKeyString(ColorValue colorValue) {
return colorValue.getUserID() + "|" + colorValue.getColorUseName()
+ "|" + colorValue.getDuration();
}
private ColorValue getColorValueFromColorValueRecord(ColorValueRecord record) {
ColorValue colorValue = new ColorValue();
colorValue.setApplicationName(record.getApplication_name());
colorValue.setColorName(record.getColor_name());
colorValue.setColorUseName(record.getColor_use_name());
colorValue.setDuration((double) record.getDuration() / (double) 3600);
colorValue.setThresholdUnit(record.getThreshold_unit());
colorValue.setThresholdValue(record.getThreshold_value());
colorValue.setUserID(record.getUserid());
return colorValue;
}
private void saveColorScaleValueSet(List colorValueRecordList,
String userID, String colorUseString, double duration) {
ColorValueTable table = new ColorValueTable(_db);
int durationSecondsInt = (int) (duration * 3600);
String whereClause = "WHERE userID='" + userID
+ "' AND application_name='" + _applicationName + "' AND "
+ "color_use_name='" + colorUseString + "' AND duration="
+ durationSecondsInt;
System.out.println(whereClause);
try {
table.delete(whereClause);
for (int i = 0; i < colorValueRecordList.size(); i++) {
ColorValueRecord record = (ColorValueRecord) colorValueRecordList
.get(i);
table.insert(record);
}
} catch (SQLException e) {
e.printStackTrace();
}
resetHvDefaultColorList();
resetColorValueTableColorScaleValueSetList();
}
public void saveAsOffice(ColorScaleValueSet colorScaleValueSet) {
List colorValueRecordList = getColorValueRecordListFromColorScaleValueSet(
colorScaleValueSet, "default");
String colorUseString = (String) _hardCodedColorUseToDatabaseColorUseMap
.get(colorScaleValueSet.getColorUseString());
if (colorUseString == null) // Checking to see if the color Use is in
// the hash map. If not, use the original
// name.
{
colorUseString = colorScaleValueSet.getColorUseString();
}
saveColorScaleValueSet(colorValueRecordList, "default", colorUseString,
colorScaleValueSet.getDuration());
}
public void saveAsUser(ColorScaleValueSet colorScaleValueSet,
double duration) {
List colorValueRecordList = getColorValueRecordListFromColorScaleValueSet(
colorScaleValueSet, _userID);
String colorUseString = (String) _hardCodedColorUseToDatabaseColorUseMap
.get(colorScaleValueSet.getColorUseString());
if (colorUseString == null) // Checking to see if the color Use is in
// the hash map. If not, use the original
// name.
{
colorUseString = colorScaleValueSet.getColorUseString();
}
saveColorScaleValueSet(colorValueRecordList, _userID, colorUseString,
duration);
}
public void deleteAsUser(ColorScaleValueSet colorScaleValueSet) {
List colorValueRecordList = getColorValueRecordListFromColorScaleValueSet(
colorScaleValueSet, _userID);
String colorUseString = (String) _hardCodedColorUseToDatabaseColorUseMap
.get(colorScaleValueSet.getColorUseString());
if (colorUseString == null) {
colorUseString = colorScaleValueSet.getColorUseString();
}
deleteColorScaleValueSet(colorValueRecordList, _userID, colorUseString,
colorScaleValueSet.getDuration());
}
public void deleteAsOffice(ColorScaleValueSet colorScaleValueSet) {
List colorValueRecordList = getColorValueRecordListFromColorScaleValueSet(
colorScaleValueSet, "default");
String colorUseString = (String) _hardCodedColorUseToDatabaseColorUseMap
.get(colorScaleValueSet.getColorUseString());
if (colorUseString == null) {
colorUseString = colorScaleValueSet.getColorUseString();
}
deleteColorScaleValueSet(colorValueRecordList, "default",
colorUseString, colorScaleValueSet.getDuration());
}
private void deleteColorScaleValueSet(List colorValueRecordList,
String userID, String colorUseString, double duration) {
ColorValueTable table = new ColorValueTable(_db);
String whereClause = "WHERE userID='" + userID
+ "' AND application_name='" + _applicationName + "' AND "
+ "color_use_name='" + colorUseString + "' AND duration="
+ duration * 3600;
try {
table.delete(whereClause);
} catch (SQLException e) {
e.printStackTrace();
}
resetHvDefaultColorList();
resetColorValueTableColorScaleValueSetList();
}
private List getColorValueRecordListFromColorScaleValueSet(
ColorScaleValueSet colorScaleValueSet, String userID) {
List colorValueRecordList = new ArrayList();
ColorValueRecord record = new ColorValueRecord();
ColorSet colorSet = colorScaleValueSet.getColorSet();
List colorSetList = colorSet.getNamedColorList();
List scaleValueSetList = colorScaleValueSet.getScaleValueSet()
.getScaleValueSet();
String colorUseString = null;
record.setApplication_name(_applicationName);
colorUseString = (String) _hardCodedColorUseToDatabaseColorUseMap
.get(colorScaleValueSet.getColorUseString());
if (colorUseString == null) // Checking to see if the color Use is in
// the hash map. If not, use the original
// name.
{
colorUseString = colorScaleValueSet.getColorUseString();
}
record.setColor_use_name(colorUseString);
record.setDuration((int) (colorScaleValueSet.getDuration() * 3600));
record.setUserid(userID);
record.setThreshold_unit("E");
for (int i = 0; i < scaleValueSetList.size(); i++) {
double scaleValue = (Double) scaleValueSetList.get(i);
NamedColor namedColor = (NamedColor) colorSetList.get(i);
record.setThreshold_value(scaleValue);
record.setColor_name(namedColor.getName());
colorValueRecordList.add(record);
record = new ColorValueRecord(record);
}
return colorValueRecordList;
}
public void setUserID(String userID) {
_userID = userID;
}
private Set getColorNameTableSet() {
Set colorNameSet = new HashSet();
ColorNameTable table = new ColorNameTable(_db);
try {
List<ColorNameRecord> recordList = table.select("");
for (ColorNameRecord record : recordList) {
colorNameSet.add(record.getColor_name());
}
} catch (SQLException e) {
e.printStackTrace();
}
return colorNameSet;
}
public void readRGBTextFile() {
File rgbColorFile = null;
BufferedReader reader = null;
String line = null;
String[] tokenizedString = null;
String colorName = null;
Set nameFromColorNameTableSet = getColorNameTableSet();
rgbColorFile = new File(_rgbColorFilePath);
try {
reader = new BufferedReader(new FileReader(rgbColorFile));
line = reader.readLine(); // discard the first line
line = reader.readLine();
while (line != null) {
tokenizedString = StringParser.tokenize(line);
colorName = getRGBColorName(tokenizedString);
// if the read in RGB color name exists in the ColorName table,
// then add to the _rgbColorMap
if (nameFromColorNameTableSet.contains(colorName.toUpperCase())) {
NamedColor namedColor = new NamedColor(colorName, Integer
.parseInt(tokenizedString[0]), Integer
.parseInt(tokenizedString[1]), Integer
.parseInt(tokenizedString[2]));
_rgbColorMap.put(colorName.toUpperCase(), namedColor);
}
line = reader.readLine();
}
} catch (IOException e) {
e.printStackTrace();
}
}
private String getRGBColorName(String[] tokenizedName) {
StringBuffer rgbColorName = new StringBuffer();
for (int i = 3; i < tokenizedName.length; i++) {
rgbColorName.append(tokenizedName[i]);
if (i != (tokenizedName.length - 1)) {
rgbColorName.append(" ");
}
}
return rgbColorName.toString();
}
public void readHydroViewDefaultColorFile() {
// String hydroviewDefaultColorFileName = null;
AppsDefaults appsDefaults = AppsDefaults.getInstance();
File hydroviewDefaultColorFile = null;
BufferedReader reader = null;
String line = null;
String colorSetString = null;
String colorUseString = null;
String colorString = null;
String databaseColorUseString = null;
float scaleValue = 0;
NamedColor namedColor = null;
String[] tokenizedString = null;
ColorScaleValueSet colorScaleValueSet = null;
ColorSet colorSet = new ColorSet();
ScaleValueSet scaleValueSet = new ScaleValueSet();
hydroviewDefaultColorFile = new File(_defaultColorFilePath);
try {
reader = new BufferedReader(new FileReader(
hydroviewDefaultColorFile));
line = reader.readLine();
while (line != null) {
if (line.trim().length() > 0) // not an empty line
{
tokenizedString = StringParser.tokenize(line);
if (line.indexOf("|") == -1) {
colorString = tokenizedString[0];
namedColor = getNamedColorByName(colorString);
scaleValue = Float.valueOf(tokenizedString[1]);
colorSet.addNamedColor(namedColor);
scaleValueSet.addScaleValue(scaleValue);
} else // line read in is the color set name (first line of
// each set)
{
colorScaleValueSet = new ColorScaleValueSet();
StringTokenizer tokenizer = new StringTokenizer(line,
"|");
colorUseString = tokenizer.nextToken();
databaseColorUseString = tokenizer.nextToken();
insertColorUseStringIntoHashMap(colorUseString,
databaseColorUseString);
colorScaleValueSet.setColorUseString(colorUseString);
}
} else // empty line
{
colorScaleValueSet.setColorSet(colorSet);
colorScaleValueSet.setScaleValueSet(scaleValueSet);
colorScaleValueSet.setUserID("HARDCODED");
colorScaleValueSet.setDuration(0);
_defaultColorScaleValueSetList.add(colorScaleValueSet);
colorSet = new ColorSet();
scaleValueSet = new ScaleValueSet();
}
line = reader.readLine();
}
} catch (IOException e) {
e.printStackTrace();
}
}
private void testRgbTextVersusColorNameTable() {
ColorNameTable table = new ColorNameTable(_db);
List extraCrapList = new ArrayList();
Set rgbHashSet = new TreeSet(_rgbColorMap.keySet());
List rgbList = new ArrayList(_rgbColorMap.keySet());
String colorName = null;
try {
List recordList = table.select("");
Set recordSet = new TreeSet();
for (int i = 0; i < recordList.size(); i++) {
ColorNameRecord record = (ColorNameRecord) recordList.get(i);
colorName = record.getColor_name();
recordSet.add(getStringWithoutSpaces(colorName));
if (!rgbHashSet.contains(colorName)) {
extraCrapList.add(colorName);
System.out
.println(colorName
+ " is not in the RGB text file but is in the database");
}
}
for (int i = 0; i < rgbList.size(); i++) {
String rgbColorName = getStringWithoutSpaces((String) rgbList
.get(i));
if (!recordSet.contains(rgbColorName)) {
extraCrapList.add(rgbColorName);
System.out
.println(rgbColorName
+ " is not in the database but is in the RGB text file");
}
}
System.out.println("DONE");
} catch (SQLException e) {
e.printStackTrace();
}
}
private String getStringWithoutSpaces(String colorName) {
StringBuffer buffer = new StringBuffer();
for (int i = 0; i < colorName.length(); i++) {
char c = colorName.charAt(i);
if (c != ' ') {
buffer.append(c);
}
}
return buffer.toString();
}
private void insertColorUseStringIntoHashMap(String colorUseString,
String databaseColorUseString) {
_hardCodedColorUseToDatabaseColorUseMap.put(colorUseString,
databaseColorUseString);
_hardCodedColorUseToDatabaseColorUseMap.put(databaseColorUseString,
colorUseString);
}
public List getDefaultColorScaleValueSetList() {
return _defaultColorScaleValueSetList;
}
public void setApplicationName(String _applicationName) {
this._applicationName = _applicationName;
}
public String getApplicationName() {
return _applicationName;
}
public List getColorValueTableColorScaleValueSetList() {
return _colorValueTableColorScaleValueSetList;
}
public void addColorScaleValueSetToColorValueTableList(
ColorScaleValueSet colorScaleValueSet) {
_colorValueTableColorScaleValueSetList.add(colorScaleValueSet);
}
public void resetColorValueTableColorScaleValueSetList() {
_colorValueTableColorScaleValueSetList = new ArrayList();
readColorValuesFromDatabase();
}
public void resetHvDefaultColorList() {
_defaultColorScaleValueSetList = new ArrayList();
readHydroViewDefaultColorFile();
}
public HashMap getRGBColorMap() {
return _rgbColorMap;
}
}

View file

@ -1,25 +0,0 @@
package ohd.hseb.color_chooser;
import java.awt.Color;
public class ColorHolder
{
private Color _color = null;
public ColorHolder( Color color )
{
setColor(color);
}
public void setColor(Color color)
{
_color = color;
}
public Color getColor()
{
return _color;
}
}

View file

@ -1,188 +0,0 @@
package ohd.hseb.color_chooser;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JButton;
import javax.swing.JColorChooser;
import javax.swing.JDialog;
import javax.swing.JPanel;
import ohd.hseb.util.gui.ComponentHelper;
public class ColorPickerDialog extends JDialog
{
private ColorHolder _colorHolder = null;
// private ColorSet _colorSet = null;
// private int _indexValueOfDefaultColor = 0;
private Container _frameContentPane = getContentPane();
private JPanel _colorDialogPanel = new JPanel();
private JColorChooser _jColorChooserDialog = new JColorChooser();
private JPanel _buttonPanel = new JPanel();
private JButton _okButton = new JButton( "OK" );
private JButton _cancelButton = new JButton( "Cancel" );
/*
public ColorPickerDialog( Frame owner, Color color, ColorSet colorSet )
{
super( owner, "Color Picker", true );
_frameContentPane.setLayout( new GridBagLayout() );
_colorDialogPanel.setLayout( new GridBagLayout() );
_jColorChooserDialog.setColor( color );
ComponentHelper.addFrameComponent( _frameContentPane, _colorDialogPanel, 1, 1, 1, 1, GridBagConstraints.BOTH );
ComponentHelper.addPanelComponent( _colorDialogPanel, _jColorChooserDialog, 1, 1, 1, 1, GridBagConstraints.BOTH );
setSize( 400, 600 );
}
*/
/*
public ColorPickerDialog( JDialog owner, Color color, ColorSet colorSet )
{
super( owner, "Color Picker", true );
_colorSet = colorSet;
_defaultColor = color;
initGUI();
_indexValueOfDefaultColor = getIndexOfDefaultColorFromColorSet();
addListeners();
}
*/
public ColorPickerDialog( JDialog owner, ColorHolder colorHolder )
{
super( owner, "Color Picker", true );
_colorHolder = colorHolder;
initGUI();
// _indexValueOfDefaultColor = getIndexOfDefaultColorFromColorSet();
addListeners();
}
private void initGUI()
{
_frameContentPane.setLayout( new GridBagLayout() );
_colorDialogPanel.setLayout( new GridBagLayout() );
_buttonPanel.setLayout( new GridBagLayout() );
_jColorChooserDialog.setColor( _colorHolder.getColor() );
setSize( 430, 400 );
_buttonPanel.setPreferredSize( new Dimension( 30, 40 ) );
// X, Y, #Col, #Row
ComponentHelper.addFrameComponent( _frameContentPane, _colorDialogPanel, 1, 1, 1, 1, GridBagConstraints.BOTH );
ComponentHelper.addFrameComponent( _frameContentPane, _buttonPanel, 1, 2, 1, 3, GridBagConstraints.BOTH );
ComponentHelper.addPanelComponent( _colorDialogPanel, _jColorChooserDialog, 1, 1, 1, 1, GridBagConstraints.BOTH );
ComponentHelper.addPanelComponent( _buttonPanel, _okButton, 1, 1, 1, 1, GridBagConstraints.BOTH );
ComponentHelper.addPanelComponent( _buttonPanel, _cancelButton, 2, 1, 1, 1, GridBagConstraints.BOTH );
}
private void addListeners()
{
WindowCloserListener windowCloser = new WindowCloserListener();
_okButton.addActionListener( new OkButtonListener() );
_cancelButton.addActionListener( windowCloser );
}
private class WindowCloserListener extends WindowAdapter implements ActionListener
{
public void windowClosing ( WindowEvent e )
{
closeWindow();
}
public void actionPerformed( ActionEvent e )
{
closeWindow();
}
}
/*
private int getIndexOfDefaultColorFromColorSet()
{
List colorList = _colorSet.getNamedColorList();
Color extractedColor = null;
int index = -1;
for ( int i = 0; i < colorList.size(); i++ )
{
extractedColor = (Color) colorList.get( i );
if ( extractedColor.equals( _defaultColor ) )
{
index = i;
}
}
return index;
}
*/
private class OkButtonListener implements ActionListener
{
public void actionPerformed( ActionEvent e )
{
_colorHolder.setColor( _jColorChooserDialog.getColor() );
// ColorPickerDialog.this.setVisible( false );
closeWindow();
}
}
/*
private class OkButtonListener implements ActionListener
{
public void actionPerformed( ActionEvent e )
{
List colorSetList = _colorSet.getNamedColorList();
Color colorObject = null;
colorSetList.set( _indexValueOfDefaultColor, _jColorChooserDialog.getColor() );
closeWindow();
}
}
private class OkButtonListener implements ActionListener
{
public void actionPerformed( ActionEvent e )
{
List colorSetList = _colorSet.getNamedColorList();
Color colorObject = null;
colorSetList.set( _indexValueOfDefaultColor, _jColorChooserDialog.getColor() );
closeWindow();
}
}
*/
private void closeWindow()
/********************
Purpose: Exit's the program gracefully
*********************/
{
this.dispose();
}
public static void main ( String[] args )
{
// ColorPickerDialog colorPicker = new ColorPickerDialog( new Frame(), Color.blue, true );
// colorPicker.setVisible( true );
}
}

View file

@ -1,100 +0,0 @@
package ohd.hseb.color_chooser;
public class ColorScaleValueSet
{
private ColorSet _colorSet = null;
private ScaleValueSet _scaleValueSet = null;
private String _colorUseString = null;
private double _duration = -99999;
private String _userID = null;
public ColorScaleValueSet()
{
}
public ColorScaleValueSet( ColorScaleValueSet colorScaleValueSet )
{
setColorSet( new ColorSet( colorScaleValueSet.getColorSet() ) );
setScaleValueSet( new ScaleValueSet( colorScaleValueSet.getScaleValueSet() ) );
setColorUseString( new String( colorScaleValueSet.getColorUseString() ) );
setUserID( new String( colorScaleValueSet.getUserID() ) );
setDuration( colorScaleValueSet.getDuration() );
/*
setColorSet( colorScaleValueSet.getColorSet() );
setScaleValueSet( colorScaleValueSet.getScaleValueSet() );
setColorUseString( colorScaleValueSet.getColorUseString() );
setUserID( colorScaleValueSet.getUserID() );
setDuration( colorScaleValueSet.getDuration() );
*/
}
public static ColorScaleValueSet getCopyOfColorScaleValueSet( ColorScaleValueSet colorScaleValueSet )
{
ColorScaleValueSet returnColorScaleValueSet = new ColorScaleValueSet();
returnColorScaleValueSet.setColorSet( new ColorSet( colorScaleValueSet.getColorSet() ) );
returnColorScaleValueSet.setScaleValueSet( new ScaleValueSet( colorScaleValueSet.getScaleValueSet() ) );
returnColorScaleValueSet.setColorUseString( new String( colorScaleValueSet.getColorUseString() ) );
returnColorScaleValueSet.setUserID( new String( colorScaleValueSet.getUserID() ) );
returnColorScaleValueSet.setDuration( colorScaleValueSet.getDuration() );
return returnColorScaleValueSet;
}
public String toString()
{
return _userID + " " + _colorUseString + " " + _duration + "\n" + _colorSet;
}
public void setColorSet( ColorSet colorSet )
{
_colorSet = colorSet;
}
public ColorSet getColorSet()
{
return _colorSet;
}
public void setScaleValueSet(ScaleValueSet scaleValueSet)
{
_scaleValueSet = scaleValueSet;
}
public ScaleValueSet getScaleValueSet()
{
return _scaleValueSet;
}
public void setColorUseString(String colorUseString)
{
_colorUseString = colorUseString;
}
public String getColorUseString()
{
return _colorUseString;
}
public void setDuration( double duration )
{
_duration = duration;
}
public double getDuration()
{
return _duration;
}
public void setUserID( String userID )
{
_userID = userID;
}
public String getUserID()
{
return _userID;
}
}

View file

@ -1,72 +0,0 @@
package ohd.hseb.color_chooser;
import java.awt.Color;
import java.util.ArrayList;
import java.util.List;
public class ColorSet
{
private List _namedColorList = new ArrayList(); // List of NamedColor objects
public ColorSet()
{
}
public ColorSet( ColorSet colorSet )
{
List namedColorList = colorSet.getNamedColorList();
for ( int i = 0; i < namedColorList.size(); i++ )
{
NamedColor extractedNamedColor = (NamedColor) namedColorList.get( i );
if ( extractedNamedColor != null )
{
_namedColorList.add( new NamedColor( extractedNamedColor ) );
}
}
}
public ColorSet( List namedColorList )
{
_namedColorList = namedColorList;
}
public void addNamedColor( Color colorObject )
{
_namedColorList.add( colorObject );
}
public void addNamedColorAtIndex( Color colorObject, int index )
{
_namedColorList.add( index, colorObject );
}
public void deleteNamedColorAtIndex( int index )
{
_namedColorList.remove( index );
}
public void replaceNamedColorAtIndex( Color colorObject, int index )
{
_namedColorList.remove( index );
_namedColorList.add( index, colorObject );
}
public String toString()
{
StringBuffer returnString = new StringBuffer();
for ( int i = 0; i < _namedColorList.size(); i++ )
{
NamedColor namedColor = (NamedColor) _namedColorList.get( i );
returnString.append( namedColor + "\n" );
}
return returnString.toString();
}
public List getNamedColorList()
{
return _namedColorList;
}
}

View file

@ -1,87 +0,0 @@
package ohd.hseb.color_chooser;
public class ColorValue
{
private String _userID;
private String _applicationName;
private String _colorUseName;
private double _duration;
private double _thresholdValue;
private String _thresholdUnit;
private String _colorName;
public void setUserID( String userID )
{
_userID = userID;
}
public String getUserID()
{
return _userID;
}
public void setApplicationName( String applicationName )
{
_applicationName = applicationName;
}
public String getApplicationName()
{
return _applicationName;
}
public void setColorUseName( String colorUseName )
{
_colorUseName = colorUseName;
}
public String getColorUseName()
{
return _colorUseName;
}
public void setDuration( double duration )
{
_duration = duration;
}
public double getDuration()
{
return _duration;
}
public void setThresholdValue( double thresholdValue )
{
_thresholdValue = thresholdValue;
}
public double getThresholdValue()
{
return _thresholdValue;
}
public void setThresholdUnit( String thresholdUnit )
{
_thresholdUnit = thresholdUnit;
}
public String getThresholdUnit()
{
return _thresholdUnit;
}
public void setColorName( String colorName )
{
_colorName = colorName;
}
public String getColorName()
{
return _colorName;
}
public String toString()
{
return _userID + " " + _colorUseName + " " + _duration + " " + _thresholdValue + " " + _colorName;
}
}

View file

@ -1,48 +0,0 @@
package ohd.hseb.color_chooser;
import java.awt.Color;
import ohd.hseb.util.StringParser;
public class NamedColor extends Color
{
private String _name = null;
public NamedColor( String name, int redValue, int greenValue, int blueValue )
{
super( redValue, greenValue, blueValue );
String[] tokenizedString = StringParser.tokenize( name );
StringBuffer nameBuffer = new StringBuffer();
for ( int i = 0; i < tokenizedString.length; i++ )
{
nameBuffer.append( tokenizedString[ i ] );
}
setName( nameBuffer.toString().toUpperCase() );
}
public NamedColor( String name, Color color )
{
this( name, color.getRed(), color.getGreen(), color.getBlue() );
}
public NamedColor( NamedColor namedColor )
{
this( namedColor.getName(), namedColor );
}
public String toString()
{
return _name + " " + super.toString();
}
public void setName( String name )
{
_name = name;
}
public String getName()
{
return _name;
}
}

View file

@ -1,94 +0,0 @@
package ohd.hseb.color_chooser;
import java.awt.Color;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
public class NamedColorMatcher
{
List _namedColorList = null;
public NamedColorMatcher(Map nameToNamedColorMap)
{
_namedColorList = new ArrayList( nameToNamedColorMap.values());
}
public NamedColor getClosestNamedColor(Color color)
{
NamedColor bestNamedColor = null;
Set specialWhiteNameSet = new HashSet();
Set specialBlackNameSet = new HashSet();
specialWhiteNameSet.add("GRAY100");
specialBlackNameSet.add("GRAY0");
List<NamedColor> colorList = _namedColorList;
for (NamedColor namedColor : colorList)
// for (int i = 0; i < _namedColorList.size(); i++)
{
// NamedColor namedColor = (NamedColor) _namedColorList.get(i);
if (isCloserColor(color, namedColor, bestNamedColor))
{
bestNamedColor = namedColor;
}
}
// System.out.println("Desired Color was " + color);
// System.out.println("Found Named Color was " + bestNamedColor);
if ( bestNamedColor != null )
{
String bestNamedColorString = bestNamedColor.getName().toUpperCase();
if ( specialWhiteNameSet.contains( bestNamedColorString ) )
{
bestNamedColor = new NamedColor( "WHITE", bestNamedColor );
}
else if ( specialBlackNameSet.contains( bestNamedColorString ) )
{
bestNamedColor = new NamedColor( "BLACK", bestNamedColor );
}
}
return bestNamedColor;
}
// --------------------------------------------------------------------------------------------------------
private boolean isCloserColor(Color color, NamedColor testNamedColor, NamedColor bestNamedColor)
{
boolean isCloser = false;
if ( (testNamedColor != null) && (bestNamedColor != null) )
{
double distanceFromTestNamedColor = getDistance(color, testNamedColor);
double distanceFromBestNamedColor = getDistance(color, bestNamedColor);
if (distanceFromTestNamedColor < distanceFromBestNamedColor)
{
isCloser = true;
}
}
else if ((bestNamedColor == null) && (testNamedColor != null) )
{
isCloser = true;
}
return isCloser;
}
// --------------------------------------------------------------------------------------------------------
private double getDistance(Color color, NamedColor namedColor)
{
double distance = 0.0;
int redDiff = color.getRed() - namedColor.getRed();
int greenDiff = color.getGreen() - namedColor.getGreen();
int blueDiff = color.getBlue() - namedColor.getBlue();
//intentionally not taking the square root - Chip
distance = (redDiff * redDiff) + (greenDiff * greenDiff) + (blueDiff * blueDiff);
return distance;
}
}

View file

@ -1,59 +0,0 @@
package ohd.hseb.color_chooser;
import java.util.ArrayList;
import java.util.List;
public class ScaleValueSet
{
private List _scaleValueSet = new ArrayList();
public ScaleValueSet()
{
}
public ScaleValueSet( List scaleValueSet )
{
setScaleValueSet( scaleValueSet );
}
public ScaleValueSet( ScaleValueSet scaleValueSet )
{
List scaleValueSetList = scaleValueSet.getScaleValueSet();
for ( int i = 0; i < scaleValueSetList.size(); i++ )
{
_scaleValueSet.add( scaleValueSetList.get( i ) );
}
}
public void addScaleValue( double value )
{
_scaleValueSet.add( value );
}
public void addScaleValueAtIndex( double value, int index )
{
_scaleValueSet.add( index, value );
}
public void replaceScaleValueAtIndex( double value, int index )
{
_scaleValueSet.remove( index );
_scaleValueSet.add( index, value );
}
public void deleteScaleValueAtIndex( int index )
{
_scaleValueSet.remove( index );
}
public void setScaleValueSet( List scaleValueSet )
{
_scaleValueSet = scaleValueSet;
}
public List getScaleValueSet()
{
return _scaleValueSet;
}
}

View file

@ -1,3 +0,0 @@
Damcrest not ported over yet? Some discussion of is it needed ??
Frank 08/21/08, (with Eric Babin) pushed to TO-11 minimally.

View file

@ -1,56 +0,0 @@
package ohd.hseb.fcstservice;
import java.util.ArrayList;
public class DataServicesGlobals //This is a singleton class
{
private static int count = 0;
private static DataServicesGlobals dataServicesGlobals = null;
private static String missingRepresentation = "-";
public static ArrayList dataServiceObservers = null;
public static ArrayList dataDetermObservers = null;
public static ArrayList dataWatSupObservers = null;
public static ArrayList dataEnsembleObservers = null;
private DataServicesGlobals()
{
}
public static synchronized DataServicesGlobals getSingleInstanceOfDataServicesGlobals()
{
if(dataServicesGlobals == null)
{
dataServicesGlobals = new DataServicesGlobals();
}
dataServiceObservers = new ArrayList();
dataDetermObservers = new ArrayList();
dataWatSupObservers = new ArrayList();
dataEnsembleObservers = new ArrayList();
return dataServicesGlobals;
}
public String getMissingRepresentation() {
return missingRepresentation;
}
public void setMissingRepresentation(String missingRepresentation) {
DataServicesGlobals.missingRepresentation = missingRepresentation;
}
public synchronized void incrementCount()
{
count++;
}
public synchronized void decrementCount()
{
count--;
}
public synchronized int getCount()
{
return count;
}
}

View file

@ -1,901 +0,0 @@
package ohd.hseb.fcstservice;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.util.ArrayList;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.text.BadLocationException;
import javax.swing.text.Element;
import ohd.hseb.db.DbTimeHelper;
import ohd.hseb.ihfsdb.generated.FcstPtServiceRecord;
import ohd.hseb.util.gui.DateTextField;
import ohd.hseb.util.gui.WindowResizingManager;
import ohd.hseb.util.gui.jtable.ComplexJTableManager;
import ohd.hseb.util.gui.jtable.JTableColumnDescriptor;
import ohd.hseb.util.gui.jtable.JTableManager;
public class FcstDataServiceWindow implements Subject
{
private DataServicesGlobals dataServicesGlobals = null;
private java.util.List lhvmRowDataList = null;
private LhvmDataManager lhvmDataManager = null;
private LhvmLogger lhvmLogger = null;
private JTableManager jtm = null;
private JFrame lhvm = null;
private FcstPtServiceJTableRowData selectedFcstPtServiceJTableRowData = null;
private ArrayList selectedFcstPtServiceJTableRowsDataList = null;
private JTextField locationTextField = null;
private JTextField floodThersholdTextField = null;
private JTextField exceedProbTextField = null;
private JComboBox serviceTypeTextField = null;
private DateTextField implDateTextField = null;
private DateTextField webDateTextField = null;
private DateTextField startDateTextField = null;
private DateTextField endDateTextField = null;
private JButton insertButton = null;
private JButton deleteButton = null;
private JButton clearButton = null;
private JButton closeButton = null;
private JButton refreshButton = null;
private JTextField stationSearchTextField = null;
private JScrollPane tableScrollPane = null;
private JPanel tableScrollPanePanel = null;
private int numRows;
private JLabel numRowsLabel = null;
private JTextArea consoleTextArea = null;
private int origNumRows;
private ArrayList observers = null;
private java.util.List lhvmRowDataList1 = null;
private String str1[] = null;
public void addObserver(Observer observer)
{
if(observers != null)
{
observers.add(observer);
}
}
public void removeObserver(Observer observer)
{
if(observers != null)
{
observers.remove(observer);
}
}
public void letKnowOfChanges()
{
if(observers != null)
{
for(int i=0;i<observers.size();i++)
{
if(observers.get(i) != null)
{
((Observer) observers.get(i)).update(this);
}
}
}
}
private void setDatabaseMessage()
{
String tempStr = null;
if(LhvmDataManager.displayedMessageServiceWindow != null)
{
tempStr = new String(LhvmDataManager.displayedMessageServiceWindow);
}
LhvmDataManager.displayedMessageServiceWindow = new StringBuffer();
if(tempStr != null)
{
LhvmDataManager.displayedMessageServiceWindow.append(tempStr);
}
LhvmDataManager.displayedMessageServiceWindow.append("\n");
LhvmDataManager.displayedMessageServiceWindow.append(LhvmDataManager.databaseMessage);
//consoleTextArea.insert(new String(LhvmDataManager.displayedMessageServiceWindow), 0);
consoleTextArea.append(new String(LhvmDataManager.displayedMessageServiceWindow));
}
private void appendToConsoleMessageDelete(String lid)
{
String valueToBeSet = new String("\n" + "Successfully deleted row with lid: " + lid + " ");
//consoleTextArea.insert("", 0);
//consoleTextArea.insert(valueToBeSet, 0);
consoleTextArea.append(valueToBeSet);
}
private void appendToConsoleMessageInsert(String lid)
{
String valueToBeSet = new String("\n" + "Successfully inserted row with lid: " + lid + " ");
//consoleTextArea.insert("", 0);
//consoleTextArea.insert(valueToBeSet, 0);
consoleTextArea.append(valueToBeSet);
}
public FcstDataServiceWindow(String jdbcUrl)
{
dataServicesGlobals = DataServicesGlobals.getSingleInstanceOfDataServicesGlobals();
this.observers = DataServicesGlobals.dataServiceObservers;
lhvm = new JFrame("Data Services");
lhvm.setSize(1000, 500);
lhvm.setLocation(20,50);
//Fix the dimensions of this window i.e. dis-allow window resizing
Dimension d = new Dimension(1060, 825);
new WindowResizingManager(lhvm, d, d);
lhvm.setResizable(false);
GridBagLayout gbl = new GridBagLayout();
lhvm.setLayout(gbl);
GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.HORIZONTAL;
JLabel consoleLabel = new JLabel("-----Database Messages-----");
consoleLabel.setForeground(Color.red);
consoleTextArea = new JTextArea(2,50);
Font font = new Font("Serif", Font.BOLD, 20);
consoleTextArea.setFont(font);
consoleTextArea.setForeground(Color.green);
consoleTextArea.setBackground(Color.black);
consoleTextArea.setCaretColor(Color.red);
consoleTextArea.setBorder(BorderFactory.createEtchedBorder() );
consoleTextArea.setLineWrap(true);
String[] columnsToBeDisplayed = {"Location ID", "Flood Threshold", "Exceed Probability %", "Service Type", "Analysis Start Date", "Analysis End Date", "Implementation Date", "Web Date"};
lhvmLogger = new LhvmLogger();
lhvmDataManager = LhvmDataManager.getSingleInstanceOfDataManager(jdbcUrl, lhvmLogger,"-");
java.util.List lhvmColumnDescriptorList = new ArrayList();
lhvmRowDataList = lhvmDataManager.readDataFromPtService();
lhvmColumnDescriptorList.add(new JTableColumnDescriptor("Location ID", true, 150, "center", "location id"));
lhvmColumnDescriptorList.add(new JTableColumnDescriptor("Flood Threshold", true, 150, "center", "flood threshold"));
lhvmColumnDescriptorList.add(new JTableColumnDescriptor("Exceed Probability %", true, 150, "center","exceed probability (%)"));
lhvmColumnDescriptorList.add(new JTableColumnDescriptor("Service Type", true, 150, "center", "service type (data or forecast)"));
lhvmColumnDescriptorList.add(new JTableColumnDescriptor("Analysis Start Date", true, 150, "center", "start date for analysis of the exceedance probability for a given flood threshold"));
lhvmColumnDescriptorList.add(new JTableColumnDescriptor("Analysis End Date", true, 150, "center", "end date for analysis of the exceedance probability for a given flood threshold"));
lhvmColumnDescriptorList.add(new JTableColumnDescriptor("Implementation Date", true, 150, "center", "date observed data first used as input to RFC hydrologic procedures"));
lhvmColumnDescriptorList.add(new JTableColumnDescriptor("Web Date", true, 150, "center", "date observed hydrograph first available on web"));
jtm = new ComplexJTableManager(lhvmColumnDescriptorList, lhvmRowDataList);
jtm.setDisplayableColumns(columnsToBeDisplayed, false, true);
jtm.setPreferredSizeForJScrollPane(new Dimension(1000, 500));
jtm.addTableListener(new ServiceTableViewListSelectListener());
tableScrollPane = jtm.getJScrollPane();
tableScrollPanePanel = new JPanel();
tableScrollPanePanel.add(tableScrollPane);
setDatabaseMessage();
// Get paragraph element
Element paragraph = consoleTextArea.getDocument().getDefaultRootElement();
// Get number of content elements
int contentCount = paragraph.getElementCount();
// Get index ranges for each content element.
// Each content element represents one line.
// Each line includes the terminating newline.
for (int i=0; i<contentCount; i++) {
Element e = paragraph.getElement(i);
int rangeStart = e.getStartOffset();
int rangeEnd = e.getEndOffset();
try
{
String line = consoleTextArea.getText(rangeStart,rangeEnd-rangeStart);
} catch (BadLocationException ex) {}
}
JScrollPane scrollableTextAreaForConsole = new JScrollPane(consoleTextArea, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
JLabel emptyLabel1 = new JLabel(" ");//25 spaces
JLabel emptyLabel2 = new JLabel(" ");//25 spaces
JLabel emptyLabel3 = new JLabel(" ");//25 spaces
JLabel emptyLabel4 = new JLabel(" ");//25 spaces
JLabel emptyLabel5 = new JLabel(" ");//25 spaces
JLabel emptyLabel6 = new JLabel(" ");//25 spaces
JLabel emptyLabel7 = new JLabel(" ");//25 spaces
JLabel emptyLabel8 = new JLabel(" ");//25 spaces
JLabel emptyLabel9 = new JLabel(" ");//25 spaces
JLabel emptyLabel10 = new JLabel(" ");//25 spaces
JLabel emptyLabel11 = new JLabel(" ");//25 spaces
JLabel emptyLabel12 = new JLabel(" ");//25 spaces
JLabel emptyLabel13 = new JLabel(" ");//25 spaces
JLabel emptyLabel14 = new JLabel(" ");//25 spaces
JLabel emptyLabel15 = new JLabel(" ");//25 spaces
numRows = lhvmRowDataList.size();
numRowsLabel = new JLabel(numRows + " Rows");
c.gridwidth = 1;
c.gridx = 0;
c.gridy = 0;
lhvm.getContentPane ().add(numRowsLabel, c);
c.gridx++;
//lhvm.getContentPane ().add(emptyLabel8, c);
JLabel stationSearchLabel = new JLabel(" Station Search:");//25 spaces to adjust alignment
c.gridx++;
lhvm.getContentPane ().add(stationSearchLabel, c);
stationSearchTextField = new JTextField(10);
stationSearchTextField.setFocusable(true);
Font fnt = stationSearchTextField.getFont();
fnt = fnt.deriveFont(Font.BOLD, 1.2F*fnt.getSize2D());
stationSearchTextField.setForeground(new Color(50,150,50));
stationSearchTextField.setBackground(Color.yellow);
stationSearchTextField.setFont(fnt);
stationSearchTextField.setCaretColor(Color.red);
stationSearchTextField.addKeyListener(new SearchTextTypedActionListener());
c.gridx++;
lhvm.getContentPane ().add(stationSearchTextField, c);
c.gridx++;
lhvm.getContentPane ().add(emptyLabel1, c);
JButton filterOptionsButton = new JButton("Stations Filter Options");
filterOptionsButton.setEnabled(false);
c.gridx++;
//lhvm.getContentPane ().add(filterOptionsButton, c);
lhvm.getContentPane ().add(emptyLabel5, c);
c.gridy++;
lhvm.getContentPane().add(emptyLabel9, c);
c.gridwidth = 0;
c.gridx = 0;
c.gridy++;
lhvm.getContentPane().add(tableScrollPanePanel,c);
//int[] selectedRowIndices = jtm.getSelectedRowIndices();
JPanel editPanel = new JPanel();
editPanel.setLayout(new GridLayout(2,4));
editPanel.setBorder(BorderFactory.createTitledBorder("Column Editor"));
editPanel.setBackground(new Color(0,150,255));
JPanel editPanel2 = new JPanel();
editPanel2.setLayout(new GridLayout(2,4));
//editPanel.setBorder(BorderFactory.createTitledBorder("Column Editor -- Fields with red text are non-editable"));
editPanel2.setBackground(new Color(0,150,255));
c.gridy++;
JLabel locationIdLabel = new JLabel("Location ID");
JLabel floodThersholdLabel = new JLabel("Flood Threshold");
JLabel exceedProbLabel = new JLabel("Exceed Probability %");
JLabel serviceTypeLabel = new JLabel("Service Type");
JLabel startDateLabel = new JLabel("Analysis Start Date");
JLabel endDateLabel = new JLabel("Analysis End Date");
JLabel implDateLabel = new JLabel("Implementation Date");
JLabel webDateLabel = new JLabel("Web Date");
locationTextField = new JTextField();
locationTextField.setBackground(new Color(255,175,75));
locationTextField.setForeground(new Color(50,150,50));
locationTextField.setFont(fnt);
locationTextField.setCaretColor(Color.red);
locationTextField.setSize(15,15);
TextTypedActionListener textTypedActionListener = new TextTypedActionListener();
locationTextField.addKeyListener(textTypedActionListener);
floodThersholdTextField = new JTextField();
floodThersholdTextField.setBackground(Color.yellow);
floodThersholdTextField.setForeground(new Color(50,150,50));
floodThersholdTextField.setFont(fnt);
floodThersholdTextField.setCaretColor(Color.red);
floodThersholdTextField.setSize(15,15);
floodThersholdTextField.addKeyListener(textTypedActionListener);
exceedProbTextField = new JTextField();
exceedProbTextField.setBackground(Color.yellow);
exceedProbTextField.setForeground(new Color(50,150,50));
exceedProbTextField.setFont(fnt);
exceedProbTextField.setCaretColor(Color.red);
exceedProbTextField.setSize(15,15);
exceedProbTextField.addKeyListener(textTypedActionListener);
implDateTextField = new DateTextField(0, lhvm, "Date Selector", 10, dataServicesGlobals.getMissingRepresentation());
implDateTextField.setBackground(Color.yellow);
implDateTextField.setForeground(new Color(50,150,50));
implDateTextField.setFont(fnt);
implDateTextField.setCaretColor(Color.red);
implDateTextField.setSize(15,15);
webDateTextField = new DateTextField(0, lhvm, "Date Selector", 10, dataServicesGlobals.getMissingRepresentation());
webDateTextField.setBackground(Color.yellow);
webDateTextField.setForeground(new Color(50,150,50));
webDateTextField.setFont(fnt);
webDateTextField.setCaretColor(Color.red);
webDateTextField.setSize(15,15);
endDateTextField = new DateTextField(0, lhvm, "Date Selector", 10, dataServicesGlobals.getMissingRepresentation());
endDateTextField.setBackground(Color.yellow);
endDateTextField.setForeground(new Color(50,150,50));
endDateTextField.setFont(fnt);
endDateTextField.setCaretColor(Color.red);
endDateTextField.setSize(15,15);
startDateTextField = new DateTextField(0, lhvm, "Date Selector", 10, dataServicesGlobals.getMissingRepresentation());
startDateTextField.setBackground(Color.yellow);
startDateTextField.setForeground(new Color(50,150,50));
startDateTextField.setFont(fnt);
startDateTextField.setCaretColor(Color.red);
startDateTextField.setSize(15,15);
lhvmRowDataList1 = lhvmDataManager.readDataFromServiceType();
str1 = new String[lhvmRowDataList1.size()];
for(int i=0;i<lhvmRowDataList1.size();i++)
{
str1[i] = ((ServiceTypeJTableRowData) lhvmRowDataList1.get(i)).getServiceType();
}
serviceTypeTextField = new JComboBox(str1);
serviceTypeTextField.setBackground(Color.yellow);
serviceTypeTextField.setForeground(new Color(50,150,50));
editPanel.add(locationIdLabel);
editPanel.add(floodThersholdLabel);
editPanel.add(exceedProbLabel);
editPanel.add(serviceTypeLabel);
editPanel.add(locationTextField);
editPanel.add(floodThersholdTextField);
editPanel.add(exceedProbTextField);
editPanel.add(serviceTypeTextField);
editPanel2.add(startDateLabel);
editPanel2.add(endDateLabel);
editPanel2.add(implDateLabel);
editPanel2.add(webDateLabel);
editPanel2.add(startDateTextField);
editPanel2.add(endDateTextField);
editPanel2.add(implDateTextField);
editPanel2.add(webDateTextField);
lhvm.getContentPane().add(editPanel,c);
c.gridy++;
c.gridy++;
lhvm.getContentPane().add(editPanel2,c);
insertButton = new JButton("Save Record");
insertButton.addActionListener(new SaveActionListener());
deleteButton = new JButton("Delete Record(s)");
deleteButton.addActionListener(new DeleteActionListener());
clearButton = new JButton("Clear");
clearButton.addActionListener(new ClearActionListener());
closeButton = new JButton("Close Window");
closeButton.addActionListener(new CloseActionListener());
//refreshButton = new JButton("Refresh Entries");
//refreshButton.addActionListener(new RefreshActionListener());
insertButton.setEnabled(false);
deleteButton.setEnabled(false);
clearButton.setEnabled(false);
//refreshButton.setEnabled(true);
closeButton.setEnabled(true);
c.gridwidth = 1;
c.gridx = 0;
c.gridy++;
lhvm.getContentPane ().add(insertButton, c);
c.gridx++;
lhvm.getContentPane ().add(deleteButton, c);
c.gridx++;
lhvm.getContentPane ().add(clearButton, c);
//c.gridx++;
//lhvm.getContentPane ().add(refreshButton, c);
c.gridx++;
lhvm.getContentPane ().add(emptyLabel3, c);
c.gridx++;
lhvm.getContentPane ().add(emptyLabel4, c);
//c.gridx++;
//lhvm.getContentPane ().add(emptyLabel5, c);
c.gridx++;
lhvm.getContentPane ().add(closeButton, c);
c.gridwidth = 0;
c.gridx = 0;
c.gridy++;
lhvm.getContentPane ().add(emptyLabel15, c);
c.gridy++;
c.gridy++;
lhvm.getContentPane().add(emptyLabel2, c);
c.gridy++;
lhvm.getContentPane ().add(consoleLabel, c);
c.gridy++;
lhvm.getContentPane().add(scrollableTextAreaForConsole, c);
lhvm.addWindowListener(new ServicesDbWindowAdapter());
lhvm.pack();
//Show the JFrame
lhvm.setVisible (true);
}
private void showCurrentRowData()
{
if(selectedFcstPtServiceJTableRowData != null)
{
locationTextField.setText(selectedFcstPtServiceJTableRowData.getDataValue("Location ID"));
floodThersholdTextField.setText(selectedFcstPtServiceJTableRowData.getDataValue("Flood Threshold"));
exceedProbTextField.setText(selectedFcstPtServiceJTableRowData.getDataValue("Exceed Probability %"));
implDateTextField.setText(selectedFcstPtServiceJTableRowData.getDataValue("Implementation Date"));
webDateTextField.setText(selectedFcstPtServiceJTableRowData.getDataValue("Web Date"));
startDateTextField.setText(selectedFcstPtServiceJTableRowData.getDataValue("Analysis Start Date"));
endDateTextField.setText(selectedFcstPtServiceJTableRowData.getDataValue("Analysis End Date"));
serviceTypeTextField.setSelectedItem(selectedFcstPtServiceJTableRowData.getDataValue("Service Type"));
selectedFcstPtServiceJTableRowData = null;
activateSaveButton();
activateClearButton();
activateDeleteButton();
}
else
{
clearForm();
}
}
private void deActivateDeleteButton()
{
deleteButton.setEnabled(false);
}
private void deActivateSaveButton()
{
insertButton.setEnabled(false);
}
private void deActivateClearButton()
{
clearButton.setEnabled(false);
}
private void activateDeleteButton()
{
deleteButton.setEnabled(true);
}
private void activateSaveButton()
{
insertButton.setEnabled(true);
}
private void activateClearButton()
{
clearButton.setEnabled(true);
}
private void removeHighlightOfAllRows()
{
int indices[] = new int[lhvmRowDataList.size()];
for(int i=0;i<lhvmRowDataList.size();i++)
{
indices[i] = i;
}
jtm.deselectRows(indices);
}
private void clearForm()
{
locationTextField.setText("");
floodThersholdTextField.setText("");
exceedProbTextField.setText("");
implDateTextField.setText("yyyy-mm-dd");
webDateTextField.setText("yyyy-mm-dd");
startDateTextField.setText("yyyy-mm-dd");
endDateTextField.setText("yyyy-mm-dd");
}
public void buttonsActivateWhenKeysTyped()
{
if(locationTextField.getText().length() > 0)
{
activateSaveButton();
activateClearButton();
}
else
{
deActivateSaveButton();
}
}
public void buttonsActivateWhenSearched()
{
if(selectedFcstPtServiceJTableRowsDataList != null && selectedFcstPtServiceJTableRowsDataList.size() < 1)
{
deActivateDeleteButton();
deActivateSaveButton();
deActivateClearButton();
clearForm();
}
else if(selectedFcstPtServiceJTableRowsDataList != null && selectedFcstPtServiceJTableRowsDataList.size() == 1)
{
selectedFcstPtServiceJTableRowData = (FcstPtServiceJTableRowData) selectedFcstPtServiceJTableRowsDataList.get(0);
showCurrentRowData();
activateDeleteButton();
activateSaveButton();
activateClearButton();
}
else if(selectedFcstPtServiceJTableRowsDataList != null && selectedFcstPtServiceJTableRowsDataList.size() > 1)
{
activateDeleteButton();
deActivateSaveButton();
deActivateClearButton();
clearForm();
}
}
public void buttonsActivateWhenSelected()
{
getSelectedRows();
if(selectedFcstPtServiceJTableRowsDataList.size() < 1)
{
deActivateDeleteButton();
deActivateSaveButton();
deActivateClearButton();
clearForm();
}
else if(selectedFcstPtServiceJTableRowsDataList.size() == 1)
{
selectedFcstPtServiceJTableRowData = (FcstPtServiceJTableRowData) selectedFcstPtServiceJTableRowsDataList.get(0);
showCurrentRowData();
activateDeleteButton();
activateSaveButton();
activateClearButton();
}
else if(selectedFcstPtServiceJTableRowsDataList.size() > 1)
{
activateDeleteButton();
deActivateSaveButton();
deActivateClearButton();
clearForm();
}
}
private void getSelectedRows()
{
selectedFcstPtServiceJTableRowsDataList = (ArrayList) jtm.getSelectedRowsData();
}
private void operationCloseWindow()
{
if(dataServicesGlobals.getCount() <= 1)
{
lhvm.dispose();
// System.exit(0);
}
else
{
dataServicesGlobals.decrementCount();
lhvm.dispose();
}
}
private class SaveActionListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
int[] rowIndex = new int[1];
String currentLidFromRowsInsideLoop = null;
int i, null_or_not = 0;
rowIndex[0] = -1;
FcstPtServiceRecord record = new FcstPtServiceRecord();
record.setLid(locationTextField.getText().toUpperCase());
record.setService_type(str1[serviceTypeTextField.getSelectedIndex()]);
try
{
if(floodThersholdTextField.getText().length() > 0 && !floodThersholdTextField.getText().equalsIgnoreCase(dataServicesGlobals.getMissingRepresentation()))
{
record.setFlood_thres(Double.parseDouble(floodThersholdTextField.getText()));
}
else
{
record.setFlood_thres(Double.MIN_VALUE);
null_or_not = 1;
}
}
catch(NumberFormatException ne)
{
JOptionPane.showMessageDialog(null, "Not a valid value in the Flood Threshold text box; It must be a number. Aborting insert.");
return;
}
try
{
if(exceedProbTextField.getText().length() > 0 && !exceedProbTextField.getText().equalsIgnoreCase(dataServicesGlobals.getMissingRepresentation()))
{
record.setExceed_prob(Short.parseShort(exceedProbTextField.getText()));
}
else
{
record.setExceed_prob(Short.MIN_VALUE);
null_or_not = 1;
}
}
catch(NumberFormatException ne)
{
JOptionPane.showMessageDialog(null, "Not a valid value in the Exceed Probability text box; It must be a number. Aborting insert.");
return;
}
Object[] options = { "YES", "NO" };
if(!implDateTextField.getText().equalsIgnoreCase("yyyy-mm-dd") && !implDateTextField.getText().equalsIgnoreCase(dataServicesGlobals.getMissingRepresentation()))
{
record.setImpl_date(DbTimeHelper.getLongTimeFromDateString(implDateTextField.getText()));
}
else
{
null_or_not = 1;
record.setImpl_date(Long.MIN_VALUE);
}
if(!webDateTextField.getText().equalsIgnoreCase("yyyy-mm-dd") && !webDateTextField.getText().equalsIgnoreCase(dataServicesGlobals.getMissingRepresentation()))
{
record.setWeb_date(DbTimeHelper.getLongTimeFromDateString(webDateTextField.getText()));
}
else
{
null_or_not = 1;
record.setWeb_date(Long.MIN_VALUE);
}
if(!startDateTextField.getText().equalsIgnoreCase("yyyy-mm-dd") && !startDateTextField.getText().equalsIgnoreCase(dataServicesGlobals.getMissingRepresentation()))
{
record.setAnal_start_date(DbTimeHelper.getLongTimeFromDateString(startDateTextField.getText()));
}
else
{
null_or_not = 1;
record.setAnal_start_date(Long.MIN_VALUE);
}
if(!endDateTextField.getText().equalsIgnoreCase("yyyy-mm-dd") && !endDateTextField.getText().equalsIgnoreCase(dataServicesGlobals.getMissingRepresentation()))
{
record.setAnal_end_date(DbTimeHelper.getLongTimeFromDateString(endDateTextField.getText()));
}
else
{
null_or_not = 1;
record.setAnal_end_date(Long.MIN_VALUE);
}
if(null_or_not == 1)
{
int yes_or_no = JOptionPane.showOptionDialog(null, "At least one field has no value defined...continue??", "Not All Fields Defined!", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE,null, options, options[1]);
if(yes_or_no == JOptionPane.NO_OPTION)
{
return;
}
null_or_not = 0;
}
// lhvmLogger.log(" Delete record"+ record.toString());
LhvmDataManager.databaseMessage = null;
int success = lhvmDataManager.insertOrUpdateServiceTable(record);
if(success != -1)
{
appendToConsoleMessageInsert(locationTextField.getText());
}
else
{
JOptionPane.showMessageDialog(null, "Oops: Problem inserting, please check console");
setDatabaseMessage();
}
lhvmRowDataList = lhvmDataManager.readDataFromPtService();
jtm.setChangedAllRowDataList(lhvmRowDataList);
numRows = lhvmRowDataList.size();
numRowsLabel.setText(numRows + " Rows");
jtm.refreshDisplay();
for(i=0;i<lhvmRowDataList.size();i++)
{
currentLidFromRowsInsideLoop = ((FcstPtServiceJTableRowData) lhvmRowDataList.get(i)).getLid();
if(locationTextField.getText().equalsIgnoreCase(currentLidFromRowsInsideLoop))
{
rowIndex[0] = i;
break;
}
}
jtm.selectRows(rowIndex[0], rowIndex[0]);
letKnowOfChanges();
}
}
private class DeleteActionListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
int i, size;
origNumRows = lhvmRowDataList.size();
size = selectedFcstPtServiceJTableRowsDataList.size();
Object[] options = { "YES", "NO" };
int yes_or_no = JOptionPane.showOptionDialog(null, "Are you sure to delete row(s)?", "About To Delete Rows!", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE,null, options, options[1]);
if(yes_or_no == JOptionPane.NO_OPTION)
{
return;
}
else
{
for(i=0;i<size;i++)
{
FcstPtServiceRecord record = new FcstPtServiceRecord();
String lid = ((FcstPtServiceJTableRowData)selectedFcstPtServiceJTableRowsDataList.get(i)).getLid();
record.setLid(lid);
//lhvmLogger.log(" Delete record"+ record.toString());
LhvmDataManager.databaseMessage = null;
int success = lhvmDataManager.deleteFromServiceTable(record);
if(success != -1)
{
appendToConsoleMessageDelete(lid);
}
else
{
JOptionPane.showMessageDialog(null, "Oops: Some or all of the rows could not be deleted, please check console");
setDatabaseMessage();
}
}
}
lhvmRowDataList = lhvmDataManager.readDataFromPtService();
jtm.setChangedAllRowDataList(lhvmRowDataList);
jtm.refreshDisplay();
deActivateDeleteButton();
deActivateSaveButton();
deActivateClearButton();
clearForm();
numRows = lhvmRowDataList.size();
numRowsLabel.setText(numRows + " Rows");
if(numRows < origNumRows)
{
JOptionPane.showMessageDialog(null, "Rows deleted, please check console");
}
origNumRows = numRows;
letKnowOfChanges();
}
}
private class CloseActionListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
operationCloseWindow();
}
}
private class RefreshActionListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
lhvmRowDataList = lhvmDataManager.readDataFromPtService();
jtm.setChangedAllRowDataList(lhvmRowDataList);
jtm.refreshDisplay();
deActivateDeleteButton();
deActivateClearButton();
deActivateSaveButton();
clearForm();
numRows = lhvmRowDataList.size();
numRowsLabel.setText(numRows + " Rows");
}
}
private class ClearActionListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
clearForm();
removeHighlightOfAllRows();
deActivateSaveButton();
deActivateDeleteButton();
deActivateClearButton();
}
}
private class TextTypedActionListener implements KeyListener
{
public void keyTyped(KeyEvent e)
{
}
public void keyPressed(KeyEvent e)
{
}
public void keyReleased(KeyEvent e)
{
buttonsActivateWhenKeysTyped();
}
}
private class ServiceTableViewListSelectListener implements ListSelectionListener
{
public void valueChanged(ListSelectionEvent e)
{
buttonsActivateWhenSelected();
}
}
private class SearchTextTypedActionListener implements KeyListener
{
String currentLidFromRowsInsideLoop;
int[] rowIndices;
int index;
public void init()
{
index = -1;
rowIndices = new int[lhvmRowDataList.size()];
for(int i=0;i<lhvmRowDataList.size();i++)
{
rowIndices[i] = -1;
}
}
public void keyTyped(KeyEvent e)
{
}
public void keyPressed(KeyEvent e)
{
}
public void keyReleased(KeyEvent e)
{
removeHighlightOfAllRows();
ArrayList searchList = new ArrayList();
String typedText = stationSearchTextField.getText();
init();
if(typedText.length() > 0 && lhvmRowDataList.size() > 0)
{
int count = 0, i;
for(i=0;i<lhvmRowDataList.size();i++)
{
currentLidFromRowsInsideLoop = ((FcstPtServiceJTableRowData) lhvmRowDataList.get(i)).getLid();
if((typedText.length() <= currentLidFromRowsInsideLoop.length()) && typedText.equalsIgnoreCase(currentLidFromRowsInsideLoop.substring(0, typedText.length())))
{
searchList.add(lhvmRowDataList.get(i));
rowIndices[count++] = i;
}
}
}
else
{
jtm.selectRows(0, 0);
clearForm();
removeHighlightOfAllRows();
deActivateSaveButton();
deActivateDeleteButton();
deActivateClearButton();
return;
}
selectedFcstPtServiceJTableRowsDataList = searchList;
buttonsActivateWhenSelected();
for(int i=0;i<rowIndices.length;i++)
{
if(rowIndices[i] == -1)
{
break;
}
index++;
}
if(index != -1)
{
//jtm.highlightRows(rowIndices[0], rowIndices[index]);
jtm.deselectRows(rowIndices);
}
}
}
}

View file

@ -1,955 +0,0 @@
package ohd.hseb.fcstservice;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.util.ArrayList;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.text.BadLocationException;
import javax.swing.text.Element;
import ohd.hseb.db.DbTimeHelper;
import ohd.hseb.ihfsdb.generated.FcstPtWatSupRecord;
import ohd.hseb.util.gui.DateTextField;
import ohd.hseb.util.gui.WindowResizingManager;
import ohd.hseb.util.gui.jtable.ComplexJTableManager;
import ohd.hseb.util.gui.jtable.JTableColumnDescriptor;
import ohd.hseb.util.gui.jtable.JTableManager;
public class FcstDataWatSupWindow implements Subject
{
private DataServicesGlobals dataServicesGlobals = null;
private java.util.List lhvmRowDataList = null;
private LhvmDataManager lhvmDataManager = null;
private LhvmLogger lhvmLogger = null;
private JTableManager jtm = null;
private JFrame lhvm = null;
private FcstPtWatSupJTableRowData selectedFcstPtWatsupJTableRowData = null;
private ArrayList selectedFcstPtWatsupJTableRowsDataList = null;
private JTextField locationTextField = null;
private JComboBox normalTextField = null;
private JComboBox watsupMethodTextField = null;
private JComboBox watsupCoordAgencyTextField = null;
private JComboBox periodReqTextField = null;
private JComboBox watsupCritTextField = null;
private JComboBox respAgencyTextField = null;
private JTextField customerDescTextField = null;
private DateTextField implDateTextField = null;
private DateTextField webDateTextField = null;
private JButton insertButton = null;
private JButton deleteButton = null;
private JButton clearButton = null;
private JButton closeButton = null;
private JButton refreshButton = null;
private JTextField stationSearchTextField = null;
private JScrollPane tableScrollPane = null;
private JPanel tableScrollPanePanel = null;
private int numRows;
private JLabel numRowsLabel = null;
private JTextArea consoleTextArea = null;
private int origNumRows;
private java.util.List lhvmRowDataList1 = null;
private java.util.List lhvmRowDataList2 = null;
private java.util.List lhvmRowDataList3 = null;
private java.util.List lhvmRowDataList4 = null;
private java.util.List lhvmRowDataList5 = null;
private java.util.List lhvmRowDataList6 = null;
private String str1[] = null;
private String str2[] = null;
private String str3[] = null;
private String str4[] = null;
private String str5[] = null;
private String str6[] = null;
private ArrayList observers = null;
public void addObserver(Observer observer)
{
if(observers != null)
{
observers.add(observer);
}
}
public void removeObserver(Observer observer)
{
if(observers != null)
{
observers.remove(observer);
}
}
public void letKnowOfChanges()
{
if(observers != null)
{
for(int i=0;i<observers.size();i++)
{
if(observers.get(i) != null)
{
((Observer) observers.get(i)).update(this);
}
}
}
}
private void setDatabaseMessage()
{
String tempStr = null;
if(LhvmDataManager.displayedMessageWatsupWindow != null)
{
tempStr = new String(LhvmDataManager.displayedMessageWatsupWindow);
}
LhvmDataManager.displayedMessageWatsupWindow = new StringBuffer();
if(tempStr != null)
{
LhvmDataManager.displayedMessageWatsupWindow.append(tempStr);
}
LhvmDataManager.displayedMessageWatsupWindow.append("\n");
LhvmDataManager.displayedMessageWatsupWindow.append(LhvmDataManager.databaseMessage);
//consoleTextArea.insert(new String(LhvmDataManager.displayedMessageWatsupWindow), 0);
consoleTextArea.append(new String(LhvmDataManager.displayedMessageWatsupWindow));
}
private void appendToConsoleMessage(String lid)
{
String valueToBeSet = new String(consoleTextArea.getText() + "\n" + "Successfully deleted row with lid: " + lid + " ");
//consoleTextArea.insert("", 0);
//consoleTextArea.insert(valueToBeSet, 0);
consoleTextArea.append(valueToBeSet);
}
private void appendToConsoleMessageInsert(String lid)
{
String valueToBeSet = new String(consoleTextArea.getText() + "\n" + "Successfully inserted row with lid: " + lid + " ");
//consoleTextArea.insert("", 0);
//consoleTextArea.insert(valueToBeSet, 0);
consoleTextArea.append(valueToBeSet);
}
public FcstDataWatSupWindow(String jdbcUrl)
{
observers = new ArrayList();
dataServicesGlobals = DataServicesGlobals.getSingleInstanceOfDataServicesGlobals();
this.observers = DataServicesGlobals.dataWatSupObservers;
lhvm = new JFrame("Water Supply");
lhvm.setSize(1000, 500);
lhvm.setLocation(20,50);
//Fix the dimensions of this window i.e. dis-allow window resizing
Dimension d = new Dimension(1060, 880);
new WindowResizingManager(lhvm, d, d);
lhvm.setResizable(false);
GridBagLayout gbl = new GridBagLayout();
lhvm.setLayout(gbl);
GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.HORIZONTAL;
JLabel consoleLabel = new JLabel("-----Database Messages-----");
consoleLabel.setForeground(Color.red);
consoleTextArea = new JTextArea(2,50);
Font font = new Font("Serif", Font.BOLD, 20);
consoleTextArea.setFont(font);
consoleTextArea.setForeground(Color.green);
consoleTextArea.setBackground(Color.black);
consoleTextArea.setCaretColor(Color.red);
consoleTextArea.setBorder(BorderFactory.createEtchedBorder() );
consoleTextArea.setLineWrap(true);
String[] columnsToBeDisplayed = {"Location ID", "Wat Sup Method", "Wat Sup Coord Agency", "Normal Upd Freq", "Period Req", "Wat Sup Criteria", "Wat Sup Resp Agency", "Customer Desc", "Implementation Date", "Web Date"};
lhvmLogger = new LhvmLogger();
lhvmDataManager = LhvmDataManager.getSingleInstanceOfDataManager(jdbcUrl, lhvmLogger,"-");
java.util.List lhvmColumnDescriptorList = new ArrayList();
lhvmRowDataList = lhvmDataManager.readDataFromPtWatsup();
lhvmColumnDescriptorList.add(new JTableColumnDescriptor("Location ID", true, 120, "center", "location id"));
lhvmColumnDescriptorList.add(new JTableColumnDescriptor("Wat Sup Method", true, 120, "center", "computational method used to produce the water supply forecast"));
lhvmColumnDescriptorList.add(new JTableColumnDescriptor("Wat Sup Coord Agency", true, 120, "center", "coordinating agency for the water supply forecast"));
lhvmColumnDescriptorList.add(new JTableColumnDescriptor("Normal Upd Freq", true, 120, "center", "normal operations period of issuance"));
lhvmColumnDescriptorList.add(new JTableColumnDescriptor("Period Req", true, 120, "center", "period required to be forecast"));
lhvmColumnDescriptorList.add(new JTableColumnDescriptor("Wat Sup Criteria", true, 120, "center", "water supply criteria"));
lhvmColumnDescriptorList.add(new JTableColumnDescriptor("Customer Desc", true, 120, "center", "description of customers interested in the water supply forecast"));
lhvmColumnDescriptorList.add(new JTableColumnDescriptor("Implementation Date", true, 120, "center", "date service was first produced"));
lhvmColumnDescriptorList.add(new JTableColumnDescriptor("Web Date", true, 120, "center", "date graphical products first available on web"));
lhvmColumnDescriptorList.add(new JTableColumnDescriptor("Wat Sup Resp Agency", true, 120, "center", "agency responsible for the water supply forecast"));
jtm = new ComplexJTableManager(lhvmColumnDescriptorList, lhvmRowDataList);
jtm.setDisplayableColumns(columnsToBeDisplayed, false, true);
jtm.setPreferredSizeForJScrollPane(new Dimension(1010, 500));
jtm.addTableListener(new DetermTableViewListSelectListener());
tableScrollPane = jtm.getJScrollPane();
//jtm.setTableToolTipText("str");
tableScrollPanePanel = new JPanel();
tableScrollPanePanel.add(tableScrollPane);
setDatabaseMessage();
// Get paragraph element
Element paragraph = consoleTextArea.getDocument().getDefaultRootElement();
// Get number of content elements
int contentCount = paragraph.getElementCount();
// Get index ranges for each content element.
// Each content element represents one line.
// Each line includes the terminating newline.
for (int i=0; i<contentCount; i++) {
Element e = paragraph.getElement(i);
int rangeStart = e.getStartOffset();
int rangeEnd = e.getEndOffset();
try
{
String line = consoleTextArea.getText(rangeStart,rangeEnd-rangeStart);
} catch (BadLocationException ex) {}
}
JScrollPane scrollableTextAreaForConsole = new JScrollPane(consoleTextArea, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
JLabel emptyLabel1 = new JLabel(" ");//25 spaces
JLabel emptyLabel2 = new JLabel(" ");//25 spaces
JLabel emptyLabel3 = new JLabel(" ");//25 spaces
JLabel emptyLabel4 = new JLabel(" ");//25 spaces
JLabel emptyLabel5 = new JLabel(" ");//25 spaces
JLabel emptyLabel6 = new JLabel(" ");//25 spaces
JLabel emptyLabel7 = new JLabel(" ");//25 spaces
JLabel emptyLabel8 = new JLabel(" ");//25 spaces
JLabel emptyLabel9 = new JLabel(" ");//25 spaces
JLabel emptyLabel10 = new JLabel(" ");//25 spaces
JLabel emptyLabel11 = new JLabel(" ");//25 spaces
JLabel emptyLabel12 = new JLabel(" ");//25 spaces
JLabel emptyLabel13 = new JLabel(" ");//25 spaces
JLabel emptyLabel14 = new JLabel(" ");//25 spaces
JLabel emptyLabel15 = new JLabel(" ");//25 spaces
numRows = lhvmRowDataList.size();
numRowsLabel = new JLabel(numRows + " Rows");
c.gridwidth = 1;
c.gridx = 0;
c.gridy = 0;
lhvm.getContentPane ().add(numRowsLabel, c);
c.gridx++;
//lhvm.getContentPane ().add(emptyLabel8, c);
JLabel stationSearchLabel = new JLabel(" Station Search:");//25 spaces to adjust alignment
c.gridx++;
lhvm.getContentPane ().add(stationSearchLabel, c);
stationSearchTextField = new JTextField(10);
stationSearchTextField.setFocusable(true);
Font fnt = stationSearchTextField.getFont();
fnt = fnt.deriveFont(Font.BOLD, 1.2F*fnt.getSize2D());
stationSearchTextField.setForeground(new Color(50,150,50));
stationSearchTextField.setBackground(Color.yellow);
stationSearchTextField.setFont(fnt);
stationSearchTextField.setCaretColor(Color.red);
stationSearchTextField.addKeyListener(new SearchTextTypedActionListener());
c.gridx++;
lhvm.getContentPane ().add(stationSearchTextField, c);
c.gridx++;
lhvm.getContentPane ().add(emptyLabel1, c);
JButton filterOptionsButton = new JButton("Stations Filter Options");
filterOptionsButton.setEnabled(false);
c.gridx++;
//lhvm.getContentPane ().add(filterOptionsButton, c);
lhvm.getContentPane ().add(emptyLabel5, c);
c.gridy++;
lhvm.getContentPane().add(emptyLabel9, c);
c.gridwidth = 0;
c.gridx = 0;
c.gridy++;
lhvm.getContentPane().add(tableScrollPanePanel,c);
//int[] selectedRowIndices = jtm.getSelectedRowIndices();
JPanel editPanel = new JPanel();
editPanel.setLayout(new GridLayout(2,5));
editPanel.setBorder(BorderFactory.createTitledBorder("Column Editor"));
editPanel.setBackground(new Color(0,150,255));
JPanel editPanel2 = new JPanel();
editPanel2.setLayout(new GridLayout(2,4));
//editPanel.setBorder(BorderFactory.createTitledBorder("Column Editor -- Fields with red text are non-editable"));
editPanel2.setBackground(new Color(0,150,255));
JPanel editPanel3 = new JPanel();
editPanel3.setLayout(new GridLayout(2,4));
//editPanel.setBorder(BorderFactory.createTitledBorder("Column Editor -- Fields with red text are non-editable"));
editPanel3.setBackground(new Color(0,150,255));
c.gridy++;
JLabel locationIdLabel = new JLabel("Location ID");
JLabel watsupMethodLabel = new JLabel("Wat Sup Method");
JLabel watsupCoordAgencyLabel = new JLabel("Wat Sup Coord Agency");
JLabel normalLabel = new JLabel("Normal Upd Freq");
JLabel periodReqLabel = new JLabel("Period Req");
JLabel watsupCritLabel = new JLabel("Wat Sup Criteria");
JLabel customerDescLabel = new JLabel("Customer Desc");
JLabel implDateLabel = new JLabel("Implementation Date");
JLabel webDateLabel = new JLabel("Web Date");
JLabel respAgencyLabel = new JLabel("Wat Sup Resp Agency");
locationTextField = new JTextField();
locationTextField.setBackground(new Color(255,175,75));
locationTextField.setForeground(new Color(50,150,50));
locationTextField.setFont(fnt);
locationTextField.setCaretColor(Color.red);
locationTextField.setSize(10,10);
TextTypedActionListener textTypedActionListener = new TextTypedActionListener();
locationTextField.addKeyListener(textTypedActionListener);
implDateTextField = new DateTextField(0, lhvm, "Date Selector", 10, dataServicesGlobals.getMissingRepresentation());
implDateTextField.setBackground(Color.yellow);
implDateTextField.setForeground(new Color(50,150,50));
implDateTextField.setFont(fnt);
implDateTextField.setCaretColor(Color.red);
implDateTextField.setSize(10,10);
webDateTextField = new DateTextField(0, lhvm, "Date Selector", 10, dataServicesGlobals.getMissingRepresentation());
webDateTextField.setBackground(Color.yellow);
webDateTextField.setForeground(new Color(50,150,50));
webDateTextField.setFont(fnt);
webDateTextField.setCaretColor(Color.red);
webDateTextField.setSize(10,10);
customerDescTextField = new JTextField();
customerDescTextField.setBackground(Color.yellow);
customerDescTextField.setForeground(new Color(50,150,50));
customerDescTextField.setFont(fnt);
customerDescTextField.setCaretColor(Color.red);
customerDescTextField.setSize(10,10);
customerDescTextField.addKeyListener(textTypedActionListener);
lhvmRowDataList1 = lhvmDataManager.readDataFromRequiredPeriod();
lhvmRowDataList2 = lhvmDataManager.readDataFromWatsupCriterion();
lhvmRowDataList3 = lhvmDataManager.readDataFromWatsupCoordAgency();
lhvmRowDataList4 = lhvmDataManager.readDataFromFrequencyUpdate();
lhvmRowDataList5 = lhvmDataManager.readDataFromWatsupMethod();
lhvmRowDataList6 = lhvmDataManager.readDataFromRespAgency();
str1 = new String[lhvmRowDataList1.size()];
str2 = new String[lhvmRowDataList2.size()];
str3 = new String[lhvmRowDataList3.size()];
str4 = new String[lhvmRowDataList4.size()];
str5 = new String[lhvmRowDataList5.size()];
str6 = new String[lhvmRowDataList6.size()];
for(int i=0;i<lhvmRowDataList1.size();i++)
{
str1[i] = ((RequiredPeriodJTableRowData) lhvmRowDataList1.get(i)).getRequiredPeriod();
}
for(int i=0;i<lhvmRowDataList2.size();i++)
{
str2[i] = ((WatSupCriterionJTableRowData) lhvmRowDataList2.get(i)).getWatsupCriterion();
}
for(int i=0;i<lhvmRowDataList3.size();i++)
{
str3[i] = ((WatSupCoordAgencyJTableRowData) lhvmRowDataList3.get(i)).getWatsupCoordAgency();
}
for(int i=0;i<lhvmRowDataList4.size();i++)
{
str4[i] = ((FrequencyUpdateJTableRowData) lhvmRowDataList4.get(i)).getFrequencyUpdate();
}
for(int i=0;i<lhvmRowDataList5.size();i++)
{
str5[i] = ((WatSupMethodJTableRowData) lhvmRowDataList5.get(i)).getWatsupMethod();
}
for(int i=0;i<lhvmRowDataList6.size();i++)
{
str6[i] = ((RespAgencyJTableRowData) lhvmRowDataList6.get(i)).getRespAgency();
}
periodReqTextField = new JComboBox(str1);
periodReqTextField.setBackground(new Color(255,175,75));
periodReqTextField.setForeground(new Color(50,150,50));
watsupCritTextField = new JComboBox(str2);
watsupCritTextField.setBackground(new Color(255,175,75));
watsupCritTextField.setForeground(new Color(50,150,50));
watsupCoordAgencyTextField = new JComboBox(str3);
watsupCoordAgencyTextField.setBackground(new Color(255,175,75));
watsupCoordAgencyTextField.setForeground(new Color(50,150,50));
normalTextField = new JComboBox(str4);
normalTextField.setBackground(new Color(255,175,75));
normalTextField.setForeground(new Color(50,150,50));
watsupMethodTextField = new JComboBox(str5);
watsupMethodTextField.setBackground(new Color(255,175,75));
watsupMethodTextField.setForeground(new Color(50,150,50));
respAgencyTextField = new JComboBox(str6);
respAgencyTextField.setBackground(Color.yellow);
respAgencyTextField.setForeground(new Color(50,150,50));
editPanel.add(locationIdLabel);
editPanel.add(watsupMethodLabel);
editPanel.add(watsupCoordAgencyLabel);
editPanel2.add(normalLabel);
editPanel2.add(periodReqLabel);
editPanel2.add(watsupCritLabel);
editPanel3.add(respAgencyLabel);
editPanel3.add(customerDescLabel);
editPanel3.add(implDateLabel);
editPanel3.add(webDateLabel);
editPanel.add(locationTextField);
editPanel.add(watsupMethodTextField);
editPanel.add(watsupCoordAgencyTextField);
editPanel2.add(normalTextField);
editPanel2.add(periodReqTextField);
editPanel2.add(watsupCritTextField);
editPanel3.add(respAgencyTextField);
editPanel3.add(customerDescTextField);
editPanel3.add(implDateTextField);
editPanel3.add(webDateTextField);
lhvm.getContentPane().add(editPanel,c);
c.gridy++;
c.gridy++;
lhvm.getContentPane().add(editPanel2,c);
c.gridy++;
c.gridy++;
lhvm.getContentPane().add(editPanel3,c);
insertButton = new JButton("Save Record");
insertButton.addActionListener(new SaveActionListener());
deleteButton = new JButton("Delete Record(s)");
deleteButton.addActionListener(new DeleteActionListener());
clearButton = new JButton("Clear");
clearButton.addActionListener(new ClearActionListener());
closeButton = new JButton("Close Window");
closeButton.addActionListener(new CloseActionListener());
//refreshButton = new JButton("Refresh Entries");
//refreshButton.addActionListener(new RefreshActionListener());
insertButton.setEnabled(false);
deleteButton.setEnabled(false);
clearButton.setEnabled(false);
//refreshButton.setEnabled(true);
closeButton.setEnabled(true);
c.gridwidth = 1;
c.gridx = 0;
c.gridy++;
lhvm.getContentPane ().add(insertButton, c);
c.gridx++;
lhvm.getContentPane ().add(deleteButton, c);
c.gridx++;
lhvm.getContentPane ().add(clearButton, c);
//c.gridx++;
//lhvm.getContentPane ().add(refreshButton, c);
c.gridx++;
lhvm.getContentPane ().add(emptyLabel4, c);
c.gridx++;
lhvm.getContentPane ().add(emptyLabel3, c);
//c.gridx++;
//lhvm.getContentPane ().add(emptyLabel5, c);
c.gridx++;
lhvm.getContentPane ().add(closeButton, c);
c.gridwidth = 0;
c.gridx = 0;
c.gridy++;
lhvm.getContentPane ().add(emptyLabel15, c);
c.gridy++;
c.gridy++;
lhvm.getContentPane().add(emptyLabel2, c);
c.gridy++;
lhvm.getContentPane ().add(consoleLabel, c);
c.gridy++;
lhvm.getContentPane().add(scrollableTextAreaForConsole, c);
lhvm.addWindowListener(new ServicesDbWindowAdapter());
lhvm.pack();
//Show the JFrame
lhvm.setVisible (true);
}
private void showCurrentRowData()
{
if(selectedFcstPtWatsupJTableRowData != null)
{
locationTextField.setText(selectedFcstPtWatsupJTableRowData.getDataValue("Location ID"));
implDateTextField.setText(selectedFcstPtWatsupJTableRowData.getDataValue("Implementation Date"));
webDateTextField.setText(selectedFcstPtWatsupJTableRowData.getDataValue("Web Date"));
customerDescTextField.setText(selectedFcstPtWatsupJTableRowData.getDataValue("Customer Desc"));
periodReqTextField.setSelectedItem(selectedFcstPtWatsupJTableRowData.getDataValue("Period Req"));
watsupCritTextField.setSelectedItem(selectedFcstPtWatsupJTableRowData.getDataValue("Wat Sup Criteria"));
watsupCoordAgencyTextField.setSelectedItem(selectedFcstPtWatsupJTableRowData.getDataValue("Wat Sup Coord Agency"));
normalTextField.setSelectedItem(selectedFcstPtWatsupJTableRowData.getDataValue("Normal Upd Freq"));
watsupMethodTextField.setSelectedItem(selectedFcstPtWatsupJTableRowData.getDataValue("Wat Sup Method"));
respAgencyTextField.setSelectedItem(selectedFcstPtWatsupJTableRowData.getDataValue("Wat Sup Resp Agency"));
selectedFcstPtWatsupJTableRowData = null;
activateSaveButton();
activateClearButton();
activateDeleteButton();
}
else
{
clearForm();
}
}
private void deActivateDeleteButton()
{
deleteButton.setEnabled(false);
}
private void deActivateSaveButton()
{
insertButton.setEnabled(false);
}
private void deActivateClearButton()
{
clearButton.setEnabled(false);
}
private void activateDeleteButton()
{
deleteButton.setEnabled(true);
}
private void activateSaveButton()
{
insertButton.setEnabled(true);
}
private void activateClearButton()
{
clearButton.setEnabled(true);
}
private void removeHighlightOfAllRows()
{
int indices[] = new int[lhvmRowDataList.size()];
for(int i=0;i<lhvmRowDataList.size();i++)
{
indices[i] = i;
}
jtm.deselectRows(indices);
}
private void clearForm()
{
locationTextField.setText("");
implDateTextField.setText("yyyy-mm-dd");
webDateTextField.setText("yyyy-mm-dd");
customerDescTextField.setText("");
}
public void buttonsActivateWhenKeysTyped()
{
if(customerDescTextField.getText().length() > 0)
{
activateClearButton();
}
else
{
deActivateClearButton();
}
if(locationTextField.getText().length() > 0)
{
activateSaveButton();
activateClearButton();
}
else
{
deActivateSaveButton();
}
}
public void buttonsActivateWhenSearched()
{
if(selectedFcstPtWatsupJTableRowsDataList != null && selectedFcstPtWatsupJTableRowsDataList.size() < 1)
{
deActivateDeleteButton();
deActivateSaveButton();
deActivateClearButton();
clearForm();
}
else if(selectedFcstPtWatsupJTableRowsDataList != null && selectedFcstPtWatsupJTableRowsDataList.size() == 1)
{
selectedFcstPtWatsupJTableRowData = (FcstPtWatSupJTableRowData) selectedFcstPtWatsupJTableRowsDataList.get(0);
showCurrentRowData();
activateDeleteButton();
activateSaveButton();
activateClearButton();
}
else if(selectedFcstPtWatsupJTableRowsDataList != null && selectedFcstPtWatsupJTableRowsDataList.size() > 1)
{
activateDeleteButton();
deActivateSaveButton();
deActivateClearButton();
clearForm();
}
}
public void buttonsActivateWhenSelected()
{
getSelectedRows();
if(selectedFcstPtWatsupJTableRowsDataList.size() < 1)
{
deActivateDeleteButton();
deActivateSaveButton();
deActivateClearButton();
clearForm();
}
else if(selectedFcstPtWatsupJTableRowsDataList.size() == 1)
{
selectedFcstPtWatsupJTableRowData = (FcstPtWatSupJTableRowData) selectedFcstPtWatsupJTableRowsDataList.get(0);
showCurrentRowData();
activateDeleteButton();
activateSaveButton();
activateClearButton();
}
else if(selectedFcstPtWatsupJTableRowsDataList.size() > 1)
{
activateDeleteButton();
deActivateSaveButton();
deActivateClearButton();
clearForm();
}
}
private void getSelectedRows()
{
selectedFcstPtWatsupJTableRowsDataList = (ArrayList) jtm.getSelectedRowsData();
}
private void operationCloseWindow()
{
if(dataServicesGlobals.getCount() <= 1)
{
lhvm.dispose();
// System.exit(0);
}
else
{
dataServicesGlobals.decrementCount();
lhvm.dispose();
}
}
private class SaveActionListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
int[] rowIndex = new int[1];
String currentLidFromRowsInsideLoop = null;
String currentwatsupMethodFromRowsInsideLoop = null;
String currentwatsupCoordAgencyFromRowsInsideLoop = null;
String currentNormalFromRowsInsideLoop = null;
String currentPeriodReqFromRowsInsideLoop = null;
String currentWatsupCritFromRowsInsideLoop = null;
int i, null_or_not = 0;
rowIndex[0] = -1;
FcstPtWatSupRecord record = new FcstPtWatSupRecord();
record.setLid(locationTextField.getText().toUpperCase());
Object[] options = { "YES", "NO" };
if(!implDateTextField.getText().equalsIgnoreCase("yyyy-mm-dd") && !implDateTextField.getText().equalsIgnoreCase(dataServicesGlobals.getMissingRepresentation()))
{
record.setImpl_date(DbTimeHelper.getLongTimeFromDateString(implDateTextField.getText()));
}
else
{
null_or_not = 1;
record.setImpl_date(Long.MIN_VALUE);
}
if(!webDateTextField.getText().equalsIgnoreCase("yyyy-mm-dd") && !webDateTextField.getText().equalsIgnoreCase(dataServicesGlobals.getMissingRepresentation()))
{
record.setWeb_date(DbTimeHelper.getLongTimeFromDateString(webDateTextField.getText()));
}
else
{
null_or_not = 1;
record.setWeb_date(Long.MIN_VALUE);
}
if(customerDescTextField.getText().length() > 0 && !customerDescTextField.getText().equals(lhvmDataManager.getMissingRepresentation()))
{
record.setCustomer_desc(customerDescTextField.getText());
}
else
{
null_or_not = 1;
}
if(null_or_not == 1)
{
int yes_or_no = JOptionPane.showOptionDialog(null, "At least one field has no value defined...continue??", "Not All Fields Defined!", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE,null, options, options[1]);
if(yes_or_no == JOptionPane.NO_OPTION)
{
return;
}
null_or_not = 0;
}
record.setFrequpd_normal(str4[normalTextField.getSelectedIndex()]);
record.setWatsup_method(str5[watsupMethodTextField.getSelectedIndex()]);
record.setWatsup_coord_agency(str3[watsupCoordAgencyTextField.getSelectedIndex()]);
record.setWatsup_crit(str2[watsupCritTextField.getSelectedIndex()]);
record.setPeriod_req(str1[periodReqTextField.getSelectedIndex()]);
record.setWatsup_resp_agency(str6[respAgencyTextField.getSelectedIndex()]);
// lhvmLogger.log(" Delete record"+ record.toString());
LhvmDataManager.databaseMessage = null;
int success = lhvmDataManager.insertOrUpdateWatsupTable(record);
if(success != -1)
{
appendToConsoleMessageInsert(locationTextField.getText());
}
else
{
JOptionPane.showMessageDialog(null, "Oops: Problem inserting, please check console");
setDatabaseMessage();
}
lhvmRowDataList = lhvmDataManager.readDataFromPtWatsup();
jtm.setChangedAllRowDataList(lhvmRowDataList);
numRows = lhvmRowDataList.size();
numRowsLabel.setText(numRows + " Rows");
jtm.refreshDisplay();
for(i=0;i<lhvmRowDataList.size();i++)
{
FcstPtWatSupJTableRowData rowData = (FcstPtWatSupJTableRowData) lhvmRowDataList.get(i);
currentLidFromRowsInsideLoop = rowData.getLid();
currentwatsupMethodFromRowsInsideLoop = rowData.getWatsupMethod();
currentwatsupCoordAgencyFromRowsInsideLoop = rowData.getWatsupCoordAgency();
currentNormalFromRowsInsideLoop = rowData.getNormal();
currentPeriodReqFromRowsInsideLoop = rowData.getPeriodReq();
currentWatsupCritFromRowsInsideLoop = rowData.getWatsupCrit();
if(locationTextField.getText().equalsIgnoreCase(currentLidFromRowsInsideLoop) &&
str5[watsupMethodTextField.getSelectedIndex()].equalsIgnoreCase(currentwatsupMethodFromRowsInsideLoop) &&
str3[watsupCoordAgencyTextField.getSelectedIndex()].equalsIgnoreCase(currentwatsupCoordAgencyFromRowsInsideLoop) &&
str4[normalTextField.getSelectedIndex()].equalsIgnoreCase(currentNormalFromRowsInsideLoop) &&
str1[periodReqTextField.getSelectedIndex()].equalsIgnoreCase(currentPeriodReqFromRowsInsideLoop) &&
str2[watsupCritTextField.getSelectedIndex()].equalsIgnoreCase(currentWatsupCritFromRowsInsideLoop))
{
rowIndex[0] = i;
break;
}
}
jtm.selectRows(rowIndex[0], rowIndex[0]);
letKnowOfChanges();
}
}
private class RefreshActionListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
lhvmRowDataList = lhvmDataManager.readDataFromPtWatsup();
jtm.setChangedAllRowDataList(lhvmRowDataList);
jtm.refreshDisplay();
deActivateDeleteButton();
deActivateClearButton();
deActivateSaveButton();
clearForm();
numRows = lhvmRowDataList.size();
numRowsLabel.setText(numRows + " Rows");
}
}
private class DeleteActionListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
int i, size;
origNumRows = lhvmRowDataList.size();
size = selectedFcstPtWatsupJTableRowsDataList.size();
Object[] options = { "YES", "NO" };
int yes_or_no = JOptionPane.showOptionDialog(null, "Are you sure to delete row(s)?", "About To Delete Rows!", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE,null, options, options[1]);
if(yes_or_no == JOptionPane.NO_OPTION)
{
return;
}
else
{
for(i=0;i<size;i++)
{
FcstPtWatSupRecord record = new FcstPtWatSupRecord();
String lid = ((FcstPtWatSupJTableRowData)selectedFcstPtWatsupJTableRowsDataList.get(i)).getLid();
record.setLid(lid);
record.setWatsup_method(((FcstPtWatSupJTableRowData)selectedFcstPtWatsupJTableRowsDataList.get(i)).getWatsupMethod());
record.setWatsup_coord_agency(((FcstPtWatSupJTableRowData)selectedFcstPtWatsupJTableRowsDataList.get(i)).getWatsupCoordAgency());
record.setFrequpd_normal(((FcstPtWatSupJTableRowData)selectedFcstPtWatsupJTableRowsDataList.get(i)).getNormal());
record.setPeriod_req(((FcstPtWatSupJTableRowData)selectedFcstPtWatsupJTableRowsDataList.get(i)).getPeriodReq());
record.setWatsup_crit(((FcstPtWatSupJTableRowData)selectedFcstPtWatsupJTableRowsDataList.get(i)).getWatsupCrit());
//lhvmLogger.log(" Delete record"+ record.toString());
LhvmDataManager.databaseMessage = null;
int success = lhvmDataManager.deleteFromWatsupTable(record);
if(success != -1)
{
appendToConsoleMessage(lid);
}
else
{
JOptionPane.showMessageDialog(null, "Oops: Some or all of the rows could not be deleted, please check console");
setDatabaseMessage();
}
}
}
lhvmRowDataList = lhvmDataManager.readDataFromPtWatsup();
jtm.setChangedAllRowDataList(lhvmRowDataList);
jtm.refreshDisplay();
deActivateDeleteButton();
deActivateSaveButton();
deActivateClearButton();
clearForm();
numRows = lhvmRowDataList.size();
numRowsLabel.setText(numRows + " Rows");
if(numRows < origNumRows)
{
JOptionPane.showMessageDialog(null, "Rows deleted, please check console");
}
origNumRows = numRows;
letKnowOfChanges();
}
}
private class CloseActionListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
operationCloseWindow();
}
}
private class ClearActionListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
clearForm();
removeHighlightOfAllRows();
deActivateSaveButton();
deActivateDeleteButton();
deActivateClearButton();
}
}
private class TextTypedActionListener implements KeyListener
{
public void keyTyped(KeyEvent e)
{
}
public void keyPressed(KeyEvent e)
{
}
public void keyReleased(KeyEvent e)
{
buttonsActivateWhenKeysTyped();
}
}
private class DetermTableViewListSelectListener implements ListSelectionListener
{
public void valueChanged(ListSelectionEvent e)
{
buttonsActivateWhenSelected();
}
}
private class SearchTextTypedActionListener implements KeyListener
{
String currentLidFromRowsInsideLoop;
int[] rowIndices;
int index;
public void init()
{
index = -1;
rowIndices = new int[lhvmRowDataList.size()];
for(int i=0;i<lhvmRowDataList.size();i++)
{
rowIndices[i] = -1;
}
}
public void keyTyped(KeyEvent e)
{
}
public void keyPressed(KeyEvent e)
{
}
public void keyReleased(KeyEvent e)
{
removeHighlightOfAllRows();
ArrayList searchList = new ArrayList();
String typedText = stationSearchTextField.getText();
init();
if(typedText.length() > 0 && lhvmRowDataList.size() > 0)
{
int count = 0, i;
for(i=0;i<lhvmRowDataList.size();i++)
{
currentLidFromRowsInsideLoop = ((FcstPtWatSupJTableRowData) lhvmRowDataList.get(i)).getLid();
if((typedText.length() <= currentLidFromRowsInsideLoop.length()) && typedText.equalsIgnoreCase(currentLidFromRowsInsideLoop.substring(0, typedText.length())))
{
searchList.add(lhvmRowDataList.get(i));
rowIndices[count++] = i;
}
}
}
else
{
jtm.selectRows(0, 0);
clearForm();
removeHighlightOfAllRows();
deActivateSaveButton();
deActivateDeleteButton();
deActivateClearButton();
return;
}
selectedFcstPtWatsupJTableRowsDataList = searchList;
buttonsActivateWhenSelected();
for(int i=0;i<rowIndices.length;i++)
{
if(rowIndices[i] == -1)
{
break;
}
index++;
}
if(index != -1)
{
//jtm.highlightRows(rowIndices[0], rowIndices[index]);
jtm.deselectRows(rowIndices);
}
}
}
}

View file

@ -1,59 +0,0 @@
package ohd.hseb.fcstservice;
import ohd.hseb.util.gui.jtable.AbstractJTableRowData;
import ohd.hseb.util.gui.jtable.BaseTableCell;
import ohd.hseb.util.gui.jtable.CellType;
public class FcstGenMethodJTableRowData extends AbstractJTableRowData
{
private String genMethod;
private String missingRep = null;
public FcstGenMethodJTableRowData()
{
}
public FcstGenMethodJTableRowData(String missingRepresentation)
{
//setMissingRepresentation(missingRepresentation);
missingRep = missingRepresentation;
}
/* public String toString()
{
String str = getGenMethod();
return str;
}
public int compare(String columnName, JTableRowData rowData)
{
int ret = 0;
FcstGenMethodJTableRowData genMethodRecord = (FcstGenMethodJTableRowData) rowData;
if(columnName.equals("Typical Fcst Gen Method"))
ret = compareStrings(getGenMethod(), genMethodRecord.getGenMethod());
return ret;
}
public String getDataValue(String columnName)
{
String dataValue = null;
if(columnName.equals("Typical Fcst Gen Method"))
dataValue = getStringValue(getGenMethod());
return dataValue;
}
*/
public void addAllCellsToMap()
{
addCell(new BaseTableCell("Typical Fcst Gen Method", CellType.STRING, getGenMethod(), missingRep));
}
public String getGenMethod() {
return genMethod;
}
public void setGenMethod(String genMethod) {
this.genMethod = genMethod;
}
}

View file

@ -1,57 +0,0 @@
package ohd.hseb.fcstservice;
import ohd.hseb.util.gui.jtable.AbstractJTableRowData;
import ohd.hseb.util.gui.jtable.BaseTableCell;
import ohd.hseb.util.gui.jtable.CellType;
public class FcstHorizonJTableRowData extends AbstractJTableRowData
{
private String fcstHorizon;
private String missingRep = null;
public FcstHorizonJTableRowData()
{
}
public FcstHorizonJTableRowData(String missingRepresentation)
{
//setMissingRepresentation(missingRepresentation);
missingRep = missingRepresentation;
}
/* public String toString()
{
String str = getFcstHorizon();
return str;
}
public int compare(String columnName, JTableRowData rowData)
{
int ret = 0;
FcstHorizonJTableRowData fcstHorizonRecord = (FcstHorizonJTableRowData) rowData;
if(columnName.equals("Horizon"))
ret = compareStrings(getFcstHorizon(), fcstHorizonRecord.getFcstHorizon());
return ret;
}
public String getDataValue(String columnName)
{
String dataValue = null;
if(columnName.equals("Horizon"))
dataValue = getStringValue(getFcstHorizon());
return dataValue;
}
*/
public void addAllCellsToMap()
{
addCell(new BaseTableCell("Horizon", CellType.STRING, getFcstHorizon(), missingRep));
}
public String getFcstHorizon() {
return fcstHorizon;
}
public void setFcstHorizon(String fcstHorizon) {
this.fcstHorizon = fcstHorizon;
}
}

View file

@ -1,362 +0,0 @@
package ohd.hseb.fcstservice;
import ohd.hseb.util.gui.jtable.AbstractJTableRowData;
import ohd.hseb.util.gui.jtable.BaseTableCell;
import ohd.hseb.util.gui.jtable.CellType;
public class FcstPtDetermJTableRowData extends AbstractJTableRowData {
private String lid;
private long implDate;
private long webDate;
private String snowMethod;
private String hydrolMethod;
private String hydraulMethod;
private String issueCriteria;
private String normal;
private String flood;
private String draught;
private String horizon;
private int qpf;
private int qtf;
private int qzf;
private String upstreamSeg;
private String reservoirModel;
private String genMethod;
private String consumptiveUse;
private String channelLoss;
private int numElevZones;
public FcstPtDetermJTableRowData() {
}
public FcstPtDetermJTableRowData(String missingRepresentation) {
setMissingRepresentation(missingRepresentation);
}
/*
* public String toString() { String str = getLid()+" "+ getImplDate()+" "+
* getWebDate()+" "+ getSnowMethod()+" "+ getDraught()+" "+ getFlood()+" "+
* getNormal()+" "+ getHorizon()+" "+ getHydraulMethod()+" "+
* getHydrolMethod()+" "+ getIssueCriteria()+" "+ getQpf()+" "+ getQtf()+" "+
* getQzf()+" "+ getUpstreamSeg()+" "+ getReservoirModel()+" "+ getGenMethod()+" "+
* getConsumptiveUse()+" "+ getChannelLoss()+" "+ getNumElevZones(); return str; }
*
* public String getDataValue(String columnName) { String dataValue = null;
* if(columnName.equals("Location ID")) dataValue = getStringValue(getLid());
* else if (columnName.equals("Implementation Date")) dataValue =
* getStringValue(getImplDate()); else if (columnName.equals("Web Date"))
* dataValue = getStringValue(getWebDate()); else if (columnName.equals("Snow
* Method")) dataValue = getStringValue(getSnowMethod()); else
* if(columnName.equals("Hydrologic Method")) dataValue =
* getStringValue(getHydrolMethod()); else if (columnName.equals("Routing
* Method")) dataValue = getStringValue(getHydraulMethod()); else if
* (columnName.equals("Def Issue Criteria")) dataValue =
* getStringValue(getIssueCriteria()); else if(columnName.equals("Normal Upd
* Freq")) dataValue = getStringValue(getNormal()); else
* if(columnName.equals("Flood Upd Freq")) dataValue =
* getStringValue(getFlood()); else if (columnName.equals("Drought Upd Freq"))
* dataValue = getStringValue(getDraught()); else if
* (columnName.equals("Forecast Period")) dataValue =
* getStringValue(getHorizon()); else if(columnName.equals("Qpf(hours)"))
* dataValue = getStringValue(getQpf()); else if
* (columnName.equals("Qtf(hours)")) dataValue = getStringValue(getQtf()); else
* if (columnName.equals("Qzf(hours)")) dataValue = getStringValue(getQzf());
* else if(columnName.equals("Upstream Segment")) dataValue =
* getStringValue(getUpstreamSeg()); else if (columnName.equals("Reservoir
* Model")) dataValue = getStringValue(getReservoirModel()); else if
* (columnName.equals("Typical Fcst Gen Method")) dataValue =
* getStringValue(getGenMethod()); else if(columnName.equals("Consumptive Use"))
* dataValue = getStringValue(getConsumptiveUse()); else if
* (columnName.equals("Channel Loss")) dataValue =
* getStringValue(getChannelLoss()); else if (columnName.equals("Num Elev
* Zones")) dataValue = getStringValue(getNumElevZones()); return dataValue; }
*
* public void setFcstPtDetermJTableRecord(FcstPtDetermRecord
* fcstPtDetermRecord) { setLid(fcstPtDetermRecord.getLid());
* setUpstreamSeg(fcstPtDetermRecord.getUpstream_seg());
* setReservoirModel(fcstPtDetermRecord.getReservoir_model());
* setGenMethod(fcstPtDetermRecord.getFcst_gen_method());
* setConsumptiveUse(fcstPtDetermRecord.getConsumptive_use());
* setChannelLoss(fcstPtDetermRecord.getChannel_loss()); Long val = new
* Long(fcstPtDetermRecord.getImpl_date()); setImplDate(val.toString()); val =
* new Long(fcstPtDetermRecord.getWeb_date()); setWebDate(val.toString());
* setSnowMethod(fcstPtDetermRecord.getSnow_method()); Integer int1 = new
* Integer(fcstPtDetermRecord.getFrequpd_flood()); setFlood(int1.toString());
* int1 = new Integer(fcstPtDetermRecord.getFrequpd_normal());
* setNormal(int1.toString()); int1 = new
* Integer(fcstPtDetermRecord.getFrequpd_drought());
* setDraught(int1.toString());
* setHydraulMethod(fcstPtDetermRecord.getHydraul_method());
* setHydrolMethod(fcstPtDetermRecord.getHydrol_method());
* setIssueCriteria(fcstPtDetermRecord.getDef_issue_crit()); int1 = new
* Integer(fcstPtDetermRecord.getFcst_horizon()); setHorizon(int1.toString());
* int1 = new Integer(fcstPtDetermRecord.getHours_qpf());
* setQpf(int1.toString()); int1 = new
* Integer(fcstPtDetermRecord.getHours_qtf()); setQtf(int1.toString()); int1 =
* new Integer(fcstPtDetermRecord.getHours_qzf()); setQzf(int1.toString()); int1 =
* new Integer(fcstPtDetermRecord.getNum_elev_zones());
* setNumElevZones(int1.toString()); }
*
* public int compare(String columnName, JTableRowData rowData) { int ret = 0;
* FcstPtDetermJTableRowData fcstPtdetermRecord = (FcstPtDetermJTableRowData)
* rowData; if(columnName.equals("Location ID")) ret = compareStrings(getLid(),
* fcstPtdetermRecord.getLid()); else if (columnName.equals("Implementation
* Date")) ret = compareStrings(getImplDate(),
* fcstPtdetermRecord.getImplDate()); else if (columnName.equals("Web Date"))
* ret = compareStrings(getWebDate(), fcstPtdetermRecord.getWebDate()); else if
* (columnName.equals("Snow Method")) ret = compareStrings(getSnowMethod(),
* fcstPtdetermRecord.getSnowMethod()); else if(columnName.equals("Hydrologic
* Method")) ret = compareStrings(getHydrolMethod(),
* fcstPtdetermRecord.getHydrolMethod()); else if (columnName.equals("Routing
* Method")) ret = compareStrings(getHydraulMethod(),
* fcstPtdetermRecord.getHydraulMethod()); else if (columnName.equals("Def Issue
* Criteria")) ret = compareStrings(getIssueCriteria(),
* fcstPtdetermRecord.getIssueCriteria()); else if(columnName.equals("Normal Upd
* Freq")) ret = compareStrings(getNormal(), fcstPtdetermRecord.getNormal());
* else if(columnName.equals("Flood Upd Freq")) ret = compareStrings(getFlood(),
* fcstPtdetermRecord.getFlood()); else if (columnName.equals("Drought Upd
* Freq")) ret = compareStrings(getDraught(), fcstPtdetermRecord.getDraught());
* else if (columnName.equals("Forecast Period")) ret =
* compareStrings(getHorizon(), fcstPtdetermRecord.getHorizon()); else
* if(columnName.equals("Qpf(hours)")) ret = compareStrings(getQpf(),
* fcstPtdetermRecord.getQpf()); else if (columnName.equals("Qtf(hours)")) ret =
* compareStrings(getQtf(), fcstPtdetermRecord.getQtf()); else if
* (columnName.equals("Qzf(hours)")) ret = compareStrings(getQzf(),
* fcstPtdetermRecord.getQzf()); else if(columnName.equals("Upstream Segment"))
* ret = compareStrings(getUpstreamSeg(), fcstPtdetermRecord.getUpstreamSeg());
* else if (columnName.equals("Reservoir Model")) ret =
* compareStrings(getReservoirModel(), fcstPtdetermRecord.getReservoirModel());
* else if (columnName.equals("Typical Fcst Gen Method")) ret =
* compareStrings(getGenMethod(), fcstPtdetermRecord.getGenMethod()); else
* if(columnName.equals("Consumptive Use")) ret =
* compareStrings(getConsumptiveUse(), fcstPtdetermRecord.getConsumptiveUse());
* else if (columnName.equals("Channel Loss")) ret =
* compareStrings(getChannelLoss(), fcstPtdetermRecord.getChannelLoss()); else
* if (columnName.equals("Num Elev Zones")) ret =
* compareStrings(getNumElevZones(), fcstPtdetermRecord.getNumElevZones());
* return ret; }
*/
public void addAllCellsToMap() {
addCell(new BaseTableCell("Location ID", CellType.STRING, getLid(),
getMissingRepresentation()));
addCell(new BaseTableCell("Implementation Date", CellType.DATE,
getImplDate(), getMissingRepresentation()));
addCell(new BaseTableCell("Web Date", CellType.DATE, getWebDate(),
getMissingRepresentation()));
addCell(new BaseTableCell("Hydrologic Method", CellType.STRING,
getHydrolMethod(), getMissingRepresentation()));
addCell(new BaseTableCell("Snow Method", CellType.STRING,
getSnowMethod(), getMissingRepresentation()));
addCell(new BaseTableCell("Routing Method", CellType.STRING,
getHydraulMethod(), getMissingRepresentation()));
addCell(new BaseTableCell("Def Issue Criteria", CellType.STRING,
getIssueCriteria(), getMissingRepresentation()));
addCell(new BaseTableCell("Qpf(hours)", CellType.INTEGER, getQpf(),
getMissingRepresentation()));
addCell(new BaseTableCell("Upstream Segment", CellType.STRING,
getUpstreamSeg(), getMissingRepresentation()));
addCell(new BaseTableCell("Reservoir Model", CellType.STRING,
getReservoirModel(), getMissingRepresentation()));
addCell(new BaseTableCell("Normal Upd Freq", CellType.STRING,
getNormal(), getMissingRepresentation()));
addCell(new BaseTableCell("Flood Upd Freq", CellType.STRING,
getFlood(), getMissingRepresentation()));
addCell(new BaseTableCell("Drought Upd Freq", CellType.STRING,
getDraught(), getMissingRepresentation()));
addCell(new BaseTableCell("Forecast Period", CellType.STRING,
getHorizon(), getMissingRepresentation()));
addCell(new BaseTableCell("Typical Fcst Gen Method", CellType.STRING,
getGenMethod(), getMissingRepresentation()));
addCell(new BaseTableCell("Consumptive Use", CellType.STRING,
getConsumptiveUse(), getMissingRepresentation()));
addCell(new BaseTableCell("Qtf(hours)", CellType.INTEGER, getQtf(),
getMissingRepresentation()));
addCell(new BaseTableCell("Qzf(hours)", CellType.INTEGER, getQzf(),
getMissingRepresentation()));
addCell(new BaseTableCell("Channel Loss", CellType.STRING,
getChannelLoss(), getMissingRepresentation()));
addCell(new BaseTableCell("Num Elev Zones", CellType.INTEGER,
getNumElevZones(), getMissingRepresentation()));
}
public String getChannelLoss() {
return channelLoss;
}
public void setChannelLoss(String channelLoss) {
this.channelLoss = channelLoss;
}
public String getConsumptiveUse() {
return consumptiveUse;
}
public void setConsumptiveUse(String consumptiveUse) {
this.consumptiveUse = consumptiveUse;
}
public String getDraught() {
return draught;
}
public void setDraught(String draught) {
this.draught = draught;
}
public String getFlood() {
return flood;
}
public void setFlood(String flood) {
this.flood = flood;
}
public String getGenMethod() {
return genMethod;
}
public void setGenMethod(String genMethod) {
this.genMethod = genMethod;
}
public String getHorizon() {
return horizon;
}
public void setHorizon(String horizon) {
this.horizon = horizon;
}
public String getHydraulMethod() {
return hydraulMethod;
}
public void setHydraulMethod(String hydraulMethod) {
this.hydraulMethod = hydraulMethod;
}
public String getHydrolMethod() {
return hydrolMethod;
}
public void setHydrolMethod(String hydrolMethod) {
this.hydrolMethod = hydrolMethod;
}
public long getImplDate() {
return implDate;
}
public void setImplDate(long implDate) {
this.implDate = implDate;
}
public String getIssueCriteria() {
return issueCriteria;
}
public void setIssueCriteria(String issueCriteria) {
this.issueCriteria = issueCriteria;
}
public String getLid() {
return lid;
}
public void setLid(String lid) {
this.lid = lid;
}
public String getNormal() {
return normal;
}
public void setNormal(String normal) {
this.normal = normal;
}
public int getNumElevZones() {
return numElevZones;
}
public void setNumElevZones(int numElevZones) {
this.numElevZones = numElevZones;
}
public int getQpf() {
return qpf;
}
public void setQpf(int qpf) {
this.qpf = qpf;
}
public int getQtf() {
return qtf;
}
public void setQtf(int qtf) {
this.qtf = qtf;
}
public int getQzf() {
return qzf;
}
public void setQzf(int qzf) {
this.qzf = qzf;
}
public String getReservoirModel() {
return reservoirModel;
}
public void setReservoirModel(String reservoirModel) {
this.reservoirModel = reservoirModel;
}
public String getSnowMethod() {
return snowMethod;
}
public void setSnowMethod(String snowMethod) {
this.snowMethod = snowMethod;
}
public String getUpstreamSeg() {
return upstreamSeg;
}
public void setUpstreamSeg(String upstreamSeg) {
this.upstreamSeg = upstreamSeg;
}
public long getWebDate() {
return webDate;
}
public void setWebDate(long webDate) {
this.webDate = webDate;
}
}

View file

@ -1,392 +0,0 @@
package ohd.hseb.fcstservice;
import ohd.hseb.util.gui.jtable.AbstractJTableRowData;
import ohd.hseb.util.gui.jtable.BaseTableCell;
import ohd.hseb.util.gui.jtable.CellType;
public class FcstPtEnsembleJTableRowData extends AbstractJTableRowData
{
private String lid;
private long implDate;
private long webDate;
private String snowMethod;
private String hydrolMethod;
private String hydraulMethod;
private String flood;
private String draught;
private String horizon;
private String flowType;
private String fcstType;
private String normal;
private int numMonClim;
private String postProcessing;
private int numDayHyd;
private long externalDate;
private String upstreamSeg;
private String reservoirModel;
private String consumptiveUse;
private String channelLoss;
private int numElevZones;
public FcstPtEnsembleJTableRowData()
{
}
public FcstPtEnsembleJTableRowData(String missingRepresentation)
{
setMissingRepresentation(missingRepresentation);
}
public String getChannelLoss() {
return channelLoss;
}
public void setChannelLoss(String channelLoss) {
this.channelLoss = channelLoss;
}
public String getConsumptiveUse() {
return consumptiveUse;
}
public void setConsumptiveUse(String consumptiveUse) {
this.consumptiveUse = consumptiveUse;
}
public String getDraught() {
return draught;
}
public void setDraught(String draught) {
this.draught = draught;
}
public long getExternalDate() {
return externalDate;
}
public void setExternalDate(long externalDate) {
this.externalDate = externalDate;
}
public String getFcstType() {
return fcstType;
}
public void setFcstType(String fcstType) {
this.fcstType = fcstType;
}
public String getFlood() {
return flood;
}
public void setFlood(String flood) {
this.flood = flood;
}
public String getFlowType() {
return flowType;
}
public void setFlowType(String flowType) {
this.flowType = flowType;
}
public String getHorizon() {
return horizon;
}
public void setHorizon(String horizon) {
this.horizon = horizon;
}
public String getHydraulMethod() {
return hydraulMethod;
}
public void setHydraulMethod(String hydraulMethod) {
this.hydraulMethod = hydraulMethod;
}
public String getHydrolMethod() {
return hydrolMethod;
}
public void setHydrolMethod(String hydrolMethod) {
this.hydrolMethod = hydrolMethod;
}
public long getImplDate() {
return implDate;
}
public void setImplDate(long implDate) {
this.implDate = implDate;
}
public String getLid() {
return lid;
}
public void setLid(String lid) {
this.lid = lid;
}
public String getNormal() {
return normal;
}
public void setNormal(String normal) {
this.normal = normal;
}
public int getNumDayHyd() {
return numDayHyd;
}
public void setNumDayHyd(int numDayHyd) {
this.numDayHyd = numDayHyd;
}
public int getNumElevZones() {
return numElevZones;
}
public void setNumElevZones(int numElevZones) {
this.numElevZones = numElevZones;
}
public int getNumMonClim() {
return numMonClim;
}
public void setNumMonClim(int numMonClim) {
this.numMonClim = numMonClim;
}
public String getPostProcessing() {
return postProcessing;
}
public void setPostProcessing(String postProcessing) {
this.postProcessing = postProcessing;
}
public String getReservoirModel() {
return reservoirModel;
}
public void setReservoirModel(String reservoirModel) {
this.reservoirModel = reservoirModel;
}
public String getSnowMethod() {
return snowMethod;
}
public void setSnowMethod(String snowMethod) {
this.snowMethod = snowMethod;
}
public String getUpstreamSeg() {
return upstreamSeg;
}
public void setUpstreamSeg(String upstreamSeg) {
this.upstreamSeg = upstreamSeg;
}
public long getWebDate() {
return webDate;
}
public void setWebDate(long webDate) {
this.webDate = webDate;
}
/* public String toString()
{
String str = getLid()+" "+
getImplDate()+" "+
getWebDate()+" "+
getSnowMethod()+" "+
getDraught()+" "+
getFlood()+" "+
getHorizon()+" "+
getHydraulMethod()+" "+
getHydrolMethod()+" "+
getFlowType()+" "+
getFcstType()+" "+
getNormal()+" "+
getNumMonClim()+" "+
getPostProcessing()+" "+
getNumDayHyd()+" "+
getExternalDate()+" "+
getUpstreamSeg()+" "+
getReservoirModel()+" "+
getConsumptiveUse()+" "+
getChannelLoss()+" "+
getNumElevZones();
return str;
}
public String getDataValue(String columnName)
{
String dataValue = null;
if(columnName.equals("Location ID"))
dataValue = getStringValue(getLid());
else if (columnName.equals("Implementation Date"))
dataValue = getStringValue(getImplDate());
else if (columnName.equals("Web Date"))
dataValue = getStringValue(getWebDate());
else if (columnName.equals("Snow Method"))
dataValue = getStringValue(getSnowMethod());
else if(columnName.equals("Hydrologic Method"))
dataValue = getStringValue(getHydrolMethod());
else if (columnName.equals("Routing Method"))
dataValue = getStringValue(getHydraulMethod());
else if(columnName.equals("Flood Upd Freq"))
dataValue = getStringValue(getFlood());
else if (columnName.equals("Drought Upd Freq"))
dataValue = getStringValue(getDraught());
else if (columnName.equals("Forecast Period"))
dataValue = getStringValue(getHorizon());
else if (columnName.equals("Flow Type"))
dataValue = getStringValue(getFlowType());
else if(columnName.equals("Fcst Type"))
dataValue = getStringValue(getFcstType());
else if (columnName.equals("Normal Upd Freq"))
dataValue = getStringValue(getNormal());
else if(columnName.equals("Num Mon Clim Fcst"))
dataValue = getStringValue(getNumMonClim());
else if(columnName.equals("Post Processor"))
dataValue = getStringValue(getPostProcessing());
else if (columnName.equals("Num Day Hydromet Fcst"))
dataValue = getStringValue(getNumDayHyd());
else if (columnName.equals("External Date"))
dataValue = getStringValue(getExternalDate());
else if(columnName.equals("Upstream Segment"))
dataValue = getStringValue(getUpstreamSeg());
else if (columnName.equals("Reservoir Model"))
dataValue = getStringValue(getReservoirModel());
else if(columnName.equals("Consumptive Use"))
dataValue = getStringValue(getConsumptiveUse());
else if (columnName.equals("Channel Loss"))
dataValue = getStringValue(getChannelLoss());
else if (columnName.equals("Num Elev Zones"))
dataValue = getStringValue(getNumElevZones());
return dataValue;
}
public void setFcstPtEnsembleJTableRecord(FcstPtESPRecord fcstPtEnsembleRecord)
{
setLid(fcstPtEnsembleRecord.getLid());
setUpstreamSeg(fcstPtEnsembleRecord.getUpstream_seg());
setReservoirModel(fcstPtEnsembleRecord.getReservoir_model());
setConsumptiveUse(fcstPtEnsembleRecord.getConsumptive_use());
setChannelLoss(fcstPtEnsembleRecord.getChannel_loss());
setFlowType(fcstPtEnsembleRecord.getFlowtype());
setFcstType(fcstPtEnsembleRecord.getFcsttype());
setSnowMethod(fcstPtEnsembleRecord.getSnow_method());
setPostProcessing(fcstPtEnsembleRecord.getPost_processor());
Long val = new Long(fcstPtEnsembleRecord.getImpl_date());
setImplDate(val.toString());
val = new Long(fcstPtEnsembleRecord.getWeb_date());
setWebDate(val.toString());
val = new Long(fcstPtEnsembleRecord.getExternal_date());
setExternalDate(val.toString());
Integer int1 = new Integer(fcstPtEnsembleRecord.getFrequpd_flood());
setFlood(int1.toString());
int1 = new Integer(fcstPtEnsembleRecord.getFrequpd_drought());
setNormal(int1.toString());
int1 = new Integer(fcstPtEnsembleRecord.getFrequpd_normal());
setDraught(int1.toString());
setHydraulMethod(fcstPtEnsembleRecord.getHydraul_method());
setHydrolMethod(fcstPtEnsembleRecord.getHydrol_method());
int1 = new Integer(fcstPtEnsembleRecord.getFcst_horizon());
setHorizon(int1.toString());
int1 = new Integer(fcstPtEnsembleRecord.getNummonclim());
setNumMonClim(int1.toString());
int1 = new Integer(fcstPtEnsembleRecord.getNumdayhyd());
setNumDayHyd(int1.toString());
int1 = new Integer(fcstPtEnsembleRecord.getNum_elev_zones());
setNumElevZones(int1.toString());
}
public int compare(String columnName, JTableRowData rowData)
{
int ret = 0;
FcstPtEnsembleJTableRowData fcstPtEnsembleRecord = (FcstPtEnsembleJTableRowData) rowData;
if(columnName.equals("Location ID"))
ret = compareStrings(getLid(), fcstPtEnsembleRecord.getLid());
else if (columnName.equals("Implementation Date"))
ret = compareStrings(getImplDate(), fcstPtEnsembleRecord.getImplDate());
else if (columnName.equals("Web Date"))
ret = compareStrings(getWebDate(), fcstPtEnsembleRecord.getWebDate());
else if (columnName.equals("Snow Method"))
ret = compareStrings(getSnowMethod(), fcstPtEnsembleRecord.getSnowMethod());
else if(columnName.equals("Hydrologic Method"))
ret = compareStrings(getHydrolMethod(), fcstPtEnsembleRecord.getHydrolMethod());
else if (columnName.equals("Routing Method"))
ret = compareStrings(getHydraulMethod(), fcstPtEnsembleRecord.getHydraulMethod());
else if (columnName.equals("External Date"))
ret = compareStrings(getExternalDate(), fcstPtEnsembleRecord.getExternalDate());
else if(columnName.equals("Flood Upd Freq"))
ret = compareStrings(getFlood(), fcstPtEnsembleRecord.getFlood());
else if (columnName.equals("Drought Upd Freq"))
ret = compareStrings(getDraught(), fcstPtEnsembleRecord.getDraught());
else if (columnName.equals("Forecast Period"))
ret = compareStrings(getHorizon(), fcstPtEnsembleRecord.getHorizon());
else if(columnName.equals("Flow Type"))
ret = compareStrings(getFlowType(), fcstPtEnsembleRecord.getFlowType());
else if (columnName.equals("Fcst Type"))
ret = compareStrings(getFcstType(), fcstPtEnsembleRecord.getFcstType());
else if (columnName.equals("Normal Upd Freq"))
ret = compareStrings(getNormal(), fcstPtEnsembleRecord.getNormal());
else if (columnName.equals("Num Mon Clim Fcst"))
ret = compareStrings(getNumMonClim(), fcstPtEnsembleRecord.getNumMonClim());
else if (columnName.equals("Post Processor"))
ret = compareStrings(getPostProcessing(), fcstPtEnsembleRecord.getPostProcessing());
else if (columnName.equals("Num Day Hydromet Fcst"))
ret = compareStrings(getNumDayHyd(), fcstPtEnsembleRecord.getNumDayHyd());
else if(columnName.equals("Upstream Segment"))
ret = compareStrings(getUpstreamSeg(), fcstPtEnsembleRecord.getUpstreamSeg());
else if (columnName.equals("Reservoir Model"))
ret = compareStrings(getReservoirModel(), fcstPtEnsembleRecord.getReservoirModel());
else if(columnName.equals("Consumptive Use"))
ret = compareStrings(getConsumptiveUse(), fcstPtEnsembleRecord.getConsumptiveUse());
else if (columnName.equals("Channel Loss"))
ret = compareStrings(getChannelLoss(), fcstPtEnsembleRecord.getChannelLoss());
else if (columnName.equals("Num Elev Zones"))
ret = compareStrings(getNumElevZones(), fcstPtEnsembleRecord.getNumElevZones());
return ret;
}*/
public void addAllCellsToMap()
{
addCell(new BaseTableCell("Location ID", CellType.STRING, getLid(), getMissingRepresentation()));
addCell(new BaseTableCell("Implementation Date", CellType.DATE, getImplDate(), getMissingRepresentation()));
addCell(new BaseTableCell("Web Date", CellType.DATE, getWebDate(), getMissingRepresentation()));
addCell(new BaseTableCell("Hydrologic Method", CellType.STRING, getHydrolMethod(), getMissingRepresentation()));
addCell(new BaseTableCell("Snow Method", CellType.STRING, getSnowMethod(), getMissingRepresentation()));
addCell(new BaseTableCell("Routing Method", CellType.STRING, getHydraulMethod(), getMissingRepresentation()));
addCell(new BaseTableCell("Upstream Segment", CellType.STRING, getUpstreamSeg(), getMissingRepresentation()));
addCell(new BaseTableCell("Reservoir Model", CellType.STRING, getReservoirModel(), getMissingRepresentation()));
addCell(new BaseTableCell("Normal Upd Freq", CellType.STRING, getNormal(), getMissingRepresentation()));
addCell(new BaseTableCell("Flood Upd Freq", CellType.STRING, getFlood(), getMissingRepresentation()));
addCell(new BaseTableCell("Drought Upd Freq", CellType.STRING, getDraught(), getMissingRepresentation()));
addCell(new BaseTableCell("Forecast Period", CellType.STRING, getHorizon(), getMissingRepresentation()));
addCell(new BaseTableCell("Consumptive Use", CellType.STRING, getConsumptiveUse(), getMissingRepresentation()));
addCell(new BaseTableCell("Channel Loss", CellType.STRING, getChannelLoss(), getMissingRepresentation()));
addCell(new BaseTableCell("Num Elev Zones", CellType.INTEGER, getNumElevZones(), getMissingRepresentation()));
addCell(new BaseTableCell("Num Mon Clim Fcst", CellType.INTEGER, getNumMonClim(), getMissingRepresentation()));
addCell(new BaseTableCell("Num Day Hydromet Fcst", CellType.INTEGER, getNumDayHyd(), getMissingRepresentation()));
addCell(new BaseTableCell("Post Processor", CellType.STRING, getPostProcessing(), getMissingRepresentation()));
addCell(new BaseTableCell("External Date", CellType.DATE, getExternalDate(), getMissingRepresentation()));
addCell(new BaseTableCell("Flow Type", CellType.STRING, getFlowType(), getMissingRepresentation()));
addCell(new BaseTableCell("Fcst Type", CellType.STRING, getFcstType(), getMissingRepresentation()));
}
}

View file

@ -1,185 +0,0 @@
package ohd.hseb.fcstservice;
import ohd.hseb.util.gui.jtable.AbstractJTableRowData;
import ohd.hseb.util.gui.jtable.BaseTableCell;
import ohd.hseb.util.gui.jtable.CellType;
public class FcstPtServiceJTableRowData extends AbstractJTableRowData
{
private String lid;
private long implDate;
private long webDate;
private long startDate;
private long endDate;
private double floodTher;
private int exceedProb;
private String serviceType;
//private String missingRep = null;
public FcstPtServiceJTableRowData()
{
}
/* public void setFcstPtServiceJTableRecord(FcstPtServiceRecord fcstPtServiceRecord)
{
setLid(fcstPtServiceRecord.getLid());
setServiceType(fcstPtServiceRecord.getService_type());
Double val1 = new Double(fcstPtServiceRecord.getFlood_thres());
setFloodTher(val1.toString());
Integer val2 = new Integer(fcstPtServiceRecord.getExceed_prob());
setExceedProb(val2.toString());
Long val = new Long(fcstPtServiceRecord.getImpl_date());
setImplDate(val.toString());
val = new Long(fcstPtServiceRecord.getWeb_date());
setWebDate(val.toString());
val = new Long(fcstPtServiceRecord.getAnal_start_date());
setStartDate(val.toString());
val = new Long(fcstPtServiceRecord.getAnal_end_date());
setEndDate(val.toString());
}
*/
public FcstPtServiceJTableRowData(String missingRepresentation)
{
setMissingRepresentation(missingRepresentation);
//missingRep = missingRepresentation;
}
/* public String toString()
{
String str = getLid()+" "+
getServiceType()+" "+
getFloodTher()+" "+
getExceedProb()+" "+
getImplDate()+" "+
getStartDate()+" "+
getEndDate()+" "+
getWebDate();
return str;
}
public int compare(String columnName, JTableRowData rowData)
{
int ret = 0;
FcstPtServiceJTableRowData fcstPtServiceRecord = (FcstPtServiceJTableRowData) rowData;
if(columnName.equals("Location ID"))
ret = compareStrings(getLid(), fcstPtServiceRecord.getLid());
else if (columnName.equals("Implementation Date"))
ret = compareStrings(getImplDate(), fcstPtServiceRecord.getImplDate());
else if (columnName.equals("Web Date"))
ret = compareStrings(getWebDate(), fcstPtServiceRecord.getWebDate());
else if (columnName.equals("Analysis Start Date"))
ret = compareStrings(getStartDate(), fcstPtServiceRecord.getStartDate());
else if (columnName.equals("Analysis End Date"))
ret = compareStrings(getEndDate(), fcstPtServiceRecord.getEndDate());
else if (columnName.equals("Flood Threshold"))
ret = compareNumbers(Double.parseDouble(getFloodTher()), Double.parseDouble(fcstPtServiceRecord.getFloodTher()));
else if (columnName.equals("Exceed Probability %"))
ret = compareStrings(getExceedProb(), fcstPtServiceRecord.getExceedProb());
else if (columnName.equals("Service Type"))
ret = compareStrings(getServiceType(), fcstPtServiceRecord.getServiceType());
return ret;
}
public String getDataValue(String columnName)
{
String dataValue = null;
if(columnName.equals("Location ID"))
dataValue = getStringValue(getLid());
else if (columnName.equals("Implementation Date"))
dataValue = getStringValue(getImplDate());
else if (columnName.equals("Web Date"))
dataValue = getStringValue(getWebDate());
else if (columnName.equals("Analysis Start Date"))
dataValue = getStringValue(getStartDate());
else if (columnName.equals("Analysis End Date"))
dataValue = getStringValue(getEndDate());
else if (columnName.equals("Flood Threshold"))
dataValue = getStringValue(getFloodTher());
else if (columnName.equals("Exceed Probability %"))
dataValue = getStringValue(getExceedProb());
else if (columnName.equals("Service Type"))
dataValue = getStringValue(getServiceType());
return dataValue;
}
*/
public void addAllCellsToMap()
{
addCell(new BaseTableCell("Location ID", CellType.STRING, getLid(), getMissingRepresentation()));
addCell(new BaseTableCell("Implementation Date", CellType.DATE, getImplDate(), getMissingRepresentation()));
addCell(new BaseTableCell("Web Date", CellType.DATE, getWebDate(), getMissingRepresentation()));
addCell(new BaseTableCell("Analysis Start Date", CellType.DATE, getStartDate(), getMissingRepresentation()));
addCell(new BaseTableCell("Analysis End Date", CellType.DATE, getEndDate(), getMissingRepresentation()));
addCell(new BaseTableCell("Flood Threshold", CellType.DOUBLE, getFloodTher(), getMissingRepresentation()));
addCell(new BaseTableCell("Exceed Probability %", CellType.INTEGER, getExceedProb(), getMissingRepresentation()));
addCell(new BaseTableCell("Service Type", CellType.STRING, getServiceType(), getMissingRepresentation()));
}
public long getEndDate() {
return endDate;
}
public void setEndDate(long endDate) {
this.endDate = endDate;
}
public int getExceedProb() {
return exceedProb;
}
public void setExceedProb(int exceedProb) {
this.exceedProb = exceedProb;
}
public double getFloodTher() {
return floodTher;
}
public void setFloodTher(double floodTher) {
this.floodTher = floodTher;
}
public long getImplDate() {
return implDate;
}
public void setImplDate(long implDate) {
this.implDate = implDate;
}
public String getLid() {
return lid;
}
public void setLid(String lid) {
this.lid = lid;
}
public String getServiceType() {
return serviceType;
}
public void setServiceType(String serviceType) {
this.serviceType = serviceType;
}
public long getStartDate() {
return startDate;
}
public void setStartDate(long startDate) {
this.startDate = startDate;
}
public long getWebDate() {
return webDate;
}
public void setWebDate(long webDate) {
this.webDate = webDate;
}
}

View file

@ -1,206 +0,0 @@
package ohd.hseb.fcstservice;
import ohd.hseb.util.gui.jtable.AbstractJTableRowData;
import ohd.hseb.util.gui.jtable.BaseTableCell;
import ohd.hseb.util.gui.jtable.CellType;
public class FcstPtWatSupJTableRowData extends AbstractJTableRowData
{
private String lid;
private long implDate;
private long webDate;
private String normal;
private String watsupMethod;
private String watsupCoordAgency;
private String periodReq;
private String watsupCrit;
private String customerDesc;
private String respAgency;
public FcstPtWatSupJTableRowData()
{
}
public FcstPtWatSupJTableRowData(String missingRepresentation)
{
setMissingRepresentation(missingRepresentation);
}
public String getCustomerDesc() {
return customerDesc;
}
public void setCustomerDesc(String customerDesc) {
this.customerDesc = customerDesc;
}
public long getImplDate() {
return implDate;
}
public void setImplDate(long implDate) {
this.implDate = implDate;
}
public String getLid() {
return lid;
}
public void setLid(String lid) {
this.lid = lid;
}
public String getNormal() {
return normal;
}
public void setNormal(String normal) {
this.normal = normal;
}
public String getPeriodReq() {
return periodReq;
}
public void setPeriodReq(String periodReq) {
this.periodReq = periodReq;
}
public String getRespAgency() {
return respAgency;
}
public void setRespAgency(String respAgency) {
this.respAgency = respAgency;
}
public String getWatsupCoordAgency() {
return watsupCoordAgency;
}
public void setWatsupCoordAgency(String watsupCoordAgency) {
this.watsupCoordAgency = watsupCoordAgency;
}
public String getWatsupCrit() {
return watsupCrit;
}
public void setWatsupCrit(String watsupCrit) {
this.watsupCrit = watsupCrit;
}
public String getWatsupMethod() {
return watsupMethod;
}
public void setWatsupMethod(String watsupMethod) {
this.watsupMethod = watsupMethod;
}
public long getWebDate() {
return webDate;
}
public void setWebDate(long webDate) {
this.webDate = webDate;
}
/* public String toString()
{
String str = getLid()+" "+
getImplDate()+" "+
getWebDate()+" "+
getNormal()+" "+
getWatsupMethod()+" "+
getWatsupCoordAgency()+" "+
getPeriodReq()+" "+
getWatsupCrit()+" "+
getRespAgency()+" "+
getCustomerDesc();
return str;
}
public String getDataValue(String columnName)
{
String dataValue = null;
if(columnName.equals("Location ID"))
dataValue = getStringValue(getLid());
else if (columnName.equals("Implementation Date"))
dataValue = getStringValue(getImplDate());
else if (columnName.equals("Web Date"))
dataValue = getStringValue(getWebDate());
else if (columnName.equals("Normal Upd Freq"))
dataValue = getStringValue(getNormal());
else if (columnName.equals("Wat Sup Method"))
dataValue = getStringValue(getWatsupMethod());
else if (columnName.equals("Wat Sup Coord Agency"))
dataValue = getStringValue(getWatsupCoordAgency());
else if (columnName.equals("Period Req"))
dataValue = getStringValue(getPeriodReq());
else if (columnName.equals("Wat Sup Criteria"))
dataValue = getStringValue(getWatsupCrit());
else if (columnName.equals("Customer Desc"))
dataValue = getStringValue(getCustomerDesc());
else if (columnName.equals("Wat Sup Resp Agency"))
dataValue = getStringValue(getRespAgency());
return dataValue;
}
public void setFcstPtWatSupJTableRecord(FcstPtWatSupRecord fcstPtWatsupRecord)
{
setLid(fcstPtWatsupRecord.getLid());
Long val = new Long(fcstPtWatsupRecord.getImpl_date());
setImplDate(val.toString());
val = new Long(fcstPtWatsupRecord.getWeb_date());
setWebDate(val.toString());
setNormal(fcstPtWatsupRecord.getFrequpd_normal());
setWatsupMethod(fcstPtWatsupRecord.getWatsup_method());
setWatsupCoordAgency(fcstPtWatsupRecord.getWatsup_coord_agency());
setPeriodReq(fcstPtWatsupRecord.getPeriod_req());
setWatsupCrit(fcstPtWatsupRecord.getWatsup_crit());
setCustomerDesc(fcstPtWatsupRecord.getCustomer_desc());
setRespAgency(fcstPtWatsupRecord.getWatsup_resp_agency());
}
public int compare(String columnName, JTableRowData rowData) //To be changed in all Windows
{
int ret = 0;
FcstPtWatSupJTableRowData fcstPtWatsupRecord = (FcstPtWatSupJTableRowData) rowData;
if(columnName.equals("Location ID"))
ret = compareStrings(getLid(), fcstPtWatsupRecord.getLid());
else if (columnName.equals("Implementation Date"))
ret = compareStrings(getImplDate(), fcstPtWatsupRecord.getImplDate());
else if (columnName.equals("Web Date"))
ret = compareStrings(getWebDate(), fcstPtWatsupRecord.getWebDate());
else if(columnName.equals("Normal Upd Freq"))
ret = compareStrings(getNormal(), fcstPtWatsupRecord.getNormal());
else if (columnName.equals("Wat Sup Method"))
ret = compareStrings(getWatsupMethod(), fcstPtWatsupRecord.getWatsupMethod());
else if (columnName.equals("Wat Sup Coord Agency"))
ret = compareStrings(getWatsupCoordAgency(), fcstPtWatsupRecord.getWatsupCoordAgency());
else if(columnName.equals("Period Req"))
ret = compareStrings(getPeriodReq(), fcstPtWatsupRecord.getPeriodReq());
else if (columnName.equals("Wat Sup Criteria"))
ret = compareStrings(getWatsupCrit(), fcstPtWatsupRecord.getWatsupCrit());
else if (columnName.equals("Customer Desc"))
ret = compareStrings(getCustomerDesc(), fcstPtWatsupRecord.getCustomerDesc());
else if (columnName.equals("Wat Sup Resp Agency"))
ret = compareStrings(getRespAgency(), fcstPtWatsupRecord.getRespAgency());
return ret;
}*/
public void addAllCellsToMap()
{
addCell(new BaseTableCell("Location ID", CellType.STRING, getLid(), getMissingRepresentation()));
addCell(new BaseTableCell("Implementation Date", CellType.DATE, getImplDate(), getMissingRepresentation()));
addCell(new BaseTableCell("Web Date", CellType.DATE, getWebDate(), getMissingRepresentation()));
addCell(new BaseTableCell("Wat Sup Method", CellType.STRING, getWatsupMethod(), getMissingRepresentation()));
addCell(new BaseTableCell("Wat Sup Coord Agency", CellType.STRING, getWatsupCoordAgency(), getMissingRepresentation()));
addCell(new BaseTableCell("Normal Upd Freq", CellType.STRING, getNormal(), getMissingRepresentation()));
addCell(new BaseTableCell("Period Req", CellType.STRING, getPeriodReq(), getMissingRepresentation()));
addCell(new BaseTableCell("Wat Sup Criteria", CellType.STRING, getWatsupCrit(), getMissingRepresentation()));
addCell(new BaseTableCell("Customer Desc", CellType.STRING, getCustomerDesc(), getMissingRepresentation()));
addCell(new BaseTableCell("Wat Sup Resp Agency", CellType.STRING, getRespAgency(), getMissingRepresentation()));
}
}

View file

@ -1,60 +0,0 @@
package ohd.hseb.fcstservice;
import ohd.hseb.util.gui.jtable.AbstractJTableRowData;
import ohd.hseb.util.gui.jtable.BaseTableCell;
import ohd.hseb.util.gui.jtable.CellType;
public class FcstTypeJTableRowData extends AbstractJTableRowData
{
private String fcstType;
private String missingRep = null;
public FcstTypeJTableRowData()
{
}
public FcstTypeJTableRowData(String missingRepresentation)
{
//setMissingRepresentation(missingRepresentation);
missingRep = missingRepresentation;
}
/* public String toString()
{
String str = getFcstType();
return str;
}
public int compare(String columnName, JTableRowData rowData)
{
int ret = 0;
FcstTypeJTableRowData fcstTypeRecord = (FcstTypeJTableRowData) rowData;
if(columnName.equals("Fcst Type"))
ret = compareStrings(getFcstType(), fcstTypeRecord.getFcstType());
return ret;
}
public String getDataValue(String columnName)
{
String dataValue = null;
if(columnName.equals("Fcst Type"))
dataValue = getStringValue(getFcstType());
return dataValue;
}
*/
public void addAllCellsToMap()
{
addCell(new BaseTableCell("Fcst Type", CellType.STRING, getFcstType(), missingRep));
}
public String getFcstType() {
return fcstType;
}
public void setFcstType(String fcstType) {
this.fcstType = fcstType;
}
}

View file

@ -1,60 +0,0 @@
package ohd.hseb.fcstservice;
import ohd.hseb.util.gui.jtable.AbstractJTableRowData;
import ohd.hseb.util.gui.jtable.BaseTableCell;
import ohd.hseb.util.gui.jtable.CellType;
public class FlowTypeJTableRowData extends AbstractJTableRowData
{
private String flowType;
private String missingRep = null;
public FlowTypeJTableRowData()
{
}
public FlowTypeJTableRowData(String missingRepresentation)
{
//setMissingRepresentation(missingRepresentation);
missingRep = missingRepresentation;
}
/* public String toString()
{
String str = getFlowType();
return str;
}
public int compare(String columnName, JTableRowData rowData)
{
int ret = 0;
FlowTypeJTableRowData flowTypeRecord = (FlowTypeJTableRowData) rowData;
if(columnName.equals("Flow Type"))
ret = compareStrings(getFlowType(), flowTypeRecord.getFlowType());
return ret;
}
public String getDataValue(String columnName)
{
String dataValue = null;
if(columnName.equals("Flow Type"))
dataValue = getStringValue(getFlowType());
return dataValue;
}
*/
public void addAllCellsToMap()
{
addCell(new BaseTableCell("Flow Type", CellType.STRING, getFlowType(), missingRep));
}
public String getFlowType() {
return flowType;
}
public void setFlowType(String flowType) {
this.flowType = flowType;
}
}

View file

@ -1,59 +0,0 @@
package ohd.hseb.fcstservice;
import ohd.hseb.util.gui.jtable.AbstractJTableRowData;
import ohd.hseb.util.gui.jtable.BaseTableCell;
import ohd.hseb.util.gui.jtable.CellType;
public class FrequencyUpdateJTableRowData extends AbstractJTableRowData
{
private String frequencyUpdate;
private String missingRep = null;
public FrequencyUpdateJTableRowData()
{
}
public FrequencyUpdateJTableRowData(String missingRepresentation)
{
//setMissingRepresentation(missingRepresentation);
missingRep = missingRepresentation;
}
/* public String toString()
{
String str = getFrequencyUpdate();
return str;
}
public int compare(String columnName, JTableRowData rowData)
{
int ret = 0;
FrequencyUpdateJTableRowData frequencyUpdateMethodRecord = (FrequencyUpdateJTableRowData) rowData;
if(columnName.equals("Frequency Update"))
ret = compareStrings(getFrequencyUpdate(), frequencyUpdateMethodRecord.getFrequencyUpdate());
return ret;
}
public String getDataValue(String columnName)
{
String dataValue = null;
if(columnName.equals("Frequency Update"))
dataValue = getStringValue(getFrequencyUpdate());
return dataValue;
}
*/
public void addAllCellsToMap()
{
addCell(new BaseTableCell("Frequency Update", CellType.STRING, getFrequencyUpdate(), missingRep));
}
public String getFrequencyUpdate() {
return frequencyUpdate;
}
public void setFrequencyUpdate(String frequencyUpdate) {
this.frequencyUpdate = frequencyUpdate;
}
}

View file

@ -1,61 +0,0 @@
package ohd.hseb.fcstservice;
import ohd.hseb.util.gui.jtable.AbstractJTableRowData;
import ohd.hseb.util.gui.jtable.BaseTableCell;
import ohd.hseb.util.gui.jtable.CellType;
public class HydrologicMethodJTableRowData extends AbstractJTableRowData
{
private String hydrologicMethod;
private String missingRep = null;
public HydrologicMethodJTableRowData()
{
}
public HydrologicMethodJTableRowData(String missingRepresentation)
{
//setMissingRepresentation(missingRepresentation);
missingRep = missingRepresentation;
}
/* public String toString()
{
String str = getHydrologicMethod();
return str;
}
public int compare(String columnName, JTableRowData rowData)
{
int ret = 0;
HydrologicMethodJTableRowData hydrologicMethodRecord = (HydrologicMethodJTableRowData) rowData;
if(columnName.equals("Hydrologic Method"))
ret = compareStrings(getHydrologicMethod(), hydrologicMethodRecord.getHydrologicMethod());
return ret;
}
public String getDataValue(String columnName)
{
String dataValue = null;
if(columnName.equals("Hydrologic Method"))
dataValue = getStringValue(getHydrologicMethod());
return dataValue;
}
*/
public void addAllCellsToMap()
{
addCell(new BaseTableCell("Hydrologic Method", CellType.STRING, getHydrologicMethod(), missingRep));
}
public String getHydrologicMethod() {
return hydrologicMethod;
}
public void setHydrologicMethod(String hydrologicMethod) {
this.hydrologicMethod = hydrologicMethod;
}
}

View file

@ -1,58 +0,0 @@
package ohd.hseb.fcstservice;
import ohd.hseb.util.gui.jtable.AbstractJTableRowData;
import ohd.hseb.util.gui.jtable.BaseTableCell;
import ohd.hseb.util.gui.jtable.CellType;
public class IssueCriteriaJTableRowData extends AbstractJTableRowData
{
private String issueCriteria;
private String missingRep = null;
public IssueCriteriaJTableRowData()
{
}
public IssueCriteriaJTableRowData(String missingRepresentation)
{
//setMissingRepresentation(missingRepresentation);
missingRep = missingRepresentation;
}
/* public String toString()
{
String str = getIssueCriteria();
return str;
}
public int compare(String columnName, JTableRowData rowData)
{
int ret = 0;
IssueCriteriaJTableRowData issueCriteriaMethodRecord = (IssueCriteriaJTableRowData) rowData;
if(columnName.equals("Def Issue Criteria"))
ret = compareStrings(getIssueCriteria(), issueCriteriaMethodRecord.getIssueCriteria());
return ret;
}
public String getDataValue(String columnName)
{
String dataValue = null;
if(columnName.equals("Def Issue Criteria"))
dataValue = getStringValue(getIssueCriteria());
return dataValue;
}
*/
public void addAllCellsToMap()
{
addCell(new BaseTableCell("Def Issue Criteria", CellType.STRING, getIssueCriteria(), missingRep));
}
public String getIssueCriteria() {
return issueCriteria;
}
public void setIssueCriteria(String issueCriteria) {
this.issueCriteria = issueCriteria;
}
}

View file

@ -1,725 +0,0 @@
package ohd.hseb.fcstservice;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.util.ArrayList;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.UIManager;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.text.BadLocationException;
import javax.swing.text.Element;
import ohd.hseb.util.gui.WindowResizingManager;
import ohd.hseb.util.gui.jtable.ComplexJTableManager;
import ohd.hseb.util.gui.jtable.JTableColumnDescriptor;
import ohd.hseb.util.gui.jtable.JTableManager;
/**
* @author varmaR
*
*/
public class LhvmApplicationWindow implements Observer
{
private DataServicesGlobals dataServicesGlobals = null;
private java.util.List lhvmRowDataList = null;
private LhvmDataManager lhvmDataManager = null;
private LhvmLogger lhvmLogger = null;
private JTableManager jtm = null;
private ServiceTableViewViewJTableRowData selectedServiceTableViewViewJTableRowData = null;
private ArrayList selectedServiceTableViewViewJTableRowsDataList = null;
private JTextField servicesTableTextField = null;
private JTextField deterministicTableTextField = null;
private JTextField watsupTableTextField = null;
private JTextField ensembleTableTextField = null;
private JButton deleteButton = null;
private JButton closeButton = null;
private JButton refreshButton = null;
private JTextField stationSearchTextField = null;
private JScrollPane tableScrollPane = null;
private JPanel tableScrollPanePanel = null;
private JMenuItem fcstPtServiceItem = null;
private JMenuItem fcstPtWatsUpItem = null;
private JMenuItem fcstPtDetermItem = null;
private JMenuItem fcstPtESPItem = null;
private JMenuItem aboutItem = null;
private JMenuItem closeItem = null;
private JMenuItem fcstRefTablesItem = null;
private JMenu setupTableMenu = null;
private LhvmApplicationWindow lhvmAppWindow = null;
private JFrame lhvm = null;
private int numRows;
private JLabel numRowsLabel = null;
private JTextArea consoleTextArea = null;
private static String jdbcUrl = null;
public void update(Subject sub)
{
if(selectedServiceTableViewViewJTableRowsDataList != null && selectedServiceTableViewViewJTableRowsDataList.size() > 0)
{
selectedServiceTableViewViewJTableRowData = (ServiceTableViewViewJTableRowData) selectedServiceTableViewViewJTableRowsDataList.get(0);
showCurrentRowData();
}
else if(selectedServiceTableViewViewJTableRowsDataList == null)
{
lhvmRowDataList = lhvmDataManager.readDataFromPtServiceView();
jtm.setChangedAllRowDataList(lhvmRowDataList);
jtm.refreshDisplay();
deActivateDeleteButton();
clearForm();
numRows = lhvmRowDataList.size();
numRowsLabel.setText(numRows + " Rows");
}
}
private void appendToConsoleMessage(String lid)
{
String valueToBeSet = new String(consoleTextArea.getText() + "\n" + "Exception getting number of entries from database for lid: " + lid + " ");
consoleTextArea.insert("", 0);
consoleTextArea.insert(valueToBeSet, 0);
}
public LhvmApplicationWindow()
{
lhvmAppWindow = this;
dataServicesGlobals = DataServicesGlobals.getSingleInstanceOfDataServicesGlobals();
dataServicesGlobals.incrementCount();
lhvm = new JFrame("Point Services Database Manager");
lhvm.setSize(1100, 500);
lhvm.setLocation(20,50);
//Fix the dimensions of this window i.e. dis-allow window resizing
Dimension d = new Dimension(1135, 790);
new WindowResizingManager(lhvm, d, d);
lhvm.setResizable(false);
//lhvm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
GridBagLayout gbl = new GridBagLayout();
lhvm.setLayout(gbl);
GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.HORIZONTAL;
JMenuBar menuBar = new JMenuBar();
JMenu fileMenu = new JMenu("File");
menuBar.add(fileMenu);
//JMenuItem importItem = new JMenuItem("Import from file");
//importItem.setEnabled(false);
//JMenuItem exportItem = new JMenuItem("Export to file");
//exportItem.setEnabled(false);
closeItem = new JMenuItem("Close Application");
//closeItem.addActionListener(ActionListener);
//fileMenu.add(importItem);
//fileMenu.add(exportItem);
fileMenu.add(closeItem);
closeItem.addActionListener(new MenuSelectActionListener());
setupTableMenu = new JMenu("Setup");
fcstRefTablesItem = new JMenuItem("RefTables");
fcstRefTablesItem.addActionListener(new MenuSelectActionListener());
//stationsFilterOptionsItem.addActionListener(ActionListener);
setupTableMenu.add(fcstRefTablesItem);
JMenu tablesMenu = new JMenu("ServiceTypes");
menuBar.add(tablesMenu);
menuBar.add(setupTableMenu);
fcstPtServiceItem = new JMenuItem("Data Service");
fcstPtWatsUpItem = new JMenuItem("Water Supply Forecast");
fcstPtDetermItem = new JMenuItem("Deterministic Forecast");
fcstPtESPItem = new JMenuItem("Ensemble Forecast");
fcstPtServiceItem.addActionListener(new MenuSelectActionListener());
fcstPtDetermItem.addActionListener(new MenuSelectActionListener());
fcstPtESPItem.addActionListener(new MenuSelectActionListener());
fcstPtWatsUpItem.addActionListener(new MenuSelectActionListener());
//stationsFilterOptionsItem.addActionListener(ActionListener);
tablesMenu.add(fcstPtServiceItem);
tablesMenu.add(fcstPtWatsUpItem);
tablesMenu.add(fcstPtDetermItem);
tablesMenu.add(fcstPtESPItem);
JMenu aboutMenu = new JMenu("Help");
menuBar.add(aboutMenu);
aboutItem = new JMenuItem("About Forecast Services");
aboutMenu.add(aboutItem);
aboutItem.addActionListener(new MenuSelectActionListener());
// Install the menu bar in the frame
lhvm.setJMenuBar(menuBar);
JLabel consoleLabel = new JLabel("-----Database Messages-----");
consoleLabel.setForeground(Color.red);
consoleTextArea = new JTextArea(2,50);
Font font = new Font("Serif", Font.BOLD, 20);
consoleTextArea.setFont(font);
consoleTextArea.setForeground(Color.green);
consoleTextArea.setBackground(Color.black);
consoleTextArea.setCaretColor(Color.red);
consoleTextArea.setBorder(BorderFactory.createEtchedBorder() );
consoleTextArea.setLineWrap(true);
String[] columnsToBeDisplayed = {"Location ID","Name", "Stream", "State","County","Hsa"};
lhvmLogger = new LhvmLogger();
lhvmDataManager = LhvmDataManager.getSingleInstanceOfDataManager(jdbcUrl, lhvmLogger,dataServicesGlobals.getMissingRepresentation());
java.util.List lhvmColumnDescriptorList = new ArrayList();
lhvmRowDataList = lhvmDataManager.readDataFromPtServiceView();
lhvmColumnDescriptorList.add(new JTableColumnDescriptor("Location ID", true, 150, "center"));
lhvmColumnDescriptorList.add(new JTableColumnDescriptor("Name", true, 250, "center"));
lhvmColumnDescriptorList.add(new JTableColumnDescriptor("Stream", true, 200, "center"));
lhvmColumnDescriptorList.add(new JTableColumnDescriptor("State", true, 125, "center"));
lhvmColumnDescriptorList.add(new JTableColumnDescriptor("County", true, 200, "center"));
lhvmColumnDescriptorList.add(new JTableColumnDescriptor("Hsa", true, 125, "center"));
jtm = new ComplexJTableManager(lhvmColumnDescriptorList, lhvmRowDataList);
jtm.setDisplayableColumns(columnsToBeDisplayed, false, true);
jtm.setPreferredSizeForJScrollPane(new Dimension(1100, 500));
jtm.addTableListener(new ServiceTableViewListSelectListener());
tableScrollPane = jtm.getJScrollPane();
//jtm.setTableToolTipText("str");
tableScrollPanePanel = new JPanel();
tableScrollPanePanel.add(tableScrollPane);
String tempStr = null;
if(LhvmDataManager.displayedMessageLhvmWindow != null)
{
tempStr = new String(LhvmDataManager.displayedMessageLhvmWindow);
}
LhvmDataManager.displayedMessageLhvmWindow = new StringBuffer();
LhvmDataManager.displayedMessageLhvmWindow.append(LhvmDataManager.databaseMessage);
if(tempStr != null)
{
LhvmDataManager.displayedMessageLhvmWindow.append(tempStr);
}
consoleTextArea.insert(new String(LhvmDataManager.displayedMessageLhvmWindow), 0);
// Get paragraph element
Element paragraph = consoleTextArea.getDocument().getDefaultRootElement();
// Get number of content elements
int contentCount = paragraph.getElementCount();
// Get index ranges for each content element.
// Each content element represents one line.
// Each line includes the terminating newline.
for (int i=0; i<contentCount; i++) {
Element e = paragraph.getElement(i);
int rangeStart = e.getStartOffset();
int rangeEnd = e.getEndOffset();
try
{
String line = consoleTextArea.getText(rangeStart,rangeEnd-rangeStart);
} catch (BadLocationException ex) {}
}
JScrollPane scrollableTextAreaForConsole = new JScrollPane(consoleTextArea, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
JLabel emptyLabel1 = new JLabel(" ");//25 spaces
JLabel emptyLabel2 = new JLabel(" ");//25 spaces
JLabel emptyLabel3 = new JLabel(" ");//25 spaces
JLabel emptyLabel4 = new JLabel(" ");//25 spaces
JLabel emptyLabel5 = new JLabel(" ");//25 spaces
JLabel emptyLabel6 = new JLabel(" ");//25 spaces
JLabel emptyLabel7 = new JLabel(" ");//6 spaces
JLabel emptyLabel8 = new JLabel(" ");//25 spaces
JLabel emptyLabel9 = new JLabel(" ");//25 spaces
JLabel emptyLabel10 = new JLabel(" ");//25 spaces
JLabel emptyLabel11 = new JLabel(" ");//25 spaces
JLabel emptyLabel12 = new JLabel(" ");//25 spaces
JLabel emptyLabel13 = new JLabel(" ");//25 spaces
JLabel emptyLabel14 = new JLabel(" ");//25 spaces
JLabel emptyLabel15 = new JLabel(" ");//25 spaces
numRows = lhvmRowDataList.size();
numRowsLabel = new JLabel(numRows + " Rows");
c.gridwidth = 1;
c.gridx = 0;
c.gridy = 0;
lhvm.getContentPane ().add(numRowsLabel, c);
c.gridx++;
//lhvm.getContentPane ().add(emptyLabel8, c);
JLabel stationSearchLabel = new JLabel(" Station Search:");//25 spaces to adjust alignment
c.gridx++;
lhvm.getContentPane ().add(stationSearchLabel, c);
stationSearchTextField = new JTextField(10);
stationSearchTextField.setFocusable(true);
Font fnt = stationSearchTextField.getFont();
fnt = fnt.deriveFont(Font.BOLD, 1.2F*fnt.getSize2D());
stationSearchTextField.setForeground(new Color(50,150,50));
stationSearchTextField.setBackground(Color.yellow);
stationSearchTextField.setFont(fnt);
stationSearchTextField.setCaretColor(Color.red);
stationSearchTextField.addKeyListener(new SearchTextTypedActionListener());
c.gridx++;
lhvm.getContentPane ().add(stationSearchTextField, c);
c.gridx++;
lhvm.getContentPane ().add(emptyLabel1, c);
JButton filterOptionsButton = new JButton("Stations Filter Options");
filterOptionsButton.setEnabled(false);
c.gridx++;
//lhvm.getContentPane ().add(filterOptionsButton, c);
lhvm.getContentPane ().add(emptyLabel6, c);
c.gridy++;
lhvm.getContentPane().add(emptyLabel9, c);
c.gridwidth = 0;
c.gridx = 0;
c.gridy++;
lhvm.getContentPane().add(tableScrollPanePanel,c);
//int[] selectedRowIndices = jtm.getSelectedRowIndices();
JPanel editPanel = new JPanel();
editPanel.setLayout(new GridLayout(2,8));
editPanel.setBorder(BorderFactory.createTitledBorder("Column Editor -- Entries for the selected location in each table"));
editPanel.setBackground(new Color(0,150,255));
c.gridy++;
JLabel servicesTableLabel = new JLabel("Data Services");
JLabel deterministicTableLabel = new JLabel("Deterministic Services");
JLabel watsupTableLabel = new JLabel("Water Supply Services");
JLabel ensembleTableLabel = new JLabel("Ensemble Services");
servicesTableTextField = new JTextField();
servicesTableTextField.setBackground(Color.yellow);
servicesTableTextField.setForeground(Color.red);
servicesTableTextField.setFont(fnt);
servicesTableTextField.setCaretColor(Color.red);
servicesTableTextField.setSize(15,15);
servicesTableTextField.setEditable(false);
deterministicTableTextField = new JTextField();
deterministicTableTextField.setBackground(Color.yellow);
deterministicTableTextField.setForeground(Color.red);
deterministicTableTextField.setFont(fnt);
deterministicTableTextField.setCaretColor(Color.red);
deterministicTableTextField.setSize(15,15);
deterministicTableTextField.setEditable(false);
watsupTableTextField = new JTextField();
watsupTableTextField.setBackground(Color.yellow);
watsupTableTextField.setForeground(Color.red);
watsupTableTextField.setFont(fnt);
watsupTableTextField.setCaretColor(Color.red);
watsupTableTextField.setSize(15,15);
watsupTableTextField.setEditable(false);
ensembleTableTextField = new JTextField();
ensembleTableTextField.setBackground(Color.yellow);
ensembleTableTextField.setForeground(Color.red);
ensembleTableTextField.setFont(fnt);
ensembleTableTextField.setCaretColor(Color.red);
ensembleTableTextField.setSize(15,15);
ensembleTableTextField.setEditable(false);
editPanel.add(servicesTableLabel);
editPanel.add(deterministicTableLabel);
editPanel.add(watsupTableLabel);
editPanel.add(ensembleTableLabel);
editPanel.add(servicesTableTextField);
editPanel.add(deterministicTableTextField);
editPanel.add(watsupTableTextField);
editPanel.add(ensembleTableTextField);
lhvm.getContentPane().add(editPanel,c);
deleteButton = new JButton("Delete Record");
deleteButton.addActionListener(new DeleteActionListener());
closeButton = new JButton("Close Window");
closeButton.addActionListener(new CloseActionListener());
//refreshButton = new JButton("Refresh Entries");
//refreshButton.addActionListener(new RefreshActionListener());
deleteButton.setEnabled(false);
closeButton.setEnabled(true);
//refreshButton.setEnabled(true);
c.gridwidth = 1;
c.gridx = 0;
c.gridy++;
//lhvm.getContentPane ().add(deleteButton, c);
lhvm.getContentPane ().add(emptyLabel7, c);
//c.gridx++;
//lhvm.getContentPane ().add(refreshButton, c);
c.gridx++;
lhvm.getContentPane ().add(emptyLabel3, c);
c.gridx++;
lhvm.getContentPane ().add(emptyLabel13, c);
c.gridx++;
lhvm.getContentPane ().add(emptyLabel4, c);
c.gridx++;
lhvm.getContentPane ().add(emptyLabel5, c);
c.gridx++;
lhvm.getContentPane ().add(closeButton, c);
c.gridwidth = 0;
c.gridx = 0;
c.gridy++;
lhvm.getContentPane ().add(emptyLabel15, c);
c.gridy++;
c.gridy++;
lhvm.getContentPane().add(emptyLabel2, c);
c.gridy++;
lhvm.getContentPane ().add(consoleLabel, c);
c.gridy++;
lhvm.getContentPane().add(scrollableTextAreaForConsole, c);
lhvm.addWindowListener(new ServicesDbWindowAdapter());
lhvm.pack();
//Show the JFrame
lhvm.setVisible (true);
}
private void showCurrentRowData()
{
if(selectedServiceTableViewViewJTableRowData != null)
{
String lid = selectedServiceTableViewViewJTableRowData.getLid();
int numRows = lhvmDataManager.entriesPerLidInDeterm(lid);
if(numRows != -1)
{
deterministicTableTextField.setText(Integer.toString(numRows));
}
else
{
appendToConsoleMessage(lid);
JOptionPane.showMessageDialog(null, "Oops: There was an exception retrieving number of rows from database, please check console");
}
numRows = lhvmDataManager.entriesPerLidInService(lid);
if(numRows != -1)
{
servicesTableTextField.setText(Integer.toString(numRows));
}
else
{
appendToConsoleMessage(lid);
JOptionPane.showMessageDialog(null, "Oops: There was an exception retrieving number of rows from database, please check console");
}
numRows = lhvmDataManager.entriesPerLidInWatsup(lid);
if(numRows != -1)
{
watsupTableTextField.setText(Integer.toString(numRows));
}
else
{
appendToConsoleMessage(lid);
JOptionPane.showMessageDialog(null, "Oops: There was an exception retrieving number of rows from database, please check console");
}
numRows = lhvmDataManager.entriesPerLidInEnsemble(lid);
if(numRows != -1)
{
ensembleTableTextField.setText(Integer.toString(numRows));
}
else
{
appendToConsoleMessage(lid);
JOptionPane.showMessageDialog(null, "Oops: There was an exception retrieving number of rows from database, please check console");
}
selectedServiceTableViewViewJTableRowData = null;
activateDeleteButton();
}
else
{
clearForm();
}
}
private void deActivateDeleteButton()
{
deleteButton.setEnabled(false);
}
private void activateDeleteButton()
{
//deleteButton.setEnabled(true);
}
private void removeHighlightOfAllRows()
{
int indices[] = new int[lhvmRowDataList.size()];
for(int i=0;i<lhvmRowDataList.size();i++)
{
indices[i] = i;
}
jtm.deselectRows(indices);
}
private void clearForm()
{
servicesTableTextField.setText("");
deterministicTableTextField.setText("");
watsupTableTextField.setText("");
ensembleTableTextField.setText("");
}
public void buttonsActivateWhenSearched()
{
if(selectedServiceTableViewViewJTableRowsDataList != null && selectedServiceTableViewViewJTableRowsDataList.size() < 1)
{
deActivateDeleteButton();
clearForm();
}
else if(selectedServiceTableViewViewJTableRowsDataList != null && selectedServiceTableViewViewJTableRowsDataList.size() == 1)
{
selectedServiceTableViewViewJTableRowData = (ServiceTableViewViewJTableRowData) selectedServiceTableViewViewJTableRowsDataList.get(0);
showCurrentRowData();
activateDeleteButton();
}
else if(selectedServiceTableViewViewJTableRowsDataList != null && selectedServiceTableViewViewJTableRowsDataList.size() > 1)
{
activateDeleteButton();
clearForm();
}
}
public void buttonsActivateWhenSelected()
{
getSelectedRows();
if(selectedServiceTableViewViewJTableRowsDataList.size() < 1)
{
deActivateDeleteButton();
clearForm();
}
else if(selectedServiceTableViewViewJTableRowsDataList.size() == 1)
{
selectedServiceTableViewViewJTableRowData = (ServiceTableViewViewJTableRowData) selectedServiceTableViewViewJTableRowsDataList.get(0);
showCurrentRowData();
activateDeleteButton();
}
else if(selectedServiceTableViewViewJTableRowsDataList.size() > 1)
{
activateDeleteButton();
clearForm();
}
}
private void getSelectedRows()
{
selectedServiceTableViewViewJTableRowsDataList = (ArrayList) jtm.getSelectedRowsData();
}
private void operationCloseWindow()
{
if(dataServicesGlobals.getCount() <= 1)
{
lhvm.dispose();
// System.exit(0);
}
else
{
dataServicesGlobals.decrementCount();
lhvm.dispose();
}
}
private class MenuSelectActionListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
if(e.getSource().equals(fcstPtServiceItem))
{
FcstDataServiceWindow fcstDataServiceWindow = new FcstDataServiceWindow(jdbcUrl);
dataServicesGlobals.incrementCount();
fcstDataServiceWindow.addObserver(lhvmAppWindow);
}
else if(e.getSource().equals(fcstPtWatsUpItem))
{
FcstDataWatSupWindow fcstDataWatSupWindow = new FcstDataWatSupWindow(jdbcUrl);
dataServicesGlobals.incrementCount();
fcstDataWatSupWindow.addObserver(lhvmAppWindow);
}
else if(e.getSource().equals(fcstPtDetermItem))
{
FcstDataDetermWindow fcstDataDetermWindow = new FcstDataDetermWindow(jdbcUrl);
dataServicesGlobals.incrementCount();
fcstDataDetermWindow.addObserver(lhvmAppWindow);
}
else if(e.getSource().equals(fcstPtESPItem))
{
FcstDataEnsembleWindow fcstDataEnsembleWindow = new FcstDataEnsembleWindow(jdbcUrl);
dataServicesGlobals.incrementCount();
fcstDataEnsembleWindow.addObserver(lhvmAppWindow);
}
else if(e.getSource().equals(fcstRefTablesItem))
{
new ReferenceTablesWindow(jdbcUrl);
dataServicesGlobals.incrementCount();
}
else if(e.getSource().equals(closeItem))
{
lhvm.dispose();
// System.exit(0);
}
else if(e.getSource().equals(aboutItem))
{
JOptionPane.showMessageDialog(null, "Application: Forecast Services\n\n" +
"Version: Awips Release OB8.3\n\n" + "Date: Jan 2'nd, 2008\n\n" +
"Developed by: National Weather Service,\n Office of Hydrologic development, \n Hydrology Laboratory\n\n",
"Forecast Services", JOptionPane.INFORMATION_MESSAGE);
}
}
}
private class DeleteActionListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
}
}
/* private class RefreshActionListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
lhvmRowDataList = lhvmDataManager.readDataFromPtServiceView();
jtm.setChangedAllRowDataList(lhvmRowDataList);
jtm.refreshDisplay();
deActivateDeleteButton();
clearForm();
numRows = lhvmRowDataList.size();
numRowsLabel.setText(numRows + " Rows");
}
}*/
private class CloseActionListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
operationCloseWindow();
}
}
private class ServiceTableViewListSelectListener implements ListSelectionListener
{
public void valueChanged(ListSelectionEvent e)
{
buttonsActivateWhenSelected();
}
}
private class SearchTextTypedActionListener implements KeyListener
{
String currentLidFromRowsInsideLoop;
int[] rowIndices;
int index;
public void init()
{
index = -1;
rowIndices = new int[lhvmRowDataList.size()];
for(int i=0;i<lhvmRowDataList.size();i++)
{
rowIndices[i] = -1;
}
}
public void keyTyped(KeyEvent e)
{
}
public void keyPressed(KeyEvent e)
{
}
public void keyReleased(KeyEvent e)
{
removeHighlightOfAllRows();
ArrayList searchList = new ArrayList();
String typedText = stationSearchTextField.getText();
init();
if(typedText.length() > 0 && lhvmRowDataList.size() > 0)
{
int count = 0, i;
for(i=0;i<lhvmRowDataList.size();i++)
{
currentLidFromRowsInsideLoop = ((ServiceTableViewViewJTableRowData)lhvmRowDataList.get(i)).getLid();
if((typedText.length() <= currentLidFromRowsInsideLoop.length()) && typedText.equalsIgnoreCase(currentLidFromRowsInsideLoop.substring(0, typedText.length())))
{
searchList.add(lhvmRowDataList.get(i));
rowIndices[count++] = i;
}
}
}
else
{
jtm.selectRows(0, 0);
clearForm();
removeHighlightOfAllRows();
deActivateDeleteButton();
return;
}
selectedServiceTableViewViewJTableRowsDataList = searchList;
buttonsActivateWhenSelected();
for(int i=0;i<rowIndices.length;i++)
{
if(rowIndices[i] == -1)
{
break;
}
index++;
}
if(index != -1)
{
//jtm.highlightRows(rowIndices[0], rowIndices[index]);
jtm.selectRows(rowIndices);
}
}
}
public static void main(String args[])
{
try
{
// UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
}catch(Exception e){}
jdbcUrl = args[0];
new LhvmApplicationWindow();
}
}

View file

@ -1,240 +0,0 @@
package ohd.hseb.fcstservice;
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.TimeZone;
import ohd.hseb.util.Logger;
public class LhvmLogger implements Logger
{
private String _fileName = null;
private OutputStream _outputStream = null;
private PrintWriter _writer = null;
private boolean _usingRealFile = false;
private boolean _fileIsOpen = false;
private int _sessionId;
private static final String dateFormatString =
"yyyyMMdd";
private static final SimpleDateFormat _dateFormatter =
new SimpleDateFormat(dateFormatString);
private static final String timeFormatString =
"HH:mm:ss";
private static final SimpleDateFormat _timeFormatter =
new SimpleDateFormat(timeFormatString);
private boolean _appendDateTime = false;
private boolean _keepFileOpen = true;
private String _messageId;
static
{
_dateFormatter.setTimeZone(TimeZone.getTimeZone("UTC"));
}
public LhvmLogger(String fileName, boolean keepFileOpen, boolean appendDateTime, String messageId)
{
_keepFileOpen = true;
_appendDateTime = true;
_messageId = messageId;
_fileName = fileName;
}
public LhvmLogger()
{
}
public int getSessionId()
{
return _sessionId;
}
public void log(String message)
{
boolean isCreatedNow = false;
if (!isOpen() || message == null)
{
openFile(_fileName, false);
isCreatedNow = true;
_writer = new PrintWriter(_outputStream);
}
else
{
String splitStr[] = _fileName.split("\\.");
String dateTimeStampInFileName = splitStr[2];
if(!(getDateTimeStamp().equalsIgnoreCase(dateTimeStampInFileName)))
{
openFile(_fileName, true);
isCreatedNow = true;
_writer = new PrintWriter(_outputStream);
}
}
if(isCreatedNow)
{
if(_messageId == null)
_messageId = new Integer(_sessionId).toString();
_writer.println(_messageId);
_writer.println("**************************************");
}
if (_appendDateTime)
{
if(message != null)
_writer.println( getTimeStamp() + ": " + message);
}
else
{
if(message != null)
_writer.println(message);
}
_writer.flush();
if (!_keepFileOpen)
{
close();
}
}
private void determineSessionId(String fileName)
{
int sessionId = -1;
String dirName;
int index = fileName.lastIndexOf("/");
dirName = fileName.substring(0, index);
File dir = new File(dirName);
int leastPossibleNumber = 1;
if(dir.exists())
{
if(dir.isDirectory())
{
String files[] = dir.list();
if(files != null)
{
if(files.length == 0)
{
sessionId = 1;
}
else
{
int existingIds[] = new int[files.length];
for(int i=0; i < files.length; i++)
{
String str = files[i];
String splitStr[] = str.split("\\.");
if(splitStr == null)
continue;
else if(splitStr.length != 3)
continue;
else if(!(splitStr[0].equals("RiverMonitor")))
continue;
else if(splitStr[2].length() != 8)
continue;
try
{
existingIds[i] = Integer.parseInt(splitStr[1]);
Integer.parseInt(splitStr[2]);// To make sure the last portion is a data (number)
}
catch(Exception e)
{
continue;
}
}
Arrays.sort(existingIds);
while(true)
{
if(Arrays.binarySearch(existingIds, leastPossibleNumber) < 0)
{
sessionId = leastPossibleNumber;
break;
}
else
leastPossibleNumber++;
}
}
}
}
else
{
System.out.println("RiverMonitorLogger:["+dir+"] isn't a directory");
}
}
else
{
System.out.println("RiverMonitorLogger:Directory ["+dir+"] doesn't exist");
}
_sessionId = sessionId;
}
public PrintWriter getPrintWriter()
{
return _writer;
}
private String getDateTimeStamp()
{
Date date = new Date();
return _dateFormatter.format(date);
}
private String getTimeStamp()
{
Date date = new Date();
return _timeFormatter.format(date);
}
private void openFile(String fileName, boolean isExistingSession)
{
try
{
if (fileName != null)
{
if(!isExistingSession)
{
determineSessionId(_fileName);
}
if(_sessionId != -1)
{
_fileName = _fileName +"."+ _sessionId + "."+getDateTimeStamp();
_outputStream = new FileOutputStream(_fileName, true);
_usingRealFile = true;
_fileIsOpen = true;
}
else
{
_outputStream = System.out;
}
}
else //fileName == null
{
_outputStream = System.out;
}
_writer = new PrintWriter(_outputStream);
}
catch (java.io.IOException e)
{
e.printStackTrace();
}
}
public void close()
{
if (isOpen() && _usingRealFile)
{
_fileIsOpen = false;
_writer.close();
}
}
private boolean isOpen()
{
return _fileIsOpen;
}
}

View file

@ -1,49 +0,0 @@
package ohd.hseb.fcstservice;
import ohd.hseb.util.gui.jtable.AbstractJTableRowData;
import ohd.hseb.util.gui.jtable.JTableRowData;
public class LocationJTableRowData extends AbstractJTableRowData
{
private String locId;
public LocationJTableRowData()
{
}
public LocationJTableRowData(String missingRepresentation)
{
setMissingRepresentation(missingRepresentation);
}
public String toString()
{
String str = getLocId();
return str;
}
public int compare(String columnName, JTableRowData rowData)
{
int ret = 0;
LocationJTableRowData riverstatRecord = (LocationJTableRowData) rowData;
if(columnName.equals("Upstream Segment"))
ret = compareStrings(getLocId(), riverstatRecord.getLocId());
return ret;
}
public String getDataValue(String columnName)
{
String dataValue = null;
if(columnName.equals("Upstream Segment"))
dataValue = getStringValue(getLocId());
return dataValue;
}
public String getLocId() {
return locId;
}
public void setLocId(String locId) {
this.locId = locId;
}
}

View file

@ -1,8 +0,0 @@
package ohd.hseb.fcstservice;
public interface Observer //Observer of the observer pattern
{
//There is no need of pasing the subject as regardless of the subject, all the tables will be read
//Just in case we might need independent subject behaviour in the future, design doesn't have to be changed.
public void update(Subject sub);
}

View file

@ -1,59 +0,0 @@
package ohd.hseb.fcstservice;
import ohd.hseb.util.gui.jtable.AbstractJTableRowData;
import ohd.hseb.util.gui.jtable.BaseTableCell;
import ohd.hseb.util.gui.jtable.CellType;
public class PostProcessingJTableRowData extends AbstractJTableRowData
{
private String postProcessing;
private String missingRep = null;
public PostProcessingJTableRowData()
{
}
public PostProcessingJTableRowData(String missingRepresentation)
{
//setMissingRepresentation(missingRepresentation);
missingRep = missingRepresentation;
}
/* public String toString()
{
String str = getPostProcessing();
return str;
}
public int compare(String columnName, JTableRowData rowData)
{
int ret = 0;
PostProcessingJTableRowData postProcessingRecord = (PostProcessingJTableRowData) rowData;
if(columnName.equals("Post Processing"))
ret = compareStrings(getPostProcessing(), postProcessingRecord.getPostProcessing());
return ret;
}
public String getDataValue(String columnName)
{
String dataValue = null;
if(columnName.equals("Post Processing"))
dataValue = getStringValue(getPostProcessing());
return dataValue;
}
*/
public void addAllCellsToMap()
{
addCell(new BaseTableCell("Post Processing", CellType.STRING, getPostProcessing(), missingRep));
}
public String getPostProcessing() {
return postProcessing;
}
public void setPostProcessing(String postProcessing) {
this.postProcessing = postProcessing;
}
}

View file

@ -1,547 +0,0 @@
package ohd.hseb.fcstservice;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.SpringLayout;
import ohd.hseb.util.gui.WindowResizingManager;
import ohd.hseb.util.gui.jtable.ComplexJTableManager;
import ohd.hseb.util.gui.jtable.JTableColumnDescriptor;
import ohd.hseb.util.gui.jtable.JTableManager;
public class ReferenceTablesWindow
{
private DataServicesGlobals dataServicesGlobals = null;
private java.util.List lhvmRowDataList1 = null;
private java.util.List lhvmRowDataList2 = null;
private java.util.List lhvmRowDataList3 = null;
private java.util.List lhvmRowDataList4 = null;
private java.util.List lhvmRowDataList5 = null;
private java.util.List lhvmRowDataList6 = null;
private java.util.List lhvmRowDataList7 = null;
private java.util.List lhvmRowDataList8 = null;
private java.util.List lhvmRowDataList9 = null;
private java.util.List lhvmRowDataList10 = null;
private java.util.List lhvmRowDataList11 = null;
private java.util.List lhvmRowDataList12 = null;
private java.util.List lhvmRowDataList13 = null;
private java.util.List lhvmRowDataList14 = null;
private java.util.List lhvmRowDataList15 = null;
private java.util.List lhvmRowDataList16 = null;
private java.util.List lhvmRowDataList17 = null;
private LhvmDataManager lhvmDataManager = null;
private LhvmLogger lhvmLogger = null;
private JFrame lhvm = null;
private JTableManager jtm1 = null;
private JTableManager jtm2 = null;
private JTableManager jtm3 = null;
private JTableManager jtm4 = null;
private JTableManager jtm5 = null;
private JTableManager jtm6 = null;
private JTableManager jtm7 = null;
private JTableManager jtm8 = null;
private JTableManager jtm9 = null;
private JTableManager jtm10 = null;
private JTableManager jtm11 = null;
private JTableManager jtm12 = null;
private JTableManager jtm13 = null;
private JTableManager jtm14 = null;
private JTableManager jtm15 = null;
private JTableManager jtm16 = null;
private JTableManager jtm17 = null;
private JScrollPane tableScrollPane1 = null;
private JPanel tableScrollPanePanel1 = null;
private JScrollPane tableScrollPane2 = null;
private JPanel tableScrollPanePanel2 = null;
private JScrollPane tableScrollPane3 = null;
private JPanel tableScrollPanePanel3 = null;
private JScrollPane tableScrollPane4 = null;
private JPanel tableScrollPanePanel4 = null;
private JScrollPane tableScrollPane5 = null;
private JPanel tableScrollPanePanel5 = null;
private JScrollPane tableScrollPane6 = null;
private JPanel tableScrollPanePanel6 = null;
private JScrollPane tableScrollPane7 = null;
private JPanel tableScrollPanePanel7 = null;
private JScrollPane tableScrollPane8 = null;
private JPanel tableScrollPanePanel8 = null;
private JScrollPane tableScrollPane9 = null;
private JPanel tableScrollPanePanel9 = null;
private JScrollPane tableScrollPane10 = null;
private JPanel tableScrollPanePanel10 = null;
private JScrollPane tableScrollPane11 = null;
private JPanel tableScrollPanePanel11 = null;
private JScrollPane tableScrollPane12 = null;
private JPanel tableScrollPanePanel12 = null;
private JScrollPane tableScrollPane13 = null;
private JPanel tableScrollPanePanel13 = null;
private JScrollPane tableScrollPane14 = null;
private JPanel tableScrollPanePanel14 = null;
private JScrollPane tableScrollPane15 = null;
private JPanel tableScrollPanePanel15 = null;
private JScrollPane tableScrollPane16 = null;
private JPanel tableScrollPanePanel16 = null;
private JScrollPane tableScrollPane17 = null;
private JPanel tableScrollPanePanel17 = null;
private JButton closeButton = null;
private void setDatabaseMessage()
{
String tempStr = null;
if(LhvmDataManager.displayedMessageReferencesWindow != null)
{
tempStr = new String(LhvmDataManager.displayedMessageReferencesWindow);
}
LhvmDataManager.displayedMessageReferencesWindow = new StringBuffer();
LhvmDataManager.displayedMessageReferencesWindow.append(LhvmDataManager.databaseMessage);
if(tempStr != null)
{
LhvmDataManager.displayedMessageReferencesWindow.append("\n").append(tempStr);
}
}
public ReferenceTablesWindow(String jdbcUrl)
{
dataServicesGlobals = DataServicesGlobals.getSingleInstanceOfDataServicesGlobals();
lhvm = new JFrame("Point Services Reference Tables");
lhvm.setSize(1000, 500);
lhvm.setLocation(20,50);
lhvm.setLayout(new SpringLayout());
//Fix the dimensions of this window i.e. dis-allow window resizing
Dimension d = new Dimension(980, 850);
new WindowResizingManager(lhvm, d, d);
lhvm.setResizable(false);
JLabel consoleLabel = new JLabel("-----Database Messages-----");
consoleLabel.setForeground(Color.red);
JLabel separatorLabel1 = new JLabel("==================================================================================================");
separatorLabel1.setForeground(Color.red);
JLabel separatorLabel2 = new JLabel("==================================================================================================");
separatorLabel2.setForeground(Color.red);
JLabel separatorLabel3 = new JLabel("==================================================================================================");
separatorLabel3.setForeground(Color.red);
closeButton = new JButton("Close Window");
closeButton.addActionListener(new CloseActionListener());
closeButton.setEnabled(true);
JTextArea consoleTextArea = new JTextArea(1,50);
Font font = new Font("Serif", Font.BOLD, 15);
consoleTextArea.setFont(font);
consoleTextArea.setForeground(Color.green);
consoleTextArea.setBackground(Color.black);
consoleTextArea.setCaretColor(Color.red);
consoleTextArea.setBorder(BorderFactory.createEtchedBorder() );
consoleTextArea.setLineWrap(true);
String[] columnsToBeDisplayed1 = {"Fcst Type"};
String[] columnsToBeDisplayed2 = {"Flow Type"};
String[] columnsToBeDisplayed3 = {"Hydrologic Method"};
String[] columnsToBeDisplayed4 = {"Def Issue Criteria"};
String[] columnsToBeDisplayed5 = {"Routing Method"};
String[] columnsToBeDisplayed6 = {"Snow Method"};
String[] columnsToBeDisplayed7 = {"Wat Sup Coord Agency"};
String[] columnsToBeDisplayed8 = {"Wat Sup Criterion"};
String[] columnsToBeDisplayed9 = {"Wat Sup Method"};
String[] columnsToBeDisplayed10 = {"Frequency Update"};
String[] columnsToBeDisplayed11 = {"Required Period"};
String[] columnsToBeDisplayed12 = {"Post Processing"};
String[] columnsToBeDisplayed13 = {"Horizon"};
String[] columnsToBeDisplayed14 = {"Typical Fcst Gen Method"};
String[] columnsToBeDisplayed15 = {"Reservoir Model"};
String[] columnsToBeDisplayed16 = {"Wat Sup Resp Agency"};
String[] columnsToBeDisplayed17 = {"Service Type"};
JLabel fcstTypeLabel = new JLabel(" Fcst Type");
JLabel flowTypeLabel = new JLabel(" Flow Type");
JLabel hydrologicMethodLabel = new JLabel(" Hydrologic Method");
JLabel issueCriteriaLabel = new JLabel(" Def Issue Criteria");
JLabel routingMethodLabel = new JLabel(" Routing Method");
JLabel snowMethodLabel = new JLabel(" Snow Type");
JLabel watsupCoordAgencyLabel = new JLabel(" Wat Sup Coord Agency");
JLabel watsupCriterionLabel = new JLabel(" Wat Sup Criterion");
JLabel watsupMethodLabel = new JLabel(" Wat Sup Method");
JLabel frequencyUpdateLabel = new JLabel(" Frequency Update");
JLabel requiredPeriodLabel = new JLabel(" Required Period");
JLabel postProcessingLabel = new JLabel(" Post Processing");
JLabel horizonLabel = new JLabel(" Horizon");
JLabel genMethodLabel = new JLabel(" Typical Fcst Gen Method");
JLabel reservoirModelLabel = new JLabel(" Reservoir Model");
JLabel serviceTypeLabel = new JLabel(" Service Type");
JLabel respAgencyLabel = new JLabel(" Wat Sup Resp Agency");
java.util.List lhvmColumnDescriptorList1 = new ArrayList();
java.util.List lhvmColumnDescriptorList2 = new ArrayList();
java.util.List lhvmColumnDescriptorList3 = new ArrayList();
java.util.List lhvmColumnDescriptorList4 = new ArrayList();
java.util.List lhvmColumnDescriptorList5 = new ArrayList();
java.util.List lhvmColumnDescriptorList6 = new ArrayList();
java.util.List lhvmColumnDescriptorList7 = new ArrayList();
java.util.List lhvmColumnDescriptorList8 = new ArrayList();
java.util.List lhvmColumnDescriptorList9 = new ArrayList();
java.util.List lhvmColumnDescriptorList10 = new ArrayList();
java.util.List lhvmColumnDescriptorList11 = new ArrayList();
java.util.List lhvmColumnDescriptorList12 = new ArrayList();
java.util.List lhvmColumnDescriptorList13 = new ArrayList();
java.util.List lhvmColumnDescriptorList14 = new ArrayList();
java.util.List lhvmColumnDescriptorList15 = new ArrayList();
java.util.List lhvmColumnDescriptorList16 = new ArrayList();
java.util.List lhvmColumnDescriptorList17 = new ArrayList();
lhvmLogger = new LhvmLogger();
lhvmDataManager = LhvmDataManager.getSingleInstanceOfDataManager(jdbcUrl, lhvmLogger,"-");
lhvmRowDataList1 = lhvmDataManager.readDataFromFcstType();
lhvmColumnDescriptorList1.add(new JTableColumnDescriptor("Fcst Type", true, 150, "center"));
jtm1 = new ComplexJTableManager(lhvmColumnDescriptorList1, lhvmRowDataList1);
jtm1.setDisplayableColumns(columnsToBeDisplayed1, false, true);
jtm1.setPreferredSizeForJScrollPane(new Dimension(150, 125));
tableScrollPane1 = jtm1.getJScrollPane();
//jtm1.setTableToolTipText("str");
tableScrollPanePanel1 = new JPanel();
tableScrollPanePanel1.add(tableScrollPane1);
setDatabaseMessage();
lhvmRowDataList2 = lhvmDataManager.readDataFromFlowType();
lhvmColumnDescriptorList2.add(new JTableColumnDescriptor("Flow Type", true, 150, "center"));
jtm2 = new ComplexJTableManager(lhvmColumnDescriptorList2, lhvmRowDataList2);
jtm2.setDisplayableColumns(columnsToBeDisplayed2, false, true);
jtm2.setPreferredSizeForJScrollPane(new Dimension(150, 125));
tableScrollPane2 = jtm2.getJScrollPane();
//jtm2.setTableToolTipText("str");
tableScrollPanePanel2 = new JPanel();
tableScrollPanePanel2.add(tableScrollPane2);
setDatabaseMessage();
lhvmRowDataList3 = lhvmDataManager.readDataFromHydrologicMethod();
lhvmColumnDescriptorList3.add(new JTableColumnDescriptor("Hydrologic Method", true, 150, "center"));
jtm3 = new ComplexJTableManager(lhvmColumnDescriptorList3, lhvmRowDataList3);
jtm3.setDisplayableColumns(columnsToBeDisplayed3, false, true);
jtm3.setPreferredSizeForJScrollPane(new Dimension(150,125));
tableScrollPane3 = jtm3.getJScrollPane();
//jtm3.setTableToolTipText("str");
tableScrollPanePanel3 = new JPanel();
tableScrollPanePanel3.add(tableScrollPane3);
setDatabaseMessage();
lhvmRowDataList4 = lhvmDataManager.readDataFromIssueCriteria();
lhvmColumnDescriptorList4.add(new JTableColumnDescriptor("Def Issue Criteria", true, 150, "center"));
jtm4 = new ComplexJTableManager(lhvmColumnDescriptorList4, lhvmRowDataList4);
jtm4.setDisplayableColumns(columnsToBeDisplayed4, false, true);
jtm4.setPreferredSizeForJScrollPane(new Dimension(150, 125));
tableScrollPane4 = jtm4.getJScrollPane();
//jtm4.setTableToolTipText("str");
tableScrollPanePanel4 = new JPanel();
tableScrollPanePanel4.add(tableScrollPane4);
setDatabaseMessage();
lhvmRowDataList5 = lhvmDataManager.readDataFromRoutingMethod();
lhvmColumnDescriptorList5.add(new JTableColumnDescriptor("Routing Method", true, 150, "center"));
jtm5 = new ComplexJTableManager(lhvmColumnDescriptorList5, lhvmRowDataList5);
jtm5.setDisplayableColumns(columnsToBeDisplayed5, false, true);
jtm5.setPreferredSizeForJScrollPane(new Dimension(150, 125));
tableScrollPane5 = jtm5.getJScrollPane();
//jtm5.setTableToolTipText("str");
tableScrollPanePanel5 = new JPanel();
tableScrollPanePanel5.add(tableScrollPane5);
setDatabaseMessage();
lhvmRowDataList6 = lhvmDataManager.readDataFromSnowMethod();
lhvmColumnDescriptorList6.add(new JTableColumnDescriptor("Snow Method", true, 150, "center"));
jtm6 = new ComplexJTableManager(lhvmColumnDescriptorList6, lhvmRowDataList6);
jtm6.setDisplayableColumns(columnsToBeDisplayed6, false, true);
jtm6.setPreferredSizeForJScrollPane(new Dimension(150, 125));
tableScrollPane6 = jtm6.getJScrollPane();
//jtm6.setTableToolTipText("str");
tableScrollPanePanel6 = new JPanel();
tableScrollPanePanel6.add(tableScrollPane6);
setDatabaseMessage();
lhvmRowDataList7 = lhvmDataManager.readDataFromWatsupCoordAgency();
lhvmColumnDescriptorList7.add(new JTableColumnDescriptor("Wat Sup Coord Agency", true, 150, "center"));
jtm7 = new ComplexJTableManager(lhvmColumnDescriptorList7, lhvmRowDataList7);
jtm7.setDisplayableColumns(columnsToBeDisplayed7, false, true);
jtm7.setPreferredSizeForJScrollPane(new Dimension(150, 125));
tableScrollPane7 = jtm7.getJScrollPane();
//jtm7.setTableToolTipText("str");
tableScrollPanePanel7 = new JPanel();
tableScrollPanePanel7.add(tableScrollPane7);
setDatabaseMessage();
lhvmRowDataList8 = lhvmDataManager.readDataFromWatsupCriterion();
lhvmColumnDescriptorList8.add(new JTableColumnDescriptor("Wat Sup Criterion", true, 150, "center"));
jtm8 = new ComplexJTableManager(lhvmColumnDescriptorList8, lhvmRowDataList8);
jtm8.setDisplayableColumns(columnsToBeDisplayed8, false, true);
jtm8.setPreferredSizeForJScrollPane(new Dimension(150, 125));
tableScrollPane8 = jtm8.getJScrollPane();
//jtm8.setTableToolTipText("str");
tableScrollPanePanel8 = new JPanel();
tableScrollPanePanel8.add(tableScrollPane8);
setDatabaseMessage();
lhvmRowDataList9 = lhvmDataManager.readDataFromWatsupMethod();
lhvmColumnDescriptorList9.add(new JTableColumnDescriptor("Wat Sup Method", true, 150, "center"));
jtm9 = new ComplexJTableManager(lhvmColumnDescriptorList9, lhvmRowDataList9);
jtm9.setDisplayableColumns(columnsToBeDisplayed9, false, true);
jtm9.setPreferredSizeForJScrollPane(new Dimension(150, 125));
tableScrollPane9 = jtm9.getJScrollPane();
//jtm9.setTableToolTipText("str");
tableScrollPanePanel9 = new JPanel();
tableScrollPanePanel9.add(tableScrollPane9);
setDatabaseMessage();
lhvmRowDataList10 = lhvmDataManager.readDataFromFrequencyUpdate();
lhvmColumnDescriptorList10.add(new JTableColumnDescriptor("Frequency Update", true, 150, "center"));
jtm10 = new ComplexJTableManager(lhvmColumnDescriptorList10, lhvmRowDataList10);
jtm10.setDisplayableColumns(columnsToBeDisplayed10, false, true);
jtm10.setPreferredSizeForJScrollPane(new Dimension(150, 125));
tableScrollPane10 = jtm10.getJScrollPane();
//jtm10.setTableToolTipText("str");
tableScrollPanePanel10 = new JPanel();
tableScrollPanePanel10.add(tableScrollPane10);
setDatabaseMessage();
lhvmRowDataList11 = lhvmDataManager.readDataFromRequiredPeriod();
lhvmColumnDescriptorList11.add(new JTableColumnDescriptor("Required Period", true, 150, "center"));
jtm11 = new ComplexJTableManager(lhvmColumnDescriptorList11, lhvmRowDataList11);
jtm11.setDisplayableColumns(columnsToBeDisplayed11, false, true);
jtm11.setPreferredSizeForJScrollPane(new Dimension(150, 125));
tableScrollPane11 = jtm11.getJScrollPane();
//jtm11.setTableToolTipText("str");
tableScrollPanePanel11 = new JPanel();
tableScrollPanePanel11.add(tableScrollPane11);
setDatabaseMessage();
lhvmRowDataList12 = lhvmDataManager.readDataFromPostProcessing();
lhvmColumnDescriptorList12.add(new JTableColumnDescriptor("Post Processing", true, 150, "center"));
jtm12 = new ComplexJTableManager(lhvmColumnDescriptorList12, lhvmRowDataList12);
jtm12.setDisplayableColumns(columnsToBeDisplayed12, false, true);
jtm12.setPreferredSizeForJScrollPane(new Dimension(150, 125));
tableScrollPane12 = jtm12.getJScrollPane();
//jtm12.setTableToolTipText("str");
tableScrollPanePanel12 = new JPanel();
tableScrollPanePanel12.add(tableScrollPane12);
setDatabaseMessage();
lhvmRowDataList13 = lhvmDataManager.readDataFromHorizon();
lhvmColumnDescriptorList13.add(new JTableColumnDescriptor("Horizon", true, 150, "center"));
jtm13 = new ComplexJTableManager(lhvmColumnDescriptorList13, lhvmRowDataList13);
jtm13.setDisplayableColumns(columnsToBeDisplayed13, false, true);
jtm13.setPreferredSizeForJScrollPane(new Dimension(150, 125));
tableScrollPane13 = jtm13.getJScrollPane();
//jtm13.setTableToolTipText("str");
tableScrollPanePanel13 = new JPanel();
tableScrollPanePanel13.add(tableScrollPane13);
setDatabaseMessage();
lhvmRowDataList14 = lhvmDataManager.readDataFromGenMethod();
lhvmColumnDescriptorList14.add(new JTableColumnDescriptor("Typical Fcst Gen Method", true, 150, "center"));
jtm14 = new ComplexJTableManager(lhvmColumnDescriptorList14, lhvmRowDataList14);
jtm14.setDisplayableColumns(columnsToBeDisplayed14, false, true);
jtm14.setPreferredSizeForJScrollPane(new Dimension(150, 125));
tableScrollPane14 = jtm14.getJScrollPane();
//jtm14.setTableToolTipText("str");
tableScrollPanePanel14 = new JPanel();
tableScrollPanePanel14.add(tableScrollPane14);
setDatabaseMessage();
lhvmRowDataList15 = lhvmDataManager.readDataFromReservoirModel();
lhvmColumnDescriptorList15.add(new JTableColumnDescriptor("Reservoir Model", true, 150, "center"));
jtm15 = new ComplexJTableManager(lhvmColumnDescriptorList15, lhvmRowDataList15);
jtm15.setDisplayableColumns(columnsToBeDisplayed15, false, true);
jtm15.setPreferredSizeForJScrollPane(new Dimension(150, 125));
tableScrollPane15 = jtm15.getJScrollPane();
//jtm15.setTableToolTipText("str");
tableScrollPanePanel15 = new JPanel();
tableScrollPanePanel15.add(tableScrollPane15);
setDatabaseMessage();
lhvmRowDataList16 = lhvmDataManager.readDataFromRespAgency();
lhvmColumnDescriptorList16.add(new JTableColumnDescriptor("Wat Sup Resp Agency", true, 150, "center"));
jtm16 = new ComplexJTableManager(lhvmColumnDescriptorList16, lhvmRowDataList16);
jtm16.setDisplayableColumns(columnsToBeDisplayed16, false, true);
jtm16.setPreferredSizeForJScrollPane(new Dimension(150, 125));
tableScrollPane16 = jtm16.getJScrollPane();
//jtm16.setTableToolTipText("str");
tableScrollPanePanel16 = new JPanel();
tableScrollPanePanel16.add(tableScrollPane16);
setDatabaseMessage();
lhvmRowDataList17 = lhvmDataManager.readDataFromServiceType();
lhvmColumnDescriptorList17.add(new JTableColumnDescriptor("Service Type", true, 150, "center"));
jtm17 = new ComplexJTableManager(lhvmColumnDescriptorList17, lhvmRowDataList17);
jtm17.setDisplayableColumns(columnsToBeDisplayed17, false, true);
jtm17.setPreferredSizeForJScrollPane(new Dimension(150, 125));
tableScrollPane17 = jtm17.getJScrollPane();
//jtm17.setTableToolTipText("str");
tableScrollPanePanel17 = new JPanel();
tableScrollPanePanel17.add(tableScrollPane17);
setDatabaseMessage();
consoleTextArea.insert(new String(LhvmDataManager.displayedMessageReferencesWindow), 0);
JScrollPane scrollableTextAreaForConsole = new JScrollPane(consoleTextArea, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
int numRows1 = lhvmRowDataList1.size();
JLabel numRowsLabel1 = new JLabel(" " + numRows1 + " Rows");
int numRows2 = lhvmRowDataList2.size();
JLabel numRowsLabel2 = new JLabel(" " + numRows2 + " Rows");
int numRows3 = lhvmRowDataList3.size();
JLabel numRowsLabel3 = new JLabel(" " + numRows3 + " Rows");
int numRows4 = lhvmRowDataList4.size();
JLabel numRowsLabel4 = new JLabel(" " + numRows4 + " Rows");
int numRows5 = lhvmRowDataList5.size();
JLabel numRowsLabel5 = new JLabel(" " + numRows5 + " Rows");
int numRows6 = lhvmRowDataList6.size();
JLabel numRowsLabel6 = new JLabel(" " + numRows6 + " Rows");
int numRows7 = lhvmRowDataList7.size();
JLabel numRowsLabel7 = new JLabel(" " + numRows7 + " Rows");
int numRows8 = lhvmRowDataList8.size();
JLabel numRowsLabel8 = new JLabel(" " + numRows8 + " Rows");
int numRows9 = lhvmRowDataList9.size();
JLabel numRowsLabel9 = new JLabel(" " + numRows9 + " Rows");
int numRows10 = lhvmRowDataList10.size();
JLabel numRowsLabel10 = new JLabel(" " + numRows10 + " Rows");
int numRows11 = lhvmRowDataList11.size();
JLabel numRowsLabel11 = new JLabel(" " + numRows11 + " Rows");
int numRows12 = lhvmRowDataList12.size();
JLabel numRowsLabel12 = new JLabel(" " + numRows12 + " Rows");
int numRows13 = lhvmRowDataList13.size();
JLabel numRowsLabel13 = new JLabel(" " + numRows13 + " Rows");
int numRows14 = lhvmRowDataList14.size();
JLabel numRowsLabel14 = new JLabel(" " + numRows14 + " Rows");
int numRows15 = lhvmRowDataList15.size();
JLabel numRowsLabel15 = new JLabel(" " + numRows15 + " Rows");
int numRows16 = lhvmRowDataList16.size();
JLabel numRowsLabel16 = new JLabel(" " + numRows16 + " Rows");
int numRows17 = lhvmRowDataList17.size();
JLabel numRowsLabel17 = new JLabel(" " + numRows17 + " Rows");
JFrame tablesPanel = new JFrame();
tablesPanel.setLayout(new SpringLayout());
tablesPanel.add(numRowsLabel1);
tablesPanel.add(numRowsLabel2);
tablesPanel.add(numRowsLabel3);
tablesPanel.add(numRowsLabel4);
tablesPanel.add(numRowsLabel5);
tablesPanel.add(fcstTypeLabel);
tablesPanel.add(flowTypeLabel);
tablesPanel.add(hydrologicMethodLabel);
tablesPanel.add(issueCriteriaLabel);
tablesPanel.add(routingMethodLabel);
tablesPanel.add(tableScrollPanePanel1);
tablesPanel.add(tableScrollPanePanel2);
tablesPanel.add(tableScrollPanePanel3);
tablesPanel.add(tableScrollPanePanel4);
tablesPanel.add(tableScrollPanePanel5);
SpringUtilities.makeCompactGrid(tablesPanel.getContentPane(), 3, 5, 0, 0, 0, 0);
JFrame tablesPanel1 = new JFrame();
tablesPanel1.setLayout(new SpringLayout());
tablesPanel1.add(numRowsLabel6);
tablesPanel1.add(numRowsLabel7);
tablesPanel1.add(numRowsLabel8);
tablesPanel1.add(numRowsLabel9);
tablesPanel1.add(numRowsLabel10);
tablesPanel1.add(snowMethodLabel);
tablesPanel1.add(watsupCoordAgencyLabel);
tablesPanel1.add(watsupCriterionLabel);
tablesPanel1.add(watsupMethodLabel);
tablesPanel1.add(frequencyUpdateLabel);
tablesPanel1.add(tableScrollPanePanel6);
tablesPanel1.add(tableScrollPanePanel7);
tablesPanel1.add(tableScrollPanePanel8);
tablesPanel1.add(tableScrollPanePanel9);
tablesPanel1.add(tableScrollPanePanel10);
SpringUtilities.makeCompactGrid(tablesPanel1.getContentPane(), 3, 5, 0, 0, 0, 0);
JFrame tablesPanel2 = new JFrame();
tablesPanel2.setLayout(new SpringLayout());
tablesPanel2.add(numRowsLabel11);
tablesPanel2.add(numRowsLabel12);
tablesPanel2.add(numRowsLabel13);
tablesPanel2.add(numRowsLabel14);
tablesPanel2.add(numRowsLabel15);
tablesPanel2.add(requiredPeriodLabel);
tablesPanel2.add(postProcessingLabel);
tablesPanel2.add(horizonLabel);
tablesPanel2.add(genMethodLabel);
tablesPanel2.add(reservoirModelLabel);
tablesPanel2.add(tableScrollPanePanel11);
tablesPanel2.add(tableScrollPanePanel12);
tablesPanel2.add(tableScrollPanePanel13);
tablesPanel2.add(tableScrollPanePanel14);
tablesPanel2.add(tableScrollPanePanel15);
SpringUtilities.makeCompactGrid(tablesPanel2.getContentPane(), 3, 5, 0, 0, 0, 0);
JFrame tablesPanel3 = new JFrame();
tablesPanel3.setLayout(new SpringLayout());
tablesPanel3.add(numRowsLabel16);
tablesPanel3.add(numRowsLabel17);
tablesPanel3.add(respAgencyLabel);
tablesPanel3.add(serviceTypeLabel);
tablesPanel3.add(tableScrollPanePanel16);
tablesPanel3.add(tableScrollPanePanel17);
SpringUtilities.makeCompactGrid(tablesPanel3.getContentPane(), 3, 2, 0, 0, 0, 0);
lhvm.getContentPane().add(tablesPanel.getContentPane());
lhvm.getContentPane ().add(separatorLabel1);
lhvm.getContentPane().add(tablesPanel1.getContentPane());
lhvm.getContentPane ().add(separatorLabel2);
lhvm.getContentPane().add(tablesPanel2.getContentPane());
lhvm.getContentPane ().add(separatorLabel3);
lhvm.getContentPane().add(tablesPanel3.getContentPane());
lhvm.getContentPane ().add(closeButton);
lhvm.getContentPane().add(consoleLabel);
lhvm.getContentPane().add(scrollableTextAreaForConsole);
SpringUtilities.makeCompactGrid(lhvm.getContentPane(), 10, 1, 0, 0, 6, 6);
lhvm.addWindowListener(new ServicesDbWindowAdapter());
lhvm.pack();
//Show the JFrame
lhvm.setVisible (true);
}
private void operationCloseWindow()
{
if(dataServicesGlobals.getCount() <= 1)
{
lhvm.dispose();
// System.exit(0);
}
else
{
dataServicesGlobals.decrementCount();
lhvm.dispose();
}
}
private class CloseActionListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
operationCloseWindow();
}
}
}

View file

@ -1,57 +0,0 @@
package ohd.hseb.fcstservice;
import ohd.hseb.util.gui.jtable.AbstractJTableRowData;
import ohd.hseb.util.gui.jtable.BaseTableCell;
import ohd.hseb.util.gui.jtable.CellType;
public class RequiredPeriodJTableRowData extends AbstractJTableRowData
{
private String requiredPeriod;
private String missingRep = null;
public RequiredPeriodJTableRowData()
{
}
public RequiredPeriodJTableRowData(String missingRepresentation)
{
//setMissingRepresentation(missingRepresentation);
missingRep = missingRepresentation;
}
/* public String toString()
{
String str = getRequiredPeriod();
return str;
}
public int compare(String columnName, JTableRowData rowData)
{
int ret = 0;
RequiredPeriodJTableRowData requiredPeriodMethodRecord = (RequiredPeriodJTableRowData) rowData;
if(columnName.equals("Required Period"))
ret = compareStrings(getRequiredPeriod(), requiredPeriodMethodRecord.getRequiredPeriod());
return ret;
}
public String getDataValue(String columnName)
{
String dataValue = null;
if(columnName.equals("Required Period"))
dataValue = getStringValue(getRequiredPeriod());
return dataValue;
}
*/
public void addAllCellsToMap()
{
addCell(new BaseTableCell("Required Period", CellType.STRING, getRequiredPeriod(), missingRep));
}
public String getRequiredPeriod() {
return requiredPeriod;
}
public void setRequiredPeriod(String requiredPeriod) {
this.requiredPeriod = requiredPeriod;
}
}

View file

@ -1,57 +0,0 @@
package ohd.hseb.fcstservice;
import ohd.hseb.util.gui.jtable.AbstractJTableRowData;
import ohd.hseb.util.gui.jtable.BaseTableCell;
import ohd.hseb.util.gui.jtable.CellType;
public class ReservoirModelJTableRowData extends AbstractJTableRowData
{
private String reservoirModel;
private String missingRep = null;
public ReservoirModelJTableRowData()
{
}
public ReservoirModelJTableRowData(String missingRepresentation)
{
//setMissingRepresentation(missingRepresentation);
missingRep = missingRepresentation;
}
/* public String toString()
{
String str = getReservoirModel();
return str;
}
public int compare(String columnName, JTableRowData rowData)
{
int ret = 0;
ReservoirModelJTableRowData reservoirModelRecord = (ReservoirModelJTableRowData) rowData;
if(columnName.equals("Reservoir Model"))
ret = compareStrings(getReservoirModel(), reservoirModelRecord.getReservoirModel());
return ret;
}
public String getDataValue(String columnName)
{
String dataValue = null;
if(columnName.equals("Reservoir Model"))
dataValue = getStringValue(getReservoirModel());
return dataValue;
}
*/
public void addAllCellsToMap()
{
addCell(new BaseTableCell("Reservoir Model", CellType.STRING, getReservoirModel(), missingRep));
}
public String getReservoirModel() {
return reservoirModel;
}
public void setReservoirModel(String reservoirModel) {
this.reservoirModel = reservoirModel;
}
}

View file

@ -1,57 +0,0 @@
package ohd.hseb.fcstservice;
import ohd.hseb.util.gui.jtable.AbstractJTableRowData;
import ohd.hseb.util.gui.jtable.BaseTableCell;
import ohd.hseb.util.gui.jtable.CellType;
public class RespAgencyJTableRowData extends AbstractJTableRowData
{
private String respAgency;
private String missingRep = null;
public RespAgencyJTableRowData()
{
}
public RespAgencyJTableRowData(String missingRepresentation)
{
//setMissingRepresentation(missingRepresentation);
missingRep = missingRepresentation;
}
/* public String toString()
{
String str = getRespAgency();
return str;
}
public int compare(String columnName, JTableRowData rowData)
{
int ret = 0;
RespAgencyJTableRowData respAgencyRecord = (RespAgencyJTableRowData) rowData;
if(columnName.equals("Wat Sup Resp Agency"))
ret = compareStrings(getRespAgency(), respAgencyRecord.getRespAgency());
return ret;
}
public String getDataValue(String columnName)
{
String dataValue = null;
if(columnName.equals("Wat Sup Resp Agency"))
dataValue = getStringValue(getRespAgency());
return dataValue;
}
*/
public void addAllCellsToMap()
{
addCell(new BaseTableCell("Wat Sup Resp Agency", CellType.STRING, getRespAgency(), missingRep));
}
public String getRespAgency() {
return respAgency;
}
public void setRespAgency(String respAgency) {
this.respAgency = respAgency;
}
}

View file

@ -1,59 +0,0 @@
package ohd.hseb.fcstservice;
import ohd.hseb.util.gui.jtable.AbstractJTableRowData;
import ohd.hseb.util.gui.jtable.BaseTableCell;
import ohd.hseb.util.gui.jtable.CellType;
public class RoutingMethodJTableRowData extends AbstractJTableRowData
{
private String routingMethod;
private String missingRep = null;
public RoutingMethodJTableRowData()
{
}
public RoutingMethodJTableRowData(String missingRepresentation)
{
//setMissingRepresentation(missingRepresentation);
missingRep = missingRepresentation;
}
/* public String toString()
{
String str = getRoutingMethod();
return str;
}
public int compare(String columnName, JTableRowData rowData)
{
int ret = 0;
RoutingMethodJTableRowData routingMethodRecord = (RoutingMethodJTableRowData) rowData;
if(columnName.equals("Routing Method"))
ret = compareStrings(getRoutingMethod(), routingMethodRecord.getRoutingMethod());
return ret;
}
public String getDataValue(String columnName)
{
String dataValue = null;
if(columnName.equals("Routing Method"))
dataValue = getStringValue(getRoutingMethod());
return dataValue;
}
*/
public void addAllCellsToMap()
{
addCell(new BaseTableCell("Routing Method", CellType.STRING, getRoutingMethod(), missingRep));
}
public String getRoutingMethod() {
return routingMethod;
}
public void setRoutingMethod(String routingMethod) {
this.routingMethod = routingMethod;
}
}

View file

@ -1,128 +0,0 @@
package ohd.hseb.fcstservice;
import ohd.hseb.ihfsdb.generated.ServiceTableViewRecord;
import ohd.hseb.util.gui.jtable.AbstractJTableRowData;
import ohd.hseb.util.gui.jtable.JTableRowData;
public class ServiceTableViewViewJTableRowData extends AbstractJTableRowData
{
private String lid;
private String state;
private String county;
private String hsa;
private String locName;
private String stream;
public ServiceTableViewViewJTableRowData()
{
}
public void setServiceTableViewRecord(ServiceTableViewRecord serviceTableViewRecord)
{
setLid(serviceTableViewRecord.getLid());
setState(serviceTableViewRecord.getState());
setCounty(serviceTableViewRecord.getCounty());
setHsa(serviceTableViewRecord.getHsa());
setLocName(serviceTableViewRecord.getName());
setStream(serviceTableViewRecord.getStream());
}
public ServiceTableViewViewJTableRowData(String missingRepresentation)
{
setMissingRepresentation(missingRepresentation);
}
public String toString()
{
String str = getLid()+" "+
getState()+" "+
getCounty()+" "+
getHsa();
return str;
}
public int compare(String columnName, JTableRowData rowData)
{
int ret = 0;
ServiceTableViewViewJTableRowData serviceTableViewRecord = (ServiceTableViewViewJTableRowData) rowData;
if(columnName.equals("Location ID"))
ret = compareStrings(getLid(), serviceTableViewRecord.getLid());
else if(columnName.equals("State"))
ret = compareStrings(getState(), serviceTableViewRecord.getState());
else if (columnName.equals("County"))
ret = compareStrings(getCounty(), serviceTableViewRecord.getCounty());
else if (columnName.equals("Hsa"))
ret = compareStrings(getHsa(), serviceTableViewRecord.getHsa());
else if (columnName.equals("Name"))
ret = compareStrings(getLocName(), serviceTableViewRecord.getLocName());
else if (columnName.equals("Stream"))
ret = compareStrings(getStream(), serviceTableViewRecord.getStream());
return ret;
}
public String getDataValue(String columnName)
{
String dataValue = null;
if(columnName.equals("Location ID"))
dataValue = getStringValue(getLid());
else if (columnName.equals("State"))
dataValue = getStringValue(getState());
else if (columnName.equals("County"))
dataValue = getStringValue(getCounty());
else if (columnName.equals("Hsa"))
dataValue = getStringValue(getHsa());
else if (columnName.equals("Name"))
dataValue = getStringValue(getLocName());
else if (columnName.equals("Stream"))
dataValue = getStringValue(getStream());
return dataValue;
}
public String getCounty() {
return county;
}
public void setCounty(String county) {
this.county = county;
}
public String getHsa() {
return hsa;
}
public void setHsa(String hsa) {
this.hsa = hsa;
}
public String getLid() {
return lid;
}
public void setLid(String lid) {
this.lid = lid;
}
public String getLocName() {
return locName;
}
public void setLocName(String locName) {
this.locName = locName;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public String getStream() {
return stream;
}
public void setStream(String stream) {
this.stream = stream;
}
}

View file

@ -1,57 +0,0 @@
package ohd.hseb.fcstservice;
import ohd.hseb.util.gui.jtable.AbstractJTableRowData;
import ohd.hseb.util.gui.jtable.BaseTableCell;
import ohd.hseb.util.gui.jtable.CellType;
public class ServiceTypeJTableRowData extends AbstractJTableRowData
{
private String serviceType;
private String missingRep = null;
public ServiceTypeJTableRowData()
{
}
public ServiceTypeJTableRowData(String missingRepresentation)
{
//setMissingRepresentation(missingRepresentation);
missingRep = missingRepresentation;
}
/* public String toString()
{
String str = getServiceType();
return str;
}
public int compare(String columnName, JTableRowData rowData)
{
int ret = 0;
ServiceTypeJTableRowData serviceTypeRecord = (ServiceTypeJTableRowData) rowData;
if(columnName.equals("Service Type"))
ret = compareStrings(getServiceType(), serviceTypeRecord.getServiceType());
return ret;
}
public String getDataValue(String columnName)
{
String dataValue = null;
if(columnName.equals("Service Type"))
dataValue = getStringValue(getServiceType());
return dataValue;
}
*/
public void addAllCellsToMap()
{
addCell(new BaseTableCell("Service Type", CellType.STRING, getServiceType(), missingRep));
}
public String getServiceType() {
return serviceType;
}
public void setServiceType(String serviceType) {
this.serviceType = serviceType;
}
}

View file

@ -1,38 +0,0 @@
package ohd.hseb.fcstservice;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JFrame;
public class ServicesDbWindowAdapter extends WindowAdapter
{
private JFrame jf = null;
private DataServicesGlobals dataServicesGlobals = null;
public ServicesDbWindowAdapter()
{
super();
}
public void windowClosing(WindowEvent e)
{
jf = (JFrame) e.getSource();
operationCloseWindow();
}
private void operationCloseWindow()
{
dataServicesGlobals = DataServicesGlobals.getSingleInstanceOfDataServicesGlobals();
if(dataServicesGlobals.getCount() <= 1)
{
jf.dispose();
// System.exit(0);
}
else
{
dataServicesGlobals.decrementCount();
jf.dispose();
}
}
}

View file

@ -1,58 +0,0 @@
package ohd.hseb.fcstservice;
import ohd.hseb.util.gui.jtable.AbstractJTableRowData;
import ohd.hseb.util.gui.jtable.BaseTableCell;
import ohd.hseb.util.gui.jtable.CellType;
public class SnowMethodJTableRowData extends AbstractJTableRowData
{
private String snowMethod;
private String missingRep = null;
public SnowMethodJTableRowData()
{
}
public SnowMethodJTableRowData(String missingRepresentation)
{
//setMissingRepresentation(missingRepresentation);
missingRep = missingRepresentation;
}
/* public String toString()
{
String str = getSnowMethod();
return str;
}
public int compare(String columnName, JTableRowData rowData)
{
int ret = 0;
SnowMethodJTableRowData snowMethodRecord = (SnowMethodJTableRowData) rowData;
if(columnName.equals("Snow Method"))
ret = compareStrings(getSnowMethod(), snowMethodRecord.getSnowMethod());
return ret;
}
public String getDataValue(String columnName)
{
String dataValue = null;
if(columnName.equals("Snow Method"))
dataValue = getStringValue(getSnowMethod());
return dataValue;
}
*/
public void addAllCellsToMap()
{
addCell(new BaseTableCell("Snow Method", CellType.STRING, getSnowMethod(), missingRep));
}
public String getSnowMethod() {
return snowMethod;
}
public void setSnowMethod(String snowMethod) {
this.snowMethod = snowMethod;
}
}

View file

@ -1,195 +0,0 @@
package ohd.hseb.fcstservice;
import java.awt.Component;
import java.awt.Container;
import javax.swing.Spring;
import javax.swing.SpringLayout;
/**
* A 1.4 file that provides utility methods for
* creating form- or grid-style layouts with SpringLayout.
* These utilities are used by several programs, such as
* SpringBox and SpringCompactGrid.
*/
public class SpringUtilities
{
/**
* A debugging utility that prints to stdout the component's
* minimum, preferred, and maximum sizes.
*/
public static void printSizes(Component c) {
System.out.println("minimumSize = " + c.getMinimumSize());
System.out.println("preferredSize = " + c.getPreferredSize());
System.out.println("maximumSize = " + c.getMaximumSize());
}
/**
* Aligns the first <code>rows</code> * <code>cols</code>
* components of <code>parent</code> in
* a grid. Each component is as big as the maximum
* preferred width and height of the components.
* The parent is made just big enough to fit them all.
*
* @param rows number of rows
* @param cols number of columns
* @param initialX x location to start the grid at
* @param initialY y location to start the grid at
* @param xPad x padding between cells
* @param yPad y padding between cells
*/
public static void makeGrid(Container parent,
int rows, int cols,
int initialX, int initialY,
int xPad, int yPad) {
SpringLayout layout;
try {
layout = (SpringLayout)parent.getLayout();
} catch (ClassCastException exc) {
System.err.println("The first argument to makeGrid must use SpringLayout.");
return;
}
Spring xPadSpring = Spring.constant(xPad);
Spring yPadSpring = Spring.constant(yPad);
Spring initialXSpring = Spring.constant(initialX);
Spring initialYSpring = Spring.constant(initialY);
int max = rows * cols;
//Calculate Springs that are the max of the width/height so that all
//cells have the same size.
Spring maxWidthSpring = layout.getConstraints(parent.getComponent(0)).
getWidth();
Spring maxHeightSpring = layout.getConstraints(parent.getComponent(0)).
getWidth();
for (int i = 1; i < max; i++) {
SpringLayout.Constraints cons = layout.getConstraints(
parent.getComponent(i));
maxWidthSpring = Spring.max(maxWidthSpring, cons.getWidth());
maxHeightSpring = Spring.max(maxHeightSpring, cons.getHeight());
}
//Apply the new width/height Spring. This forces all the
//components to have the same size.
for (int i = 0; i < max; i++) {
SpringLayout.Constraints cons = layout.getConstraints(
parent.getComponent(i));
cons.setWidth(maxWidthSpring);
cons.setHeight(maxHeightSpring);
}
//Then adjust the x/y constraints of all the cells so that they
//are aligned in a grid.
SpringLayout.Constraints lastCons = null;
SpringLayout.Constraints lastRowCons = null;
for (int i = 0; i < max; i++) {
SpringLayout.Constraints cons = layout.getConstraints(
parent.getComponent(i));
if (i % cols == 0) { //start of new row
lastRowCons = lastCons;
cons.setX(initialXSpring);
} else { //x position depends on previous component
cons.setX(Spring.sum(lastCons.getConstraint(SpringLayout.EAST),
xPadSpring));
}
if (i / cols == 0) { //first row
cons.setY(initialYSpring);
} else { //y position depends on previous row
cons.setY(Spring.sum(lastRowCons.getConstraint(SpringLayout.SOUTH),
yPadSpring));
}
lastCons = cons;
}
//Set the parent's size.
SpringLayout.Constraints pCons = layout.getConstraints(parent);
pCons.setConstraint(SpringLayout.SOUTH,
Spring.sum(
Spring.constant(yPad),
lastCons.getConstraint(SpringLayout.SOUTH)));
pCons.setConstraint(SpringLayout.EAST,
Spring.sum(
Spring.constant(xPad),
lastCons.getConstraint(SpringLayout.EAST)));
}
/* Used by makeCompactGrid. */
private static SpringLayout.Constraints getConstraintsForCell(
int row, int col,
Container parent,
int cols) {
SpringLayout layout = (SpringLayout) parent.getLayout();
Component c = parent.getComponent(row * cols + col);
return layout.getConstraints(c);
}
/**
* Aligns the first <code>rows</code> * <code>cols</code>
* components of <code>parent</code> in
* a grid. Each component in a column is as wide as the maximum
* preferred width of the components in that column;
* height is similarly determined for each row.
* The parent is made just big enough to fit them all.
*
* @param rows number of rows
* @param cols number of columns
* @param initialX x location to start the grid at
* @param initialY y location to start the grid at
* @param xPad x padding between cells
* @param yPad y padding between cells
*/
public static void makeCompactGrid(Container parent,
int rows, int cols,
int initialX, int initialY,
int xPad, int yPad) {
SpringLayout layout;
try {
layout = (SpringLayout)parent.getLayout();
} catch (ClassCastException exc) {
System.err.println("The first argument to makeCompactGrid must use SpringLayout.");
return;
}
//Align all cells in each column and make them the same width.
Spring x = Spring.constant(initialX);
for (int c = 0; c < cols; c++) {
Spring width = Spring.constant(0);
for (int r = 0; r < rows; r++) {
width = Spring.max(width,getConstraintsForCell(r, c, parent, cols).getWidth());
}
for (int r = 0; r < rows; r++) {
SpringLayout.Constraints constraints =
getConstraintsForCell(r, c, parent, cols);
constraints.setX(x);
constraints.setWidth(width);
}
x = Spring.sum(x, Spring.sum(width, Spring.constant(xPad)));
}
//Align all cells in each row and make them the same height.
Spring y = Spring.constant(initialY);
for (int r = 0; r < rows; r++) {
Spring height = Spring.constant(0);
for (int c = 0; c < cols; c++) {
height = Spring.max(height,
getConstraintsForCell(r, c, parent, cols).
getHeight());
}
for (int c = 0; c < cols; c++) {
SpringLayout.Constraints constraints =
getConstraintsForCell(r, c, parent, cols);
constraints.setY(y);
constraints.setHeight(height);
}
y = Spring.sum(y, Spring.sum(height, Spring.constant(yPad)));
}
//Set the parent's size.
SpringLayout.Constraints pCons = layout.getConstraints(parent);
pCons.setConstraint(SpringLayout.SOUTH, y);
pCons.setConstraint(SpringLayout.EAST, x);
}
}

View file

@ -1,8 +0,0 @@
package ohd.hseb.fcstservice;
public interface Subject //Subject of the observer pattern
{
public void addObserver(Observer observer);
public void removeObserver(Observer observer);
public void letKnowOfChanges();
}

View file

@ -1,58 +0,0 @@
package ohd.hseb.fcstservice;
import ohd.hseb.util.gui.jtable.AbstractJTableRowData;
import ohd.hseb.util.gui.jtable.BaseTableCell;
import ohd.hseb.util.gui.jtable.CellType;
public class WatSupCoordAgencyJTableRowData extends AbstractJTableRowData
{
private String watsupCoordAgency;
private String missingRep = null;
public WatSupCoordAgencyJTableRowData()
{
}
public WatSupCoordAgencyJTableRowData(String missingRepresentation)
{
//setMissingRepresentation(missingRepresentation);
missingRep = missingRepresentation;
}
/* public String toString()
{
String str = getWatsupCoordAgency();
return str;
}
public int compare(String columnName, JTableRowData rowData)
{
int ret = 0;
WatSupCoordAgencyJTableRowData watsupCoordAgencyRecord = (WatSupCoordAgencyJTableRowData) rowData;
if(columnName.equals("Wat Sup Coord Agency"))
ret = compareStrings(getWatsupCoordAgency(), watsupCoordAgencyRecord.getWatsupCoordAgency());
return ret;
}
public String getDataValue(String columnName)
{
String dataValue = null;
if(columnName.equals("Wat Sup Coord Agency"))
dataValue = getStringValue(getWatsupCoordAgency());
return dataValue;
}
*/
public void addAllCellsToMap()
{
addCell(new BaseTableCell("Wat Sup Coord Agency", CellType.STRING, getWatsupCoordAgency(), missingRep));
}
public String getWatsupCoordAgency() {
return watsupCoordAgency;
}
public void setWatsupCoordAgency(String watsupCoordAgency) {
this.watsupCoordAgency = watsupCoordAgency;
}
}

View file

@ -1,59 +0,0 @@
package ohd.hseb.fcstservice;
import ohd.hseb.util.gui.jtable.AbstractJTableRowData;
import ohd.hseb.util.gui.jtable.BaseTableCell;
import ohd.hseb.util.gui.jtable.CellType;
public class WatSupCriterionJTableRowData extends AbstractJTableRowData
{
private String watsupCriterion;
private String missingRep = null;
public WatSupCriterionJTableRowData()
{
}
public WatSupCriterionJTableRowData(String missingRepresentation)
{
//setMissingRepresentation(missingRepresentation);
missingRep = missingRepresentation;
}
/* public String toString()
{
String str = getWatsupCriterion();
return str;
}
public int compare(String columnName, JTableRowData rowData)
{
int ret = 0;
WatSupCriterionJTableRowData watsupCriterionRecord = (WatSupCriterionJTableRowData) rowData;
if(columnName.equals("Wat Sup Criterion"))
ret = compareStrings(getWatsupCriterion(), watsupCriterionRecord.getWatsupCriterion());
return ret;
}
public String getDataValue(String columnName)
{
String dataValue = null;
if(columnName.equals("Wat Sup Criterion"))
dataValue = getStringValue(getWatsupCriterion());
return dataValue;
}
*/
public void addAllCellsToMap()
{
addCell(new BaseTableCell("Wat Sup Criterion", CellType.STRING, getWatsupCriterion(), missingRep));
}
public String getWatsupCriterion() {
return watsupCriterion;
}
public void setWatsupCriterion(String watsupCriterion) {
this.watsupCriterion = watsupCriterion;
}
}

View file

@ -1,58 +0,0 @@
package ohd.hseb.fcstservice;
import ohd.hseb.util.gui.jtable.AbstractJTableRowData;
import ohd.hseb.util.gui.jtable.BaseTableCell;
import ohd.hseb.util.gui.jtable.CellType;
public class WatSupMethodJTableRowData extends AbstractJTableRowData
{
private String watsupMethod;
private String missingRep = null;
public WatSupMethodJTableRowData()
{
}
public WatSupMethodJTableRowData(String missingRepresentation)
{
//setMissingRepresentation(missingRepresentation);
missingRep = missingRepresentation;
}
/* public String toString()
{
String str = getWatsupMethod();
return str;
}
public int compare(String columnName, JTableRowData rowData)
{
int ret = 0;
WatSupMethodJTableRowData watsupMethodRecord = (WatSupMethodJTableRowData) rowData;
if(columnName.equals("Wat Sup Method"))
ret = compareStrings(getWatsupMethod(), watsupMethodRecord.getWatsupMethod());
return ret;
}
public String getDataValue(String columnName)
{
String dataValue = null;
if(columnName.equals("Wat Sup Method"))
dataValue = getStringValue(getWatsupMethod());
return dataValue;
}
*/
public void addAllCellsToMap()
{
addCell(new BaseTableCell("Wat Sup Method", CellType.STRING, getWatsupMethod(), missingRep));
}
public String getWatsupMethod() {
return watsupMethod;
}
public void setWatsupMethod(String watsupMethod) {
this.watsupMethod = watsupMethod;
}
}

View file

@ -1,467 +0,0 @@
package ohd.hseb.fp_vtec_info;
import java.util.ArrayList;
public class FpCurPrevVtec
{
private String _locId;
private String _locName;
private String _locStream;
private String _locPe;
private double _floodStg;
private double _floodFlow;
private long _obsBeginTime;
private long _fcstEndTime;
private double _adjustendhrs;
private String _curAction;
private String _curPhenom;
private String _curSignif;
private String _curSeverity;
private String _curCause;
private String _curRecord;
private int _curEtn;
private double _curCrestValue;
private long _curBeginTime;
private long _curEndTime;
private long _curRiseTime;
private long _curCrestTime;
private long _curFallTime;
private String _prevAction;
private String _prevPhenom;
private String _prevSignif;
private String _prevSeverity;
private String _prevCause;
private String _prevRecord;
private int _prevEtn;
private double _prevCrestValue;
private String _prevRiseType;
private String _prevCrestType;
private String _prevFallType;
private long _prevBeginTime;
private long _prevEndTime;
private long _prevRiseTime;
private long _prevCrestTime;
private long _prevFallTime;
private long _prevProductTime;
private ArrayList _obsValuetTimeList;
private ArrayList _fcstValueTimeList;
public FpCurPrevVtec()
{
}
public String getLocId()
{
return _locId;
}
public void setLocId(String locId)
{
_locId = locId;
}
public String getLocName()
{
return _locName;
}
public void setLocName(String locName)
{
_locName = locName;
}
public String getLocStream()
{
return _locStream;
}
public void setLocStream(String locStream)
{
_locStream = locStream;
}
public String getLocPe()
{
return _locPe;
}
public void setLocPe(String locPe)
{
_locPe = locPe;
}
public double getFloodStg()
{
return _floodStg;
}
public void setFloodStg(double floodStg)
{
_floodStg = floodStg;
}
public double getFloodFlow()
{
return _floodFlow;
}
public void setFloodFlow(double floodFlow)
{
_floodFlow = floodFlow;
}
public long getObsBeginTime()
{
return _obsBeginTime;
}
public void setObsBeginTime(long obsBeginTime)
{
_obsBeginTime = obsBeginTime;
}
public long getFcstEndTime()
{
return _fcstEndTime;
}
public void setFcstEndTime(long fcstEndTime)
{
_fcstEndTime = fcstEndTime;
}
public double getAdjustEndhrs()
{
return _adjustendhrs;
}
public void setAdjustEndhrs(double adjustendhrs)
{
_adjustendhrs = adjustendhrs;
}
public String getcurAction()
{
return _curAction;
}
public void setcurAction(String curAction)
{
_curAction = curAction;
}
public String getcurPhenom()
{
return _curPhenom;
}
public void setcurPhenom(String curPhenom)
{
_curPhenom = curPhenom;
}
public String getcurSignif()
{
return _curSignif;
}
public void setcurSignif(String curSignif)
{
_curSignif = curSignif;
}
public String getcurSeverity()
{
return _curSeverity;
}
public void setcurSeverity(String curSeverity)
{
_curSeverity = curSeverity;
}
public String getcurCause()
{
return _curCause;
}
public void setcurCause(String curCause)
{
_curCause = curCause;
}
public String getcurRecord()
{
return _curRecord;
}
public void setcurRecord(String curRecord)
{
_curRecord = curRecord;
}
public int getcurEtn()
{
return _curEtn;
}
public void setcurEtn(int curEtn)
{
_curEtn = curEtn;
}
public double getcurCrestValue()
{
return _curCrestValue;
}
public void setcurCrestValue(double curCrestValue)
{
_curCrestValue = curCrestValue;
}
public long getcurBeginTime()
{
return _curBeginTime;
}
public void setcurBeginTime(long curBeginTime)
{
_curBeginTime = curBeginTime;
}
public long getcurEndTime()
{
return _curEndTime;
}
public void setcurEndTime(long curEndTime)
{
_curEndTime = curEndTime;
}
public long getcurRiseTime()
{
return _curRiseTime;
}
public void setcurRiseTime(long curRiseTime)
{
_curRiseTime = curRiseTime;
}
public long getcurCrestTime()
{
return _curCrestTime;
}
public void setcurCrestTime(long curCrestTime)
{
_curCrestTime = curCrestTime;
}
public long getcurFallTime()
{
return _curFallTime;
}
public void setcurFallTime(long curFallTime)
{
_curFallTime = curFallTime;
}
public String getprevAction()
{
return _prevAction;
}
public void setprevAction(String prevAction)
{
_prevAction = prevAction;
}
public String getprevPhenom()
{
return _prevPhenom;
}
public void setprevPhenom(String prevPhenom)
{
_prevPhenom = prevPhenom;
}
public String getprevSignif()
{
return _prevSignif;
}
public void setprevSignif(String prevSignif)
{
_prevSignif = prevSignif;
}
public String getprevSeverity()
{
return _prevSeverity;
}
public void setprevSeverity(String prevSeverity)
{
_prevSeverity = prevSeverity;
}
public String getprevCause()
{
return _prevCause;
}
public void setprevCause(String prevCause)
{
_prevCause = prevCause;
}
public String getprevRecord()
{
return _prevRecord;
}
public void setprevRecord(String prevRecord)
{
_prevRecord = prevRecord;
}
public int getprevEtn()
{
return _prevEtn;
}
public void setprevEtn(int prevEtn)
{
_prevEtn = prevEtn;
}
public double getprevCrestValue()
{
return _prevCrestValue;
}
public void setprevCrestValue(double prevCrestValue)
{
_prevCrestValue = prevCrestValue;
}
public String getprevRiseType()
{
return _prevRiseType;
}
public void setprevRiseType(String prevRiseType)
{
_prevRiseType = prevRiseType;
}
public String getprevCrestType()
{
return _prevCrestType;
}
public void setprevCrestType(String prevCrestType)
{
_prevCrestType = prevCrestType;
}
public String getprevFallType()
{
return _prevFallType;
}
public void setprevFallType(String prevFallType)
{
_prevFallType = prevFallType;
}
public long getprevBeginTime()
{
return _prevBeginTime;
}
public void setprevBeginTime(long prevBeginTime)
{
_prevBeginTime = prevBeginTime;
}
public long getprevEndTime()
{
return _prevEndTime;
}
public void setprevEndTime(long prevEndTime)
{
_prevEndTime = prevEndTime;
}
public long getprevRiseTime()
{
return _prevRiseTime;
}
public void setprevRiseTime(long prevRiseTime)
{
_prevRiseTime = prevRiseTime;
}
public long getprevCrestTime()
{
return _prevCrestTime;
}
public void setprevCrestTime(long prevCrestTime)
{
_prevCrestTime = prevCrestTime;
}
public long getprevFallTime()
{
return _prevFallTime;
}
public void setprevFallTime(long prevFallTime)
{
_prevFallTime = prevFallTime;
}
public long getprevProductTime()
{
return _prevProductTime;
}
public void setprevProductTime(long prevProductTime)
{
_prevProductTime = prevProductTime;
}
public String toString()
{
String str = null;
return str;
}
public ArrayList getObsValuetTimeList() {
return _obsValuetTimeList;
}
public void setObsValuetTimeList(ArrayList obsValuetTimeList) {
_obsValuetTimeList = obsValuetTimeList;
}
public ArrayList getFcstValueTimeList() {
return _fcstValueTimeList;
}
public void setFcstValueTimeList(ArrayList fcstValueTimeList) {
_fcstValueTimeList = fcstValueTimeList;
}
}

File diff suppressed because it is too large Load diff

View file

@ -1,532 +0,0 @@
package ohd.hseb.fp_vtec_info;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import ohd.hseb.db.Database;
import ohd.hseb.db.DbTable;
import ohd.hseb.ihfsdb.generated.FcstHeightTable;
import ohd.hseb.ihfsdb.generated.FloodcatRecord;
import ohd.hseb.ihfsdb.generated.FloodcatTable;
import ohd.hseb.ihfsdb.generated.IngestFilterRecord;
import ohd.hseb.ihfsdb.generated.IngestFilterTable;
import ohd.hseb.ihfsdb.generated.RatingRecord;
import ohd.hseb.ihfsdb.generated.RatingShiftRecord;
import ohd.hseb.ihfsdb.generated.RatingShiftTable;
import ohd.hseb.ihfsdb.generated.RatingTable;
import ohd.hseb.ihfsdb.generated.RiverstatRecord;
import ohd.hseb.ihfsdb.generated.RiverstatTable;
import ohd.hseb.measurement.AbsTimeMeasurement;
import ohd.hseb.measurement.IrregularTimeSeries;
import ohd.hseb.measurement.MeasuringUnit;
import ohd.hseb.model.RatingCurve;
import ohd.hseb.model.RatingPoint;
import ohd.hseb.model.SigRiverLevels;
import ohd.hseb.timeserieslite.ParamCode;
import ohd.hseb.util.FileLogger;
import ohd.hseb.util.Logger;
import com.raytheon.uf.common.ohd.AppsDefaults;
public class FpVtecInfoDataManager {
private static final long MILLIS_PER_SECOND = 1000;
private Database _db = null;
private Logger _logger = null;
private String _jdbcConnectionString = null;
private String _rpfdataFilePath = null;
private Map _vtecinfoMap = new HashMap();
// ---------------------------------------------------------------------------------
public FpVtecInfoDataManager(String jdbcConnectionString) {
_logger = new FileLogger(true);
_jdbcConnectionString = jdbcConnectionString;
_db = new Database();
_db.connect(_jdbcConnectionString);
getAppsDefaults();
}
// ---------------------------------------------------------------------------------
private void getAppsDefaults() {
AppsDefaults ad = AppsDefaults.getInstance();
_rpfdataFilePath = ad.getToken("rpf_template_dir") + "/";
return;
}
// ----------------------------------------------------------------------------------
public void readInputFileFormFpCurPrevVtecInfoMap() {
// String header =
// "FpVtecInfoDataManager.readInputFileFormCurPrevVtecInfoMap(): ";
String fpvtecinfoFileName = getFpVtecInfoFileName();
FpVtecInfoFileReader reader = new FpVtecInfoFileReader(
fpvtecinfoFileName);
_vtecinfoMap = reader.read();
return;
}
// ------------------------------------------------------------------------
private String getFpVtecInfoFileName() {
String fpvtecinfoFileName = _rpfdataFilePath + "fpvtecinfo.dat";
System.out.println("FpVtecInfoDataManager: getFpVtecInfoFileName()"
+ fpvtecinfoFileName);
return fpvtecinfoFileName;
}
// -------------------------------------------------------------------------------------
private void logSQLException(SQLException exception) {
_logger.log("SQL ERROR = " + exception.getErrorCode() + " "
+ exception.getMessage());
exception.printStackTrace(_logger.getPrintWriter());
_logger.log("End of stack trace");
}
// ------------------------------------------------------------------------
public IrregularTimeSeries loadObservedStageTimeSeries(String locationId,
ParamCode paramCode, long startTime,
FpCurPrevVtec fpCurPrevVtecRecord) {
final double missingValue = -9999.0;
String header = "FpVtecInfoDataManager.loadObservedStageTimeSeries(): ";
MeasuringUnit unit = MeasuringUnit.feet;
IrregularTimeSeries stageTimeSeries = new IrregularTimeSeries(unit);
AbsTimeMeasurement measurement = null;
ArrayList obsValueTimeList = new ArrayList();
String obsValueTimeRecord = null;
String[] temp = null;
double obsValue = missingValue;
long obsTime = 0;
try {
obsValueTimeList = fpCurPrevVtecRecord.getObsValuetTimeList();
if (obsValueTimeList != null) {
for (int i = 0; i < obsValueTimeList.size(); i++) {
obsValueTimeRecord = obsValueTimeList.get(i).toString();
// don't let the missing values be included
temp = obsValueTimeRecord.split(",");
obsValue = Double.parseDouble(temp[0]);
obsTime = (Long.parseLong(temp[1])) * MILLIS_PER_SECOND;
measurement = new AbsTimeMeasurement(obsValue, obsTime,
unit);
stageTimeSeries.insertMeasurement(measurement);
}
}
}
catch (Exception e) {
System.err.println(header
+ "error loading observed data from obsValueTimeList");
e.printStackTrace();
}
return stageTimeSeries;
}
// ------------------------------------------------------------------------
public IrregularTimeSeries loadObservedDischargeTimeSeries(
String locationId, ParamCode paramCode, long startTime,
FpCurPrevVtec fpCurPrevVtecRecord) {
final double missingValue = -9999.0;
MeasuringUnit unit = MeasuringUnit.cfs;
String header = "FpVtecInfoDataManager.loadObservedDischargeTimeSeries(): ";
AbsTimeMeasurement measurement = null;
ArrayList obsValueTimeList = new ArrayList();
String obsValueTimeRecord = null;
String[] temp = null;
double obsValue = missingValue;
long obsTime = 0;
IrregularTimeSeries dischargeTimeSeries = new IrregularTimeSeries(unit);
try {
obsValueTimeList = fpCurPrevVtecRecord.getObsValuetTimeList();
if (obsValueTimeList != null) {
for (int i = 0; i < obsValueTimeList.size(); i++) {
obsValueTimeRecord = obsValueTimeList.get(i).toString();
temp = obsValueTimeRecord.split(",");
obsValue = Double.parseDouble(temp[0]);
obsTime = (Long.parseLong(temp[1])) * MILLIS_PER_SECOND;
measurement = new AbsTimeMeasurement(obsValue, obsTime,
unit);
dischargeTimeSeries.insertMeasurement(measurement);
}
}
}
catch (Exception e) {
System.err.println(header
+ "error loading observed data from obsValueTimeList");
e.printStackTrace();
}
return dischargeTimeSeries;
}
// ------------------------------------------------------------------------
public IrregularTimeSeries loadFcstStageTimeSeries(String locationId,
ParamCode paramCode, long endTime, FpCurPrevVtec fpCurPrevVtecRecord) {
long originalBasisTime = 0;
final double missingValue = -9999.0;
MeasuringUnit unit = MeasuringUnit.feet;
AbsTimeMeasurement measurement = null;
String header = "FpVtecInfoDataManager.loadFcstStageTimeSeries(): ";
ArrayList fcstValueTimeList = new ArrayList();
String fcstValueTimeRecord = null;
String[] temp = null;
double fcstValue = missingValue;
long fcstTime = 0;
IrregularTimeSeries stageTimeSeries = new IrregularTimeSeries(unit);
try {
fcstValueTimeList = fpCurPrevVtecRecord.getFcstValueTimeList();
if (fcstValueTimeList != null) {
for (int i = 0; i < fcstValueTimeList.size(); i++) {
fcstValueTimeRecord = fcstValueTimeList.get(i).toString();
temp = fcstValueTimeRecord.split(",");
fcstValue = Double.parseDouble(temp[0]);
fcstTime = (Long.parseLong(temp[1])) * MILLIS_PER_SECOND;
measurement = new AbsTimeMeasurement(fcstValue, fcstTime,
unit);
stageTimeSeries.insertMeasurement(measurement);
}
}
}
catch (Exception e) {
System.err.println(header
+ "error loading forecast data from fcstValueTimeList");
e.printStackTrace();
}
return stageTimeSeries;
}
// -----------------------------------------------------------------------------------
public IrregularTimeSeries loadFcstDischargeTimeSeries(String locationId,
ParamCode paramCode, long endTime, FpCurPrevVtec fpCurPrevVtecRecord) {
long originalBasisTime = 0;
final double missingValue = -9999.0;
MeasuringUnit unit = MeasuringUnit.cfs;
String header = "FpVtecInfoDataManager.loadFcstDischargeTimeSeries(): ";
ArrayList fcstValueTimeList = new ArrayList();
String fcstValueTimeRecord = null;
String[] temp = null;
double fcstValue = missingValue;
long fcstTime = 0;
AbsTimeMeasurement measurement = null;
IrregularTimeSeries dischargeTimeSeries = new IrregularTimeSeries(unit);
try {
fcstValueTimeList = fpCurPrevVtecRecord.getFcstValueTimeList();
if (fcstValueTimeList != null) {
for (int i = 0; i < fcstValueTimeList.size(); i++) {
fcstValueTimeRecord = fcstValueTimeList.get(i).toString();
temp = fcstValueTimeRecord.split(",");
fcstValue = Double.parseDouble(temp[0]);
fcstTime = (Long.parseLong(temp[1])) * MILLIS_PER_SECOND;
measurement = new AbsTimeMeasurement(fcstValue, fcstTime,
unit);
dischargeTimeSeries.insertMeasurement(measurement);
}
}
}
catch (Exception e) {
System.err.println(header
+ "error loading forecast data from fcstValueTimeList");
e.printStackTrace();
}
return dischargeTimeSeries;
}
// ------------------------------------------------------------------------------------
public RatingCurve loadRatingCurve(String locationId) {
RatingCurve ratingCurve = null;
RatingTable ratingTable = new RatingTable(_db);
RatingShiftTable ratingShiftTable = new RatingShiftTable(_db);
RiverstatTable riverstatTable = new RiverstatTable(_db);
List ratingRecordList = null;
List ratingShiftList = null;
List riverstatList = null;
try {
ratingRecordList = ratingTable.select("WHERE LID = '" + locationId
+ "' ORDER by stage");
ratingShiftList = ratingShiftTable.selectNRecords("WHERE LID = '"
+ locationId + "' AND active = 'T' ORDER BY date desc", 1);
riverstatList = riverstatTable.select("WHERE LID = '" + locationId
+ "'");
// determine total amount of active
// rating shifts
double totalShiftAmount = 0.0;
for (int i = 0; i < ratingShiftList.size(); i++) {
RatingShiftRecord shiftRecord = (RatingShiftRecord) ratingShiftList
.get(i);
totalShiftAmount = shiftRecord.getShift_amount();
}
// initialize the RatingCurve object with data from the database,
// including
// the totalShiftAmount
ratingCurve = new RatingCurve(locationId);
ratingCurve.setShiftAmount(totalShiftAmount);
for (int i = 0; i < ratingRecordList.size(); i++) {
RatingRecord record = (RatingRecord) ratingRecordList.get(i);
RatingPoint ratingPoint = new RatingPoint();
ratingPoint.setDischarge(record.getDischarge());
ratingPoint.setUnshiftedStage(record.getStage());
// done by addRatingPoint
// ratingCurve.setShiftAmount(totalShiftAmount);
ratingCurve.addRatingPoint(ratingPoint);
} // end for
// set the USGS fields in the rating curve
if (riverstatList.size() > 0) {
RiverstatRecord riverstatRecord = (RiverstatRecord) riverstatList
.get(0);
ratingCurve.setUsgsRatingNumber(riverstatRecord
.getUsgs_ratenum());
ratingCurve.setRatingDate(riverstatRecord.getRatedat());
}
} catch (SQLException e) {
logSQLException(e);
ratingCurve = null;
}
return ratingCurve;
}
// ------------------------------------------------------------------------------
public SigRiverLevels loadSigRiverLevels(String locationId) {
String header = "FpVtecInfoDataManager.loadSigRiverLevels(): ";
RiverstatTable table = new RiverstatTable(_db);
RiverstatRecord record = null;
SigRiverLevels levels = null;
String whereClause = "WHERE lid = '" + locationId + "'";
try {
List recordList = table.select(whereClause);
if (recordList.size() > 0) {
record = (RiverstatRecord) recordList.get(0);
double floodStage = record.getFs();
double actionStage = record.getWstg();
double floodFlow = record.getFq();
double actionFlow = record.getAction_flow();
// need to change the common lib SigRiverLevels.java
if (DbTable.isNull(actionStage)) {
System.out.println(header + " actionStage is null for "
+ locationId);
}
if (DbTable.isNull(record.getPrimary_pe())) {
System.out.println(header + " primary_pe is null for "
+ locationId);
record.setPrimary_pe("HG");
}
levels = new SigRiverLevels(locationId, record.getPrimary_pe(),
floodStage, actionStage, floodFlow, actionFlow);
// load moderate and major floods
loadFloodCategories(levels);
}
} catch (SQLException e) {
logSQLException(e);
}
return levels;
}
// --------------------------------------------------------------------------------------------------
private void loadFloodCategories(SigRiverLevels levels) {
FloodcatTable table = new FloodcatTable(_db);
FloodcatRecord record = null;
String whereClause = "WHERE lid = '" + levels.getLocationId() + "'";
try {
List recordList = table.select(whereClause);
if (recordList.size() > 0) {
record = (FloodcatRecord) recordList.get(0);
levels.setMinorFloodFlow(record.getMinor_flow());
levels.setModerateFloodFlow(record.getModerate_flow());
levels.setMajorFloodFlow(record.getMajor_flow());
levels.setMinorFloodStage(record.getMinor_stage());
levels.setModerateFloodStage(record.getModerate_stage());
levels.setMajorFloodStage(record.getMajor_stage());
}
} catch (SQLException e) {
logSQLException(e);
}
return;
}
// -------------------------------------------------------------------------------------
public String getPreferredFcstTypeSource(String lid, String pe) {
String header = "FpVtecInfoDataManager.getPreferredFcstTypeSource(): ";
String newTypeSource = null;
IngestFilterTable table = new IngestFilterTable(_db);
IngestFilterRecord record = null;
String whereClause = "WHERE lid = '" + lid + "'" + " AND pe = '" + pe
+ "'" + " AND dur = 0 " + " AND ts like 'F%' "
+ " order by ts_rank ASC";
try {
List recordList = table.select(whereClause);
if (recordList.size() > 0) {
if (pe.charAt(0) == 'H') {
for (int i = 0; i < recordList.size(); i++) {
record = (IngestFilterRecord) recordList.get(i);
if (fcstHeightRecordExists(record)) {
newTypeSource = record.getTs();
break;
}
}
} else // pe is not 'H*', so don't look at fcstHeight to see if
// it exists
{
newTypeSource = record.getTs();
}
}
} catch (SQLException e) {
logSQLException(e);
}
// System.out.println(header + " newTypeSource = " + newTypeSource);
return newTypeSource;
}
// --------------------------------------------------------------------------
// ----------------------------------------------------------------------------------
public boolean fcstHeightRecordExists(IngestFilterRecord ingestRecord) {
boolean result = false;
String header = "FpVtecInfoDataManager.fcstHeightRecordExists(): ";
FcstHeightTable table = new FcstHeightTable(_db);
String whereClause = "WHERE lid = '" + ingestRecord.getLid() + "'"
+ " AND pe = '" + ingestRecord.getPe() + "'" + " AND dur = "
+ ingestRecord.getDur() + " AND ts = '" + ingestRecord.getTs()
+ "'";
try {
int recordCount = table.selectCount(whereClause);
if (recordCount > 0) {
result = true;
}
} catch (SQLException e) {
logSQLException(e);
}
return result;
}
public Map getvtecinfoMap() {
return _vtecinfoMap;
}
public String get_rpfdataFilePath() {
return _rpfdataFilePath;
}
public void set_rpfdataFilePath(String filePath) {
_rpfdataFilePath = filePath;
}
public Database get_db() {
return _db;
}
public void set_db(Database _db) {
this._db = _db;
}
} // end FpVtecInfoDataManager

View file

@ -1,442 +0,0 @@
package ohd.hseb.fp_vtec_info;
import java.io.BufferedReader;
import java.io.EOFException;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;
public class FpVtecInfoFileReader
{
//private List _fpvtecinfoList;
private String _fullFilePath = null;
private boolean _debug = false;
private BufferedReader _reader = null;
private Map _fpcurprevvtecMap = null;
// ------------------------------------------------------------------------------
public FpVtecInfoFileReader()
{
}
// ----------------------------------------------------------------------------------
public FpVtecInfoFileReader(String fullFilePath)
{
_fullFilePath = fullFilePath;
_fpcurprevvtecMap = new HashMap();
}
// ----------------------------------------------------------------------------------
public Map read()
{
String header = "FpVtecInfoFileReader.read() ";
try
{
FileReader fileReader = new FileReader(_fullFilePath);
_reader = new BufferedReader(fileReader);
readFileHeader();
boolean done = false;
while ( ! done )
{
try
{
FpCurPrevVtec fpvtecinfo = readFpVtecData();
if (fpvtecinfo != null)
{
_fpcurprevvtecMap.put(fpvtecinfo.getLocId(), fpvtecinfo);
}
else
{
System.out.println("fpvtecinfo is null");
debug_logline(header + "fpvtecinfo is null");
}
}
catch (EOFException e)
{
done = true;
}
catch (Exception e)
{
System.err.println(header +
"Exception reading file " + _fullFilePath +
" " + e.getMessage());
e.printStackTrace();
done = true;
}
} //end while
if (_reader != null)
{
_reader.close();
_reader = null;
}
} //end try
catch (FileNotFoundException e)
{
System.err.println("Unable to open" + _fullFilePath);
}
catch (IOException e)
{
System.err.println("Unable to open" + _fullFilePath);
}
return _fpcurprevvtecMap;
}
// ----------------------------------------------------------------------------------
private void readFileHeader() throws IOException
{
String header = "FpVtecInfoFileReader.readFileHeader(): ";
String line = null;
//ignore the first 4 lines in the fpvtecinfo.dat
line = _reader.readLine();
debug_logline(header + " line 1 = " + line);
line = _reader.readLine();
debug_logline(header + " line 2 = " + line);
line = _reader.readLine();
debug_logline(header + " line 3 = " + line);
line = _reader.readLine();
debug_logline(header + " line 4 = " + line);
line = _reader.readLine();
debug_logline(header + " line 5 = " + line);
line = _reader.readLine();
debug_logline(header + " line 6 = " + line);
}
// ----------------------------------------------------------------------------------
private FpCurPrevVtec readFpVtecData() throws IOException
{
String header = "FpVtecInfoFileReader.readFpVtecData(): ";
StringTokenizer fpLineTokenizer = null;
StringTokenizer curVtecLineTokenizer = null;
StringTokenizer prevVtecLineTokenizer = null;
StringTokenizer observedTSLineTokenizer = null;
StringTokenizer fcstTSLineTokenizer = null;
ArrayList obsValueTimeList = new ArrayList();
ArrayList fcstValueTimeList = new ArrayList();
// The first line includes fp information for specific location
String stationFpDataLine = _reader.readLine();
if (stationFpDataLine == null)
{
throw new EOFException();
}
else
fpLineTokenizer = new StringTokenizer(stationFpDataLine, ",");
// The second line includes current VTEC information for specific location
String stationCurVtecDataLine = _reader.readLine();
if (stationCurVtecDataLine == null)
{
throw new EOFException();
}
else
curVtecLineTokenizer = new StringTokenizer(stationCurVtecDataLine, ",");
// The third line includes previous VTEC information for specific location
String stationPrevVtecDataLine = _reader.readLine();
if (stationPrevVtecDataLine == null)
{
throw new EOFException();
}
else if (stationPrevVtecDataLine.equals("MSG"))
{
//no previous event exist
System.out.println("No previous event exist.");
}
else
{
prevVtecLineTokenizer = new StringTokenizer(stationPrevVtecDataLine, ",");
}
// The fourth line includes observed timesreis data
String stationObservedTSLine = _reader.readLine();
if (stationObservedTSLine == null)
{
throw new EOFException();
}
else if (stationObservedTSLine.equals("MSG"))
{
//no observed TS exists
System.out.println("No Observed TimeSeries data exists.");
}
else
{
observedTSLineTokenizer = new StringTokenizer(stationObservedTSLine, ";");
}
// The fifth line includes forecast timesreis data
String stationForecastTSLine = _reader.readLine();
if (stationForecastTSLine == null)
{
throw new EOFException();
}
else if (stationForecastTSLine.equals("MSG"))
{
//no forecast TS exists
System.out.println("No Forecast TimeSeries data exists.");
}
else
{
fcstTSLineTokenizer = new StringTokenizer(stationForecastTSLine, ";");
}
FpCurPrevVtec descriptor = new FpCurPrevVtec();
// parse out the first line FP information
String lid = fpLineTokenizer.nextToken();
descriptor.setLocId(lid.trim());
String name = fpLineTokenizer.nextToken();
descriptor.setLocName(name.trim());
String stream = fpLineTokenizer.nextToken();
descriptor.setLocStream(stream.trim());
String pe = fpLineTokenizer.nextToken();
descriptor.setLocPe(pe.trim());
double fs = Double.parseDouble(fpLineTokenizer.nextToken());
descriptor.setFloodStg(fs);
double fq = Double.parseDouble(fpLineTokenizer.nextToken());
descriptor.setFloodFlow(fq);
long obs_begintime = Long.parseLong(fpLineTokenizer.nextToken());
descriptor.setObsBeginTime(obs_begintime);
long fcst_endtime = Long.parseLong(fpLineTokenizer.nextToken());
descriptor.setFcstEndTime(fcst_endtime);
double adjustendhrs = Double.parseDouble(fpLineTokenizer.nextToken());
descriptor.setAdjustEndhrs(adjustendhrs);
debug_logline(header + "lid = " + lid + " " +
"name = " + name + " " +
"stream = " + stream);
// parse out second line current VTEC information
String cur_action = curVtecLineTokenizer.nextToken();
descriptor.setcurAction(cur_action.trim());
String cur_phenom = curVtecLineTokenizer.nextToken();
descriptor.setcurPhenom(cur_phenom.trim());
String cur_signif = curVtecLineTokenizer.nextToken();
descriptor.setcurSignif(cur_signif.trim());
String cur_severity = curVtecLineTokenizer.nextToken();
descriptor.setcurSeverity(cur_severity.trim());
String cur_cause = curVtecLineTokenizer.nextToken();
descriptor.setcurCause(cur_cause.trim());
String cur_record = curVtecLineTokenizer.nextToken();
descriptor.setcurRecord(cur_record.trim());
int cur_etn = Integer.parseInt(curVtecLineTokenizer.nextToken());
descriptor.setcurEtn(cur_etn);
double cur_crest_value = Double.parseDouble(curVtecLineTokenizer.nextToken());
descriptor.setcurCrestValue(cur_crest_value);
long cur_begintime = Long.parseLong(curVtecLineTokenizer.nextToken());
descriptor.setcurBeginTime(cur_begintime);
long cur_endtime = Long.parseLong(curVtecLineTokenizer.nextToken());
descriptor.setcurEndTime(cur_endtime);
long cur_risetime = Long.parseLong(curVtecLineTokenizer.nextToken());
descriptor.setcurRiseTime(cur_risetime);
long cur_cresttime = Long.parseLong(curVtecLineTokenizer.nextToken());
descriptor.setcurCrestTime(cur_cresttime);
long cur_falltime = Long.parseLong(curVtecLineTokenizer.nextToken());
descriptor.setcurFallTime(cur_falltime);
debug_logline(header + "cur_action = " + cur_action + " " +
"cur_phenom = " + cur_phenom + " " +
"cur_signif = " + cur_signif + " " +
"cur_severity = " + cur_severity + " " +
"cur_cause = " + cur_cause + " " +
"cur_record = " + cur_record + " " +
"cur_etn = " + cur_etn + " " +
"cur_crest_value = " + cur_crest_value);
// parse out third line previous VTEC information
if (prevVtecLineTokenizer != null)
{
String prev_action = prevVtecLineTokenizer.nextToken();
descriptor.setprevAction(prev_action);
String prev_phenom = prevVtecLineTokenizer.nextToken();
descriptor.setprevPhenom(prev_phenom);
String prev_signif = prevVtecLineTokenizer.nextToken();
descriptor.setprevSignif(prev_signif);
String prev_severity = prevVtecLineTokenizer.nextToken();
descriptor.setprevSeverity(prev_severity);
String prev_cause = prevVtecLineTokenizer.nextToken();
descriptor.setprevCause(prev_cause);
String prev_record = prevVtecLineTokenizer.nextToken();
descriptor.setprevRecord(prev_record);
int prev_etn = Integer.parseInt(prevVtecLineTokenizer.nextToken());
descriptor.setprevEtn(prev_etn);
double prev_crest_value = Double.parseDouble(prevVtecLineTokenizer.nextToken());
descriptor.setprevCrestValue(prev_crest_value);
String prev_rise_ts = prevVtecLineTokenizer.nextToken();
descriptor.setprevRiseType(prev_rise_ts);
String prev_crest_ts = prevVtecLineTokenizer.nextToken();
descriptor.setprevCrestType(prev_crest_ts);
String prev_fall_ts = prevVtecLineTokenizer.nextToken();
descriptor.setprevFallType(prev_fall_ts);
long prev_begintime = Long.parseLong(prevVtecLineTokenizer.nextToken());
descriptor.setprevBeginTime(prev_begintime);
long prev_endtime = Long.parseLong(prevVtecLineTokenizer.nextToken());
descriptor.setprevEndTime(prev_endtime);
long prev_risetime = Long.parseLong(prevVtecLineTokenizer.nextToken());
descriptor.setprevRiseTime(prev_risetime);
long prev_cresttime = Long.parseLong(prevVtecLineTokenizer.nextToken());
descriptor.setprevCrestTime(prev_cresttime);
long prev_falltime = Long.parseLong(prevVtecLineTokenizer.nextToken());
descriptor.setprevFallTime(prev_falltime);
long prev_producttime = Long.parseLong(prevVtecLineTokenizer.nextToken());
descriptor.setprevProductTime(prev_producttime);
debug_logline(header + "prev_action = " + prev_action + " " +
"prev_phenom = " + prev_phenom + " " +
"prev_signif = " + prev_signif + " " +
"prev_severity = " + prev_severity + " " +
"prev_cause = " + prev_cause + " " +
"prev_record = " + prev_record + " " +
"prev_etn = " + prev_etn + " " +
"prev_crest_value = " + prev_crest_value + " " +
"prev_rise_ts = " + prev_rise_ts + " " +
"prev_crest_ts = " + prev_crest_ts + " " +
"prev_fall_ts = " + prev_fall_ts);
}
// parse out the observed time series data
if (observedTSLineTokenizer != null)
{
while (observedTSLineTokenizer.hasMoreTokens()) {
obsValueTimeList.add(observedTSLineTokenizer.nextToken());
}
descriptor.setObsValuetTimeList(obsValueTimeList);
}
// pase out the forecast time series data
if (fcstTSLineTokenizer != null)
{
while (fcstTSLineTokenizer.hasMoreTokens()) {
fcstValueTimeList.add(fcstTSLineTokenizer.nextToken());
}
descriptor.setFcstValueTimeList(fcstValueTimeList);
}
return descriptor;
}
//---------------------------------------------------------
public void setDebug(boolean debug)
{
this._debug = debug;
}
//---------------------------------------------------------------------------------
public boolean getDebug()
{
return _debug;
}
// ----------------------------------------------------------------------------------
private void debug_logline(String message)
{
debug_log(message + '\n');
return;
}
// ----------------------------------------------------------------------------------
private void debug_log(String message)
{
if (getDebug())
{
System.out.print(message);
}
return;
}
// ----------------------------------------------------------------------------------
public Map getFpCurPrevVtecMap()
{
return _fpcurprevvtecMap;
}
// ---------------------------------------------------------------------------------
}

View file

@ -1,233 +0,0 @@
package ohd.hseb.fp_vtec_info;
import java.awt.Point;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionListener;
import ohd.hseb.db.DbTimeHelper;
import ohd.hseb.util.DataPoint;
import ohd.hseb.util.TimeHelper;
import ohd.hseb.util.TimeHolder;
import ohd.hseb.util.gui.drawing.TsPaintableCanvas;
public class TimeLineAdjustmentListener extends MouseAdapter implements MouseMotionListener
{
private boolean _button1Down = false;
private boolean _tipShownOnce = false;
//variables related to keyboard commands
private boolean _hasFocus = false;
private Point _mousePosition = null;
private TimeHolder _beginTimeHolder = null;
private TimeHolder _endTimeHolder = null;
private TimeHolder _riseTimeHolder = null;
private TimeHolder _crestTimeHolder = null;
private TimeHolder _fallTimeHolder = null;
private TimeHolder[] _timeHolderArray = null;
private TimeHolder _selectedTimeHolder = null;
//List _pointList = new ArrayList();
private TsPaintableCanvas _canvas = null;
private FpVtecInfo _worker = null;
// constructor
public TimeLineAdjustmentListener(FpVtecInfo worker,
TsPaintableCanvas canvas,
TimeHolder beginTimeHolder,
TimeHolder endTimeHolder,
TimeHolder riseTimeHolder,
TimeHolder crestTimeHolder,
TimeHolder fallTimeHolder)
{
_beginTimeHolder = beginTimeHolder;
_endTimeHolder = endTimeHolder;
_riseTimeHolder = riseTimeHolder;
_crestTimeHolder = crestTimeHolder;
_fallTimeHolder = fallTimeHolder;
_timeHolderArray = new TimeHolder[] {beginTimeHolder,
endTimeHolder,
riseTimeHolder,
crestTimeHolder,
fallTimeHolder};
_canvas = canvas;
_worker = worker;
}
public void mouseDragged(MouseEvent event)
{
String header = "TimeLineAdjustmentListener.mouseDragged(): ";
System.out.println(header + "activated ");
if (_button1Down)
{
Point point = event.getPoint();
//System.out.println("activated mouseDragged, button = " + button );
//adjustTimeLine(point);
}
}
public void mouseMoved(MouseEvent event)
{
_mousePosition = event.getPoint();
//do nothing
}
public void mousePressed(MouseEvent event)
{
String header = "TimeLineAdjustmentListener.mousePressed(): ";
System.out.println(header);
int button = event.getButton();
if (button == MouseEvent.BUTTON1)
{
_button1Down = true;
_selectedTimeHolder = findClosestTimeHolder(event.getPoint());
}
else
{
}
return;
}
public void mouseReleased(MouseEvent event)
{
System.out.println("Precip adjust listener: mouseReleased()");
int button = event.getButton();
if (button == MouseEvent.BUTTON1)
{
_button1Down = false;
adjustTimeLine(event.getPoint());
_selectedTimeHolder = null;
}
}
public void mouseEntered(MouseEvent event)
{
//get the focus on this canvas, so that the keyboard commands will work on it
//AnalysisWindow.this._precipCanvas.requestFocusInWindow();
// System.out.println("mouseEntered():" + " requested focus ");
_hasFocus = true;
}
public void mouseExited(MouseEvent event)
{
_hasFocus = false;
}
public void keyPressed(KeyEvent e)
{
}
public void keyReleased(KeyEvent e)
{
}
public void keyTyped(KeyEvent e)
{
}
// ----------------------------------------------------------------------------------
private TimeHolder findClosestTimeHolder(Point point)
{
long timeInMillis = getTimeFromPoint(point);
long timeWindowInHours = 3;
final long timeWindowInMillis = timeWindowInHours * TimeHelper.MILLIS_PER_HOUR;
long timeDiffInMillis = 0;
long bigTimeInMillis = timeWindowInMillis + 1;
long minDiffInMillis = bigTimeInMillis;
TimeHolder closestTimeHolder = null;
for (int i = 0; i < _timeHolderArray.length; i++)
{
TimeHolder timeHolder = _timeHolderArray[i];
long timefromtimeholder = timeHolder.getTime();
timeDiffInMillis = Math.abs(timeHolder.getTime() - timeInMillis);
if (timeDiffInMillis < minDiffInMillis)
{
minDiffInMillis = timeDiffInMillis;
closestTimeHolder = timeHolder;
}
}
//make sure that the closest one is within the time window
if (minDiffInMillis > timeWindowInMillis)
{
closestTimeHolder = null;
}
return closestTimeHolder;
}
// ----------------------------------------------------------------------------------
private long getTimeFromPoint(Point point)
{
DataPoint dataPoint = _canvas.getViewport().getDataPoint(point);
long newTime = (long) Math.floor(dataPoint.getX());
newTime /= TimeHelper.MILLIS_PER_HALF_HOUR;
newTime *= TimeHelper.MILLIS_PER_HALF_HOUR;
return newTime;
}
private void adjustTimeLine(Point point)
{
String header = "TimeLineAdjustment.adjustTimeLine(): ";
TimeHolder timeHolder = _selectedTimeHolder;
System.out.println(header + "_selectedTimeHolder = " + _selectedTimeHolder);
if (timeHolder == null)
{
return;
}
long newTime = getTimeFromPoint(point);
long oldTime = timeHolder.getTime();
System.out.println(header + DbTimeHelper.getDateTimeStringFromLongTime(oldTime) +
" new time = " + DbTimeHelper.getDateTimeStringFromLongTime(newTime) );
timeHolder.setTime(newTime);
System.out.println(header + "time line moved to " +
DbTimeHelper.getDateTimeStringFromLongTime(newTime));
_worker.getFrame().updateCurDateTimeTextField();
_worker.getFrame().updateGraph();
} //end adjustTimeLine
} //end TimeLineAdjustmentListener
//--------------------------------------------------------------------

View file

@ -1,19 +0,0 @@
package ohd.hseb.geomap.contour;
/**
*
* @author cgobs
* This is an interface for a 2-D (row * col) non-jagged array that contains doubles.
*/
public interface ContourGrid
{
double getValue(int row, int col);
void setValue(int row, int col, double value);
double[][] getValuesArray();
int getRowCount();
int getColCount();
}

View file

@ -1,23 +0,0 @@
package ohd.hseb.geomap.contour;
public class Interpolator
{
// -----------------------------------------------------------------------------------------
public Interpolator()
{
}
// -----------------------------------------------------------------------------------------
public double interpolate(double targetX, double x1, double y1, double x2, double y2)
{
double slope = (y2 - y1) / (x2 - x1);
double intercept = (y1) - (slope*x1);
double y = (slope*targetX) + intercept;
return y;
}
// -----------------------------------------------------------------------------------------
}

View file

@ -1,15 +0,0 @@
package ohd.hseb.geomap.contour;
import ohd.hseb.geomap.model.LatLonPoint;
import ohd.hseb.geomap.model.RowColumnPoint;
public interface RowColToLatLonTranslator
{
LatLonPoint getLatLonPoint(RowColumnPoint rowColumnPoint);
LatLonPoint getLatLonPoint(double row, double col);
// RowColumnPoint getRowColumnPoint(double lat, double lon);
RowColumnPoint getRowColumnPoint(LatLonPoint latLonPoint);
}

View file

@ -1,254 +0,0 @@
package ohd.hseb.geomap.contour;
import java.util.ArrayList;
import java.util.List;
import ohd.hseb.geomap.model.LatLonPoint;
import ohd.hseb.geomap.model.LatLonPolyline;
import ohd.hseb.geomap.model.RowColumnPoint;
import ohd.hseb.util.Range;
public class RowToLatLonContourer
{
private double[][] _valueArray;
private int _rowCount = 0;
private int _colCount = 0;
private RowColToLatLonTranslator _positionTranslator = null;
// --------------------------------------------------------------------------------------------
public RowToLatLonContourer(short [][] valueArray, RowColToLatLonTranslator translator )
{
this (getDoubleArrayFromShortArray(valueArray), translator);
}
// --------------------------------------------------------------------------------------------
public RowToLatLonContourer(ContourGrid grid, RowColToLatLonTranslator translator)
{
this (grid.getValuesArray(), translator);
}
// --------------------------------------------------------------------------------------------
public RowToLatLonContourer(double [][] valueArray, RowColToLatLonTranslator translator)
{
setValueArray(valueArray);
_rowCount = valueArray.length;
if (_rowCount > 0)
{
_colCount = valueArray[0].length;
}
_positionTranslator = translator;
}
// --------------------------------------------------------------------------------------------
private static double[][] getDoubleArrayFromShortArray(short[][] shortArray)
{
int rowCount = shortArray.length;
int colCount = 0;
if (rowCount > 0)
{
colCount = shortArray[0].length;
}
double[][] doubleArray = new double[rowCount][colCount];
for (int row = 0; row < rowCount; row ++)
{
for (int col = 0; col < colCount; col++)
{
doubleArray[row][col] = shortArray[row][col];
}
}
return doubleArray;
}
// --------------------------------------------------------------------------------------------
public void setValueArray(double[][] valueArray)
{
_valueArray = valueArray;
}
// --------------------------------------------------------------------------------------------
public double[][] getValueArray()
{
return _valueArray;
}
// --------------------------------------------------------------------------------------------
public double getValue(int row, int col)
{
// System.out.println("row = " + row + " col = " + col);
return _valueArray[row][col];
}
// --------------------------------------------------------------------------------------------
public List< List<LatLonPolyline> > contour(double[] levelArray)
{
List< List<LatLonPolyline> > listOfLatLonPolylineLists = new ArrayList<List<LatLonPolyline> >();
for (int i = 0; i < levelArray.length; i++)
{
List<LatLonPolyline> polylineList = contourOneLevel(levelArray[i]);
listOfLatLonPolylineLists.add(polylineList);
}
return listOfLatLonPolylineLists;
}
// --------------------------------------------------------------------------------------------
public List<LatLonPolyline> contourOneLevel(double level)
{
List<LatLonPolyline> polylineList = new ArrayList<LatLonPolyline>();
LatLonPoint previousPoint = null;
for (int row = 0; row < _rowCount; row++)
{
for (int col = 0; col < _colCount; col++)
{
List<LatLonPoint> pointList = getPointsFromFourCells(level, row, col); //eliminate duplicate points
if (pointList.size() > 0)
{
LatLonPolyline polyline = new LatLonPolyline(pointList);
polylineList.add(polyline);
}
}
}
return polylineList;
}
// --------------------------------------------------------------------------------------------
private List<LatLonPoint> getPointsFromFourCells(double level, int row, int col)
{
String header = "RowToLatLonContourer.getPointsFromFourCells(): ";
List latLonPointList = new ArrayList<LatLonPoint> ();
LatLonPoint point = null;
if (col < _colCount - 1)
{
point = getCrossOverLatLonPoint(level, row, col, row, col+1);
addPointToListIfNotNull(latLonPointList, point);
if (row < _rowCount - 1)
{
point = getCrossOverLatLonPoint(level, row, col+1, row+1, col+1);
addPointToListIfNotNull(latLonPointList, point);
point = getCrossOverLatLonPoint(level, row+1, col+1, row+1, col);
addPointToListIfNotNull(latLonPointList, point);
}
}
if (row < _rowCount - 1)
{
point = getCrossOverLatLonPoint(level, row+1, col, row, col);
addPointToListIfNotNull(latLonPointList, point);
}
if (latLonPointList.size() == 1)
{
latLonPointList.clear();
System.out.println(header + "clearing list of its single point");
}
return latLonPointList;
}
// --------------------------------------------------------------------------------------------
private LatLonPoint getCrossOverLatLonPoint(double level,
int row1, int col1,
int row2, int col2)
{
LatLonPoint point = null;
double value1 = getValue(row1, col1);
double value2 = getValue(row2, col2);
Range range = new Range(value1, value2);
if (range.isBetweenInclusive(level))
{
if (value1 == value2) //ignore it, this is counterintuitive, but needed
{
//do nothing
}
else //there is a distinct boundary and value1 != value2
{
LatLonPoint latLonPoint1 = getLatLonPoint(row1, col1);
LatLonPoint latLonPoint2 = getLatLonPoint(row2, col2);
LatLonPoint interpolatedPoint = interpolate(level, latLonPoint1, value1, latLonPoint2, value2);
point = interpolatedPoint;
}
}
return point;
}
// --------------------------------------------------------------------------------------------
private LatLonPoint interpolate(double targetValue,
LatLonPoint point1, double value1,
LatLonPoint point2, double value2)
{
// String header = "RowToLatLonContourer.interpolate(): ";
Interpolator interpolator = new Interpolator();
double lat1 = point1.getLat();
double lat2 = point2.getLat();
double lon1 = point1.getLon();
double lon2 = point2.getLon();
// these are switched from the usual order, since we are seeking lat and lon instead of value
double interpolatedLat = interpolator.interpolate(targetValue, value1, lat1, value2, lat2);
double interpolatedLon = interpolator.interpolate(targetValue, value1, lon1, value2, lon2);
LatLonPoint newPoint = new LatLonPoint(interpolatedLat, interpolatedLon);
RowColumnPoint rcPoint = getRowColumnPoint(newPoint);
// System.out.println(header + rcPoint );
return newPoint;
}
// --------------------------------------------------------------------------------------------
private LatLonPoint getLatLonPoint(int row, int col)
{
LatLonPoint point = _positionTranslator.getLatLonPoint(new RowColumnPoint(row, col));
return point;
}
// --------------------------------------------------------------------------------------------
private RowColumnPoint getRowColumnPoint(LatLonPoint latLonPoint)
{
RowColumnPoint point = _positionTranslator.getRowColumnPoint(latLonPoint);
return point;
}
// --------------------------------------------------------------------------------------------
private void addPointToListIfNotNull(List<LatLonPoint> pointList, LatLonPoint point)
{
if (point != null)
{
pointList.add(point);
}
return;
}
// --------------------------------------------------------------------------------------------
}

View file

@ -1,8 +0,0 @@
package ohd.hseb.geomap.model;
public interface DrawableShape
{
}

View file

@ -1,228 +0,0 @@
package ohd.hseb.geomap.model;
import java.util.ArrayList;
import java.util.List;
import ohd.hseb.geomap.contour.RowColToLatLonTranslator;
public class ElevationMap implements RowColToLatLonTranslator
{
private LatLonBounds _latLonBounds = null;
private double _latResInDegrees = 0;
private double _lonResInDegrees = 0;
private short[][] _valueArray = null;
private int _rowCount = 0;
private int _colCount = 0;
// ----------------------------------------------------------------------------------------------------------------------
public ElevationMap(LatLonBounds latLonBounds, double latResInDegrees, double lonResInDegrees)
{
_latLonBounds = new LatLonBounds(latLonBounds);
setLatResInDegrees(latResInDegrees);
setLonResInDegrees(lonResInDegrees);
_rowCount = (int) Math.ceil(latLonBounds.getLatDifference() / latResInDegrees);
_colCount = (int) Math.ceil(latLonBounds.getLonDifference() / lonResInDegrees);
_valueArray = new short[getRowCount()][getColCount()];
}
// ------------------------------------------------------------------------------
public void setLatLonBounds(LatLonBounds latLonBounds)
{
_latLonBounds = latLonBounds;
}
// ------------------------------------------------------------------------------
public LatLonBounds getLatLonBounds()
{
return _latLonBounds;
}
// ------------------------------------------------------------------------------
public List<LatLonPoint> getLatLonPointList()
{
return new ArrayList<LatLonPoint>();
}
// ------------------------------------------------------------------------------
public void setLatResInDegrees(double latResInDegrees)
{
_latResInDegrees = latResInDegrees;
}
public double getLatResInDegrees()
{
return _latResInDegrees;
}
public void setLonResInDegrees(double lonResInDegrees)
{
_lonResInDegrees = lonResInDegrees;
}
public double getLonResInDegrees()
{
return _lonResInDegrees;
}
// ------------------------------------------------------------------------------
public RowColumnPoint getRowColumnPoint(LatLonPoint latLonPoint)
{
double row = getRow(latLonPoint.getLat());
double col = getCol(latLonPoint.getLon());
return new RowColumnPoint(row, col);
}
// ------------------------------------------------------------------------------
public LatLonPoint getLatLonPoint(RowColumnPoint rowColumnPoint)
{
double lat = getLat((int) rowColumnPoint.getRow());
double lon = getLon((int) rowColumnPoint.getCol());
return new LatLonPoint(lat, lon);
}
// ------------------------------------------------------------------------------
public LatLonPoint getLatLonPoint(double row, double col)
{
double lat = getLat((int) row);
double lon = getLon((int) col);
return new LatLonPoint(lat, lon);
}
// ------------------------------------------------------------------------------
public int getRow(double lat)
{
int row = -1;
double latDiff = _latLonBounds.getNorthLat() - lat;
row = (int) Math.ceil(latDiff / getLatResInDegrees());
return row;
}
// ------------------------------------------------------------------------------
public int getCol(double lon)
{
int col = -1;
double lonDiff = lon - _latLonBounds.getWestLon();
col = (int) Math.ceil(lonDiff / getLonResInDegrees());
return col;
}
// ------------------------------------------------------------------------------
public double getLat(int row)
{
double lat = _latLonBounds.getNorthLat() - (row * getLatResInDegrees());
return lat;
}
// ------------------------------------------------------------------------------
public double getLon(int col)
{
double lon = _latLonBounds.getWestLon() + (col * getLonResInDegrees());
return lon;
}
// ------------------------------------------------------------------------------
public void setValueByLatLon(double lat, double lon, short value)
{
setValue(getRow(lat), getCol(lon), value);
}
// ------------------------------------------------------------------------------
public void setValue(int row, int col, short value)
{
_valueArray[row][col] = value;
}
// ------------------------------------------------------------------------------
public short[][] getValueArray()
{
return _valueArray;
}
// ------------------------------------------------------------------------------
public short getValue(int row, int col)
{
short value = 0;
if (isInRange(row, col))
{
value = _valueArray[row][col];
}
return value;
}
private boolean isInRange(int row, int col)
{
boolean result = false;
if ((row >-1) &&
(row < getRowCount()) &&
(col >-1) &&
(col < getColCount()) )
{
result = true;
}
return result;
}
public short getValueByLatLon(double lat, double lon)
{
int row = getRow(lat);
int col = getCol(lon);
return getValue(row, col);
}
// ------------------------------------------------------------------------------
public String toString()
{
StringBuffer buffer = new StringBuffer();
buffer.append(getLatLonBounds() + "lat res = " + getLatResInDegrees() + " lon res = " + getLonResInDegrees());
int rowCount = getRowCount();
int colCount = getColCount();
for (int row = 0; row < rowCount; row++)
{
for (int col = 0; col < colCount; col++)
{
buffer.append(_valueArray[row][col] + " ");
}
buffer.append("\n");
}
return buffer.toString();
}
// ------------------------------------------------------------------------------
public void setRowCount(int rowCount)
{
_rowCount = rowCount;
}
public int getRowCount()
{
return _rowCount;
}
public void setColCount(int colCount)
{
_colCount = colCount;
}
public int getColCount()
{
return _colCount;
}
// ------------------------------------------------------------------------------
}

View file

@ -1,207 +0,0 @@
package ohd.hseb.geomap.model;
import java.util.HashMap;
import java.util.Map;
import ohd.hseb.geomap.contour.RowColToLatLonTranslator;
public class HrapRowColToLatLonConverter implements RowColToLatLonTranslator
{
private static double RADIANS_PER_DEGREE = 0.017453293;
private static double DEGREES_PER_RADIAN = 57.29577951;
private static double EARTH_RADIUS = 6371.2;
private static double MESH_LEN = 4.7625;
private static double STDLAT = 60;
private static double STDLON = 105;
// public static int LOCAL_HRAP_ROWS = 131;
// public static int LOCAL_HRAP_COLS = 131;
private int _baseNationalRow = 0;
private int _baseNationalColumn = 0;
private Map<RowColumnPoint, LatLonPoint> _latLonCache = new HashMap<RowColumnPoint, LatLonPoint>();
// -------------------------------------------------------------------------------------------------
/**
* This class translates between local Hrap grid locations and Lat-Lon corrdinates.
* It uses the baseNationalRow and the baseNationalColumn for this
*/
public HrapRowColToLatLonConverter(int baseNationalRow, int baseNationalColumn)
{
_baseNationalRow = baseNationalRow;
_baseNationalColumn = baseNationalColumn;
}
// -------------------------------------------------------------------------------------------------
public RowColumnPoint getRowColumnPoint(LatLonPoint latLonPoint)
{
return getRowColumnPoint(latLonPoint.getLat(), latLonPoint.getLon());
}
// -------------------------------------------------------------------------------------------------
public RowColumnPoint getRowColumnPoint(double lat, double lon)
{
double tlat, re;
double latrad, lonrad;
double r;
double x, y;
tlat = STDLAT * RADIANS_PER_DEGREE;
re = (EARTH_RADIUS * (1. + Math.sin(tlat))) / MESH_LEN;
latrad = lat * RADIANS_PER_DEGREE;
lonrad = (lon + 180. - STDLON) * RADIANS_PER_DEGREE;
r = re * Math.cos(latrad) / (1. + Math.sin(latrad));
x = r * Math.sin(lonrad);
y = r * Math.cos(lonrad);
double col = x + 401.;
double row = y + 1601.;
col -= getBaseNationalColumn();
row -= getBaseNationalRow();
return new RowColumnPoint(row, col);
}
// -------------------------------------------------------------------------------------------------
public static RowColumnPoint getNationalRowColumnPoint(LatLonPoint latLonPoint)
{
return getNationalRowColumnPoint(latLonPoint.getLat(), latLonPoint.getLon());
}
// -------------------------------------------------------------------------------------------------
public static RowColumnPoint getNationalRowColumnPoint(double lat, double lon)
{
double tlat, re;
double latrad, lonrad;
double r;
double x, y;
tlat = STDLAT * RADIANS_PER_DEGREE;
re = (EARTH_RADIUS * (1. + Math.sin(tlat))) / MESH_LEN;
latrad = lat * RADIANS_PER_DEGREE;
lonrad = (lon + 180. - STDLON) * RADIANS_PER_DEGREE;
r = re * Math.cos(latrad) / (1. + Math.sin(latrad));
x = r * Math.sin(lonrad);
y = r * Math.cos(lonrad);
double col = x + 401.;
double row = y + 1601.;
return new RowColumnPoint(row, col);
}
// -------------------------------------------------------------------------------------------------
public LatLonPoint getLatLonPoint(RowColumnPoint rowColumnPoint)
{
return getLatLonPoint(rowColumnPoint.getRow(), rowColumnPoint.getCol());
}
// -------------------------------------------------------------------------------------------------
public LatLonPoint getLatLonPointOld(double row, double col)
{
RowColumnPoint rowColumnPoint = new RowColumnPoint(row, col);
LatLonPoint latLonPoint = _latLonCache.get(rowColumnPoint);
if (latLonPoint == null )
{
latLonPoint = calculateLatLonPoint(row, col);
_latLonCache.put(rowColumnPoint, latLonPoint);
}
return latLonPoint;
}
// -------------------------------------------------------------------------------------------------
public LatLonPoint getLatLonPoint(double row, double col)
{
return calculateLatLonPoint(row, col);
}
// -------------------------------------------------------------------------------------------------
public LatLonPoint calculateLatLonPoint(double row, double col)
{
row = row + getBaseNationalRow();
col = col + getBaseNationalColumn();
double x, y;
double rr, gi;
double ang, tlat;
double lat = 0;
double lon = 0;
tlat = 60.0 / DEGREES_PER_RADIAN;
x = col - 401.;
y = row - 1601.;
rr = (x * x) + (y * y);
gi = ((EARTH_RADIUS * (1 + Math.sin(tlat)))/MESH_LEN);
gi = gi * gi;
lat = Math.asin((gi - rr) / (gi + rr)) * DEGREES_PER_RADIAN;
ang = Math.atan2(y, x) * DEGREES_PER_RADIAN;
if (ang < 0)
ang=ang + 360.;
lon = 270 + STDLON - ang;
if (lon < 0)
lon += 360.;
if (lon > 360)
lon -= 360.;
lon *= -1.0;
return new LatLonPoint(lat, lon);
}
// -------------------------------------------------------------------------------------------------
private void setBaseNationalRow(int baseNationalRow)
{
_baseNationalRow = baseNationalRow;
}
// -------------------------------------------------------------------------------------------------
private int getBaseNationalRow()
{
return _baseNationalRow;
}
// -------------------------------------------------------------------------------------------------
private void setBaseNationalColumn(int baseNationalColumn)
{
_baseNationalColumn = baseNationalColumn;
}
// -------------------------------------------------------------------------------------------------
private int getBaseNationalColumn()
{
return _baseNationalColumn;
}
// -------------------------------------------------------------------------------------------------
}

View file

@ -1,199 +0,0 @@
package ohd.hseb.geomap.model;
public class LatLonBounds
{
private double _northLat = 0;
private double _southLat = 0;
private double _westLon = 0;
private double _eastLon = 0;
// -----------------------------------------------------------------------------------------------------------
public LatLonBounds(double northLat, double southLat, double westLon, double eastLon)
{
setNorthLat(northLat);
setSouthLat(southLat);
setWestLon(westLon);
setEastLon(eastLon);
return;
}
// -----------------------------------------------------------------------------------------------------------
public LatLonBounds(LatLonPoint northWestLatLong, LatLonPoint southEastLatLong)
{
setNorthLat(northWestLatLong.getLat());
setSouthLat(southEastLatLong.getLat());
setWestLon(northWestLatLong.getLon());
setEastLon(southEastLatLong.getLon());
}
// -----------------------------------------------------------------------------------------------------------
public LatLonBounds(LatLonBounds origBounds)
{
setNorthLat(origBounds.getNorthLat());
setSouthLat(origBounds.getSouthLat());
setWestLon(origBounds.getWestLon());
setEastLon(origBounds.getEastLon());
return;
}
// -----------------------------------------------------------------------------------------------------------
public void setNorthLat(double northLat)
{
_northLat = northLat;
}
// -----------------------------------------------------------------------------------------------------------
public double getNorthLat()
{
return _northLat;
}
// -----------------------------------------------------------------------------------------------------------
public void changeNorthLat(double changeAmount)
{
_northLat += changeAmount;
}
// -----------------------------------------------------------------------------------------------------------
public void setSouthLat(double southLat)
{
_southLat = southLat;
}
// -----------------------------------------------------------------------------------------------------------
public double getSouthLat()
{
return _southLat;
}
// -----------------------------------------------------------------------------------------------------------
public void changeSouthLat(double changeAmount)
{
_southLat += changeAmount;
}
// -----------------------------------------------------------------------------------------------------------
public void setWestLon(double westLon)
{
_westLon = westLon;
}
// -----------------------------------------------------------------------------------------------------------
public double getWestLon()
{
return _westLon;
}
// -----------------------------------------------------------------------------------------------------------
public void changeWestLon(double changeAmount)
{
_westLon += changeAmount;
}
// -----------------------------------------------------------------------------------------------------------
public void setEastLon(double eastLon)
{
_eastLon = eastLon;
}
// -----------------------------------------------------------------------------------------------------------
public double getEastLon()
{
return _eastLon;
}
// -----------------------------------------------------------------------------------------------------------
public void changeEastLon(double changeAmount)
{
_eastLon += changeAmount;
}
// -----------------------------------------------------------------------------------------------------------
public double getLatDifference()
{
return getNorthLat() - getSouthLat();
}
// -----------------------------------------------------------------------------------------------------------
public double getLonDifference()
{
return getEastLon() - getWestLon();
}
// -----------------------------------------------------------------------------------------------------------
public void updateLatLonBounds(float lat1, float lat2,
float lon1, float lon2)
{
updateLatitude(lat1);
updateLatitude(lat2);
updateLongitude(lon1);
updateLongitude(lon2);
return;
}
// -----------------------------------------------------------------------------------------------------------
private void updateLatitude(float lat)
{
if (lat > getNorthLat())
{
setNorthLat(lat);
}
if (lat < getSouthLat())
{
setSouthLat(lat);
}
return;
}
// -----------------------------------------------------------------------------------------------------------
private void updateLongitude(float lon)
{
if (lon < getWestLon())
{
setWestLon(lon);
}
if (lon > getEastLon())
{
setEastLon(lon);
}
return;
}
// -----------------------------------------------------------------------------------------------------------
public boolean equals(Object object)
{
boolean result = false;
LatLonBounds otherBounds = (LatLonBounds) object;
if (
(getNorthLat() == otherBounds.getNorthLat() ) &&
(getSouthLat() == otherBounds.getSouthLat() ) &&
(getEastLon() == otherBounds.getEastLon()) &&
(getWestLon() == otherBounds.getWestLon() )
)
{
result = true;
}
return result;
}
// -----------------------------------------------------------------------------------------------------------
public String toString()
{
String string = getNorthLat() + "," + getWestLon() + " to " + getSouthLat() + ", " + getEastLon();
return string;
}
// -----------------------------------------------------------------------------------------------------------
} //end class LatLonBounds

View file

@ -1,70 +0,0 @@
package ohd.hseb.geomap.model;
public class LatLonPoint implements DrawableShape
{
private double _lat;
private double _lon;
public LatLonPoint(double lat, double lon)
{
setLat(lat);
setLon(lon);
}
public void setLat(double lat)
{
_lat = lat;
}
public double getLat()
{
return _lat;
}
public void changeLat(double changeAmount)
{
_lat += changeAmount;
}
public void setLon(double lon)
{
_lon = lon;
}
public double getLon()
{
return _lon;
}
public void changeLon(double changeAmount)
{
_lon += changeAmount;
}
public boolean equals(LatLonPoint point)
{
double tolerance = 0.000000001;
boolean result = false;
double latDiff = Math.abs(getLat() - point.getLat());
double lonDiff = Math.abs(getLon() - point.getLon());
if ( (latDiff < tolerance) && (lonDiff < tolerance))
{
result = true;
}
return result;
}
public String toString()
{
return String.format("lat = %5.2f , lon = %5.2f ", _lat, _lon);
}
}

View file

@ -1,73 +0,0 @@
package ohd.hseb.geomap.model;
import java.util.ArrayList;
import java.util.List;
public class LatLonPolyline implements DrawableShape
{
List<LatLonPoint> _pointList = null;
public LatLonPolyline()
{
_pointList = new ArrayList<LatLonPoint>();
}
public LatLonPolyline(List<LatLonPoint> pointList)
{
_pointList = pointList;
}
public void addPoint(LatLonPoint point)
{
_pointList.add(point);
}
public void addPointList(List<LatLonPoint> pointList)
{
_pointList.addAll(pointList);
}
public List<LatLonPoint> getPointList()
{
return _pointList;
}
public boolean equals(LatLonPolyline line)
{
boolean result = false;
if (_pointList.size() == line.getPointList().size())
{
result = true;
for (int i = 0; i < _pointList.size(); i++)
{
LatLonPoint point1 = _pointList.get(i);
LatLonPoint point2 = line.getPointList().get(i);
if (! point1.equals(point2) )
{
result = false;
break;
}
}
}
return result;
}
public String toString()
{
StringBuffer buffer = new StringBuffer();
for (LatLonPoint point: _pointList)
{
buffer.append(point.toString());
}
return buffer.toString();
}
}

View file

@ -1,19 +0,0 @@
package ohd.hseb.geomap.model;
import java.util.ArrayList;
import java.util.List;
public class Polygon implements DrawableShape
{
List<LatLonPoint> _pointList = new ArrayList<LatLonPoint>();
public Polygon(List<LatLonPoint> pointList)
{
_pointList = pointList;
}
public List<LatLonPoint> getPointList()
{
return _pointList;
}
}

View file

@ -1,51 +0,0 @@
package ohd.hseb.geomap.model;
public class RowColumnPoint
{
private double _row = 0;
private double _column = 0;
// -----------------------------------------------------------------------------------------
public RowColumnPoint(double row, double column)
{
setRow(row);
setColumn(column);
}
// -----------------------------------------------------------------------------------------
public void setRow(double row)
{
_row = row;
}
// -----------------------------------------------------------------------------------------
public double getRow()
{
return _row;
}
// -----------------------------------------------------------------------------------------
public void setColumn(double column)
{
_column = column;
}
// -----------------------------------------------------------------------------------------
public double getCol()
{
return _column;
}
// -----------------------------------------------------------------------------------------
public String toString()
{
return "row = " + getRow() + " col = " + getCol();
}
// -----------------------------------------------------------------------------------------
}

View file

@ -1,377 +0,0 @@
package ohd.hseb.geomap.projection;
import java.awt.Point;
import java.util.ArrayList;
import java.util.List;
import ohd.hseb.geomap.model.LatLonBounds;
import ohd.hseb.geomap.model.LatLonPoint;
public abstract class BaseMapProjection implements MapProjection
{
protected static double RADIANS_PER_DEGREE = 0.017453292519943295 ;
protected static double DEGREES_PER_RADIAN = 1.0/RADIANS_PER_DEGREE ;
protected static double NAUTICAL_MILES_PER_DEGREE = 60;
private int _mapWidth = 0;
private int _mapHeight = 0;
private LatLonBounds _latLonBounds = null;
private double _mapScaleFactor = 90; //degrees per/ pixel
private LatLonPoint _centerLatLon = null;
// -----------------------------------------------------------------------------------
protected int getOffsetX()
{
return getMapWidth() / 2;
}
protected int getOffsetY()
{
return getMapHeight() / 2;
}
/*
float zoom_multiple = 1.0 ;
float original_zoom_multiple = 1.0 ;
long orig_scale_factor;
long init_scale_factor;
long map_scale_factor;
static int MAXX = 0 ;
static int MAXY = 0 ;
int offsetx,offsety;
int polar_offsety = 0 ; // Used for keeping track of the y-offset of the
// HRAP and Polar Stereographic map projection.
int polar_offsetx = 0 ; // Used for keeping track of the x-offset of the
// HRAP projection.
int projection=M_FLAT;
int prev_projection=M_FLAT;
static int XOR = 0 ;
static int YOR = 0 ;
int zoom_scale = 1;
float map_center_lat=33.0;
float map_center_lon=-114.0;
float original_center_lat ;
float original_center_lon ;
float top_lat,left_lon;
float width_in_nmi = 0.0 ;
float dtr = 0.017453292519943295 ;
float init_top_lat , init_width ;
int init_offsetx , init_zoom ;
float region_llat = -999.0 ,
region_llon = -999.0 ,
region_rlat = -999.0 ,
region_rlon = -999.0 ;
static MotifCallback pan_routine = NULL ;
static MotifCallback zoom_routine = NULL ;
*/
abstract public LatLonPoint getLatLonPoint(Point screenPoint);
abstract public LatLonPoint getLatLonPoint(int x, int y);
abstract public Point getScreenPoint(LatLonPoint latlonPoint);
abstract public Point getScreenPoint(double lat, double lon);
public boolean isInRange(double lat, double lon)
{
String header = "BaseMapProjection.isInRange()";
boolean result = false;
LatLonBounds bounds = getLatLonBounds();
if (bounds.getNorthLat() == bounds.getSouthLat())
{
System.out.println(header + " north and sound bounds are the same.");
}
if (
(lat <= bounds.getNorthLat()) &&
(lat >= bounds.getSouthLat()) &&
(lon >= bounds.getEastLon()) &&
(lon <= bounds.getWestLon())
)
{
result = true;
System.out.println(header + "finally, something is in range to be drawn");
}
return result;
}
// ----------------------------------------------------------------
public List<LatLonPoint> getLatLonPointList(List<Point> screenCoordList)
{
List<LatLonPoint> latLonPointList = new ArrayList<LatLonPoint>();
for (Point screenPoint : screenCoordList)
{
LatLonPoint latLonPoint = getLatLonPoint(screenPoint);
latLonPointList.add(latLonPoint);
}
return null;
}
// ----------------------------------------------------------------
public List<Point> getScreenPointList(List<LatLonPoint> latLongCoordinateList)
{
List<Point> screenPointList = new ArrayList<Point>();
for (LatLonPoint latLonPoint : latLongCoordinateList)
{
Point screenPoint = getScreenPoint(latLonPoint);
screenPointList.add(screenPoint);
}
return screenPointList;
}
//-------------------------------------------------------------------------------------------------
protected void init(float displayWidthInNauticalMiles)
{
double degreesLongitude ;
int offsetx = getOffsetX();
int offsety = getOffsetY();
double mapCenterLat = getCenterLatLon().getLat();
degreesLongitude = displayWidthInNauticalMiles /
( NAUTICAL_MILES_PER_DEGREE * Math.cos ( mapCenterLat * RADIANS_PER_DEGREE ) ) ;
double map_scale_factor = ( long ) ( 2.0 * ( float ) getOffsetX() / degreesLongitude ) ;
//Compute the top latitude and the left longitude.
LatLonPoint northWestLatLong = getLatLonPoint(new Point(0,0));
_latLonBounds.setNorthLat(northWestLatLong.getLat());
_latLonBounds.setWestLon(northWestLatLong.getLon());
/*
init_scale_factor = map_scale_factor ;
orig_scale_factor = init_scale_factor ;
init_top_lat = top_lat ;
init_width = width_in_nmi ;
init_offsetx = offsetx ;
*/
}
// ----------------------------------------------------------------
/*
void _init_map_variables ( float nmi )
{
float degrees_lon ;
projection = M_FLAT ;
width_in_nmi = nmi ;
offsetx = _get_map_width ( 0 ) / 2 ;
offsety = _get_map_height ( 0 ) / 2 ;
// New logic added by Bryon Lawrence on January 15, 2002. This is an
// attempt to incorporate an initial measurement in nautical miles into
// the initial computation of the scale factor.
degrees_lon = width_in_nmi /
( ( float ) NUM_NMI_PER_DEGREE * cos ( map_center_lat * dtr ) ) ;
map_scale_factor = ( long ) ( 2.0 * ( float ) offsetx / degrees_lon ) ;
//Compute the top latitude and the left longitude.
mConvertXY2LatLon(0,0,&top_lat,&left_lon) ;
init_scale_factor = map_scale_factor ;
orig_scale_factor = init_scale_factor ;
init_top_lat = top_lat ;
init_width = width_in_nmi ;
init_offsetx = offsetx ;
}
*/
// ----------------------------------------------------------------
public void setLatLonBounds(LatLonBounds latLonBounds)
{
String header = "BaseMapProjection.setLatLonBounds(): ";
System.out.println(header);
_latLonBounds = new LatLonBounds(latLonBounds);
setCenterInternally();
}
private void setCenterInternally()
{
String header = "BaseMapProjection.setCenterInternally(): ";
System.out.println(header);
LatLonBounds bounds = getLatLonBounds();
double lat = (bounds.getNorthLat() + bounds.getSouthLat())/2.0 ;
double lon = (bounds.getEastLon() + bounds.getWestLon())/2.0 ;
_centerLatLon = new LatLonPoint(lat, lon);
}
private void setLatLonBoundsInternally()
{
String header = "BaseMapProjection.setLatLonBoundsInternally(): ";
LatLonPoint centerPoint = getCenterLatLon();
double pixelsPerDegree = getMapScaleFactor();
double latOffset = getOffsetY() / pixelsPerDegree;
double lonOffset = getOffsetX() / pixelsPerDegree;
System.out.println(header + " latOffset = " + latOffset);
System.out.println(header + " lonOffset = " + lonOffset);
double northLat = centerPoint.getLat() + latOffset;
double southLat = centerPoint.getLat() - latOffset;
double westLat = centerPoint.getLon() - lonOffset;
double eastLat = centerPoint.getLon() + lonOffset;
_latLonBounds = new LatLonBounds(northLat,southLat, westLat, eastLat);
System.out.println(header + " latLonBounds = " + _latLonBounds);
}
// ----------------------------------------------------------------
public LatLonBounds getLatLonBounds()
{
return _latLonBounds;
}
// ----------------------------------------------------------------
public void setMapHeight(int mapHeight)
{
_mapHeight = mapHeight;
setLatLonBoundsInternally();
}
// ----------------------------------------------------------------
public int getMapHeight()
{
return _mapHeight;
}
//-------------------------------------------------------------------------------------------------
public void panProportionally(double northSouthPanProportion, double eastWestPanProportion)
{
String header = "BaseMapProjection.panProportionally(): ";
// System.out.println(header + "northSouthPanProportion = " + northSouthPanProportion +
// " eastWestPanProportion = " + eastWestPanProportion);
LatLonBounds latLonBounds = getLatLonBounds();
double panLatAmount = northSouthPanProportion * latLonBounds.getLatDifference();
double panLonAmount = eastWestPanProportion * latLonBounds.getLonDifference();
System.out.println(header + "latLonBounds.getLatDifference() = " + latLonBounds.getLatDifference() +
" latLonBounds.getLonDifference() = " + latLonBounds.getLonDifference());
changeCenter(panLatAmount, panLonAmount);
return;
}
//-------------------------------------------------------------------------------------------------
public void changeCenter(double changeLatAmount, double changeLonAmount)
{
String header = "BaseMapProjection.changeCenter(): ";
System.out.println(header + "changeLatAmount " + changeLatAmount);
System.out.println(header + "changeLonAmount " + changeLonAmount);
_centerLatLon.changeLat(changeLatAmount);
_centerLatLon.changeLon(changeLonAmount);
System.out.println(header + "new center = " + _centerLatLon);
System.out.println(header + "mapScaleFactor = " + getMapScaleFactor());
setLatLonBoundsInternally();
}
//-------------------------------------------------------------------------------------------------
public LatLonPoint getCenterLatLon()
{
return _centerLatLon;
}
//-------------------------------------------------------------------------------------------------
public void setCenterLatLon(LatLonPoint newCenter)
{
String header = "BaseMapProjection.setCenterLatLon(): ";
LatLonPoint oldCenter = getCenterLatLon();
_centerLatLon = newCenter;
System.out.println(header + "oldCenter = " + oldCenter + " newCenter = " + newCenter);
System.out.println(header + "width " + getMapWidth() + " height = " + getMapHeight());
setLatLonBoundsInternally();
return;
}
// ----------------------------------------------------------------
public void setMapScaleFactor(double mapScaleFactor)
{
_mapScaleFactor = mapScaleFactor;
}
// ----------------------------------------------------------------
public double getMapScaleFactor()
{
return _mapScaleFactor;
}
// ----------------------------------------------------------------
public void setMapWidthAndHeight(int mapWidth, int mapHeight)
{
_mapWidth = mapWidth;
_mapHeight = mapHeight;
setLatLonBoundsInternally();
}
public void setMapWidth(int mapWidth)
{
_mapWidth = mapWidth;
setLatLonBoundsInternally();
}
// ----------------------------------------------------------------
public int getMapWidth()
{
return _mapWidth;
}
}

View file

@ -1,84 +0,0 @@
package ohd.hseb.geomap.projection;
import java.awt.Point;
import ohd.hseb.geomap.model.LatLonPoint;
// ------------------------------------------------------------------------------------------
public class FlatMapProjection extends BaseMapProjection
{
// ------------------------------------------------------------------------------------------
public FlatMapProjection (LatLonPoint centerLatLonPoint)
{
setCenterLatLon(centerLatLonPoint);
}
public LatLonPoint getLatLonPoint(int x, int y)
{
double lat = 0.0;
double lon = 0.0;
double mapCenterLon = getCenterLatLon().getLon();
double mapCenterLat = getCenterLatLon().getLat();
lon = ( ( ( double ) (x - getOffsetX()) / getMapScaleFactor() ) + mapCenterLon) ;
lat = mapCenterLat - ( ( double ) ( y - getOffsetY() ) / getMapScaleFactor() ) ;
LatLonPoint point = new LatLonPoint(lat, lon);
return point;
}
//-------------------------------------------------------------------------------------------------
public LatLonPoint getLatLonPoint(Point screenPoint)
{
int x = screenPoint.x;
int y = screenPoint.y;
return getLatLonPoint(x, y);
}
//-------------------------------------------------------------------------------------------------
public Point getScreenPoint(LatLonPoint latLonPoint)
{
double lat = latLonPoint.getLat();
double lon = latLonPoint.getLon();
return getScreenPoint(lat, lon);
}
// -------------------------------------------------------------------------------------------------
public Point getScreenPoint(double lat, double lon)
{
double mapCenterLat = getCenterLatLon().getLat();
double mapCenterLon = getCenterLatLon().getLon();
if (mapCenterLon > 0 && lon < 0)
lon = lon + 360;
if (mapCenterLon < 0 && lon > 0)
lon = lon - 360;
int x = (int) ((lon - mapCenterLon) * getMapScaleFactor() ) + getOffsetX();
int y = (int) ( getOffsetY() - ((lat - mapCenterLat) * getMapScaleFactor() ) );
return new Point(x,y);
}
//-------------------------------------------------------------------------------------------------
}

View file

@ -1,43 +0,0 @@
package ohd.hseb.geomap.projection;
import java.awt.Point;
import java.util.List;
import ohd.hseb.geomap.model.LatLonBounds;
import ohd.hseb.geomap.model.LatLonPoint;
public interface MapProjection
{
void setMapScaleFactor(double mapScaleFactor);
double getMapScaleFactor();
int getMapWidth();
void setMapWidth(int mapWidth);
int getMapHeight();
void setMapHeight(int mapHeight);
//configuration methods
void setLatLonBounds(LatLonBounds latLonBounds);
LatLonBounds getLatLonBounds();
void panProportionally(double northSouthPanProportion, double eastWestPanProportion);
void setCenterLatLon(LatLonPoint centerLatLong);
LatLonPoint getCenterLatLon();
//useful methods
boolean isInRange(double lat, double lon);
LatLonPoint getLatLonPoint(Point screenPoint);
LatLonPoint getLatLonPoint(int x, int y);
List<LatLonPoint> getLatLonPointList(List<Point> screenCoordList);
Point getScreenPoint(LatLonPoint latlonPoint);
Point getScreenPoint(double lat, double lon);
List<Point> getScreenPointList(List<LatLonPoint> latLonPointList);
}

View file

@ -1,95 +0,0 @@
package ohd.hseb.geomap.projection;
import java.awt.Point;
import ohd.hseb.geomap.model.LatLonPoint;
public class PolarProjection extends BaseMapProjection
{
public PolarProjection(LatLonPoint centerLatLonPoint, double mapScaleFactor)
{
setCenterLatLon(centerLatLonPoint);
setMapScaleFactor(mapScaleFactor);
}
@Override
public LatLonPoint getLatLonPoint(Point screenPoint)
{
return getLatLonPoint(screenPoint.x, screenPoint.y);
}
@Override
public LatLonPoint getLatLonPoint(int x, int y)
{
double c;
double py;
double px;
double p;
/* Be sure to take into account any panning/recentering effects. */
x = x - getOffsetX();
y = (-1 * y) + getOffsetY();
py = (double)y;
px = (double)x;
double lon = ((getCenterLatLon().getLon() * RADIANS_PER_DEGREE) + Math.atan2(py,px)) * DEGREES_PER_RADIAN + 90.0;
p = Math.pow(((px*px) + (py*py)),0.5);
c = 2.0 * Math.atan(p/(2.0 * ( double ) getMapScaleFactor()));
double lat = Math.asin(Math.cos(c) * Math.sin((90.0 *RADIANS_PER_DEGREE)) +
(py * Math.sin(c) * Math.cos((90.0 * RADIANS_PER_DEGREE))/p)) * DEGREES_PER_RADIAN;
return new LatLonPoint(lat, lon);
}
@Override
public Point getScreenPoint(LatLonPoint latLonPoint)
{
return getScreenPoint(latLonPoint.getLat(), latLonPoint.getLon());
}
@Override
public Point getScreenPoint(double lat, double lon)
{
double k;
double temp;
double centerLon;
int x = 0;
int y = 0;
lat = lat * RADIANS_PER_DEGREE;
lon = lon * RADIANS_PER_DEGREE;
centerLon = getCenterLatLon().getLon() * RADIANS_PER_DEGREE;
temp = 1 + Math.sin(lat);
if (temp == 0.0)
{
System.out.println("Error\n");
}
else
{
k = getMapScaleFactor();
double tangentTerm = 2.0 * k * Math.tan((Math.PI /4.0) - (lat / 2.0)) ;
temp = tangentTerm * Math.sin(lon - centerLon);
x = (int)temp + getOffsetX();
temp = -tangentTerm * Math.cos(lon - centerLon);
y = getOffsetY() - (int)temp;
}
return new Point(x, y);
}
}

View file

@ -1,242 +0,0 @@
/*
* Created on May 24, 2004
*
*
*/
package ohd.hseb.grid;
import java.util.HashMap;
import java.util.Map;
import ohd.hseb.db.DbTimeHelper;
/**
* @author GobsC
*
*
*/
public class XmrgGrid
{
public static final double OFF_GRID_VALUE = -8888.0;
private double _missingValue = -999.0;
private long _time = 0;
// old way of storing grid
private Map _valueMap = null;
// private List _valueList = null;
//new way of storing grid
private double[][] _gridValuesArray = null;
private boolean _isValid = true;
private int _rowCount = 0;
private int _colCount = 0;
private int _baseRow = 0; //southern row
private int _baseCol = 0; // western col
// private boolean _newWay = true;
// -----------------------------------------------------------------------------------
private XmrgGrid()
{
_isValid = true;
}
// -----------------------------------------------------------------------------------
public static XmrgGrid getInvalidGrid(long time)
{
XmrgGrid grid = new XmrgGrid(time);
grid.setIsValid(false);
return grid;
}
// -----------------------------------------------------------------------------------
public XmrgGrid(long time)
{
_time = time;
_valueMap = new HashMap();
// _valueList = new ArrayList();
}
// -----------------------------------------------------------------------------------
public XmrgGrid(long time, int southernRowIndex, int westernColIndex,
int rowCount, int colCount)
{
_time = time;
// new way
_rowCount = rowCount;
_colCount = colCount;
_baseRow = southernRowIndex;
_baseCol = westernColIndex;
_gridValuesArray = new double[_rowCount][_colCount];
return;
}
// -----------------------------------------------------------------------------------
public void setValue(int hrapRow, int hrapCol, double value)
{
int rowIndex = hrapRow - _baseRow;
int colIndex = hrapCol - _baseCol;
_gridValuesArray[rowIndex][colIndex] = value;
return;
}
// -----------------------------------------------------------------------------------
public double[][] getValuesArray()
{
return _gridValuesArray;
}
// -----------------------------------------------------------------------------------
public double getValue(int hrapRow, int hrapCol)
{
int rowIndex = hrapRow - _baseRow;
int colIndex = hrapCol - _baseCol;
double value = OFF_GRID_VALUE;
//Chip CHANGE 8/23/05
if (
(rowIndex > -1) && (rowIndex < _rowCount) &&
(colIndex > -1) && (colIndex < _colCount)
)
{
value = _gridValuesArray[rowIndex][colIndex];
}
else
{
// System.out.println("XmrgGrid.getValue(): attempting to access " +
// "rowIndex = " + rowIndex + " colIndex = " + colIndex);
// System.out.print(" Row Values should be >= 0 < " + _rowCount);
// System.out.println(" and column values should be >= 0 < " + _colCount);
}
return value;
}
// -----------------------------------------------------------------------------------
public void setTime(long time)
{
_time = time;
}
// -----------------------------------------------------------------------------------
public long getTime()
{
return _time;
}
// -----------------------------------------------------------------------------------
private Object getKey(int hrapRow, int hrapCol)
{
Long key = new Long(hrapRow*10000 + hrapCol);
return key;
}
// -----------------------------------------------------------------------------------
public String toString()
{
StringBuffer buffer = new StringBuffer();
// String outString = null;
double value = 0;
buffer.append("time = " + DbTimeHelper.getDateTimeStringFromLongTime(_time) + "\n");
/*
for (int i = 0; i < _valueList.size(); i++)
{
String keyValue = (String) _valueList.get(i);
StringTokenizer tokenizer = new StringTokenizer(keyValue, "|");
while (tokenizer.hasMoreTokens())
{
String hrapRow = tokenizer.nextToken();
String hrapCol = tokenizer.nextToken();
String valueString = tokenizer.nextToken();
value = Double.parseDouble(valueString);
if (value > 0.0)
{
buffer.append("hrapRow = " + hrapRow + " hrapCol = " + hrapCol + " value = " + value + "\n");
}
}
}
*/
return buffer.toString();
}
// -----------------------------------------------------------------------------------
public void setIsValid(boolean isValid)
{
_isValid = isValid;
}
// -----------------------------------------------------------------------------------
public boolean isValid()
{
return _isValid;
}
private void setBaseRow(int baseRow)
{
_baseRow = baseRow;
}
public int getBaseRow()
{
return _baseRow;
}
private void setBaseCol(int baseCol)
{
_baseCol = baseCol;
}
public int getBaseCol()
{
return _baseCol;
}
public int getRowCount()
{
return _rowCount;
}
public int getColCount()
{
return _colCount;
}
// -----------------------------------------------------------------------------------
}

View file

@ -1,181 +0,0 @@
package ohd.hseb.gui.util;
import java.awt.AWTException;
import java.awt.Component;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.image.BufferedImage;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import javax.imageio.ImageIO;
import javax.imageio.stream.FileImageOutputStream;
import javax.imageio.stream.ImageOutputStream;
import javax.swing.JFileChooser;
import javax.swing.filechooser.FileFilter;
import ohd.hseb.util.gui.DialogHelper;
import ohd.hseb.util.gui.ExtensionFileFilter;
import com.raytheon.uf.common.ohd.AppsDefaults;
public class ScreenCaptureActionListener implements ActionListener {
private JFileChooser _imageFileChooser = null;
private Window _baseWindow = null;
private Component _componentToCapture = null;
// -------------------------------------------------------------------------------------
public ScreenCaptureActionListener(Window componentToCapture) {
_componentToCapture = componentToCapture;
_baseWindow = componentToCapture;
return;
}
// -------------------------------------------------------------------------------------
public ScreenCaptureActionListener(Window baseWindow,
Component componentToCapture) {
_baseWindow = baseWindow;
_componentToCapture = componentToCapture;
return;
}
// -------------------------------------------------------------------------------------
public void actionPerformed(ActionEvent event) {
this.displayCaptureScreenFileChooser();
} // end actionPerformed
// -------------------------------------------------------------------------------------
private void displayCaptureScreenFileChooser() {
BufferedImage image = captureScreenToImage();
if (_imageFileChooser == null) {
AppsDefaults ad = AppsDefaults.getInstance();
String defaultDirectory = ad.getToken("whfs_image_dir");
_imageFileChooser = new JFileChooser(defaultDirectory);
}
// add a FileFilter for JPG files
List filterList = new ArrayList();
filterList.add("JPEG");
filterList.add("JPG");
FileFilter fileFilter = new ExtensionFileFilter(filterList,
"JPEG Image Files (*.jpg, *.JPG) ");
// set the file filter
_imageFileChooser.setFileFilter(fileFilter);
// _imageFileChooser.set
// open the dialog
int returnVal = _imageFileChooser.showSaveDialog(_baseWindow);
if (returnVal == JFileChooser.APPROVE_OPTION) {
File file = _imageFileChooser.getSelectedFile();
// ensure ends in ".jpg"
if ((!file.getName().endsWith(".jpg"))
&& (!file.getName().endsWith(".JPG"))) {
String newFilePath = file.getPath() + ".jpg";
file = new File(newFilePath);
}
writeImageToFile(image, file);
}
else {
DialogHelper.displayMessageDialog(_baseWindow,
"Image file not saved.");
}
return;
}
// -----------------------------------------------------------------
private BufferedImage captureScreenToImage() {
String header = "ScreenCaptureActionListener.captureScreenToImage(): ";
BufferedImage bufferedImage = null;
try {
Robot robot = new Robot();
Rectangle boundsRectangle = null;
if (_componentToCapture != _baseWindow) {
Point origin = getOriginRelativeToScreen(_componentToCapture);
// _componentToCapture.get
Rectangle componentBounds = _componentToCapture.getBounds();
boundsRectangle = new Rectangle(origin.x, origin.y,
componentBounds.width, componentBounds.height);
} else {
boundsRectangle = _baseWindow.getBounds();
}
bufferedImage = robot.createScreenCapture(boundsRectangle);
} // end try
catch (AWTException e) {
e.printStackTrace();
}
return bufferedImage;
}
// -----------------------------------------------------------------
private Point getOriginRelativeToScreen(Component component) {
int x = 0;
int y = 0;
Component parent = component;
while (parent != null) {
x += parent.getX();
y += parent.getY();
parent = parent.getParent();
}
return new Point(x, y);
}
// -----------------------------------------------------------------
private void writeImageToFile(BufferedImage image, File file) {
try {
ImageOutputStream imageOutputStream = new FileImageOutputStream(
file);
ImageIO.write(image, "JPG", imageOutputStream);
imageOutputStream.close();
}
catch (java.io.IOException e) {
e.printStackTrace();
}
return;
}
// -----------------------------------------------------------------
}

View file

@ -1,167 +0,0 @@
/*
* Created on Aug 25, 2003
*
* To change the template for this generated file go to
* Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
*/
package ohd.hseb.measurement;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;
/**
* @author GobsC
*
*
*/
public class AbsTimeMeasurement extends Measurement
{
private long _time; // the time the measurement was taken
// *****************************************************************************
public AbsTimeMeasurement(Measurement measurement, long timeInMillis)
{
super(measurement);
_time = timeInMillis;
return;
}
// *****************************************************************************
public AbsTimeMeasurement(double value, long timeInMillis, MeasuringUnit unit)
{
super(value, unit);
_time = timeInMillis;
return;
}
// *****************************************************************************
public AbsTimeMeasurement(AbsTimeMeasurement measurement)
{
super(measurement.getValue(), measurement.getUnit());
_time = measurement.getTime();
return;
}
//---------------------------------------------------------------
public long getTime()
{
return _time;
}
public void setTime(long timeInMillis)
{
_time = timeInMillis;
}
//---------------------------------------------------------------
private String formatTime(long time)
{
SimpleDateFormat formatter = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss.SSS");
formatter.setTimeZone(TimeZone.getTimeZone("UTC"));
return formatter.format(new Date(time)) + " UTC";
}
//---------------------------------------------------------------
public static AbsTimeMeasurement getConvertedCopy(AbsTimeMeasurement origMeasurement,
MeasuringUnit toUnit)
{
AbsTimeMeasurement newMeasurement = new AbsTimeMeasurement(origMeasurement);
newMeasurement.convert(toUnit);
return newMeasurement;
}
// ---------------------------------------------------------------
public static AbsTimeMeasurement interpolate(AbsTimeMeasurement m1,
AbsTimeMeasurement m2,
long desiredTime)
{
long t1 = m1.getTime();
long t2 = m2.getTime();
double value1 = m1.getValue();
double value2 = m2.getValue();
double slope = (value2 - value1) / (t2 - t1);
double intercept = (value1) - (slope*t1);
double value = (slope*desiredTime) + intercept;
AbsTimeMeasurement measurement = new AbsTimeMeasurement(value, desiredTime, m1.getUnit());
measurement.setIsInterpolated(true);
return measurement;
}
//---------------------------------------------------------------
public boolean equals(Object object)
{
boolean result = false;
if (object instanceof AbsTimeMeasurement)
{
AbsTimeMeasurement m = (AbsTimeMeasurement) object;
result = equals(m);
}
return result;
}
//---------------------------------------------------------------
public boolean equals(AbsTimeMeasurement measurement)
{
boolean result = false;
if (this.getUnit() != measurement.getUnit())
{
measurement = AbsTimeMeasurement.getConvertedCopy(measurement, this.getUnit());
}
if (
(this.getValue() == measurement.getValue()) &&
(this.getTime() == measurement.getTime())
)
{
result = true;
}
return result;
}
// ---------------------------------------------------------------
public int hashCode()
{
int value = 0;
MeasuringUnit standardUnit = MeasuringUnit.getStandardUnitForUnit(this.getUnit());
value = (int) ( this.getTime() +
this.getValue(standardUnit));
return value;
}
// ---------------------------------------------------------------
public String toString()
{
return getValue() + " in " + getUnit().getName() + " at " + formatTime(_time);
}
}

Some files were not shown because too many files have changed in this diff Show more