VLab Issue #3721 - NCEP CAVE plugin delivery for 14.3.1
PGEN Bug Fixes Change-Id: Ie50d8f829e0dfb00fab254945a46592553cdb59c Former-commit-id:d6f370db60
[formerlye71b522740
[formerly 2f93fd7bdbcf1fa4698dfc2dd51c377db6d809b6]] Former-commit-id:e71b522740
Former-commit-id:be04b1b1d9
This commit is contained in:
parent
5e1cd16ad7
commit
003aa6e113
19 changed files with 4248 additions and 3046 deletions
|
@ -304,6 +304,13 @@
|
|||
id="action"
|
||||
name="action"/>
|
||||
</command>
|
||||
<command
|
||||
id="gov.noaa.nws.ncep.ui.pgen.tools.PgenContoursHotkeyCommand"
|
||||
name="Contour level up/down">
|
||||
<commandParameter
|
||||
id="action"
|
||||
name="action"/>
|
||||
</command>
|
||||
<command categoryId="gov.noaa.nws.ncep.viz.ui.modalTool"
|
||||
id="gov.noaa.nws.ncep.ui.pgen.rsc.PgenClip"
|
||||
name="Pgen Clip">
|
||||
|
@ -553,6 +560,10 @@
|
|||
class="gov.noaa.nws.ncep.ui.pgen.tools.PgenCopypasteHotkeyHandler"
|
||||
commandId="gov.noaa.nws.ncep.ui.pgen.tools.PgenCopypasteHotkeyCommand">
|
||||
</handler>
|
||||
<handler
|
||||
class="gov.noaa.nws.ncep.ui.pgen.tools.PgenContoursHotkeyHandler"
|
||||
commandId="gov.noaa.nws.ncep.ui.pgen.tools.PgenContoursHotkeyCommand">
|
||||
</handler>
|
||||
<handler
|
||||
class="gov.noaa.nws.ncep.ui.pgen.tools.PgenClippingTool"
|
||||
commandId="gov.noaa.nws.ncep.ui.pgen.rsc.PgenClip">
|
||||
|
@ -2728,7 +2739,7 @@
|
|||
label="Solid Line"
|
||||
className="Lines"
|
||||
commandId="gov.noaa.nws.ncep.ui.pgen.rsc.PgenMultiDraw"
|
||||
icon="icons/cntr.gif" />
|
||||
icon="icons/solidln.gif" />
|
||||
<object
|
||||
name="POINTED_ARROW"
|
||||
label="Line with open arrow head"
|
||||
|
@ -3340,6 +3351,22 @@
|
|||
sequence="M1+A">
|
||||
<parameter id="action" value="SELECTALL" />
|
||||
</key>
|
||||
<!-- Hot keys to move contour level up/down -->
|
||||
<key
|
||||
commandId="gov.noaa.nws.ncep.ui.pgen.tools.PgenContoursHotkeyCommand"
|
||||
contextId="gov.noaa.nws.ncep.ui.pgen.pgenContext"
|
||||
schemeId="com.raytheon.viz.ui.awips.scheme"
|
||||
sequence="ARROW_UP">
|
||||
<parameter id="action" value="ARROW_UP" />
|
||||
</key>
|
||||
<key
|
||||
commandId="gov.noaa.nws.ncep.ui.pgen.tools.PgenContoursHotkeyCommand"
|
||||
contextId="gov.noaa.nws.ncep.ui.pgen.pgenContext"
|
||||
schemeId="com.raytheon.viz.ui.awips.scheme"
|
||||
sequence="ARROW_DOWN">
|
||||
<parameter id="action" value="ARROW_DOWN" />
|
||||
</key>
|
||||
|
||||
|
||||
</extension>
|
||||
|
||||
|
|
|
@ -205,8 +205,7 @@ public class PgenUtil {
|
|||
public static final String FIVE_ZERO = "00000";
|
||||
|
||||
// Default CAVE window title string
|
||||
// public static String caveTitle = "CAVE";
|
||||
public static String caveTitle = null;
|
||||
public static String caveTitle = "CAVE";
|
||||
|
||||
/**
|
||||
* Check the given editor for a PgenResource. If editor is null then the
|
||||
|
@ -1961,7 +1960,7 @@ public class PgenUtil {
|
|||
&& PlatformUI.getWorkbench().getActiveWorkbenchWindow()
|
||||
.getShell() != null) {
|
||||
// Save the existing title to reset.
|
||||
if (caveTitle == null) {
|
||||
if (caveTitle.equalsIgnoreCase("CAVE")) {
|
||||
caveTitle = PlatformUI.getWorkbench()
|
||||
.getActiveWorkbenchWindow().getShell().getText();
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -10,9 +10,9 @@ package gov.noaa.nws.ncep.ui.pgen.contours;
|
|||
|
||||
import gov.noaa.nws.ncep.ui.pgen.annotation.ElementOperations;
|
||||
import gov.noaa.nws.ncep.ui.pgen.annotation.Operation;
|
||||
import gov.noaa.nws.ncep.ui.pgen.display.IAttribute;
|
||||
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.display.IAttribute;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.util.ArrayList;
|
||||
|
@ -34,211 +34,225 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
* a set of lines.
|
||||
* 11/10 #345 J. Wu Added support for Contours Circle
|
||||
* 07/13 TTR765 J. Wu DEL_PART between vertexes.
|
||||
* 05/14 TTR1008 J. Wu Added getKey() method.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author J. Wu
|
||||
* @author J. Wu
|
||||
*/
|
||||
@ElementOperations ( {Operation.COPY_MOVE} )
|
||||
@ElementOperations({ Operation.COPY_MOVE })
|
||||
public class Contours extends DECollection implements IContours {
|
||||
|
||||
private String parm;
|
||||
private String level;
|
||||
private String forecastHour;
|
||||
private String cint;
|
||||
private Calendar time1;
|
||||
private Calendar time2;
|
||||
private String parm;
|
||||
|
||||
/**
|
||||
* public constructor
|
||||
*/
|
||||
public Contours(){
|
||||
private String level;
|
||||
|
||||
super("Contours");
|
||||
setPgenCategory( "MET" );
|
||||
setPgenType( "Contours" );
|
||||
private String forecastHour;
|
||||
|
||||
this.setParm("");
|
||||
this.setLevel("");
|
||||
this.setForecastHour("");
|
||||
this.setTime1( (Calendar)Calendar.getInstance() );
|
||||
this.setTime2( (Calendar)Calendar.getInstance() );
|
||||
this.setCint("");
|
||||
private String cint;
|
||||
|
||||
}
|
||||
private Calendar time1;
|
||||
|
||||
public Contours( String name ){
|
||||
super(name);
|
||||
}
|
||||
private Calendar time2;
|
||||
|
||||
public Contours( IAttribute attr, ArrayList<Coordinate> points ){
|
||||
/**
|
||||
* public constructor
|
||||
*/
|
||||
public Contours() {
|
||||
|
||||
super("Contours");
|
||||
setPgenCategory( "MET" );
|
||||
setPgenType( "Contours" );
|
||||
super("Contours");
|
||||
setPgenCategory("MET");
|
||||
setPgenType("Contours");
|
||||
|
||||
}
|
||||
this.setParm("");
|
||||
this.setLevel("");
|
||||
this.setForecastHour("");
|
||||
this.setTime1((Calendar) Calendar.getInstance());
|
||||
this.setTime2((Calendar) Calendar.getInstance());
|
||||
this.setCint("");
|
||||
|
||||
/**
|
||||
* @param parm the parm to set
|
||||
*/
|
||||
public void setParm(String parm) {
|
||||
this.parm = parm;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the parm
|
||||
*/
|
||||
public String getParm() {
|
||||
return parm;
|
||||
}
|
||||
public Contours(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the level
|
||||
*/
|
||||
public String getLevel() {
|
||||
return level;
|
||||
}
|
||||
public Contours(IAttribute attr, ArrayList<Coordinate> points) {
|
||||
|
||||
/**
|
||||
* @param level the level to set
|
||||
*/
|
||||
public void setLevel(String level) {
|
||||
this.level = level;
|
||||
}
|
||||
super("Contours");
|
||||
setPgenCategory("MET");
|
||||
setPgenType("Contours");
|
||||
|
||||
/**
|
||||
* @return the forecastHour
|
||||
*/
|
||||
public String getForecastHour() {
|
||||
return forecastHour;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param forecastHour the forecastHour to set
|
||||
*/
|
||||
public void setForecastHour(String forecastHour) {
|
||||
this.forecastHour = forecastHour;
|
||||
}
|
||||
/**
|
||||
* @param parm
|
||||
* the parm to set
|
||||
*/
|
||||
public void setParm(String parm) {
|
||||
this.parm = parm;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the cint
|
||||
*/
|
||||
public String getCint() {
|
||||
return cint;
|
||||
}
|
||||
/**
|
||||
* @return the parm
|
||||
*/
|
||||
public String getParm() {
|
||||
return parm;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param cint the cint to set
|
||||
*/
|
||||
public void setCint(String cint) {
|
||||
this.cint = cint;
|
||||
}
|
||||
/**
|
||||
* @return the level
|
||||
*/
|
||||
public String getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the time1
|
||||
*/
|
||||
public Calendar getTime1() {
|
||||
return time1;
|
||||
}
|
||||
/**
|
||||
* @param level
|
||||
* the level to set
|
||||
*/
|
||||
public void setLevel(String level) {
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param time the time to set
|
||||
*/
|
||||
public void setTime1(Calendar time) {
|
||||
this.time1 = time;
|
||||
}
|
||||
/**
|
||||
* @return the forecastHour
|
||||
*/
|
||||
public String getForecastHour() {
|
||||
return forecastHour;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the time2
|
||||
*/
|
||||
public Calendar getTime2() {
|
||||
return time2;
|
||||
}
|
||||
/**
|
||||
* @param forecastHour
|
||||
* the forecastHour to set
|
||||
*/
|
||||
public void setForecastHour(String forecastHour) {
|
||||
this.forecastHour = forecastHour;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param time the time2 to set
|
||||
*/
|
||||
public void setTime2(Calendar time) {
|
||||
this.time2 = time;
|
||||
}
|
||||
/**
|
||||
* @return the cint
|
||||
*/
|
||||
public String getCint() {
|
||||
return cint;
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* make a deep copy of the Contours
|
||||
*/
|
||||
public Contours copy() {
|
||||
/**
|
||||
* @param cint
|
||||
* the cint to set
|
||||
*/
|
||||
public void setCint(String cint) {
|
||||
this.cint = cint;
|
||||
}
|
||||
|
||||
Contours newContours = new Contours();
|
||||
/**
|
||||
* @return the time1
|
||||
*/
|
||||
public Calendar getTime1() {
|
||||
return time1;
|
||||
}
|
||||
|
||||
Iterator<AbstractDrawableComponent> iterator = this.getComponentIterator();
|
||||
/**
|
||||
* @param time
|
||||
* the time to set
|
||||
*/
|
||||
public void setTime1(Calendar time) {
|
||||
this.time1 = time;
|
||||
}
|
||||
|
||||
while ( iterator.hasNext() ) {
|
||||
AbstractDrawableComponent adc = iterator.next().copy();
|
||||
adc.setParent( newContours );
|
||||
newContours.add( adc );
|
||||
/**
|
||||
* @return the time2
|
||||
*/
|
||||
public Calendar getTime2() {
|
||||
return time2;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param time
|
||||
* the time2 to set
|
||||
*/
|
||||
public void setTime2(Calendar time) {
|
||||
this.time2 = time;
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* make a deep copy of the Contours
|
||||
*/
|
||||
public Contours copy() {
|
||||
|
||||
Contours newContours = new Contours();
|
||||
|
||||
Iterator<AbstractDrawableComponent> iterator = this
|
||||
.getComponentIterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
AbstractDrawableComponent adc = iterator.next().copy();
|
||||
adc.setParent(newContours);
|
||||
newContours.add(adc);
|
||||
}
|
||||
|
||||
newContours.update( this );
|
||||
|
||||
return newContours;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* update the attributes for a Contours element
|
||||
*/
|
||||
public void update( IContours attr ) {
|
||||
this.setParm(attr.getParm());
|
||||
this.setLevel(attr.getLevel());
|
||||
this.setForecastHour(attr.getForecastHour());
|
||||
this.setTime1(attr.getTime1());
|
||||
this.setTime2(attr.getTime2());
|
||||
this.setCint(attr.getCint());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Split a contour line in a Contours. - using index
|
||||
*
|
||||
* Older version - use only the points on the original (un-smoothed) line
|
||||
*/
|
||||
public Contours split( ContourLine cline, int start, int end ) {
|
||||
|
||||
Contours newContours = new Contours();
|
||||
|
||||
Iterator<AbstractDrawableComponent> iterator = this.getComponentIterator();
|
||||
|
||||
while ( iterator.hasNext() ) {
|
||||
|
||||
AbstractDrawableComponent oldAdc = iterator.next();
|
||||
AbstractDrawableComponent newAdc = oldAdc.copy();
|
||||
|
||||
if ( oldAdc.equals( cline ) ) {
|
||||
ArrayList<ContourLine> newLines = ((ContourLine)newAdc).split( start, end );
|
||||
for ( ContourLine cln : newLines ) {
|
||||
cln.setParent( newContours );
|
||||
newContours.add( cln );
|
||||
}
|
||||
}
|
||||
else {
|
||||
newAdc.setParent( newContours );
|
||||
newContours.add( newAdc );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
newContours.update( this );
|
||||
newContours.update(this);
|
||||
|
||||
return newContours;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the string
|
||||
*/
|
||||
public String toString() {
|
||||
StringBuilder result = new StringBuilder( getClass().getSimpleName());
|
||||
/**
|
||||
* update the attributes for a Contours element
|
||||
*/
|
||||
public void update(IContours attr) {
|
||||
this.setParm(attr.getParm());
|
||||
this.setLevel(attr.getLevel());
|
||||
this.setForecastHour(attr.getForecastHour());
|
||||
this.setTime1(attr.getTime1());
|
||||
this.setTime2(attr.getTime2());
|
||||
this.setCint(attr.getCint());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Split a contour line in a Contours. - using index
|
||||
*
|
||||
* Older version - use only the points on the original (un-smoothed) line
|
||||
*/
|
||||
public Contours split(ContourLine cline, int start, int end) {
|
||||
|
||||
Contours newContours = new Contours();
|
||||
|
||||
Iterator<AbstractDrawableComponent> iterator = this
|
||||
.getComponentIterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
|
||||
AbstractDrawableComponent oldAdc = iterator.next();
|
||||
AbstractDrawableComponent newAdc = oldAdc.copy();
|
||||
|
||||
if (oldAdc.equals(cline)) {
|
||||
ArrayList<ContourLine> newLines = ((ContourLine) newAdc).split(
|
||||
start, end);
|
||||
for (ContourLine cln : newLines) {
|
||||
cln.setParent(newContours);
|
||||
newContours.add(cln);
|
||||
}
|
||||
} else {
|
||||
newAdc.setParent(newContours);
|
||||
newContours.add(newAdc);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
newContours.update(this);
|
||||
|
||||
return newContours;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the string
|
||||
*/
|
||||
public String toString() {
|
||||
StringBuilder result = new StringBuilder(getClass().getSimpleName());
|
||||
|
||||
result.append("Category:\t" + pgenCategory + "\n");
|
||||
result.append("Type:\t" + pgenType + "\n");
|
||||
|
@ -248,74 +262,77 @@ public class Contours extends DECollection implements IContours {
|
|||
result.append("Time1:\t" + time1 + "\n");
|
||||
result.append("Time2:\t" + time2 + "\n");
|
||||
|
||||
return result.toString();
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a list of all ContourLines
|
||||
*/
|
||||
public ArrayList<ContourLine> getContourLines() {
|
||||
/**
|
||||
* @return a list of all ContourLines
|
||||
*/
|
||||
public ArrayList<ContourLine> getContourLines() {
|
||||
|
||||
ArrayList<ContourLine> lines = new ArrayList<ContourLine>();
|
||||
ArrayList<ContourLine> lines = new ArrayList<ContourLine>();
|
||||
|
||||
Iterator<AbstractDrawableComponent> iterator = this.getComponentIterator();
|
||||
Iterator<AbstractDrawableComponent> iterator = this
|
||||
.getComponentIterator();
|
||||
|
||||
while ( iterator.hasNext() ) {
|
||||
AbstractDrawableComponent adc = iterator.next();
|
||||
if ( adc instanceof ContourLine ) {
|
||||
lines.add( (ContourLine)adc );
|
||||
}
|
||||
while (iterator.hasNext()) {
|
||||
AbstractDrawableComponent adc = iterator.next();
|
||||
if (adc instanceof ContourLine) {
|
||||
lines.add((ContourLine) adc);
|
||||
}
|
||||
}
|
||||
|
||||
return lines;
|
||||
return lines;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a list of all ContourMinmaxs
|
||||
*/
|
||||
public ArrayList<ContourMinmax> getContourMinmaxs() {
|
||||
/**
|
||||
* @return a list of all ContourMinmaxs
|
||||
*/
|
||||
public ArrayList<ContourMinmax> getContourMinmaxs() {
|
||||
|
||||
ArrayList<ContourMinmax> cmms = new ArrayList<ContourMinmax>();
|
||||
ArrayList<ContourMinmax> cmms = new ArrayList<ContourMinmax>();
|
||||
|
||||
Iterator<AbstractDrawableComponent> iterator = this.getComponentIterator();
|
||||
Iterator<AbstractDrawableComponent> iterator = this
|
||||
.getComponentIterator();
|
||||
|
||||
while ( iterator.hasNext() ) {
|
||||
AbstractDrawableComponent adc = iterator.next();
|
||||
if ( adc instanceof ContourMinmax ) {
|
||||
cmms.add( (ContourMinmax)adc );
|
||||
}
|
||||
while (iterator.hasNext()) {
|
||||
AbstractDrawableComponent adc = iterator.next();
|
||||
if (adc instanceof ContourMinmax) {
|
||||
cmms.add((ContourMinmax) adc);
|
||||
}
|
||||
}
|
||||
|
||||
return cmms;
|
||||
return cmms;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a list of all ContourCircles
|
||||
*/
|
||||
public ArrayList<ContourCircle> getContourCircles() {
|
||||
/**
|
||||
* @return a list of all ContourCircles
|
||||
*/
|
||||
public ArrayList<ContourCircle> getContourCircles() {
|
||||
|
||||
ArrayList<ContourCircle> cmms = new ArrayList<ContourCircle>();
|
||||
ArrayList<ContourCircle> cmms = new ArrayList<ContourCircle>();
|
||||
|
||||
Iterator<AbstractDrawableComponent> iterator = this.getComponentIterator();
|
||||
Iterator<AbstractDrawableComponent> iterator = this
|
||||
.getComponentIterator();
|
||||
|
||||
while ( iterator.hasNext() ) {
|
||||
AbstractDrawableComponent adc = iterator.next();
|
||||
if ( adc instanceof ContourCircle) {
|
||||
cmms.add( (ContourCircle)adc );
|
||||
}
|
||||
while (iterator.hasNext()) {
|
||||
AbstractDrawableComponent adc = iterator.next();
|
||||
if (adc instanceof ContourCircle) {
|
||||
cmms.add((ContourCircle) adc);
|
||||
}
|
||||
}
|
||||
|
||||
return cmms;
|
||||
return cmms;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a new Contours from a set of lines generated from a grid.
|
||||
*/
|
||||
public Contours createContours( int nContours, int[] nContourPts,
|
||||
double[] latlons, float[] contourValue, Color clr ) {
|
||||
/**
|
||||
* @return a new Contours from a set of lines generated from a grid.
|
||||
*/
|
||||
public Contours createContours(int nContours, int[] nContourPts,
|
||||
double[] latlons, float[] contourValue, Color clr) {
|
||||
|
||||
/*
|
||||
* Create a new Contours element from the contour lines
|
||||
|
@ -323,41 +340,42 @@ public class Contours extends DECollection implements IContours {
|
|||
Contours gridContours = this.copy();
|
||||
gridContours.clear();
|
||||
|
||||
int tPts = 0;
|
||||
ArrayList<Coordinate> linePts = new ArrayList<Coordinate>();
|
||||
for ( int mm = 0; mm < nContours; mm++ ) {
|
||||
int tPts = 0;
|
||||
ArrayList<Coordinate> linePts = new ArrayList<Coordinate>();
|
||||
for (int mm = 0; mm < nContours; mm++) {
|
||||
|
||||
for ( int nn = 0; nn < nContourPts[ mm ]; nn++ ) {
|
||||
Coordinate point = new Coordinate();
|
||||
point.x = latlons[ tPts + nn*2 ];
|
||||
point.y = latlons[ tPts + nn*2 + 1 ];
|
||||
for (int nn = 0; nn < nContourPts[mm]; nn++) {
|
||||
Coordinate point = new Coordinate();
|
||||
point.x = latlons[tPts + nn * 2];
|
||||
point.y = latlons[tPts + nn * 2 + 1];
|
||||
|
||||
linePts.add( point );
|
||||
}
|
||||
linePts.add(point);
|
||||
}
|
||||
|
||||
tPts = tPts + nContourPts[ mm ] * 2;
|
||||
tPts = tPts + nContourPts[mm] * 2;
|
||||
|
||||
int nLabels = 2;
|
||||
ContourLine cline = new ContourLine( linePts, false,
|
||||
new String[]{ "" + contourValue[ mm ] }, nLabels );
|
||||
ContourLine cline = new ContourLine(linePts, false,
|
||||
new String[] { "" + contourValue[mm] }, nLabels);
|
||||
|
||||
cline.setParent( gridContours );
|
||||
if ( clr != null ) cline.getLine().setColors( new Color[]{ clr } );
|
||||
cline.getLine().setLineWidth( 2 );
|
||||
gridContours.add( cline );
|
||||
cline.setParent(gridContours);
|
||||
if (clr != null)
|
||||
cline.getLine().setColors(new Color[] { clr });
|
||||
cline.getLine().setLineWidth(2);
|
||||
gridContours.add(cline);
|
||||
|
||||
linePts.clear();
|
||||
}
|
||||
linePts.clear();
|
||||
}
|
||||
|
||||
return gridContours;
|
||||
return gridContours;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a new Contours from a set of lines generated from a grid.
|
||||
*/
|
||||
public Contours createContours( int nContours, int[] nContourPts,
|
||||
double[] latlons, String[] contourValue, Color clr ) {
|
||||
/**
|
||||
* @return a new Contours from a set of lines generated from a grid.
|
||||
*/
|
||||
public Contours createContours(int nContours, int[] nContourPts,
|
||||
double[] latlons, String[] contourValue, Color clr) {
|
||||
|
||||
/*
|
||||
* Create a new Contours element from the contour lines
|
||||
|
@ -365,71 +383,91 @@ public class Contours extends DECollection implements IContours {
|
|||
Contours gridContours = this.copy();
|
||||
gridContours.clear();
|
||||
|
||||
int tPts = 0;
|
||||
ArrayList<Coordinate> linePts = new ArrayList<Coordinate>();
|
||||
for ( int mm = 0; mm < nContours; mm++ ) {
|
||||
int tPts = 0;
|
||||
ArrayList<Coordinate> linePts = new ArrayList<Coordinate>();
|
||||
for (int mm = 0; mm < nContours; mm++) {
|
||||
|
||||
for ( int nn = 0; nn < nContourPts[ mm ]; nn++ ) {
|
||||
Coordinate point = new Coordinate();
|
||||
point.x = latlons[ tPts + nn*2 ];
|
||||
point.y = latlons[ tPts + nn*2 + 1 ];
|
||||
for (int nn = 0; nn < nContourPts[mm]; nn++) {
|
||||
Coordinate point = new Coordinate();
|
||||
point.x = latlons[tPts + nn * 2];
|
||||
point.y = latlons[tPts + nn * 2 + 1];
|
||||
|
||||
linePts.add( point );
|
||||
}
|
||||
linePts.add(point);
|
||||
}
|
||||
|
||||
tPts = tPts + nContourPts[ mm ] * 2;
|
||||
tPts = tPts + nContourPts[mm] * 2;
|
||||
|
||||
int nLabels = 2;
|
||||
ContourLine cline = new ContourLine( linePts, false,
|
||||
new String[]{ contourValue[ mm ] }, nLabels );
|
||||
ContourLine cline = new ContourLine(linePts, false,
|
||||
new String[] { contourValue[mm] }, nLabels);
|
||||
|
||||
cline.setParent( gridContours );
|
||||
if ( clr != null ) cline.getLine().setColors( new Color[]{ clr } );
|
||||
cline.getLine().setLineWidth( 2 );
|
||||
gridContours.add( cline );
|
||||
cline.setParent(gridContours);
|
||||
if (clr != null)
|
||||
cline.getLine().setColors(new Color[] { clr });
|
||||
cline.getLine().setLineWidth(2);
|
||||
gridContours.add(cline);
|
||||
|
||||
linePts.clear();
|
||||
}
|
||||
linePts.clear();
|
||||
}
|
||||
|
||||
return gridContours;
|
||||
return gridContours;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Split a contour line in a Contours - using coordinate
|
||||
*/
|
||||
public Contours split( ContourLine cline, Coordinate start, Coordinate end ) {
|
||||
/**
|
||||
* Split a contour line in a Contours - using coordinate
|
||||
*/
|
||||
public Contours split(ContourLine cline, Coordinate start, Coordinate end) {
|
||||
|
||||
Contours newContours = new Contours();
|
||||
Contours newContours = new Contours();
|
||||
|
||||
Iterator<AbstractDrawableComponent> iterator = this.getComponentIterator();
|
||||
Iterator<AbstractDrawableComponent> iterator = this
|
||||
.getComponentIterator();
|
||||
|
||||
while ( iterator.hasNext() ) {
|
||||
while (iterator.hasNext()) {
|
||||
|
||||
AbstractDrawableComponent oldAdc = iterator.next();
|
||||
AbstractDrawableComponent newAdc = oldAdc.copy();
|
||||
AbstractDrawableComponent oldAdc = iterator.next();
|
||||
AbstractDrawableComponent newAdc = oldAdc.copy();
|
||||
|
||||
if ( oldAdc.equals( cline ) ) {
|
||||
ArrayList<ContourLine> newLines = ((ContourLine)newAdc).split( start, end );
|
||||
for ( ContourLine cln : newLines ) {
|
||||
cln.setParent( newContours );
|
||||
newContours.add( cln );
|
||||
if (oldAdc.equals(cline)) {
|
||||
ArrayList<ContourLine> newLines = ((ContourLine) newAdc).split(
|
||||
start, end);
|
||||
for (ContourLine cln : newLines) {
|
||||
cln.setParent(newContours);
|
||||
newContours.add(cln);
|
||||
}
|
||||
}
|
||||
else {
|
||||
newAdc.setParent( newContours );
|
||||
newContours.add( newAdc );
|
||||
}
|
||||
} else {
|
||||
newAdc.setParent(newContours);
|
||||
newContours.add(newAdc);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
newContours.update( this );
|
||||
newContours.update(this);
|
||||
|
||||
return newContours;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Form a key that could be used to ID this contour
|
||||
*/
|
||||
public String getKey() {
|
||||
return getKey(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Form a key that could be used to ID a given contour
|
||||
*/
|
||||
public static String getKey(IContours ctr) {
|
||||
String key = ctr.getParm() + "," + ctr.getLevel() + ","
|
||||
+ ctr.getForecastHour() + "|"
|
||||
+ ctr.getTime1().get(Calendar.YEAR) + "-"
|
||||
+ (ctr.getTime1().get(Calendar.MONTH) + 1) + "-"
|
||||
+ ctr.getTime1().get(Calendar.DAY_OF_MONTH) + ","
|
||||
+ ctr.getTime1().get(Calendar.HOUR_OF_DAY) + ":"
|
||||
+ ctr.getTime1().get(Calendar.MINUTE) + "Z";
|
||||
return key;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -21,6 +21,8 @@ import gov.noaa.nws.ncep.ui.pgen.store.StorageUtils;
|
|||
import gov.noaa.nws.ncep.ui.pgen.tools.PgenSnapJet;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
|
@ -69,6 +71,7 @@ import com.raytheon.viz.ui.dialogs.CaveJFACEDialog;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- -----------------------------------
|
||||
* 03/13 #977 S.gilbert Modified from PgenFileManageDialog1
|
||||
* 01/2014 #1105 jwu Ues "subtype" for query as well.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -85,6 +88,10 @@ public class RetrieveActivityDialog extends CaveJFACEDialog {
|
|||
class ActivityElement {
|
||||
String dataURI;
|
||||
|
||||
/*
|
||||
* This will be a combo of "Product"'s activity type/subtype in format
|
||||
* of type(subtype).
|
||||
*/
|
||||
String activityType;
|
||||
|
||||
String activityLabel;
|
||||
|
@ -119,6 +126,10 @@ public class RetrieveActivityDialog extends CaveJFACEDialog {
|
|||
|
||||
private ListViewer fileListViewer = null;
|
||||
|
||||
private Button listLatestBtn = null;
|
||||
|
||||
private Button listAllBtn = null;
|
||||
|
||||
private Button browseBtn = null;
|
||||
|
||||
private Button autoSaveOffBtn = null;
|
||||
|
@ -173,7 +184,7 @@ public class RetrieveActivityDialog extends CaveJFACEDialog {
|
|||
private void setTitle(String btnName) {
|
||||
|
||||
if (btnName.equals("Open")) {
|
||||
title = "Rretrive a PGEN Activity";
|
||||
title = "Retrieve a PGEN Activity";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -285,16 +296,18 @@ public class RetrieveActivityDialog extends CaveJFACEDialog {
|
|||
|
||||
dirList.addListener(SWT.Selection, new Listener() {
|
||||
public void handleEvent(Event e) {
|
||||
if (dirList.getSelectionCount() > 0) {
|
||||
|
||||
selectedDir = dirList.getSelection()[0];
|
||||
fileListViewer.setInput(activityMap.get(selectedDir));
|
||||
fileListViewer.getList().setToolTipText(null);
|
||||
fileListViewer.refresh();
|
||||
|
||||
// Update the full file name with the new path
|
||||
fullName = null;
|
||||
}
|
||||
listActivities();
|
||||
/*
|
||||
* if (dirList.getSelectionCount() > 0) {
|
||||
*
|
||||
* selectedDir = dirList.getSelection()[0];
|
||||
* fileListViewer.setInput(activityMap.get(selectedDir));
|
||||
* fileListViewer.getList().setToolTipText(null);
|
||||
* fileListViewer.refresh();
|
||||
*
|
||||
* // Update the full file name with the new path fullName =
|
||||
* null; }
|
||||
*/
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -310,6 +323,33 @@ public class RetrieveActivityDialog extends CaveJFACEDialog {
|
|||
|
||||
fileLbl.setLayoutData(layoutData8);
|
||||
|
||||
listLatestBtn = new Button(topForm, SWT.RADIO);
|
||||
listLatestBtn.setText("Latest");
|
||||
listLatestBtn.setSelection(true);
|
||||
|
||||
FormData layoutData20 = new FormData();
|
||||
layoutData20.top = new FormAttachment(dirList, 20, SWT.BOTTOM);
|
||||
layoutData20.left = new FormAttachment(fileLbl, 10, SWT.RIGHT);
|
||||
listLatestBtn.setLayoutData(layoutData20);
|
||||
listLatestBtn.addSelectionListener(new SelectionAdapter() {
|
||||
public void widgetSelected(SelectionEvent ev) {
|
||||
listActivities();
|
||||
}
|
||||
});
|
||||
|
||||
listAllBtn = new Button(topForm, SWT.RADIO);
|
||||
listAllBtn.setText("All");
|
||||
|
||||
FormData layoutData21 = new FormData();
|
||||
layoutData21.top = new FormAttachment(dirList, 20, SWT.BOTTOM);
|
||||
layoutData21.left = new FormAttachment(listLatestBtn, 10, SWT.RIGHT);
|
||||
listAllBtn.setLayoutData(layoutData21);
|
||||
listAllBtn.addSelectionListener(new SelectionAdapter() {
|
||||
public void widgetSelected(SelectionEvent ev) {
|
||||
listActivities();
|
||||
}
|
||||
});
|
||||
|
||||
fileListViewer = new ListViewer(topForm, SWT.SINGLE | SWT.BORDER
|
||||
| SWT.V_SCROLL);
|
||||
|
||||
|
@ -414,6 +454,7 @@ public class RetrieveActivityDialog extends CaveJFACEDialog {
|
|||
DbQueryRequest request = new DbQueryRequest();
|
||||
request.setEntityClass(PgenRecord.class.getName());
|
||||
request.addRequestField(PgenRecord.ACTIVITY_TYPE);
|
||||
request.addRequestField(PgenRecord.ACTIVITY_SUBTYPE);
|
||||
request.addRequestField(PgenRecord.ACTIVITY_LABEL);
|
||||
request.addRequestField(PgenRecord.DATAURI);
|
||||
request.addRequestField(PgenRecord.REF_TIME);
|
||||
|
@ -426,6 +467,15 @@ public class RetrieveActivityDialog extends CaveJFACEDialog {
|
|||
ActivityElement elem = new ActivityElement();
|
||||
elem.activityType = (String) result
|
||||
.get(PgenRecord.ACTIVITY_TYPE);
|
||||
|
||||
if (result.get(PgenRecord.ACTIVITY_SUBTYPE) != null) {
|
||||
String subtype = (String) result
|
||||
.get(PgenRecord.ACTIVITY_SUBTYPE);
|
||||
if (!subtype.isEmpty() && !subtype.equalsIgnoreCase("NONE")) {
|
||||
elem.activityType += "(" + subtype + ")";
|
||||
}
|
||||
}
|
||||
|
||||
elem.activityLabel = (String) result
|
||||
.get(PgenRecord.ACTIVITY_LABEL);
|
||||
elem.dataURI = (String) result.get(PgenRecord.DATAURI);
|
||||
|
@ -692,4 +742,51 @@ public class RetrieveActivityDialog extends CaveJFACEDialog {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* List all activities for an activity type/subtype or just the latest ones.
|
||||
*/
|
||||
private void listActivities() {
|
||||
|
||||
boolean listLatest = listLatestBtn.getSelection();
|
||||
if (dirList.getSelectionCount() > 0) {
|
||||
|
||||
selectedDir = dirList.getSelection()[0];
|
||||
java.util.List<ActivityElement> elems = activityMap
|
||||
.get(selectedDir);
|
||||
|
||||
java.util.List<ActivityElement> filterElms = new ArrayList<ActivityElement>();
|
||||
|
||||
if (elems.size() > 0) {
|
||||
if (listLatest) {
|
||||
|
||||
// Sort all entries based on time, latest first.
|
||||
Collections.sort(elems, new Comparator<ActivityElement>() {
|
||||
@Override
|
||||
public int compare(ActivityElement ae1,
|
||||
ActivityElement ae2) {
|
||||
return -1 * ae1.refTime.compareTo(ae2.refTime);
|
||||
}
|
||||
});
|
||||
|
||||
// Pick unique labels.
|
||||
java.util.List<String> actLbls = new ArrayList<String>();
|
||||
for (ActivityElement ae : elems) {
|
||||
if (!actLbls.contains(ae.activityLabel)) {
|
||||
actLbls.add(ae.activityLabel);
|
||||
filterElms.add(ae);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
filterElms.addAll(elems);
|
||||
}
|
||||
}
|
||||
|
||||
fileListViewer.setInput(filterElms);
|
||||
fileListViewer.getList().setToolTipText(null);
|
||||
fileListViewer.refresh();
|
||||
|
||||
// Update the full file name with the new path
|
||||
fullName = null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -15,6 +15,7 @@ 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 java.io.File;
|
||||
import java.util.Calendar;
|
||||
import java.util.TimeZone;
|
||||
|
||||
|
@ -24,16 +25,18 @@ import org.eclipse.swt.SWT;
|
|||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Combo;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
import org.eclipse.swt.widgets.DateTime;
|
||||
import org.eclipse.swt.widgets.Group;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
|
||||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
import com.raytheon.uf.viz.core.localization.LocalizationManager;
|
||||
import com.raytheon.viz.core.mode.CAVEMode;
|
||||
import com.raytheon.viz.ui.dialogs.CaveJFACEDialog;
|
||||
|
||||
|
@ -45,6 +48,7 @@ import com.raytheon.viz.ui.dialogs.CaveJFACEDialog;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- -----------------------------------
|
||||
* 03/13 #977 S. Gilbert Initial creation
|
||||
* 01/14 #1105 J. Wu Pre-fill for each activity info.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -83,7 +87,7 @@ public class StoreActivityDialog extends CaveJFACEDialog {
|
|||
|
||||
private Text forecasterText = null;
|
||||
|
||||
private Text modeText;
|
||||
private Combo modeCombo;
|
||||
|
||||
private Text statusText;
|
||||
|
||||
|
@ -99,7 +103,7 @@ public class StoreActivityDialog extends CaveJFACEDialog {
|
|||
|
||||
private Product activity;
|
||||
|
||||
private Text messageText;
|
||||
// private Text messageText;
|
||||
|
||||
/*
|
||||
* Constructor
|
||||
|
@ -120,11 +124,11 @@ public class StoreActivityDialog extends CaveJFACEDialog {
|
|||
private void setStoreMode(String btnName) {
|
||||
|
||||
if (btnName.equals("Open")) {
|
||||
title = "Open a PGEN Product file";
|
||||
title = "Open a PGEN Activity file";
|
||||
} else if (btnName.equals("Save") || btnName.equals("Save All")) {
|
||||
title = "Save the PGEN Product";
|
||||
title = "Save the PGEN Activity";
|
||||
} else if (btnName.equals("Save As")) {
|
||||
title = "Save the PGEN Product as";
|
||||
title = "Save the PGEN Activity as";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -185,9 +189,10 @@ public class StoreActivityDialog extends CaveJFACEDialog {
|
|||
/*
|
||||
* Initialize the Message Area
|
||||
*/
|
||||
Group g4 = new Group(dlgAreaForm, SWT.NONE);
|
||||
g4.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||
createMessageArea(g4);
|
||||
/*
|
||||
* Group g4 = new Group(dlgAreaForm, SWT.NONE); g4.setLayoutData(new
|
||||
* GridData(GridData.FILL_HORIZONTAL)); createMessageArea(g4);
|
||||
*/
|
||||
|
||||
setDialogFields();
|
||||
return dlgAreaForm;
|
||||
|
@ -199,58 +204,84 @@ public class StoreActivityDialog extends CaveJFACEDialog {
|
|||
GridData gdata = new GridData(SWT.FILL, SWT.CENTER, true, false);
|
||||
|
||||
Label infoLabel = new Label(g1, SWT.NONE);
|
||||
infoLabel.setText("Activity Label:");
|
||||
infoLabel.setText("Activity Label*:");
|
||||
|
||||
infoText = new Text(g1, SWT.NONE);
|
||||
infoText.setLayoutData(gdata);
|
||||
infoText.setToolTipText("Input a file name - required.");
|
||||
|
||||
Label nameLabel = new Label(g1, SWT.NONE);
|
||||
nameLabel.setText("Activity Name:");
|
||||
nameLabel.setText("Activity Name*:");
|
||||
|
||||
nameText = new Text(g1, SWT.NONE);
|
||||
nameText.setLayoutData(gdata);
|
||||
nameText.setToolTipText("Alias for this activity, just like your first name while activity "
|
||||
+ "type/subtype is the last name. Leave it as is");
|
||||
|
||||
Label typeLabel = new Label(g1, SWT.NONE);
|
||||
typeLabel.setText("Activity Type:");
|
||||
typeLabel.setText("Activity Type*:");
|
||||
typeLabel.setEnabled(false);
|
||||
|
||||
typeText = new Text(g1, SWT.NONE);
|
||||
typeText.setLayoutData(gdata);
|
||||
typeText.setEditable(false);
|
||||
typeText.setToolTipText("Activity type as defined. Leave it as is");
|
||||
|
||||
Label subtypeLabel = new Label(g1, SWT.NONE);
|
||||
subtypeLabel.setText("Activity Subtype:");
|
||||
subtypeLabel.setText("Activity Subtype*:");
|
||||
subtypeLabel.setEnabled(false);
|
||||
|
||||
subtypeText = new Text(g1, SWT.NONE);
|
||||
subtypeText.setLayoutData(gdata);
|
||||
subtypeText.setEditable(false);
|
||||
subtypeText
|
||||
.setToolTipText("Activity subtype as defined. Leave it as is");
|
||||
|
||||
Label siteLabel = new Label(g1, SWT.NONE);
|
||||
siteLabel.setText("Site:");
|
||||
siteLabel.setText("Site*:");
|
||||
siteLabel.setEnabled(false);
|
||||
|
||||
siteText = new Text(g1, SWT.NONE);
|
||||
siteText.setLayoutData(gdata);
|
||||
siteText.setEditable(false);
|
||||
siteText.setToolTipText("Site defined in localization. Leave it as is");
|
||||
|
||||
Label deskLabel = new Label(g1, SWT.NONE);
|
||||
deskLabel.setText("Desk:");
|
||||
deskLabel.setEnabled(false);
|
||||
|
||||
deskText = new Text(g1, SWT.NONE);
|
||||
deskText.setLayoutData(gdata);
|
||||
deskText.setEditable(false);
|
||||
deskText.setToolTipText("Desk defined in localization or set when starting CAVE. Leave it as is");
|
||||
|
||||
Label forecasterLabel = new Label(g1, SWT.NONE);
|
||||
forecasterLabel.setText("Forecaster:");
|
||||
|
||||
forecasterText = new Text(g1, SWT.NONE);
|
||||
forecasterText.setLayoutData(gdata);
|
||||
forecasterText
|
||||
.setToolTipText("Forecaster's name, default is your user name, not required");
|
||||
|
||||
Label modeLabel = new Label(g1, SWT.NONE);
|
||||
modeLabel.setText("Operating Mode:");
|
||||
|
||||
modeText = new Text(g1, SWT.NONE);
|
||||
modeText.setLayoutData(gdata);
|
||||
modeCombo = new Combo(g1, SWT.DROP_DOWN | SWT.READ_ONLY);
|
||||
|
||||
for (CAVEMode cm : CAVEMode.values()) {
|
||||
modeCombo.add(cm.name());
|
||||
}
|
||||
|
||||
modeCombo.select(0);
|
||||
modeCombo
|
||||
.setToolTipText("CAVE mode set at starting, or pick one here.");
|
||||
|
||||
Label statusLabel = new Label(g1, SWT.NONE);
|
||||
statusLabel.setText("Activity Status:");
|
||||
|
||||
statusText = new Text(g1, SWT.NONE);
|
||||
statusText.setLayoutData(gdata);
|
||||
statusText.setToolTipText("Activity status, not in use yet.");
|
||||
|
||||
}
|
||||
|
||||
|
@ -259,11 +290,20 @@ public class StoreActivityDialog extends CaveJFACEDialog {
|
|||
g2.setLayout(new GridLayout(4, false));
|
||||
|
||||
Label refTimeLabel = new Label(g2, SWT.NONE);
|
||||
refTimeLabel.setText("Ref Time:");
|
||||
refTimeLabel.setText("Ref Time*:");
|
||||
|
||||
validDate = new DateTime(g2, SWT.BORDER | SWT.DATE);
|
||||
|
||||
validDate
|
||||
.setToolTipText("Activity's reference date, changing it and saving the "
|
||||
+ "activity will save the current activity as a new entry in PGEN DB.");
|
||||
|
||||
validTime = new DateTime(g2, SWT.BORDER | SWT.TIME | SWT.SHORT);
|
||||
|
||||
validTime
|
||||
.setToolTipText("Activity's reference time, changing it and saving the "
|
||||
+ "activity will save the current activity as a new entry in PGEN DB.");
|
||||
|
||||
Label utcLabel = new Label(g2, SWT.NONE);
|
||||
utcLabel.setText("UTC");
|
||||
|
||||
|
@ -285,15 +325,14 @@ public class StoreActivityDialog extends CaveJFACEDialog {
|
|||
|
||||
}
|
||||
|
||||
private void createMessageArea(Composite g4) {
|
||||
g4.setLayout(new GridLayout(1, true));
|
||||
GridData gdata = new GridData(SWT.FILL, SWT.CENTER, true, false);
|
||||
|
||||
messageText = new Text(g4, SWT.MULTI | SWT.READ_ONLY | SWT.H_SCROLL
|
||||
| SWT.V_SCROLL);
|
||||
messageText.setLayoutData(gdata);
|
||||
}
|
||||
|
||||
/*
|
||||
* private void createMessageArea(Composite g4) { g4.setLayout(new
|
||||
* GridLayout(1, true)); GridData gdata = new GridData(SWT.FILL, SWT.CENTER,
|
||||
* true, false);
|
||||
*
|
||||
* messageText = new Text(g4, SWT.MULTI | SWT.READ_ONLY | SWT.H_SCROLL |
|
||||
* SWT.V_SCROLL); messageText.setLayoutData(gdata); }
|
||||
*/
|
||||
/**
|
||||
* Save/Cancel button for "Save" a product file.
|
||||
*/
|
||||
|
@ -318,17 +357,63 @@ public class StoreActivityDialog extends CaveJFACEDialog {
|
|||
|
||||
private void setDialogFields() {
|
||||
|
||||
if (activity.getOutputFile() != null)
|
||||
if (activity.getOutputFile() != null) {
|
||||
infoText.setText(activity.getOutputFile());
|
||||
} else {
|
||||
String filename = PgenSession.getInstance().getPgenResource()
|
||||
.buildFileName(activity);
|
||||
filename = filename
|
||||
.substring(filename.lastIndexOf(File.separator) + 1);
|
||||
// filename = filename.replace(".xml", ""); // remove ending ".xml"
|
||||
|
||||
infoText.setText(filename);
|
||||
}
|
||||
|
||||
if (activity.getName() != null)
|
||||
nameText.setText(activity.getName());
|
||||
if (activity.getType() != null)
|
||||
typeText.setText(activity.getType());
|
||||
if (activity.getCenter() != null)
|
||||
siteText.setText(activity.getCenter());
|
||||
if (activity.getForecaster() != null)
|
||||
forecasterText.setText(activity.getForecaster());
|
||||
modeText.setText(CAVEMode.getMode().name());
|
||||
|
||||
/*
|
||||
* Activity type/subtype is stored in Product as "type(subtype)", so we
|
||||
* need to split it up here.
|
||||
*/
|
||||
String type = activity.getType();
|
||||
if (type != null) {
|
||||
int loc1 = type.indexOf("(");
|
||||
if (loc1 > 0) {
|
||||
typeText.setText(type.substring(0, loc1));
|
||||
String subtype = type.substring(loc1 + 1).replace(")", "");
|
||||
if (subtype.length() > 0 && !subtype.equalsIgnoreCase("NONE"))
|
||||
subtypeText.setText(subtype);
|
||||
} else {
|
||||
typeText.setText(type);
|
||||
}
|
||||
}
|
||||
|
||||
siteText.setText(PgenUtil.getCurrentOffice());
|
||||
|
||||
// get the desk info.
|
||||
String desk = LocalizationManager.getContextName(LocalizationLevel
|
||||
.valueOf("DESK"));
|
||||
|
||||
if (desk != null && !desk.equalsIgnoreCase("none")) {
|
||||
deskText.setText(desk);
|
||||
}
|
||||
|
||||
forecasterText.setText(System.getProperty("user.name"));
|
||||
|
||||
// Select the cave mode.
|
||||
String mode = CAVEMode.getMode().name();
|
||||
int index = 0;
|
||||
int ii = 0;
|
||||
for (String md : modeCombo.getItems()) {
|
||||
if (md.equals(mode)) {
|
||||
index = ii;
|
||||
break;
|
||||
}
|
||||
ii++;
|
||||
}
|
||||
modeCombo.select(index);
|
||||
|
||||
statusText.setText("Unknown");
|
||||
|
||||
Calendar datetime = activity.getTime().getStartTime();
|
||||
|
@ -369,28 +454,34 @@ public class StoreActivityDialog extends CaveJFACEDialog {
|
|||
|
||||
// PgenSession.getInstance().getPgenPalette().setActiveIcon("Select");
|
||||
|
||||
activity.setInputFile(activityLabel);
|
||||
activity.setOutputFile(activityLabel);
|
||||
// activity.setInputFile(activityLabel);
|
||||
// activity.setOutputFile(activityLabel);
|
||||
|
||||
ActivityInfo info = getActivityInfo();
|
||||
messageText.setText("Sending Activity...");
|
||||
messageText.setBackground(shell.getDisplay().getSystemColor(
|
||||
SWT.COLOR_WIDGET_BACKGROUND));
|
||||
messageText.redraw();
|
||||
activity.setInputFile(info.getActivityLabel());
|
||||
activity.setOutputFile(info.getActivityLabel());
|
||||
activity.setCenter(info.getSite());
|
||||
activity.setForecaster(info.getForecaster());
|
||||
|
||||
/*
|
||||
* messageText.setText("Sending Activity...");
|
||||
* messageText.setBackground(shell.getDisplay().getSystemColor(
|
||||
* SWT.COLOR_WIDGET_BACKGROUND)); messageText.redraw();
|
||||
*/
|
||||
try {
|
||||
StorageUtils.storeProduct(info, activity, true);
|
||||
// StorageUtils.storeProduct(info, activity, true);
|
||||
String uri = StorageUtils.storeProduct(info, activity, true);
|
||||
// System.out.println("Activity saved at dataURI: " + uri);
|
||||
} catch (PgenStorageException e) {
|
||||
e.printStackTrace();
|
||||
messageText.setText(e.getMessage());
|
||||
messageText.setBackground(shell.getDisplay().getSystemColor(
|
||||
SWT.COLOR_RED));
|
||||
if (e.getMessage().contains("\n")) {
|
||||
messageText.setSize(SWT.DEFAULT,
|
||||
5 * messageText.getLineHeight());
|
||||
messageText.getShell().pack();
|
||||
messageText.getShell().layout();
|
||||
}
|
||||
/*
|
||||
* messageText.setText(e.getMessage());
|
||||
* messageText.setBackground(shell.getDisplay().getSystemColor(
|
||||
* SWT.COLOR_RED)); if (e.getMessage().contains("\n")) {
|
||||
* messageText.setSize(SWT.DEFAULT, 5 *
|
||||
* messageText.getLineHeight()); messageText.getShell().pack();
|
||||
* messageText.getShell().layout(); }
|
||||
*/
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -403,14 +494,18 @@ public class StoreActivityDialog extends CaveJFACEDialog {
|
|||
private ActivityInfo getActivityInfo() {
|
||||
|
||||
ActivityInfo info = new ActivityInfo();
|
||||
info.setActivityLabel(infoText.getText());
|
||||
String lbl = infoText.getText();
|
||||
if (!lbl.endsWith(".xml")) {
|
||||
lbl += ".xml";
|
||||
}
|
||||
info.setActivityLabel(lbl);
|
||||
info.setActivityName(nameText.getText());
|
||||
info.setActivityType(typeText.getText());
|
||||
info.setActivitySubtype(subtypeText.getText());
|
||||
info.setSite(siteText.getText());
|
||||
info.setDesk(deskText.getText());
|
||||
info.setForecaster(forecasterText.getText());
|
||||
info.setMode(modeText.getText());
|
||||
info.setMode(modeCombo.getText());
|
||||
info.setStatus(statusText.getText());
|
||||
|
||||
Calendar refTime = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
|
||||
|
|
|
@ -141,6 +141,7 @@ import com.vividsolutions.jts.operation.distance.DistanceOp;
|
|||
* 11/13 TTR 752 J. Wu added methods to compute an element's range record.
|
||||
* 12/13 #1089 B. Yin Modify watch to display county list
|
||||
* 02/14 #2819 R. Anderson Removed unnecessary .clone() call
|
||||
* 02/14 #2819 R. Anderson Removed unnecessary .clone() call
|
||||
* </pre>
|
||||
*
|
||||
* @author sgilbert
|
||||
|
@ -629,20 +630,25 @@ public class DisplayElementFactory {
|
|||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a list of IDisplayable Objects from an IWatchBox object
|
||||
* @param de A PGEN Drawable Element of a WatchBox object
|
||||
* @param paintProps The paint properties associated with the target
|
||||
* @return A list of IDisplayable elements
|
||||
*/
|
||||
public ArrayList<IDisplayable> createDisplayElements(IWatchBox watchBox, PaintProperties paintProps) {
|
||||
/**
|
||||
* Creates a list of IDisplayable Objects from an IWatchBox object
|
||||
*
|
||||
* @param de
|
||||
* A PGEN Drawable Element of a WatchBox object
|
||||
* @param paintProps
|
||||
* The paint properties associated with the target
|
||||
* @return A list of IDisplayable elements
|
||||
*/
|
||||
public ArrayList<IDisplayable> createDisplayElements(IWatchBox watchBox,
|
||||
PaintProperties paintProps) {
|
||||
|
||||
/*
|
||||
/*
|
||||
* Create the List to be returned
|
||||
*/
|
||||
ArrayList<IDisplayable> dlist = new ArrayList<IDisplayable>();
|
||||
|
||||
List<SPCCounty> counties = watchBox.getOriginalCountyList();
|
||||
<<<<<<< HEAD
|
||||
if ( counties == null || counties.isEmpty()){ //if the watch is not issued yet, the original county list is not set.
|
||||
counties = watchBox.getCountyList();
|
||||
}
|
||||
|
@ -745,66 +751,189 @@ public class DisplayElementFactory {
|
|||
}
|
||||
}
|
||||
|
||||
=======
|
||||
if (counties == null || counties.isEmpty()) { // if the watch is not
|
||||
// issued yet, the
|
||||
// original county list is
|
||||
// not set.
|
||||
counties = watchBox.getCountyList();
|
||||
}
|
||||
|
||||
if (counties != null && !counties.isEmpty()) {
|
||||
if (watchBox.getFillFlag()) {
|
||||
|
||||
Geometry cntyUnion = null;
|
||||
;
|
||||
Color[] colors = null;
|
||||
|
||||
Collection<Geometry> gCollection = new ArrayList<Geometry>();
|
||||
|
||||
// draw county border
|
||||
for (SPCCounty cnty : counties) {
|
||||
Geometry countyGeo = cnty.getShape();
|
||||
|
||||
colors = watchBox.getColors();
|
||||
colors[1] = watchBox.getFillColor();
|
||||
|
||||
for (int ii = 0; ii < countyGeo.getNumGeometries(); ii++) {
|
||||
Polygon poly = (Polygon) countyGeo.getGeometryN(ii);
|
||||
List<Coordinate> pts = new ArrayList<Coordinate>(
|
||||
Arrays.asList(poly.getCoordinates()));
|
||||
|
||||
Line cntyBorder = new Line(null, colors, .5f, .5, true,
|
||||
false, pts, 0, FillPattern.FILL_PATTERN_6,
|
||||
"Lines", "LINE_SOLID");
|
||||
ArrayList<IDisplayable> cntyLine = createDisplayElements(
|
||||
cntyBorder, paintProps);
|
||||
dlist.addAll(cntyLine);
|
||||
}
|
||||
|
||||
if (countyGeo != null) {
|
||||
gCollection.add(countyGeo.buffer(.02));
|
||||
}
|
||||
}
|
||||
|
||||
// Merge counties together and fill the whole area
|
||||
GeometryFactory gf = new GeometryFactory();
|
||||
|
||||
if (gCollection.size() > 1) {
|
||||
GeometryCollection geometryCollection = (GeometryCollection) gf
|
||||
.buildGeometry(gCollection);
|
||||
|
||||
cntyUnion = geometryCollection.union();
|
||||
} else
|
||||
cntyUnion = gf.buildGeometry(gCollection);
|
||||
|
||||
IShadedShape theShadedShape = target.createShadedShape(false,
|
||||
iDescriptor, true);
|
||||
|
||||
// IWireframeShape theWireframeShape =
|
||||
// target.createWireframeShape(false, mapDescriptor);
|
||||
|
||||
JTSCompiler compiler = new JTSCompiler(theShadedShape, null,
|
||||
iDescriptor, PointStyle.CROSS);
|
||||
|
||||
try {
|
||||
compiler.handle(cntyUnion,
|
||||
new RGB(colors[1].getRed(), colors[1].getGreen(),
|
||||
colors[1].getBlue()));
|
||||
|
||||
if (elem.getFillPattern() != FillPattern.TRANSPARENCY
|
||||
&& elem.getFillPattern() != FillPattern.SOLID) {
|
||||
FillPatternList fpl = new FillPatternList();
|
||||
byte[] fpattern = fpl.getFillPattern(elem
|
||||
.getFillPattern());
|
||||
theShadedShape.setFillPattern(fpattern);
|
||||
}
|
||||
theShadedShape.compile();
|
||||
|
||||
// theWireframeShape.compile();
|
||||
// dlist.add(new LineDisplayElement(theWireframeShape,
|
||||
// colors[1], .5f));
|
||||
dlist.add(new FillDisplayElement(theShadedShape, 1f));
|
||||
|
||||
} catch (VizException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
for (SPCCounty cnty : counties) {
|
||||
|
||||
Symbol cSymbol = new Symbol(null, watchBox.getColors(),
|
||||
watchBox.getWatchSymbolWidth(),
|
||||
watchBox.getWatchSymbolSize(), false,
|
||||
cnty.getCentriod(), "Marker",
|
||||
watchBox.getWatchSymbolType());
|
||||
ArrayList<IDisplayable> cList = createDisplayElements(
|
||||
cSymbol, paintProps);
|
||||
dlist.addAll(cList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if already issued, draw the list of active counties with OCTAGON
|
||||
// symbols.
|
||||
if (watchBox.getIssueFlag() != 0) {
|
||||
List<SPCCounty> activeCounties = watchBox.getCountyList();
|
||||
if (activeCounties != null && !activeCounties.isEmpty()) {
|
||||
for (SPCCounty cnty : activeCounties) {
|
||||
|
||||
Symbol cSymbol = new Symbol(null,
|
||||
IWatchBox.WATCH_LIST_COLOR, 3, 2, false,
|
||||
cnty.getCentriod(), "Marker", "OCTAGON");
|
||||
ArrayList<IDisplayable> cList = createDisplayElements(
|
||||
cSymbol, paintProps);
|
||||
dlist.addAll(cList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
>>>>>>> d3a1e1a... VLab Issue #3721 - NCEP CAVE plugin delivery for 14.3.1
|
||||
Coordinate[] points = watchBox.getLinePoints();
|
||||
ArrayList<Coordinate> ptsList = new ArrayList<Coordinate>();
|
||||
|
||||
for ( int ii = 0; ii < points.length; ii++ ){
|
||||
ptsList.add(points[ii]);
|
||||
for (int ii = 0; ii < points.length; ii++) {
|
||||
ptsList.add(points[ii]);
|
||||
}
|
||||
|
||||
//get displayElements for the watch box.
|
||||
Line box = new Line(null, watchBox.getColors(),3.0f,3.0,true,
|
||||
false, ptsList,
|
||||
0,FillPattern.SOLID,"Lines","LINE_SOLID");
|
||||
ArrayList<IDisplayable> dBox = createDisplayElements(box,paintProps);
|
||||
// get displayElements for the watch box.
|
||||
Line box = new Line(null, watchBox.getColors(), 3.0f, 3.0, true, false,
|
||||
ptsList, 0, FillPattern.SOLID, "Lines", "LINE_SOLID");
|
||||
ArrayList<IDisplayable> dBox = createDisplayElements(box, paintProps);
|
||||
dlist.addAll(dBox);
|
||||
|
||||
//get displayElements for the center line in the watch box
|
||||
// get displayElements for the center line in the watch box
|
||||
ptsList.clear();
|
||||
ptsList.add(points[0]);
|
||||
ptsList.add(new Coordinate((points[0].x+points[4].x)/2,
|
||||
(points[0].y+points[4].y)/2));
|
||||
ptsList.add(new Coordinate((points[0].x + points[4].x) / 2,
|
||||
(points[0].y + points[4].y) / 2));
|
||||
ptsList.add(points[4]);
|
||||
|
||||
Line centerLine = new Line(null, watchBox.getColors(),3.0f,3.0,false,
|
||||
false, ptsList, 0,FillPattern.SOLID,"Lines","LINE_SOLID");
|
||||
Line centerLine = new Line(null, watchBox.getColors(), 3.0f, 3.0,
|
||||
false, false, ptsList, 0, FillPattern.SOLID, "Lines",
|
||||
"LINE_SOLID");
|
||||
|
||||
ArrayList<IDisplayable> dLine = createDisplayElements(centerLine,paintProps);
|
||||
ArrayList<IDisplayable> dLine = createDisplayElements(centerLine,
|
||||
paintProps);
|
||||
dlist.addAll(dLine);
|
||||
|
||||
Station[] anchors = watchBox.getAnchors();
|
||||
Symbol anchor1 = new Symbol(null, watchBox.getColors(), 1.5f, 0.7, false,
|
||||
new Coordinate(anchors[0].getLongitude(),anchors[0].getLatitude()),
|
||||
"Marker", "DIAMOND");
|
||||
Symbol anchor1 = new Symbol(null, watchBox.getColors(), 1.5f, 0.7,
|
||||
false, new Coordinate(anchors[0].getLongitude(),
|
||||
anchors[0].getLatitude()), "Marker", "DIAMOND");
|
||||
|
||||
ArrayList<IDisplayable> aList1 = createDisplayElements(anchor1,paintProps);
|
||||
ArrayList<IDisplayable> aList1 = createDisplayElements(anchor1,
|
||||
paintProps);
|
||||
dlist.addAll(aList1);
|
||||
|
||||
Symbol anchor2 = new Symbol(null, watchBox.getColors(), 1.5f, 0.7, false,
|
||||
new Coordinate(anchors[1].getLongitude(),anchors[1].getLatitude()),
|
||||
"Marker", "DIAMOND");
|
||||
Symbol anchor2 = new Symbol(null, watchBox.getColors(), 1.5f, 0.7,
|
||||
false, new Coordinate(anchors[1].getLongitude(),
|
||||
anchors[1].getLatitude()), "Marker", "DIAMOND");
|
||||
|
||||
ArrayList<IDisplayable> aList2 = createDisplayElements(anchor2,paintProps);
|
||||
ArrayList<IDisplayable> aList2 = createDisplayElements(anchor2,
|
||||
paintProps);
|
||||
dlist.addAll(aList2);
|
||||
|
||||
//Add watch number if the watch is issued
|
||||
if ( watchBox.getIssueFlag() != 0 ){
|
||||
// Add watch number if the watch is issued
|
||||
if (watchBox.getIssueFlag() != 0) {
|
||||
|
||||
String[] wtext = { String.valueOf(watchBox.getWatchNumber())};
|
||||
Text wNumber= new Text(null, "Courier", 18f,
|
||||
TextJustification.CENTER, new Coordinate(watchBox.getLinePoints()[7].x -.05,
|
||||
watchBox.getLinePoints()[7].y - .1), 0., TextRotation.SCREEN_RELATIVE,
|
||||
wtext, FontStyle.REGULAR, watchBox.getColors()[0],
|
||||
0, 0, true, DisplayType.NORMAL, "Text", "Text" );
|
||||
ArrayList<IDisplayable> tList = createDisplayElements((IText)wNumber,paintProps);
|
||||
String[] wtext = { String.valueOf(watchBox.getWatchNumber()) };
|
||||
Text wNumber = new Text(null, "Courier", 18f,
|
||||
TextJustification.CENTER, new Coordinate(
|
||||
watchBox.getLinePoints()[7].x - .05,
|
||||
watchBox.getLinePoints()[7].y - .1), 0.,
|
||||
TextRotation.SCREEN_RELATIVE, wtext, FontStyle.REGULAR,
|
||||
watchBox.getColors()[0], 0, 0, true, DisplayType.NORMAL,
|
||||
"Text", "Text");
|
||||
ArrayList<IDisplayable> tList = createDisplayElements(
|
||||
(IText) wNumber, paintProps);
|
||||
|
||||
dlist.addAll(tList);
|
||||
dlist.addAll(tList);
|
||||
}
|
||||
|
||||
return dlist;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to add ALL symbols of the same color into a single wire-frame.
|
||||
|
@ -1555,7 +1684,8 @@ public class DisplayElementFactory {
|
|||
Text label = new Text(null, "Courier", 14.0f,
|
||||
TextJustification.LEFT_JUSTIFY,
|
||||
tcmFcst.getQuarters()[0].getLocation(), 0.0,
|
||||
TextRotation.NORTH_RELATIVE, txt, FontStyle.REGULAR,
|
||||
/* TTR 895 TextRotation.NORTH_RELATIVE, */
|
||||
TextRotation.SCREEN_RELATIVE, txt, FontStyle.REGULAR,
|
||||
getDisplayColor(Color.YELLOW), 4, 0, false,
|
||||
DisplayType.NORMAL, "Text", "General Text");
|
||||
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
*/
|
||||
package gov.noaa.nws.ncep.ui.pgen.display;
|
||||
|
||||
import java.awt.geom.Rectangle2D;
|
||||
|
||||
import gov.noaa.nws.ncep.ui.pgen.display.IText.DisplayType;
|
||||
|
||||
import org.eclipse.swt.graphics.RGB;
|
||||
|
@ -16,169 +14,189 @@ import org.eclipse.swt.graphics.RGB;
|
|||
import com.raytheon.uf.viz.core.DrawableString;
|
||||
import com.raytheon.uf.viz.core.IExtent;
|
||||
import com.raytheon.uf.viz.core.IGraphicsTarget;
|
||||
import com.raytheon.uf.viz.core.IGraphicsTarget.HorizontalAlignment;
|
||||
import com.raytheon.uf.viz.core.IGraphicsTarget.TextStyle;
|
||||
import com.raytheon.uf.viz.core.IGraphicsTarget.VerticalAlignment;
|
||||
import com.raytheon.uf.viz.core.PixelExtent;
|
||||
import com.raytheon.uf.viz.core.drawables.IFont;
|
||||
import com.raytheon.uf.viz.core.drawables.PaintProperties;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
import com.raytheon.viz.ui.color.BackgroundColor;
|
||||
import com.raytheon.viz.ui.color.IBackgroundColorChangedListener.BGColorMode;
|
||||
|
||||
/**
|
||||
* Contains information needed to readily display "text" information to a graphics target.
|
||||
* @prologue TTR 737
|
||||
* @assigned dsushon
|
||||
* status: TTR 737 is dependendent on a code-fix from Raytheon, the class GLTarget needs a mask flag implemented
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Contains information needed to readily display "text" information to a
|
||||
* graphics target.
|
||||
* <P>
|
||||
* Objects of this class are typically created from PGEN "drawable elements" using the DisplayElementFactory
|
||||
* class.
|
||||
* Objects of this class are typically created from PGEN "drawable elements"
|
||||
* using the DisplayElementFactory class.
|
||||
*
|
||||
* @author sgilbert
|
||||
*
|
||||
*/
|
||||
public class TextDisplayElement implements IDisplayable {
|
||||
|
||||
/**
|
||||
* The text to be displayed. Each element of the String array is displayed on a separate line.
|
||||
private String[] text;
|
||||
/**
|
||||
* The text to be displayed. Each element of the String array is displayed
|
||||
* on a separate line. private String[] text;
|
||||
*/
|
||||
|
||||
/**
|
||||
* The font used to display the text private IFont font;
|
||||
*/
|
||||
|
||||
/**
|
||||
* Screen coordinates for the text loation private double xpos, ypos;
|
||||
*/
|
||||
|
||||
/**
|
||||
* Indicates whether any additional style should be applied to the text
|
||||
* display such as a background mask, outline box, etc... private TextStyle
|
||||
* textStyle;
|
||||
*/
|
||||
|
||||
private boolean mask;
|
||||
|
||||
// private RGB color;
|
||||
|
||||
/**
|
||||
* specifies the text justification to use. private HorizontalAlignment
|
||||
* horizontalAlignment;
|
||||
*/
|
||||
|
||||
/**
|
||||
* The rotation angle (relative to the screen) at which to display the text.
|
||||
* private Double rotation;
|
||||
*/
|
||||
private IExtent box;
|
||||
|
||||
private DisplayType displayType;
|
||||
|
||||
private DrawableString dstring;
|
||||
|
||||
/**
|
||||
*/
|
||||
public TextDisplayElement(DrawableString dstring, boolean mask,
|
||||
DisplayType dType, IExtent box) {
|
||||
|
||||
/**
|
||||
* The font used to display the text
|
||||
private IFont font;
|
||||
*/
|
||||
this.mask = mask;
|
||||
this.box = box;
|
||||
// this.xpos = xpos;
|
||||
// this.ypos = ypos;
|
||||
this.displayType = dType;
|
||||
this.dstring = dstring;
|
||||
|
||||
/**
|
||||
* Screen coordinates for the text loation
|
||||
private double xpos, ypos;
|
||||
*/
|
||||
// TODO: uncomment this single line below when DrawableString has
|
||||
// backgroundMaskFlag implemented (requires change from Raytheon)
|
||||
// this.dstring.backgroundMaskFlag = mask;
|
||||
|
||||
/**
|
||||
* Indicates whether any additional style should be applied to the text display
|
||||
* such as a background mask, outline box, etc...
|
||||
private TextStyle textStyle;
|
||||
*/
|
||||
// this.horizontalAlignment = horizontalAlignment;
|
||||
// this.rotation = rotation;
|
||||
|
||||
private boolean mask;
|
||||
//private RGB color;
|
||||
/*
|
||||
* dstring = new DrawableString( text, color); dstring.font = font;
|
||||
* dstring.setCoordinates(xpos, ypos); dstring.textStyle =
|
||||
* TextStyle.NORMAL; dstring.horizontalAlignment = horizontalAlignment;
|
||||
* dstring.verticallAlignment = VerticalAlignment.MIDDLE;
|
||||
* dstring.rotation = rotation;
|
||||
*/
|
||||
|
||||
/**
|
||||
* specifies the text justification to use.
|
||||
private HorizontalAlignment horizontalAlignment;
|
||||
*/
|
||||
// if ( mask || (dType != DisplayType.NORMAL) )
|
||||
// box = createBox(bounds);
|
||||
}
|
||||
|
||||
/**
|
||||
* The rotation angle (relative to the screen) at which to display the text.
|
||||
private Double rotation;
|
||||
*/
|
||||
private IExtent box;
|
||||
private DisplayType displayType;
|
||||
private DrawableString dstring;
|
||||
/*
|
||||
* private IExtent createBox(Rectangle2D bounds) {
|
||||
*
|
||||
* System.out.println("bounds: "+bounds);
|
||||
*
|
||||
* PixelExtent box = new PixelExtent(bounds.getMinX(),bounds.getMaxX(),
|
||||
* bounds.getMinY(), bounds.getMaxY());
|
||||
*
|
||||
* return box; }
|
||||
*/
|
||||
|
||||
/**
|
||||
*/
|
||||
public TextDisplayElement(DrawableString dstring, boolean mask, DisplayType dType,
|
||||
IExtent box) {
|
||||
/**
|
||||
* Disposes any graphic resources held by this object.
|
||||
*
|
||||
* @see gov.noaa.nws.ncep.ui.pgen.display.IDisplayable#dispose()
|
||||
*/
|
||||
@Override
|
||||
public void dispose() {
|
||||
|
||||
this.mask = mask;
|
||||
this.box = box;
|
||||
//this.xpos = xpos;
|
||||
//this.ypos = ypos;
|
||||
this.displayType = dType;
|
||||
this.dstring = dstring;
|
||||
//this.horizontalAlignment = horizontalAlignment;
|
||||
//this.rotation = rotation;
|
||||
dstring.font.dispose();
|
||||
|
||||
/*
|
||||
dstring = new DrawableString( text, color);
|
||||
dstring.font = font;
|
||||
dstring.setCoordinates(xpos, ypos);
|
||||
dstring.textStyle = TextStyle.NORMAL;
|
||||
dstring.horizontalAlignment = horizontalAlignment;
|
||||
dstring.verticallAlignment = VerticalAlignment.MIDDLE;
|
||||
dstring.rotation = rotation;
|
||||
*/
|
||||
}
|
||||
|
||||
//if ( mask || (dType != DisplayType.NORMAL) )
|
||||
// box = createBox(bounds);
|
||||
}
|
||||
/**
|
||||
* Draws the text strings to the specified graphics target
|
||||
*
|
||||
* @param target
|
||||
* Destination graphics target
|
||||
* @see gov.noaa.nws.ncep.ui.pgen.display.IDisplayable#draw(com.raytheon.viz.core.IGraphicsTarget)
|
||||
*/
|
||||
@Override
|
||||
public void draw(IGraphicsTarget target, PaintProperties paintProps) {
|
||||
|
||||
/*
|
||||
private IExtent createBox(Rectangle2D bounds) {
|
||||
// target.setRotateTextAroundPoint(true);
|
||||
|
||||
System.out.println("bounds: "+bounds);
|
||||
try {
|
||||
if (mask) {
|
||||
RGB bg = BackgroundColor.getActivePerspectiveInstance()
|
||||
.getColor(BGColorMode.EDITOR);
|
||||
dstring.boxColor = bg;
|
||||
|
||||
PixelExtent box = new PixelExtent(bounds.getMinX(),bounds.getMaxX(),
|
||||
bounds.getMinY(), bounds.getMaxY());
|
||||
// !!! Keep this before Raytheon implements the mask flag in
|
||||
// DrawableString.
|
||||
target.drawShadedRect(box, bg, 1.0, null);
|
||||
}
|
||||
|
||||
return box;
|
||||
}
|
||||
*/
|
||||
switch (displayType) {
|
||||
|
||||
/**
|
||||
* Disposes any graphic resources held by this object.
|
||||
* @see gov.noaa.nws.ncep.ui.pgen.display.IDisplayable#dispose()
|
||||
*/
|
||||
@Override
|
||||
public void dispose() {
|
||||
case NORMAL:
|
||||
dstring.textStyle = TextStyle.NORMAL;
|
||||
break;
|
||||
|
||||
dstring.font.dispose();
|
||||
case BOX:
|
||||
dstring.textStyle = TextStyle.BOXED;
|
||||
// target.drawRect(box, dstring.getColors()[0], 1.0f, 1.0);
|
||||
break;
|
||||
|
||||
}
|
||||
case OVERLINE:
|
||||
dstring.textStyle = TextStyle.OVERLINE;
|
||||
// target.drawLine(box.getMinX(), box.getMinY(), 0.0,
|
||||
// box.getMaxX(), box.getMinY(), 0.0,
|
||||
// dstring.getColors()[0], 1.0f);
|
||||
break;
|
||||
|
||||
/**
|
||||
* Draws the text strings to the specified graphics target
|
||||
* @param target Destination graphics target
|
||||
* @see gov.noaa.nws.ncep.ui.pgen.display.IDisplayable#draw(com.raytheon.viz.core.IGraphicsTarget)
|
||||
*/
|
||||
@Override
|
||||
public void draw(IGraphicsTarget target, PaintProperties paintProps) {
|
||||
case UNDERLINE:
|
||||
dstring.textStyle = TextStyle.UNDERLINE;
|
||||
// target.drawLine(box.getMinX(), box.getMaxY(), 0.0,
|
||||
// box.getMaxX(), box.getMaxY(), 0.0,
|
||||
// dstring.getColors()[0], 1.0f);
|
||||
break;
|
||||
|
||||
//target.setRotateTextAroundPoint(true);
|
||||
}
|
||||
|
||||
try {
|
||||
if ( mask ) {
|
||||
RGB bg = BackgroundColor.getActivePerspectiveInstance().getColor(BGColorMode.EDITOR);
|
||||
target.drawShadedRect(box, bg, 1.0, null);
|
||||
}
|
||||
target.drawStrings(dstring);
|
||||
|
||||
switch (displayType) {
|
||||
|
||||
case BOX:
|
||||
target.drawRect(box, dstring.getColors()[0], 1.0f, 1.0);
|
||||
break;
|
||||
|
||||
case OVERLINE:
|
||||
target.drawLine(box.getMinX(), box.getMinY(), 0.0, box.getMaxX(), box.getMinY(),
|
||||
0.0, dstring.getColors()[0], 1.0f);
|
||||
break;
|
||||
|
||||
case UNDERLINE:
|
||||
target.drawLine(box.getMinX(), box.getMaxY(), 0.0, box.getMaxX(), box.getMaxY(),
|
||||
0.0, dstring.getColors()[0], 1.0f);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
target.drawStrings(dstring);
|
||||
/*
|
||||
if ( text.length == 1 ) {
|
||||
target.drawString(font, text[0], xpos, ypos, 0.0, textStyle, color, horizontalAlignment, VerticalAlignment.MIDDLE, rotation);
|
||||
}
|
||||
else {
|
||||
RGB[] colors = new RGB[text.length];
|
||||
for ( int j=0; j<text.length; j++ ) {
|
||||
colors[j] = color;
|
||||
}
|
||||
target.drawStrings1Box(font, text, xpos, ypos, 0.0, textStyle, colors, horizontalAlignment, rotation);
|
||||
}
|
||||
*/
|
||||
}
|
||||
catch (VizException ve) {
|
||||
ve.printStackTrace();
|
||||
}
|
||||
//finally {
|
||||
// target.setRotateTextAroundPoint(false);
|
||||
//}
|
||||
|
||||
}
|
||||
/*
|
||||
* if ( text.length == 1 ) { target.drawString(font, text[0], xpos,
|
||||
* ypos, 0.0, textStyle, color, horizontalAlignment,
|
||||
* VerticalAlignment.MIDDLE, rotation); } else { RGB[] colors = new
|
||||
* RGB[text.length]; for ( int j=0; j<text.length; j++ ) { colors[j]
|
||||
* = color; } target.drawStrings1Box(font, text, xpos, ypos, 0.0,
|
||||
* textStyle, colors, horizontalAlignment, rotation); }
|
||||
*/
|
||||
} catch (VizException ve) {
|
||||
ve.printStackTrace();
|
||||
}
|
||||
// finally {
|
||||
// target.setRotateTextAroundPoint(false);
|
||||
// }
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,7 +33,6 @@ import java.util.HashSet;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import javax.xml.transform.Source;
|
||||
import javax.xml.transform.Transformer;
|
||||
|
@ -70,6 +69,7 @@ import com.vividsolutions.jts.geom.Polygon;
|
|||
* 04/13 #977 S. Gilbert PGEN Database support
|
||||
* 12/13 TTR904 B. Yin Increased county name column to 17 characters
|
||||
* 12/13 TTR800 B. Yin Added original county list
|
||||
* 04/14 TRAC 1112 S. Russell Added updateActiveCountiesInWatchBox()
|
||||
* </pre>
|
||||
*
|
||||
* @author B. Yin
|
||||
|
@ -77,9 +77,7 @@ import com.vividsolutions.jts.geom.Polygon;
|
|||
@ElementOperations({ Operation.COPY_MOVE, Operation.EXTRAPOLATE })
|
||||
public class WatchBox extends MultiPointElement implements IWatchBox {
|
||||
|
||||
/*
|
||||
* default half width for watch box in statute miles.
|
||||
*/
|
||||
/* default half width for watch box in statute miles. */
|
||||
public final static float HALF_WIDTH = 60f;
|
||||
|
||||
// State names
|
||||
|
@ -89,8 +87,7 @@ public class WatchBox extends MultiPointElement implements IWatchBox {
|
|||
NS, EW, ESOL
|
||||
};
|
||||
|
||||
public static String dirs[] = { "N", "NNE", "NE", "ENE", "E", "ESE", "SE",
|
||||
"SSE", "S", "SSW", "SW", "WSW", "W", "WNW", "NW", "NNW", "N" };
|
||||
public static String dirs[] = { "N", "NNE", "NE", "ENE", "E", "ESE", "SE", "SSE", "S", "SSW", "SW", "WSW", "W", "WNW", "NW", "NNW", "N" };
|
||||
|
||||
private WatchShape boxShape;
|
||||
|
||||
|
@ -107,6 +104,7 @@ public class WatchBox extends MultiPointElement implements IWatchBox {
|
|||
private Station anchors[];
|
||||
|
||||
private List<SPCCounty> countyList;
|
||||
|
||||
private List<SPCCounty> originalCountyList;
|
||||
|
||||
// Watch Issue Information
|
||||
|
@ -193,42 +191,31 @@ public class WatchBox extends MultiPointElement implements IWatchBox {
|
|||
* County list is NOT copied
|
||||
*/
|
||||
public AbstractDrawableComponent copy() {
|
||||
/*
|
||||
* create a new Line object and initially set its attributes to this
|
||||
* one's
|
||||
*/
|
||||
/* create a new Line object and initially set its attributes to this
|
||||
* one's */
|
||||
WatchBox newWatchBox = new WatchBox();
|
||||
|
||||
newWatchBox.setAnchors(anchors[0], anchors[1]);
|
||||
newWatchBox.update(this);
|
||||
|
||||
/*
|
||||
* new Coordinates points are created and set, so we don't just set
|
||||
* references
|
||||
*/
|
||||
/* new Coordinates points are created and set, so we don't just set
|
||||
* references */
|
||||
ArrayList<Coordinate> ptsCopy = new ArrayList<Coordinate>();
|
||||
for (int i = 0; i < this.getPoints().size(); i++) {
|
||||
ptsCopy.add(new Coordinate(this.getPoints().get(i)));
|
||||
}
|
||||
newWatchBox.setPoints(ptsCopy);
|
||||
|
||||
/*
|
||||
* new colors are created and set, so we don't just set references
|
||||
*/
|
||||
/* new colors are created and set, so we don't just set references */
|
||||
Color[] colorCopy = new Color[this.getColors().length];
|
||||
for (int i = 0; i < this.getColors().length; i++) {
|
||||
colorCopy[i] = new Color(this.getColors()[i].getRed(),
|
||||
this.getColors()[i].getGreen(),
|
||||
this.getColors()[i].getBlue());
|
||||
colorCopy[i] = new Color(this.getColors()[i].getRed(), this.getColors()[i].getGreen(), this.getColors()[i].getBlue());
|
||||
}
|
||||
newWatchBox.setColors(colorCopy);
|
||||
if (fillColor != null) {
|
||||
newWatchBox.setFillColor(new Color(fillColor.getRed(), fillColor
|
||||
.getGreen(), fillColor.getBlue()));
|
||||
newWatchBox.setFillColor(new Color(fillColor.getRed(), fillColor.getGreen(), fillColor.getBlue()));
|
||||
}
|
||||
/*
|
||||
* new Strings are created for Type and LinePattern
|
||||
*/
|
||||
/* new Strings are created for Type and LinePattern */
|
||||
newWatchBox.setPgenCategory(new String(this.getPgenCategory()));
|
||||
newWatchBox.setPgenType(new String(this.getPgenType()));
|
||||
newWatchBox.setParent(this.getParent());
|
||||
|
@ -237,37 +224,37 @@ public class WatchBox extends MultiPointElement implements IWatchBox {
|
|||
newWatchBox.setWatchSymbolSize(symbolSize);
|
||||
newWatchBox.setWatchSymbolWidth(symbolWidth);
|
||||
|
||||
newWatchBox.setIssueStatus(getIssueStatus());
|
||||
newWatchBox.setIssueStatus(getIssueStatus());
|
||||
newWatchBox.setWatchNumber(watchNumber);
|
||||
newWatchBox.setIssueFlag(getIssueFlag());
|
||||
newWatchBox.setForecaster(forecaster);
|
||||
newWatchBox.setIssueTime(getIssueTime());
|
||||
newWatchBox.setIssueTime(getIssueTime());
|
||||
newWatchBox.setExpTime(this.getExpTime());
|
||||
newWatchBox.setSeverity(this.getSeverity());
|
||||
newWatchBox.setTimeZone(this.getTimeZone());
|
||||
newWatchBox.setHailSize(this.getHailSize());
|
||||
newWatchBox.setGust(this.getGust());
|
||||
newWatchBox.setTop(this.getTop());
|
||||
newWatchBox.setMoveDir(this.getMoveDir());
|
||||
newWatchBox.setMoveSpeed(this.getMoveSpeed());
|
||||
newWatchBox.setStatesIncl(this.getStatesIncl());
|
||||
newWatchBox.setAdjAreas( this.getAdjAreas() );
|
||||
newWatchBox.setWatchType(getWatchType());
|
||||
newWatchBox.setSeverity(this.getSeverity());
|
||||
newWatchBox.setTimeZone(this.getTimeZone());
|
||||
newWatchBox.setHailSize(this.getHailSize());
|
||||
newWatchBox.setGust(this.getGust());
|
||||
newWatchBox.setTop(this.getTop());
|
||||
newWatchBox.setMoveDir(this.getMoveDir());
|
||||
newWatchBox.setMoveSpeed(this.getMoveSpeed());
|
||||
newWatchBox.setStatesIncl(this.getStatesIncl());
|
||||
newWatchBox.setAdjAreas(this.getAdjAreas());
|
||||
newWatchBox.setWatchType(getWatchType());
|
||||
|
||||
newWatchBox.setEndPointAnc(this.getEndPointAnc());
|
||||
newWatchBox.setEndPointVor(this.getEndPointVor());
|
||||
newWatchBox.setHalfWidthSm(this.getHalfWidthSm());
|
||||
newWatchBox.setHalfWidthNm(this.getHalfWidthNm());
|
||||
newWatchBox.setWathcAreaNm(this.getWathcAreaNm());
|
||||
newWatchBox.setCntyInfo(this.getCntyInfo());
|
||||
newWatchBox.setEndPointAnc(this.getEndPointAnc());
|
||||
newWatchBox.setEndPointVor(this.getEndPointVor());
|
||||
newWatchBox.setHalfWidthSm(this.getHalfWidthSm());
|
||||
newWatchBox.setHalfWidthNm(this.getHalfWidthNm());
|
||||
newWatchBox.setWathcAreaNm(this.getWathcAreaNm());
|
||||
newWatchBox.setCntyInfo(this.getCntyInfo());
|
||||
|
||||
newWatchBox.setContWatch( this.getContWatch());
|
||||
newWatchBox.setReplWatch(this.getReplWatch());
|
||||
newWatchBox.setContWatch(this.getContWatch());
|
||||
newWatchBox.setReplWatch(this.getReplWatch());
|
||||
|
||||
newWatchBox.setCountyList(new ArrayList<SPCCounty>( this.getCountyList()));
|
||||
if ( this.getOriginalCountyList() != null ){
|
||||
newWatchBox.setOriginalCountyList( this.getOriginalCountyList());
|
||||
}
|
||||
newWatchBox.setCountyList(new ArrayList<SPCCounty>(this.getCountyList()));
|
||||
if (this.getOriginalCountyList() != null) {
|
||||
newWatchBox.setOriginalCountyList(this.getOriginalCountyList());
|
||||
}
|
||||
|
||||
return newWatchBox;
|
||||
}
|
||||
|
@ -341,8 +328,7 @@ public class WatchBox extends MultiPointElement implements IWatchBox {
|
|||
GeodeticCalculator gc = new GeodeticCalculator(DefaultEllipsoid.WGS84);
|
||||
|
||||
gc.setStartingGeographicPoint(linePoints.get(0).x, linePoints.get(0).y);
|
||||
gc.setDestinationGeographicPoint(linePoints.get(1).x,
|
||||
linePoints.get(1).y);
|
||||
gc.setDestinationGeographicPoint(linePoints.get(1).x, linePoints.get(1).y);
|
||||
|
||||
return gc.getOrthodromicDistance();
|
||||
}
|
||||
|
@ -355,32 +341,11 @@ public class WatchBox extends MultiPointElement implements IWatchBox {
|
|||
public String getSpec() {
|
||||
String spec;
|
||||
|
||||
spec = String.format("%1$5.2f%2$10.2f", linePoints.get(0).y,
|
||||
linePoints.get(0).x)
|
||||
+ " "
|
||||
+ getRelative(linePoints.get(0), anchors[0])
|
||||
+ " "
|
||||
+ getRelative(linePoints.get(0),
|
||||
getNearestVor(linePoints.get(0)))
|
||||
+ "\n"
|
||||
+ String.format("%1$5.2f%2$10.2f", linePoints.get(4).y,
|
||||
linePoints.get(4).x)
|
||||
+ " "
|
||||
+ getRelative(linePoints.get(4), anchors[1])
|
||||
+ " "
|
||||
+ getRelative(linePoints.get(4),
|
||||
getNearestVor(linePoints.get(4)))
|
||||
+ "\n"
|
||||
+ "ORIENT: "
|
||||
+ boxShape.toString()
|
||||
+ " - HALF WIDTH: "
|
||||
+ String.format("%1$4.0f", getHalfWidth() / PgenUtil.SM2M)
|
||||
+ "sm ("
|
||||
+ Math.round(getHalfWidth() / PgenUtil.NM2M / 5.0)
|
||||
* 5
|
||||
+ " nm)\n"
|
||||
+ "AREA(sq nautical miles): "
|
||||
+ String.format("%1$-8.0f", getWatchArea()) + "\n";
|
||||
spec = String.format("%1$5.2f%2$10.2f", linePoints.get(0).y, linePoints.get(0).x) + " " + getRelative(linePoints.get(0), anchors[0]) + " "
|
||||
+ getRelative(linePoints.get(0), getNearestVor(linePoints.get(0))) + "\n" + String.format("%1$5.2f%2$10.2f", linePoints.get(4).y, linePoints.get(4).x) + " "
|
||||
+ getRelative(linePoints.get(4), anchors[1]) + " " + getRelative(linePoints.get(4), getNearestVor(linePoints.get(4))) + "\n" + "ORIENT: " + boxShape.toString()
|
||||
+ " - HALF WIDTH: " + String.format("%1$4.0f", getHalfWidth() / PgenUtil.SM2M) + "sm (" + Math.round(getHalfWidth() / PgenUtil.NM2M / 5.0) * 5 + " nm)\n"
|
||||
+ "AREA(sq nautical miles): " + String.format("%1$-8.0f", getWatchArea()) + "\n";
|
||||
|
||||
return spec;
|
||||
}
|
||||
|
@ -404,8 +369,7 @@ public class WatchBox extends MultiPointElement implements IWatchBox {
|
|||
long dir = Math.round(gc.getAzimuth());
|
||||
if (dir < 0)
|
||||
dir += 360;
|
||||
String str = String.format("%1$4d%2$5s%3$5s", dist,
|
||||
dirs[(int) Math.round(dir / 22.5)], st.getStid());
|
||||
String str = String.format("%1$4d%2$5s%3$5s", dist, dirs[(int) Math.round(dir / 22.5)], st.getStid());
|
||||
// String str = dist + " " + dirs[(int)Math.round(dir/22.5)]+ " " +
|
||||
// st.getStid() ;
|
||||
return str;
|
||||
|
@ -419,8 +383,7 @@ public class WatchBox extends MultiPointElement implements IWatchBox {
|
|||
*/
|
||||
public Station getNearestVor(Coordinate loc) {
|
||||
|
||||
return PgenStaticDataProvider.getProvider().getVorTbl()
|
||||
.getNearestStation(loc);
|
||||
return PgenStaticDataProvider.getProvider().getVorTbl().getNearestStation(loc);
|
||||
|
||||
}
|
||||
|
||||
|
@ -433,14 +396,12 @@ public class WatchBox extends MultiPointElement implements IWatchBox {
|
|||
GeodeticCalculator gc = new GeodeticCalculator(DefaultEllipsoid.WGS84);
|
||||
|
||||
gc.setStartingGeographicPoint(linePoints.get(0).x, linePoints.get(0).y);
|
||||
gc.setDestinationGeographicPoint(linePoints.get(4).x,
|
||||
linePoints.get(4).y);
|
||||
gc.setDestinationGeographicPoint(linePoints.get(4).x, linePoints.get(4).y);
|
||||
|
||||
double base = gc.getOrthodromicDistance();
|
||||
|
||||
Coordinate intrPt = new Coordinate();
|
||||
getDistanceFromLine(linePoints.get(1), linePoints.get(0),
|
||||
linePoints.get(4), intrPt);
|
||||
getDistanceFromLine(linePoints.get(1), linePoints.get(0), linePoints.get(4), intrPt);
|
||||
|
||||
gc.setStartingGeographicPoint(linePoints.get(1).x, linePoints.get(1).y);
|
||||
gc.setDestinationGeographicPoint(intrPt.x, intrPt.y);
|
||||
|
@ -464,8 +425,7 @@ public class WatchBox extends MultiPointElement implements IWatchBox {
|
|||
* - the nearest point on the line
|
||||
* @return - the distance from the input point to the input line
|
||||
*/
|
||||
private double getDistanceFromLine(Coordinate point, Coordinate lnPt1,
|
||||
Coordinate lnPt2, Coordinate intrsctPt) {
|
||||
private double getDistanceFromLine(Coordinate point, Coordinate lnPt1, Coordinate lnPt2, Coordinate intrsctPt) {
|
||||
if (lnPt1.x == lnPt2.x) {
|
||||
intrsctPt.x = lnPt1.x;
|
||||
intrsctPt.y = point.y;
|
||||
|
@ -481,8 +441,7 @@ public class WatchBox extends MultiPointElement implements IWatchBox {
|
|||
double b = point.y - m * point.x;
|
||||
intrsctPt.x = (b - bi) / (mi - m);
|
||||
intrsctPt.y = m * (intrsctPt.x) + b;
|
||||
double d = (intrsctPt.x - point.x) * (intrsctPt.x - point.x)
|
||||
+ (intrsctPt.y - point.y) * (intrsctPt.y - point.y);
|
||||
double d = (intrsctPt.x - point.x) * (intrsctPt.x - point.x) + (intrsctPt.y - point.y) * (intrsctPt.y - point.y);
|
||||
return Math.sqrt(d);
|
||||
}
|
||||
}
|
||||
|
@ -590,8 +549,7 @@ public class WatchBox extends MultiPointElement implements IWatchBox {
|
|||
// wfo can be more than one
|
||||
if (wfo != null) {
|
||||
for (int ii = 0; ii < wfo.length(); ii += 3) {
|
||||
String wfoStr = wfo.substring(ii,
|
||||
wfo.length() > ii + 3 ? ii + 3 : wfo.length());
|
||||
String wfoStr = wfo.substring(ii, wfo.length() > ii + 3 ? ii + 3 : wfo.length());
|
||||
if (!wfos.contains(wfoStr))
|
||||
wfos.add(wfoStr);
|
||||
}
|
||||
|
@ -613,8 +571,7 @@ public class WatchBox extends MultiPointElement implements IWatchBox {
|
|||
if (countyList != null && !countyList.isEmpty()) {
|
||||
for (SPCCounty cnty : countyList) {
|
||||
|
||||
if (cnty.getState() != null
|
||||
&& !states.contains(cnty.getState())) {
|
||||
if (cnty.getState() != null && !states.contains(cnty.getState())) {
|
||||
states.add(cnty.getState());
|
||||
// System.out.println(obj[2]+"...");
|
||||
|
||||
|
@ -636,8 +593,7 @@ public class WatchBox extends MultiPointElement implements IWatchBox {
|
|||
Iterator<SPCCounty> it = countyList.iterator();
|
||||
while (it.hasNext()) {
|
||||
SPCCounty cnty = it.next();
|
||||
if (cnty.getState() != null
|
||||
&& cnty.getState().equalsIgnoreCase(state)) {
|
||||
if (cnty.getState() != null && cnty.getState().equalsIgnoreCase(state)) {
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
|
@ -654,8 +610,7 @@ public class WatchBox extends MultiPointElement implements IWatchBox {
|
|||
Iterator<SPCCounty> it = countyList.iterator();
|
||||
while (it.hasNext()) {
|
||||
SPCCounty cnty = it.next();
|
||||
if (cnty.getWfo() != null
|
||||
&& cnty.getWfo().equalsIgnoreCase(cwa)) {
|
||||
if (cnty.getWfo() != null && cnty.getWfo().equalsIgnoreCase(cwa)) {
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
|
@ -668,14 +623,11 @@ public class WatchBox extends MultiPointElement implements IWatchBox {
|
|||
* @param cwa
|
||||
*/
|
||||
public void addCwa(String cwa) {
|
||||
List<SPCCounty> allCounties = PgenStaticDataProvider.getProvider()
|
||||
.getSPCCounties();
|
||||
List<SPCCounty> allCounties = PgenStaticDataProvider.getProvider().getSPCCounties();
|
||||
|
||||
if (allCounties != null) {
|
||||
for (SPCCounty cnty : allCounties) {
|
||||
if (cnty.getWfo() != null
|
||||
&& cnty.getWfo().equalsIgnoreCase(cwa)
|
||||
&& !countyList.contains(cnty)) {
|
||||
if (cnty.getWfo() != null && cnty.getWfo().equalsIgnoreCase(cwa) && !countyList.contains(cnty)) {
|
||||
countyList.add(cnty);
|
||||
}
|
||||
}
|
||||
|
@ -731,8 +683,7 @@ public class WatchBox extends MultiPointElement implements IWatchBox {
|
|||
continue;
|
||||
|
||||
// Check any county centeriod inside the hole
|
||||
for (SPCCounty cnty : PgenStaticDataProvider.getProvider()
|
||||
.getSPCCounties()) {
|
||||
for (SPCCounty cnty : PgenStaticDataProvider.getProvider().getSPCCounties()) {
|
||||
|
||||
if (p.contains(gf.createPoint(cnty.getCentriod()))) {
|
||||
rt.add(cnty);
|
||||
|
@ -809,8 +760,7 @@ public class WatchBox extends MultiPointElement implements IWatchBox {
|
|||
|
||||
GeometryFactory gf = new GeometryFactory();
|
||||
|
||||
GeometryCollection geometryCollection = (GeometryCollection) gf
|
||||
.buildGeometry(gCollection);
|
||||
GeometryCollection geometryCollection = (GeometryCollection) gf.buildGeometry(gCollection);
|
||||
|
||||
return geometryCollection.union();
|
||||
|
||||
|
@ -964,34 +914,20 @@ public class WatchBox extends MultiPointElement implements IWatchBox {
|
|||
msg += String.format("PDS/Normal:\t\t%1$s\n", getSeverity());
|
||||
msg += "ISSUE TIME:\t\tXX XX XXXX XXXX\n";
|
||||
msg += "VALID TIME:\t\tXX XX XXXX XXXX\n";
|
||||
msg += String.format("EXPIRATION TIME:\t%1$tm %1$td %1$tY %1$tY\n",
|
||||
getExpTime());
|
||||
msg += String.format("ENDPOINT (ANC,sm):\t%1$s - %2$s\n",
|
||||
getRelative(getPoints().get(0), getAnchors()[0]).trim(),
|
||||
getRelative(getPoints().get(4), getAnchors()[1]).trim());
|
||||
msg += String.format(
|
||||
"ENDPOINT (VOR,nm):\t%1$s - %2$s\n",
|
||||
getRelative(getPoints().get(0),
|
||||
getNearestVor(getPoints().get(0))).trim(),
|
||||
getRelative(getPoints().get(4),
|
||||
getNearestVor(getPoints().get(4))).trim());
|
||||
msg += String.format("ATTRIB (ANC,sm):\t%1$-4.0f\n", getHalfWidth()
|
||||
/ PgenUtil.SM2M);
|
||||
msg += String.format("ATTRIB (VOR,nm):\t%1$-4d\n",
|
||||
Math.round(getHalfWidth() / PgenUtil.NM2M / 5.0) * 5);
|
||||
msg += String.format("WATCH CORNER POINT:\t%1$-6.2f %2$-6.2f\n",
|
||||
getPoints().get(1).y, getPoints().get(1).x);
|
||||
msg += String.format("WATCH CORNER POINT:\t%1$-6.2f %2$-6.2f\n",
|
||||
getPoints().get(3).y, getPoints().get(3).x);
|
||||
msg += String.format("WATCH CORNER POINT:\t%1$-6.2f %2$-6.2f\n",
|
||||
getPoints().get(5).y, getPoints().get(5).x);
|
||||
msg += String.format("WATCH CORNER POINT:\t%1$-6.2f %2$-6.2f\n",
|
||||
getPoints().get(7).y, getPoints().get(7).x);
|
||||
msg += String.format("EXPIRATION TIME:\t%1$tm %1$td %1$tY %1$tY\n", getExpTime());
|
||||
msg += String.format("ENDPOINT (ANC,sm):\t%1$s - %2$s\n", getRelative(getPoints().get(0), getAnchors()[0]).trim(), getRelative(getPoints().get(4), getAnchors()[1]).trim());
|
||||
msg += String.format("ENDPOINT (VOR,nm):\t%1$s - %2$s\n", getRelative(getPoints().get(0), getNearestVor(getPoints().get(0))).trim(),
|
||||
getRelative(getPoints().get(4), getNearestVor(getPoints().get(4))).trim());
|
||||
msg += String.format("ATTRIB (ANC,sm):\t%1$-4.0f\n", getHalfWidth() / PgenUtil.SM2M);
|
||||
msg += String.format("ATTRIB (VOR,nm):\t%1$-4d\n", Math.round(getHalfWidth() / PgenUtil.NM2M / 5.0) * 5);
|
||||
msg += String.format("WATCH CORNER POINT:\t%1$-6.2f %2$-6.2f\n", getPoints().get(1).y, getPoints().get(1).x);
|
||||
msg += String.format("WATCH CORNER POINT:\t%1$-6.2f %2$-6.2f\n", getPoints().get(3).y, getPoints().get(3).x);
|
||||
msg += String.format("WATCH CORNER POINT:\t%1$-6.2f %2$-6.2f\n", getPoints().get(5).y, getPoints().get(5).x);
|
||||
msg += String.format("WATCH CORNER POINT:\t%1$-6.2f %2$-6.2f\n", getPoints().get(7).y, getPoints().get(7).x);
|
||||
msg += String.format("HAIL SIZE (in):\t\t%1$-4.2f\n", getHailSize());
|
||||
msg += String.format("MAX GUSTS (kts):\t%1$-4d\n", getGust());
|
||||
msg += String.format("MAX TOPS (100s ft):\t%1$-6d\n", getTop());
|
||||
msg += String.format("MOTION (deg,kts):\t%1$-4d %2$-4d\n",
|
||||
getMoveDir(), getMoveSpeed());
|
||||
msg += String.format("MOTION (deg,kts):\t%1$-4d %2$-4d\n", getMoveDir(), getMoveSpeed());
|
||||
msg += String.format("TIME ZONE:\t\t%1$s\n", getTimeZone());
|
||||
msg += String.format("REPL WATCH NUMBER:\t%1$s\n", getReplWatch());
|
||||
msg += String.format("STATES INCLUDED:\t%1$s\n", getStatesIncl());
|
||||
|
@ -1010,37 +946,25 @@ public class WatchBox extends MultiPointElement implements IWatchBox {
|
|||
String wbFile = "ww0002.xml";
|
||||
String xsltFile = "wou.xlt";
|
||||
|
||||
/*
|
||||
* Convert XML string into xmlSourse
|
||||
*/
|
||||
/* Convert XML string into xmlSourse */
|
||||
Source xmlSource = new StreamSource(wbFile);
|
||||
|
||||
/*
|
||||
* Construct xsltSource from xslfFile
|
||||
*/
|
||||
/* Construct xsltSource from xslfFile */
|
||||
Source xsltSource = new StreamSource(xsltFile);
|
||||
|
||||
/*
|
||||
* Use the factory for XSLT transformer
|
||||
*/
|
||||
/* Use the factory for XSLT transformer */
|
||||
TransformerFactory transFact = TransformerFactory.newInstance();
|
||||
try {
|
||||
Transformer trans = transFact.newTransformer(xsltSource);
|
||||
|
||||
/*
|
||||
* Create object for the transformation product
|
||||
*/
|
||||
/* Create object for the transformation product */
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
|
||||
trans.transform(xmlSource, new StreamResult(baos));
|
||||
/*
|
||||
* Convert transformation product to string
|
||||
*/
|
||||
/* Convert transformation product to string */
|
||||
res = new String(baos.toByteArray());
|
||||
} catch (Exception e) {
|
||||
/*
|
||||
* Catch invalid control characters in the report
|
||||
*/
|
||||
/* Catch invalid control characters in the report */
|
||||
e.printStackTrace();
|
||||
|
||||
}
|
||||
|
@ -1056,14 +980,11 @@ public class WatchBox extends MultiPointElement implements IWatchBox {
|
|||
public boolean hasStatusLine() {
|
||||
|
||||
AbstractDrawableComponent adc = this.getParent();
|
||||
if (adc instanceof DECollection
|
||||
&& adc.getName().equalsIgnoreCase("Watch")) {
|
||||
Iterator<DrawableElement> it = ((DECollection) adc)
|
||||
.createDEIterator();
|
||||
if (adc instanceof DECollection && adc.getName().equalsIgnoreCase("Watch")) {
|
||||
Iterator<DrawableElement> it = ((DECollection) adc).createDEIterator();
|
||||
while (it.hasNext()) {
|
||||
DrawableElement de = it.next();
|
||||
if (de instanceof Line
|
||||
&& de.getPgenType().equalsIgnoreCase("POINTED_ARROW")) {
|
||||
if (de instanceof Line && de.getPgenType().equalsIgnoreCase("POINTED_ARROW")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1103,20 +1024,18 @@ public class WatchBox extends MultiPointElement implements IWatchBox {
|
|||
Layer defaultLayer = new Layer();
|
||||
//defaultLayer.addElement(this.getParent());
|
||||
|
||||
DECollection dec = new DECollection("Watch");
|
||||
dec.setPgenType("WatchBox");
|
||||
dec.setPgenCategory("MET");
|
||||
dec.add( this.copy() );
|
||||
defaultLayer.addElement(dec);
|
||||
|
||||
DECollection dec = new DECollection("Watch");
|
||||
dec.setPgenType("WatchBox");
|
||||
dec.setPgenCategory("MET");
|
||||
dec.add(this.copy());
|
||||
defaultLayer.addElement(dec);
|
||||
|
||||
ArrayList<Layer> layerList = new ArrayList<Layer>();
|
||||
layerList.add(defaultLayer);
|
||||
|
||||
ProductTime refTime = new ProductTime(getIssueTime());
|
||||
|
||||
Product defaultProduct = new Product("WatchBox", "WATCHBOX", forecaster, null,
|
||||
refTime, layerList);
|
||||
Product defaultProduct = new Product("WatchBox", "WATCHBOX", forecaster, null, refTime, layerList);
|
||||
|
||||
defaultProduct.setOutputFile(label);
|
||||
defaultProduct.setCenter(PgenUtil.getCurrentOffice());
|
||||
|
@ -1260,12 +1179,10 @@ public class WatchBox extends MultiPointElement implements IWatchBox {
|
|||
public static Coordinate snapOnAnchor(Station anchor, Coordinate point) {
|
||||
|
||||
GeodeticCalculator gc = new GeodeticCalculator(DefaultEllipsoid.WGS84);
|
||||
gc.setStartingGeographicPoint(anchor.getLongitude(),
|
||||
anchor.getLatitude());
|
||||
gc.setStartingGeographicPoint(anchor.getLongitude(), anchor.getLatitude());
|
||||
gc.setDestinationGeographicPoint(point.x, point.y);
|
||||
|
||||
double dis = Math
|
||||
.round((float) (gc.getOrthodromicDistance() / PgenUtil.SM2M) / 5) * 5.0;
|
||||
double dis = Math.round((float) (gc.getOrthodromicDistance() / PgenUtil.SM2M) / 5) * 5.0;
|
||||
double angle = Math.round(gc.getAzimuth() / 22.5) * 22.5;
|
||||
|
||||
gc.setDirection(angle, dis * PgenUtil.SM2M);
|
||||
|
@ -1284,8 +1201,7 @@ public class WatchBox extends MultiPointElement implements IWatchBox {
|
|||
* - a list of anchor points
|
||||
* @return - the nearest acnhor point
|
||||
*/
|
||||
public static Station getNearestAnchorPt(Coordinate pt,
|
||||
List<Station> anchorList) {
|
||||
public static Station getNearestAnchorPt(Coordinate pt, List<Station> anchorList) {
|
||||
|
||||
GeodeticCalculator gc = new GeodeticCalculator(DefaultEllipsoid.WGS84);
|
||||
gc.setStartingGeographicPoint(pt.x, pt.y);
|
||||
|
@ -1296,8 +1212,7 @@ public class WatchBox extends MultiPointElement implements IWatchBox {
|
|||
;
|
||||
|
||||
for (Station stn : anchorList) {
|
||||
gc.setDestinationGeographicPoint(stn.getLongitude(),
|
||||
stn.getLatitude());
|
||||
gc.setDestinationGeographicPoint(stn.getLongitude(), stn.getLatitude());
|
||||
|
||||
try {
|
||||
dist = gc.getOrthodromicDistance();
|
||||
|
@ -1328,8 +1243,7 @@ public class WatchBox extends MultiPointElement implements IWatchBox {
|
|||
* : second input location
|
||||
* @return
|
||||
*/
|
||||
public static ArrayList<Coordinate> generateWatchBoxPts(WatchShape ws,
|
||||
double halfWidth, Coordinate point1, Coordinate point2) {
|
||||
public static ArrayList<Coordinate> generateWatchBoxPts(WatchShape ws, double halfWidth, Coordinate point1, Coordinate point2) {
|
||||
|
||||
ArrayList<Coordinate> watchBoxPts;
|
||||
|
||||
|
@ -1343,9 +1257,7 @@ public class WatchBox extends MultiPointElement implements IWatchBox {
|
|||
if (Math.abs(point1.x - point2.x) < 0.0001) {
|
||||
dir = 90;
|
||||
} else {
|
||||
dir = 180
|
||||
- Math.atan((point2.y - point1.y)
|
||||
/ (point2.x - point1.x)) * 180 / Math.PI;
|
||||
dir = 180 - Math.atan((point2.y - point1.y) / (point2.x - point1.x)) * 180 / Math.PI;
|
||||
if (dir > 180)
|
||||
dir -= 360;
|
||||
|
||||
|
@ -1371,8 +1283,7 @@ public class WatchBox extends MultiPointElement implements IWatchBox {
|
|||
* @param point2
|
||||
* @return
|
||||
*/
|
||||
private static ArrayList<Coordinate> generateWatchBoxPts(double direction,
|
||||
double halfWidth, Coordinate point1, Coordinate point2) {
|
||||
private static ArrayList<Coordinate> generateWatchBoxPts(double direction, double halfWidth, Coordinate point1, Coordinate point2) {
|
||||
|
||||
// get direction from point2 to point 1
|
||||
double dir1 = direction + 180;
|
||||
|
@ -1403,8 +1314,7 @@ public class WatchBox extends MultiPointElement implements IWatchBox {
|
|||
pt = gc.getDestinationGeographicPoint();
|
||||
Coordinate pt4 = new Coordinate(pt.getX(), pt.getY());
|
||||
|
||||
Coordinate pt3 = new Coordinate((pt2.x + pt4.x) / 2,
|
||||
(pt2.y + pt4.y) / 2);
|
||||
Coordinate pt3 = new Coordinate((pt2.x + pt4.x) / 2, (pt2.y + pt4.y) / 2);
|
||||
|
||||
Coordinate pt5 = new Coordinate(point2.x, point2.y);
|
||||
|
||||
|
@ -1412,8 +1322,7 @@ public class WatchBox extends MultiPointElement implements IWatchBox {
|
|||
pt = gc.getDestinationGeographicPoint();
|
||||
Coordinate pt6 = new Coordinate(pt.getX(), pt.getY());
|
||||
|
||||
Coordinate pt7 = new Coordinate((pt6.x + pt8.x) / 2,
|
||||
(pt6.y + pt8.y) / 2);
|
||||
Coordinate pt7 = new Coordinate((pt6.x + pt8.x) / 2, (pt6.y + pt8.y) / 2);
|
||||
|
||||
watchBoxPts.add(pt1);
|
||||
watchBoxPts.add(pt2);
|
||||
|
@ -1437,8 +1346,7 @@ public class WatchBox extends MultiPointElement implements IWatchBox {
|
|||
* - new location of the editing point.
|
||||
* @return - points of the new watch box
|
||||
*/
|
||||
public ArrayList<Coordinate> createNewWatchBox(int ptIdx, Coordinate loc,
|
||||
WatchShape ws) {
|
||||
public ArrayList<Coordinate> createNewWatchBox(int ptIdx, Coordinate loc, WatchShape ws) {
|
||||
|
||||
Coordinate newPt0 = new Coordinate();
|
||||
Coordinate newPt4 = new Coordinate();
|
||||
|
@ -1464,8 +1372,7 @@ public class WatchBox extends MultiPointElement implements IWatchBox {
|
|||
* - new location for point 4
|
||||
* @return - half width of the new watch box
|
||||
*/
|
||||
private double getNewHalfWidth(int ptIdx, Coordinate loc,
|
||||
Coordinate newWbPt0, Coordinate newWbPt4) {
|
||||
private double getNewHalfWidth(int ptIdx, Coordinate loc, Coordinate newWbPt0, Coordinate newWbPt4) {
|
||||
|
||||
GeodeticCalculator gc = new GeodeticCalculator(DefaultEllipsoid.WGS84);
|
||||
Coordinate newPt0 = new Coordinate();
|
||||
|
@ -1513,8 +1420,7 @@ public class WatchBox extends MultiPointElement implements IWatchBox {
|
|||
if (pt0.x == pt4.x) {
|
||||
newPt0.y = loc.y;
|
||||
} else {
|
||||
newPt0.y = pt4.y + (loc.x - pt4.x) * (pt4.y - pt0.y)
|
||||
/ (pt4.x - pt0.x);
|
||||
newPt0.y = pt4.y + (loc.x - pt4.x) * (pt4.y - pt0.y) / (pt4.x - pt0.x);
|
||||
}
|
||||
|
||||
newPt0.x = loc.x;
|
||||
|
@ -1523,8 +1429,7 @@ public class WatchBox extends MultiPointElement implements IWatchBox {
|
|||
if (pt0.y == pt4.y) {
|
||||
newPt0.x = loc.x;
|
||||
} else {
|
||||
newPt0.x = pt4.x + (loc.y - pt4.y) * (pt4.x - pt0.x)
|
||||
/ (pt4.y - pt0.y);
|
||||
newPt0.x = pt4.x + (loc.y - pt4.y) * (pt4.x - pt0.x) / (pt4.y - pt0.y);
|
||||
}
|
||||
newPt0.y = loc.y;
|
||||
} else if (this.getWatchBoxShape() == WatchBox.WatchShape.ESOL) {
|
||||
|
@ -1547,8 +1452,7 @@ public class WatchBox extends MultiPointElement implements IWatchBox {
|
|||
if (pt0.x == pt4.x) {
|
||||
newPt4.y = loc.y;
|
||||
} else {
|
||||
newPt4.y = pt0.y + (loc.x - pt0.x) * (pt4.y - pt0.y)
|
||||
/ (pt4.x - pt0.x);
|
||||
newPt4.y = pt0.y + (loc.x - pt0.x) * (pt4.y - pt0.y) / (pt4.x - pt0.x);
|
||||
}
|
||||
|
||||
newPt4.x = loc.x;
|
||||
|
@ -1557,8 +1461,7 @@ public class WatchBox extends MultiPointElement implements IWatchBox {
|
|||
if (pt0.y == pt4.y) {
|
||||
newPt4.x = loc.x;
|
||||
} else {
|
||||
newPt4.x = pt0.x + (loc.y - pt0.y) * (pt4.x - pt0.x)
|
||||
/ (pt4.y - pt0.y);
|
||||
newPt4.x = pt0.x + (loc.y - pt0.y) * (pt4.x - pt0.x) / (pt4.y - pt0.y);
|
||||
}
|
||||
newPt4.y = loc.y;
|
||||
} else if (this.getWatchBoxShape() == WatchBox.WatchShape.ESOL) {
|
||||
|
@ -1583,8 +1486,7 @@ public class WatchBox extends MultiPointElement implements IWatchBox {
|
|||
if (pt5.x == pt7.x) {
|
||||
newPtx.y = loc.y;
|
||||
} else {
|
||||
newPtx.y = pt5.y + (loc.x - pt5.x) * (pt7.y - pt5.y)
|
||||
/ (pt7.x - pt5.x);
|
||||
newPtx.y = pt5.y + (loc.x - pt5.x) * (pt7.y - pt5.y) / (pt7.x - pt5.x);
|
||||
}
|
||||
newPtx.x = loc.x;
|
||||
|
||||
|
@ -1592,8 +1494,7 @@ public class WatchBox extends MultiPointElement implements IWatchBox {
|
|||
if (pt5.y == pt7.y) {
|
||||
newPtx.x = loc.x;
|
||||
} else {
|
||||
newPtx.x = pt5.x + (loc.y - pt5.y) * (pt7.x - pt5.x)
|
||||
/ (pt7.y - pt5.y);
|
||||
newPtx.x = pt5.x + (loc.y - pt5.y) * (pt7.x - pt5.x) / (pt7.y - pt5.y);
|
||||
}
|
||||
|
||||
newPtx.y = loc.y;
|
||||
|
@ -1632,8 +1533,7 @@ public class WatchBox extends MultiPointElement implements IWatchBox {
|
|||
if (pt1.x == pt3.x) {
|
||||
newPtx.y = loc.y;
|
||||
} else {
|
||||
newPtx.y = pt1.y + (loc.x - pt1.x) * (pt3.y - pt1.y)
|
||||
/ (pt3.x - pt1.x);
|
||||
newPtx.y = pt1.y + (loc.x - pt1.x) * (pt3.y - pt1.y) / (pt3.x - pt1.x);
|
||||
}
|
||||
newPtx.x = loc.x;
|
||||
|
||||
|
@ -1641,8 +1541,7 @@ public class WatchBox extends MultiPointElement implements IWatchBox {
|
|||
if (pt1.y == pt3.y) {
|
||||
newPtx.x = loc.x;
|
||||
} else {
|
||||
newPtx.x = pt1.x + (loc.y - pt1.y) * (pt3.x - pt1.x)
|
||||
/ (pt3.y - pt1.y);
|
||||
newPtx.x = pt1.x + (loc.y - pt1.y) * (pt3.x - pt1.x) / (pt3.y - pt1.y);
|
||||
}
|
||||
|
||||
newPtx.y = loc.y;
|
||||
|
@ -1691,8 +1590,7 @@ public class WatchBox extends MultiPointElement implements IWatchBox {
|
|||
|
||||
List<SPCCounty> counties = new ArrayList<SPCCounty>();
|
||||
|
||||
counties.addAll(PgenStaticDataProvider.getProvider()
|
||||
.getCountiesInGeometry(bUnion));
|
||||
counties.addAll(PgenStaticDataProvider.getProvider().getCountiesInGeometry(bUnion));
|
||||
ArrayList<String> nWFOs = new ArrayList<String>();
|
||||
|
||||
List<String> wfos = this.getWFOs();
|
||||
|
@ -1701,8 +1599,7 @@ public class WatchBox extends MultiPointElement implements IWatchBox {
|
|||
// wfo can be more than one
|
||||
if (wfo != null) {
|
||||
for (int ii = 0; ii < wfo.length(); ii += 3) {
|
||||
String wfoStr = wfo.substring(ii,
|
||||
wfo.length() > ii + 3 ? ii + 3 : wfo.length());
|
||||
String wfoStr = wfo.substring(ii, wfo.length() > ii + 3 ? ii + 3 : wfo.length());
|
||||
if (!wfos.contains(wfoStr) && !nWFOs.contains(wfoStr))
|
||||
nWFOs.add(wfoStr);
|
||||
}
|
||||
|
@ -1747,14 +1644,12 @@ public class WatchBox extends MultiPointElement implements IWatchBox {
|
|||
int iCnty = 0;
|
||||
|
||||
for (SPCCounty county : countyList) {
|
||||
if (county.getState() != null
|
||||
&& state.equalsIgnoreCase(county.getState())) {
|
||||
if (county.getState() != null && state.equalsIgnoreCase(county.getState())) {
|
||||
if (ugcStr.isEmpty()) {
|
||||
ugcStr = county.getUgcId();
|
||||
} else {
|
||||
if (ugcStr.contains("\n")) {
|
||||
oneLine = ugcStr
|
||||
.substring(ugcStr.lastIndexOf('\n') + 1);
|
||||
oneLine = ugcStr.substring(ugcStr.lastIndexOf('\n') + 1);
|
||||
} else {
|
||||
oneLine = ugcStr;
|
||||
}
|
||||
|
@ -1768,9 +1663,7 @@ public class WatchBox extends MultiPointElement implements IWatchBox {
|
|||
|
||||
if (ugcStr.charAt(2) == 'Z') {
|
||||
// for coastal waters
|
||||
waters += "\n"
|
||||
+ county.getZoneName().toUpperCase()
|
||||
.replaceAll("_", " ") + "\n";
|
||||
waters += "\n" + county.getZoneName().toUpperCase().replaceAll("_", " ") + "\n";
|
||||
} else if (Integer.valueOf(county.getFips().substring(2)) > 509) {
|
||||
if (iCiti == 3) {
|
||||
cities += "\n";
|
||||
|
@ -1779,11 +1672,9 @@ public class WatchBox extends MultiPointElement implements IWatchBox {
|
|||
|
||||
String citi = county.getName().toUpperCase();
|
||||
if (iCiti == 0) {
|
||||
cities += String.format("%1$-21s",
|
||||
citi.replaceAll("CITY OF ", ""));
|
||||
cities += String.format("%1$-21s", citi.replaceAll("CITY OF ", ""));
|
||||
} else {
|
||||
cities += String.format("%1$-20s",
|
||||
citi.replaceAll("CITY OF ", ""));
|
||||
cities += String.format("%1$-20s", citi.replaceAll("CITY OF ", ""));
|
||||
}
|
||||
iCiti++;
|
||||
|
||||
|
@ -1823,26 +1714,19 @@ public class WatchBox extends MultiPointElement implements IWatchBox {
|
|||
|
||||
if (ugcStr.charAt(2) == 'Z') {
|
||||
// for coastal waters
|
||||
cntyStr += "CW" + "\n\n" + ". "
|
||||
+ "ADJACENT COASTAL WATERS INCLUDED ARE:\n" + waters;
|
||||
cntyStr += "CW" + "\n\n" + ". " + "ADJACENT COASTAL WATERS INCLUDED ARE:\n" + waters;
|
||||
} else {
|
||||
String stName = stateName.get(state).toUpperCase();
|
||||
|
||||
if (stName != null) {
|
||||
if (state.equalsIgnoreCase("LA")) {
|
||||
cntyStr += state + "\n\n" + ". " + stName
|
||||
+ " PARISHES INCLUDED ARE:\n\n"
|
||||
+ counties.toUpperCase();
|
||||
cntyStr += state + "\n\n" + ". " + stName + " PARISHES INCLUDED ARE:\n\n" + counties.toUpperCase();
|
||||
} else {
|
||||
cntyStr += state + "\n\n" + ". " + stName
|
||||
+ " COUNTIES INCLUDED ARE:\n\n"
|
||||
+ counties.toUpperCase();
|
||||
cntyStr += state + "\n\n" + ". " + stName + " COUNTIES INCLUDED ARE:\n\n" + counties.toUpperCase();
|
||||
}
|
||||
|
||||
if (!cities.isEmpty()) {
|
||||
cntyStr += "\n\n" + stName
|
||||
+ " INDEPENDENT CITIES INCLUDED ARE:\n\n"
|
||||
+ cities.toUpperCase();
|
||||
cntyStr += "\n\n" + stName + " INDEPENDENT CITIES INCLUDED ARE:\n\n" + cities.toUpperCase();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1859,8 +1743,7 @@ public class WatchBox extends MultiPointElement implements IWatchBox {
|
|||
*/
|
||||
private Set<String> findCntyInClst(String fips) {
|
||||
|
||||
Set<String> rt = PgenStaticDataProvider.getProvider().getClstTbl()
|
||||
.get(fips);
|
||||
Set<String> rt = PgenStaticDataProvider.getProvider().getClstTbl().get(fips);
|
||||
return (rt == null) ? new HashSet<String>(Arrays.asList(fips)) : rt;
|
||||
|
||||
}
|
||||
|
@ -1871,8 +1754,7 @@ public class WatchBox extends MultiPointElement implements IWatchBox {
|
|||
* @param county
|
||||
*/
|
||||
public void rmClstCnty(SPCCounty county) {
|
||||
if (county.getFips().isEmpty()
|
||||
|| county.getFips().equalsIgnoreCase("00000")) {
|
||||
if (county.getFips().isEmpty() || county.getFips().equalsIgnoreCase("00000")) {
|
||||
removeCounty(county);
|
||||
}
|
||||
for (String fips : findCntyInClst(county.getFips())) {
|
||||
|
@ -1886,13 +1768,11 @@ public class WatchBox extends MultiPointElement implements IWatchBox {
|
|||
* @param county
|
||||
*/
|
||||
public void addClstCnty(SPCCounty county) {
|
||||
if (county.getFips().isEmpty()
|
||||
|| county.getFips().equalsIgnoreCase("00000")) {
|
||||
if (county.getFips().isEmpty() || county.getFips().equalsIgnoreCase("00000")) {
|
||||
addCounty(county);
|
||||
} else {
|
||||
for (String fips : findCntyInClst(county.getFips())) {
|
||||
SPCCounty cnty = PgenStaticDataProvider.getProvider()
|
||||
.findCounty(fips);
|
||||
SPCCounty cnty = PgenStaticDataProvider.getProvider().findCounty(fips);
|
||||
if (cnty != null && !countyList.contains(cnty))
|
||||
addCounty(cnty);
|
||||
}
|
||||
|
@ -1914,8 +1794,7 @@ public class WatchBox extends MultiPointElement implements IWatchBox {
|
|||
* - forecaster name
|
||||
*/
|
||||
|
||||
public void addStatus(String fromLine, int dNum, Calendar vTime,
|
||||
Calendar eTime, String name) {
|
||||
public void addStatus(String fromLine, int dNum, Calendar vTime, Calendar eTime, String name) {
|
||||
if (statusHistory == null) {
|
||||
statusHistory = new ArrayList<WatchStatus>();
|
||||
}
|
||||
|
@ -1954,12 +1833,8 @@ public class WatchBox extends MultiPointElement implements IWatchBox {
|
|||
if (cntyList != null && !cntyList.isEmpty()) {
|
||||
|
||||
for (SPCCounty cnty : cntyList) {
|
||||
String cntyName = cnty.getName().replaceAll("City of ", "")
|
||||
.replaceAll(" City", "").replaceAll(" ", "_").replaceAll("'", "").replaceAll("\\.", "");
|
||||
cntyInfo += String.format(
|
||||
"%1$-7s%2$-5s%3$-17s%4$5.2f%5$8.2f%6$7s %7$-5s",
|
||||
cnty.getUgcId(), cnty.getState(), cntyName,
|
||||
cnty.getCentriod().y, cnty.getCentriod().x,
|
||||
String cntyName = cnty.getName().replaceAll("City of ", "").replaceAll(" City", "").replaceAll(" ", "_").replaceAll("'", "").replaceAll("\\.", "");
|
||||
cntyInfo += String.format("%1$-7s%2$-5s%3$-17s%4$5.2f%5$8.2f%6$7s %7$-5s", cnty.getUgcId(), cnty.getState(), cntyName, cnty.getCentriod().y, cnty.getCentriod().x,
|
||||
cnty.getFips(), cnty.getWfo());
|
||||
cntyInfo += "\n";
|
||||
}
|
||||
|
@ -1972,16 +1847,16 @@ public class WatchBox extends MultiPointElement implements IWatchBox {
|
|||
}
|
||||
|
||||
public List<SPCCounty> getOriginalCountyList() {
|
||||
return originalCountyList;
|
||||
}
|
||||
return originalCountyList;
|
||||
}
|
||||
|
||||
public void makeOriginalCountyList(List<SPCCounty> countyList) {
|
||||
this.originalCountyList = new ArrayList<SPCCounty>(countyList);
|
||||
}
|
||||
this.originalCountyList = new ArrayList<SPCCounty>(countyList);
|
||||
}
|
||||
|
||||
public void setOriginalCountyList(List<SPCCounty> originalCountyList) {
|
||||
this.originalCountyList = originalCountyList;
|
||||
}
|
||||
public void setOriginalCountyList(List<SPCCounty> originalCountyList) {
|
||||
this.originalCountyList = originalCountyList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Class to hold watch status information
|
||||
|
@ -2001,8 +1876,7 @@ public class WatchBox extends MultiPointElement implements IWatchBox {
|
|||
|
||||
private String statusForecaster;
|
||||
|
||||
private WatchStatus(String fromLine, int dNum, Calendar vTime,
|
||||
Calendar eTime, String name) {
|
||||
private WatchStatus(String fromLine, int dNum, Calendar vTime, Calendar eTime, String name) {
|
||||
this.fromLine = fromLine;
|
||||
this.discussion = dNum;
|
||||
this.statusValidTime = vTime;
|
||||
|
@ -2052,6 +1926,25 @@ public class WatchBox extends MultiPointElement implements IWatchBox {
|
|||
|
||||
}
|
||||
|
||||
//TRAC 1112
|
||||
public void updateActiveCountiesInWatchBox(List<String> ugcList) {
|
||||
List<SPCCounty> allCounties = null;
|
||||
|
||||
countyList.clear();
|
||||
allCounties = PgenStaticDataProvider.getProvider().getSPCCounties();
|
||||
|
||||
//for each UGC retrieved from the database/WCN files
|
||||
for (String ugc : ugcList) {
|
||||
// for each existing county on record
|
||||
for (SPCCounty county : allCounties) {
|
||||
|
||||
if (ugc.equalsIgnoreCase(county.getUgcId())) {
|
||||
countyList.add(county);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -50,6 +50,7 @@ import com.raytheon.viz.core.mode.CAVEMode;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Apr 22, 2013 sgilbert Initial creation
|
||||
* Aug 30, 2013 2298 rjpeter Make getPluginName abstract
|
||||
* Jan 29, 2014 #1105 jwu Create ActivityInfo from Product.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -89,6 +90,20 @@ public class StorageUtils {
|
|||
ActivityInfo info = new ActivityInfo();
|
||||
info.setActivityName(prod.getName());
|
||||
info.setActivityType(prod.getType());
|
||||
|
||||
String type = prod.getType();
|
||||
info.setActivityType(type);
|
||||
|
||||
if (type != null) {
|
||||
int loc1 = type.indexOf("(");
|
||||
if (loc1 > 0) {
|
||||
info.setActivityType(type.substring(0, loc1));
|
||||
String subtype = type.substring(loc1 + 1).replace(")", "");
|
||||
if (subtype.length() > 0 && !subtype.equalsIgnoreCase("NONE"))
|
||||
info.setActivitySubtype(subtype);
|
||||
}
|
||||
}
|
||||
|
||||
info.setActivityLabel(prod.getOutputFile());
|
||||
info.setRefTime(prod.getTime().getStartTime());
|
||||
info.setSite(prod.getCenter());
|
||||
|
@ -141,6 +156,10 @@ public class StorageUtils {
|
|||
}
|
||||
|
||||
try {
|
||||
prod.setCenter(info.getSite());
|
||||
prod.setForecaster(info.getForecaster());
|
||||
prod.getTime().setStartTime(info.getRefTime());
|
||||
|
||||
String activityXML = serializeProduct(prod);
|
||||
|
||||
StoreActivityRequest request = new StoreActivityRequest(info,
|
||||
|
@ -210,6 +229,7 @@ public class StorageUtils {
|
|||
record.setStatus(info.getStatus());
|
||||
|
||||
record.setDataTime(new DataTime(info.getRefTime()));
|
||||
// record.setPluginName("pgen");
|
||||
try {
|
||||
record.constructDataURI();
|
||||
} catch (PluginException e1) {
|
||||
|
|
|
@ -32,6 +32,7 @@ import com.raytheon.viz.ui.tools.AbstractModalTool;
|
|||
* resetMouseHandler, and setWorkingComponent
|
||||
* 12/13 TTR899 J. Wu Set delObjFlag to false when any Pgen Action
|
||||
* button is clicked
|
||||
* 04/2014 TTR900 pswamy R-click cannot return to SELECT from Rotate and DEL_OBJ
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -46,7 +47,7 @@ public abstract class AbstractPgenTool extends AbstractModalTool {
|
|||
|
||||
private static boolean delObjFlag;
|
||||
|
||||
private IInputHandler inputHandler = null;
|
||||
protected IInputHandler inputHandler = null;
|
||||
|
||||
/**
|
||||
* A handler to the current drawing layer.
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,58 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package gov.noaa.nws.ncep.ui.pgen.tools;
|
||||
|
||||
import gov.noaa.nws.ncep.ui.pgen.attrdialog.ContoursAttrDlg;
|
||||
|
||||
import org.eclipse.core.commands.AbstractHandler;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import org.eclipse.core.commands.ExecutionException;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
|
||||
//import gov.noaa.nws.ncep.viz.ui.display.NmapUiUtils;
|
||||
|
||||
/**
|
||||
* Implements Hotkeys for PGEN contours drawing tool.
|
||||
*
|
||||
* ARROW_UP - move the contour value up a level. ARROW_DOWN - move the contour
|
||||
* value down a level.
|
||||
*
|
||||
* <pre>
|
||||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 03/14 #1117 J. Wu Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author J. Wu
|
||||
*/
|
||||
public class PgenContoursHotkeyHandler extends AbstractHandler {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.
|
||||
* ExecutionEvent)
|
||||
*/
|
||||
@Override
|
||||
public Object execute(ExecutionEvent event) throws ExecutionException {
|
||||
String actionStr = event.getParameter("action");
|
||||
if (actionStr == null || actionStr.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ContoursAttrDlg cdlg = ContoursAttrDlg.getInstance(PlatformUI
|
||||
.getWorkbench().getActiveWorkbenchWindow().getShell());
|
||||
|
||||
if (cdlg != null && cdlg.getShell() != null
|
||||
&& !cdlg.getShell().isDisposed()) {
|
||||
cdlg.upDownLabelSelection(actionStr);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -32,8 +32,6 @@ import java.util.ArrayList;
|
|||
import java.util.Iterator;
|
||||
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
|
||||
import com.raytheon.uf.viz.core.rsc.IInputHandler;
|
||||
import com.vividsolutions.jts.geom.Coordinate;
|
||||
|
@ -57,6 +55,8 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
* the same type.
|
||||
* 03/13 #927 B. Yin Added right mouse click context menu
|
||||
* 08/13 TTR778 J. Wu Move loading libg2g to GraphToGridParamDialog.
|
||||
* 04/14 #1117 J. Wu Set focus to label/use line color for label.
|
||||
* 05/14 TTR1008 J. Wu Remove confirmation dialog when adding to an existing contour.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -107,8 +107,7 @@ public class PgenContoursTool extends AbstractPgenDrawingTool implements
|
|||
protected void activateTool() {
|
||||
|
||||
super.activateTool();
|
||||
// LibraryLoader.load("g2g");
|
||||
|
||||
// LibraryLoader.load("g2g");
|
||||
|
||||
/*
|
||||
* if the ExecutionEvent's trigger has been set, it should be something
|
||||
|
@ -117,29 +116,35 @@ public class PgenContoursTool extends AbstractPgenDrawingTool implements
|
|||
*/
|
||||
Object de = event.getTrigger();
|
||||
|
||||
// The same tool could be activated again (for instance, click on PGEN palette and then click in the editor).
|
||||
// However the trigger of the event may not be the current contour if the contour is modified.
|
||||
if ( event != lastEvent ) {
|
||||
// The same tool could be activated again (for instance, click on PGEN
|
||||
// palette and then click in the editor).
|
||||
// However the trigger of the event may not be the current contour if
|
||||
// the contour is modified.
|
||||
if (event != lastEvent) {
|
||||
if (de instanceof Contours) {
|
||||
elem = (Contours) de;
|
||||
//addContourLine = true;
|
||||
// addContourLine = true;
|
||||
this.setPgenSelectHandler();
|
||||
PgenSession.getInstance().getPgenPalette().setActiveIcon("Select");
|
||||
PgenSession.getInstance().getPgenPalette()
|
||||
.setActiveIcon("Select");
|
||||
} else {
|
||||
elem = null;
|
||||
}
|
||||
lastEvent = event;
|
||||
lastEvent = event;
|
||||
}
|
||||
|
||||
if (attrDlg instanceof ContoursAttrDlg) {
|
||||
// ((ContoursAttrDlg) attrDlg).disableActionButtons();
|
||||
((ContoursAttrDlg)attrDlg).setDrawingTool( this );
|
||||
if ( de != null ){
|
||||
((ContoursAttrDlg)attrDlg).setSelectMode();
|
||||
}
|
||||
else {
|
||||
((ContoursAttrDlg)attrDlg).setDrawingStatus(ContoursAttrDlg.ContourDrawingStatus.DRAW_LINE);
|
||||
// ((ContoursAttrDlg) attrDlg).disableActionButtons();
|
||||
((ContoursAttrDlg) attrDlg).setDrawingTool(this);
|
||||
if (de != null) {
|
||||
((ContoursAttrDlg) attrDlg).setSelectMode();
|
||||
} else {
|
||||
((ContoursAttrDlg) attrDlg)
|
||||
.setDrawingStatus(ContoursAttrDlg.ContourDrawingStatus.DRAW_LINE);
|
||||
}
|
||||
|
||||
((ContoursAttrDlg) attrDlg).setLabelFocus();
|
||||
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -180,7 +185,12 @@ public class PgenContoursTool extends AbstractPgenDrawingTool implements
|
|||
|
||||
// Check if mouse is in geographic extent
|
||||
Coordinate loc = mapEditor.translateClick(anX, aY);
|
||||
if ( loc == null || shiftDown ) return false;
|
||||
if (loc == null || shiftDown)
|
||||
return false;
|
||||
|
||||
if (attrDlg != null) {
|
||||
((ContoursAttrDlg) attrDlg).setLabelFocus();
|
||||
}
|
||||
|
||||
// Drawing Min/Max symbol
|
||||
if (attrDlg != null && ((ContoursAttrDlg) attrDlg).drawSymbol()) {
|
||||
|
@ -191,7 +201,8 @@ public class PgenContoursTool extends AbstractPgenDrawingTool implements
|
|||
|
||||
points.clear();
|
||||
if (attrDlg != null) {
|
||||
((ContoursAttrDlg) attrDlg).setDrawingStatus( ContourDrawingStatus.SELECT );
|
||||
((ContoursAttrDlg) attrDlg)
|
||||
.setDrawingStatus(ContourDrawingStatus.SELECT);
|
||||
}
|
||||
drawingLayer.removeGhostLine();
|
||||
|
||||
|
@ -225,7 +236,8 @@ public class PgenContoursTool extends AbstractPgenDrawingTool implements
|
|||
|
||||
points.clear();
|
||||
if (attrDlg != null) {
|
||||
((ContoursAttrDlg) attrDlg).setDrawingStatus(ContoursAttrDlg.ContourDrawingStatus.SELECT);
|
||||
((ContoursAttrDlg) attrDlg)
|
||||
.setDrawingStatus(ContoursAttrDlg.ContourDrawingStatus.SELECT);
|
||||
}
|
||||
drawingLayer.removeGhostLine();
|
||||
|
||||
|
@ -249,11 +261,11 @@ public class PgenContoursTool extends AbstractPgenDrawingTool implements
|
|||
return true;
|
||||
} else if (button == 3) {
|
||||
if (points.size() == 0) {
|
||||
((ContoursAttrDlg) attrDlg).setDrawingStatus(ContoursAttrDlg.ContourDrawingStatus.SELECT);
|
||||
}
|
||||
else {
|
||||
setDrawingMode();
|
||||
drawContours();
|
||||
((ContoursAttrDlg) attrDlg)
|
||||
.setDrawingStatus(ContoursAttrDlg.ContourDrawingStatus.SELECT);
|
||||
} else {
|
||||
setDrawingMode();
|
||||
drawContours();
|
||||
}
|
||||
return true;
|
||||
} else if (button == 2) {
|
||||
|
@ -272,12 +284,19 @@ public class PgenContoursTool extends AbstractPgenDrawingTool implements
|
|||
*/
|
||||
@Override
|
||||
public boolean handleMouseMove(int x, int y) {
|
||||
if ( !isResourceEditable() || shiftDown ) return false;
|
||||
if (!isResourceEditable() || shiftDown) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if mouse is in geographic extent
|
||||
Coordinate loc = mapEditor.translateClick(x, y);
|
||||
if (loc == null)
|
||||
if (loc == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (attrDlg != null) {
|
||||
((ContoursAttrDlg) attrDlg).setLabelFocus();
|
||||
}
|
||||
|
||||
// Draw a ghost contour min/max
|
||||
if (attrDlg != null && ((ContoursAttrDlg) attrDlg).drawSymbol()) {
|
||||
|
@ -307,6 +326,9 @@ public class PgenContoursTool extends AbstractPgenDrawingTool implements
|
|||
lbl.setText(oldText);
|
||||
lbl.setHide(hide);
|
||||
lbl.setAuto(auto);
|
||||
if (((ContoursAttrDlg) attrDlg).isUseMainColor()) {
|
||||
lbl.setColors(mmTemp.getColors());
|
||||
}
|
||||
}
|
||||
|
||||
drawingLayer.setGhostLine(ghost);
|
||||
|
@ -345,6 +367,9 @@ public class PgenContoursTool extends AbstractPgenDrawingTool implements
|
|||
lbl.setText(oldText);
|
||||
lbl.setHide(hide);
|
||||
lbl.setAuto(auto);
|
||||
if (((ContoursAttrDlg) attrDlg).isUseMainColor()) {
|
||||
lbl.setColors(circleTemp.getColors());
|
||||
}
|
||||
}
|
||||
|
||||
drawingLayer.setGhostLine(ghost);
|
||||
|
@ -394,6 +419,9 @@ public class PgenContoursTool extends AbstractPgenDrawingTool implements
|
|||
lbl.setText(oldText);
|
||||
lbl.setHide(hide);
|
||||
lbl.setAuto(auto);
|
||||
if (((ContoursAttrDlg) attrDlg).isUseMainColor()) {
|
||||
lbl.setColors(lineTemp.getColors());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -419,8 +447,11 @@ public class PgenContoursTool extends AbstractPgenDrawingTool implements
|
|||
|
||||
@Override
|
||||
public boolean handleMouseDownMove(int x, int y, int mouseButton) {
|
||||
if ( !isResourceEditable() || shiftDown ) return false;
|
||||
else return true;
|
||||
if (!isResourceEditable() || shiftDown) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -464,6 +495,9 @@ public class PgenContoursTool extends AbstractPgenDrawingTool implements
|
|||
lbl.setText(oldText);
|
||||
lbl.setHide(hide);
|
||||
lbl.setAuto(auto);
|
||||
if (((ContoursAttrDlg) attrDlg).isUseMainColor()) {
|
||||
lbl.setColors(lineTemp.getColors());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -552,6 +586,9 @@ public class PgenContoursTool extends AbstractPgenDrawingTool implements
|
|||
lbl.setText(oldText);
|
||||
lbl.setHide(hide);
|
||||
lbl.setAuto(auto);
|
||||
if (((ContoursAttrDlg) attrDlg).isUseMainColor()) {
|
||||
lbl.setColors(mmTemp.getColors());
|
||||
}
|
||||
}
|
||||
|
||||
// Check if we need to add to existing contours or create a new
|
||||
|
@ -674,6 +711,9 @@ public class PgenContoursTool extends AbstractPgenDrawingTool implements
|
|||
lbl.setText(oldText);
|
||||
lbl.setHide(hide);
|
||||
lbl.setAuto(auto);
|
||||
if (((ContoursAttrDlg) attrDlg).isUseMainColor()) {
|
||||
lbl.setColors(circleTemp.getColors());
|
||||
}
|
||||
}
|
||||
|
||||
// Check if we need to add to existing contours or create a new
|
||||
|
@ -732,20 +772,13 @@ public class PgenContoursTool extends AbstractPgenDrawingTool implements
|
|||
|
||||
/*
|
||||
* Loop through current layer and see if there is an same type of
|
||||
* Contours. If yes, add to the existing contours. If not, draw a new
|
||||
* Contours.
|
||||
*
|
||||
* If yes, show a warning message and ask for confirmation either add to
|
||||
* the existing contours or draw a new Cnntours.
|
||||
*/
|
||||
private Contours checkExistingContours() {
|
||||
|
||||
Contours existingContours = elem;
|
||||
|
||||
// Loop through current layer and see if there is an same type of
|
||||
// Contours.
|
||||
// If yes, show a warning message and ask for confirmation either
|
||||
// add to the
|
||||
// existing contours or draw a new Contours.
|
||||
if (existingContours == null) {
|
||||
|
||||
Iterator<AbstractDrawableComponent> it = drawingLayer
|
||||
|
@ -755,33 +788,14 @@ public class PgenContoursTool extends AbstractPgenDrawingTool implements
|
|||
if (adc instanceof Contours && !(adc instanceof Outlook)) {
|
||||
Contours thisContour = (Contours) adc;
|
||||
ContoursAttrDlg thisDlg = (ContoursAttrDlg) attrDlg;
|
||||
if (thisContour.getParm().equals(thisDlg.getParm())
|
||||
&& thisContour.getLevel().equals(
|
||||
thisDlg.getLevel())) {
|
||||
|
||||
if (thisContour.getKey().equals(
|
||||
Contours.getKey(thisDlg))) {
|
||||
existingContours = (Contours) adc;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (existingContours != null) {
|
||||
MessageDialog msgDlg = new MessageDialog(PlatformUI
|
||||
.getWorkbench().getActiveWorkbenchWindow()
|
||||
.getShell(), "Warning!", null, "There is another ["
|
||||
+ existingContours.getParm() + ","
|
||||
+ existingContours.getLevel()
|
||||
+ "] Contours element in this layer.\n"
|
||||
+ "Do you want to add to it or create a new one?",
|
||||
MessageDialog.INFORMATION,
|
||||
new String[] { "Add to Existing One",
|
||||
"Create a New One" }, 0);
|
||||
msgDlg.open();
|
||||
|
||||
// start a new Contours.
|
||||
if (msgDlg.getReturnCode() != MessageDialog.OK) {
|
||||
existingContours = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return existingContours;
|
||||
|
@ -812,62 +826,64 @@ public class PgenContoursTool extends AbstractPgenDrawingTool implements
|
|||
|
||||
/**
|
||||
* Gets the current working contour.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Contours getCurrentContour(){
|
||||
return elem;
|
||||
public Contours getCurrentContour() {
|
||||
return elem;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the current working contour
|
||||
*
|
||||
* @param con
|
||||
*/
|
||||
public void setCurrentContour( Contours con){
|
||||
attrDlg.setDrawableElement(con);
|
||||
elem = con;
|
||||
public void setCurrentContour(Contours con) {
|
||||
attrDlg.setDrawableElement(con);
|
||||
elem = con;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the selecting handler.
|
||||
*/
|
||||
public void setPgenSelectHandler( ){
|
||||
public void setPgenSelectHandler() {
|
||||
|
||||
setHandler(new PgenSelectHandler(this, mapEditor, drawingLayer,attrDlg ));
|
||||
}
|
||||
setHandler(new PgenSelectHandler(this, mapEditor, drawingLayer, attrDlg));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the contour mouse handler.
|
||||
*/
|
||||
public void setPgenContoursHandler( ){
|
||||
/**
|
||||
* Sets the contour mouse handler.
|
||||
*/
|
||||
public void setPgenContoursHandler() {
|
||||
|
||||
setHandler(new PgenContoursHandler());
|
||||
setHandler(new PgenContoursHandler());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears selected elements.
|
||||
*/
|
||||
public void clearSelected(){
|
||||
drawingLayer.removeSelected();
|
||||
mapEditor.refresh();
|
||||
}
|
||||
/**
|
||||
* Clears selected elements.
|
||||
*/
|
||||
public void clearSelected() {
|
||||
drawingLayer.removeSelected();
|
||||
mapEditor.refresh();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the default mouse handler.
|
||||
*/
|
||||
@Override
|
||||
protected IInputHandler getDefaultMouseHandler(){
|
||||
return new PgenSelectHandler(this, mapEditor, drawingLayer,attrDlg );
|
||||
}
|
||||
/**
|
||||
* Gets the default mouse handler.
|
||||
*/
|
||||
@Override
|
||||
protected IInputHandler getDefaultMouseHandler() {
|
||||
return new PgenSelectHandler(this, mapEditor, drawingLayer, attrDlg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets current working component
|
||||
*/
|
||||
@Override
|
||||
protected void setWorkingComponent( AbstractDrawableComponent adc ){
|
||||
if ( adc instanceof Contours ){
|
||||
setCurrentContour( (Contours) adc );
|
||||
((ContoursAttrDlg) attrDlg).setCurrentContours(elem);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Sets current working component
|
||||
*/
|
||||
@Override
|
||||
protected void setWorkingComponent(AbstractDrawableComponent adc) {
|
||||
if (adc instanceof Contours) {
|
||||
setCurrentContour((Contours) adc);
|
||||
((ContoursAttrDlg) attrDlg).setCurrentContours(elem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ package gov.noaa.nws.ncep.ui.pgen.tools;
|
|||
import gov.noaa.nws.ncep.ui.pgen.PgenUtil;
|
||||
import gov.noaa.nws.ncep.ui.pgen.attrdialog.AttrDlg;
|
||||
import gov.noaa.nws.ncep.ui.pgen.contours.ContourMinmax;
|
||||
import gov.noaa.nws.ncep.ui.pgen.contours.Contours;
|
||||
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.Layer;
|
||||
|
@ -18,6 +19,9 @@ import gov.noaa.nws.ncep.ui.pgen.elements.Outlook;
|
|||
import gov.noaa.nws.ncep.ui.pgen.filter.AcceptFilter;
|
||||
import gov.noaa.nws.ncep.ui.pgen.rsc.PgenResource;
|
||||
|
||||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
|
||||
import com.raytheon.viz.ui.editor.AbstractEditor;
|
||||
import com.vividsolutions.jts.geom.Coordinate;
|
||||
|
||||
|
@ -29,6 +33,7 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 04/13 927 B. Yin Moved from the PgenDeleteElement class
|
||||
* 04/14 1117 J. Wu Added confirmation for deleting contours
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -37,152 +42,182 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
|
||||
public class PgenDeleteElementHandler extends InputHandlerDefaultImpl {
|
||||
|
||||
protected AbstractEditor mapEditor;
|
||||
protected PgenResource pgenrsc;
|
||||
protected AbstractPgenTool tool;
|
||||
protected AttrDlg attrDlg;
|
||||
protected AbstractEditor mapEditor;
|
||||
|
||||
private boolean preempt;
|
||||
protected PgenResource pgenrsc;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param tool
|
||||
*/
|
||||
public PgenDeleteElementHandler( AbstractPgenTool tool ) {
|
||||
this.tool = tool;
|
||||
pgenrsc = tool.getDrawingLayer();
|
||||
mapEditor = tool.mapEditor;
|
||||
protected AbstractPgenTool tool;
|
||||
|
||||
if ( tool instanceof AbstractPgenDrawingTool ) {
|
||||
attrDlg = ((AbstractPgenDrawingTool)tool).getAttrDlg();
|
||||
}
|
||||
}
|
||||
protected AttrDlg attrDlg;
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.ui.input.IInputHandler#handleMouseDown(int,
|
||||
* int, int)
|
||||
*/
|
||||
@Override
|
||||
public boolean handleMouseDown(int anX, int aY, int button) {
|
||||
if ( !tool.isResourceEditable() ) return false;
|
||||
private boolean preempt;
|
||||
|
||||
preempt = false;
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param tool
|
||||
*/
|
||||
public PgenDeleteElementHandler(AbstractPgenTool tool) {
|
||||
this.tool = tool;
|
||||
pgenrsc = tool.getDrawingLayer();
|
||||
mapEditor = tool.mapEditor;
|
||||
|
||||
// Check if mouse is in geographic extent
|
||||
Coordinate loc = mapEditor.translateClick(anX, aY);
|
||||
if ( loc == null ) return false;
|
||||
if (tool instanceof AbstractPgenDrawingTool) {
|
||||
attrDlg = ((AbstractPgenDrawingTool) tool).getAttrDlg();
|
||||
}
|
||||
}
|
||||
|
||||
if ( button == 1 ) {
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.ui.input.IInputHandler#handleMouseDown(int, int,
|
||||
* int)
|
||||
*/
|
||||
@Override
|
||||
public boolean handleMouseDown(int anX, int aY, int button) {
|
||||
if (!tool.isResourceEditable())
|
||||
return false;
|
||||
|
||||
if ( pgenrsc.getSelectedComp() != null ) {
|
||||
doDelete();
|
||||
preempt = false;
|
||||
}
|
||||
else {
|
||||
// Get the nearest element and set it as the selected element.
|
||||
AbstractDrawableComponent elSelected = pgenrsc.getNearestComponent( loc, new AcceptFilter(), true );
|
||||
preempt = false;
|
||||
|
||||
//Delete watch status line
|
||||
if ( elSelected instanceof DECollection && elSelected.getName().equalsIgnoreCase("Watch")
|
||||
&& pgenrsc.getNearestElement(loc).getPgenType().equalsIgnoreCase("POINTED_ARROW")){
|
||||
elSelected =pgenrsc.getNearestElement(loc);
|
||||
}
|
||||
else if ( elSelected instanceof Outlook && ((Outlook)elSelected).getDEs() > 1){
|
||||
AbstractDrawableComponent adc = pgenrsc.getNearestElement(loc);
|
||||
elSelected = adc.getParent();
|
||||
}
|
||||
// Check if mouse is in geographic extent
|
||||
Coordinate loc = mapEditor.translateClick(anX, aY);
|
||||
if (loc == null)
|
||||
return false;
|
||||
|
||||
if (elSelected != null) {
|
||||
pgenrsc.setSelected( elSelected );
|
||||
preempt = true;
|
||||
}
|
||||
mapEditor.refresh();
|
||||
}
|
||||
if (button == 1) {
|
||||
|
||||
return preempt;
|
||||
if (pgenrsc.getSelectedComp() != null) {
|
||||
doDelete();
|
||||
preempt = false;
|
||||
} else {
|
||||
// Get the nearest element and set it as the selected element.
|
||||
AbstractDrawableComponent elSelected = pgenrsc
|
||||
.getNearestComponent(loc, new AcceptFilter(), true);
|
||||
|
||||
}
|
||||
else if ( button == 2 ){
|
||||
// Delete watch status line
|
||||
if (elSelected instanceof DECollection
|
||||
&& elSelected.getName().equalsIgnoreCase("Watch")
|
||||
&& pgenrsc.getNearestElement(loc).getPgenType()
|
||||
.equalsIgnoreCase("POINTED_ARROW")) {
|
||||
elSelected = pgenrsc.getNearestElement(loc);
|
||||
} else if (elSelected instanceof Outlook
|
||||
&& ((Outlook) elSelected).getDEs() > 1) {
|
||||
AbstractDrawableComponent adc = pgenrsc
|
||||
.getNearestElement(loc);
|
||||
elSelected = adc.getParent();
|
||||
}
|
||||
|
||||
return true;
|
||||
if (elSelected != null) {
|
||||
pgenrsc.setSelected(elSelected);
|
||||
preempt = true;
|
||||
}
|
||||
mapEditor.refresh();
|
||||
}
|
||||
|
||||
}
|
||||
else if ( button == 3 ) {
|
||||
return preempt;
|
||||
|
||||
if ( pgenrsc.getSelectedComp() != null ){
|
||||
// de-select element
|
||||
pgenrsc.removeSelected();
|
||||
mapEditor.refresh();
|
||||
}
|
||||
else {
|
||||
// set selecting mode
|
||||
PgenUtil.setSelectingMode();
|
||||
}
|
||||
} else if (button == 2) {
|
||||
|
||||
return true;
|
||||
return true;
|
||||
|
||||
}
|
||||
else{
|
||||
} else if (button == 3) {
|
||||
|
||||
return true;
|
||||
if (pgenrsc.getSelectedComp() != null) {
|
||||
// de-select element
|
||||
pgenrsc.removeSelected();
|
||||
mapEditor.refresh();
|
||||
} else {
|
||||
// set selecting mode
|
||||
PgenUtil.setSelectingMode();
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
} else {
|
||||
|
||||
@Override
|
||||
public boolean handleMouseDownMove(int x, int y, int mouseButton) {
|
||||
if ( !tool.isResourceEditable() || shiftDown ) return false;
|
||||
else return true;
|
||||
}
|
||||
return true;
|
||||
|
||||
/**
|
||||
* Deletes the selected element and reset the handler.
|
||||
* For a single element, closes the attributes dialog when the element is deleted.
|
||||
*/
|
||||
@Override
|
||||
public void preprocess(){
|
||||
}
|
||||
|
||||
if ( pgenrsc.getSelectedComp() != null ) {
|
||||
if ( attrDlg != null &&
|
||||
( pgenrsc.getSelectedComp().getParent() instanceof Layer
|
||||
|| pgenrsc.getSelectedComp().getParent().getName().equalsIgnoreCase("labeledSymbol"))){
|
||||
attrDlg.close();
|
||||
}
|
||||
}
|
||||
|
||||
doDelete();
|
||||
tool.resetMouseHandler();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public boolean handleMouseDownMove(int x, int y, int mouseButton) {
|
||||
if (!tool.isResourceEditable() || shiftDown)
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the selected element or component from the PGEN resource.
|
||||
*/
|
||||
private void doDelete(){
|
||||
/**
|
||||
* Deletes the selected element and reset the handler. For a single element,
|
||||
* closes the attributes dialog when the element is deleted.
|
||||
*/
|
||||
@Override
|
||||
public void preprocess() {
|
||||
|
||||
AbstractDrawableComponent adc = pgenrsc.getSelectedComp();
|
||||
if (pgenrsc.getSelectedComp() != null) {
|
||||
if (attrDlg != null
|
||||
&& (pgenrsc.getSelectedComp().getParent() instanceof Layer || pgenrsc
|
||||
.getSelectedComp().getParent().getName()
|
||||
.equalsIgnoreCase("labeledSymbol"))) {
|
||||
attrDlg.close();
|
||||
}
|
||||
|
||||
if ( adc.getParent() instanceof ContourMinmax
|
||||
|| adc.getParent().getName().equalsIgnoreCase("labeledSymbol") ){
|
||||
pgenrsc.removeElement(adc.getParent());
|
||||
}
|
||||
else {
|
||||
pgenrsc.removeElement(adc);
|
||||
}
|
||||
// de-select element
|
||||
pgenrsc.removeSelected();
|
||||
mapEditor.refresh();
|
||||
}
|
||||
doDelete();
|
||||
tool.resetMouseHandler();
|
||||
}
|
||||
}
|
||||
|
||||
public AbstractEditor getMapEditor() {
|
||||
return mapEditor;
|
||||
}
|
||||
/**
|
||||
* Deletes the selected element or component from the PGEN resource.
|
||||
*/
|
||||
private void doDelete() {
|
||||
|
||||
public PgenResource getPgenrsc() {
|
||||
return pgenrsc;
|
||||
}
|
||||
AbstractDrawableComponent adc = pgenrsc.getSelectedComp();
|
||||
|
||||
// Ask for user confirmation before deleting a Contours element.
|
||||
boolean deleteContour = true;
|
||||
if (adc instanceof Contours) {
|
||||
|
||||
/*
|
||||
* Confirm request to delete a Contour.
|
||||
*/
|
||||
String msg = "Are you sure you want to delete this Contour completely?";
|
||||
|
||||
MessageDialog confirmDlg = new MessageDialog(PlatformUI
|
||||
.getWorkbench().getActiveWorkbenchWindow().getShell(),
|
||||
"Confirm Delete of a Contour", null, msg,
|
||||
MessageDialog.QUESTION, new String[] { "OK", "Cancel" }, 0);
|
||||
confirmDlg.open();
|
||||
|
||||
if (!(confirmDlg.getReturnCode() == MessageDialog.OK)) {
|
||||
deleteContour = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (deleteContour) {
|
||||
if (adc.getParent() instanceof ContourMinmax
|
||||
|| adc.getParent().getName()
|
||||
.equalsIgnoreCase("labeledSymbol")) {
|
||||
pgenrsc.removeElement(adc.getParent());
|
||||
} else {
|
||||
pgenrsc.removeElement(adc);
|
||||
}
|
||||
}
|
||||
|
||||
// de-select element
|
||||
pgenrsc.removeSelected();
|
||||
mapEditor.refresh();
|
||||
}
|
||||
|
||||
public AbstractEditor getMapEditor() {
|
||||
return mapEditor;
|
||||
}
|
||||
|
||||
public PgenResource getPgenrsc() {
|
||||
return pgenrsc;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
|
||||
package gov.noaa.nws.ncep.ui.pgen.tools;
|
||||
|
||||
import gov.noaa.nws.ncep.ui.pgen.PgenUtil;
|
||||
|
||||
import com.raytheon.uf.viz.core.rsc.IInputHandler;
|
||||
|
||||
/**
|
||||
|
@ -18,24 +20,54 @@ import com.raytheon.uf.viz.core.rsc.IInputHandler;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 05/09 79 B. Yin Initial Creation.
|
||||
* 04/2014 TTR900 pswamy R-click cannot return to SELECT from Rotate and DEL_OBJ
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author B. Yin
|
||||
* @author B. Yin
|
||||
*/
|
||||
|
||||
public class PgenDeleteObj extends AbstractPgenTool {
|
||||
|
||||
public PgenDeleteObj(){
|
||||
public PgenDeleteObj() {
|
||||
|
||||
super();
|
||||
super();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInputHandler getMouseHandler() {
|
||||
return null; // no interaction
|
||||
}
|
||||
@Override
|
||||
public IInputHandler getMouseHandler() {
|
||||
|
||||
if (inputHandler == null) {
|
||||
inputHandler = new PgenDeleteObjHandler();
|
||||
}
|
||||
return inputHandler;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements input handler for mouse events.
|
||||
*/
|
||||
public class PgenDeleteObjHandler extends InputHandlerDefaultImpl {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.ui.input.IInputHandler#handleMouseDown(int,
|
||||
* int, int)
|
||||
*/
|
||||
@Override
|
||||
public boolean handleMouseDown(int x, int y, int button) {
|
||||
if (!isResourceEditable())
|
||||
return false;
|
||||
|
||||
if (button == 3) {
|
||||
// set selecting mode
|
||||
PgenUtil.setSelectingMode();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -8,8 +8,9 @@
|
|||
|
||||
package gov.noaa.nws.ncep.ui.pgen.tools;
|
||||
|
||||
import static java.lang.Math.*;
|
||||
|
||||
import static java.lang.Math.atan2;
|
||||
import static java.lang.Math.toDegrees;
|
||||
import gov.noaa.nws.ncep.ui.pgen.PgenUtil;
|
||||
import gov.noaa.nws.ncep.ui.pgen.annotation.Operation;
|
||||
import gov.noaa.nws.ncep.ui.pgen.attrdialog.TrackExtrapPointInfoDlg;
|
||||
import gov.noaa.nws.ncep.ui.pgen.display.ISinglePoint;
|
||||
|
@ -34,6 +35,7 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* 01/2010 Mikhail L. Initial Creation.
|
||||
* 06/2010 #280 Moved two methods to PgenToolUtils.
|
||||
* 04/2014 TTR900 pswamy R-click cannot return to SELECT from Rotate and DEL_OBJ
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -42,260 +44,283 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
|
||||
public class PgenRotateElement extends AbstractPgenDrawingTool {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.ui.tools.AbstractTool#runTool()
|
||||
*/
|
||||
@Override
|
||||
protected void activateTool() {
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.ui.tools.AbstractTool#runTool()
|
||||
*/
|
||||
@Override
|
||||
protected void activateTool() {
|
||||
|
||||
attrDlg = null;
|
||||
if (buttonName == null){
|
||||
buttonName = new String("Select");
|
||||
}
|
||||
attrDlg = null;
|
||||
if (buttonName == null) {
|
||||
buttonName = new String("Select");
|
||||
}
|
||||
|
||||
super.activateTool();
|
||||
super.activateTool();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current mouse handler.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public IInputHandler getMouseHandler() {
|
||||
if (mouseHandler == null) {
|
||||
mouseHandler = new PgenSelectRotateHandler();
|
||||
}
|
||||
return mouseHandler;
|
||||
}
|
||||
/**
|
||||
* Returns the current mouse handler.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public IInputHandler getMouseHandler() {
|
||||
if (mouseHandler == null) {
|
||||
mouseHandler = new PgenSelectRotateHandler();
|
||||
}
|
||||
return mouseHandler;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements input handler for mouse events.
|
||||
*
|
||||
* @author bingfan, Mikhail L.
|
||||
*
|
||||
*/
|
||||
public class PgenSelectRotateHandler extends InputHandlerDefaultImpl {
|
||||
/**
|
||||
* Implements input handler for mouse events.
|
||||
*
|
||||
* @author bingfan, Mikhail L.
|
||||
*
|
||||
*/
|
||||
public class PgenSelectRotateHandler extends InputHandlerDefaultImpl {
|
||||
|
||||
OperationFilter rotateFilter = new OperationFilter( Operation.ROTATE );
|
||||
OperationFilter rotateFilter = new OperationFilter(Operation.ROTATE);
|
||||
|
||||
/** Attribute dialog for displaying track points info */
|
||||
TrackExtrapPointInfoDlg trackExtrapPointInfoDlg = null;
|
||||
/** Attribute dialog for displaying track points info */
|
||||
TrackExtrapPointInfoDlg trackExtrapPointInfoDlg = null;
|
||||
|
||||
/** Flag if any point of the element is selected. */
|
||||
protected boolean ptSelected = false;
|
||||
/** Flag if any point of the element is selected. */
|
||||
protected boolean ptSelected = false;
|
||||
|
||||
/** The original direction is needed for undo. */
|
||||
private Double oldDir = null; // using Double instead of double because we need to use null value
|
||||
/** The original direction is needed for undo. */
|
||||
private Double oldDir = null; // using Double instead of double because
|
||||
// we need to use null value
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.ui.input.IInputHandler#handleMouseDown(int,
|
||||
* int, int)
|
||||
*/
|
||||
@Override
|
||||
public boolean handleMouseDown(int x, int y, int button) {
|
||||
if ( !isResourceEditable() ) return false;
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.ui.input.IInputHandler#handleMouseDown(int,
|
||||
* int, int)
|
||||
*/
|
||||
@Override
|
||||
public boolean handleMouseDown(int x, int y, int button) {
|
||||
if (!isResourceEditable())
|
||||
return false;
|
||||
|
||||
// Check if mouse is in geographic extent
|
||||
Coordinate loc = mapEditor.translateClick(x, y);
|
||||
if (loc == null || shiftDown ) {
|
||||
return false;
|
||||
}
|
||||
// Check if mouse is in geographic extent
|
||||
Coordinate loc = mapEditor.translateClick(x, y);
|
||||
if (loc == null || shiftDown) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (button == 1) {
|
||||
if (button == 1) {
|
||||
|
||||
// Return if an element or a point has been selected
|
||||
if (ptSelected || drawingLayer.getSelectedDE() != null) {
|
||||
return true;
|
||||
}
|
||||
// Return if an element or a point has been selected
|
||||
if (ptSelected || drawingLayer.getSelectedDE() != null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Get the nearest element and set it as the selected element.
|
||||
DrawableElement elSelected = drawingLayer.getNearestElement(loc, rotateFilter);
|
||||
// Get the nearest element and set it as the selected element.
|
||||
DrawableElement elSelected = drawingLayer.getNearestElement(
|
||||
loc, rotateFilter);
|
||||
|
||||
/*
|
||||
if (elSelected instanceof TCAElement) {
|
||||
PgenUtil.loadTCATool(elSelected);
|
||||
} else if (elSelected instanceof WatchBox) {
|
||||
PgenUtil.loadWatchBoxModifyTool(elSelected);
|
||||
}
|
||||
*/
|
||||
/*
|
||||
* if (elSelected instanceof TCAElement) {
|
||||
* PgenUtil.loadTCATool(elSelected); } else if (elSelected
|
||||
* instanceof WatchBox) {
|
||||
* PgenUtil.loadWatchBoxModifyTool(elSelected); }
|
||||
*/
|
||||
|
||||
if (elSelected != null) drawingLayer.setSelected(elSelected);
|
||||
if (elSelected != null)
|
||||
drawingLayer.setSelected(elSelected);
|
||||
|
||||
mapEditor.refresh();
|
||||
return false;
|
||||
mapEditor.refresh();
|
||||
return false;
|
||||
|
||||
} else if (button == 3) {
|
||||
} else if (button == 3) {
|
||||
|
||||
if (trackExtrapPointInfoDlg != null){
|
||||
trackExtrapPointInfoDlg.close();
|
||||
trackExtrapPointInfoDlg = null;
|
||||
}
|
||||
if (trackExtrapPointInfoDlg != null) {
|
||||
trackExtrapPointInfoDlg.close();
|
||||
trackExtrapPointInfoDlg = null;
|
||||
}
|
||||
|
||||
drawingLayer.removeGhostLine();
|
||||
ptSelected = false;
|
||||
drawingLayer.removeSelected();
|
||||
mapEditor.refresh();
|
||||
if (drawingLayer.getSelectedDE() != null) {
|
||||
drawingLayer.removeGhostLine();
|
||||
ptSelected = false;
|
||||
drawingLayer.removeSelected();
|
||||
mapEditor.refresh();
|
||||
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
// set selecting mode
|
||||
PgenUtil.setSelectingMode();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.ui.input.IInputHandler#handleMouseDownMove(int,
|
||||
* int, int)
|
||||
*/
|
||||
@Override
|
||||
public boolean handleMouseDownMove(int x, int y, int button) {
|
||||
if ( !isResourceEditable() ) return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if mouse is in geographic extent
|
||||
Coordinate loc = mapEditor.translateClick(x, y);
|
||||
if (loc == null || shiftDown ) return false;
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.ui.input.IInputHandler#handleMouseDownMove(int,
|
||||
* int, int)
|
||||
*/
|
||||
@Override
|
||||
public boolean handleMouseDownMove(int x, int y, int button) {
|
||||
if (!isResourceEditable())
|
||||
return false;
|
||||
|
||||
DrawableElement el = drawingLayer.getSelectedDE();
|
||||
// Check if mouse is in geographic extent
|
||||
Coordinate loc = mapEditor.translateClick(x, y);
|
||||
if (loc == null || shiftDown)
|
||||
return false;
|
||||
|
||||
// The requirements are to rotate Vector and Text elements only
|
||||
// Do not modify other elements
|
||||
if (el != null) {
|
||||
Coordinate origin = ((ISinglePoint)el).getLocation();
|
||||
DrawableElement el = drawingLayer.getSelectedDE();
|
||||
|
||||
if (el instanceof Vector) {
|
||||
if (oldDir == null) {
|
||||
oldDir = ((Vector) el).getDirection(); // autoboxing to Double
|
||||
}
|
||||
double[] swtCoordinates = mapEditor.translateInverseClick(origin);
|
||||
Double newDir = PgenToolUtils.calculateAngle(oldDir, swtCoordinates[0], swtCoordinates[1], x, y);
|
||||
if("Hash".equals(((Vector) el).getPgenType())){
|
||||
newDir = PgenToolUtils.transformToRange0To360(180 - newDir);
|
||||
newDir -= southOffsetAngle(origin);
|
||||
} else {
|
||||
// offset for the location point
|
||||
newDir += southOffsetAngle(origin);
|
||||
}
|
||||
((Vector) el).setDirection(newDir);
|
||||
// The requirements are to rotate Vector and Text elements only
|
||||
// Do not modify other elements
|
||||
if (el != null) {
|
||||
Coordinate origin = ((ISinglePoint) el).getLocation();
|
||||
|
||||
} else if (el instanceof Text) {
|
||||
if (oldDir == null) {
|
||||
oldDir = ((Text) el).getRotation(); // autoboxing to Double
|
||||
}
|
||||
double[] swtCoordinates = mapEditor.translateInverseClick(origin);
|
||||
Double newRotation = 180 - PgenToolUtils.calculateAngle(oldDir, swtCoordinates[0], swtCoordinates[1], x, y);
|
||||
newRotation = PgenToolUtils.transformToRange0To360(newRotation);
|
||||
if(((Text) el).getRotationRelativity() == TextRotation.NORTH_RELATIVE){
|
||||
// offset for the location point
|
||||
newRotation -= southOffsetAngle(origin);
|
||||
}
|
||||
((Text) el).setRotation(newRotation);
|
||||
}
|
||||
if (el instanceof Vector) {
|
||||
if (oldDir == null) {
|
||||
oldDir = ((Vector) el).getDirection(); // autoboxing to
|
||||
// Double
|
||||
}
|
||||
double[] swtCoordinates = mapEditor
|
||||
.translateInverseClick(origin);
|
||||
Double newDir = PgenToolUtils.calculateAngle(oldDir,
|
||||
swtCoordinates[0], swtCoordinates[1], x, y);
|
||||
if ("Hash".equals(((Vector) el).getPgenType())) {
|
||||
newDir = PgenToolUtils
|
||||
.transformToRange0To360(180 - newDir);
|
||||
newDir -= southOffsetAngle(origin);
|
||||
} else {
|
||||
// offset for the location point
|
||||
newDir += southOffsetAngle(origin);
|
||||
}
|
||||
((Vector) el).setDirection(newDir);
|
||||
|
||||
drawingLayer.resetElement(el); // reset display of this element
|
||||
mapEditor.refresh();
|
||||
}
|
||||
} else if (el instanceof Text) {
|
||||
if (oldDir == null) {
|
||||
oldDir = ((Text) el).getRotation(); // autoboxing to
|
||||
// Double
|
||||
}
|
||||
double[] swtCoordinates = mapEditor
|
||||
.translateInverseClick(origin);
|
||||
Double newRotation = 180 - PgenToolUtils.calculateAngle(
|
||||
oldDir, swtCoordinates[0], swtCoordinates[1], x, y);
|
||||
newRotation = PgenToolUtils
|
||||
.transformToRange0To360(newRotation);
|
||||
if (((Text) el).getRotationRelativity() == TextRotation.NORTH_RELATIVE) {
|
||||
// offset for the location point
|
||||
newRotation -= southOffsetAngle(origin);
|
||||
}
|
||||
((Text) el).setRotation(newRotation);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
drawingLayer.resetElement(el); // reset display of this element
|
||||
mapEditor.refresh();
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the angle difference of "south" relative to the screen's y-axis
|
||||
* at a given lat/lon location.
|
||||
* @param loc - The point location in Lat/Lon coordinates
|
||||
* @return The angle difference of "north" versus pixel coordinate's y-axis
|
||||
*/
|
||||
private double southOffsetAngle( Coordinate loc ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
double delta = 0.05;
|
||||
/*
|
||||
* copy/paste from DisplayElementFactory
|
||||
*
|
||||
* Calculate points in pixel coordinates just south and north of
|
||||
* original location.
|
||||
*/
|
||||
double[] south = { loc.x, loc.y - delta, 0.0 };
|
||||
double[] pt1 = drawingLayer.getDescriptor().worldToPixel(south);
|
||||
/**
|
||||
* Calculates the angle difference of "south" relative to the screen's
|
||||
* y-axis at a given lat/lon location.
|
||||
*
|
||||
* @param loc
|
||||
* - The point location in Lat/Lon coordinates
|
||||
* @return The angle difference of "north" versus pixel coordinate's
|
||||
* y-axis
|
||||
*/
|
||||
private double southOffsetAngle(Coordinate loc) {
|
||||
|
||||
double[] north = { loc.x, loc.y + delta, 0.0 };
|
||||
double[] pt2 = drawingLayer.getDescriptor().worldToPixel(north);
|
||||
double delta = 0.05;
|
||||
/*
|
||||
* copy/paste from DisplayElementFactory
|
||||
*
|
||||
* Calculate points in pixel coordinates just south and north of
|
||||
* original location.
|
||||
*/
|
||||
double[] south = { loc.x, loc.y - delta, 0.0 };
|
||||
double[] pt1 = drawingLayer.getDescriptor().worldToPixel(south);
|
||||
|
||||
return -90 - toDegrees(atan2( (pt2[1]-pt1[1]), (pt2[0]-pt1[0]) ));
|
||||
}
|
||||
double[] north = { loc.x, loc.y + delta, 0.0 };
|
||||
double[] pt2 = drawingLayer.getDescriptor().worldToPixel(north);
|
||||
|
||||
return -90 - toDegrees(atan2((pt2[1] - pt1[1]), (pt2[0] - pt1[0])));
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.ui.input.IInputHandler#handleMouseUp(int, int,
|
||||
* int)
|
||||
*/
|
||||
@Override
|
||||
public boolean handleMouseUp(int x, int y, int button) {
|
||||
if ( !isResourceEditable() ) return false;
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.ui.input.IInputHandler#handleMouseUp(int, int,
|
||||
* int)
|
||||
*/
|
||||
@Override
|
||||
public boolean handleMouseUp(int x, int y, int button) {
|
||||
if (!isResourceEditable())
|
||||
return false;
|
||||
|
||||
// Finish the editing
|
||||
if (button == 1 && drawingLayer != null) {
|
||||
// Finish the editing
|
||||
if (button == 1 && drawingLayer != null) {
|
||||
|
||||
// Create a copy of the currently selected element
|
||||
DrawableElement el = drawingLayer.getSelectedDE();
|
||||
// Create a copy of the currently selected element
|
||||
DrawableElement el = drawingLayer.getSelectedDE();
|
||||
|
||||
if (el != null && oldDir != null) {
|
||||
if (el != null && oldDir != null) {
|
||||
|
||||
DrawableElement newEl = (DrawableElement) el.copy();
|
||||
DrawableElement newEl = (DrawableElement) el.copy();
|
||||
|
||||
drawingLayer.resetElement(el);
|
||||
drawingLayer.resetElement(el);
|
||||
|
||||
if (el instanceof Vector) {
|
||||
((Vector) el).setDirection(oldDir);
|
||||
oldDir = null;
|
||||
} else if (el instanceof Text) {
|
||||
((Text) el).setRotation(oldDir);
|
||||
oldDir = null;
|
||||
}
|
||||
if (el instanceof Vector) {
|
||||
((Vector) el).setDirection(oldDir);
|
||||
oldDir = null;
|
||||
} else if (el instanceof Text) {
|
||||
((Text) el).setRotation(oldDir);
|
||||
oldDir = null;
|
||||
}
|
||||
|
||||
drawingLayer.replaceElement(el, newEl);
|
||||
drawingLayer.setSelected(newEl);
|
||||
drawingLayer.replaceElement(el, newEl);
|
||||
drawingLayer.setSelected(newEl);
|
||||
|
||||
mapEditor.refresh();
|
||||
}
|
||||
}
|
||||
mapEditor.refresh();
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the nearest point of an selected element to the input point
|
||||
*
|
||||
* @param el
|
||||
* element
|
||||
* @param pt
|
||||
* input point
|
||||
* @return
|
||||
*/
|
||||
protected int getNearestPtIndex(MultiPointElement el, Coordinate pt) {
|
||||
/**
|
||||
* Gets the nearest point of an selected element to the input point
|
||||
*
|
||||
* @param el
|
||||
* element
|
||||
* @param pt
|
||||
* input point
|
||||
* @return
|
||||
*/
|
||||
protected int getNearestPtIndex(MultiPointElement el, Coordinate pt) {
|
||||
|
||||
int ptId = 0;
|
||||
double minDistance = -1;
|
||||
GeodeticCalculator gc;
|
||||
gc = new GeodeticCalculator(drawingLayer.getCoordinateReferenceSystem());
|
||||
gc.setStartingGeographicPoint(pt.x, pt.y);
|
||||
int index = 0;
|
||||
for (Coordinate elPoint : el.getPoints()) {
|
||||
gc.setDestinationGeographicPoint(elPoint.x, elPoint.y);
|
||||
double dist = gc.getOrthodromicDistance();
|
||||
if (minDistance < 0 || dist < minDistance) {
|
||||
minDistance = dist;
|
||||
ptId = index;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
return ptId;
|
||||
}
|
||||
}
|
||||
int ptId = 0;
|
||||
double minDistance = -1;
|
||||
GeodeticCalculator gc;
|
||||
gc = new GeodeticCalculator(
|
||||
drawingLayer.getCoordinateReferenceSystem());
|
||||
gc.setStartingGeographicPoint(pt.x, pt.y);
|
||||
int index = 0;
|
||||
for (Coordinate elPoint : el.getPoints()) {
|
||||
gc.setDestinationGeographicPoint(elPoint.x, elPoint.y);
|
||||
double dist = gc.getOrthodromicDistance();
|
||||
if (minDistance < 0 || dist < minDistance) {
|
||||
minDistance = dist;
|
||||
ptId = index;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
return ptId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -77,6 +77,14 @@ import com.vividsolutions.jts.geom.Point;
|
|||
* 09/13 ? J. Wu Call buildVortext for GFA when mouse is
|
||||
* down since GFA converted from VGF does not
|
||||
* have vorText set.
|
||||
* 04/14 #1117 J. Wu Set focus to label/update line type for Contours.
|
||||
* 04/2014 TTR867 pswamy Select-tool-on-center-vertex of circle does not
|
||||
* move circle (as in NMAP)
|
||||
* 04/21/2014 TTR992 D. Sushon Contour tool's Label >> Edit option should not close
|
||||
* main Contour tool window on Cancel, changing a
|
||||
* symbol's label should not change the symbol;
|
||||
* Both issues fixed.
|
||||
* 05/14 TTR1008 J. Wu Set "adc" to current contour for PgenContoursTool..
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -171,20 +179,27 @@ public class PgenSelectHandler extends InputHandlerDefaultImpl {
|
|||
@Override
|
||||
public boolean handleMouseDown(int anX, int aY, int button) {
|
||||
|
||||
if (!tool.isResourceEditable())
|
||||
if (!tool.isResourceEditable()) {
|
||||
return false;
|
||||
}
|
||||
// Check if mouse is in geographic extent
|
||||
Coordinate loc = mapEditor.translateClick(anX, aY);
|
||||
if (loc == null || shiftDown || simulate)
|
||||
if (loc == null || shiftDown || simulate) {
|
||||
return false;
|
||||
}
|
||||
preempt = false;
|
||||
|
||||
if (attrDlg != null && attrDlg instanceof ContoursAttrDlg) {
|
||||
((ContoursAttrDlg) attrDlg).setLabelFocus();
|
||||
}
|
||||
|
||||
if (button == 1) {
|
||||
|
||||
// reset ptSelected flag in case the dialog is closed without
|
||||
// right-mouse click.
|
||||
if (pgenrsc.getSelectedDE() == null)
|
||||
if (pgenrsc.getSelectedDE() == null) {
|
||||
ptSelected = false;
|
||||
}
|
||||
|
||||
// Return if an element or a point has been selected
|
||||
if (ptSelected || pgenrsc.getSelectedDE() != null) {
|
||||
|
@ -229,8 +244,9 @@ public class PgenSelectHandler extends InputHandlerDefaultImpl {
|
|||
// AbstractDrawableComponent adc = drawingLayer.getNearestComponent(
|
||||
// loc, new AcceptFilter(), true );
|
||||
|
||||
if (elSelected == null)
|
||||
if (elSelected == null) {
|
||||
return false;
|
||||
}
|
||||
preempt = true;
|
||||
|
||||
/*
|
||||
|
@ -263,6 +279,8 @@ public class PgenSelectHandler extends InputHandlerDefaultImpl {
|
|||
// of the contour.
|
||||
ptSelected = false;
|
||||
}
|
||||
|
||||
adc = dec;
|
||||
}
|
||||
|
||||
pgCategory = "MET";
|
||||
|
@ -472,24 +490,34 @@ public class PgenSelectHandler extends InputHandlerDefaultImpl {
|
|||
*/
|
||||
@Override
|
||||
public boolean handleMouseDownMove(int x, int y, int button) {
|
||||
if (!tool.isResourceEditable())
|
||||
if (!tool.isResourceEditable()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (shiftDown)
|
||||
if (shiftDown) {
|
||||
return false;
|
||||
if (dontMove && pgenrsc.getSelectedDE() != null)
|
||||
}
|
||||
if (dontMove && pgenrsc.getSelectedDE() != null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (attrDlg != null && attrDlg instanceof ContoursAttrDlg) {
|
||||
((ContoursAttrDlg) attrDlg).setLabelFocus();
|
||||
}
|
||||
|
||||
// Check if mouse is in geographic extent
|
||||
Coordinate loc = mapEditor.translateClick(x, y);
|
||||
// if ( loc == null ) return false;
|
||||
// if ( loc == null ){ return false;}
|
||||
|
||||
DrawableElement tmpEl = pgenrsc.getSelectedDE();
|
||||
if (PgenUtil.isUnmovable(tmpEl))
|
||||
if (PgenUtil.isUnmovable(tmpEl)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//
|
||||
if (loc != null)
|
||||
if (loc != null) {
|
||||
tempLoc = loc;
|
||||
}
|
||||
|
||||
if (loc != null && inOut == 1) {
|
||||
// make sure the click is close enough to the element
|
||||
|
@ -510,13 +538,14 @@ public class PgenSelectHandler extends InputHandlerDefaultImpl {
|
|||
} else if (loc != null && inOut == 0) {
|
||||
inOut = 1;
|
||||
} else {
|
||||
if (inOut != 0)
|
||||
if (inOut != 0) {
|
||||
inOut = 0;
|
||||
}
|
||||
|
||||
if (tmpEl == null) // make sure if no DE is selected, no moving the
|
||||
// DE
|
||||
return false; // for pan
|
||||
else {
|
||||
if (tmpEl == null) { // make sure if no DE is selected, no moving
|
||||
// the DE for pan
|
||||
return false;
|
||||
} else {
|
||||
simulate = true;
|
||||
PgenUtil.simulateMouseDown(x, y, button, mapEditor);
|
||||
simulate = false;
|
||||
|
@ -579,10 +608,12 @@ public class PgenSelectHandler extends InputHandlerDefaultImpl {
|
|||
((TextAttrDlg) attrDlg).getString()[0]);
|
||||
|
||||
if (lbl.length() > 0) {
|
||||
if (lbl.charAt(0) == '[')
|
||||
if (lbl.charAt(0) == '[') {
|
||||
lbl.deleteCharAt(0);
|
||||
if (lbl.charAt(lbl.length() - 1) == ']')
|
||||
}
|
||||
if (lbl.charAt(lbl.length() - 1) == ']') {
|
||||
lbl.deleteCharAt(lbl.length() - 1);
|
||||
}
|
||||
try {
|
||||
Integer.parseInt(lbl.toString());
|
||||
// check if the text is right or left of the
|
||||
|
@ -623,9 +654,32 @@ public class PgenSelectHandler extends InputHandlerDefaultImpl {
|
|||
|
||||
} else {
|
||||
if (ptSelected) {
|
||||
// Replace the selected point and repaint.
|
||||
ghostEl.removePoint(ptIndex);
|
||||
ghostEl.addPoint(ptIndex, loc);
|
||||
|
||||
if ((ghostEl instanceof Arc) && (ptIndex == 0)) {
|
||||
|
||||
double[] centerOldLoc = mapEditor
|
||||
.translateInverseClick(ghostEl.getPoints().get(
|
||||
0));
|
||||
|
||||
double deltaX = (x - centerOldLoc[0]);
|
||||
double deltaY = (y - centerOldLoc[1]);
|
||||
|
||||
double[] circferOldLoc = mapEditor
|
||||
.translateInverseClick(ghostEl.getPoints().get(
|
||||
1));
|
||||
|
||||
Coordinate newLoc = mapEditor.translateClick(
|
||||
(circferOldLoc[0] + deltaX),
|
||||
(circferOldLoc[1] + deltaY));
|
||||
|
||||
// Replace the selected point and repaint.
|
||||
ghostEl.getPoints().set(ptIndex, loc);
|
||||
ghostEl.getPoints().set(ptIndex + 1, newLoc);
|
||||
|
||||
} else {
|
||||
ghostEl.getPoints().set(ptIndex, loc);
|
||||
}
|
||||
|
||||
if (ghostEl instanceof Gfa && !((Gfa) ghostEl).isSnapshot()) {
|
||||
((GfaAttrDlg) attrDlg).setEnableStatesButton(true);
|
||||
}
|
||||
|
@ -651,7 +705,7 @@ public class PgenSelectHandler extends InputHandlerDefaultImpl {
|
|||
ghostEl.setPgenType(tmpEl.getPgenType());
|
||||
|
||||
ptIndex = getNearestPtIndex(ghostEl, loc);
|
||||
|
||||
// mapEditor
|
||||
double[] locScreen = mapEditor
|
||||
.translateInverseClick(loc);
|
||||
double[] pt = mapEditor.translateInverseClick((ghostEl
|
||||
|
@ -698,8 +752,13 @@ public class PgenSelectHandler extends InputHandlerDefaultImpl {
|
|||
@Override
|
||||
public boolean handleMouseUp(int x, int y, int button) {
|
||||
firstDown = null;
|
||||
if (!tool.isResourceEditable())
|
||||
if (!tool.isResourceEditable()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (attrDlg != null && attrDlg instanceof ContoursAttrDlg) {
|
||||
((ContoursAttrDlg) attrDlg).setLabelFocus();
|
||||
}
|
||||
|
||||
// Finish the editing
|
||||
if (button == 1 && pgenrsc != null) {
|
||||
|
@ -837,10 +896,11 @@ public class PgenSelectHandler extends InputHandlerDefaultImpl {
|
|||
}
|
||||
|
||||
Coordinate loc = mapEditor.translateClick(x, y);
|
||||
if (loc != null)
|
||||
if (loc != null) {
|
||||
((SinglePointElement) newEl).setLocation(loc);
|
||||
else
|
||||
} else {
|
||||
((SinglePointElement) newEl).setLocation(tempLoc);
|
||||
}
|
||||
pgenrsc.setSelected(newEl);
|
||||
}
|
||||
|
||||
|
@ -922,8 +982,9 @@ public class PgenSelectHandler extends InputHandlerDefaultImpl {
|
|||
|
||||
}
|
||||
|
||||
if (attrDlg != null)
|
||||
if (attrDlg != null) {
|
||||
attrDlg.setDrawableElement(newEl);
|
||||
}
|
||||
|
||||
// Set this new element as the currently selected
|
||||
// element
|
||||
|
@ -937,8 +998,9 @@ public class PgenSelectHandler extends InputHandlerDefaultImpl {
|
|||
|
||||
if (newEl instanceof Track) {
|
||||
if (isModifiedPointOneOfTheLastTwoInitPoint(newEl,
|
||||
ptIndex))
|
||||
ptIndex)) {
|
||||
((Track) newEl).calculateExtrapTrackPoints();
|
||||
}
|
||||
displayTrackExtrapPointInfoDlg((TrackAttrDlg) attrDlg,
|
||||
(Track) newEl);
|
||||
} else if (newEl instanceof Gfa) {
|
||||
|
@ -979,8 +1041,9 @@ public class PgenSelectHandler extends InputHandlerDefaultImpl {
|
|||
// PgenUtil.setSelectingMode();
|
||||
// }
|
||||
|
||||
if (trackExtrapPointInfoDlg != null)
|
||||
if (trackExtrapPointInfoDlg != null) {
|
||||
trackExtrapPointInfoDlg.close();
|
||||
}
|
||||
trackExtrapPointInfoDlg = null;
|
||||
|
||||
pgenrsc.removeGhostLine();
|
||||
|
@ -1011,23 +1074,27 @@ public class PgenSelectHandler extends InputHandlerDefaultImpl {
|
|||
/*
|
||||
* If multiPointElement is not a type of Track, do nothing
|
||||
*/
|
||||
if (multiPointElement == null || !(multiPointElement instanceof Track))
|
||||
if (multiPointElement == null || !(multiPointElement instanceof Track)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Track track = (Track) multiPointElement;
|
||||
int initialTrackPointSize = 0;
|
||||
if (track.getInitialPoints() != null)
|
||||
if (track.getInitialPoints() != null) {
|
||||
initialTrackPointSize = track.getInitialPoints().length;
|
||||
if (isInitialPointSelected(initialTrackPointSize, nearestPointIndex))
|
||||
}
|
||||
if (isInitialPointSelected(initialTrackPointSize, nearestPointIndex)) {
|
||||
track.setInitialColor(new java.awt.Color(255, 255, 255));
|
||||
else
|
||||
} else {
|
||||
track.setExtrapColor(new java.awt.Color(255, 255, 255));
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isInitialPointSelected(int initialPointSize,
|
||||
int nearestPointIndex) {
|
||||
if (nearestPointIndex < initialPointSize)
|
||||
if (nearestPointIndex < initialPointSize) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1037,16 +1104,19 @@ public class PgenSelectHandler extends InputHandlerDefaultImpl {
|
|||
/*
|
||||
* If multiPointElement is not a type of Track, return false
|
||||
*/
|
||||
if (drawableElement == null || !(drawableElement instanceof Track))
|
||||
if (drawableElement == null || !(drawableElement instanceof Track)) {
|
||||
return isOneOfTheLastTwoInitPoint;
|
||||
}
|
||||
|
||||
Track track = (Track) drawableElement;
|
||||
int initialTrackPointSize = 0;
|
||||
if (track.getInitialPoints() != null)
|
||||
if (track.getInitialPoints() != null) {
|
||||
initialTrackPointSize = track.getInitialPoints().length;
|
||||
}
|
||||
if (nearestPointIndex == (initialTrackPointSize - 1)
|
||||
|| nearestPointIndex == (initialTrackPointSize - 2))
|
||||
|| nearestPointIndex == (initialTrackPointSize - 2)) {
|
||||
isOneOfTheLastTwoInitPoint = true;
|
||||
}
|
||||
|
||||
return isOneOfTheLastTwoInitPoint;
|
||||
}
|
||||
|
@ -1091,15 +1161,17 @@ public class PgenSelectHandler extends InputHandlerDefaultImpl {
|
|||
}
|
||||
|
||||
public void closeDlg() {
|
||||
if (attrDlg != null)
|
||||
if (attrDlg != null) {
|
||||
attrDlg.close();
|
||||
}
|
||||
}
|
||||
|
||||
private void displayTrackExtrapPointInfoDlg(TrackAttrDlg attrDlgObject,
|
||||
Track trackObject) {
|
||||
|
||||
if (attrDlgObject == null)
|
||||
if (attrDlgObject == null) {
|
||||
return;
|
||||
}
|
||||
TrackExtrapPointInfoDlg extrapPointInfoDlg = attrDlgObject
|
||||
.getTrackExtrapPointInfoDlg();
|
||||
if (extrapPointInfoDlg != null) {
|
||||
|
@ -1130,20 +1202,23 @@ public class PgenSelectHandler extends InputHandlerDefaultImpl {
|
|||
}
|
||||
|
||||
private boolean isTrackElement(DrawableType drawableType) {
|
||||
if (drawableType == DrawableType.TRACK)
|
||||
if (drawableType == DrawableType.TRACK) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private DrawableType getDrawableType(String pgenTypeString) {
|
||||
if (Track.TRACK_PGEN_TYPE.equalsIgnoreCase(pgenTypeString))
|
||||
if (Track.TRACK_PGEN_TYPE.equalsIgnoreCase(pgenTypeString)) {
|
||||
return DrawableType.TRACK;
|
||||
}
|
||||
return DrawableType.LINE;
|
||||
}
|
||||
|
||||
private boolean closeAttrDlg(AttrDlg attrDlgObject, String pgenTypeString) {
|
||||
if (attrDlgObject == null)
|
||||
if (attrDlgObject == null) {
|
||||
return false;
|
||||
}
|
||||
if (isTrackElement(getDrawableType(pgenTypeString))) {
|
||||
TrackAttrDlg tempTrackAttrDlg = (TrackAttrDlg) attrDlgObject;
|
||||
TrackExtrapPointInfoDlg tempTrackExtrapPointInfoDlg = tempTrackAttrDlg
|
||||
|
@ -1156,8 +1231,9 @@ public class PgenSelectHandler extends InputHandlerDefaultImpl {
|
|||
}
|
||||
|
||||
private void closeTrackExtrapPointInfoDlg(TrackExtrapPointInfoDlg dlgObject) {
|
||||
if (dlgObject != null)
|
||||
if (dlgObject != null) {
|
||||
dlgObject.close();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1214,8 +1290,9 @@ public class PgenSelectHandler extends InputHandlerDefaultImpl {
|
|||
newContours.update(oldContours);
|
||||
pgenrsc.replaceElement(oldContours, newContours);
|
||||
pgenrsc.setSelected(selElem);
|
||||
if (attrDlg != null)
|
||||
if (attrDlg != null) {
|
||||
((ContoursAttrDlg) attrDlg).setCurrentContours(newContours);
|
||||
}
|
||||
((PgenContoursTool) tool).setCurrentContour(newContours);
|
||||
}
|
||||
}
|
||||
|
@ -1254,7 +1331,8 @@ public class PgenSelectHandler extends InputHandlerDefaultImpl {
|
|||
|
||||
cdlg.setNumOfLabels(((ContourLine) pele).getNumOfLabels());
|
||||
cdlg.setClosed(((Line) elSelected).isClosedLine());
|
||||
cdlg.setContourLineType(elSelected.getPgenType());
|
||||
cdlg.setActiveLine(elSelected);
|
||||
// cdlg.setContourLineType(elSelected.getPgenType());
|
||||
// cdlg.setDrawingLine();
|
||||
} else if (elSelected instanceof Symbol) {
|
||||
Text lbl = ((ContourMinmax) pele).getLabel();
|
||||
|
@ -1262,7 +1340,7 @@ public class PgenSelectHandler extends InputHandlerDefaultImpl {
|
|||
if (lbl != null) {
|
||||
cdlg.setLabel(lbl.getText()[0]);
|
||||
cdlg.setNumOfLabels(1);
|
||||
// cdlg.setActiveSymbol( elSelected );
|
||||
cdlg.setActiveSymbol(elSelected);
|
||||
}
|
||||
} else if (elSelected instanceof Text) {
|
||||
cdlg.setLabel(((Text) elSelected).getText()[0]);
|
||||
|
@ -1272,13 +1350,13 @@ public class PgenSelectHandler extends InputHandlerDefaultImpl {
|
|||
cdlg.setNumOfLabels(((ContourLine) pele).getNumOfLabels());
|
||||
cdlg.setClosed(((ContourLine) pele).getLine()
|
||||
.isClosedLine());
|
||||
cdlg.setContourLineType(((ContourLine) pele).getLine()
|
||||
.getPgenType());
|
||||
cdlg.setActiveLine(((ContourLine) pele).getLine());
|
||||
// cdlg.setContourLineType(((ContourLine) pele).getLine()
|
||||
// .getPgenType());
|
||||
} else if (pele instanceof ContourMinmax) {
|
||||
// cdlg.setDrawingSymbol();
|
||||
cdlg.setNumOfLabels(1);
|
||||
// cdlg.setActiveSymbol( ((ContourMinmax)pele).getSymbol()
|
||||
// );
|
||||
cdlg.setActiveSymbol(((ContourMinmax) pele).getSymbol());
|
||||
} else if (pele instanceof ContourCircle) {
|
||||
// cdlg.setDrawingCircle();
|
||||
cdlg.setNumOfLabels(1);
|
||||
|
|
Loading…
Add table
Reference in a new issue