VLab Issue #4003 - Mostly PGEN bug fixes

minor updates to nsharp, lat/lon overlay, ntrans, and plotdata resource

Change-Id: I2a1718ed7674edb786bceec13bcb20c29cc5d616

Former-commit-id: d9b57e6c7a [formerly d9b57e6c7a [formerly 8bdc663629050457b23d06c19bd7a925597c1288]]
Former-commit-id: 57393984d3
Former-commit-id: dc922d5112
This commit is contained in:
Stephen Gilbert 2014-12-01 17:17:39 -05:00
parent dbf2f42af1
commit acb128eb72
37 changed files with 7515 additions and 6910 deletions

View file

@ -47,7 +47,7 @@ import java.util.Set;
* 17-May-2011 M. Li Created a parseCINT to simplify CINT parsing.
* 07-Apr-2014 TTR-938 D.Sushon Added check for null string to constructor, fixing NullPointerException
* thrown when attempting to initialize with null String.
*
* 09-Sep-2014 TTR-852 A.Yuk remove restriction of contour lines =50 and make it unlimited contour lines.
*
* </pre>
*
@ -56,7 +56,7 @@ import java.util.Set;
* @see $GEMPAK/help/hlx/cint.hl2
*/
public class CINT {
/** The object responsible for parsing the CINT string */
private ContourStringParser cintParser;
@ -396,20 +396,44 @@ public class CINT {
if (interval == null || interval.isNaN()) {
interval = (cmax - cmin) / 10.0;
}
// Only allow less than 50 contour levels
if ((cmax - cmin) / interval > 50)
interval = (cmax - cmin) / 50;
// System.out.println(" cmax=="+cmax);
// Only allow less than 50 contour levels :
// comment out contour restriction. : IT WAs BAD Code to generate decimal point on contour labels.
/* if ((cmax - cmin) / interval > 50) {
interval = (cmax - cmin) / 50;
interval =(double) (int) ((cmax - cmin)/50) ; }
*/
contourInfo = new CINT(interval.toString() + "/"
+ cmin.toString() + "/" + cmax.toString());
cvalues = contourInfo
.getUniqueSortedContourValuesFromAllZoomLevels();
.getUniqueSortedContourValuesFromAllZoomLevels();
}
}
/********************************
int csize=cvalues.size();
System.out.println(" .................");
System.out.println(" .................");
System.out.println(" Contour level range is from "+cvalues.get(0)+" to "+cvalues.get(csize-1)+".");
System.out.println(" Contour interval "+interval+".");
System.out.println(" .................");
System.out.println(" .................");
// * capped contour lines to 50
if (csize > 50) {
System.out.println(" !!! Pay attention to CONTOUR INTERVAL.");
System.out.println(" Contour lines from "+cvalues.get(0)+" to "+cvalues.get(csize-1)+" are eliminated due to maximum contour allowance." );
while (cvalues.size()>50){cvalues.remove(50);}
System.out.println(" !!! Contours are being plotted to the first 50th lines.");
System.out.println(" Range of contour lines drawn is from "+cvalues.get(0)+" to "+cvalues.get(49)+".");
System.out.println(" !!! Contour lines are capped due to allowance of maximum contour lines of 50. ");
}
}
return cvalues;
System.out.println(" Contour level = "+cvalues.toString()+".");
***************************/
while (cvalues.size()>50){cvalues.remove(50);}
int csize=cvalues.size();
System.out.println(" Contour lines("+csize+ ") from "+cvalues.get(0)+" to "+cvalues.get(csize-1));
return cvalues;
}
/** @return boolean isCINTStringParsed */
@ -652,3 +676,4 @@ public class CINT {
}
}

View file

@ -1940,9 +1940,10 @@ public class NsharpResourceHandler {
return;
}
if (!fromArchive) {
// start FixMark:nearByStnCompSnd d2dlite
if (!(sndType.contentEquals("NCUAIR") || sndType
.contentEquals("BUFRUA"))) {
// For those sounding report with forecast time, e.g. model/pfc sounding
if (timeLine.contains("V")) { //fix D2D loading issue. 10/8/2014
// if (!(sndType.contentEquals("NCUAIR") || sndType
// .contentEquals("BUFRUA"))) {
// Chin's NOTE:
// Can Not use reference time directly from the stnInfo,
// Timestamp refTime = stnInfo.getReftime()

View file

@ -16,7 +16,7 @@
* 01/08/2014 Chin Chen Only initializing inventory when in NCP
* 01/13/2014 Chin Chen TTR829- when interpolation, edit graph is allowed
* 01/22/2014 Chin Chen DR17003 issue: NSHARP sounding display throws errors when swapping into main pane when show text is turned on.
*
* 10/20/2014 Chin Chen DR16864, D2D does not use unload button. Check to make sure not D2D instance before access unload button.
* </pre>
*
* @author Chin Chen
@ -150,7 +150,7 @@ public class NsharpPaletteWindow extends ViewPart implements SelectionListener,
private boolean spcGpCreated = false;
private boolean awcGpCreated = false;
private boolean imD2d = false; // fixMark:NcInventory
public static NsharpPaletteWindow getInstance() {
if (VizPerspectiveListener.getCurrentPerspectiveManager() != null) {
@ -220,7 +220,8 @@ public class NsharpPaletteWindow extends ViewPart implements SelectionListener,
interpBtn.setEnabled(false);
graphModeBtnIcing.setEnabled(false);
graphModeBtnTurb.setEnabled(false);
unloadBtn.setEnabled(false); // FixMark:nearByStnCompSnd
if (!imD2d)
unloadBtn.setEnabled(false); // FixMark:nearByStnCompSnd
} else if (compareStnIsOn) {
compareStnBtn.setText(COMP_STN_ON);
graphEditBtn.setEnabled(false);
@ -231,7 +232,8 @@ public class NsharpPaletteWindow extends ViewPart implements SelectionListener,
interpBtn.setEnabled(false);
graphModeBtnIcing.setEnabled(false);
graphModeBtnTurb.setEnabled(false);
unloadBtn.setEnabled(false); // FixMark:nearByStnCompSnd
if (!imD2d)
unloadBtn.setEnabled(false); // FixMark:nearByStnCompSnd
} else if (compareSndIsOn) {
compareSndBtn.setText(COMP_SND_ON);
graphEditBtn.setEnabled(false);
@ -242,7 +244,8 @@ public class NsharpPaletteWindow extends ViewPart implements SelectionListener,
interpBtn.setEnabled(false);
graphModeBtnIcing.setEnabled(false);
graphModeBtnTurb.setEnabled(false);
unloadBtn.setEnabled(false); // FixMark:nearByStnCompSnd
if (!imD2d)
unloadBtn.setEnabled(false); // FixMark:nearByStnCompSnd
} else if (compareTmIsOn) {
compareTmBtn.setText(COMP_TM_ON);
compareSndBtn.setEnabled(false);
@ -253,7 +256,8 @@ public class NsharpPaletteWindow extends ViewPart implements SelectionListener,
interpBtn.setEnabled(false);
graphModeBtnIcing.setEnabled(false);
graphModeBtnTurb.setEnabled(false);
unloadBtn.setEnabled(false); // FixMark:nearByStnCompSnd
if (!imD2d)
unloadBtn.setEnabled(false); // FixMark:nearByStnCompSnd
} else if (editGraphOn) {
graphEditBtn.setText(EDIT_GRAPH_ON);
dataEditBtn.setEnabled(false);
@ -264,7 +268,8 @@ public class NsharpPaletteWindow extends ViewPart implements SelectionListener,
interpBtn.setEnabled(false);
graphModeBtnIcing.setEnabled(false);
graphModeBtnTurb.setEnabled(false);
unloadBtn.setEnabled(false); // FixMark:nearByStnCompSnd
if (!imD2d)
unloadBtn.setEnabled(false); // FixMark:nearByStnCompSnd
}
} else if (currentGraphMode == NsharpConstants.GRAPH_TURB) {
@ -377,7 +382,7 @@ public class NsharpPaletteWindow extends ViewPart implements SelectionListener,
public NsharpPaletteWindow() {
super();
instance = this;
boolean imD2d = false; // fixMark:NcInventory
//boolean imD2d = false; // fixMark:NcInventory
if (VizPerspectiveListener.getCurrentPerspectiveManager() != null) {
if (VizPerspectiveListener.getCurrentPerspectiveManager()
.getPerspectiveId().equals(D2D5Pane.ID_PERSPECTIVE)) {
@ -945,7 +950,8 @@ public class NsharpPaletteWindow extends ViewPart implements SelectionListener,
graphModeBtnIcing.setEnabled(false);
interpBtn.setEnabled(false);
cfgBtn.setEnabled(false);
unloadBtn.setEnabled(false);// FixMark:nearByStnCompSnd
if (!imD2d)
unloadBtn.setEnabled(false);// FixMark:nearByStnCompSnd
} else {
overlayIsOn = false;
overlayBtn.setText(OVLY_OFF);
@ -958,7 +964,8 @@ public class NsharpPaletteWindow extends ViewPart implements SelectionListener,
graphModeBtnIcing.setEnabled(true);
interpBtn.setEnabled(true);
cfgBtn.setEnabled(true);
unloadBtn.setEnabled(true);// FixMark:nearByStnCompSnd
if (!imD2d)
unloadBtn.setEnabled(true);// FixMark:nearByStnCompSnd
}
NsharpResourceHandler rsc = getRscHandler();
if (rsc != null) {
@ -1001,7 +1008,8 @@ public class NsharpPaletteWindow extends ViewPart implements SelectionListener,
graphModeBtnIcing.setEnabled(false);
interpBtn.setEnabled(false);
cfgBtn.setEnabled(false);
unloadBtn.setEnabled(false);// FixMark:nearByStnCompSnd
if (!imD2d)
unloadBtn.setEnabled(false);// FixMark:nearByStnCompSnd
} else {
compareStnIsOn = false;
compareStnBtn.setText(COMP_STN_OFF);
@ -1014,7 +1022,8 @@ public class NsharpPaletteWindow extends ViewPart implements SelectionListener,
graphModeBtnIcing.setEnabled(true);
interpBtn.setEnabled(true);
cfgBtn.setEnabled(true);
unloadBtn.setEnabled(true);// FixMark:nearByStnCompSnd
if (!imD2d)
unloadBtn.setEnabled(true);// FixMark:nearByStnCompSnd
}
NsharpResourceHandler rsc = getRscHandler();
if (rsc != null) {
@ -1059,7 +1068,8 @@ public class NsharpPaletteWindow extends ViewPart implements SelectionListener,
graphModeBtnIcing.setEnabled(false);
interpBtn.setEnabled(false);
cfgBtn.setEnabled(false);
unloadBtn.setEnabled(false);// FixMark:nearByStnCompSnd
if (!imD2d)
unloadBtn.setEnabled(false);// FixMark:nearByStnCompSnd
} else {
compareTmIsOn = false;
compareTmBtn.setText(COMP_TM_OFF);
@ -1072,7 +1082,8 @@ public class NsharpPaletteWindow extends ViewPart implements SelectionListener,
graphModeBtnIcing.setEnabled(true);
interpBtn.setEnabled(true);
cfgBtn.setEnabled(true);
unloadBtn.setEnabled(true);// FixMark:nearByStnCompSnd
if (!imD2d)
unloadBtn.setEnabled(true);// FixMark:nearByStnCompSnd
}
NsharpResourceHandler rsc = getRscHandler();
if (rsc != null) {
@ -1115,7 +1126,8 @@ public class NsharpPaletteWindow extends ViewPart implements SelectionListener,
graphModeBtnIcing.setEnabled(false);
interpBtn.setEnabled(false);
cfgBtn.setEnabled(false);
unloadBtn.setEnabled(false);// FixMark:nearByStnCompSnd
if (!imD2d)
unloadBtn.setEnabled(false);// FixMark:nearByStnCompSnd
} else {
compareSndIsOn = false;
compareSndBtn.setText(COMP_SND_OFF);
@ -1128,7 +1140,8 @@ public class NsharpPaletteWindow extends ViewPart implements SelectionListener,
graphModeBtnIcing.setEnabled(true);
interpBtn.setEnabled(true);
cfgBtn.setEnabled(true);
unloadBtn.setEnabled(true);// FixMark:nearByStnCompSnd
if (!imD2d)
unloadBtn.setEnabled(true);// FixMark:nearByStnCompSnd
}
NsharpResourceHandler rsc = getRscHandler();
if (rsc != null) {
@ -1187,7 +1200,8 @@ public class NsharpPaletteWindow extends ViewPart implements SelectionListener,
compareSndBtn.setEnabled(true);
compareStnBtn.setEnabled(true);
overlayBtn.setEnabled(true);
unloadBtn.setEnabled(true);// FixMark:nearByStnCompSnd
if (!imD2d)
unloadBtn.setEnabled(true);// FixMark:nearByStnCompSnd
}
} else {
editGraphOn = true;
@ -1200,7 +1214,8 @@ public class NsharpPaletteWindow extends ViewPart implements SelectionListener,
compareSndBtn.setEnabled(false);
compareStnBtn.setEnabled(false);
overlayBtn.setEnabled(false);
unloadBtn.setEnabled(false);// FixMark:nearByStnCompSnd
if (!imD2d)
unloadBtn.setEnabled(false);// FixMark:nearByStnCompSnd
}
NsharpResourceHandler rsc = getRscHandler();
if (rsc != null) {

View file

@ -840,7 +840,7 @@
<Color red="255" green="255" blue="0" alpha="255"/>
<Point Lat="39.35390746604257" Lon="-73.2133975036754"/>
</Vector>
<Track skipFactorTextString="0" setTimeButtonSelected="true" pgenType="STORM_TRACK" pgenCategory="Track" lineWidth="1.0" intervalTimeTextString="01:00" intervalComboSelectedIndex="2" initialMarker="FILLED_DIAMOND" initialLinePattern="LINE_SOLID" fontStyleComboSelectedIndex="2" fontSizeComboSelectedIndex="2" fontSize="14.0" fontNameComboSelectedIndex="0" fontName="Courier" extrapMarker="FILLED_TRIANGLE" extrapLinePattern="LINE_SOLID" extraPointTimeDisplayOptionName="SKIP_FACTOR">
<Track skipFactorTextString="0" setTimeButtonSelected="true" pgenType="STORM_TRACK" pgenCategory="Track" lineWidth="1.0" intervalTimeTextString="00:30" intervalComboSelectedIndex="2" initialMarker="FILLED_DIAMOND" initialLinePattern="LINE_SOLID" fontStyleComboSelectedIndex="1" fontStyle="BOLD" fontSizeComboSelectedIndex="2" fontSize="14.0" fontNameComboSelectedIndex="0" fontName="Courier" extrapMarker="FILLED_TRIANGLE" extrapLinePattern="LINE_SOLID" extraPointTimeDisplayOptionName="SKIP_FACTOR">
<initialColor>
<Color red="255" green="0" blue="0" alpha="255"/>
</initialColor>

View file

@ -803,7 +803,7 @@
<Color red="255" green="255" blue="0" alpha="255"/>
<Point Lat="39.35390746604257" Lon="-73.2133975036754"/>
</Vector>
<Track skipFactorTextString="0" setTimeButtonSelected="true" pgenType="STORM_TRACK" pgenCategory="Track" lineWidth="1.0" intervalTimeTextString="01:00" intervalComboSelectedIndex="2" initialMarker="FILLED_DIAMOND" initialLinePattern="LINE_SOLID" fontStyleComboSelectedIndex="2" fontSizeComboSelectedIndex="2" fontSize="14.0" fontNameComboSelectedIndex="0" fontName="Courier" extrapMarker="FILLED_TRIANGLE" extrapLinePattern="LINE_SOLID" extraPointTimeDisplayOptionName="SKIP_FACTOR">
<Track skipFactorTextString="0" setTimeButtonSelected="true" pgenType="STORM_TRACK" pgenCategory="Track" lineWidth="1.0" intervalTimeTextString="00:30" intervalComboSelectedIndex="2" initialMarker="FILLED_DIAMOND" initialLinePattern="LINE_SOLID" fontStyleComboSelectedIndex="1" fontStyle="BOLD" fontSizeComboSelectedIndex="2" fontSize="14.0" fontNameComboSelectedIndex="0" fontName="Courier" extrapMarker="FILLED_TRIANGLE" extrapLinePattern="LINE_SOLID" extraPointTimeDisplayOptionName="SKIP_FACTOR">
<initialColor>
<Color red="255" green="0" blue="0" alpha="255"/>
</initialColor>

View file

@ -18,6 +18,7 @@
E. Safford/SAIC 06/07 rm "...UPDT TO CANCEL..."
B. Yin/SAIC 02/08 add tag number after cancellation
B. Yin 12/11 added new line for 'New' or 'Cor'
J. Wu 09/14 added new line for 'CAN'
-->
<xsl:template name="GetAttentionLine">
<xsl:param name="status"></xsl:param>
@ -25,14 +26,16 @@
<xsl:choose>
<xsl:when test="contains( $status, 'CAN')"> <!-- Cancel lines -->
<xsl:when test="contains( $status, 'CAN')"> <!-- Cancel lines -->
<xsl:element name="line"><xsl:attribute name="indent">0</xsl:attribute>
<xsl:choose>
<xsl:when test="contains( $airmet_outlook, 'AIRMET')">
<xsl:value-of select="$newline"/>
<xsl:text>CANCEL AIRMET. CONDS HV ENDED.</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$newline"/>
<xsl:text>CANCEL OUTLOOK.</xsl:text>
</xsl:otherwise>
</xsl:choose>

View file

@ -20,15 +20,19 @@
B. Yin/SAIC 08/06 distinguish smear and outlook
B. Yin/Chugach 12/11 changed 'Status' to 'issueType'
changed for-each condition for smears
J. Wu/SGT 10/14 TTR 714 - go through all smears (airmets & outlooks) in
one loop since the input XML format is different from
those in NMAP2
-->
<xsl:template name="GetStatus">
<xsl:param name="haz1">NO HAZARD1</xsl:param>
<xsl:param name="haz2">NO HAZARD2</xsl:param>
<xsl:param name="haz3">NO HAZARD3</xsl:param>
<xsl:for-each select="//Gfa[(@hazard = $haz1 or @hazard = $haz2 or @hazard = $haz3) and contains(@fcstHr,'-') and @isOutlook='false']">
<!-- <xsl:for-each select="//Gfa[(@hazard = $haz1 or @hazard = $haz2 or @hazard = $haz3) and contains(@fcstHr,'-') and @isOutlook='false']">
-->
<xsl:for-each select="//Gfa[(@hazard = $haz1 or @hazard = $haz2 or @hazard = $haz3) and contains(@fcstHr,'-') ]">
<xsl:if test="contains( @hazard, $haz1 ) or contains( @hazard, $haz2 ) or contains( @hazard, $haz3 )">
<xsl:choose>
<xsl:when test="@issueType = 'CAN'">
@ -46,8 +50,9 @@
</xsl:choose>
</xsl:if>
</xsl:for-each>
<xsl:for-each select="//outlook">
<!--
<xsl:for-each select="//outlook">
<xsl:if test="contains( hazard, $haz1 ) or contains( hazard, $haz2 ) or contains( hazard, $haz3 )">
<xsl:choose>
<xsl:when test="issueType = 'CAN'">
@ -65,7 +70,7 @@
</xsl:choose>
</xsl:if>
</xsl:for-each>
-->
</xsl:template>
<!--

View file

@ -141,15 +141,14 @@
</xsl:element>
</xsl:if>
<xsl:if test="contains( @issueType, 'CAN' ) or not(string-length($freqSevStatement) > 1)">
<!-- <xsl:if test="contains( @issueType, 'CAN' ) or not(string-length($freqSevStatement) > 1)">
<xsl:value-of select="$newline"/>
<!-- <xsl:if test="string-length($airTag) > 1">
<xsl:if test="string-length($airTag) > 1">
<xsl:element name="line">
<xsl:value-of select="$newline"/><xsl:value-of select="normalize-space($airTag)"/>.</xsl:element>
</xsl:if>
-->
</xsl:if>
-->
<!-- Add the attention line(s) -->
<xsl:call-template name="GetAttentionLine">
<xsl:with-param name="status"><xsl:value-of select="@issueType"/></xsl:with-param>

View file

@ -78,6 +78,7 @@ public abstract class AttrDlg extends Dialog implements IAttribute {
public static int ctrlBtnHeight = 28;
// public static int ctrlBtnWidth = 90;
// public static int ctrlBtnHeight = 30;
/**
@ -128,11 +129,24 @@ public abstract class AttrDlg extends Dialog implements IAttribute {
this.getButton(IDialogConstants.CANCEL_ID).setEnabled(false);
this.getButton(IDialogConstants.OK_ID).setEnabled(false);
this.getButton(IDialogConstants.CANCEL_ID).setLayoutData(
new GridData(ctrlBtnWidth, ctrlBtnHeight));
this.getButton(IDialogConstants.OK_ID).setLayoutData(
new GridData(ctrlBtnWidth, ctrlBtnHeight));
setDefaultControlButtonSize();
}
/**
* Set default size for control buttons.
*/
public void setDefaultControlButtonSize() {
setButtonSize(ctrlBtnWidth, ctrlBtnHeight);
}
/**
* Set size for control buttons.
*/
public void setButtonSize(int width, int height) {
this.getButton(IDialogConstants.CANCEL_ID).setLayoutData(
new GridData(width, height));
this.getButton(IDialogConstants.OK_ID).setLayoutData(
new GridData(width, height));
}
@Override

View file

@ -3169,6 +3169,10 @@ public class ContoursAttrDlg extends AttrDlg implements IContours,
private PgenContoursTool tool = null;
private Contours prevCont = null;
private Contours nowCont = null;
private ContourMinmaxAttrDlg(Shell parShell) throws VizException {
super(parShell);
@ -3238,11 +3242,54 @@ public class ContoursAttrDlg extends AttrDlg implements IContours,
if (apt instanceof PgenContoursTool) {
tool = (PgenContoursTool) apt;
}
if (tool != null) {
tool.resetUndoRedoCount();
PgenSession.getInstance().getCommandManager()
.addStackListener(tool);
}
// set the lat/lon from the current symbol.
DrawableElement de = drawingLayer.getSelectedDE();
if (de != null && de.getParent() instanceof ContourMinmax
&& de instanceof Symbol) {
super.setLatitude(((Symbol) de).getLocation().y);
super.setLongitude(((Symbol) de).getLocation().x);
}
/*
* Reset the listenser.
*/
for (Listener ls : undoBtn.getListeners(SWT.MouseDown)) {
undoBtn.removeListener(SWT.MouseDown, ls);
}
undoBtn.addListener(SWT.MouseDown, new Listener() {
@Override
public void handleEvent(Event event) {
if (undoBtn.getText().equalsIgnoreCase(UNDO_SYMBOL)) {
undoBtn.setText(REDO_SYMBOL);
drawingLayer.getCommandMgr().undo();
} else if (undoBtn.getText().equalsIgnoreCase(REDO_SYMBOL)) {
undoBtn.setText(UNDO_SYMBOL);
drawingLayer.getCommandMgr().redo();
}
/*
* Reset the currentContours for the ContoursAttrDlg.
*/
currentContours = prevCont;
prevCont = nowCont;
nowCont = currentContours;
mapEditor.refresh();
}
});
}
@Override
@ -3252,6 +3299,10 @@ public class ContoursAttrDlg extends AttrDlg implements IContours,
PgenSession.getInstance().getCommandManager()
.removeStackListener(tool);
}
prevCont = null;
nowCont = null;
return super.close();
}
@ -3262,15 +3313,34 @@ public class ContoursAttrDlg extends AttrDlg implements IContours,
protected void placeSymbol() {
if (tool != null) {
if (tool.getMouseHandler() instanceof PgenContoursHandler) {
/*
* Keep a copy of currentConoturs for "Undo". It chnages
* after call the "tool".
*/
prevCont = currentContours;
((PgenContoursHandler) tool.getMouseHandler())
.drawContourMinmax(new Coordinate(Double
.parseDouble(longitudeText.getText()),
Double.parseDouble(latitudeText.getText())));
placeBtn.setEnabled(false);
nowCont = currentContours; // Keep a copy for "Redo"
undoBtn.setEnabled(true);
undoBtn.setText("Undo Symbol");
((PgenContoursHandler) tool.getMouseHandler())
.drawContourMinmax(new Coordinate(Double
.parseDouble(longitudeText.getText()), Double
.parseDouble(latitudeText.getText())));
placeBtn.setEnabled(false);
undoBtn.setEnabled(true);
undoBtn.setText("Undo Symbol");
} else if (tool.getMouseHandler() instanceof PgenSelectHandler) {
minmaxTemplate = (gov.noaa.nws.ncep.ui.pgen.elements.Symbol) new DrawableElementFactory()
.create(DrawableType.SYMBOL, (IAttribute) this,
"Symbol", getActiveSymbolObjType(),
(Coordinate) null, null);
contoursAttrSettings.put(getActiveSymbolObjType(),
minmaxTemplate);
updateMinmaxAttributes();
placeBtn.setEnabled(false);
}
}
}
}
@ -3330,7 +3400,34 @@ public class ContoursAttrDlg extends AttrDlg implements IContours,
if (newEl != null && oldAdc.equals(de.getParent())) {
newEl.setParent(newAdc);
if (newEl instanceof Symbol) {
if (minmaxAttrDlg != null
&& minmaxAttrDlg.getShell() != null) {
if (minmaxAttrDlg.latitudeText.isEnabled()
&& minmaxAttrDlg.longitudeText
.isEnabled()) {
ArrayList<Coordinate> loc = new ArrayList<Coordinate>();
double lat = ((Symbol) newEl).getLocation().y;
double lon = ((Symbol) newEl).getLocation().x;
try {
lon = Double
.valueOf(minmaxAttrDlg.longitudeText
.getText());
lat = Double
.valueOf(minmaxAttrDlg.latitudeText
.getText());
} catch (Exception e) {
lon = ((Symbol) newEl).getLocation().x;
lat = ((Symbol) newEl).getLocation().y;
}
loc.add(new Coordinate(lon, lat));
newEl.setPoints(loc);
}
}
((DECollection) newAdc)
.replace(((ContourMinmax) newAdc)
.getSymbol(), newEl);
@ -3338,6 +3435,8 @@ public class ContoursAttrDlg extends AttrDlg implements IContours,
((ContourMinmax) newAdc).getSymbol().update(
minmaxTemplate);
((ContourMinmax) newAdc).getLabel().setAuto(true);
}
}
@ -3926,4 +4025,15 @@ public class ContoursAttrDlg extends AttrDlg implements IContours,
return typeChanged;
}
/**
* Update lat/lon and Undo button on SymbolAttrDlg.
*/
public void updateSymbolAttrOnGUI(Coordinate loc) {
if (minmaxAttrDlg != null && minmaxAttrDlg.getShell() != null) {
minmaxAttrDlg.setLatitude(loc.y);
minmaxAttrDlg.setLongitude(loc.x);
minmaxAttrDlg.enableUndoBtn(true);
}
}
}

View file

@ -68,9 +68,6 @@ import com.raytheon.uf.viz.core.exception.VizException;
*/
public class GfaFormatAttrDlg extends AttrDlg {
// private final static Logger logger =
// Logger.getLogger(GfaFormatAttrDlg.class);
private static final String ZULU = "ZULU";
private static final String TANGO = "TANGO";
@ -151,7 +148,6 @@ public class GfaFormatAttrDlg extends AttrDlg {
instance = new GfaFormatAttrDlg(parShell);
} catch (VizException e) {
// logger.error(e);
e.printStackTrace();
}
}
@ -306,12 +302,14 @@ public class GfaFormatAttrDlg extends AttrDlg {
@Override
public void createButtonsForButtonBar(Composite parent) {
super.createButtonsForButtonBar(parent);
this.getButton( OK_ID ).setText( SAVE_LABEL );
this.getButton( CANCEL_ID).setText( CANCEL_LABEL );
super.createButtonsForButtonBar(parent);
this.getButton(OK_ID).setText(SAVE_LABEL);
this.getButton(CANCEL_ID).setText(CANCEL_LABEL);
}
// createButton(parent, OK_ID, SAVE_LABEL, true);
// createButton(parent, CANCEL_ID, CANCEL_LABEL, false);
@Override
public void setDefaultControlButtonSize() {
setButtonSize(ctrlBtnWidth + 50, ctrlBtnHeight);
}
@Override

View file

@ -69,9 +69,27 @@ public class DefaultElementContainer extends AbstractElementContainer {
public void draw(IGraphicsTarget target, PaintProperties paintProps,
DisplayProperties dprops, boolean needsCreate) {
if ((displayEls == null) || paintProps.isZooming())
/*
* For ghost drawing - "needsCreate && dprops == null" - It is always on
* the active layer so DiaplayProperties' "filled" should be true while
* "monoColor" should be false (using the element's color).
*/
if (needsCreate && dprops == null) {
dprops = new DisplayProperties(false, null, true);
}
// For normal drawing........
if ((displayEls == null) || paintProps.isZooming()) {
needsCreate = true;
/*
* TTR971 - needs to set display properties, otherwise the layer
* color may not take effect (e.g., after switching projection)
*/
def.setLayerDisplayAttr(dprops.getLayerMonoColor(),
dprops.getLayerColor(), dprops.getLayerFilled());
}
if (paintProps.getZoomLevel() != zoomLevel) {
needsCreate = true;
zoomLevel = paintProps.getZoomLevel();
@ -102,5 +120,4 @@ public class DefaultElementContainer extends AbstractElementContainer {
}
}
}

View file

@ -143,6 +143,9 @@ import com.vividsolutions.jts.operation.distance.DistanceOp;
* 05/14 TTR 995 J. Wu Make contour label auto-placement an option.
* 07/14 ? B. Yin Added support for dashed-line circle for TCM 12 feet sea.
* 08/14 ? B. Yin Fixed world wrap for TCM track and zero circle issues.
* 08/14 TTR972 J. Wu Draw filled object as filled only if either its layer's "filled" flag
* "true" or they are on the active layer, .
* 09/14 TTR750 J. Wu Draw track label with specified font styles.
* </pre>
*
* @author sgilbert
@ -524,6 +527,7 @@ public class DisplayElementFactory {
if (isFilled) {
list.add(createFill(pts));
}
/*
* Compile each IWireframeShape, create its LineDisplayElement, and add
* to IDisplayable return list
@ -1814,7 +1818,8 @@ public class DisplayElementFactory {
double major = Math.sqrt((diff[0] * diff[0]) + (diff[1] * diff[1]));
double minor = major * arc.getAxisRatio();
if (major / this.screenToExtent < 0.000001) { // ignore circles with major = 0
if (major / this.screenToExtent < 0.000001) { // ignore circles with
// major = 0
return slist;
}
@ -2035,8 +2040,9 @@ public class DisplayElementFactory {
Text txt = new Text(null, track.getFontName(),
track.getFontSize(), TextJustification.LEFT_JUSTIFY,
pt.getLocation(), 0.0, TextRotation.SCREEN_RELATIVE,
new String[] { dtime }, FontStyle.BOLD, iniDspClr, 0,
3, false, DisplayType.NORMAL, "Text", "General Text");
new String[] { dtime }, track.getFontStyle(),
iniDspClr, 0, 3, false, DisplayType.NORMAL, "Text",
"General Text");
temps = createDisplayElements((IText) txt, paintProps);
slist.addAll(temps);
}
@ -2093,8 +2099,9 @@ public class DisplayElementFactory {
Text txt = new Text(null, track.getFontName(),
track.getFontSize(), TextJustification.LEFT_JUSTIFY,
pt.getLocation(), 0.0, TextRotation.SCREEN_RELATIVE,
new String[] { dtime }, FontStyle.BOLD, expDspClr, 0,
3, false, DisplayType.NORMAL, "Text", "General Text");
new String[] { dtime }, track.getFontStyle(),
expDspClr, 0, 3, false, DisplayType.NORMAL, "Text",
"General Text");
temps = createDisplayElements((IText) txt, paintProps);
slist.addAll(temps);
}
@ -4814,10 +4821,22 @@ public class DisplayElementFactory {
*/
private boolean getDisplayFillMode(Boolean filled) {
if (layerFilled) {
return layerFilled;
/*
* if (layerFilled) { return layerFilled; } else { return filled; }
*/
/*
* TTR 972 - to match NMAP2 behavior, non-filled elements will always be
* drawn as non-filled. Filled objects should be drawn as filled only
* when the "filled" flag for its layer is set to "true" or they are on
* the active layer, so it is necessary to set the "layerFilled" flag to
* true before generating displayables for such objects (see
* PgenResource.drawFilledElement()).
*/
if (filled && layerFilled) {
return true;
} else {
return filled;
return false;
}
}

View file

@ -7,118 +7,134 @@
*/
package gov.noaa.nws.ncep.ui.pgen.display;
import gov.noaa.nws.ncep.ui.pgen.display.IText.FontStyle;
import java.awt.Color;
import java.util.Calendar;
import gov.noaa.nws.ncep.ui.pgen.display.IText.FontStyle;
/**
* Interface used to get specific attributes of a PGEN Storm track object.
*
* @author sgilbert
*
*
*/
public interface ITrack extends ILine{
public interface ITrack extends ILine {
/**
* this enum stores the time display options for extra points
*/
public static enum ExtraPointTimeDisplayOption { SKIP_FACTOR, SHOW_FIRST_LAST, ON_ONE_HOUR, ON_HALF_HOUR };
/**
* this enum stores the time display options for extra points
*/
public static enum ExtraPointTimeDisplayOption {
SKIP_FACTOR, SHOW_FIRST_LAST, ON_ONE_HOUR, ON_HALF_HOUR
};
// /**
// * Defines available font styles
// * @return font style
// */
// public static enum FontStyle {
// REGULAR, BOLD, ITALIC, BOLD_ITALIC
// }
/**
* Gets a font style for text of track points
*/
public FontStyle getFontStyle() ;
/**
* Fets a boolean array that indicates if a time text of a extra point should be skipped
*/
public boolean[] getExtraPointTimeTextDisplayIndicator();
public FontStyle getFontStyle();
/**
* Gets extra point time display option
*/
public ExtraPointTimeDisplayOption getExtraPointTimeDisplayOption();
/**
* Gets color to plot the initial storm points
* @return color
*/
public Color getInitialColor();
/**
* Gets the line pattern used to display the initial storm points
* @return line pattern
*/
public String getInitialLinePattern();
/**
* Gets the marker used to display the initial storm points
* @return marker type
*/
public String getInitialMarker();
/**
* Gets the initial storm points and associated date/times
* @return track points
*/
public TrackPoint[] getInitialPoints();
/**
* Gets color to plot the extrapolated storm points
* @return color
*/
public Color getExtrapColor();
/**
* Gets the line pattern used to display the extrapolated storm points
* @return line pattern
*/
public String getExtrapLinePattern();
/**
* Gets the marker used to display the extrapolated storm points
* @return marker type
*/
public String getExtrapMarker();
/**
* Gets the extrapolated storm points and associated date/times
* @return track points
*/
public TrackPoint[] getExtrapPoints();
/**
* Gets the font used to display the location times
* @return font name
*/
public String getFontName();
/**
* Gets the size of the font
* @return font size
*/
public float getFontSize();
public Calendar getFirstTimeCalendar();
public Calendar getSecondTimeCalendar();
public boolean isSetTimeButtonSelected();
public int getExtraDrawingPointNumber();
public FontStyle getStyle();
public String getSkipFactorText();
public int getFontNameComboSelectedIndex();
public int getFontSizeComboSelectedIndex();
public int getFontStyleComboSelectedIndex();
public int getUnitComboSelectedIndex();
public int getRoundComboSelectedIndex();
public int getRoundDirComboSelectedIndex();
public String getIntervalTimeString();
/**
* Fets a boolean array that indicates if a time text of a extra point
* should be skipped
*/
public boolean[] getExtraPointTimeTextDisplayIndicator();
}
/**
* Gets extra point time display option
*/
public ExtraPointTimeDisplayOption getExtraPointTimeDisplayOption();
/**
* Gets color to plot the initial storm points
*
* @return color
*/
public Color getInitialColor();
/**
* Gets the line pattern used to display the initial storm points
*
* @return line pattern
*/
public String getInitialLinePattern();
/**
* Gets the marker used to display the initial storm points
*
* @return marker type
*/
public String getInitialMarker();
/**
* Gets the initial storm points and associated date/times
*
* @return track points
*/
public TrackPoint[] getInitialPoints();
/**
* Gets color to plot the extrapolated storm points
*
* @return color
*/
public Color getExtrapColor();
/**
* Gets the line pattern used to display the extrapolated storm points
*
* @return line pattern
*/
public String getExtrapLinePattern();
/**
* Gets the marker used to display the extrapolated storm points
*
* @return marker type
*/
public String getExtrapMarker();
/**
* Gets the extrapolated storm points and associated date/times
*
* @return track points
*/
public TrackPoint[] getExtrapPoints();
/**
* Gets the font used to display the location times
*
* @return font name
*/
public String getFontName();
/**
* Gets the size of the font
*
* @return font size
*/
public float getFontSize();
public Calendar getFirstTimeCalendar();
public Calendar getSecondTimeCalendar();
public boolean isSetTimeButtonSelected();
public int getExtraDrawingPointNumber();
public String getSkipFactorText();
public int getFontNameComboSelectedIndex();
public int getFontSizeComboSelectedIndex();
public int getFontStyleComboSelectedIndex();
public int getUnitComboSelectedIndex();
public int getRoundComboSelectedIndex();
public int getRoundDirComboSelectedIndex();
public String getIntervalTimeString();
}

View file

@ -15,59 +15,81 @@ import com.raytheon.uf.viz.core.map.IMapDescriptor;
/**
* An Element Container that can be used for most Symbol/Marker Elements.
* Recreation of the IDisplayable objects is only done if the layer DisplayProperties change.
* The raster images do not need to be recreated when panning or zooming.
* Recreation of the IDisplayable objects is only done if the layer
* DisplayProperties change. The raster images do not need to be recreated when
* panning or zooming.
*
* @author sgilbert
*
*
*/
public class RasterElementContainer extends AbstractElementContainer {
private DisplayProperties saveProps = null;
/**
* @param element
* @param mapDescriptor
* @param target
*/
public RasterElementContainer(DrawableElement element,
IMapDescriptor mapDescriptor, IGraphicsTarget target) {
super(element, mapDescriptor, target);
//
}
private DisplayProperties saveProps = null;
/*
* Draws to the given graphics target. Recreates the IDisplayable objects
* if the Layer properties change.
* @see gov.noaa.nws.ncep.ui.pgen.display.AbstractTBNL#draw(com.raytheon.uf.viz.core.IGraphicsTarget, com.raytheon.uf.viz.core.drawables.PaintProperties)
*/
@Override
public void draw(IGraphicsTarget target, PaintProperties paintProps,
DisplayProperties dprops) {
draw(target, paintProps, dprops, false);
}
/**
* @param element
* @param mapDescriptor
* @param target
*/
public RasterElementContainer(DrawableElement element,
IMapDescriptor mapDescriptor, IGraphicsTarget target) {
super(element, mapDescriptor, target);
//
}
/*
* Draws to the given graphics target. Recreates the IDisplayable objects
* if the Layer properties change.
* @see gov.noaa.nws.ncep.ui.pgen.display.AbstractTBNL#draw(com.raytheon.uf.viz.core.IGraphicsTarget, com.raytheon.uf.viz.core.drawables.PaintProperties, boolean)
*/
@Override
public void draw(IGraphicsTarget target, PaintProperties paintProps,
DisplayProperties dprops, boolean needsCreate) {
if ( displayEls == null ) needsCreate = true;
if ( (dprops != null) && ! dprops.equals(saveProps) ) {
def.setLayerDisplayAttr(dprops.getLayerMonoColor(), dprops.getLayerColor(), dprops.getLayerFilled());
needsCreate = true;
}
if ( needsCreate ) createDisplayables(paintProps);
saveProps = dprops;
for ( IDisplayable each : displayEls ) {
each.draw(target, paintProps);
}
}
/*
* Draws to the given graphics target. Recreates the IDisplayable objects if
* the Layer properties change.
*
* @see
* gov.noaa.nws.ncep.ui.pgen.display.AbstractTBNL#draw(com.raytheon.uf.viz
* .core.IGraphicsTarget,
* com.raytheon.uf.viz.core.drawables.PaintProperties)
*/
@Override
public void draw(IGraphicsTarget target, PaintProperties paintProps,
DisplayProperties dprops) {
draw(target, paintProps, dprops, false);
}
/*
* Draws to the given graphics target. Recreates the IDisplayable objects if
* the Layer properties change.
*
* @see
* gov.noaa.nws.ncep.ui.pgen.display.AbstractTBNL#draw(com.raytheon.uf.viz
* .core.IGraphicsTarget,
* com.raytheon.uf.viz.core.drawables.PaintProperties, boolean)
*/
@Override
public void draw(IGraphicsTarget target, PaintProperties paintProps,
DisplayProperties dprops, boolean needsCreate) {
if (displayEls == null) {
needsCreate = true;
/*
* TTR971 - needs to set display properties, otherwise the layer
* color may not take effect (e.g., after switching projection)
*/
def.setLayerDisplayAttr(dprops.getLayerMonoColor(),
dprops.getLayerColor(), dprops.getLayerFilled());
}
if ((dprops != null) && !dprops.equals(saveProps)) {
def.setLayerDisplayAttr(dprops.getLayerMonoColor(),
dprops.getLayerColor(), dprops.getLayerFilled());
needsCreate = true;
}
if (needsCreate)
createDisplayables(paintProps);
saveProps = dprops;
for (IDisplayable each : displayEls) {
each.draw(target, paintProps);
}
}
}

View file

@ -154,6 +154,14 @@ public class TextDisplayElement implements IDisplayable {
target.drawShadedRect(box, bg, 1.0, null);
}
/*
* TTR 741 (10/2014) - Note, for single-line text, we could match it
* to Raytheon's text style. For multi-line text, we cannot match it
* to Raytheon's since it may add box, overline, underline to each
* line of text, not one single box, overline, or underline - so we
* may need to develop a new drawing method or ask Raytheon to
* provide support in GlTarget.
*/
switch (displayType) {
case NORMAL:
@ -161,19 +169,40 @@ public class TextDisplayElement implements IDisplayable {
break;
case BOX:
dstring.textStyle = TextStyle.BOXED;
// dstring.textStyle = TextStyle.BOXED;
if (dstring.getText().length > 1) {
target.drawRect(box, dstring.getColors()[0], 1.0f, 1.0);
} else {
dstring.textStyle = TextStyle.BOXED;
}
// target.drawRect(box, dstring.getColors()[0], 1.0f, 1.0);
break;
case OVERLINE:
dstring.textStyle = TextStyle.OVERLINE;
// dstring.textStyle = TextStyle.OVERLINE;
if (dstring.getText().length > 1) {
target.drawLine(box.getMinX(), box.getMinY(), 0.0,
box.getMaxX(), box.getMinY(), 0.0,
dstring.getColors()[0], 1.0f);
} else {
dstring.textStyle = TextStyle.OVERLINE;
}
// target.drawLine(box.getMinX(), box.getMinY(), 0.0,
// box.getMaxX(), box.getMinY(), 0.0,
// dstring.getColors()[0], 1.0f);
break;
case UNDERLINE:
dstring.textStyle = TextStyle.UNDERLINE;
// dstring.textStyle = TextStyle.UNDERLINE;
if (dstring.getText().length > 1) {
target.drawLine(box.getMinX(), box.getMaxY(), 0.0,
box.getMaxX(), box.getMaxY(), 0.0,
dstring.getColors()[0], 1.0f);
} else {
dstring.textStyle = TextStyle.UNDERLINE;
}
// target.drawLine(box.getMinX(), box.getMaxY(), 0.0,
// box.getMaxX(), box.getMaxY(), 0.0,
// dstring.getColors()[0], 1.0f);

View file

@ -134,6 +134,7 @@ import com.vividsolutions.jts.geom.Coordinate;
* 12/13 TTR904 B. Yin Added back the water zone string for Watch county list
* 11/13 #1065 J. Wu Added Kink lines.
* 05/14 TTR995 J. Wu Set Text's 'auto" flag to false.
* 09/14 TTR716 J. Wu Use "-" for GFA Outlook's Vor text.
*
* </pre>
*
@ -735,6 +736,12 @@ public class ProductConverter {
gfa.setGfaValue("Type", fgfa.getType());
}
// textVOR
String vorStr = fgfa.getTextVor();
if (vorStr != null) {
gfa.setGfaVorText(nvl(vorStr));
}
String cig = fgfa.getCig();
if (cig != null) {
gfa.setGfaValue(Gfa.CIG, fgfa.getCig());
@ -1098,7 +1105,11 @@ public class ProductConverter {
}
// textVOR
fgfa.setTextVor(nvl(((Gfa) de).getGfaVorText()));
String vorStr = ((Gfa) de).getGfaVorText();
if (vorStr != null && ((Gfa) de).isOutlook()) {
vorStr = vorStr.replaceAll(" TO ", "-");
}
fgfa.setTextVor(nvl(vorStr));
fgfa.setFillPattern(nvl(((Gfa) de).getFillPattern()
.name()));

View file

@ -5,11 +5,11 @@
// Generated on: 2009.05.28 at 02:35:15 PM EDT
//
package gov.noaa.nws.ncep.ui.pgen.file;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
@ -17,11 +17,13 @@ import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for anonymous complex type.
* <p>
* Java class for anonymous complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
* <p>
* The following schema fragment specifies the expected content contained within
* this class.
*
* <pre>
* &lt;complexType>
@ -38,6 +40,7 @@ import javax.xml.bind.annotation.XmlType;
* &lt;attribute name="extrapLinePattern" type="{http://www.w3.org/2001/XMLSchema}string" />
* &lt;attribute name="extrapMarker" type="{http://www.w3.org/2001/XMLSchema}string" />
* &lt;attribute name="fontName" type="{http://www.w3.org/2001/XMLSchema}string" />
* &lt;attribute name="fontStyle" type="{http://www.w3.org/2001/XMLSchema}string" />
* &lt;attribute name="fontNameComboSelectedIndex" type="{http://www.w3.org/2001/XMLSchema}int" />
* &lt;attribute name="fontSize" type="{http://www.w3.org/2001/XMLSchema}float" />
* &lt;attribute name="fontSizeComboSelectedIndex" type="{http://www.w3.org/2001/XMLSchema}int" />
@ -60,68 +63,85 @@ import javax.xml.bind.annotation.XmlType;
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"initialColor",
"extrapColor",
"initialPoints",
"extrapPoints",
"extraPointTimeTextDisplayIndicator"
})
@XmlType(name = "", propOrder = { "initialColor", "extrapColor",
"initialPoints", "extrapPoints", "extraPointTimeTextDisplayIndicator" })
@XmlRootElement(name = "Track")
public class Track {
@XmlElement(required = true)
protected ColorType initialColor;
@XmlElement(required = true)
protected ColorType extrapColor;
@XmlElement(required = true)
protected List<TrackPoint> initialPoints;
@XmlElement(required = true)
protected List<TrackPoint> extrapPoints;
@XmlElement(type = Boolean.class)
protected List<Boolean> extraPointTimeTextDisplayIndicator;
@XmlAttribute
protected String extraPointTimeDisplayOptionName;
@XmlAttribute
protected String extrapLinePattern;
@XmlAttribute
protected String extrapMarker;
@XmlAttribute
protected String fontName;
@XmlAttribute
protected String fontStyle;
@XmlAttribute
protected Integer fontNameComboSelectedIndex;
@XmlAttribute
protected Float fontSize;
@XmlAttribute
protected Integer fontSizeComboSelectedIndex;
@XmlAttribute
protected Integer fontStyleComboSelectedIndex;
@XmlAttribute
protected String initialLinePattern;
@XmlAttribute
protected String initialMarker;
@XmlAttribute
protected Integer intervalComboSelectedIndex;
@XmlAttribute
protected String intervalTimeTextString;
@XmlAttribute
protected Float lineWidth;
@XmlAttribute
protected String pgenCategory;
@XmlAttribute
protected String pgenType;
@XmlAttribute
protected Boolean setTimeButtonSelected;
@XmlAttribute
protected String skipFactorTextString;
/**
* Gets the value of the initialColor property.
*
* @return
* possible object is
* {@link ColorType }
*
* @return possible object is {@link ColorType }
*
*/
public ColorType getInitialColor() {
return initialColor;
@ -131,9 +151,8 @@ public class Track {
* Sets the value of the initialColor property.
*
* @param value
* allowed object is
* {@link ColorType }
*
* allowed object is {@link ColorType }
*
*/
public void setInitialColor(ColorType value) {
this.initialColor = value;
@ -142,10 +161,8 @@ public class Track {
/**
* Gets the value of the extrapColor property.
*
* @return
* possible object is
* {@link ColorType }
*
* @return possible object is {@link ColorType }
*
*/
public ColorType getExtrapColor() {
return extrapColor;
@ -155,9 +172,8 @@ public class Track {
* Sets the value of the extrapColor property.
*
* @param value
* allowed object is
* {@link ColorType }
*
* allowed object is {@link ColorType }
*
*/
public void setExtrapColor(ColorType value) {
this.extrapColor = value;
@ -167,15 +183,16 @@ public class Track {
* Gets the value of the initialPoints property.
*
* <p>
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a <CODE>set</CODE> method for the initialPoints property.
* This accessor method returns a reference to the live list, not a
* snapshot. Therefore any modification you make to the returned list will
* be present inside the JAXB object. This is why there is not a
* <CODE>set</CODE> method for the initialPoints property.
*
* <p>
* For example, to add a new item, do as follows:
*
* <pre>
* getInitialPoints().add(newItem);
* getInitialPoints().add(newItem);
* </pre>
*
*
@ -196,15 +213,16 @@ public class Track {
* Gets the value of the extrapPoints property.
*
* <p>
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a <CODE>set</CODE> method for the extrapPoints property.
* This accessor method returns a reference to the live list, not a
* snapshot. Therefore any modification you make to the returned list will
* be present inside the JAXB object. This is why there is not a
* <CODE>set</CODE> method for the extrapPoints property.
*
* <p>
* For example, to add a new item, do as follows:
*
* <pre>
* getExtrapPoints().add(newItem);
* getExtrapPoints().add(newItem);
* </pre>
*
*
@ -225,21 +243,22 @@ public class Track {
* Gets the value of the extraPointTimeTextDisplayIndicator property.
*
* <p>
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a <CODE>set</CODE> method for the extraPointTimeTextDisplayIndicator property.
* This accessor method returns a reference to the live list, not a
* snapshot. Therefore any modification you make to the returned list will
* be present inside the JAXB object. This is why there is not a
* <CODE>set</CODE> method for the extraPointTimeTextDisplayIndicator
* property.
*
* <p>
* For example, to add a new item, do as follows:
*
* <pre>
* getExtraPointTimeTextDisplayIndicator().add(newItem);
* getExtraPointTimeTextDisplayIndicator().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link Boolean }
* Objects of the following type(s) are allowed in the list {@link Boolean }
*
*
*/
@ -253,10 +272,8 @@ public class Track {
/**
* Gets the value of the extraPointTimeDisplayOptionName property.
*
* @return
* possible object is
* {@link String }
*
* @return possible object is {@link String }
*
*/
public String getExtraPointTimeDisplayOptionName() {
return extraPointTimeDisplayOptionName;
@ -266,9 +283,8 @@ public class Track {
* Sets the value of the extraPointTimeDisplayOptionName property.
*
* @param value
* allowed object is
* {@link String }
*
* allowed object is {@link String }
*
*/
public void setExtraPointTimeDisplayOptionName(String value) {
this.extraPointTimeDisplayOptionName = value;
@ -277,10 +293,8 @@ public class Track {
/**
* Gets the value of the extrapLinePattern property.
*
* @return
* possible object is
* {@link String }
*
* @return possible object is {@link String }
*
*/
public String getExtrapLinePattern() {
return extrapLinePattern;
@ -290,9 +304,8 @@ public class Track {
* Sets the value of the extrapLinePattern property.
*
* @param value
* allowed object is
* {@link String }
*
* allowed object is {@link String }
*
*/
public void setExtrapLinePattern(String value) {
this.extrapLinePattern = value;
@ -301,10 +314,8 @@ public class Track {
/**
* Gets the value of the extrapMarker property.
*
* @return
* possible object is
* {@link String }
*
* @return possible object is {@link String }
*
*/
public String getExtrapMarker() {
return extrapMarker;
@ -314,9 +325,8 @@ public class Track {
* Sets the value of the extrapMarker property.
*
* @param value
* allowed object is
* {@link String }
*
* allowed object is {@link String }
*
*/
public void setExtrapMarker(String value) {
this.extrapMarker = value;
@ -325,10 +335,8 @@ public class Track {
/**
* Gets the value of the fontName property.
*
* @return
* possible object is
* {@link String }
*
* @return possible object is {@link String }
*
*/
public String getFontName() {
return fontName;
@ -338,21 +346,39 @@ public class Track {
* Sets the value of the fontName property.
*
* @param value
* allowed object is
* {@link String }
*
* allowed object is {@link String }
*
*/
public void setFontName(String value) {
this.fontName = value;
}
/**
* Gets the value of the fontStyle property.
*
* @return possible object is {@link String }
*
*/
public String getFontStyle() {
return fontStyle;
}
/**
* Sets the value of the fontStyle property.
*
* @param value
* allowed object is {@link String }
*
*/
public void setFontStyle(String value) {
this.fontStyle = value;
}
/**
* Gets the value of the fontNameComboSelectedIndex property.
*
* @return
* possible object is
* {@link Integer }
*
* @return possible object is {@link Integer }
*
*/
public Integer getFontNameComboSelectedIndex() {
return fontNameComboSelectedIndex;
@ -362,9 +388,8 @@ public class Track {
* Sets the value of the fontNameComboSelectedIndex property.
*
* @param value
* allowed object is
* {@link Integer }
*
* allowed object is {@link Integer }
*
*/
public void setFontNameComboSelectedIndex(Integer value) {
this.fontNameComboSelectedIndex = value;
@ -373,10 +398,8 @@ public class Track {
/**
* Gets the value of the fontSize property.
*
* @return
* possible object is
* {@link Float }
*
* @return possible object is {@link Float }
*
*/
public Float getFontSize() {
return fontSize;
@ -386,9 +409,8 @@ public class Track {
* Sets the value of the fontSize property.
*
* @param value
* allowed object is
* {@link Float }
*
* allowed object is {@link Float }
*
*/
public void setFontSize(Float value) {
this.fontSize = value;
@ -397,10 +419,8 @@ public class Track {
/**
* Gets the value of the fontSizeComboSelectedIndex property.
*
* @return
* possible object is
* {@link Integer }
*
* @return possible object is {@link Integer }
*
*/
public Integer getFontSizeComboSelectedIndex() {
return fontSizeComboSelectedIndex;
@ -410,9 +430,8 @@ public class Track {
* Sets the value of the fontSizeComboSelectedIndex property.
*
* @param value
* allowed object is
* {@link Integer }
*
* allowed object is {@link Integer }
*
*/
public void setFontSizeComboSelectedIndex(Integer value) {
this.fontSizeComboSelectedIndex = value;
@ -421,10 +440,8 @@ public class Track {
/**
* Gets the value of the fontStyleComboSelectedIndex property.
*
* @return
* possible object is
* {@link Integer }
*
* @return possible object is {@link Integer }
*
*/
public Integer getFontStyleComboSelectedIndex() {
return fontStyleComboSelectedIndex;
@ -434,9 +451,8 @@ public class Track {
* Sets the value of the fontStyleComboSelectedIndex property.
*
* @param value
* allowed object is
* {@link Integer }
*
* allowed object is {@link Integer }
*
*/
public void setFontStyleComboSelectedIndex(Integer value) {
this.fontStyleComboSelectedIndex = value;
@ -445,10 +461,8 @@ public class Track {
/**
* Gets the value of the initialLinePattern property.
*
* @return
* possible object is
* {@link String }
*
* @return possible object is {@link String }
*
*/
public String getInitialLinePattern() {
return initialLinePattern;
@ -458,9 +472,8 @@ public class Track {
* Sets the value of the initialLinePattern property.
*
* @param value
* allowed object is
* {@link String }
*
* allowed object is {@link String }
*
*/
public void setInitialLinePattern(String value) {
this.initialLinePattern = value;
@ -469,10 +482,8 @@ public class Track {
/**
* Gets the value of the initialMarker property.
*
* @return
* possible object is
* {@link String }
*
* @return possible object is {@link String }
*
*/
public String getInitialMarker() {
return initialMarker;
@ -482,9 +493,8 @@ public class Track {
* Sets the value of the initialMarker property.
*
* @param value
* allowed object is
* {@link String }
*
* allowed object is {@link String }
*
*/
public void setInitialMarker(String value) {
this.initialMarker = value;
@ -493,10 +503,8 @@ public class Track {
/**
* Gets the value of the intervalComboSelectedIndex property.
*
* @return
* possible object is
* {@link Integer }
*
* @return possible object is {@link Integer }
*
*/
public Integer getIntervalComboSelectedIndex() {
return intervalComboSelectedIndex;
@ -506,9 +514,8 @@ public class Track {
* Sets the value of the intervalComboSelectedIndex property.
*
* @param value
* allowed object is
* {@link Integer }
*
* allowed object is {@link Integer }
*
*/
public void setIntervalComboSelectedIndex(Integer value) {
this.intervalComboSelectedIndex = value;
@ -517,10 +524,8 @@ public class Track {
/**
* Gets the value of the intervalTimeTextString property.
*
* @return
* possible object is
* {@link String }
*
* @return possible object is {@link String }
*
*/
public String getIntervalTimeTextString() {
return intervalTimeTextString;
@ -530,9 +535,8 @@ public class Track {
* Sets the value of the intervalTimeTextString property.
*
* @param value
* allowed object is
* {@link String }
*
* allowed object is {@link String }
*
*/
public void setIntervalTimeTextString(String value) {
this.intervalTimeTextString = value;
@ -541,10 +545,8 @@ public class Track {
/**
* Gets the value of the lineWidth property.
*
* @return
* possible object is
* {@link Float }
*
* @return possible object is {@link Float }
*
*/
public Float getLineWidth() {
return lineWidth;
@ -554,9 +556,8 @@ public class Track {
* Sets the value of the lineWidth property.
*
* @param value
* allowed object is
* {@link Float }
*
* allowed object is {@link Float }
*
*/
public void setLineWidth(Float value) {
this.lineWidth = value;
@ -565,10 +566,8 @@ public class Track {
/**
* Gets the value of the pgenCategory property.
*
* @return
* possible object is
* {@link String }
*
* @return possible object is {@link String }
*
*/
public String getPgenCategory() {
return pgenCategory;
@ -578,9 +577,8 @@ public class Track {
* Sets the value of the pgenCategory property.
*
* @param value
* allowed object is
* {@link String }
*
* allowed object is {@link String }
*
*/
public void setPgenCategory(String value) {
this.pgenCategory = value;
@ -589,10 +587,8 @@ public class Track {
/**
* Gets the value of the pgenType property.
*
* @return
* possible object is
* {@link String }
*
* @return possible object is {@link String }
*
*/
public String getPgenType() {
return pgenType;
@ -602,9 +598,8 @@ public class Track {
* Sets the value of the pgenType property.
*
* @param value
* allowed object is
* {@link String }
*
* allowed object is {@link String }
*
*/
public void setPgenType(String value) {
this.pgenType = value;
@ -613,10 +608,8 @@ public class Track {
/**
* Gets the value of the setTimeButtonSelected property.
*
* @return
* possible object is
* {@link Boolean }
*
* @return possible object is {@link Boolean }
*
*/
public Boolean isSetTimeButtonSelected() {
return setTimeButtonSelected;
@ -626,9 +619,8 @@ public class Track {
* Sets the value of the setTimeButtonSelected property.
*
* @param value
* allowed object is
* {@link Boolean }
*
* allowed object is {@link Boolean }
*
*/
public void setSetTimeButtonSelected(Boolean value) {
this.setTimeButtonSelected = value;
@ -637,10 +629,8 @@ public class Track {
/**
* Gets the value of the skipFactorTextString property.
*
* @return
* possible object is
* {@link String }
*
* @return possible object is {@link String }
*
*/
public String getSkipFactorTextString() {
return skipFactorTextString;
@ -650,9 +640,8 @@ public class Track {
* Sets the value of the skipFactorTextString property.
*
* @param value
* allowed object is
* {@link String }
*
* allowed object is {@link String }
*
*/
public void setSkipFactorTextString(String value) {
this.skipFactorTextString = value;

View file

@ -7,11 +7,17 @@
*/
package gov.noaa.nws.ncep.ui.pgen.file;
import gov.noaa.nws.ncep.ui.pgen.display.FillPatternList.FillPattern;
import gov.noaa.nws.ncep.ui.pgen.display.IText.FontStyle;
import gov.noaa.nws.ncep.ui.pgen.display.ITrack;
import gov.noaa.nws.ncep.ui.pgen.display.TrackPoint;
import gov.noaa.nws.ncep.ui.pgen.elements.Track;
import java.awt.Color;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.List;
import java.util.ArrayList;
import java.awt.Color;
import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.datatype.DatatypeFactory;
@ -22,318 +28,423 @@ import org.geotools.referencing.datum.DefaultEllipsoid;
import com.vividsolutions.jts.geom.Coordinate;
import gov.noaa.nws.ncep.ui.pgen.elements.Track;
import gov.noaa.nws.ncep.ui.pgen.display.ITrack;
import gov.noaa.nws.ncep.ui.pgen.display.TrackPoint;
import gov.noaa.nws.ncep.ui.pgen.display.FillPatternList.FillPattern;
/**
* Define a ProductConverter Class - some methods to convert the products between XML format
* and the actual in-memory PGEN products.
* Define a ProductConverter Class - some methods to convert the products
* between XML format and the actual in-memory PGEN products.
*
* <pre>
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 02/2012 TTR456 Q. Zhou Added speed, dir. Default to kts, no round
* 02/2012 TTR456 Q. Zhou Added speed, dir. Default to kts, no round
* 09/2014 TTR750 J. Wu Use FontStyle instead of "index".
* </pre>
* */
public class TrackConverter {
// private final static org.apache.log4j.Logger log =
// org.apache.log4j.Logger.getLogger(TrackConverter.class);
/*
* Convert a XML file DrawableElement object to a list of PGEN in-memory
* DrawableElement objects
*/
public static List<Track> getTrackElementListByTrackBeanList (
List<gov.noaa.nws.ncep.ui.pgen.file.Track> trackBeanList) {
List<Track> trackElementList = new ArrayList<Track>(trackBeanList.size());
for(gov.noaa.nws.ncep.ui.pgen.file.Track trackBean : trackBeanList) {
Track trackElement = new Track();
trackElement.setInitialColor(getColorByColorTypeBean(trackBean.initialColor, true));
trackElement.setExtrapColor(getColorByColorTypeBean(trackBean.extrapColor, false));
trackElement.setInitTrackPoints(getTrackPointElementListByTrackPointBeanList(trackBean.getInitialPoints()).toArray(new TrackPoint[trackBean.getInitialPoints().size()]));
trackElement.setExtrapPoints(getTrackPointElementListByTrackPointBeanList(trackBean.getExtrapPoints()).toArray(new TrackPoint[trackBean.getExtrapPoints().size()]));
/*
* Now initialize track's firstTimeCalendar and secondTimeCalendar using initTrackPoints
*/
trackElement.setFirstTimeCalendar(getFirstOrSecondTimeCalendarByTrackBean(trackBean, true));
trackElement.setSecondTimeCalendar(getFirstOrSecondTimeCalendarByTrackBean(trackBean, false));
/*
* Important note: the following two method calls are necessary.
* 1. combine init and extrap points to allow PgenSource to go over every point for drawing
* 2. setLinePattern is from the parent class of Track, the name is kind of misleading
* It is hard coded now, for future, a new field is needed to the XSD file.
*/
trackElement.setLinePointsValue(trackElement.getInitialPoints(), trackElement.getExtrapPoints());
trackElement.setExtraPointTimeTextDisplayIndicator(getBooleanArrayByBooleanList(trackBean.extraPointTimeTextDisplayIndicator));
trackElement.setInitialLinePattern(trackBean.getInitialLinePattern());
trackElement.setExtrapLinePattern(trackBean.getExtrapLinePattern());
trackElement.setInitialMarker(trackBean.getInitialMarker());
trackElement.setExtrapMarker(trackBean.getExtrapMarker());
trackElement.setFontName(trackBean.getFontName());
if(trackBean.getLineWidth() != null)
trackElement.setLineWidth(trackBean.getLineWidth().floatValue());
else
trackElement.setLineWidth((float)1.0); //set a 1.0 as the default value
if(trackBean.getFontSize() != null)
trackElement.setFontSize(trackBean.getFontSize().floatValue());
else
trackElement.setFontSize((float)2.0); //set a 2.0 as the default value
if(trackBean.getPgenCategory() == null)
trackElement.setPgenCategory(Track.TRACK_PGEN_CATEGORY);
else
trackElement.setPgenCategory(trackBean.getPgenCategory());
if(trackBean.getPgenType() == null)
trackElement.setPgenType(Track.TRACK_PGEN_TYPE);
else
trackElement.setPgenType(trackBean.getPgenType());
/*
* add speed, dir. Default to kts, no round --Quan
*/
TrackPoint[] initPts = trackElement.getInitTrackPoints();
int initPtsLength = initPts.length;
Coordinate initPointBeforeLastInitPointCoordinate = initPts[initPtsLength - 2].getLocation();
Coordinate lastInitPointCoordinate = initPts[initPtsLength - 1].getLocation();
GeodeticCalculator gc = new GeodeticCalculator(DefaultEllipsoid.WGS84);
gc.setStartingGeographicPoint(initPointBeforeLastInitPointCoordinate.x,
initPointBeforeLastInitPointCoordinate.y);
gc.setDestinationGeographicPoint(lastInitPointCoordinate.x,
lastInitPointCoordinate.y);
double direction = gc.getAzimuth();
double distanceInMeter = gc.getOrthodromicDistance();
long timeDifference = initPts[initPtsLength - 1].getTime().getTimeInMillis() -
initPts[initPtsLength - 2].getTime().getTimeInMillis();
double speed = distanceInMeter / (double)timeDifference;
trackElement.setDirectionForExtraPoints(direction);
trackElement.setSpeed(speed);
/*
* add something related to line drawing
*/
trackElement.setSizeScale((double) 1.0);
trackElement.setSmoothFactor(0);
trackElement.setClosed(false);
trackElement.setFilled(false);
trackElement.setFillPattern(FillPattern.FILL_PATTERN_0);
/*
* The following attributes are necessary to fill values for the pop-up
* TrackAttiDlg window from the restored line images.
*/
boolean setTimeButtonSelectedFlag = true; // set the default value as TRUE
if(trackBean.isSetTimeButtonSelected() != null)
setTimeButtonSelectedFlag = trackBean.isSetTimeButtonSelected().booleanValue();
trackElement.setSetTimeButtonSelected(setTimeButtonSelectedFlag);
int intervalComboSelectedIndexValue = 0; //set the default value
if(trackBean.getIntervalComboSelectedIndex() != null)
intervalComboSelectedIndexValue = trackBean.getIntervalComboSelectedIndex().intValue();
trackElement.setIntervalComboSelectedIndex(intervalComboSelectedIndexValue);
trackElement.setIntervalTimeString(trackBean.getIntervalTimeTextString());
String extraPointTimeDisplayOptionName = ITrack.ExtraPointTimeDisplayOption.SKIP_FACTOR.name(); // set the default value
if(trackBean.getExtraPointTimeDisplayOptionName() != null)
extraPointTimeDisplayOptionName = trackBean.getExtraPointTimeDisplayOptionName();
trackElement.setExtraPointTimeDisplayOption(ITrack.ExtraPointTimeDisplayOption.valueOf(extraPointTimeDisplayOptionName));
String skipFactorTextString = "0"; //set the default value
if(trackBean.getSkipFactorTextString() != null)
skipFactorTextString = trackBean.getSkipFactorTextString();
trackElement.setSkipFactorTextString(skipFactorTextString);
int fontNameComboSelectedIndex = 0; //set the default value
if(trackBean.getFontNameComboSelectedIndex() != null)
fontNameComboSelectedIndex = trackBean.getFontNameComboSelectedIndex().intValue();
trackElement.setFontNameComboSelectedIndex(fontNameComboSelectedIndex);
int fontSizeComboSelectedIndex = 0; //set the default value
if(trackBean.getFontSizeComboSelectedIndex() != null)
fontSizeComboSelectedIndex = trackBean.getFontSizeComboSelectedIndex().intValue();
trackElement.setFontSizeComboSelectedIndex(fontSizeComboSelectedIndex);
int fontStyleComboSelectedIndex = 0; //set the default value
if(trackBean.getFontStyleComboSelectedIndex() != null)
fontStyleComboSelectedIndex = trackBean.getFontStyleComboSelectedIndex().intValue();
trackElement.setFontStyleComboSelectedIndex(fontStyleComboSelectedIndex);
trackElementList.add(trackElement);
}
// private final static org.apache.log4j.Logger log =
// org.apache.log4j.Logger.getLogger(TrackConverter.class);
/*
* Convert a XML file DrawableElement object to a list of PGEN in-memory
* DrawableElement objects
*/
public static List<Track> getTrackElementListByTrackBeanList(
List<gov.noaa.nws.ncep.ui.pgen.file.Track> trackBeanList) {
List<Track> trackElementList = new ArrayList<Track>(
trackBeanList.size());
for (gov.noaa.nws.ncep.ui.pgen.file.Track trackBean : trackBeanList) {
Track trackElement = new Track();
trackElement.setInitialColor(getColorByColorTypeBean(
trackBean.initialColor, true));
trackElement.setExtrapColor(getColorByColorTypeBean(
trackBean.extrapColor, false));
trackElement
.setInitTrackPoints(getTrackPointElementListByTrackPointBeanList(
trackBean.getInitialPoints())
.toArray(
new TrackPoint[trackBean.getInitialPoints()
.size()]));
trackElement
.setExtrapPoints(getTrackPointElementListByTrackPointBeanList(
trackBean.getExtrapPoints()).toArray(
new TrackPoint[trackBean.getExtrapPoints().size()]));
/*
* Now initialize track's firstTimeCalendar and secondTimeCalendar
* using initTrackPoints
*/
trackElement
.setFirstTimeCalendar(getFirstOrSecondTimeCalendarByTrackBean(
trackBean, true));
trackElement
.setSecondTimeCalendar(getFirstOrSecondTimeCalendarByTrackBean(
trackBean, false));
/*
* Important note: the following two method calls are necessary. 1.
* combine init and extrap points to allow PgenSource to go over
* every point for drawing 2. setLinePattern is from the parent
* class of Track, the name is kind of misleading It is hard coded
* now, for future, a new field is needed to the XSD file.
*/
trackElement.setLinePointsValue(trackElement.getInitialPoints(),
trackElement.getExtrapPoints());
trackElement
.setExtraPointTimeTextDisplayIndicator(getBooleanArrayByBooleanList(trackBean.extraPointTimeTextDisplayIndicator));
trackElement.setInitialLinePattern(trackBean
.getInitialLinePattern());
trackElement.setExtrapLinePattern(trackBean.getExtrapLinePattern());
trackElement.setInitialMarker(trackBean.getInitialMarker());
trackElement.setExtrapMarker(trackBean.getExtrapMarker());
trackElement.setFontName(trackBean.getFontName());
// TTR 950 - Font Style
int styleInd = 0;
FontStyle dstyle = FontStyle.BOLD;
if (trackBean.getFontStyle() != null) {
int jj = 0;
for (FontStyle ft : FontStyle.values()) {
if (ft == FontStyle.valueOf(trackBean.getFontStyle()
.toUpperCase())) {
styleInd = jj;
dstyle = ft;
break;
}
jj++;
}
}
trackElement.setFontStyle(dstyle);
trackElement.setFontStyleComboSelectedIndex(styleInd);
if (trackBean.getLineWidth() != null)
trackElement
.setLineWidth(trackBean.getLineWidth().floatValue());
else
trackElement.setLineWidth((float) 1.0); // set a 1.0 as the
// default value
if (trackBean.getFontSize() != null)
trackElement.setFontSize(trackBean.getFontSize().floatValue());
else
trackElement.setFontSize((float) 2.0); // set a 2.0 as the
// default value
if (trackBean.getPgenCategory() == null)
trackElement.setPgenCategory(Track.TRACK_PGEN_CATEGORY);
else
trackElement.setPgenCategory(trackBean.getPgenCategory());
if (trackBean.getPgenType() == null)
trackElement.setPgenType(Track.TRACK_PGEN_TYPE);
else
trackElement.setPgenType(trackBean.getPgenType());
/*
* add speed, dir. Default to kts, no round --Quan
*/
TrackPoint[] initPts = trackElement.getInitTrackPoints();
int initPtsLength = initPts.length;
Coordinate initPointBeforeLastInitPointCoordinate = initPts[initPtsLength - 2]
.getLocation();
Coordinate lastInitPointCoordinate = initPts[initPtsLength - 1]
.getLocation();
GeodeticCalculator gc = new GeodeticCalculator(
DefaultEllipsoid.WGS84);
gc.setStartingGeographicPoint(
initPointBeforeLastInitPointCoordinate.x,
initPointBeforeLastInitPointCoordinate.y);
gc.setDestinationGeographicPoint(lastInitPointCoordinate.x,
lastInitPointCoordinate.y);
double direction = gc.getAzimuth();
double distanceInMeter = gc.getOrthodromicDistance();
long timeDifference = initPts[initPtsLength - 1].getTime()
.getTimeInMillis()
- initPts[initPtsLength - 2].getTime().getTimeInMillis();
double speed = distanceInMeter / (double) timeDifference;
trackElement.setDirectionForExtraPoints(direction);
trackElement.setSpeed(speed);
/*
* add something related to line drawing
*/
trackElement.setSizeScale((double) 1.0);
trackElement.setSmoothFactor(0);
trackElement.setClosed(false);
trackElement.setFilled(false);
trackElement.setFillPattern(FillPattern.FILL_PATTERN_0);
/*
* The following attributes are necessary to fill values for the
* pop-up TrackAttiDlg window from the restored line images.
*/
boolean setTimeButtonSelectedFlag = true; // set the default value
// as TRUE
if (trackBean.isSetTimeButtonSelected() != null)
setTimeButtonSelectedFlag = trackBean.isSetTimeButtonSelected()
.booleanValue();
trackElement.setSetTimeButtonSelected(setTimeButtonSelectedFlag);
int intervalComboSelectedIndexValue = 0; // set the default value
if (trackBean.getIntervalComboSelectedIndex() != null)
intervalComboSelectedIndexValue = trackBean
.getIntervalComboSelectedIndex().intValue();
trackElement
.setIntervalComboSelectedIndex(intervalComboSelectedIndexValue);
trackElement.setIntervalTimeString(trackBean
.getIntervalTimeTextString());
String extraPointTimeDisplayOptionName = ITrack.ExtraPointTimeDisplayOption.SKIP_FACTOR
.name(); // set the default value
if (trackBean.getExtraPointTimeDisplayOptionName() != null)
extraPointTimeDisplayOptionName = trackBean
.getExtraPointTimeDisplayOptionName();
trackElement
.setExtraPointTimeDisplayOption(ITrack.ExtraPointTimeDisplayOption
.valueOf(extraPointTimeDisplayOptionName));
String skipFactorTextString = "0"; // set the default value
if (trackBean.getSkipFactorTextString() != null)
skipFactorTextString = trackBean.getSkipFactorTextString();
trackElement.setSkipFactorTextString(skipFactorTextString);
int fontNameComboSelectedIndex = 0; // set the default value
if (trackBean.getFontNameComboSelectedIndex() != null)
fontNameComboSelectedIndex = trackBean
.getFontNameComboSelectedIndex().intValue();
trackElement
.setFontNameComboSelectedIndex(fontNameComboSelectedIndex);
int fontSizeComboSelectedIndex = 0; // set the default value
if (trackBean.getFontSizeComboSelectedIndex() != null)
fontSizeComboSelectedIndex = trackBean
.getFontSizeComboSelectedIndex().intValue();
trackElement
.setFontSizeComboSelectedIndex(fontSizeComboSelectedIndex);
trackElementList.add(trackElement);
}
return trackElementList;
}
public static gov.noaa.nws.ncep.ui.pgen.file.Track getTrackBeanByTrackElement(
public static gov.noaa.nws.ncep.ui.pgen.file.Track getTrackBeanByTrackElement(
Track trackElement) {
gov.noaa.nws.ncep.ui.pgen.file.Track trackBean = new gov.noaa.nws.ncep.ui.pgen.file.Track();
gov.noaa.nws.ncep.ui.pgen.file.Track trackBean = new gov.noaa.nws.ncep.ui.pgen.file.Track();
trackBean.setInitialColor(getColorTypeBeanByColorElement(trackElement.getInitialColor()));
trackBean.setExtrapColor(getColorTypeBeanByColorElement(trackElement.getExtrapColor()));
if(trackElement.getInitialPoints() != null) {
for(TrackPoint currentTrackPoint : trackElement.getInitialPoints()) {
trackBean.getInitialPoints().add(getTrackPointBeanByTrackPointElement(currentTrackPoint));
}
}
if(trackElement.getExtrapPoints() != null) {
for(TrackPoint currentTrackPoint : trackElement.getExtrapPoints()) {
trackBean.getExtrapPoints().add(getTrackPointBeanByTrackPointElement(currentTrackPoint));
}
}
trackBean.getExtraPointTimeTextDisplayIndicator().addAll(getBooleanObjectList(trackElement.getExtraPointTimeTextDisplayIndicator()));
trackBean.setInitialColor(getColorTypeBeanByColorElement(trackElement
.getInitialColor()));
trackBean.setExtrapColor(getColorTypeBeanByColorElement(trackElement
.getExtrapColor()));
trackBean.setInitialLinePattern(trackElement.getInitialLinePattern());
trackBean.setExtrapLinePattern(trackElement.getExtrapLinePattern());
trackBean.setInitialMarker(trackElement.getInitialMarker());
trackBean.setExtrapMarker(trackElement.getExtrapMarker());
trackBean.setFontName(trackElement.getFontName());
trackBean.setFontSize(new Float(trackElement.getFontSize()));
trackBean.setLineWidth(new Float(trackElement.getLineWidth()));
trackBean.setPgenCategory(trackElement.getPgenCategory());
trackBean.setPgenType(trackElement.getPgenType());
/*
* The following attributes are not necessary to save the line images
* and late to restore them back on the map. However, they are necessary
* values to pop-up and set up the correct attributes of the TrackAttrDlg
*/
trackBean.setSetTimeButtonSelected(new Boolean(trackElement.isSetTimeButtonSelected()));
trackBean.setIntervalComboSelectedIndex(new Integer(trackElement.getIntervalComboSelectedIndex()));
trackBean.setIntervalTimeTextString(trackElement.getIntervalTimeString());
trackBean.setExtraPointTimeDisplayOptionName(trackElement.getExtraPointTimeDisplayOption().name());
trackBean.setSkipFactorTextString(trackElement.getSkipFactorTextString());
trackBean.setFontNameComboSelectedIndex(new Integer(trackElement.getFontNameComboSelectedIndex()));
trackBean.setFontSizeComboSelectedIndex(new Integer(trackElement.getFontSizeComboSelectedIndex()));
trackBean.setFontStyleComboSelectedIndex(new Integer(trackElement.getFontStyleComboSelectedIndex()));
return trackBean;
if (trackElement.getInitialPoints() != null) {
for (TrackPoint currentTrackPoint : trackElement.getInitialPoints()) {
trackBean
.getInitialPoints()
.add(getTrackPointBeanByTrackPointElement(currentTrackPoint));
}
}
if (trackElement.getExtrapPoints() != null) {
for (TrackPoint currentTrackPoint : trackElement.getExtrapPoints()) {
trackBean
.getExtrapPoints()
.add(getTrackPointBeanByTrackPointElement(currentTrackPoint));
}
}
trackBean.getExtraPointTimeTextDisplayIndicator().addAll(
getBooleanObjectList(trackElement
.getExtraPointTimeTextDisplayIndicator()));
trackBean.setInitialLinePattern(trackElement.getInitialLinePattern());
trackBean.setExtrapLinePattern(trackElement.getExtrapLinePattern());
trackBean.setInitialMarker(trackElement.getInitialMarker());
trackBean.setExtrapMarker(trackElement.getExtrapMarker());
trackBean.setFontName(trackElement.getFontName());
// Font style
int styleInd = 0;
FontStyle dstyle = FontStyle.BOLD;
if (trackElement.getFontStyle() != null) {
int jj = 0;
for (FontStyle ft : FontStyle.values()) {
if (ft == trackElement.getFontStyle()) {
styleInd = jj;
dstyle = ft;
break;
}
jj++;
}
}
trackBean.setFontStyle(dstyle.toString());
trackBean.setFontStyleComboSelectedIndex(styleInd);
trackBean.setFontSize(new Float(trackElement.getFontSize()));
trackBean.setLineWidth(new Float(trackElement.getLineWidth()));
trackBean.setPgenCategory(trackElement.getPgenCategory());
trackBean.setPgenType(trackElement.getPgenType());
/*
* The following attributes are not necessary to save the line images
* and late to restore them back on the map. However, they are necessary
* values to pop-up and set up the correct attributes of the
* TrackAttrDlg
*/
trackBean.setSetTimeButtonSelected(new Boolean(trackElement
.isSetTimeButtonSelected()));
trackBean.setIntervalComboSelectedIndex(new Integer(trackElement
.getIntervalComboSelectedIndex()));
trackBean.setIntervalTimeTextString(trackElement
.getIntervalTimeString());
trackBean.setExtraPointTimeDisplayOptionName(trackElement
.getExtraPointTimeDisplayOption().name());
trackBean.setSkipFactorTextString(trackElement
.getSkipFactorTextString());
trackBean.setFontNameComboSelectedIndex(new Integer(trackElement
.getFontNameComboSelectedIndex()));
trackBean.setFontSizeComboSelectedIndex(new Integer(trackElement
.getFontSizeComboSelectedIndex()));
return trackBean;
}
/*
* help methods for transferring objects back and forth between class objects and JAXB beans
* help methods for transferring objects back and forth between class
* objects and JAXB beans
*/
private static Calendar getFirstOrSecondTimeCalendarByTrackBean(gov.noaa.nws.ncep.ui.pgen.file.Track trackBean, boolean isFirstTimeCalendar) {
int indexOffSet = 1;
if(isFirstTimeCalendar)
indexOffSet++;
List<TrackPoint> trackPointElementList = getTrackPointElementListByTrackPointBeanList(trackBean.getInitialPoints());
if(trackPointElementList == null || trackPointElementList.size() < 2) {
// log.error("Retrieved List<TrackPoint> trackPointElementList is NULL or the initial points are less than 2 points");
return null;
}
int listSize = trackPointElementList.size();
return trackPointElementList.get(listSize - indexOffSet).getTime();
}
private static java.awt.Color getColorByColorTypeBean(gov.noaa.nws.ncep.ui.pgen.file.ColorType colorTypeBean,
boolean isInitColor) {
if(colorTypeBean == null || colorTypeBean.getColor() == null) {
if(isInitColor)
return new Color(0, 0, 255); //return a default color as Blue
else
return new Color(0, 192, 0); //return a green color as the default color for extrapPoint
}
gov.noaa.nws.ncep.ui.pgen.file.Color colorBean = colorTypeBean.getColor();
return new Color(colorBean.getRed(), colorBean.getGreen(), colorBean.getBlue(),
colorBean.getAlpha());
}
private static List<TrackPoint> getTrackPointElementListByTrackPointBeanList(List<gov.noaa.nws.ncep.ui.pgen.file.TrackPoint> trackPointBeanList) {
List<TrackPoint> trackPointElementList = new ArrayList<TrackPoint>(trackPointBeanList.size());
for(gov.noaa.nws.ncep.ui.pgen.file.TrackPoint trackPointBean : trackPointBeanList) {
java.util.Calendar currentCalendar = null;
if(trackPointBean.getTime() != null) {
currentCalendar = trackPointBean.getTime().toGregorianCalendar();
}
Coordinate currentCoordinate = getCoordinateByTrackPointBean(trackPointBean);
TrackPoint currentTrackPointElement = new TrackPoint(currentCoordinate, currentCalendar);
trackPointElementList.add(currentTrackPointElement);
}
return trackPointElementList;
}
private static Coordinate getCoordinateByTrackPointBean(gov.noaa.nws.ncep.ui.pgen.file.TrackPoint trackPointBean) {
Coordinate coordinate = new Coordinate();
if(trackPointBean.getLocation() != null) {
coordinate.x = trackPointBean.getLocation().getLongitude();
coordinate.y = trackPointBean.getLocation().getLatitude();
}
return coordinate;
}
private static boolean[] getBooleanArrayByBooleanList(List<Boolean> booleanList) {
boolean[] booleanArray = new boolean[booleanList.size()];
int arrayIndex = 0;
for(Boolean currentBoolean : booleanList) {
booleanArray[arrayIndex++] = currentBoolean.booleanValue();
}
return booleanArray;
private static Calendar getFirstOrSecondTimeCalendarByTrackBean(
gov.noaa.nws.ncep.ui.pgen.file.Track trackBean,
boolean isFirstTimeCalendar) {
int indexOffSet = 1;
if (isFirstTimeCalendar)
indexOffSet++;
List<TrackPoint> trackPointElementList = getTrackPointElementListByTrackPointBeanList(trackBean
.getInitialPoints());
if (trackPointElementList == null || trackPointElementList.size() < 2) {
// log.error("Retrieved List<TrackPoint> trackPointElementList is NULL or the initial points are less than 2 points");
return null;
}
int listSize = trackPointElementList.size();
return trackPointElementList.get(listSize - indexOffSet).getTime();
}
private static gov.noaa.nws.ncep.ui.pgen.file.ColorType getColorTypeBeanByColorElement(java.awt.Color colorElement) {
gov.noaa.nws.ncep.ui.pgen.file.ColorType colorTypeBean = new gov.noaa.nws.ncep.ui.pgen.file.ColorType();
gov.noaa.nws.ncep.ui.pgen.file.Color colorBean = new gov.noaa.nws.ncep.ui.pgen.file.Color();
colorBean.setAlpha(colorElement.getAlpha());
colorBean.setBlue(colorElement.getBlue());
colorBean.setRed(colorElement.getRed());
colorBean.setGreen(colorElement.getGreen());
colorTypeBean.setColor(colorBean);
return colorTypeBean;
private static java.awt.Color getColorByColorTypeBean(
gov.noaa.nws.ncep.ui.pgen.file.ColorType colorTypeBean,
boolean isInitColor) {
if (colorTypeBean == null || colorTypeBean.getColor() == null) {
if (isInitColor)
return new Color(0, 0, 255); // return a default color as Blue
else
return new Color(0, 192, 0); // return a green color as the
// default color for extrapPoint
}
gov.noaa.nws.ncep.ui.pgen.file.Color colorBean = colorTypeBean
.getColor();
return new Color(colorBean.getRed(), colorBean.getGreen(),
colorBean.getBlue(), colorBean.getAlpha());
}
private static gov.noaa.nws.ncep.ui.pgen.file.TrackPoint getTrackPointBeanByTrackPointElement(TrackPoint trackPointElement) {
gov.noaa.nws.ncep.ui.pgen.file.TrackPoint trackPointBean = new gov.noaa.nws.ncep.ui.pgen.file.TrackPoint();
if(trackPointElement.getTime() != null) {
GregorianCalendar gregorianCalendar = new GregorianCalendar();
gregorianCalendar.setTimeInMillis(trackPointElement.getTime().getTimeInMillis());
try {
XMLGregorianCalendar xmlGregorianCalendar = DatatypeFactory.newInstance().newXMLGregorianCalendar(gregorianCalendar);
trackPointBean.setTime(xmlGregorianCalendar);
} catch(DatatypeConfigurationException dce) {
// log.error("Error, instantiating XMLGregorianCalendar failed, error="+dce.getMessage());
}
}
if(trackPointElement.getLocation() != null) {
trackPointBean.location = new gov.noaa.nws.ncep.ui.pgen.file.TrackPoint.Location();
trackPointBean.getLocation().setLongitude(trackPointElement.getLocation().x);
trackPointBean.getLocation().setLatitude(trackPointElement.getLocation().y);
}
return trackPointBean;
private static List<TrackPoint> getTrackPointElementListByTrackPointBeanList(
List<gov.noaa.nws.ncep.ui.pgen.file.TrackPoint> trackPointBeanList) {
List<TrackPoint> trackPointElementList = new ArrayList<TrackPoint>(
trackPointBeanList.size());
for (gov.noaa.nws.ncep.ui.pgen.file.TrackPoint trackPointBean : trackPointBeanList) {
java.util.Calendar currentCalendar = null;
if (trackPointBean.getTime() != null) {
currentCalendar = trackPointBean.getTime()
.toGregorianCalendar();
}
Coordinate currentCoordinate = getCoordinateByTrackPointBean(trackPointBean);
TrackPoint currentTrackPointElement = new TrackPoint(
currentCoordinate, currentCalendar);
trackPointElementList.add(currentTrackPointElement);
}
return trackPointElementList;
}
private static Coordinate getCoordinateByTrackPointBean(
gov.noaa.nws.ncep.ui.pgen.file.TrackPoint trackPointBean) {
Coordinate coordinate = new Coordinate();
if (trackPointBean.getLocation() != null) {
coordinate.x = trackPointBean.getLocation().getLongitude();
coordinate.y = trackPointBean.getLocation().getLatitude();
}
return coordinate;
}
private static boolean[] getBooleanArrayByBooleanList(
List<Boolean> booleanList) {
boolean[] booleanArray = new boolean[booleanList.size()];
int arrayIndex = 0;
for (Boolean currentBoolean : booleanList) {
booleanArray[arrayIndex++] = currentBoolean.booleanValue();
}
return booleanArray;
}
private static gov.noaa.nws.ncep.ui.pgen.file.ColorType getColorTypeBeanByColorElement(
java.awt.Color colorElement) {
gov.noaa.nws.ncep.ui.pgen.file.ColorType colorTypeBean = new gov.noaa.nws.ncep.ui.pgen.file.ColorType();
gov.noaa.nws.ncep.ui.pgen.file.Color colorBean = new gov.noaa.nws.ncep.ui.pgen.file.Color();
colorBean.setAlpha(colorElement.getAlpha());
colorBean.setBlue(colorElement.getBlue());
colorBean.setRed(colorElement.getRed());
colorBean.setGreen(colorElement.getGreen());
colorTypeBean.setColor(colorBean);
return colorTypeBean;
}
private static gov.noaa.nws.ncep.ui.pgen.file.TrackPoint getTrackPointBeanByTrackPointElement(
TrackPoint trackPointElement) {
gov.noaa.nws.ncep.ui.pgen.file.TrackPoint trackPointBean = new gov.noaa.nws.ncep.ui.pgen.file.TrackPoint();
if (trackPointElement.getTime() != null) {
GregorianCalendar gregorianCalendar = new GregorianCalendar();
gregorianCalendar.setTimeInMillis(trackPointElement.getTime()
.getTimeInMillis());
try {
XMLGregorianCalendar xmlGregorianCalendar = DatatypeFactory
.newInstance().newXMLGregorianCalendar(
gregorianCalendar);
trackPointBean.setTime(xmlGregorianCalendar);
} catch (DatatypeConfigurationException dce) {
// log.error("Error, instantiating XMLGregorianCalendar failed, error="+dce.getMessage());
}
}
if (trackPointElement.getLocation() != null) {
trackPointBean.location = new gov.noaa.nws.ncep.ui.pgen.file.TrackPoint.Location();
trackPointBean.getLocation().setLongitude(
trackPointElement.getLocation().x);
trackPointBean.getLocation().setLatitude(
trackPointElement.getLocation().y);
}
return trackPointBean;
}
private static List<Boolean> getBooleanObjectList(boolean[] booleanArray) {
List<Boolean> booleanList = null;
if(booleanArray == null)
booleanList = new ArrayList<Boolean>();
else
booleanList = new ArrayList<Boolean>(booleanArray.length);
for(boolean booleanValue : booleanArray) {
Boolean booleanObject = new Boolean(booleanValue);
booleanList.add(booleanObject);
}
return booleanList;
List<Boolean> booleanList = null;
if (booleanArray == null)
booleanList = new ArrayList<Boolean>();
else
booleanList = new ArrayList<Boolean>(booleanArray.length);
for (boolean booleanValue : booleanArray) {
Boolean booleanObject = new Boolean(booleanValue);
booleanList.add(booleanObject);
}
return booleanList;
}
}
}

View file

@ -411,27 +411,52 @@
<xsd:sequence>
<xsd:element name="initialColor" type="ColorType"></xsd:element>
<xsd:element name="extrapColor" type="ColorType"></xsd:element>
<xsd:element name="initialPoints" type="TrackPoint" maxOccurs="unbounded" minOccurs="1"></xsd:element>
<xsd:element name="extrapPoints" type="TrackPoint" maxOccurs="unbounded" minOccurs="1"></xsd:element>
<xsd:element name="extraPointTimeTextDisplayIndicator" type="xsd:boolean" maxOccurs="unbounded" minOccurs="1"></xsd:element>
<xsd:element name="initialPoints" type="TrackPoint"
maxOccurs="unbounded" minOccurs="1">
</xsd:element>
<xsd:element name="extrapPoints" type="TrackPoint"
maxOccurs="unbounded" minOccurs="1">
</xsd:element>
<xsd:element name="extraPointTimeTextDisplayIndicator"
type="xsd:boolean" maxOccurs="unbounded" minOccurs="1">
</xsd:element>
</xsd:sequence>
<xsd:attribute name="initialLinePattern" type="xsd:string"></xsd:attribute>
<xsd:attribute name="initialLinePattern"
type="xsd:string">
</xsd:attribute>
<xsd:attribute name="extrapLinePattern" type="xsd:string"></xsd:attribute>
<xsd:attribute name="initialMarker" type="xsd:string"></xsd:attribute>
<xsd:attribute name="extrapMarker" type="xsd:string"></xsd:attribute>
<xsd:attribute name="lineWidth" type="xsd:float"></xsd:attribute>
<xsd:attribute name="fontName" type="xsd:string"></xsd:attribute>
<xsd:attribute name="fontStyle" type="xsd:string"></xsd:attribute>
<xsd:attribute name="fontSize" type="xsd:float"></xsd:attribute>
<xsd:attribute name="pgenType" type="xsd:string"></xsd:attribute>
<xsd:attribute name="pgenCategory" type="xsd:string"></xsd:attribute>
<xsd:attribute name="setTimeButtonSelected" type="xsd:boolean"></xsd:attribute>
<xsd:attribute name="intervalComboSelectedIndex" type="xsd:int"></xsd:attribute>
<xsd:attribute name="intervalTimeTextString" type="xsd:string"></xsd:attribute>
<xsd:attribute name="extraPointTimeDisplayOptionName" type="xsd:string"></xsd:attribute>
<xsd:attribute name="skipFactorTextString" type="xsd:string"></xsd:attribute>
<xsd:attribute name="fontNameComboSelectedIndex" type="xsd:int"></xsd:attribute>
<xsd:attribute name="fontSizeComboSelectedIndex" type="xsd:int"></xsd:attribute>
<xsd:attribute name="fontStyleComboSelectedIndex" type="xsd:int"></xsd:attribute>
<xsd:attribute name="setTimeButtonSelected"
type="xsd:boolean">
</xsd:attribute>
<xsd:attribute name="intervalComboSelectedIndex"
type="xsd:int">
</xsd:attribute>
<xsd:attribute name="intervalTimeTextString"
type="xsd:string">
</xsd:attribute>
<xsd:attribute name="extraPointTimeDisplayOptionName"
type="xsd:string">
</xsd:attribute>
<xsd:attribute name="skipFactorTextString"
type="xsd:string">
</xsd:attribute>
<xsd:attribute name="fontNameComboSelectedIndex"
type="xsd:int">
</xsd:attribute>
<xsd:attribute name="fontSizeComboSelectedIndex"
type="xsd:int">
</xsd:attribute>
<xsd:attribute name="fontStyleComboSelectedIndex"
type="xsd:int">
</xsd:attribute>
</xsd:complexType>
</xsd:element>

View file

@ -14,10 +14,10 @@ import gov.noaa.nws.ncep.ui.pgen.elements.Product;
import gov.noaa.nws.ncep.ui.pgen.file.FileTools;
import gov.noaa.nws.ncep.ui.pgen.file.ProductConverter;
import gov.noaa.nws.ncep.ui.pgen.file.Products;
import gov.noaa.nws.ncep.ui.pgen.rsc.PgenResource;
import gov.noaa.nws.ncep.ui.pgen.store.PgenStorageException;
import gov.noaa.nws.ncep.ui.pgen.store.StorageUtils;
import gov.noaa.nws.ncep.ui.pgen.tools.PgenCycleTool;
import gov.noaa.nws.ncep.ui.pgen.rsc.PgenResource;
import java.io.File;
import java.io.IOException;
@ -61,6 +61,7 @@ import com.vividsolutions.jts.geom.GeometryFactory;
* 05/13 #610 J. Wu Implemented FZLVL range (TTR425)
* 07/13 ? J. Wu Move state list ordering to GfaRules.
* 08/13 TTR714/715 J. Wu Fixed issue type and times.
* 10/14 TTR714 J. Wu Check issue type in get_status.xml.
*
* </pre>
*
@ -70,7 +71,9 @@ import com.vividsolutions.jts.geom.GeometryFactory;
public class GfaGenerate {
private static final String TEXT_TYPE = "TEXT";
private GeometryFactory gf = new GeometryFactory();
private GeometryFactory gf = new GeometryFactory();
private static final String ISSUE_TYPE_FROM_OUTLOOK = "ISSUE_TYPE_FROM_OUTLOOK";
// private final static Logger logger = Logger.getLogger(GfaGenerate.class);
@ -109,20 +112,22 @@ public class GfaGenerate {
/*
* Create an additional smear for the adjacent area.
*/
for ( Gfa g : all) {
Gfa sg = createAdjacentGfa( g );
for (Gfa g : all) {
Gfa sg = createAdjacentGfa(g);
adjusted.add( g );
adjusted.add(g);
if ( sg != null ) {
adjusted.add( sg );
if (sg != null) {
adjusted.add(sg);
}
}
/*
* Find issue type for an Airmet's associated Outlook
* Find issue type for an Airmet's associated Outlook. Note: TTR 714 -
* J. Wu: this may cause other issues. Instead, we should check the
* issue types in "get_status.xsl".
*/
trackOtlkIssueTypeToAirmet( adjusted );
// trackOtlkIssueTypeToAirmet(adjusted);
/*
* Find GFA smears in each area and hazard category, generate xml, and
@ -130,14 +135,14 @@ public class GfaGenerate {
*/
for (String category : categories) {
for (String area : areas) {
List<Gfa> ret = filterSelected( adjusted, area, category );
List<Gfa> ret = filterSelected(adjusted, area, category);
// If no issue/until times, assign them.
for (Gfa de : ret) {
if (!de.isSnapshot()
&& de.getAttribute(Gfa.ISSUE_TIME) == null) {
GfaRules.assignIssueTime( de );
GfaRules.assignIssueTime(de);
}
}
@ -154,24 +159,25 @@ public class GfaGenerate {
/*
* Find freezing range for this area!
*/
String fzlvlRange = findFreezingRange( all, ret, area, category );
String fzlvlRange = findFreezingRange(all, ret, area, category);
/*
* Note - needs to use a copy so it won't change the parent of
* the original G-Airmets, e.g. l.add( de ) will set the parent
* of the 'de" to be "l"!
*/
for ( Gfa gss : ret) {
Gfa gfaCopy = gss.copy();
String otlkIssueType = nvl( gfaCopy.getGfaValue( ISSUE_TYPE_FROM_OUTLOOK ) );
if ( !otlkIssueType.equals( "NRML" ) ) {
gfaCopy.setGfaIssueType( otlkIssueType );
}
if ( fzlvlRange != null ) {
gfaCopy.setGfaValue( Gfa.FZL_RANGE, fzlvlRange );
}
l.add( gfaCopy );
for (Gfa gss : ret) {
Gfa gfaCopy = gss.copy();
/*
* String otlkIssueType = nvl(gfaCopy
* .getGfaValue(ISSUE_TYPE_FROM_OUTLOOK)); if
* (!otlkIssueType.equals("NRML")) {
* gfaCopy.setGfaIssueType( otlkIssueType ); }
*/
if (fzlvlRange != null) {
gfaCopy.setGfaValue(Gfa.FZL_RANGE, fzlvlRange);
}
l.add(gfaCopy);
}
// l.add( ret );
@ -183,7 +189,7 @@ public class GfaGenerate {
// Needs to add an empty Gfa to carry the issue/until for proper
// formatting.
if (ret.size() == 0) {
addNullGfa( products, category, fzlvlRange );
addNullGfa(products, category, fzlvlRange);
}
String xml = SerializationUtil.marshalToXml(products);
@ -191,7 +197,7 @@ public class GfaGenerate {
if (sb.length() > 0 && !sb.toString().endsWith("\n\n")) {
sb.append("\n\n");
}
String prdXml = generateProduct(xml, category, area).trim();
temp.append(prdXml);
@ -233,7 +239,8 @@ public class GfaGenerate {
* @param cats
* @return
*/
private static List<Gfa> filterSelected( List<Gfa> all, String area, String category) {
private static List<Gfa> filterSelected(List<Gfa> all, String area,
String category) {
ArrayList<Gfa> ret = new ArrayList<Gfa>();
@ -258,6 +265,7 @@ public class GfaGenerate {
}
public String generateProduct(String prdxml, String category, String area) {
System.out.println("\nprdxml is:\n" + prdxml + "\n");
String xml1 = prdxml.replaceAll("TURB-HI", "TURB");
String xml = xml1.replaceAll("TURB-LO", "TURB");
@ -279,6 +287,7 @@ public class GfaGenerate {
transformer.transform(xmlSource, result);
res = result.getWriter().toString().trim();
System.out.println("\nres is:\n" + res + "\n");
} catch (Exception e) {
// logger.error( "", e );
@ -295,11 +304,13 @@ public class GfaGenerate {
}
/**
* Create a new smear for smears with two FA areas and re-order the state list.
* Create a new smear for smears with two FA areas and re-order the state
* list.
*
* The States in the primary area precede states in the adjacent area.
* The States in the primary area precede states in the adjacent area.
*
* @param g Gfa to be processed
* @param g
* Gfa to be processed
*
* @return
*/
@ -310,12 +321,12 @@ public class GfaGenerate {
String[] s = nvl(g.getGfaArea()).split("-");
if (s.length > 1) {
String sname = new String( s[1].trim() + "-" + s[0].trim() );
String sname = new String(s[1].trim() + "-" + s[0].trim());
// create an additional smear and re-order state list.
secondg = g.copy();
secondg.setGfaArea( sname );
GfaRules.reorderStateList( secondg );
secondg = g.copy();
secondg.setGfaArea(sname);
GfaRules.reorderStateList(secondg);
}
return secondg;
@ -362,12 +373,12 @@ public class GfaGenerate {
/*
* Adds an empty Gfa to the product so it can pass issue/until time for
* correct formatting. Freezing range should be set if provided.
* correct formatting. Freezing range should be set if provided.
*
* Note - this should be called only when there is no Gfa smears in the
* "prds".
*/
private void addNullGfa(Products prds, String category, String fzlRange ) {
private void addNullGfa(Products prds, String category, String fzlRange) {
gov.noaa.nws.ncep.ui.pgen.file.Gfa fgfa = new gov.noaa.nws.ncep.ui.pgen.file.Gfa();
@ -380,9 +391,9 @@ public class GfaGenerate {
fgfa.setFcstHr("0-6");
// If freezing range is provided, set it and set hazard type as "FZLVL".
if ( fzlRange != null ) {
fgfa.setHazard( "FZLVL" );
fgfa.setFzlRange( fzlRange );
if (fzlRange != null) {
fgfa.setHazard("FZLVL");
fgfa.setFzlRange(fzlRange);
}
//
@ -429,398 +440,395 @@ public class GfaGenerate {
}
/*
* Find the freezing range from FZLVL/M_FZLVL airmets.
* Find the freezing range from FZLVL/M_FZLVL airmets.
*/
private String findFreezingRange( List<Gfa> all, List<Gfa> selected,
String area, String cat ) {
if ( !cat.equalsIgnoreCase( "ZULU" ) ) {
return null;
}
String fzlRange = null;
String topStr = null;
String botStr = null;
/*
* If no FZLVL/M_FZLVL in this area, find range using those outside of
* this area, if any.
*/
if ( selected == null || selected.size() == 0 ) {
int[] extRange = findExernalFzlvlRange( all, area );
if ( extRange[0] != -1 ) {
topStr = padding( extRange[0] );
botStr = padding( extRange[1] );
}
}
else {
/*
* First - find the worst range from existing FZL_RANGE in FZLVL airmets.
* If no existing range found, then find the worst top/bottom from
* FZLVLs' levels ( top = level + 40 and bottom = level - 40)
* Second - find the worst top/bottom from M_FZLVLs
*
* Third - find the worst case range using info from step 1 and 2.
*
*/
int[] existingRange = findExistingFzlRange( all, selected, area );
int[] mfzlRange = findMfzlvlRange( all, selected, area );
private String findFreezingRange(List<Gfa> all, List<Gfa> selected,
String area, String cat) {
if ( existingRange[0] == -1 ) {
existingRange = findFzlvlLevelRange( all, selected, area );
}
if (!cat.equalsIgnoreCase("ZULU")) {
return null;
}
if ( existingRange[0] != -1 || mfzlRange[0] != -1 ) {
topStr = padding( Math.max( existingRange[0], mfzlRange[0] ) );
}
String fzlRange = null;
String topStr = null;
String botStr = null;
if ( existingRange[1] != 9999 || mfzlRange[1] != 9999 ){
botStr = padding( Math.min( existingRange[1], mfzlRange[1] ) );
}
}
// Now create a range string.
if ( topStr != null && botStr != null ) {
fzlRange = area + ";" + topStr + ";" + botStr;
}
return fzlRange;
}
/*
* Retrieve the worst FZLVL range from ranges existing in FZLVL airmet/outlook.
* Such existing range should be in the form as "MIA;160;40", retrievable as
* gfa.getGfaValue( Gfa.FZL_RANGE ).
*/
private int[] findExistingFzlRange( List<Gfa> all, List<Gfa> selected, String area ) {
int[] topBot = { -1, 9999 };
for ( Gfa elem : selected ) {
String gtype = elem.getGfaHazard();
if ( !gtype.equalsIgnoreCase("FZLVL") || elem.isSnapshot() ) {
continue;
}
String range1 = elem.getGfaValue( Gfa.FZL_RANGE );
if ( range1 != null ) {
String[] rangeInfo = range1.split(";");
if ( rangeInfo.length >= 3 && rangeInfo[0].equalsIgnoreCase( area ) ) {
int top1 = -1;
int bot1 = -1;
try {
top1 = Integer.parseInt( rangeInfo[1] );
}
catch ( Exception e ) {
e.printStackTrace();
}
if ( rangeInfo[2].equalsIgnoreCase("SFC") ) {
bot1 = 0;
}
else {
try {
bot1 = Integer.parseInt( rangeInfo[2] );
}
catch ( Exception e ) {
e.printStackTrace();
}
}
if ( top1 >= 0 && bot1 >= 0 ) {
topBot[0] = Math.max( topBot[0], top1 );
topBot[1] = Math.min( topBot[1], bot1 );
}
}
}
}
return topBot;
}
/*
* Retrieve the worst range from existing top/bottom of M_FZLVL airmet/outlook.
* Such top/bottom are retrievable as gfa.getGfaTop() & gfa.getGfaBottom().
*/
private int[] findMfzlvlRange( List<Gfa> all, List<Gfa> selected, String area ) {
int[] topBot = { -1, 9999 };
for ( Gfa elem : selected ) {
String gtype = elem.getGfaHazard();
if ( !gtype.equalsIgnoreCase("M_FZLVL") || elem.isSnapshot() ) {
continue;
}
int top2 = -1;
int bot2 = -1;
if ( elem.getGfaTop() != null ) {
try {
top2 = Integer.parseInt( elem.getGfaTop() );
}
catch ( Exception e ) {
e.printStackTrace();
}
}
String botStr = elem.getGfaBottom();
if ( botStr != null ) {
if ( botStr.equalsIgnoreCase( "SFC") ) {
bot2 = 0;
}
else {
try {
bot2 = Integer.parseInt( elem.getGfaBottom() );
}
catch ( Exception e ) {
e.printStackTrace();
}
}
}
if ( top2 >= 0 && bot2 >= 0 ) {
topBot[0] = Math.max( topBot[0], top2 );
topBot[1] = Math.min( topBot[1], bot2 );
}
}
return topBot;
}
/*
* Retrieve the worst range from existing levels of FZLVL airmet/outlook.
* Such levels are retrievable as gfa.getGfaValue( Gfa.LEVEL ).
*/
private int[] findFzlvlLevelRange( List<Gfa> all, List<Gfa> selected, String area ) {
int[] topBot = { -1, 9999 };
for ( Gfa elem : selected ) {
String gtype = elem.getGfaHazard();
if ( !gtype.equalsIgnoreCase("FZLVL") || elem.isSnapshot() ) {
continue;
}
int top2 = -1;
int bot2 = -1;
String levelStr = elem.getGfaValue( Gfa.LEVEL );
int lvl = -1;
if ( levelStr != null ) {
if ( levelStr.equalsIgnoreCase( "SFC" ) ) {
top2 = 40;
bot2 = 0;
}
else {
try {
lvl = Integer.parseInt( levelStr );
}
catch ( Exception e ) {
e.printStackTrace();
}
if ( lvl >= 0 && lvl <= 40 ) {
top2 = 40;
bot2 = 0;
}
else {
top2 = lvl + 40;
bot2 = lvl - 40;
}
}
}
if ( top2 >= 0 && bot2 >= 0 ) {
topBot[0] = Math.max( topBot[0], top2 );
topBot[1] = Math.min( topBot[1], bot2 );
}
}
return topBot;
}
/*
* Find the top and base levels for a FA area that is not intersected by any FZLVL
* contours. It sorts all external fzlvls by distance from the area centroid, then
* uses the level from that contour. If the contour is to the left of the area then
* the answer is base = contour level, top = base + 040. If the contour is to the
* right of the area then the answer top = contour level, base = top - 040.
*
* See legacy af_getExternalFzlvlRng() in af_getAirmetXml.c.
*
* Note (1) only FZLVLs are used, not M_FZLVLs.
* (2) All FZLVLs are used, including snapshots.
*
*/
private int[] findExernalFzlvlRange( List<Gfa> all, String area ) {
int[] topBot = { -1, 9999 };
HashMap<String, Geometry> areaBnds = GfaClip.getInstance().getFaAreaBounds();
Coordinate center = gf.createLinearRing( areaBnds.get(area ).getCoordinates() ).getCentroid().getCoordinate();
Gfa closestGfa = null;
double minDist = Double.MAX_VALUE;
for ( Gfa elem : all ) {
String gtype = elem.getGfaHazard();
if ( !gtype.equalsIgnoreCase("FZLVL") ) {
continue;
}
// Find distance from the FA Area's centroid to this FZLVL.
double dist = distance( elem, center );
if ( dist < minDist ) {
minDist = dist;
closestGfa = elem;
/*
* If no FZLVL/M_FZLVL in this area, find range using those outside of
* this area, if any.
*/
if (selected == null || selected.size() == 0) {
int[] extRange = findExernalFzlvlRange(all, area);
if (extRange[0] != -1) {
topStr = padding(extRange[0]);
botStr = padding(extRange[1]);
}
}
if ( closestGfa != null ) {
boolean isLeft = GfaSnap.getInstance().atLeft( center, closestGfa.getLinePoints(),
closestGfa.isClosedLine(), 0.0 );
String levelStr = closestGfa.getGfaValue( Gfa.LEVEL );
int lvl = -1;
if ( levelStr != null ) {
if ( levelStr.equalsIgnoreCase( "SFC" ) ) {
} else {
/*
* First - find the worst range from existing FZL_RANGE in FZLVL
* airmets. If no existing range found, then find the worst
* top/bottom from FZLVLs' levels ( top = level + 40 and bottom =
* level - 40) Second - find the worst top/bottom from M_FZLVLs
*
* Third - find the worst case range using info from step 1 and 2.
*/
int[] existingRange = findExistingFzlRange(all, selected, area);
int[] mfzlRange = findMfzlvlRange(all, selected, area);
if (existingRange[0] == -1) {
existingRange = findFzlvlLevelRange(all, selected, area);
}
if (existingRange[0] != -1 || mfzlRange[0] != -1) {
topStr = padding(Math.max(existingRange[0], mfzlRange[0]));
}
if (existingRange[1] != 9999 || mfzlRange[1] != 9999) {
botStr = padding(Math.min(existingRange[1], mfzlRange[1]));
}
}
// Now create a range string.
if (topStr != null && botStr != null) {
fzlRange = area + ";" + topStr + ";" + botStr;
}
return fzlRange;
}
/*
* Retrieve the worst FZLVL range from ranges existing in FZLVL
* airmet/outlook. Such existing range should be in the form as
* "MIA;160;40", retrievable as gfa.getGfaValue( Gfa.FZL_RANGE ).
*/
private int[] findExistingFzlRange(List<Gfa> all, List<Gfa> selected,
String area) {
int[] topBot = { -1, 9999 };
for (Gfa elem : selected) {
String gtype = elem.getGfaHazard();
if (!gtype.equalsIgnoreCase("FZLVL") || elem.isSnapshot()) {
continue;
}
String range1 = elem.getGfaValue(Gfa.FZL_RANGE);
if (range1 != null) {
String[] rangeInfo = range1.split(";");
if (rangeInfo.length >= 3
&& rangeInfo[0].equalsIgnoreCase(area)) {
int top1 = -1;
int bot1 = -1;
try {
top1 = Integer.parseInt(rangeInfo[1]);
} catch (Exception e) {
e.printStackTrace();
}
if (rangeInfo[2].equalsIgnoreCase("SFC")) {
bot1 = 0;
} else {
try {
bot1 = Integer.parseInt(rangeInfo[2]);
} catch (Exception e) {
e.printStackTrace();
}
}
if (top1 >= 0 && bot1 >= 0) {
topBot[0] = Math.max(topBot[0], top1);
topBot[1] = Math.min(topBot[1], bot1);
}
}
}
}
return topBot;
}
/*
* Retrieve the worst range from existing top/bottom of M_FZLVL
* airmet/outlook. Such top/bottom are retrievable as gfa.getGfaTop() &
* gfa.getGfaBottom().
*/
private int[] findMfzlvlRange(List<Gfa> all, List<Gfa> selected, String area) {
int[] topBot = { -1, 9999 };
for (Gfa elem : selected) {
String gtype = elem.getGfaHazard();
if (!gtype.equalsIgnoreCase("M_FZLVL") || elem.isSnapshot()) {
continue;
}
int top2 = -1;
int bot2 = -1;
if (elem.getGfaTop() != null) {
try {
top2 = Integer.parseInt(elem.getGfaTop());
} catch (Exception e) {
e.printStackTrace();
}
}
String botStr = elem.getGfaBottom();
if (botStr != null) {
if (botStr.equalsIgnoreCase("SFC")) {
bot2 = 0;
} else {
try {
bot2 = Integer.parseInt(elem.getGfaBottom());
} catch (Exception e) {
e.printStackTrace();
}
}
}
if (top2 >= 0 && bot2 >= 0) {
topBot[0] = Math.max(topBot[0], top2);
topBot[1] = Math.min(topBot[1], bot2);
}
}
return topBot;
}
/*
* Retrieve the worst range from existing levels of FZLVL airmet/outlook.
* Such levels are retrievable as gfa.getGfaValue( Gfa.LEVEL ).
*/
private int[] findFzlvlLevelRange(List<Gfa> all, List<Gfa> selected,
String area) {
int[] topBot = { -1, 9999 };
for (Gfa elem : selected) {
String gtype = elem.getGfaHazard();
if (!gtype.equalsIgnoreCase("FZLVL") || elem.isSnapshot()) {
continue;
}
int top2 = -1;
int bot2 = -1;
String levelStr = elem.getGfaValue(Gfa.LEVEL);
int lvl = -1;
if (levelStr != null) {
if (levelStr.equalsIgnoreCase("SFC")) {
top2 = 40;
bot2 = 0;
} else {
try {
lvl = Integer.parseInt(levelStr);
} catch (Exception e) {
e.printStackTrace();
}
if (lvl >= 0 && lvl <= 40) {
top2 = 40;
bot2 = 0;
} else {
top2 = lvl + 40;
bot2 = lvl - 40;
}
}
}
if (top2 >= 0 && bot2 >= 0) {
topBot[0] = Math.max(topBot[0], top2);
topBot[1] = Math.min(topBot[1], bot2);
}
}
return topBot;
}
/*
* Find the top and base levels for a FA area that is not intersected by any
* FZLVL contours. It sorts all external fzlvls by distance from the area
* centroid, then uses the level from that contour. If the contour is to the
* left of the area then the answer is base = contour level, top = base +
* 040. If the contour is to the right of the area then the answer top =
* contour level, base = top - 040.
*
* See legacy af_getExternalFzlvlRng() in af_getAirmetXml.c.
*
* Note (1) only FZLVLs are used, not M_FZLVLs. (2) All FZLVLs are used,
* including snapshots.
*/
private int[] findExernalFzlvlRange(List<Gfa> all, String area) {
int[] topBot = { -1, 9999 };
HashMap<String, Geometry> areaBnds = GfaClip.getInstance()
.getFaAreaBounds();
Coordinate center = gf
.createLinearRing(areaBnds.get(area).getCoordinates())
.getCentroid().getCoordinate();
Gfa closestGfa = null;
double minDist = Double.MAX_VALUE;
for (Gfa elem : all) {
String gtype = elem.getGfaHazard();
if (!gtype.equalsIgnoreCase("FZLVL")) {
continue;
}
// Find distance from the FA Area's centroid to this FZLVL.
double dist = distance(elem, center);
if (dist < minDist) {
minDist = dist;
closestGfa = elem;
}
}
if (closestGfa != null) {
boolean isLeft = GfaSnap.getInstance().atLeft(center,
closestGfa.getLinePoints(), closestGfa.isClosedLine(), 0.0);
String levelStr = closestGfa.getGfaValue(Gfa.LEVEL);
int lvl = -1;
if (levelStr != null) {
if (levelStr.equalsIgnoreCase("SFC")) {
lvl = 0;
}
else {
try {
lvl = Integer.parseInt( levelStr );
}
catch ( Exception e ) {
e.printStackTrace();
}
}
}
if ( lvl >= 0 ) {
if ( !isLeft ) { // FZLVL is at right of FA area
topBot[0] = lvl + 40;
topBot[1] = lvl;
}
else { // FZLVL is at left of FA area
topBot[0] = lvl;
topBot[1] = lvl - 40;
if ( topBot[1] < 0 ) topBot[1] = 0;
}
}
}
return topBot;
} else {
try {
lvl = Integer.parseInt(levelStr);
} catch (Exception e) {
e.printStackTrace();
}
}
}
if (lvl >= 0) {
if (!isLeft) { // FZLVL is at right of FA area
topBot[0] = lvl + 40;
topBot[1] = lvl;
} else { // FZLVL is at left of FA area
topBot[0] = lvl;
topBot[1] = lvl - 40;
if (topBot[1] < 0)
topBot[1] = 0;
}
}
}
return topBot;
}
/*
* Pad a value between 0 to 100 in format of "0xx".
*/
private String padding( int value ) {
StringBuilder str = new StringBuilder();
if ( value <= 0 ) {
str.append( "SFC" );
}
else {
if ( value < 100 ) {
str.append( "0" + value );
}
else {
str.append( value );
}
}
return str.toString();
* Pad a value between 0 to 100 in format of "0xx".
*/
private String padding(int value) {
StringBuilder str = new StringBuilder();
if (value <= 0) {
str.append("SFC");
} else {
if (value < 100) {
str.append("0" + value);
} else {
str.append(value);
}
}
return str.toString();
}
/*
* Find the distance from a given point to a Gfa line or polygon.
*/
private double distance( Gfa gfa, Coordinate loc ) {
* Find the distance from a given point to a Gfa line or polygon.
*/
private double distance(Gfa gfa, Coordinate loc) {
double dist = Double.MAX_VALUE;
double minDist = Double.MAX_VALUE;
Object pts[] = gfa.getPoints().toArray();
for ( int ii = 0; ii < pts.length; ii++ ) {
for (int ii = 0; ii < pts.length; ii++) {
if ( ii == pts.length - 1 ) {
if ( gfa.isClosedLine() ) {
dist = PgenResource.distanceFromLineSegment( loc,
if (ii == pts.length - 1) {
if (gfa.isClosedLine()) {
dist = PgenResource.distanceFromLineSegment(loc,
(Coordinate) pts[ii], (Coordinate) pts[0]);
}
else {
} else {
break;
}
}
else {
dist = PgenResource.distanceFromLineSegment( loc, (Coordinate) pts[ii],
(Coordinate) pts[ii + 1]);
} else {
dist = PgenResource.distanceFromLineSegment(loc,
(Coordinate) pts[ii], (Coordinate) pts[ii + 1]);
}
if ( dist < minDist ) {
if (dist < minDist) {
minDist = dist;
}
}
return minDist;
}
}
return minDist;
}
/**
* Find if a smear has an associated outlook that are generated from the same series of
* snapshots (with same hazard type, tag and desk.
* Find if a smear has an associated outlook that are generated from the
* same series of snapshots (with same hazard type, tag and desk.
*
* This is used to get around the issue when a pair of airmet and outlook is generated from
* the same series of snapshots, and the airmet's issue tyep is "NRML" while outlook's issue
* type is not "NRML". In this case, the formatted header should show the outlook's issue type.
* This is used to get around the issue when a pair of airmet and outlook is
* generated from the same series of snapshots, and the airmet's issue type
* is "NRML" while outlook's issue type is not "NRML". In this case, the
* formatted header should show the outlook's issue type.
*
* Note: TTR 714 - 10/2014: for the above case, we should modify
* "get_status.xsl" to get the formatted header by looping through all
* airmets and outlooks instead of modifying it here.
*
* @param all
* @return
*/
private static void trackOtlkIssueTypeToAirmet( List<Gfa> all ) {
private static void trackOtlkIssueTypeToAirmet(List<Gfa> all) {
for ( Gfa gg : all) {
gg.setGfaValue( ISSUE_TYPE_FROM_OUTLOOK, "NRML" );
if ( gg.isAirmet() && "NRML".equalsIgnoreCase( gg.getGfaIssueType() ) ) {
String akey = gg.getGfaHazard() + gg.getGfaTag() + gg.getGfaDesk();
for ( Gfa gotlk : all) {
if ( gotlk.isOutlook() && !("NRML".equalsIgnoreCase( gotlk.getGfaIssueType() ) ) ) {
String okey = gotlk.getGfaHazard() + gotlk.getGfaTag() + gotlk.getGfaDesk();
if ( okey.equals( akey ) ) {
gg.setGfaValue( ISSUE_TYPE_FROM_OUTLOOK, gotlk.getGfaIssueType() );
break;
}
}
}
}
for (Gfa gg : all) {
gg.setGfaValue(ISSUE_TYPE_FROM_OUTLOOK, "NRML");
if (gg.isAirmet() && "NRML".equalsIgnoreCase(gg.getGfaIssueType())) {
String akey = gg.getGfaHazard() + gg.getGfaTag()
+ gg.getGfaDesk();
for (Gfa gotlk : all) {
if (gotlk.isOutlook()
&& !("NRML".equalsIgnoreCase(gotlk
.getGfaIssueType()))) {
String okey = gotlk.getGfaHazard() + gotlk.getGfaTag()
+ gotlk.getGfaDesk();
if (okey.equals(akey)) {
gg.setGfaValue(ISSUE_TYPE_FROM_OUTLOOK,
gotlk.getGfaIssueType());
break;
}
}
}
}
}
}
}

View file

@ -7,6 +7,12 @@
*/
package gov.noaa.nws.ncep.ui.pgen.gfa;
import static gov.noaa.nws.ncep.ui.pgen.gfa.Gfa.BOS;
import static gov.noaa.nws.ncep.ui.pgen.gfa.Gfa.CHI;
import static gov.noaa.nws.ncep.ui.pgen.gfa.Gfa.DFW;
import static gov.noaa.nws.ncep.ui.pgen.gfa.Gfa.MIA;
import static gov.noaa.nws.ncep.ui.pgen.gfa.Gfa.SFO;
import static gov.noaa.nws.ncep.ui.pgen.gfa.Gfa.SLC;
import gov.noaa.nws.ncep.ui.pgen.PgenStaticDataProvider;
import java.awt.Color;
@ -20,8 +26,6 @@ import org.dom4j.Node;
import org.dom4j.io.SAXReader;
import org.eclipse.swt.graphics.RGB;
import static gov.noaa.nws.ncep.ui.pgen.gfa.Gfa.*;
/**
* Helper class to read the GFA configuration.
*
@ -41,379 +45,390 @@ import static gov.noaa.nws.ncep.ui.pgen.gfa.Gfa.*;
*/
public class GfaInfo {
// gui settings
private static Document doc;
// gui settings
private static Document doc;
public static final String HAZARD_XPATH = "/root/hazard";
public static final String FCSTHR_XPATH = "/root/fcstHr";
public static final String TAG_XPATH = "/root/tag";
public static final String DESK_XPATH = "/root/desk";
public static final String ISSUE_TYPE_XPATH = "/root/issueType";
public static final String GFA_OTLKGEN_RATIO_XPATH = "/root/gfaOtlkgenRatio";
public static final String AIRMET_ELEMENT_XPATH = "/airmetcycle/element";
public static final String GFA_SNAPSHOT = "snapshot";
public static final String GFA_SMEAR = "smear";
public static final String GFA_OUTLOOK = "outlook";
public static final String HAZARD_XPATH = "/root/hazard";
public static final int GFA_SMEAR_LINEWIDTH = 3;
public static final int GFA_OUTLOOK_LINEWIDTH = 4;
public static final int GFA_OTHER_LINEWIDTH = 2;
public static final String FCSTHR_XPATH = "/root/fcstHr";
/**
* Hazard type vs color array (index means the same as the position
* in fcstHr combo box)
*/
private static HashMap<String, RGB[]> rgbMap;
public static final String TAG_XPATH = "/root/tag";
/**
* Pairs like ("red", new RGB(255, 0, 0)) read from gfa.xml
*/
private static HashMap<String, RGB> definedColors;
/**
* Hazard categories
*/
private static HashMap<String, HazardCategory> hazardCategories;
public enum HazardCategory{
SIERRA, TANGO, ZULU, NONE;
}
public static final String DESK_XPATH = "/root/desk";
/**
* State orders in each FA area.
*/
private static HashMap<String, ArrayList<String> > stateOrderByArea;
/**
* Pairs like ("red", new RGB(255, 0, 0)) read from gfa.xml
*/
private static HashMap<String, RGB> fzlvlSfcColors;
/**
* Getter for the document.
*
* @return
*/
public static Document getDocument() {
if (doc == null) {
readOptions();
}
return doc;
}
public static final String ISSUE_TYPE_XPATH = "/root/issueType";
/**
* Read the menu configuration from gfa.xml file
*/
private static void readOptions() {
File gfainfoFile = PgenStaticDataProvider.getProvider().getStaticFile(
PgenStaticDataProvider.getProvider().getPgenLocalizationRoot() + "gfa.xml");
public static final String GFA_OTLKGEN_RATIO_XPATH = "/root/gfaOtlkgenRatio";
try {
SAXReader reader = new SAXReader();
doc = reader.read(gfainfoFile.getAbsoluteFile());
} catch (Exception e) {
e.printStackTrace();
}
}
public static final String AIRMET_ELEMENT_XPATH = "/airmetcycle/element";
/*
* This method is just to suppress warning
*/
@SuppressWarnings("unchecked")
public static List<Node> selectNodes(String xPath) {
return (List<Node>) GfaInfo.getDocument().selectNodes(xPath);
}
public static final String GFA_SNAPSHOT = "snapshot";
/**
* Creates an rgb map for hazard types and returns the corresponding color.
*
* @param hazard
* @return
*/
public static RGB getRGB(String hazard, int fcstHrIndex) {
if (rgbMap == null) {
loadColors();
}
public static final String GFA_SMEAR = "smear";
if (fcstHrIndex < 0 || fcstHrIndex >= rgbMap.get(hazard).length) {
// take last as default if parameter is out of range (fcstHr=Other)
fcstHrIndex = rgbMap.get(hazard).length-1;
}
public static final String GFA_OUTLOOK = "outlook";
return rgbMap.get(hazard)[fcstHrIndex];
}
/**
* Load colors.
*/
private static void loadColors() {
List<Node> colorNodes = selectNodes("/root/color/value");
public static final int GFA_SMEAR_LINEWIDTH = 3;
definedColors = new HashMap<String, RGB>();
for (Node n : colorNodes) {
int r = Integer.parseInt(n.valueOf("@r"));
int g = Integer.parseInt(n.valueOf("@g"));
int b = Integer.parseInt(n.valueOf("@b"));
// for example, <"red", (255,0,0)>
definedColors.put(n.valueOf("@name"), new RGB(r, g, b));
}
public static final int GFA_OUTLOOK_LINEWIDTH = 4;
List<Node> hazardNodes = selectNodes(HAZARD_XPATH);
List<Node> fcstHrNodes = selectNodes(FCSTHR_XPATH);
public static final int GFA_OTHER_LINEWIDTH = 2;
// hazard type vs. color array (index means the same as the position
// in fcstHr combo box)
rgbMap = new HashMap<String, RGB[]>();
/**
* Hazard type vs color array (index means the same as the position in
* fcstHr combo box)
*/
private static HashMap<String, RGB[]> rgbMap;
for (Node n : hazardNodes) {
RGB[] colors = new RGB[fcstHrNodes.size()];
int i = 0;
for (Node f : fcstHrNodes) {
String type = f.valueOf("@type"); // for example, "smear"
String colorStr = n.valueOf("@" + type); // for example,
// "blue"
colors[i++] = definedColors.get(colorStr);
}
rgbMap.put(n.valueOf("@name"), colors);
}
}
/**
* Pairs like ("red", new RGB(255, 0, 0)) read from gfa.xml
*/
private static HashMap<String, RGB> definedColors;
/**
* Returns the default colors for the hazard and forecast hour pair.
*
* @param hazard
* @param fcstHr
* @return Color[]
*/
public static Color[] getDefaultColors(String hazard, String fcstHr) {
RGB rgb = getDefaultRGB( hazard, fcstHr );
Color color = new Color(rgb.red, rgb.green, rgb.blue);
return new Color[]{color, color};
}
/**
* Hazard categories
*/
private static HashMap<String, HazardCategory> hazardCategories;
/**
* Returns the default color's RGB for the hazard and forecast hour pair.
*
* @param hazard
* @param fcstHr
* @return RGB
*/
public static RGB getDefaultRGB(String hazard, String fcstHr) {
if (definedColors == null) {
loadColors();
}
String xPath = HAZARD_XPATH + "[@name='" + hazard + "']";
List<Node> hazardNodes = selectNodes(xPath);
xPath = FCSTHR_XPATH + "[@name='" + fcstHr + "']";
List<Node> fcsthrNodes = selectNodes(xPath);
if (fcsthrNodes.size() != 1) {
try{
if(fcstHr.indexOf("-") == -1) { // snapshot
xPath = FCSTHR_XPATH + "[@name='0 Z']";
} else {
String second= fcstHr.split("-")[1];
String hour = second.split(":")[0];
if(Integer.parseInt(hour) <=6){ // smear
xPath = FCSTHR_XPATH + "[@name='0-6']";
} else { // outlook
xPath = FCSTHR_XPATH + "[@name='6-9']";
}
}
} catch (Exception e){
xPath = FCSTHR_XPATH + "[@name='Other']";
}
fcsthrNodes = selectNodes(xPath);
}
String gfaType = GFA_SNAPSHOT;
if ( fcsthrNodes.size() != 1 ) { //hard-coded
if ( fcstHr.indexOf("-") >= 0 ) {
String second= fcstHr.split("-")[1];
String hour = second.split(":")[0];
if(Integer.parseInt(hour) <=6) {
gfaType = GFA_SMEAR;
} else {
gfaType = GFA_OUTLOOK;
}
}
}
else {
gfaType = fcsthrNodes.get(0).valueOf("@type"); // from table
}
if (hazardNodes.size() != 1 ) {
throw new IllegalArgumentException("Please check hazard name");
}
String colorStr = hazardNodes.get(0).valueOf("@" + gfaType );
RGB rgb = definedColors.get(colorStr);
return rgb;
}
/**
* Returns the default line width for the forecast hour.
*
* @param fcstHr
* @return
*/
public static int getLineWidth(String fcstHr) {
String xPath = FCSTHR_XPATH + "[@name='" + fcstHr + "']";
List<Node> fcsthrNodes = selectNodes(xPath);
int lineWidth = GFA_OTHER_LINEWIDTH;
if ( fcsthrNodes.size() > 0 ) {
lineWidth = Integer.parseInt( fcsthrNodes.get(0).valueOf("@linewidth") );
}
else {
if ( fcstHr.indexOf("-") >= 0 ) {
String second= fcstHr.split("-")[1];
String hour = second.split(":")[0];
if( Integer.parseInt(hour) <= 6 ) {
lineWidth = GFA_SMEAR_LINEWIDTH;
} else {
lineWidth = GFA_OUTLOOK_LINEWIDTH;
}
}
}
public enum HazardCategory {
SIERRA, TANGO, ZULU, NONE;
}
return lineWidth;
}
public static boolean isFormat(String hazard){
if (definedColors == null) {
loadColors();
}
String xPath = HAZARD_XPATH + "[@name='" + hazard + "']";
List<Node> hazardNodes = selectNodes(xPath);
if (hazardNodes.size() != 1) {
throw new IllegalArgumentException("Please check hazard name");
}
String format = hazardNodes.get(0).valueOf("@format");
return !"false".equals(format);
}
/**
* State orders in each FA area.
*/
private static HashMap<String, ArrayList<String>> stateOrderByArea;
private static HashMap<String, HazardCategory> getHazardCategories() {
if(hazardCategories == null) {
hazardCategories = new HashMap<String, HazardCategory>();
List<Node> nodes = selectNodes(HAZARD_XPATH);
for(Node n: nodes){
String key = n.valueOf("@name");
String category = n.valueOf("@category");
HazardCategory cat = HazardCategory.valueOf(HazardCategory.class, category);
if(cat == null) cat = HazardCategory.NONE;
hazardCategories.put(key, cat);
}
}
return hazardCategories;
}
public static HazardCategory getHazardCategory(String hazard){
return getHazardCategories().get(hazard);
}
public static double getGfaOtlkgenRatio(){
List<Node> nodes = selectNodes(GFA_OTLKGEN_RATIO_XPATH);
Node n = nodes.get(0);
String rationStr = n.getStringValue();
return Double.parseDouble(rationStr);
}
/**
* Pairs like ("red", new RGB(255, 0, 0)) read from gfa.xml
*/
private static HashMap<String, RGB> fzlvlSfcColors;
/**
* Getter for the document.
*
* @return
*/
public static Document getDocument() {
if (doc == null) {
readOptions();
}
return doc;
}
/**
* Read the menu configuration from gfa.xml file
*/
private static void readOptions() {
File gfainfoFile = PgenStaticDataProvider.getProvider().getStaticFile(
PgenStaticDataProvider.getProvider().getPgenLocalizationRoot()
+ "gfa.xml");
try {
SAXReader reader = new SAXReader();
doc = reader.read(gfainfoFile.getAbsoluteFile());
} catch (Exception e) {
e.printStackTrace();
}
}
/*
* This method is just to suppress warning
*/
@SuppressWarnings("unchecked")
public static List<Node> selectNodes(String xPath) {
return (List<Node>) GfaInfo.getDocument().selectNodes(xPath);
}
/**
* Creates an rgb map for hazard types and returns the corresponding color.
*
* @param hazard
* @return
*/
public static RGB getRGB(String hazard, int fcstHrIndex) {
if (rgbMap == null) {
loadColors();
}
if (fcstHrIndex < 0 || fcstHrIndex >= rgbMap.get(hazard).length) {
// take last as default if parameter is out of range (fcstHr=Other)
fcstHrIndex = rgbMap.get(hazard).length - 1;
}
return rgbMap.get(hazard)[fcstHrIndex];
}
/**
* Load colors.
*/
private static void loadColors() {
List<Node> colorNodes = selectNodes("/root/color/value");
definedColors = new HashMap<String, RGB>();
for (Node n : colorNodes) {
int r = Integer.parseInt(n.valueOf("@r"));
int g = Integer.parseInt(n.valueOf("@g"));
int b = Integer.parseInt(n.valueOf("@b"));
// for example, <"red", (255,0,0)>
definedColors.put(n.valueOf("@name"), new RGB(r, g, b));
}
List<Node> hazardNodes = selectNodes(HAZARD_XPATH);
List<Node> fcstHrNodes = selectNodes(FCSTHR_XPATH);
// hazard type vs. color array (index means the same as the position
// in fcstHr combo box)
rgbMap = new HashMap<String, RGB[]>();
for (Node n : hazardNodes) {
RGB[] colors = new RGB[fcstHrNodes.size()];
int i = 0;
for (Node f : fcstHrNodes) {
String type = f.valueOf("@type"); // for example, "smear"
String colorStr = n.valueOf("@" + type); // for example,
// "blue"
colors[i++] = definedColors.get(colorStr);
}
rgbMap.put(n.valueOf("@name"), colors);
}
}
/**
* Returns the default colors for the hazard and forecast hour pair.
*
* @param hazard
* @param fcstHr
* @return Color[]
*/
public static Color[] getDefaultColors(String hazard, String fcstHr) {
RGB rgb = getDefaultRGB(hazard, fcstHr);
Color color = new Color(rgb.red, rgb.green, rgb.blue);
return new Color[] { color, color };
}
/**
* Returns the default color's RGB for the hazard and forecast hour pair.
*
* @param hazard
* @param fcstHr
* @return RGB
*/
public static RGB getDefaultRGB(String hazard, String fcstHr) {
if (definedColors == null) {
loadColors();
}
String xPath = HAZARD_XPATH + "[@name='" + hazard + "']";
List<Node> hazardNodes = selectNodes(xPath);
xPath = FCSTHR_XPATH + "[@name='" + fcstHr + "']";
List<Node> fcsthrNodes = selectNodes(xPath);
if (fcsthrNodes.size() != 1) {
try {
if (fcstHr.indexOf("-") == -1) { // snapshot
xPath = FCSTHR_XPATH + "[@name='0 Z']";
} else {
String second = fcstHr.split("-")[1];
String hour = second.split(":")[0];
if (Integer.parseInt(hour) <= 6) { // smear
xPath = FCSTHR_XPATH + "[@name='0-6']";
} else { // outlook
xPath = FCSTHR_XPATH + "[@name='6-9']";
}
}
} catch (Exception e) {
xPath = FCSTHR_XPATH + "[@name='Other']";
}
fcsthrNodes = selectNodes(xPath);
}
String gfaType = GFA_SNAPSHOT;
if (fcsthrNodes.size() != 1) { // hard-coded
if (fcstHr.indexOf("-") >= 0) {
String second = fcstHr.split("-")[1];
String hour = second.split(":")[0];
if (Integer.parseInt(hour) <= 6) {
gfaType = GFA_SMEAR;
} else {
gfaType = GFA_OUTLOOK;
}
}
} else {
gfaType = fcsthrNodes.get(0).valueOf("@type"); // from table
}
if (hazardNodes.size() != 1) {
throw new IllegalArgumentException("Please check hazard name");
}
String colorStr = hazardNodes.get(0).valueOf("@" + gfaType);
RGB rgb = definedColors.get(colorStr);
return rgb;
}
/**
* Returns the default line width for the forecast hour.
*
* @param fcstHr
* @return
*/
public static int getLineWidth(String fcstHr) {
String xPath = FCSTHR_XPATH + "[@name='" + fcstHr + "']";
List<Node> fcsthrNodes = selectNodes(xPath);
int lineWidth = GFA_OTHER_LINEWIDTH;
if (fcsthrNodes.size() > 0) {
lineWidth = Integer.parseInt(fcsthrNodes.get(0).valueOf(
"@linewidth"));
} else {
if (fcstHr.indexOf("-") >= 0) {
String second = fcstHr.split("-")[1];
String hour = second.split(":")[0];
if (Integer.parseInt(hour) <= 6) {
lineWidth = GFA_SMEAR_LINEWIDTH;
} else {
lineWidth = GFA_OUTLOOK_LINEWIDTH;
}
}
}
return lineWidth;
}
public static boolean isFormat(String hazard) {
if (definedColors == null) {
loadColors();
}
String xPath = HAZARD_XPATH + "[@name='" + hazard + "']";
List<Node> hazardNodes = selectNodes(xPath);
if (hazardNodes.size() != 1) {
throw new IllegalArgumentException("Please check hazard name");
}
String format = hazardNodes.get(0).valueOf("@format");
return !"false".equals(format);
}
private static HashMap<String, HazardCategory> getHazardCategories() {
if (hazardCategories == null) {
hazardCategories = new HashMap<String, HazardCategory>();
List<Node> nodes = selectNodes(HAZARD_XPATH);
for (Node n : nodes) {
String key = n.valueOf("@name");
String category = n.valueOf("@category");
HazardCategory cat = HazardCategory.valueOf(
HazardCategory.class, category);
if (cat == null)
cat = HazardCategory.NONE;
hazardCategories.put(key, cat);
}
}
return hazardCategories;
}
public static HazardCategory getHazardCategory(String hazard) {
return getHazardCategories().get(hazard);
}
public static double getGfaOtlkgenRatio() {
List<Node> nodes = selectNodes(GFA_OTLKGEN_RATIO_XPATH);
Node n = nodes.get(0);
String rationStr = n.getStringValue();
return Double.parseDouble(rationStr);
}
/**
* Return the fixed ordered state list in each FA area.
*/
public static HashMap<String, ArrayList<String> > getStateOrderByArea() {
if ( stateOrderByArea == null ) {
stateOrderByArea = new HashMap<String, ArrayList<String> >();
ArrayList<String> bos = new ArrayList<String>();
String[] bosStr = new String[]{"ME","NH","VT","MA","RI","CT","NY",
"LO","PA","NJ","OH","LE","WV","MD",
"DC", "DE", "VA", "CSTL WTRS"};
for ( String st : bosStr ) {
bos.add( st );
}
stateOrderByArea.put( BOS, bos);
ArrayList<String> mia = new ArrayList<String>();
String[] miaStr = new String[]{"NC", "SC", "GA", "FL" , "CSTL WTRS"};
for ( String st : miaStr ) {
mia.add( st );
}
stateOrderByArea.put( MIA, mia );
public static HashMap<String, ArrayList<String>> getStateOrderByArea() {
ArrayList<String> chi = new ArrayList<String>();
String[] chiStr = new String[]{"ND", "SD", "NE", "KS", "MN", "IA",
"MO", "WI", "LM", "LS", "MI", "LH",
"IL", "IN", "KY"};
for ( String st : chiStr ) {
chi.add( st );
}
stateOrderByArea.put( CHI, chi );
if (stateOrderByArea == null) {
stateOrderByArea = new HashMap<String, ArrayList<String>>();
ArrayList<String> bos = new ArrayList<String>();
String[] bosStr = new String[] { "ME", "NH", "VT", "MA", "RI",
"CT", "NY", "LO", "NJ", "PA", "OH", "LE", "WV", "MD", "DC",
"DE", "VA", "CSTL WTRS" };
for (String st : bosStr) {
bos.add(st);
}
stateOrderByArea.put(BOS, bos);
ArrayList<String> dfw = new ArrayList<String>();
String[] dfwStr = new String[]{"OK", "TX", "AR", "TN", "LA", "MS",
"AL", "CSTL WTRS"};
for ( String st : dfwStr ) {
dfw.add( st );
}
stateOrderByArea.put( DFW, dfw );
ArrayList<String> slc = new ArrayList<String>();
String[] slcStr = new String[]{"ID", "MT", "WY", "NV", "UT", "CO",
"AZ", "NM"} ;
for ( String st : slcStr ) {
slc.add( st );
}
stateOrderByArea.put( SLC, slc );
ArrayList<String> sfo = new ArrayList<String>();
String[] sfoStr = new String[]{"WA", "OR", "CA", "CSTL WTRS"};
for ( String st : sfoStr ) {
sfo.add( st );
}
stateOrderByArea.put( SFO, sfo );
}
return stateOrderByArea;
}
/**
* Get colors for FZLVL SFC snapshot, smear, or outlook.
* Default is "sky".
*/
public static RGB getFzlvlSfcColor( String name ) {
ArrayList<String> mia = new ArrayList<String>();
String[] miaStr = new String[] { "NC", "SC", "GA", "FL",
"CSTL WTRS" };
for (String st : miaStr) {
mia.add(st);
}
stateOrderByArea.put(MIA, mia);
if ( definedColors == null ) {
loadColors();
}
List<Node> colorNodes = selectNodes("/root/fzlvlSFC/value");
if ( fzlvlSfcColors == null ) {
fzlvlSfcColors = new HashMap<String, RGB>();
for ( Node nd : colorNodes ) {
fzlvlSfcColors.put( nd.valueOf("@name"), definedColors.get( nd.valueOf("@nmapcolor") ) );
}
}
RGB clr = fzlvlSfcColors.get( name );
if ( clr == null ) clr = definedColors.get( "sky" );
return clr;
ArrayList<String> chi = new ArrayList<String>();
String[] chiStr = new String[] { "ND", "SD", "NE", "KS", "MN",
"IA", "MO", "WI", "LM", "LS", "MI", "LH", "IL", "IN", "KY" };
for (String st : chiStr) {
chi.add(st);
}
stateOrderByArea.put(CHI, chi);
ArrayList<String> dfw = new ArrayList<String>();
String[] dfwStr = new String[] { "OK", "TX", "AR", "TN", "LA",
"MS", "AL", "CSTL WTRS" };
for (String st : dfwStr) {
dfw.add(st);
}
stateOrderByArea.put(DFW, dfw);
ArrayList<String> slc = new ArrayList<String>();
String[] slcStr = new String[] { "ID", "MT", "WY", "NV", "UT",
"CO", "AZ", "NM" };
for (String st : slcStr) {
slc.add(st);
}
stateOrderByArea.put(SLC, slc);
ArrayList<String> sfo = new ArrayList<String>();
String[] sfoStr = new String[] { "WA", "OR", "CA", "CSTL WTRS" };
for (String st : sfoStr) {
sfo.add(st);
}
stateOrderByArea.put(SFO, sfo);
}
return stateOrderByArea;
}
/**
* Get colors for FZLVL SFC snapshot, smear, or outlook. Default is "sky".
*/
public static RGB getFzlvlSfcColor(String name) {
if (definedColors == null) {
loadColors();
}
List<Node> colorNodes = selectNodes("/root/fzlvlSFC/value");
if (fzlvlSfcColors == null) {
fzlvlSfcColors = new HashMap<String, RGB>();
for (Node nd : colorNodes) {
fzlvlSfcColors.put(nd.valueOf("@name"),
definedColors.get(nd.valueOf("@nmapcolor")));
}
}
RGB clr = fzlvlSfcColors.get(name);
if (clr == null)
clr = definedColors.get("sky");
return clr;
}
}
}

View file

@ -179,7 +179,7 @@ public class ProductManageDialog extends ProductDialog {
* Sets the title of the dialog.
*/
public void setTitle() {
shell.setText("Product Center");
shell.setText("Activity Center");
}
/**
@ -319,7 +319,7 @@ public class ProductManageDialog extends ProductDialog {
titleComp.setLayout(gl0);
Label prds = new Label(titleComp, SWT.NONE);
prds.setText("Products:");
prds.setText("Activities:");
/*
* if ( !compact ) { Button multiSaveBtn = new Button( titleComp,
@ -745,12 +745,8 @@ public class ProductManageDialog extends ProductDialog {
if (!compact) {
Button clrBtn = new Button(layersComp, SWT.PUSH);
if (lyr.isMonoColor()) {
clrBtn.setText("M/F");
} else {
clrBtn.setText("A/F");
}
clrBtn.setText(getDisplayString(lyr.isMonoColor(),
lyr.isFilled()));
setButtonColor(clrBtn, lyr.getColor());
clrBtn.setData(ii);
@ -852,12 +848,8 @@ public class ProductManageDialog extends ProductDialog {
protected void updateDisplayAttr(boolean mono, Color clr, boolean fill) {
if (colorModeBtnInUse >= 0) {
if (mono) {
colorModeBtns.get(colorModeBtnInUse).setText("M/F");
} else {
colorModeBtns.get(colorModeBtnInUse).setText("A/F");
}
colorModeBtns.get(colorModeBtnInUse).setText(
getDisplayString(mono, fill));
layerList.get(colorModeBtnInUse).setMonoColor(mono);
layerList.get(colorModeBtnInUse).setColor(clr);
@ -2188,4 +2180,25 @@ public class ProductManageDialog extends ProductDialog {
exitProductManage();
}
/*
* Build a string based on given Mono color and fill flags..
*/
private String getDisplayString(boolean monoClr, boolean fill) {
String dispStr = "";
if (monoClr) {
if (fill)
dispStr += "M/F ";
else
dispStr += "M/N";
} else {
if (fill)
dispStr += "A/F ";
else
dispStr += "A/N ";
}
return dispStr;
}
}

View file

@ -11,10 +11,10 @@ import gov.noaa.nws.ncep.ui.pgen.PgenUtil;
import gov.noaa.nws.ncep.ui.pgen.producttypes.PgenLayer;
import gov.noaa.nws.ncep.ui.pgen.producttypes.ProductType;
import java.awt.Color;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.awt.Color;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
@ -29,13 +29,13 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;
@ -49,7 +49,7 @@ import org.eclipse.swt.widgets.ToolItem;
* 09/09 #151 J. Wu Initial creation.
* 01/11 #151 J. Wu updated to show info in a product type.
* 09/11 #335 J. Wu updated with new activity type definition.
* 09/11 #335 J. Wu made cascading menu for activity type/subtype.
* 09/11 #335 J. Wu made cascading menu for activity type/subtype.
*
* </pre>
*
@ -60,497 +60,500 @@ import org.eclipse.swt.widgets.ToolItem;
public class ProductNameDialog extends ProductDialog {
private Text nameText = null;
private Combo typeCombo = null;
private Composite typeComp = null;
private Text typeText = null;
private ToolBar typeToolBar = null;
private Text forecasterText = null;
private Text centerText = null;
private Text nameText = null;
private Combo typeCombo = null;
private Composite typeComp = null;
private Text typeText = null;
private ToolBar typeToolBar = null;
private Text forecasterText = null;
private Text centerText = null;
private Button saveLayerBtn = null;
private Text outputFileTxt = null;
private Group layersGrp = null;
private String initialOutput = null;
private Text outputFileTxt = null;
private Group layersGrp = null;
private String initialOutput = null;
private ProductManageDialog prdManageDlg = null;
/**
/**
* Constructor.
*/
public ProductNameDialog( Shell parentShell, ProductManageDialog dlg ) {
super( parentShell );
prdManageDlg = dlg;
}
/**
* Sets the title of the dialog.
*/
public void setTitle() {
shell.setText( "Edit Product" );
public ProductNameDialog(Shell parentShell, ProductManageDialog dlg) {
super(parentShell);
prdManageDlg = dlg;
}
/**
* Creates the main layout for the shell.
* Sets the title of the dialog.
*/
public void setTitle() {
shell.setText("Edit Activity");
}
/**
* Creates the main layout for the shell.
*/
public void setLayout() {
GridLayout mainLayout = new GridLayout( 1, true );
GridLayout mainLayout = new GridLayout(1, true);
mainLayout.marginHeight = 1;
mainLayout.marginWidth = 1;
shell.setLayout( mainLayout );
shell.setLayout(mainLayout);
}
/**
* Set the default location.
* Set the default location.
*
* @param parent
*/
public void setDefaultLocation( Shell parent ) {
public void setDefaultLocation(Shell parent) {
if ( shellLocation == null ) {
Point pt = parent.getLocation();
shell.setLocation( pt.x + 420, pt.y + 200 );
} else {
shell.setLocation(shellLocation);
}
if (shellLocation == null) {
Point pt = parent.getLocation();
shell.setLocation(pt.x + 420, pt.y + 200);
} else {
shell.setLocation(shellLocation);
}
}
/**
* Initialize the dialog components.
*/
public void initializeComponents() {
// initialOutput = prdManageDlg.getPrdOutputFile( prdManageDlg.getActiveProduct() );
initialOutput = prdManageDlg.getActiveProduct().getOutputFile();
Composite main = new Composite( shell, SWT.NONE );
GridLayout gl1 = new GridLayout( 1, false );
main.setLayout( gl1 );
Composite top = new Composite( main, SWT.NONE );
GridLayout gl = new GridLayout( 2, false );
top.setLayout( gl );
GridData gd = new GridData( SWT.FILL, SWT.DEFAULT, true, false );
Label pname = new Label( top, SWT.NONE );
pname.setText( "Name:");
nameText = new Text( top, SWT.SINGLE | SWT.BORDER );
nameText.setLayoutData( new GridData( 100, 20 ) );
nameText.setEditable( true );
nameText.setText( prdManageDlg.getActiveProduct().getName() );
// initialOutput = prdManageDlg.getPrdOutputFile(
// prdManageDlg.getActiveProduct() );
initialOutput = prdManageDlg.getActiveProduct().getOutputFile();
Composite main = new Composite(shell, SWT.NONE);
GridLayout gl1 = new GridLayout(1, false);
main.setLayout(gl1);
Composite top = new Composite(main, SWT.NONE);
GridLayout gl = new GridLayout(2, false);
top.setLayout(gl);
GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
Label pname = new Label(top, SWT.NONE);
pname.setText("Name:");
nameText = new Text(top, SWT.SINGLE | SWT.BORDER);
nameText.setLayoutData(new GridData(100, 20));
nameText.setEditable(true);
nameText.setText(prdManageDlg.getActiveProduct().getName());
Label ptype = new Label(top, SWT.NONE);
ptype.setText("Type:");
Label ptype = new Label( top, SWT.NONE );
ptype.setText( "Type:");
String curType = prdManageDlg.getActiveProduct().getType();
typeComp = new Composite( top, SWT.LEFT );
typeComp.setLayout( new GridLayout( 2, false ) );
typeText = new Text( typeComp, SWT.LEFT | SWT.BORDER );
typeText.setSize( 300, 20 );
typeText.setText( curType );
typeText.setData( curType );
typeText.setEditable( false );
typeToolBar = new ToolBar( typeComp, SWT.HORIZONTAL );
final ToolItem ti = new ToolItem( typeToolBar, SWT.DROP_DOWN );
ti.setEnabled( true );
final Menu mu = new Menu( shell.getShell(), SWT.POP_UP );
MenuItem mi1 = new MenuItem( mu, SWT.PUSH, 0 );
mi1.setText( "Default" );
mi1.setData( "Default" );
mi1.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
typeText.setText( ((MenuItem)e.widget).getData().toString() );
typeText.pack();
typeComp.pack();
typeComp.getParent().pack();
switchProductType( "Default" );
}
});
int ntyp = 1;
ArrayList<String> typeUsed = new ArrayList<String>();
for ( String ptypName : prdManageDlg.prdTypesMap.keySet() ) {
ProductType prdType = prdManageDlg.prdTypesMap.get( ptypName );
LinkedHashMap<String, String> subtypesNalias = prdManageDlg.getSubtypes( prdType.getType(), true );
if ( (ptypName.equals( prdType.getName() ) &&
!prdType.getType().equals( prdType.getName() ) ) ||
!prdManageDlg.hasSubtypes( subtypesNalias.values() ) ) {
MenuItem typeItem = new MenuItem( mu, SWT.PUSH, ntyp );
typeItem.setText( ptypName );
typeItem.setData( ptypName );
typeItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
String typeName = ((MenuItem)e.widget).getData().toString();
typeText.setText( typeName );
typeText.pack();
typeComp.pack();
typeComp.getParent().pack();
switchProductType( typeName );
}
});
}
else {
if ( typeUsed.contains( prdType.getType() ) ) {
continue;
}
else {
typeUsed.add( prdType.getType() );
}
MenuItem typeItem = new MenuItem( mu, SWT.CASCADE, ntyp );
typeItem.setText( prdType.getType() );
Menu submenu = new Menu( typeItem );
typeItem.setMenu( submenu );
for ( String styp : subtypesNalias.keySet() ) {
MenuItem subtypeItem = new MenuItem( submenu, SWT.PUSH );
subtypeItem.setText( subtypesNalias.get( styp ) );
subtypeItem.setData( styp );
typeComp = new Composite(top, SWT.LEFT);
typeComp.setLayout(new GridLayout(2, false));
subtypeItem.addSelectionListener( new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
String typeName = ((MenuItem)e.widget).getData().toString();
typeText.setText( typeName );
typeText.pack();
typeComp.pack();
typeComp.getParent().pack();
switchProductType( typeName);
}
});
}
typeText = new Text(typeComp, SWT.LEFT | SWT.BORDER);
typeText.setSize(300, 20);
typeText.setText(curType);
typeText.setData(curType);
typeText.setEditable(false);
typeToolBar = new ToolBar(typeComp, SWT.HORIZONTAL);
final ToolItem ti = new ToolItem(typeToolBar, SWT.DROP_DOWN);
ti.setEnabled(true);
final Menu mu = new Menu(shell.getShell(), SWT.POP_UP);
MenuItem mi1 = new MenuItem(mu, SWT.PUSH, 0);
mi1.setText("Default");
mi1.setData("Default");
mi1.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
typeText.setText(((MenuItem) e.widget).getData().toString());
typeText.pack();
typeComp.pack();
typeComp.getParent().pack();
switchProductType("Default");
}
ntyp++;
}
ti.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) {
Rectangle bounds = ti.getBounds();
Point point = typeToolBar.toDisplay( bounds.x, bounds.y + bounds.height );
mu.setLocation( point );
mu.setVisible( true );
}
});
Label pfst = new Label( top, SWT.NONE );
pfst.setText( "Forecaster:");
forecasterText = new Text( top, SWT.SINGLE | SWT.BORDER );
forecasterText.setLayoutData( new GridData( 100, 20 ) );
forecasterText.setEditable( true );
forecasterText.setText( prdManageDlg.getActiveProduct().getForecaster() );
Label pcnt = new Label( top, SWT.NONE );
pcnt.setText( "Center:");
centerText = new Text( top, SWT.SINGLE | SWT.BORDER );
centerText.setLayoutData( new GridData( 100, 20 ) );
centerText.setEditable( true );
centerText.setText( prdManageDlg.getActiveProduct().getCenter() );
Group typeInfoGrp = new Group( main, SWT.SHADOW_IN );
typeInfoGrp.setLayout( new GridLayout( 1, false) );
typeInfoGrp.setText( "Product Type Information" );
Composite bot1 = new Composite( typeInfoGrp, SWT.NONE );
bot1.setLayout( new GridLayout( 2, false) );
Composite bot2 = new Composite( typeInfoGrp, SWT.NONE );
bot2.setLayout( new GridLayout( 3, false) );
Label psave = new Label( bot1, SWT.NONE );
psave.setText( "Save Layers:");
saveLayerBtn = new Button( bot1, SWT.CHECK );
saveLayerBtn.setSelection( prdManageDlg.getActiveProduct().isSaveLayers() );
//Create a composite for output file name
Label outputLbl = new Label( bot2, SWT.LEFT );
outputLbl.setText("Output:");
outputFileTxt = new Text( bot2, SWT.SINGLE | SWT.BORDER );
outputFileTxt.setLayoutData( new GridData( 150, 20 ) );
outputFileTxt.setEditable( true );
if ( initialOutput != null ) {
outputFileTxt.setText( initialOutput );
}
else {
outputFileTxt.setText( "" );
}
int ntyp = 1;
ArrayList<String> typeUsed = new ArrayList<String>();
for (String ptypName : prdManageDlg.prdTypesMap.keySet()) {
Button browseBtn = new Button( bot2, SWT.PUSH );
browseBtn.setText( "Browse");
layersGrp = new Group( typeInfoGrp, SWT.NONE );
layersGrp.setLayout( new GridLayout( 1, false) );
layersGrp.setText( "Layers Defined");
String prevType = prdManageDlg.getActiveProduct().getType();
createLayersTemplate( layersGrp , prevType );
browseBtn.addSelectionListener( new SelectionAdapter() {
public void widgetSelected( SelectionEvent event ) {
createFileText( outputFileTxt, initialOutput );
ProductType prdType = prdManageDlg.prdTypesMap.get(ptypName);
LinkedHashMap<String, String> subtypesNalias = prdManageDlg
.getSubtypes(prdType.getType(), true);
if ((ptypName.equals(prdType.getName()) && !prdType.getType()
.equals(prdType.getName()))
|| !prdManageDlg.hasSubtypes(subtypesNalias.values())) {
MenuItem typeItem = new MenuItem(mu, SWT.PUSH, ntyp);
typeItem.setText(ptypName);
typeItem.setData(ptypName);
typeItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
String typeName = ((MenuItem) e.widget).getData()
.toString();
typeText.setText(typeName);
typeText.pack();
typeComp.pack();
typeComp.getParent().pack();
switchProductType(typeName);
}
});
} else {
if (typeUsed.contains(prdType.getType())) {
continue;
} else {
typeUsed.add(prdType.getType());
}
MenuItem typeItem = new MenuItem(mu, SWT.CASCADE, ntyp);
typeItem.setText(prdType.getType());
Menu submenu = new Menu(typeItem);
typeItem.setMenu(submenu);
for (String styp : subtypesNalias.keySet()) {
MenuItem subtypeItem = new MenuItem(submenu, SWT.PUSH);
subtypeItem.setText(subtypesNalias.get(styp));
subtypeItem.setData(styp);
subtypeItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
String typeName = ((MenuItem) e.widget).getData()
.toString();
typeText.setText(typeName);
typeText.pack();
typeComp.pack();
typeComp.getParent().pack();
switchProductType(typeName);
}
});
}
}
});
browseBtn.setEnabled( false );
ntyp++;
}
ti.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) {
Rectangle bounds = ti.getBounds();
Point point = typeToolBar.toDisplay(bounds.x, bounds.y
+ bounds.height);
mu.setLocation(point);
mu.setVisible(true);
}
});
Label pfst = new Label(top, SWT.NONE);
pfst.setText("Forecaster:");
forecasterText = new Text(top, SWT.SINGLE | SWT.BORDER);
forecasterText.setLayoutData(new GridData(100, 20));
forecasterText.setEditable(true);
forecasterText.setText(prdManageDlg.getActiveProduct().getForecaster());
Label pcnt = new Label(top, SWT.NONE);
pcnt.setText("Center:");
centerText = new Text(top, SWT.SINGLE | SWT.BORDER);
centerText.setLayoutData(new GridData(100, 20));
centerText.setEditable(true);
centerText.setText(prdManageDlg.getActiveProduct().getCenter());
Group typeInfoGrp = new Group(main, SWT.SHADOW_IN);
typeInfoGrp.setLayout(new GridLayout(1, false));
typeInfoGrp.setText("Product Type Information");
Composite bot1 = new Composite(typeInfoGrp, SWT.NONE);
bot1.setLayout(new GridLayout(2, false));
Composite bot2 = new Composite(typeInfoGrp, SWT.NONE);
bot2.setLayout(new GridLayout(3, false));
Label psave = new Label(bot1, SWT.NONE);
psave.setText("Save Layers:");
saveLayerBtn = new Button(bot1, SWT.CHECK);
saveLayerBtn.setSelection(prdManageDlg.getActiveProduct()
.isSaveLayers());
// Create a composite for output file name
Label outputLbl = new Label(bot2, SWT.LEFT);
outputLbl.setText("Output:");
outputFileTxt = new Text(bot2, SWT.SINGLE | SWT.BORDER);
outputFileTxt.setLayoutData(new GridData(150, 20));
outputFileTxt.setEditable(true);
if (initialOutput != null) {
outputFileTxt.setText(initialOutput);
} else {
outputFileTxt.setText("");
}
Button browseBtn = new Button(bot2, SWT.PUSH);
browseBtn.setText("Browse");
layersGrp = new Group(typeInfoGrp, SWT.NONE);
layersGrp.setLayout(new GridLayout(1, false));
layersGrp.setText("Layers Defined");
String prevType = prdManageDlg.getActiveProduct().getType();
createLayersTemplate(layersGrp, prevType);
browseBtn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
createFileText(outputFileTxt, initialOutput);
}
});
browseBtn.setEnabled(false);
// Create control buttons
Composite centeredComp = new Composite( shell, SWT.NONE );
GridLayout gl2 = new GridLayout( 2, true );
centeredComp.setLayout( gl2 );
centeredComp.setLayoutData( gd );
Composite centeredComp = new Composite(shell, SWT.NONE);
GridLayout gl2 = new GridLayout(2, true);
centeredComp.setLayout(gl2);
centeredComp.setLayoutData(gd);
Button acceptBtn = new Button( centeredComp, SWT.NONE );
acceptBtn.setText( "Accept" );
acceptBtn.setLayoutData( gd );
acceptBtn.addSelectionListener( new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
updateProduct();
close();
}
});
Button cancelBtn = new Button( centeredComp, SWT.NONE );
cancelBtn.setText( " Close " );
cancelBtn.setLayoutData( gd );
cancelBtn.addSelectionListener( new SelectionAdapter() {
Button acceptBtn = new Button(centeredComp, SWT.NONE);
acceptBtn.setText("Accept");
acceptBtn.setLayoutData(gd);
acceptBtn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
prdManageDlg.setOpenPrdNameDlg( false );
close();
updateProduct();
close();
}
});
}
/*
* Update the product attributes in the product control window.
*/
private void updateProduct() {
// selectProductType();
HashMap<String, String> attr = new HashMap<String, String>();
attr.put( "name", nameText.getText() );
attr.put( "type", typeText.getText() );
attr.put( "forecaster", forecasterText.getText() );
attr.put( "center", centerText.getText() );
if (saveLayerBtn.getSelection() ) {
attr.put( "saveLayers", "true" );
}
else {
attr.put( "saveLayers", "false" );
}
attr.put( "outputfile", outputFileTxt.getText() );
if ( prdManageDlg != null ) {
prdManageDlg.updateProductAttr( attr );
}
}
/*
* Select a product type with confirmation.
*/
private void selectProductType() {
if ( !(typeCombo.getText().equals( prdManageDlg.getActiveProduct().getType() ) ) ) {
/*
MessageDialog confirmDlg = new MessageDialog(
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
"Confirm type", null,
"Are you sure you want to switch from type " +
prdManageDlg.getActiveProduct().getType()
+ " to type " + typeCombo.getText() + "?",
MessageDialog.QUESTION, new String[]{"OK", "Cancel"}, 0);
confirmDlg.open();
if ( confirmDlg.getReturnCode() != MessageDialog.OK ) {
typeCombo.select( curType );
Button cancelBtn = new Button(centeredComp, SWT.NONE);
cancelBtn.setText(" Close ");
cancelBtn.setLayoutData(gd);
cancelBtn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
prdManageDlg.setOpenPrdNameDlg(false);
close();
}
*/
// typeCombo.select( curType );
});
}
/*
* Update the product attributes in the product control window.
*/
private void updateProduct() {
// selectProductType();
HashMap<String, String> attr = new HashMap<String, String>();
attr.put("name", nameText.getText());
attr.put("type", typeText.getText());
attr.put("forecaster", forecasterText.getText());
attr.put("center", centerText.getText());
if (saveLayerBtn.getSelection()) {
attr.put("saveLayers", "true");
} else {
attr.put("saveLayers", "false");
}
attr.put("outputfile", outputFileTxt.getText());
if (prdManageDlg != null) {
prdManageDlg.updateProductAttr(attr);
}
}
/*
* Select a product type with confirmation.
*/
private void selectProductType() {
if (!(typeCombo.getText().equals(prdManageDlg.getActiveProduct()
.getType()))) {
/*
* MessageDialog confirmDlg = new MessageDialog(
* PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
* "Confirm type", null,
* "Are you sure you want to switch from type " +
* prdManageDlg.getActiveProduct().getType() + " to type " +
* typeCombo.getText() + "?", MessageDialog.QUESTION, new
* String[]{"OK", "Cancel"}, 0);
*
* confirmDlg.open();
*
* if ( confirmDlg.getReturnCode() != MessageDialog.OK ) {
* typeCombo.select( curType ); }
*/
// typeCombo.select( curType );
}
}
/**
* Create a file/path input dialog with a Text and a "Browse" button.
*
* @param txt
* @return
*/
private void createFileText( Text txt, String initialFile ) {
String[] filterNames = new String[] { "*.xml", "All Files (*)" };
String[] filterExtensions = new String[] {"*.xml", "*" };
// String filterPath = PgenUtil.CURRENT_WORKING_DIRECTORY;
String filterPath = PgenUtil.getWorkingDirectory();
String defaultFile = new String( "default.xml" );
if ( initialFile != null ) {
int index = initialFile.lastIndexOf('/');
if ( index >= 0 ) {
defaultFile = initialFile.substring( index+1, initialFile.length() );
filterPath = initialFile.substring( 0, index);
}
else {
defaultFile = new String( initialFile );
}
}
String selectedFile = selectFile( shell, SWT.OPEN, filterNames,
filterExtensions, filterPath, defaultFile, true );
if ( selectedFile != null ) {
txt.setText( selectedFile );
}
}
/**
* Create a file selection dialog
*
* @param sh
* @param mode
* @param nameFilter
* @param extensionFilter
* @param pathFilter
* @param defaultFile
* @param overWrite
* @return dialog.open()
*/
private String selectFile( Shell sh, int mode, String[] nameFilter,
String[] extensionFilter, String pathFilter,
String defaultFile, boolean overWrite ) {
FileDialog dialog = new FileDialog( sh, mode );
dialog.setFilterNames( nameFilter );
dialog.setFilterExtensions( extensionFilter );
dialog.setFilterPath( pathFilter );
if ( defaultFile != null ) {
dialog.setFileName ( defaultFile );
}
dialog.setOverwrite( overWrite );
return dialog.open();
}
/*
* Create name, on/off, and color mode buttons for defined layers
}
/**
* Create a file/path input dialog with a Text and a "Browse" button.
*
* @param txt
* @return
*/
private void createLayersTemplate( Composite cmp, String typ ) {
Control[] wids = cmp.getChildren();
for ( int jj = 0; jj < wids.length; jj++ ) {
wids[jj].dispose();
}
cmp.pack();
shell.pack( true );
ProductType prdtype = prdManageDlg.prdTypesMap.get( typ );
if ( prdtype == null || prdtype.getPgenLayer() == null ||
prdtype.getPgenLayer().size() <= 0 ) {
return;
private void createFileText(Text txt, String initialFile) {
String[] filterNames = new String[] { "*.xml", "All Files (*)" };
String[] filterExtensions = new String[] { "*.xml", "*" };
// String filterPath = PgenUtil.CURRENT_WORKING_DIRECTORY;
String filterPath = PgenUtil.getWorkingDirectory();
String defaultFile = new String("default.xml");
if (initialFile != null) {
int index = initialFile.lastIndexOf('/');
if (index >= 0) {
defaultFile = initialFile.substring(index + 1,
initialFile.length());
filterPath = initialFile.substring(0, index);
} else {
defaultFile = new String(initialFile);
}
}
Composite layersComp = new Composite( cmp, SWT.NONE );
GridLayout gl = new GridLayout( 3, false );
String selectedFile = selectFile(shell, SWT.OPEN, filterNames,
filterExtensions, filterPath, defaultFile, true);
if (selectedFile != null) {
txt.setText(selectedFile);
}
}
/**
* Create a file selection dialog
*
* @param sh
* @param mode
* @param nameFilter
* @param extensionFilter
* @param pathFilter
* @param defaultFile
* @param overWrite
* @return dialog.open()
*/
private String selectFile(Shell sh, int mode, String[] nameFilter,
String[] extensionFilter, String pathFilter, String defaultFile,
boolean overWrite) {
FileDialog dialog = new FileDialog(sh, mode);
dialog.setFilterNames(nameFilter);
dialog.setFilterExtensions(extensionFilter);
dialog.setFilterPath(pathFilter);
if (defaultFile != null) {
dialog.setFileName(defaultFile);
}
dialog.setOverwrite(overWrite);
return dialog.open();
}
/*
* Create name, on/off, and color mode buttons for defined layers
*/
private void createLayersTemplate(Composite cmp, String typ) {
Control[] wids = cmp.getChildren();
for (int jj = 0; jj < wids.length; jj++) {
wids[jj].dispose();
}
cmp.pack();
shell.pack(true);
ProductType prdtype = prdManageDlg.prdTypesMap.get(typ);
if (prdtype == null || prdtype.getPgenLayer() == null
|| prdtype.getPgenLayer().size() <= 0) {
return;
}
Composite layersComp = new Composite(cmp, SWT.NONE);
GridLayout gl = new GridLayout(3, false);
gl.marginHeight = 1;
gl.marginWidth = 1;
gl.verticalSpacing = 1;
gl.horizontalSpacing = 10;
layersComp.setLayout( gl );
for ( PgenLayer lyr : prdtype.getPgenLayer() ) {
Button nameBtn = new Button( layersComp, SWT.PUSH );
nameBtn.setText( lyr.getName() );
Button dispBtn = new Button( layersComp, SWT.CHECK );
dispBtn.setSelection( lyr.isOnOff() );
dispBtn.setEnabled( false );
Button clrBtn = new Button( layersComp, SWT.PUSH );
clrBtn.setText( "A/F" );
Color clr = new Color( lyr.getColor().getRed(),
lyr.getColor().getGreen(),
lyr.getColor().getBlue(),
lyr.getColor().getAlpha() );
layersComp.setLayout(gl);
setButtonColor( clrBtn, clr );
}
cmp.pack();
shell.pack( true );
}
/*
* Switch to a new type
*/
private void switchProductType( String newType ) {
for (PgenLayer lyr : prdtype.getPgenLayer()) {
createLayersTemplate( layersGrp, newType );
nameText.setText( newType );
saveLayerBtn.setSelection( false );
outputFileTxt.setText( "" );
outputFileTxt.setEditable( false );
Button nameBtn = new Button(layersComp, SWT.PUSH);
nameBtn.setText(lyr.getName());
ProductType ptyp = prdManageDlg.prdTypesMap.get( newType );
if ( ptyp != null ) {
if ( ptyp.getPgenSave() != null ) {
if ( ptyp.getPgenSave().getOutputFile() != null ) {
outputFileTxt.setText( ptyp.getPgenSave().getOutputFile() );
}
if ( ptyp.getPgenSave().isSaveLayers() != null ) {
saveLayerBtn.setSelection( ptyp.getPgenSave().isSaveLayers() );
}
}
Button dispBtn = new Button(layersComp, SWT.CHECK);
dispBtn.setSelection(lyr.isOnOff());
dispBtn.setEnabled(false);
Button clrBtn = new Button(layersComp, SWT.PUSH);
clrBtn.setText("A/F");
Color clr = new Color(lyr.getColor().getRed(), lyr.getColor()
.getGreen(), lyr.getColor().getBlue(), lyr.getColor()
.getAlpha());
setButtonColor(clrBtn, clr);
}
cmp.pack();
shell.pack(true);
}
/*
* Switch to a new type
*/
private void switchProductType(String newType) {
createLayersTemplate(layersGrp, newType);
nameText.setText(newType);
saveLayerBtn.setSelection(false);
outputFileTxt.setText("");
outputFileTxt.setEditable(false);
ProductType ptyp = prdManageDlg.prdTypesMap.get(newType);
if (ptyp != null) {
if (ptyp.getPgenSave() != null) {
if (ptyp.getPgenSave().getOutputFile() != null) {
outputFileTxt.setText(ptyp.getPgenSave().getOutputFile());
}
if (ptyp.getPgenSave().isSaveLayers() != null) {
saveLayerBtn
.setSelection(ptyp.getPgenSave().isSaveLayers());
}
}
}
}
}

View file

@ -143,7 +143,9 @@ import com.vividsolutions.jts.geom.Point;
* 03/13 #927 B. Yin Implemented IContextMenuProvider interface
* 04/13 #874 B. Yin Added a method replaceElements with parameter parent.
* 04/13 #977 S. Gilbert PGEN Database support
* 11/13 TTR 752 J. Wu Add methods for CCFP text auto placement.
* 09/14 TTR972 J. Wu "Filled" object on the active layer should be
* drawn as "filled" even if the "filled" flag for
* the layer is "false".
* </pre>
*
* @author B. Yin
@ -1841,6 +1843,12 @@ public class PgenResource extends
dprops.setLayerMonoColor(layer.isMonoColor());
dprops.setLayerColor(layer.getColor());
dprops.setLayerFilled(layer.isFilled());
} else {
/*
* "Filled" should always be set to "true" for displaying the
* active layer.
*/
dprops.setLayerFilled(true);
}
Iterator<DrawableElement> iterator = layer.createDEIterator();
@ -1991,7 +1999,6 @@ public class PgenResource extends
PaintProperties paintProps, DisplayProperties dispProps) {
if (filters.acceptOnce(de)) {
if (!displayMap.containsKey(de)) {
AbstractElementContainer container = ElementContainerFactory
.createContainer(de, descriptor, target);

View file

@ -23,7 +23,6 @@ import gov.noaa.nws.ncep.ui.pgen.display.AbstractElementContainer;
import gov.noaa.nws.ncep.ui.pgen.display.DefaultElementContainer;
import gov.noaa.nws.ncep.ui.pgen.display.DisplayElementFactory;
import gov.noaa.nws.ncep.ui.pgen.elements.AbstractDrawableComponent;
import gov.noaa.nws.ncep.ui.pgen.elements.DECollection;
import gov.noaa.nws.ncep.ui.pgen.elements.DrawableElement;
import java.util.HashMap;
@ -38,36 +37,37 @@ import com.raytheon.uf.viz.core.map.IMapDescriptor;
* Ghost drawing for the pgen resource.
*
* <pre>
*
*
* SOFTWARE HISTORY
*
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jun 15, 2012 bgonzale Initial creation
*
*
* </pre>
*
*
* @author bgonzale
* @version 1.0
* @version 1.0
*/
public class PgenResourceGhost {
public AbstractDrawableComponent component;
Map<Object, AbstractElementContainer> componentMap = new HashMap<Object, AbstractElementContainer>();
/**
* Draw the ghost
*
* @param target
* @param paintProps
* @param df
* @param descriptor
*/
public void draw( IGraphicsTarget target, PaintProperties paintProps,
DisplayElementFactory df, IMapDescriptor descriptor){
df.setLayerDisplayAttr( false, null, false );
public void draw(IGraphicsTarget target, PaintProperties paintProps,
DisplayElementFactory df, IMapDescriptor descriptor) {
df.setLayerDisplayAttr(false, null, false);
if (component != null) {
Iterator<DrawableElement> iterator = component
.createDEIterator();
Iterator<DrawableElement> iterator = component.createDEIterator();
int count = 0;
while (iterator.hasNext()) {
DrawableElement element = iterator.next();
@ -76,21 +76,27 @@ public class PgenResourceGhost {
}
}
}
/**
* Creates displayables for an element using an ElementContainer and call the
* displayables' draw() method to draw the element.
* @param target Graphic target
* @param paintProps Paint properties
* @param df Display element factory
* @param el Input drawable element
* Creates displayables for an element using an ElementContainer and call
* the displayables' draw() method to draw the element.
*
* @param target
* Graphic target
* @param paintProps
* Paint properties
* @param df
* Display element factory
* @param el
* Input drawable element
* @praram descriptor
*/
private void drawElement( IGraphicsTarget target, PaintProperties paintProps,
DisplayElementFactory df, DrawableElement el, IMapDescriptor descriptor){
private void drawElement(IGraphicsTarget target,
PaintProperties paintProps, DisplayElementFactory df,
DrawableElement el, IMapDescriptor descriptor) {
Object key = createKey(el);
AbstractElementContainer graphic = componentMap.get(key);
AbstractElementContainer graphic = componentMap.get(key);
if (graphic == null) {
graphic = new DefaultElementContainer(el, descriptor, target);
componentMap.put(key, graphic);
@ -99,16 +105,17 @@ public class PgenResourceGhost {
}
graphic.draw(target, paintProps, null, true);
}
private Object createKey(DrawableElement el) {
return el.getPgenCategory()+ ":"+el.getPgenType();
return el.getPgenCategory() + ":" + el.getPgenType();
}
/**
* Sets the ghost line for the PGEN drawing layer.
* @param ghost
*
* @param ghost
*/
public void setGhostLine(AbstractDrawableComponent ghost) {
this.component = ghost;
this.component = ghost;
}
}

View file

@ -197,6 +197,7 @@ public class PgenContoursTool extends AbstractPgenDrawingTool implements
if (button == 1) {
drawContourMinmax(loc);
((ContoursAttrDlg) attrDlg).updateSymbolAttrOnGUI(loc);
} else if (button == 3) {
points.clear();

View file

@ -3,13 +3,15 @@ package gov.noaa.nws.ncep.viz.overlays.resources;
import gov.noaa.nws.ncep.viz.resources.INatlCntrsResource;
import java.util.ArrayList;
import java.util.List;
import java.util.HashMap;
import java.util.Map;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import com.raytheon.uf.viz.core.IGraphicsTarget;
import com.raytheon.uf.viz.core.PixelExtent;
import com.raytheon.uf.viz.core.drawables.IFont;
import com.raytheon.uf.viz.core.drawables.IFont.Style;
import com.raytheon.uf.viz.core.drawables.IWireframeShape;
import com.raytheon.uf.viz.core.drawables.PaintProperties;
import com.raytheon.uf.viz.core.exception.VizException;
@ -17,6 +19,8 @@ import com.raytheon.uf.viz.core.map.IMapDescriptor;
import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
import com.raytheon.uf.viz.core.rsc.LoadProperties;
import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.Geometry;
import com.vividsolutions.jts.geom.GeometryFactory;
/**
* Implements a drawing layer to draw lat/lon lines
@ -52,9 +56,9 @@ public class LatLonOverlayResource extends
/** The wireframe object for drawing Longitude lines */
private IWireframeShape wireframeShapeForLonLineArray;
private List<Coordinate[]> latitudeCoordinatePointArrayList;
private Map<Double, Geometry> latitudeLineGeometries;
private List<Coordinate[]> longitudeCoordinatePointArrayList;
private Map<Double, Geometry> longitudeLineGeometries;
private double offset = 0; // 50000;
@ -75,17 +79,26 @@ public class LatLonOverlayResource extends
private double viewMaxX;
/*
* The four minimum and maximum of X and Y used to paint label
* The four effective view borders (map borders inside the viewable user
* window) used to paint label
*/
private double effectiveMinX;
private Geometry effectiveLeftBorder;
private double effectiveMaxY;
private Geometry effectiveRightBorder;
private double effectiveMinY;
private Geometry effectiveBottomBorder;
private double effectiveMaxX;
private Geometry effectiveTopBorder;
private double latLonDrawingPointInterval = 1.0; // 0.7; //1.0; //0.5
private Geometry mapBoundary;
private Geometry mapMedianLine;
private final double latLonDrawingPointInterval = 1.0; // 0.7; //1.0; //0.5
private final double drawingGap = 120;
private double labelGap;
private boolean needsUpdate = true;
@ -114,8 +127,10 @@ public class LatLonOverlayResource extends
public void paintInternal(IGraphicsTarget target, PaintProperties paintProps)
throws VizException {
IFont lfont = target.initializeFont("Courier", 14, null);
IFont lfont = target.initializeFont("Courier", 14,
new Style[] { Style.BOLD });
float zoomFactor = paintProps.getZoomLevel();
labelGap = drawingGap * zoomFactor;
initializeViewMinAndMaxXAndY(paintProps);
int latitudeDrawingLineNumber = getLatitudeDrawingLineNumber(latLonOverlayResourceData
@ -128,17 +143,12 @@ public class LatLonOverlayResource extends
if (needsUpdate) {
needsUpdate = false;
/*
* necessary???
*/
clearWireFrameShapeArray(wireframeShapeForLatLineArray);
clearWireFrameShapeArray(wireframeShapeForLonLineArray);
clearCoordinatePointArrayList(latitudeCoordinatePointArrayList);
clearCoordinatePointArrayList(longitudeCoordinatePointArrayList);
latitudeCoordinatePointArrayList = new ArrayList<Coordinate[]>(
latitudeLineGeometries = new HashMap<Double, Geometry>(
latitudeDrawingLineNumber);
longitudeCoordinatePointArrayList = new ArrayList<Coordinate[]>(
longitudeLineGeometries = new HashMap<Double, Geometry>(
longitudeDrawingLineNumber);
wireframeShapeForLatLineArray = target.createWireframeShape(false,
@ -149,19 +159,17 @@ public class LatLonOverlayResource extends
double latitudeValue = -90;
for (int i = 0; i < latitudeDrawingLineNumber
&& latitudeValue <= 90; i++) {
Coordinate[] latLonCoordinateArray = createCoordinateArrayForLatitudeLine(
double[][] latLonCoordinateArray = createCoordinateArrayForLatitudeLine(
latitudeValue, latLonDrawingPointInterval);
latitudeCoordinatePointArrayList.add(latLonCoordinateArray);
if (!(latitudeValue == -90 || latitudeValue == 90)) {
if (!(latitudeValue == -90 || latitudeValue == 90)
&& latLonCoordinateArray.length > 0) {
wireframeShapeForLatLineArray
.addLineSegment(latLonCoordinateArray);
}
latitudeValue += latLonOverlayResourceData
.getLatitudeInterval();
}
wireframeShapeForLatLineArray.compile();
wireframeShapeForLonLineArray = target.createWireframeShape(false,
@ -172,39 +180,47 @@ public class LatLonOverlayResource extends
double longitudeValue = -180;
for (int i = 0; i < longitudeDrawingLineNumber
&& longitudeValue <= 180; i++) {
Coordinate[] latLonCoordinateArray = createCoordinateArrayLongitudeLine(
double[][] latLonCoordinateArray = createCoordinateArrayLongitudeLine(
longitudeValue, latLonDrawingPointInterval);
longitudeCoordinatePointArrayList.add(latLonCoordinateArray);
wireframeShapeForLonLineArray
.addLineSegment(latLonCoordinateArray);
if (latLonCoordinateArray.length > 0) {
wireframeShapeForLonLineArray
.addLineSegment(latLonCoordinateArray);
}
longitudeValue += latLonOverlayResourceData
.getLongitudeInterval();
}
wireframeShapeForLonLineArray.compile();
}
double latitudeValue = -90;
updateEffectiveMinX(getMapMinX(), getViewMinX(), getViewMaxX());
for (int i = 0; i < latitudeDrawingLineNumber && latitudeValue <= 90; i++) {
addDefaultLabelByPointIndex(wireframeShapeForLatLineArray,
String.valueOf((int) latitudeValue),
latitudeCoordinatePointArrayList.get(i), 0);
int pointIndexForAddingLabel = getPointLabelIndexForAddingLatitudeLabel(
latitudeCoordinatePointArrayList.get(i), zoomFactor,
getEffectiveMinX(), getEffectiveMaxX(), getEffectiveMinY(),
getEffectiveMaxY());
if (!(pointIndexForAddingLabel < 0)) {
addLabelOnLatLonLine(wireframeShapeForLatLineArray,
latitudeCoordinatePointArrayList.get(i),
pointIndexForAddingLabel,
String.valueOf((int) latitudeValue));
Geometry latLine = latitudeLineGeometries.get(latitudeValue);
if (latLine != null) {
wireframeShapeForLatLineArray.clearLabels();
Coordinate intersection = null;
if (effectiveLeftBorder.intersects(latLine)) {
intersection = effectiveLeftBorder.intersection(latLine)
.getCoordinate();
} else if (latLine.within(mapBoundary)
&& mapMedianLine.intersects(latLine)) {
intersection = mapMedianLine.intersection(latLine)
.getCoordinate();
// Removes default latitude label if it is too close to the
// bottom of the viewable edge to prevent the latitude label
// from being displayed over the longitude labels.
if (intersection.y > effectiveBottomBorder.getCoordinate().y
- 2.5 * labelGap) {
intersection = null;
}
}
if (intersection != null) {
wireframeShapeForLatLineArray
.addLabel(String.valueOf((int) latitudeValue),
new double[] { intersection.x + labelGap,
intersection.y });
}
}
target.drawWireframeShape(wireframeShapeForLatLineArray,
latLonOverlayResourceData.getColor(),
latLonOverlayResourceData.getLineWidth(),
@ -212,18 +228,21 @@ public class LatLonOverlayResource extends
latitudeValue += latLonOverlayResourceData.getLatitudeInterval();
}
double longitudeValue = -180;
updateEffectiveMaxY(getMapMaxY(), getViewMinY(), getViewMaxY());
for (int i = 0; i < longitudeDrawingLineNumber && longitudeValue <= 180; i++) {
int pointIndexForAddingLabel = getPointLabelIndexForAddingLongitudeLabel(
longitudeCoordinatePointArrayList.get(i), zoomFactor,
getEffectiveMinX(), getEffectiveMaxX(), getEffectiveMinY(),
getEffectiveMaxY());
if (!(pointIndexForAddingLabel < 0)) {
addLabelOnLatLonLine(wireframeShapeForLonLineArray,
longitudeCoordinatePointArrayList.get(i),
pointIndexForAddingLabel,
String.valueOf((int) longitudeValue));
Geometry lonLine = longitudeLineGeometries.get(longitudeValue);
if (lonLine != null) {
wireframeShapeForLonLineArray.clearLabels();
if (lonLine.intersects(effectiveBottomBorder)) {
Coordinate intersection = effectiveBottomBorder
.intersection(lonLine).getCoordinate();
int lonInt = (int) longitudeValue;
String label = Math.abs(lonInt) != 180 ? String
.valueOf(lonInt) : "ID";
wireframeShapeForLonLineArray.clearLabels();
wireframeShapeForLonLineArray.addLabel(label, new double[] {
intersection.x, intersection.y - labelGap });
}
}
target.drawWireframeShape(wireframeShapeForLonLineArray,
latLonOverlayResourceData.getColor(),
@ -234,22 +253,27 @@ public class LatLonOverlayResource extends
lfont.dispose();
}
private void addLabelOnLatLonLine(IWireframeShape wireframeShape,
Coordinate[] coordinateArray, int coordiantePointIndex, String label) {
double[] tmp = { coordinateArray[coordiantePointIndex].x,
coordinateArray[coordiantePointIndex].y };
double[] screenPixel = descriptor.worldToPixel(tmp);
if (screenPixel != null) {
wireframeShape.clearLabels();
wireframeShape.addLabel(label, screenPixel);
}
}
private void initializeMapMinAndMaxXAndY() {
mapMinX = descriptor.getGridGeometry().getGridRange().getLow(0);
mapMaxX = descriptor.getGridGeometry().getGridRange().getHigh(0);
mapMinY = descriptor.getGridGeometry().getGridRange().getLow(1);
mapMaxY = descriptor.getGridGeometry().getGridRange().getHigh(1);
double mapMidX = (mapMaxX - mapMinX) / 2;
double mapMidY = (mapMaxY - mapMinY) / 2;
mapMedianLine = new GeometryFactory()
.createLineString(new Coordinate[] {
new Coordinate(mapMidX, mapMinY),
new Coordinate(mapMidX, mapMidY) });
// Map boundary must be created in a continuous coordinate order to form
// a rectangle!
mapBoundary = new GeometryFactory().createPolygon(
new GeometryFactory().createLinearRing(new Coordinate[] {
new Coordinate(mapMinX, mapMinY),
new Coordinate(mapMinX, mapMaxY),
new Coordinate(mapMaxX, mapMaxY),
new Coordinate(mapMaxX, mapMinY),
new Coordinate(mapMinX, mapMinY) }), null);
}
private void initializeViewMinAndMaxXAndY(PaintProperties paintProps) {
@ -258,129 +282,48 @@ public class LatLonOverlayResource extends
viewMinY = paintProps.getView().getExtent().getMinY();
viewMaxY = paintProps.getView().getExtent().getMaxY();
effectiveMinX = viewMinX;
effectiveMaxX = viewMaxX;
effectiveMinY = viewMinY;
effectiveMaxY = viewMaxY;
updateEffectiveView();
}
private void updateEffectiveMinX(double mapMinXValue, double viewMinXValue,
double viewMaxXValue) {
if (isLeftEdgeOfMapInsideCurrentView(mapMinXValue, viewMinXValue,
viewMaxXValue)) {
effectiveMinX = mapMinXValue;
private void updateEffectiveView() {
double effectiveMinX = viewMinX;
double effectiveMaxX = viewMaxX;
double effectiveMinY = viewMinY;
double effectiveMaxY = viewMaxY;
if (mapMinX > viewMinX && mapMinX < viewMaxX) {
effectiveMinX = mapMinX;
}
}
private boolean isLeftEdgeOfMapInsideCurrentView(double minXOfMap,
double minXOfCurrentView, double maxXOfCurrentView) {
boolean isInsideResult = false;
if (minXOfMap > minXOfCurrentView && minXOfMap < maxXOfCurrentView)
isInsideResult = true;
return isInsideResult;
}
private void updateEffectiveMaxY(double mapMaxYValue, double viewMinYValue,
double viewMaxYValue) {
if (isBottomEdgeOfMapInsideCurrentView(mapMaxYValue, viewMinYValue,
viewMaxYValue))
effectiveMaxY = mapMaxYValue;
}
private boolean isBottomEdgeOfMapInsideCurrentView(double maxYOfMap,
double minYOfCurrentView, double maxYOfCurrentView) {
boolean isInsideResult = false;
if (maxYOfMap > minYOfCurrentView && maxYOfMap < maxYOfCurrentView) {
isInsideResult = true;
if (mapMaxX > viewMinX && mapMaxX < viewMaxX) {
effectiveMaxX = mapMaxX;
}
return isInsideResult;
}
private int getPointLabelIndexForAddingLongitudeLabel(
Coordinate[] latLonCoordinateArray, float zoomFactor, double minX,
double maxX, double minY, double maxY) {
int pointIndex = -1;
if (latLonCoordinateArray == null || latLonCoordinateArray.length == 0)
return pointIndex;
double positionOffset = 120;
for (int i = 0; i < latLonCoordinateArray.length; i++) {
double[] tmp = { latLonCoordinateArray[i].x,
latLonCoordinateArray[i].y };
double[] screenPixel = descriptor.worldToPixel(tmp);
if (isPointForPlacingLongituteLabel(screenPixel, positionOffset,
zoomFactor, minX, maxX, minY, maxY)) {
pointIndex = i;
break;
}
if (mapMinY > viewMinY && mapMinY < viewMaxY) {
effectiveMinY = mapMinY;
}
return pointIndex;
}
private int getPointLabelIndexForAddingLatitudeLabel(
Coordinate[] latLonCoordinateArray, float zoomFactor, double minX,
double maxX, double minY, double maxY) {
int pointIndex = -1;
if (latLonCoordinateArray == null || latLonCoordinateArray.length == 0)
return pointIndex;
double positionOffset = 120;
for (int i = 0; i < latLonCoordinateArray.length; i++) {
double[] tmp = { latLonCoordinateArray[i].x,
latLonCoordinateArray[i].y };
double[] screenPixel = descriptor.worldToPixel(tmp);
if (isPointForPlacingLatituteLabel(screenPixel, positionOffset,
zoomFactor, minX, maxX, minY, maxY)) {
pointIndex = i;
break;
}
if (mapMaxY > viewMinY && mapMaxY < viewMaxY) {
effectiveMaxY = mapMaxY;
}
return pointIndex;
}
private void addDefaultLabelByPointIndex(IWireframeShape wireframeShape,
String labelValue, Coordinate[] latLonCoordinateArray,
int defaultPointIndex) {
double[] tmp = { latLonCoordinateArray[defaultPointIndex].x,
latLonCoordinateArray[defaultPointIndex].y };
double[] screenPixel = descriptor.worldToPixel(tmp);
if (screenPixel != null)
wireframeShape.addLabel(labelValue, screenPixel);
}
private boolean isPointForPlacingLongituteLabel(double[] pixelValueArray,
double positionOffset, float zoomFactor, double minX, double maxX,
double minY, double maxY) {
double delta = 200;
boolean isPointForLabel = false;
if (pixelValueArray != null) {
if (pixelValueArray[0] > minX && pixelValueArray[0] < maxX
&& pixelValueArray[1] > minY && pixelValueArray[1] < maxY) {
if (Math.abs(pixelValueArray[1] - maxY) < delta) {
isPointForLabel = true;
}
}
}
return isPointForLabel;
}
private boolean isPointForPlacingLatituteLabel(double[] pixelValueArray,
double positionOffset, float zoomFactor, double minX, double maxX,
double minY, double maxY) {
double delta = 200;
double adjustedOffset = positionOffset * zoomFactor;
boolean isPointForLabel = false;
if (pixelValueArray != null) {
if (pixelValueArray[0] > (minX + adjustedOffset)
&& pixelValueArray[0] < maxX && pixelValueArray[1] > minY
&& pixelValueArray[1] < maxY) {
if (Math.abs(pixelValueArray[0] - minX
- (positionOffset * zoomFactor)) < delta) {
isPointForLabel = true;
}
}
}
return isPointForLabel;
double cornerGap = 2.5 * labelGap;
Coordinate[] leftBorderCoordinates = new Coordinate[] {
new Coordinate(effectiveMinX, effectiveMinY + cornerGap),
new Coordinate(effectiveMinX, effectiveMaxY - cornerGap) };
Coordinate[] rightBorderCoordinates = new Coordinate[] {
new Coordinate(effectiveMaxX, effectiveMinY + cornerGap),
new Coordinate(effectiveMaxX, effectiveMaxY - cornerGap) };
Coordinate[] bottomBorderCoordinates = new Coordinate[] {
new Coordinate(effectiveMinX + cornerGap, effectiveMaxY),
new Coordinate(effectiveMaxX - cornerGap, effectiveMaxY) };
Coordinate[] topBorderCoordinates = new Coordinate[] {
new Coordinate(effectiveMinX + cornerGap, effectiveMinY),
new Coordinate(effectiveMaxX - cornerGap, effectiveMinY) };
effectiveLeftBorder = new GeometryFactory()
.createLineString(leftBorderCoordinates);
effectiveRightBorder = new GeometryFactory()
.createLineString(rightBorderCoordinates);
effectiveBottomBorder = new GeometryFactory()
.createLineString(bottomBorderCoordinates);
effectiveTopBorder = new GeometryFactory()
.createLineString(topBorderCoordinates);
}
private int getLatitudeDrawingLineNumber(int latInterval) {
@ -402,28 +345,54 @@ public class LatLonOverlayResource extends
return lonLineNumber + 1;
}
private Coordinate[] createCoordinateArrayForLatitudeLine(
private double[][] createCoordinateArrayForLatitudeLine(
double latitudeValue, double latLonPointInterval) {
int coordinateArrayLength = (int) (360 / latLonPointInterval) + 1;
Coordinate[] coordinateArray = new Coordinate[coordinateArrayLength];
ArrayList<Coordinate> latLineCoordinates = new ArrayList<Coordinate>(
coordinateArrayLength);
ArrayList<double[]> latLinePixels = new ArrayList<double[]>(
coordinateArrayLength);
double longitude = -180;
for (int i = 0; i < coordinateArray.length && longitude <= 180; i++) {
coordinateArray[i] = new Coordinate(longitude, latitudeValue);
for (int i = 0; i < coordinateArrayLength && longitude <= 180; i++) {
double[] latLon = new double[] { longitude, latitudeValue };
double[] screenPixel = descriptor.worldToPixel(latLon);
if (screenPixel != null) {
latLinePixels.add(screenPixel);
latLineCoordinates.add(new Coordinate(screenPixel[0],
screenPixel[1]));
}
longitude += latLonPointInterval;
}
return coordinateArray;
if (!latLineCoordinates.isEmpty())
latitudeLineGeometries.put(latitudeValue, new GeometryFactory()
.createLineString(latLineCoordinates
.toArray(new Coordinate[] {})));
return latLinePixels.toArray(new double[][] {});
}
private Coordinate[] createCoordinateArrayLongitudeLine(
private double[][] createCoordinateArrayLongitudeLine(
double longitudeValue, double latLonPointInterval) {
int coordinateArrayLength = (int) ((180 - 10) / latLonPointInterval);
Coordinate[] coordinateArray = new Coordinate[coordinateArrayLength];
ArrayList<Coordinate> lonLineCoordinates = new ArrayList<Coordinate>(
coordinateArrayLength);
ArrayList<double[]> lonLinePixels = new ArrayList<double[]>(
coordinateArrayLength);
double latitude = -90 + latLonPointInterval;
for (int i = 0; i < coordinateArray.length && latitude <= 90; i++) {
coordinateArray[i] = new Coordinate(longitudeValue, latitude);
for (int i = 0; i < coordinateArrayLength && latitude <= 90; i++) {
double[] latLon = new double[] { longitudeValue, latitude };
double[] screenPixel = descriptor.worldToPixel(latLon);
if (screenPixel != null) {
lonLinePixels.add(screenPixel);
lonLineCoordinates.add(new Coordinate(screenPixel[0],
screenPixel[1]));
}
latitude += latLonPointInterval;
}
return coordinateArray;
if (!lonLineCoordinates.isEmpty())
longitudeLineGeometries.put(longitudeValue, new GeometryFactory()
.createLineString(lonLineCoordinates
.toArray(new Coordinate[] {})));
return lonLinePixels.toArray(new double[][] {});
}
/*
@ -432,9 +401,8 @@ public class LatLonOverlayResource extends
* @see com.raytheon.viz.core.rsc.IVizResource#dispose()
*/
public void disposeInternal() {
// clearWireFrameShapeArray(wireframeShapeForLatLineArray);
// clearWireFrameShapeArray(wireframeShapeForLonLineArray);
clearWireFrameShapeArray(wireframeShapeForLatLineArray);
clearWireFrameShapeArray(wireframeShapeForLonLineArray);
}
private void clearWireFrameShapeArray(IWireframeShape wireframeShapeArray) {
@ -444,16 +412,6 @@ public class LatLonOverlayResource extends
}
}
private void clearCoordinatePointArrayList(
List<Coordinate[]> coordinatePointArrayList) {
if (coordinatePointArrayList != null) {
for (Coordinate[] eachCoordinateArray : coordinatePointArrayList) {
eachCoordinateArray = null;
}
coordinatePointArrayList = null;
}
}
/*
* the getters for Map's Min and Max X and Y, View's Min and Max X and Y
*/
@ -489,22 +447,6 @@ public class LatLonOverlayResource extends
return mapMaxX;
}
public double getEffectiveMinX() {
return effectiveMinX;
}
public double getEffectiveMaxY() {
return effectiveMaxY;
}
public double getEffectiveMinY() {
return effectiveMinY;
}
public double getEffectiveMaxX() {
return effectiveMaxX;
}
// @Override
public void resourceAttrsModified() {
needsUpdate = true;
@ -515,9 +457,9 @@ public class LatLonOverlayResource extends
return true;
}
// TODO : This has not been tested.
@Override
public void project(CoordinateReferenceSystem mapData) throws VizException {
needsUpdate = true;
initializeMapMinAndMaxXAndY();
}
}

View file

@ -59,6 +59,7 @@ import com.raytheon.uf.viz.core.exception.VizException;
* 09/15/2014 B. Hebbard At CPC request, persist model selected across dialog close/open
* even if resource not preselected (from existing RBD contents).
* (This now differs from non-NTRANS behavior.)
* 09/15/2014 B. Hebbard Remove bogus "km" from product group name if it appears (per CPC)
*
* </pre>
*
@ -771,6 +772,23 @@ public class NtransSelectionControl extends ResourceSelectionControl {
}
});
productLViewer.setLabelProvider(new LabelProvider() {
public String getText(Object element) {
String productName = (String) element;
// TODO investigate following -- already fixed separately?
// This happens intermittently; band-aid until cause located...
final String removeMe = "km";
if (productName.endsWith(removeMe)) {
System.out
.println("[WARNING: Caught a productName ending in '"
+ removeMe + "']");
return productName.substring(0, productName.length() - 2);
} else {
return productName;
}
}
});
rscAttrSetLViewer.setContentProvider(new IStructuredContentProvider() {
@Override
public Object[] getElements(Object inputElement) {

View file

@ -8,7 +8,6 @@ import gov.noaa.nws.ncep.viz.resources.manager.ResourceName;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtension;
@ -19,9 +18,10 @@ import org.eclipse.swt.graphics.RGB;
import com.raytheon.uf.viz.core.IGraphicsTarget.LineStyle;
import com.raytheon.uf.viz.core.exception.VizException;
/**
*
*
*
* <pre>
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
@ -34,382 +34,439 @@ import com.raytheon.uf.viz.core.exception.VizException;
* 01/15/12 #606 Greg Hull add resource parameters
* 04/19/12 #606 Greg Hull add attributeName attribute for resource parameters
* 04/23/12 #606 Greg Hull add ConditionalFilter as a shortcut for the classname.
*
* - - S.Gurung Code formatter changes only
* </pre>
*
* @author
* @author
* @version 1
*/
public class ResourceExtPointMngr {
private static final String NC_RESOURCE_EXT = "gov.noaa.nws.ncep.viz.resources.NC-Resource";
private static final String RESOURCE_NAME_TAG = "name";
private static final String RESOURCE_NAME_TAG = "name";
private static final String RESOURCE_CLASS_TAG = "class";
private static final String EDIT_DLG_CLASS_TAG = "editDialogClass";
private static final String NC_RESOURCE_PARAMS_EXT = "gov.noaa.nws.ncep.viz.resources.NC-ResourceParameter";
private static final String RESOURCE_NAME_REF_TAG = "ncResourceName";
private static final String RSC_PARAM_ELEMENT_NAME = "nc-resourceParameter";
private static final String PARAM_TYPE_TAG = "paramType";
private static final String PARAM_NAME_TAG = "paramName";
private static final String ATTR_NAME_TAG = "attributeName";
private static final String PARAM_NAME_TAG = "paramName";
private static final String ATTR_NAME_TAG = "attributeName";
private static final String PARAM_CLASS_TAG = "paramClass";
private static final String CONSTRAINT_NAME_TAG = "constraintName";
// private static final String PARAM_REF_LOC_TAG = "paramRefLocation";
// private static final String PARAM_REF_LOC_TAG = "paramRefLocation";
private static final String DFLT_VAL_TAG = "defaultValue";
public static enum ResourceParamType {
EDITABLE_ATTRIBUTE("EDITABLE_ATTRIBUTE"),
IMPLEMENTATION_PARAM("IMPLEMENTATION_PARAM"), // used to instantiate the ResourceImplementation
REQUEST_CONSTRAINT("REQUEST_CONSTRAINT"), // instantiates a Resource Implementation and also used as a request constraint
NON_EDITABLE_ATTRIBUTE("NON_EDITABLE_ATTRIBUTE");
private String name;
private ResourceParamType( String n ) {
name = n;
}
public static ResourceParamType getResourceParamType( String n ) {
if( n.equalsIgnoreCase( REQUEST_CONSTRAINT.name ) ) {
return REQUEST_CONSTRAINT;
}
else if( n.equalsIgnoreCase( EDITABLE_ATTRIBUTE.name ) ) {
return EDITABLE_ATTRIBUTE;
}
else if( n.equalsIgnoreCase( NON_EDITABLE_ATTRIBUTE.name ) ) {
return NON_EDITABLE_ATTRIBUTE;
}
else if( n.equalsIgnoreCase( IMPLEMENTATION_PARAM.name ) ) {
return IMPLEMENTATION_PARAM;
}
return IMPLEMENTATION_PARAM;
}
EDITABLE_ATTRIBUTE("EDITABLE_ATTRIBUTE"), IMPLEMENTATION_PARAM(
"IMPLEMENTATION_PARAM"), // used to instantiate the
// ResourceImplementation
REQUEST_CONSTRAINT("REQUEST_CONSTRAINT"), // instantiates a Resource
// Implementation and also
// used as a request
// constraint
NON_EDITABLE_ATTRIBUTE("NON_EDITABLE_ATTRIBUTE");
private String name;
private ResourceParamType(String n) {
name = n;
}
public static ResourceParamType getResourceParamType(String n) {
if (n.equalsIgnoreCase(REQUEST_CONSTRAINT.name)) {
return REQUEST_CONSTRAINT;
} else if (n.equalsIgnoreCase(EDITABLE_ATTRIBUTE.name)) {
return EDITABLE_ATTRIBUTE;
} else if (n.equalsIgnoreCase(NON_EDITABLE_ATTRIBUTE.name)) {
return NON_EDITABLE_ATTRIBUTE;
} else if (n.equalsIgnoreCase(IMPLEMENTATION_PARAM.name)) {
return IMPLEMENTATION_PARAM;
}
return IMPLEMENTATION_PARAM;
}
}
public static class ResourceParamInfo {
private String paramName;
private String constraintName; // usually the same as the paramName except for
// GDFILE which is modelName
// the name of the member variable in the java resourceData class.
// This will default to the paramName which will be the case for everything
// except the Grid resource which will be the same except lower case.
//
private String attributeName;
private Class<?> paramClass;
private ResourceParamType paramType;
private String paramName;
private String dfltVal; // not implemented
// private String paramRefLocation; // for ref'd colorBars
private String constraintName; // usually the same as the paramName
// except for
// GDFILE which is modelName
ResourceParamInfo( String n, String c, String a, Class<?> clz, ResourceParamType ptype,
String dval ) { //, String prmRefLoc) {
paramName = n;
constraintName = c;
attributeName = a;
paramClass = clz;
paramType = ptype;
dfltVal = dval;
// paramRefLocation = prmRefLoc;
}
public String getParamName() {
return paramName;
}
public String getConstraintName() {
return constraintName;
}
public String getAttributeName() {
return attributeName;
}
public Class<?> getParamClass() {
return paramClass;
}
public ResourceParamType getParamType() {
return paramType;
}
public String getDefaultValue() {
return dfltVal;
}
// the name of the member variable in the java resourceData class.
// This will default to the paramName which will be the case for
// everything
// except the Grid resource which will be the same except lower case.
//
private String attributeName;
private Class<?> paramClass;
private ResourceParamType paramType;
private String dfltVal; // not implemented
// private String paramRefLocation; // for ref'd colorBars
ResourceParamInfo(String n, String c, String a, Class<?> clz,
ResourceParamType ptype, String dval) { // , String prmRefLoc) {
paramName = n;
constraintName = c;
attributeName = a;
paramClass = clz;
paramType = ptype;
dfltVal = dval;
// paramRefLocation = prmRefLoc;
}
public String getParamName() {
return paramName;
}
public String getConstraintName() {
return constraintName;
}
public String getAttributeName() {
return attributeName;
}
public Class<?> getParamClass() {
return paramClass;
}
public ResourceParamType getParamType() {
return paramType;
}
public String getDefaultValue() {
return dfltVal;
}
}
private static class ResourceExtPointInfo {
String rscName; //
Class<?> rscDataClass;
Class<?> rscDialogClass;
HashMap<String, ResourceParamInfo> rscParameters = null;
ResourceExtPointInfo( String name, Class<?> rcls, Class<?> rdlgcls) {
rscName = new String( name );
rscParameters = new HashMap<String, ResourceParamInfo>();
rscDataClass = rcls;
rscDialogClass = rdlgcls;
}
void addParameter( String prmName, String cName, String aName,
Class<?> prmClass, ResourceParamType pType, String dflt) { // , Object dfltVal ) {
String rscName; //
rscParameters.put( prmName,
new ResourceParamInfo( prmName, cName, aName, prmClass, pType, dflt ) );
}
Class<?> rscDataClass;
Class<?> rscDialogClass;
HashMap<String, ResourceParamInfo> rscParameters = null;
ResourceExtPointInfo(String name, Class<?> rcls, Class<?> rdlgcls) {
rscName = new String(name);
rscParameters = new HashMap<String, ResourceParamInfo>();
rscDataClass = rcls;
rscDialogClass = rdlgcls;
}
void addParameter(String prmName, String cName, String aName,
Class<?> prmClass, ResourceParamType pType, String dflt) { // ,
// Object
// dfltVal
// )
// {
rscParameters.put(prmName, new ResourceParamInfo(prmName, cName,
aName, prmClass, pType, dflt));
}
}
// map from the resource name to the resource info containing the rscData class,
// the class that implements the edit dialog and a list of attributes from the
// map from the resource name to the resource info containing the rscData
// class,
// the class that implements the edit dialog and a list of attributes from
// the
// attribute extension points
//
static HashMap<String, ResourceExtPointInfo> rscExtPointInfoMap = null;
static ResourceExtPointMngr instance = null;
public static ResourceExtPointMngr getInstance() {
if( instance == null ) {
instance = new ResourceExtPointMngr();
}
else if( instance.rscExtPointInfoMap.size() == 0 ) {
instance = new ResourceExtPointMngr();
}
return instance;
if (instance == null) {
instance = new ResourceExtPointMngr();
} else if (instance.rscExtPointInfoMap.size() == 0) {
instance = new ResourceExtPointMngr();
}
return instance;
}
private ResourceExtPointMngr() {
rscExtPointInfoMap = new HashMap<String, ResourceExtPointInfo>();
rscExtPointInfoMap = new HashMap<String, ResourceExtPointInfo>();
readResourceExpPoint();
readResourceParameterssExtPoint();
}
private static void readResourceExpPoint( ) {
private static void readResourceExpPoint() {
IExtensionRegistry registry = Platform.getExtensionRegistry();
IExtensionPoint extPoint = registry.getExtensionPoint( NC_RESOURCE_EXT );
if( extPoint == null ) {
System.out.println("Unable to get Extension Point : " + NC_RESOURCE_EXT );
return;
IExtensionPoint extPoint = registry.getExtensionPoint(NC_RESOURCE_EXT);
if (extPoint == null) {
System.out.println("Unable to get Extension Point : "
+ NC_RESOURCE_EXT);
return;
}
IExtension[] extensions = extPoint.getExtensions();
for( int i = 0; i < extensions.length; i++ ) {
IConfigurationElement[] config = extensions[i].getConfigurationElements();
for (int i = 0; i < extensions.length; i++) {
IConfigurationElement[] config = extensions[i]
.getConfigurationElements();
for( int j = 0; j < config.length; j++ ) {
String rscName = config[j].getAttribute(RESOURCE_NAME_TAG);
String rscClassName = config[j].getAttribute(RESOURCE_CLASS_TAG);
String editDlgClassName = config[j].getAttribute(EDIT_DLG_CLASS_TAG);
for (int j = 0; j < config.length; j++) {
String rscName = config[j].getAttribute(RESOURCE_NAME_TAG);
String rscClassName = config[j]
.getAttribute(RESOURCE_CLASS_TAG);
String editDlgClassName = config[j]
.getAttribute(EDIT_DLG_CLASS_TAG);
if( rscClassName == null ) {
System.out.println( " "+rscClassName );
continue;
if (rscClassName == null) {
System.out.println(" " + rscClassName);
continue;
}
// for now this is optional since we can have NC resources that do not have
// for now this is optional since we can have NC resources that
// do not have
// editable attributes.
if( editDlgClassName == null ) {
continue;
if (editDlgClassName == null) {
continue;
}
IConfigurationElement[] fields = config[j].getChildren();
Class<?> rscClass = null;
Class<?> editDlgClass = null;
try {
rscClass = Class.forName( rscClassName );
editDlgClass = Class.forName( editDlgClassName );
rscExtPointInfoMap.put( rscName,
new ResourceExtPointInfo( rscName, rscClass, editDlgClass ) );
} catch ( ClassNotFoundException e ) {
System.out.println("Unable to load class "+rscClassName +" or "+ editDlgClassName );
rscClass = Class.forName(rscClassName);
editDlgClass = Class.forName(editDlgClassName);
rscExtPointInfoMap.put(rscName, new ResourceExtPointInfo(
rscName, rscClass, editDlgClass));
} catch (ClassNotFoundException e) {
System.out.println("Unable to load class " + rscClassName
+ " or " + editDlgClassName);
}
}
}
}
// init the resourceAttrsMap from the NC-ResourceAttributes ext point
private static void readResourceParameterssExtPoint( ) {
// init the resourceAttrsMap from the NC-ResourceAttributes ext point
private static void readResourceParameterssExtPoint() {
IExtensionRegistry registry = Platform.getExtensionRegistry();
IExtensionPoint extPoint = registry.getExtensionPoint( NC_RESOURCE_PARAMS_EXT );
if( extPoint == null ) {
System.out.println("Unable to get Extension Point : "+ NC_RESOURCE_PARAMS_EXT );
return;
IExtensionPoint extPoint = registry
.getExtensionPoint(NC_RESOURCE_PARAMS_EXT);
if (extPoint == null) {
System.out.println("Unable to get Extension Point : "
+ NC_RESOURCE_PARAMS_EXT);
return;
}
IExtension[] extensions = extPoint.getExtensions();
for( int i = 0; i < extensions.length; i++ ) {
IConfigurationElement[] config = extensions[i].getConfigurationElements();
for( int j = 0; j < config.length; j++ ) {
if( config[j].getName().equalsIgnoreCase( RSC_PARAM_ELEMENT_NAME ) ) {
String rscName = config[j].getAttribute(RESOURCE_NAME_REF_TAG);
String prmName = config[j].getAttribute(PARAM_NAME_TAG);
String attrName = config[j].getAttribute(ATTR_NAME_TAG);
String prmClassName = config[j].getAttribute(PARAM_CLASS_TAG);
String constraintName = config[j].getAttribute(CONSTRAINT_NAME_TAG);
String prmType = config[j].getAttribute(PARAM_TYPE_TAG);
String dfltVal = config[j].getAttribute(DFLT_VAL_TAG);
// String refLoc = config[j].getAttribute(PARAM_REF_LOC_TAG);
// sanity check ; these are required
if( rscName == null || prmName == null || prmClassName == null || prmType == null) {
System.out.println( "Invalid Extension of Ext Point: "+ NC_RESOURCE_PARAMS_EXT );
continue;
}
for (int i = 0; i < extensions.length; i++) {
IConfigurationElement[] config = extensions[i]
.getConfigurationElements();
// then test for one of the standard types or classes.
//
prmClassName = getFullClassName( prmClassName );
for (int j = 0; j < config.length; j++) {
if (config[j].getName()
.equalsIgnoreCase(RSC_PARAM_ELEMENT_NAME)) {
String rscName = config[j]
.getAttribute(RESOURCE_NAME_REF_TAG);
String prmName = config[j].getAttribute(PARAM_NAME_TAG);
String attrName = config[j].getAttribute(ATTR_NAME_TAG);
String prmClassName = config[j]
.getAttribute(PARAM_CLASS_TAG);
String constraintName = config[j]
.getAttribute(CONSTRAINT_NAME_TAG);
String prmType = config[j].getAttribute(PARAM_TYPE_TAG);
String dfltVal = config[j].getAttribute(DFLT_VAL_TAG);
// String refLoc =
// config[j].getAttribute(PARAM_REF_LOC_TAG);
ResourceExtPointInfo repi = rscExtPointInfoMap.get( rscName );
// sanity check ; these are required
if (rscName == null || prmName == null
|| prmClassName == null || prmType == null) {
System.out.println("Invalid Extension of Ext Point: "
+ NC_RESOURCE_PARAMS_EXT);
continue;
}
if( repi == null ) {
System.out.println("Error reading "+NC_RESOURCE_PARAMS_EXT + " Ext Point: The Resource " +
rscName + " is not defined." );
continue;
}
// then test for one of the standard types or classes.
//
prmClassName = getFullClassName(prmClassName);
if( constraintName == null ) {
constraintName = prmName;
}
// this only exists for Grids where the parameter name is upper case
// and the attribute name (ie the name of the member variable in the
// java class) is lowercase
//
if( attrName == null ) {
attrName = prmName;
}
try {
Class<?> rscPrmClass = Class.forName( prmClassName );
ResourceParamType rscPrmType = ResourceParamType.getResourceParamType( prmType );
repi.addParameter( prmName, constraintName, attrName,
rscPrmClass, rscPrmType, dfltVal );
} catch (ClassNotFoundException e) {
System.out.println("Unable to load class: "+prmClassName );
}
}
ResourceExtPointInfo repi = rscExtPointInfoMap.get(rscName);
if (repi == null) {
System.out.println("Error reading "
+ NC_RESOURCE_PARAMS_EXT
+ " Ext Point: The Resource " + rscName
+ " is not defined.");
continue;
}
if (constraintName == null) {
constraintName = prmName;
}
// this only exists for Grids where the parameter name is
// upper case
// and the attribute name (ie the name of the member
// variable in the
// java class) is lowercase
//
if (attrName == null) {
attrName = prmName;
}
try {
Class<?> rscPrmClass = Class.forName(prmClassName);
ResourceParamType rscPrmType = ResourceParamType
.getResourceParamType(prmType);
repi.addParameter(prmName, constraintName, attrName,
rscPrmClass, rscPrmType, dfltVal);
} catch (ClassNotFoundException e) {
System.out.println("Unable to load class: "
+ prmClassName);
}
}
}
}
}
}
public Class<?> getResourceDialogClass( ResourceName rscName ) {
// get the rsc Impl for this
String rscImplName = null;
public Class<?> getResourceDialogClass(ResourceName rscName) {
// get the rsc Impl for this
String rscImplName = null;
// if( rscCfgMngr == null ) {
try {
rscImplName = ResourceDefnsMngr.getInstance().getResourceImplementation( rscName.getRscType() );
} catch (VizException e) {
e.printStackTrace();
}
// }
// if( rscCfgMngr == null ) {
try {
rscImplName = ResourceDefnsMngr.getInstance()
.getResourceImplementation(rscName.getRscType());
} catch (VizException e) {
e.printStackTrace();
}
// }
ResourceExtPointInfo repi = rscExtPointInfoMap.get( rscImplName );
return ( repi == null ? null : repi.rscDialogClass );
}
ResourceExtPointInfo repi = rscExtPointInfoMap.get(rscImplName);
private static String getFullClassName( String clzName ) {
// then test for one of the standard types or classes.
//
if( clzName.equalsIgnoreCase( "Integer" )) {
return "java.lang.Integer";
} else if( clzName.equalsIgnoreCase( "Boolean" )) {
return "java.lang.Boolean";
} else if( clzName.equalsIgnoreCase( "Double" )) {
return "java.lang.Double";
} else if( clzName.equalsIgnoreCase( "Float" )) {
return "java.lang.Float";
} else if( clzName.equalsIgnoreCase( "String" )) {
return "java.lang.String";
} else if( clzName.equalsIgnoreCase( "RGB" )) {
return RGB.class.getName();
} else if( clzName.equalsIgnoreCase( "ArrowStyle" )) {
return "gov.noaa.nws.ncep.viz.rsc.ncscat.rsc.NcscatResourceData$ArrowStyle";
} else if( clzName.equalsIgnoreCase( "LineStyle" )) {
return LineStyle.class.getName();
} else if( clzName.equalsIgnoreCase( "MarkerState" )) {
return MarkerState.class.getName();
} else if( clzName.equalsIgnoreCase( "MarkerType" )) {
return MarkerType.class.getName();
} else if( clzName.equalsIgnoreCase( "MarkerTextSize" )) {
return MarkerTextSize.class.getName();
} else if( clzName.equalsIgnoreCase("PlotModel") ) {
return "gov.noaa.nws.ncep.viz.rsc.plotdata.plotModels.elements.PlotModel";
} else if( clzName.equalsIgnoreCase("ColorBar") ) {
return "gov.noaa.nws.ncep.viz.ui.display.ColorBar";
} else if( clzName.equalsIgnoreCase("conditionalFilter") ) {
return "gov.noaa.nws.ncep.viz.rsc.plotdata.conditionalfilter.ConditionalFilter";
}
return clzName;
}
// public String getResourceNameForClass( Class<?> rscDataClass ) {
// ResourceExtPointInfo repi = rscExtPointInfoMap.get( //rscDataClass );
//
// return ( repi == null ? null : repi.rscName );
// }
// public HashMap<String,ResourceAttrInfo> getResourceAttributes( ResourceName rscName ) {
// String rscImplName = null;
//
//// if( rscCfgMngr == null ) {
// try {
// rscImplName = ResourceDefnsMngr.getInstance().getResourceImplementation( rscName.getRscType() );
// } catch (VizException e) {
// e.printStackTrace();
// }
//// }
//
// ResourceExtPointInfo repi = rscExtPointInfoMap.get( rscImplName );
//
// return ( repi == null ? null : repi.rscAttributes );
// }
return (repi == null ? null : repi.rscDialogClass);
}
public HashMap<String,ResourceParamInfo> getParameterInfoForRscImplementation( ResourceName rscName ) {
try {
String rscImpl = ResourceDefnsMngr.getInstance().getResourceImplementation( rscName.getRscType() );
return getResourceParameters( rscImpl );
} catch (VizException e) {
e.printStackTrace();
return new HashMap<String,ResourceParamInfo>();
}
}
public HashMap<String,ResourceParamInfo> getResourceParameters( String rscImpl ) {
ResourceExtPointInfo repi = rscExtPointInfoMap.get( rscImpl );
return ( repi == null ? null : repi.rscParameters );
}
public ArrayList<String> getAvailResources( ) {
ArrayList<String> availResources = new ArrayList<String>();
for( ResourceExtPointInfo rscInfo : rscExtPointInfoMap.values() ) {
availResources.add( rscInfo.rscName );
}
return availResources;
}
public Class<?> getResourceDataClass( String rscName ) {
for( ResourceExtPointInfo rscInfo : rscExtPointInfoMap.values() ) {
if( rscInfo.rscName.equals( rscName ) ) {
return rscInfo.rscDataClass;
}
}
// if( rscExtPointInfoMap.containsKey( rscName ) ) {
// return rscExtPointInfoMap.get( rscName ).rscDataClass;
// }
return null;
}
private static String getFullClassName(String clzName) {
// then test for one of the standard types or classes.
//
if (clzName.equalsIgnoreCase("Integer")) {
return "java.lang.Integer";
} else if (clzName.equalsIgnoreCase("Boolean")) {
return "java.lang.Boolean";
} else if (clzName.equalsIgnoreCase("Double")) {
return "java.lang.Double";
} else if (clzName.equalsIgnoreCase("Float")) {
return "java.lang.Float";
} else if (clzName.equalsIgnoreCase("String")) {
return "java.lang.String";
} else if (clzName.equalsIgnoreCase("RGB")) {
return RGB.class.getName();
} else if (clzName.equalsIgnoreCase("ArrowStyle")) {
return "gov.noaa.nws.ncep.viz.rsc.ncscat.rsc.NcscatResourceData$ArrowStyle";
} else if (clzName.equalsIgnoreCase("LineStyle")) {
return LineStyle.class.getName();
} else if (clzName.equalsIgnoreCase("MarkerState")) {
return MarkerState.class.getName();
} else if (clzName.equalsIgnoreCase("MarkerType")) {
return MarkerType.class.getName();
} else if (clzName.equalsIgnoreCase("MarkerTextSize")) {
return MarkerTextSize.class.getName();
} else if (clzName.equalsIgnoreCase("PlotModel")) {
return "gov.noaa.nws.ncep.viz.rsc.plotdata.plotModels.elements.PlotModel";
} else if (clzName.equalsIgnoreCase("ColorBar")) {
return "gov.noaa.nws.ncep.viz.ui.display.ColorBar";
} else if (clzName.equalsIgnoreCase("conditionalFilter")) {
return "gov.noaa.nws.ncep.viz.rsc.plotdata.conditionalfilter.ConditionalFilter";
}
return clzName;
}
// public String getResourceNameForClass( Class<?> rscDataClass ) {
// ResourceExtPointInfo repi = rscExtPointInfoMap.get( //rscDataClass );
//
// return ( repi == null ? null : repi.rscName );
// }
// public HashMap<String,ResourceAttrInfo> getResourceAttributes(
// ResourceName rscName ) {
// String rscImplName = null;
//
// // if( rscCfgMngr == null ) {
// try {
// rscImplName = ResourceDefnsMngr.getInstance().getResourceImplementation(
// rscName.getRscType() );
// } catch (VizException e) {
// e.printStackTrace();
// }
// // }
//
// ResourceExtPointInfo repi = rscExtPointInfoMap.get( rscImplName );
//
// return ( repi == null ? null : repi.rscAttributes );
// }
public HashMap<String, ResourceParamInfo> getParameterInfoForRscImplementation(
ResourceName rscName) {
try {
String rscImpl = ResourceDefnsMngr.getInstance()
.getResourceImplementation(rscName.getRscType());
return getResourceParameters(rscImpl);
} catch (VizException e) {
e.printStackTrace();
return new HashMap<String, ResourceParamInfo>();
}
}
public HashMap<String, ResourceParamInfo> getResourceParameters(
String rscImpl) {
ResourceExtPointInfo repi = rscExtPointInfoMap.get(rscImpl);
return (repi == null ? null : repi.rscParameters);
}
public ArrayList<String> getAvailResources() {
ArrayList<String> availResources = new ArrayList<String>();
for (ResourceExtPointInfo rscInfo : rscExtPointInfoMap.values()) {
availResources.add(rscInfo.rscName);
}
return availResources;
}
public Class<?> getResourceDataClass(String rscName) {
for (ResourceExtPointInfo rscInfo : rscExtPointInfoMap.values()) {
if (rscInfo.rscName.equals(rscName)) {
return rscInfo.rscDataClass;
}
}
// if( rscExtPointInfoMap.containsKey( rscName ) ) {
// return rscExtPointInfoMap.get( rscName ).rscDataClass;
// }
return null;
}
}

View file

@ -30,6 +30,8 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TimeZone;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.measure.converter.ConversionException;
@ -119,6 +121,7 @@ import com.sun.jna.ptr.IntByReference;
* 11/2013 845 T. Lee Implemented parameter scaling
* 04/11/2014 981 D.Sushon Code cleanup, enforce explicit use of curly-brackets {}
* 04/14/2014 S. Gilbert Remove dataUri from query - cleanup old unused methods.
* 07/2014 T. Lee Fixed specific humidity scaling for NAM
* </pre>
*
* @author tlee
@ -1334,7 +1337,7 @@ public class Dgdriv {
outGridFlipped[kk] = -9999.0f;
kk++;
} else {
outGridFlipped[kk] = inGrid[ii] / scale_parm;
outGridFlipped[kk] = inGrid[ii];
kk++;
}
}
@ -1354,7 +1357,7 @@ public class Dgdriv {
if (inGrid[ii] < -900000.0) {
outGridFlipped[ii] = -9999.0f;
} else {
outGridFlipped[ii] = inGrid[ii] / scale_parm;
outGridFlipped[ii] = inGrid[ii];
}
}
@ -1405,8 +1408,6 @@ public class Dgdriv {
return outGridFlopped;
}
int scale_parm = 1;
private float[] retrieveDataFromRetriever(String dataURI)
throws VizException {
@ -1425,8 +1426,6 @@ public class Dgdriv {
try {
String gempakParm = cacheData.getGempakParam(dataURI);
if (gempakParm != null) {
scale_parm = (int) Math.pow(10,
gempakParmInfo.getParmScale(gempakParm));
dataRetriever.setUnit(UnitConv.deserializer(gempakParmInfo
.getParmUnit(gempakParm)));
}
@ -1750,8 +1749,8 @@ public class Dgdriv {
String modelName = parms[0];
String dbTag = parms[1];
String eventName = parms[2];
// String tmStr = constructTimeStr(parms[3]);
DataTime dtime = constructDataTime(parms[3]);
String tmStr = constructTimeStr(parms[3]);
Pattern p = Pattern.compile(tmStr);
// logger.info("executeScript:modelname=" + modelName + " dbTag=" +dbTag
// + " eventName="+eventName + " time=" + tmStr);
@ -1765,9 +1764,15 @@ public class Dgdriv {
eventName, ConstraintType.EQUALS));
}
rcMap.put(GridDBConstants.DATA_TIME_QUERY,
new RequestConstraint(dtime.getURIString(),
ConstraintType.EQUALS));
try {
String gempakTimeStrFFF = parms[3].split("f")[1];
int fhr = Integer.parseInt(gempakTimeStrFFF) * 3600;
rcMap.put(GridDBConstants.FORECAST_TIME_QUERY,
new RequestConstraint(Integer.toString(fhr),
ConstraintType.EQUALS));
} catch (NumberFormatException e1) {
// Don't worry if fcsthr not specified. we'll get em all
}
DbQueryRequest request = new DbQueryRequest();
request.addRequestField(GridDBConstants.REF_TIME_QUERY);
@ -1775,6 +1780,8 @@ public class Dgdriv {
request.setDistinct(true);
request.setConstraints(rcMap);
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHH");
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
String retFileNames = "";
try {
DbQueryResponse response = (DbQueryResponse) ThriftClient
@ -1796,6 +1803,14 @@ public class Dgdriv {
GridDBConstants.REF_TIME_QUERY);
if (fSecValue != null && fSecValue instanceof Integer
&& refValue != null && refValue instanceof Date) {
String refString = sdf.format((Date) refValue);
logger.debug("executeScript: match " + refString);
logger.debug("executeScript: with " + tmStr);
Matcher m = p.matcher(refString);
if (!m.matches())
continue;
int fcstTimeInSec = ((Integer) fSecValue).intValue();
DataTime refTime = new DataTime((Date) refValue);
String[] dts = refTime.toString().split(" ");
@ -1822,57 +1837,20 @@ public class Dgdriv {
return retFileNames;
}
/*
* Convert Gempak time string YYMMDD/HHMMfHHH to DataTime
*/
private DataTime constructDataTime(String gempakTimeStr) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd/HH");
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
String[] times = gempakTimeStr.split("f");
DataTime dt;
try {
Date date = sdf.parse(times[0]);
int fcstTimeInSec = CommonDateFormatUtil
.getForecastTimeInSec(gempakTimeStr);
dt = new DataTime(date, fcstTimeInSec);
} catch (Exception e) {
dt = null;
private String constructTimeStr(String gempakTimeStr) {
String gempakTimeStrCycle = gempakTimeStr.split("f")[0];
gempakTimeStrCycle = gempakTimeStrCycle.replace("[0-9]", ".");
if (gempakTimeStrCycle.length() < 10) {
return null;
}
return dt;
String timeStr = gempakTimeStrCycle.substring(0, 4)
+ gempakTimeStrCycle.substring(4, 6)
+ gempakTimeStrCycle.substring(6, 8)
+ gempakTimeStrCycle.substring(8, 10);
return timeStr;
}
// private String constructTimeStr(String gempakTimeStr) {
// String gempakTimeStrCycle = gempakTimeStr.split("f")[0];
// gempakTimeStrCycle = gempakTimeStrCycle.replace("[0-9]", "%");
// if (gempakTimeStrCycle.length() < 10) {
// return null;
// }
//
// String gempakTimeStrFFF = gempakTimeStr.split("f")[1];
// gempakTimeStrFFF = gempakTimeStrFFF.replace("[0-9]", "%");
//
// String timeStr;
// try {
// int fhr = Integer.parseInt(gempakTimeStrFFF) / 3600;
//
// timeStr = gempakTimeStrCycle.substring(0, 4) + "-"
// + gempakTimeStrCycle.substring(4, 6) + "-"
// + gempakTimeStrCycle.substring(6, 8) + "_"
// + gempakTimeStrCycle.substring(8, 10) + "%_(" + fhr + ")%";
// } catch (NumberFormatException e) {
// timeStr = gempakTimeStrCycle.substring(0, 4) + "-"
// + gempakTimeStrCycle.substring(4, 6) + "-"
// + gempakTimeStrCycle.substring(6, 8) + "_"
// + gempakTimeStrCycle.substring(8, 10) + "%_("
// + gempakTimeStrFFF;
// }
// return timeStr;
// }
private String getDataURIFromAssembler(String parameters)
throws VizException {
long t0 = System.currentTimeMillis();

View file

@ -0,0 +1,28 @@
ncgm -- Computer Graphics Metafile interpreter and renderer
See also the other README.TXT, in sibling "jcgm" package.
This package contains classes which extend a limited subset of the classes
in the "jcgm" package.
(For more information about "jcgm", see: http://jcgm.sourceforge.net)
The key classes here are...
NcCGM (extends jcgm's CGM):
Builds (via NcCGM.read(DataInput)) and holds (as an ordered list
of "commands") a Java representation of a single CGM image.
NcCommand (extends jcgm's Command):
Builds (via *static* NcCommand.read(DataInput)) and returns
a single CGM command. The readCommand() method has been modified
from the jcgm original to "know" which commands have extensions
in ncgm, and to create them instead of the base jcgm versions.
INcCommand:
Interface whose implementation enables these ncgm extended
commands to know how to contribute themselves to an AWIPS II
image.
An AWIPS II image is constructed in an ImageBuilder object, by sequential
"execution" of these CGM commands.
We only extend the "jcgm" commands that are of interest to NTRANS. Any others
(if somehow encountered in an input metafile) will simply be ignored.

View file

@ -72,7 +72,7 @@ import com.raytheon.viz.pointdata.PointDataRequest;
* 04/01/2014 1040 B. Hebbard In requestUpperAirData, (1) clear displayStationPlotBoolList for each new station, (2) call cond filter check with newInstance vs. metPrm
* 04/08/2014 1127 B. Hebbard In requestSurfaceData, exclude only those obs returned from HDF5 that don't match desired time; fix dataTime association;
* removed redundant datatimes from constraint.
* 06/17/2014 932 S. Russell TTR 923, altered methods addToDerivedParamsList(), requestSurfaceData(), and newInstance()
* 06/17/2014 923 S. Russell TTR 923, altered methods addToDerivedParamsList(), requestSurfaceData(), and newInstance()
* 07/08/2014 TTR1028 B. Hebbard In requestSurfaceData() and requestUpperAirData(), prune out stations that already have all met params they need, to avoid unnecessary querying
* 09/04/2014 1127 B. Hebbard Exempt forecast (e.g., MOS) datatimes from check in requestSurfaceData that sees if retrieved value matches desired time. This is because we retrieve only the refTime from HDF5 for comparison, which is sufficient for obs times, but not those with forecast component.
*