ncradarui command not found when running developer.product
Former-commit-id: 18377206554113dec6d02029a46f5bfdb59bd381 [formerly18bdb82c94
] Former-commit-id:ebc82fbb4e
This commit is contained in:
parent
58cf791552
commit
c5dd3b67a6
18 changed files with 3805 additions and 0 deletions
|
@ -45,6 +45,13 @@
|
|||
install-size="0"
|
||||
version="0.0.0"
|
||||
unpack="false"/>
|
||||
|
||||
<plugin
|
||||
id="gov.noaa.nws.ncep.ui.ncradarui"
|
||||
download-size="0"
|
||||
install-size="0"
|
||||
version="0.0.0"
|
||||
unpack="false"/>
|
||||
|
||||
<plugin
|
||||
id="gov.noaa.nws.ncep.ui.pgen"
|
||||
|
|
|
@ -615,6 +615,11 @@
|
|||
</reference>
|
||||
</visibleWhen>
|
||||
</command>
|
||||
<command
|
||||
commandId="edu.ucar.unidata.ui.ncradarui.palette"
|
||||
label="Ncradar"
|
||||
style="push">
|
||||
</command>
|
||||
</toolbar>
|
||||
</menuContribution>
|
||||
<menuContribution
|
||||
|
|
7
unidata/edu.ucar.unidata.ui.ncradarui/.classpath
Normal file
7
unidata/edu.ucar.unidata.ui.ncradarui/.classpath
Normal file
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
28
unidata/edu.ucar.unidata.ui.ncradarui/.project
Normal file
28
unidata/edu.ucar.unidata.ui.ncradarui/.project
Normal file
|
@ -0,0 +1,28 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>gov.noaa.nws.ncep.ui.ncradarui</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.ManifestBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.SchemaBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.pde.PluginNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
41
unidata/edu.ucar.unidata.ui.ncradarui/META-INF/MANIFEST.MF
Normal file
41
unidata/edu.ucar.unidata.ui.ncradarui/META-INF/MANIFEST.MF
Normal file
|
@ -0,0 +1,41 @@
|
|||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: Ncradarui Plug-in
|
||||
Bundle-SymbolicName: edu.ucar.unidata.ui.ncradarui;singleton:=true
|
||||
Bundle-Version: 1.0.0.qualifier
|
||||
Bundle-Activator: edu.ucar.unidata.ui.ncradarui.Activator
|
||||
Eclipse-BuddyPolicy: registered, ext, global
|
||||
Eclipse-RegisterBuddy: com.raytheon.viz.core, com.raytheon.uf.common.serialization
|
||||
Require-Bundle: org.eclipse.ui,
|
||||
org.eclipse.core.runtime,
|
||||
com.raytheon.viz.ui;bundle-version="1.11.17",
|
||||
org.geotools,
|
||||
com.raytheon.viz.core;bundle-version="1.11.17",
|
||||
gov.noaa.nws.ncep.ui.pgen,
|
||||
gov.noaa.nws.ncep.viz.common;bundle-version="1.0.0",
|
||||
com.raytheon.uf.common.pointdata,
|
||||
com.raytheon.uf.viz.datacube
|
||||
Eclipse-LazyStart: true
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
||||
Bundle-Vendor: SIB
|
||||
Import-Package: com.raytheon.uf.common.inventory.exception,
|
||||
com.raytheon.uf.common.dataplugin,
|
||||
com.raytheon.uf.common.dataplugin.obs.metar,
|
||||
com.raytheon.uf.common.pointdata,
|
||||
com.raytheon.uf.viz.core,
|
||||
com.raytheon.uf.viz.core.drawables,
|
||||
com.raytheon.uf.viz.core.exception,
|
||||
com.raytheon.uf.viz.core.map,
|
||||
com.raytheon.uf.viz.core.rsc,
|
||||
com.raytheon.viz.pointdata,
|
||||
com.vividsolutions.jts.geom,
|
||||
gov.noaa.nws.ncep.viz.common.ui,
|
||||
gov.noaa.nws.ncep.viz.localization,
|
||||
gov.noaa.nws.ncep.viz.overlays,
|
||||
gov.noaa.nws.ncep.viz.resources.manager,
|
||||
gov.noaa.nws.ncep.viz.ui.display,
|
||||
org.eclipse.ui.forms.widgets,
|
||||
org.geotools.referencing,
|
||||
org.geotools.referencing.datum,
|
||||
org.opengis.referencing.crs
|
||||
Export-Package: edu.ucar.unidata.ui.ncradarui.rsc
|
5
unidata/edu.ucar.unidata.ui.ncradarui/build.properties
Normal file
5
unidata/edu.ucar.unidata.ui.ncradarui/build.properties
Normal file
|
@ -0,0 +1,5 @@
|
|||
source.. = src/
|
||||
output.. = bin/
|
||||
bin.includes = META-INF/,\
|
||||
.,\
|
||||
plugin.xml
|
85
unidata/edu.ucar.unidata.ui.ncradarui/plugin.xml
Normal file
85
unidata/edu.ucar.unidata.ui.ncradarui/plugin.xml
Normal file
|
@ -0,0 +1,85 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?eclipse version="3.3"?>
|
||||
<plugin>
|
||||
|
||||
<extension
|
||||
point="org.eclipse.ui.commands">
|
||||
<command
|
||||
id="edu.ucar.unidata.ui.ncradarui.palette"
|
||||
name="Ncradar">
|
||||
</command>
|
||||
<command
|
||||
id="edu.ucar.unidata.ui.ncradarui.rsc.NcradaruiTool"
|
||||
name="Ncradarui Selecting">
|
||||
</command>
|
||||
<!--
|
||||
<command
|
||||
id="edu.ucar.unidata.ui.ncradarui.help"
|
||||
name="NCRADAR Help">
|
||||
</command>
|
||||
-->
|
||||
</extension>
|
||||
|
||||
<extension
|
||||
point="org.eclipse.ui.handlers">
|
||||
<handler
|
||||
class="edu.ucar.unidata.ui.ncradarui.palette.NcradaruiPaletteAction"
|
||||
commandId="edu.ucar.unidata.ui.ncradarui.palette">
|
||||
</handler>
|
||||
<!--
|
||||
<handler
|
||||
class="edu.ucar.unidata.ui.ncradarui.rsc.NcradaruiModalTool"
|
||||
commandId="edu.ucar.unidata.ui.ncradarui.rsc.NcradaruiTool">
|
||||
</handler>
|
||||
|
||||
<handler
|
||||
class="edu.ucar.unidata.ui.ncradarui.productManage.HelpHandler"
|
||||
commandId="edu.ucar.unidata.ui.ncradarui.help">
|
||||
</handler>
|
||||
-->
|
||||
</extension>
|
||||
|
||||
<extension
|
||||
point="org.eclipse.ui.views">
|
||||
<category
|
||||
id="gov.noaa.nws.ncep.viz.ui.nmap"
|
||||
name="NMAP Views"/>
|
||||
<view
|
||||
category="gov.noaa.nws.ncep.viz.ui.nmap"
|
||||
allowMultiple="false"
|
||||
restorable="true"
|
||||
class="edu.ucar.unidata.ui.ncradarui.palette.NcradaruiPaletteWindow"
|
||||
id="edu.ucar.unidata.ui.ncradarui"
|
||||
name="NCRADAR"/>
|
||||
</extension>
|
||||
<extension
|
||||
point="com.raytheon.uf.viz.core.classContext">
|
||||
<classContext
|
||||
class="edu.ucar.unidata.ui.ncradarui.palette.NcradaruiPaletteWindow">
|
||||
<contextId
|
||||
id="gov.noaa.nws.ncep.viz.ui.display.NCMapContext">
|
||||
</contextId>
|
||||
</classContext>
|
||||
</extension>
|
||||
<!--
|
||||
<extension
|
||||
point="org.eclipse.ui.menus">
|
||||
<menuContribution
|
||||
locationURI="toolbar:edu.ucar.unidata.ui.ncradarui">
|
||||
<command
|
||||
commandId="edu.ucar.unidata.ui.ncradarui.help"
|
||||
label="Help"
|
||||
mnemonic="H"
|
||||
style="push">
|
||||
</command>
|
||||
</menuContribution>
|
||||
</extension>
|
||||
-->
|
||||
<!--
|
||||
<extension
|
||||
point="edu.ucar.unidata.ui.ncradarui.palette">
|
||||
</extension>
|
||||
-->
|
||||
|
||||
|
||||
</plugin>
|
|
@ -0,0 +1,50 @@
|
|||
package edu.ucar.unidata.ui.ncradarui;
|
||||
|
||||
import org.eclipse.ui.plugin.AbstractUIPlugin;
|
||||
import org.osgi.framework.BundleContext;
|
||||
|
||||
/**
|
||||
* The activator class controls the plug-in life cycle
|
||||
*/
|
||||
public class Activator extends AbstractUIPlugin {
|
||||
|
||||
// The plug-in ID
|
||||
public static final String PLUGIN_ID = "edu.ucar.unidata.ui.ncradarui";
|
||||
|
||||
// The shared instance
|
||||
private static Activator plugin;
|
||||
|
||||
/**
|
||||
* The constructor
|
||||
*/
|
||||
public Activator() {
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
|
||||
*/
|
||||
public void start(BundleContext context) throws Exception {
|
||||
super.start(context);
|
||||
plugin = this;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
|
||||
*/
|
||||
public void stop(BundleContext context) throws Exception {
|
||||
plugin = null;
|
||||
super.stop(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the shared instance
|
||||
*
|
||||
* @return the shared instance
|
||||
*/
|
||||
public static Activator getDefault() {
|
||||
return plugin;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package edu.ucar.unidata.ui.ncradarui.dbutil;
|
||||
|
||||
public enum EReportTimeRange {
|
||||
|
||||
NONE(0), ONE_HOUR (1), THREE_HOURS(3), SIX_HOURS(6), TWELVE_HOURS(12), TWENTYFOUR_HOURS(24), FORTYEIGHT_HOURS(48);
|
||||
private int timeRangeVal;
|
||||
|
||||
// Constructor
|
||||
EReportTimeRange(int p) { timeRangeVal = p; }
|
||||
|
||||
// Overloaded constructor
|
||||
EReportTimeRange() { timeRangeVal = -1; }
|
||||
|
||||
public int getTimeRange() { return timeRangeVal; }
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,65 @@
|
|||
package edu.ucar.unidata.ui.ncradarui.dbutil;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class NcradarStationInfo {
|
||||
protected String productid; //WMO id
|
||||
protected String stnid;
|
||||
protected String stnname;
|
||||
protected String state;
|
||||
protected String country;
|
||||
protected double latitude;
|
||||
protected double longitude;
|
||||
protected Integer elevation;
|
||||
|
||||
|
||||
public String getProductid() {
|
||||
return productid;
|
||||
}
|
||||
public void setProductid(String productid) {
|
||||
this.productid = productid;
|
||||
}
|
||||
public String getStnid() {
|
||||
return stnid;
|
||||
}
|
||||
public void setStnid(String stnid) {
|
||||
this.stnid = stnid;
|
||||
}
|
||||
public String getStnname() {
|
||||
return stnname;
|
||||
}
|
||||
public void setStnname(String stnname) {
|
||||
this.stnname = stnname;
|
||||
}
|
||||
public String getState() {
|
||||
return state;
|
||||
}
|
||||
public void setState(String state) {
|
||||
this.state = state;
|
||||
}
|
||||
public String getCountry() {
|
||||
return country;
|
||||
}
|
||||
public void setCountry(String country) {
|
||||
this.country = country;
|
||||
}
|
||||
public double getLatitude() {
|
||||
return latitude;
|
||||
}
|
||||
public void setLatitude(double latitude) {
|
||||
this.latitude = latitude;
|
||||
}
|
||||
public double getLongitude() {
|
||||
return longitude;
|
||||
}
|
||||
public void setLongitude(double longitude) {
|
||||
this.longitude = longitude;
|
||||
}
|
||||
public Integer getElevation() {
|
||||
return elevation;
|
||||
}
|
||||
public void setElevation(Integer elevation) {
|
||||
this.elevation = elevation;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,185 @@
|
|||
/**
|
||||
*
|
||||
* edu.ucar.unidata.ui.ncradarui.palette.HandlePrinting
|
||||
*
|
||||
* This java class performs the NCRADAR GUI text printing handling.
|
||||
* It should be able to be used by other project as well.
|
||||
* This code has been developed by the SIB for use in the AWIPS2 system.
|
||||
*
|
||||
* <pre>
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------- ------- -------- -----------
|
||||
* 1/21/2010 TBD Chin Chen Initial coding
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author Chin Chen
|
||||
* @version 1.0
|
||||
*/
|
||||
package edu.ucar.unidata.ui.ncradarui.palette;
|
||||
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.graphics.Color;
|
||||
import org.eclipse.swt.graphics.Font;
|
||||
import org.eclipse.swt.graphics.GC;
|
||||
import org.eclipse.swt.graphics.Point;
|
||||
import org.eclipse.swt.graphics.RGB;
|
||||
import org.eclipse.swt.graphics.Rectangle;
|
||||
import org.eclipse.swt.printing.PrintDialog;
|
||||
import org.eclipse.swt.printing.Printer;
|
||||
import org.eclipse.swt.printing.PrinterData;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
|
||||
public class HandlePrinting {
|
||||
private Printer printer;
|
||||
private StringBuffer wordBuffer;
|
||||
private int lineHeight = 0;
|
||||
private int tabWidth = 0;
|
||||
private int leftMargin, rightMargin, topMargin, bottomMargin;
|
||||
private int x, y;
|
||||
private int index, end;
|
||||
private String text;
|
||||
private GC gc;
|
||||
|
||||
private static HandlePrinting printHandle=null;
|
||||
public static HandlePrinting getPrintHandle() {
|
||||
if(printHandle==null)
|
||||
printHandle = new HandlePrinting();
|
||||
return printHandle;
|
||||
}
|
||||
public void handlePrint(String intext) {
|
||||
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
|
||||
text = intext;
|
||||
PrintDialog dialog = new PrintDialog(shell, SWT.NULL);
|
||||
PrinterData data = dialog.open();
|
||||
if (data == null) return;
|
||||
if (data.printToFile) {
|
||||
data.fileName = "print.out"; // you probably want to ask the user for a filename
|
||||
}
|
||||
|
||||
/* Do the printing in a background thread so that spooling does not freeze the UI. */
|
||||
printer = new Printer(data);
|
||||
Thread printingThread = new Thread("Printing") {
|
||||
public void run() {
|
||||
print(printer);
|
||||
printer.dispose();
|
||||
}
|
||||
};
|
||||
printingThread.start();
|
||||
}
|
||||
|
||||
private void print(Printer printer) {
|
||||
String tabs;
|
||||
Font printerFont;
|
||||
Color printerForegroundColor, printerBackgroundColor;
|
||||
|
||||
if (printer.startJob("Ncradar")) { // the string is the job name - shows up in the printer's job list
|
||||
Rectangle clientArea = printer.getClientArea();
|
||||
Rectangle trim = printer.computeTrim(0, 0, 0, 0);
|
||||
Point dpi = printer.getDPI();
|
||||
leftMargin = dpi.x + trim.x; // one inch from left side of paper
|
||||
rightMargin = clientArea.width - dpi.x + trim.x + trim.width; // one inch from right side of paper
|
||||
topMargin = dpi.y + trim.y; // one inch from top edge of paper
|
||||
bottomMargin = clientArea.height - dpi.y + trim.y + trim.height; // one inch from bottom edge of paper
|
||||
|
||||
/* Create a buffer for computing tab width. */
|
||||
int tabSize = 4; // is tab width a user setting in your UI?
|
||||
StringBuffer tabBuffer = new StringBuffer(tabSize);
|
||||
for (int i = 0; i < tabSize; i++) tabBuffer.append(' ');
|
||||
tabs = tabBuffer.toString();
|
||||
|
||||
/* Create printer GC, and create and set the printer font & foreground color. */
|
||||
gc = new GC(printer);
|
||||
printerFont = new Font(printer, "Courier", 8, SWT.NORMAL);
|
||||
gc.setFont(printerFont);
|
||||
tabWidth = gc.stringExtent(tabs).x;
|
||||
lineHeight = gc.getFontMetrics().getHeight();
|
||||
|
||||
RGB rgb = new RGB(0,0,0);//Black
|
||||
printerForegroundColor = new Color(printer, rgb);
|
||||
gc.setForeground(printerForegroundColor);
|
||||
rgb = new RGB(255,255,255);//white
|
||||
printerBackgroundColor = new Color(printer, rgb);
|
||||
gc.setBackground(printerBackgroundColor);
|
||||
|
||||
/* Print text to current gc using word wrap */
|
||||
printText();
|
||||
printer.endJob();
|
||||
|
||||
/* Cleanup graphics resources used in printing */
|
||||
printerFont.dispose();
|
||||
printerForegroundColor.dispose();
|
||||
printerBackgroundColor.dispose();
|
||||
gc.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
void printText() {
|
||||
String textToPrint;
|
||||
/* Get the text to print */
|
||||
textToPrint = text;
|
||||
printer.startPage();
|
||||
wordBuffer = new StringBuffer();
|
||||
x = leftMargin;
|
||||
y = topMargin;
|
||||
index = 0;
|
||||
end = textToPrint.length();
|
||||
while (index < end) {
|
||||
char c = textToPrint.charAt(index);
|
||||
index++;
|
||||
if (c != 0) {
|
||||
if (c == 0x0a || c == 0x0d) {
|
||||
if (c == 0x0d && index < end && textToPrint.charAt(index) == 0x0a) {
|
||||
index++; // if this is cr-lf, skip the lf
|
||||
}
|
||||
printWordBuffer();
|
||||
newline();
|
||||
} else {
|
||||
if (c != '\t') {
|
||||
wordBuffer.append(c);
|
||||
}
|
||||
if (Character.isWhitespace(c)) {
|
||||
printWordBuffer();
|
||||
if (c == '\t') {
|
||||
x += tabWidth;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (y + lineHeight <= bottomMargin) {
|
||||
printer.endPage();
|
||||
}
|
||||
}
|
||||
|
||||
void printWordBuffer() {
|
||||
if (wordBuffer.length() > 0) {
|
||||
String word = wordBuffer.toString();
|
||||
int wordWidth = gc.stringExtent(word).x;
|
||||
if (x + wordWidth > rightMargin) {
|
||||
/* word doesn't fit on current line, so wrap */
|
||||
newline();
|
||||
}
|
||||
gc.drawString(word, x, y, false);
|
||||
x += wordWidth;
|
||||
wordBuffer = new StringBuffer();
|
||||
}
|
||||
}
|
||||
|
||||
void newline() {
|
||||
x = leftMargin;
|
||||
y += lineHeight;
|
||||
if (y + lineHeight > bottomMargin) {
|
||||
printer.endPage();
|
||||
if (index + 1 < end) {
|
||||
y = topMargin;
|
||||
printer.startPage();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
* edu.ucar.unidata.ui.ncradarui.palette.NcradaruiPaletteAction
|
||||
*
|
||||
* 12/24/2009
|
||||
*
|
||||
* This code has been developed by the SIB for use in the AWIPS2 system.
|
||||
*
|
||||
* @author Chin Chen
|
||||
* @version 1.0
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 06/28/2011 T402 X. Guo Re-format NCRADAR view panel, check
|
||||
* the click action on nctext legend
|
||||
*/
|
||||
|
||||
package edu.ucar.unidata.ui.ncradarui.palette;
|
||||
|
||||
|
||||
import org.eclipse.core.commands.AbstractHandler;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import org.eclipse.core.commands.ExecutionException;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
import org.eclipse.ui.IViewPart;
|
||||
import org.eclipse.ui.IWorkbenchPage;
|
||||
|
||||
import edu.ucar.unidata.ui.ncradarui.rsc.NcradaruiResource;
|
||||
|
||||
|
||||
public class NcradaruiPaletteAction extends AbstractHandler {
|
||||
|
||||
@Override
|
||||
public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
||||
|
||||
/*
|
||||
* The viewID string is in the XML file for NCRADARUI extension point.
|
||||
*/
|
||||
|
||||
IWorkbenchPage wpage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
||||
|
||||
IViewPart vpart = wpage.findView( "edu.ucar.unidata.ui.NCRADARUI" );
|
||||
|
||||
try {
|
||||
|
||||
if ( vpart == null ){
|
||||
|
||||
vpart = wpage.showView( "edu.ucar.unidata.ui.NCRADARUI" );
|
||||
if (PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() != null) {
|
||||
NcradaruiResource ncradarMapResource = NcradaruiResource.getNcradaruiResource();
|
||||
ncradarMapResource.setPoints(null);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
if ( ! wpage.isPartVisible(vpart) ) vpart = wpage.showView( "edu.ucar.unidata.ui.NCRADARUI" );
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
|
||||
e.printStackTrace();
|
||||
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,322 @@
|
|||
/*
|
||||
* edu.ucar.unidata.ui.ncradarui.rsc.NcradaruiMouseHandler
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 07/18/2012 #751 S. Gurung Removed handleMouseDownMove(...) since this functionality
|
||||
* is handled by NcPanHandler.handleMouseDownMove(...).
|
||||
* 02/15/2012 #972 G. Hull NatlCntrsEditor
|
||||
*
|
||||
*
|
||||
*/
|
||||
package edu.ucar.unidata.ui.ncradarui.rsc;
|
||||
|
||||
import edu.ucar.unidata.ui.ncradarui.dbutil.NcradarDbQuery;
|
||||
import edu.ucar.unidata.ui.ncradarui.dbutil.NcradarStationInfo;
|
||||
import edu.ucar.unidata.ui.ncradarui.palette.NcradaruiPaletteWindow;
|
||||
import gov.noaa.nws.ncep.ui.pgen.tools.InputHandlerDefaultImpl;
|
||||
import gov.noaa.nws.ncep.viz.ui.display.NatlCntrsEditor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.geotools.referencing.GeodeticCalculator;
|
||||
|
||||
import com.raytheon.uf.viz.core.map.IMapDescriptor;
|
||||
import com.vividsolutions.jts.geom.Coordinate;
|
||||
|
||||
public class NcradaruiMouseHandler extends InputHandlerDefaultImpl {
|
||||
|
||||
private static int ASCII_CR_VAL = 13;
|
||||
|
||||
private static final double NcradaruiPointMinDistance = 45000;
|
||||
|
||||
private int prevMouseX, prevMouseY;
|
||||
|
||||
static int textDispIndex = 0;
|
||||
|
||||
/**
|
||||
* Index of the selected point.
|
||||
*/
|
||||
protected int ptIndex = 0;
|
||||
|
||||
private NcradarDbQuery query;// = NcradarDbQuery.getAccess();
|
||||
|
||||
/**
|
||||
* For single point element, the original location is needed for undo.
|
||||
*/
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.ui.input.IInputHandler#handleMouseDown(int, int,
|
||||
* int)
|
||||
*/
|
||||
@Override
|
||||
public boolean handleMouseDown(int x, int y, int button) {
|
||||
// System.out.println("mouse down");
|
||||
prevMouseX = x;
|
||||
prevMouseY = y;
|
||||
return false;
|
||||
}
|
||||
|
||||
public NcradaruiMouseHandler() {
|
||||
|
||||
query = NcradarDbQuery.getAccess();
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.ui.input.IInputHandler#handleMouseDownMove(int,
|
||||
* int, int) handle left button, so user be able to shift map while it is
|
||||
* down
|
||||
*/
|
||||
/*
|
||||
* @Override public boolean handleMouseDownMove(int x, int y, int button) {
|
||||
* if (button == 1 ){ NCMapEditor mapEditor =
|
||||
* NcradaruiResource.getMapEditor(); if(mapEditor!= null){ IDisplayPane[]
|
||||
* panes = ( mapEditor.arePanesGeoSynced() ? mapEditor.getDisplayPanes() :
|
||||
* mapEditor.getSelectedPanes() );
|
||||
*
|
||||
* for( IDisplayPane p : panes ) { p.shiftExtent(new double[] { x, y }, new
|
||||
* double[] { prevMouseX, prevMouseY }); }
|
||||
*
|
||||
* mapEditor.refresh(); }
|
||||
*
|
||||
* prevMouseX = x; prevMouseY = y;
|
||||
*
|
||||
* } return false;
|
||||
*
|
||||
* }
|
||||
*/
|
||||
private String removeCR(String curStr) {
|
||||
int i = ASCII_CR_VAL;
|
||||
char asciiCr = (char) i;
|
||||
String newStr = curStr.replace(asciiCr, ' ');
|
||||
return newStr;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.ui.input.IInputHandler#handleMouseUp(int, int, int)
|
||||
* handle right button, so user be able to pick stn and print text report
|
||||
*/
|
||||
@Override
|
||||
public boolean handleMouseUp(int x, int y, int button) {
|
||||
// System.out.println("NcradaruiMouseHandler mouse up");
|
||||
if (!NcradaruiResource.getNcradaruiResource().isEditable())
|
||||
return false;
|
||||
|
||||
// button 1 is left mouse button
|
||||
if (button == 1) {
|
||||
NatlCntrsEditor mapEditor = NcradaruiResource.getMapEditor();
|
||||
if (mapEditor != null) {
|
||||
// Check if mouse is in geographic extent
|
||||
Coordinate loc = mapEditor.translateClick(x, y);
|
||||
if (loc == null)
|
||||
return false;
|
||||
NcradaruiPaletteWindow ncradaruiPaletteWindow = NcradaruiPaletteWindow
|
||||
.getAccess();
|
||||
if (ncradaruiPaletteWindow != null) {
|
||||
// get the stn (point) list
|
||||
List<NcradarStationInfo> points = ncradaruiPaletteWindow
|
||||
.getPoints();
|
||||
if (points.isEmpty() == false) {
|
||||
|
||||
// get the stn close to loc "enough" and retrieve text
|
||||
// report for it
|
||||
NcradarStationInfo StnPt = getPtWithinMinDist(points,
|
||||
loc);
|
||||
|
||||
if (StnPt != null) {
|
||||
ncradaruiPaletteWindow.displayProduct(StnPt);
|
||||
/*
|
||||
* //add RED "X" marker(s) on picked stn
|
||||
* List<NcradarStationInfo> rtnStateStnLst = new
|
||||
* ArrayList<NcradarStationInfo> ();
|
||||
* if(ncradaruiPaletteWindow.isState() == true) {
|
||||
*
|
||||
* List<NcradarStationInfo> stateStnLst =
|
||||
* query.getStateStationInfoList
|
||||
* (ncradaruiPaletteWindow
|
||||
* .getCurrentProductName()+StnPt.getState());
|
||||
* //need to filter out those stns does not have
|
||||
* reports in DB now, use points list for reference
|
||||
* for (NcradarStationInfo stnInState : stateStnLst){
|
||||
* for (NcradarStationInfo stnHasRpt : points){
|
||||
* if(stnInState
|
||||
* .getStnid().equals(stnHasRpt.getStnid()) ==
|
||||
* true){ rtnStateStnLst.add(stnInState); break; } }
|
||||
* } } else{ rtnStateStnLst.add(StnPt); } Text text
|
||||
* = ncradaruiPaletteWindow.getText();
|
||||
* if(ncradaruiPaletteWindow.isReplaceText() ==
|
||||
* false){ //APPEND mode //List<NcradarStationInfo>
|
||||
* prevPickedStnLst =
|
||||
* ncradaruiPaletteWindow.getncradaruiResource
|
||||
* ().getPickedStnPt(); List<NcradarStationInfo>
|
||||
* prevPickedStnLst =
|
||||
* NcradaruiResource.getncradaruiResource
|
||||
* ().getPickedStnPt(); if(prevPickedStnLst.size() >
|
||||
* 0){ if(rtnStateStnLst.addAll(prevPickedStnLst) ==
|
||||
* false) { //System.out.println(
|
||||
* "handleMouseUp : add picked stn failed"); return
|
||||
* false; } } } else { //REPLACE mode
|
||||
* text.setText(""); }
|
||||
* //ncradaruiPaletteWindow.getncradaruiResource
|
||||
* ().setPickedStnPt(rtnStateStnLst);
|
||||
* NcradaruiResource
|
||||
* .getncradaruiResource().setPickedStnPt
|
||||
* (rtnStateStnLst); mapEditor.refresh();
|
||||
* ncradaruiModalTool.setModal(); // QUERY DB
|
||||
* now....Object[0] = Rawrecord text data, Object[1]
|
||||
* = issuesite List<List<Object[]>> rptLstList =
|
||||
* query
|
||||
* .getProductDataListList(ncradaruiPaletteWindow
|
||||
* .getCurrentProductName(), StnPt,
|
||||
* ncradaruiPaletteWindow.getTimeCovered(),
|
||||
* ncradaruiPaletteWindow.isState(),null);
|
||||
* if(rptLstList.isEmpty()){
|
||||
* if(ncradaruiPaletteWindow.isState())
|
||||
* text.append("--State " +StnPt.getState()+ "--" +
|
||||
* ncradaruiPaletteWindow.getCurrentProductName()+
|
||||
* " Report (Station picked "
|
||||
* +StnPt.getStnid()+")\n"); else
|
||||
* text.append("--Text-- " +
|
||||
* ": "+ncradaruiPaletteWindow
|
||||
* .getCurrentProductName()
|
||||
* +": Reporting Station: ("+StnPt.getStnid()+") "+
|
||||
* StnPt.getStnname()+"\n");
|
||||
* if(ncradaruiPaletteWindow
|
||||
* .getTimeCovered().getTimeRange() == 0)
|
||||
* text.append("Report unavailable in database.\n");
|
||||
* else text.append("Report unavailable within "+
|
||||
* ncradaruiPaletteWindow
|
||||
* .getTimeCovered().getTimeRange()+
|
||||
* " hour(s) range.\n");
|
||||
*
|
||||
* } else { String textToDisp; String textRawStr;
|
||||
* StringBuilder textStr;
|
||||
* if(ncradaruiPaletteWindow.isState()){ //SelectBy
|
||||
* State mode textStr = new StringBuilder("--State "
|
||||
* +StnPt.getState()+ "--" +
|
||||
* ncradaruiPaletteWindow.getCurrentProductName
|
||||
* ()+" Report\n");
|
||||
*
|
||||
* for(List<Object[]> lstObj : rptLstList){
|
||||
* textStr.append("--Station " +
|
||||
* (String)(lstObj.get(0))[1] +
|
||||
* "-- : "+ncradaruiPaletteWindow
|
||||
* .getCurrentProductName()+"\n"); textRawStr =
|
||||
* (String)(lstObj.get(0))[0]; // remove CR before
|
||||
* displaying textToDisp = removeCR(textRawStr);
|
||||
* textStr.append(textToDisp+"\n"); }
|
||||
*
|
||||
* //When put text string to Text display, use
|
||||
* "setText" but not "append" method, so, the text
|
||||
* will show from top
|
||||
* if(ncradaruiPaletteWindow.isReplaceText() ==
|
||||
* false){ // get current text string from Text
|
||||
* StringBuilder textStr1 = new
|
||||
* StringBuilder(text.getText());
|
||||
* textStr1.append(textStr.toString());
|
||||
* text.setText(textStr1.toString()); } else
|
||||
* text.setText(textStr.toString()); } else {
|
||||
* //SelectBy Station mode // "----" used as text
|
||||
* header delimiter String textHeader = "--Text-- "
|
||||
* +
|
||||
* ": "+ncradaruiPaletteWindow.getCurrentProductName
|
||||
* ()+": Reporting Station: ("+StnPt.getStnid()+") "
|
||||
* +StnPt.getStnname()+ "----"+"\n";
|
||||
* ncradaruiPaletteWindow
|
||||
* .setCurrentTextReports(rptLstList.get(0));
|
||||
*
|
||||
* int currentTextIndex = 0;
|
||||
* ncradaruiPaletteWindow.setCurrentTextIndex
|
||||
* (currentTextIndex); textRawStr =
|
||||
* (String)(rptLstList
|
||||
* .get(0).get(currentTextIndex))[0]; // remove CR
|
||||
* before displaying textToDisp =
|
||||
* removeCR(textRawStr); //When put text string to
|
||||
* Text display, use "setText" but not "append"
|
||||
* method, so, the text will show from top
|
||||
* if(ncradaruiPaletteWindow.isReplaceText() ==
|
||||
* false){ //Append mode: get current text string
|
||||
* from Text StringBuilder textStr1 = new
|
||||
* StringBuilder(text.getText());
|
||||
* textStr1.append(textHeader+textToDisp);
|
||||
* text.setText(textStr1.toString()); } else
|
||||
* //Replace mode
|
||||
* text.setText(textHeader+textToDisp);
|
||||
* if((rptLstList.get(0).size() > 1 ) &&
|
||||
* (ncradaruiPaletteWindow.isReplaceText() == true)){
|
||||
* //System.out.println("list size "+
|
||||
* rptLstList.get(0).size());
|
||||
* ncradaruiPaletteWindow.enablePrevBtn(true); } else
|
||||
* { ncradaruiPaletteWindow.enablePrevBtn(false); } }
|
||||
* }
|
||||
*/
|
||||
} else { // debug
|
||||
// System.out.println("Mouse point too far from stn");
|
||||
}
|
||||
} else { // debug
|
||||
// System.out.println("points is null");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the nearest point of an selected element to the input point
|
||||
*
|
||||
* @param el
|
||||
* element
|
||||
* @param pt
|
||||
* input point
|
||||
* @return
|
||||
*/
|
||||
protected NcradarStationInfo getPtWithinMinDist(
|
||||
List<NcradarStationInfo> points, Coordinate pt) {
|
||||
|
||||
NcradarStationInfo thePoint = null;
|
||||
double minDistance = NcradaruiPointMinDistance;
|
||||
GeodeticCalculator gc;
|
||||
NatlCntrsEditor mapEditor = NcradaruiResource.getMapEditor();
|
||||
if (mapEditor != null) {
|
||||
IMapDescriptor desc;
|
||||
desc = (IMapDescriptor) mapEditor.getActiveDisplayPane()
|
||||
.getRenderableDisplay().getDescriptor();
|
||||
|
||||
gc = new GeodeticCalculator(desc.getCRS());
|
||||
gc.setStartingGeographicPoint(pt.x, pt.y);
|
||||
// int textDispIndex = 1;//debug
|
||||
for (NcradarStationInfo point : points) {
|
||||
|
||||
gc.setDestinationGeographicPoint(point.getLongitude(),
|
||||
point.getLatitude());
|
||||
double dist;
|
||||
try {
|
||||
dist = gc.getOrthodromicDistance();
|
||||
// System.out.println("dist to point " + textDispIndex++ +
|
||||
// " is " + dist);
|
||||
if (dist < minDistance) {
|
||||
|
||||
minDistance = dist;
|
||||
thePoint = point;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
// e.printStackTrace();
|
||||
// System.out.println("getOrthodromicDistance exception happened!");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return thePoint;
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,505 @@
|
|||
/*
|
||||
* edu.ucar.unidata.ui.ncradarui.rsc.NcradaruiResource
|
||||
*
|
||||
* 1/7/2010
|
||||
*
|
||||
* This code has been developed by the SIB for use in the AWIPS2 system.
|
||||
*
|
||||
* @author Chin Chen
|
||||
* @version 1.0
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 06/28/2011 T402 X. Guo Re-format NCRADAR view panel, check
|
||||
* the click action on ncradar legend
|
||||
* 02/15/2012 T627 Archana Updated the call to addRbd() to accept
|
||||
* a NCMapEditor object as one of the arguments
|
||||
* Removed the call to setNcEditor()
|
||||
* 08/17/2012 T655 B. Hebbard Added paintProps as parameter to IDisplayable draw (2)
|
||||
* 07/10/2014 Chin Chen added NcText new Admin Message Group
|
||||
*/
|
||||
package edu.ucar.unidata.ui.ncradarui.rsc;
|
||||
|
||||
import edu.ucar.unidata.ui.ncradarui.dbutil.NcradarStationInfo;
|
||||
import edu.ucar.unidata.ui.ncradarui.palette.NcradaruiPaletteWindow;
|
||||
import gov.noaa.nws.ncep.ui.pgen.display.DisplayElementFactory;
|
||||
import gov.noaa.nws.ncep.ui.pgen.display.IDisplayable;
|
||||
import gov.noaa.nws.ncep.ui.pgen.elements.SymbolLocationSet;
|
||||
import gov.noaa.nws.ncep.viz.common.display.NcDisplayType;
|
||||
import gov.noaa.nws.ncep.viz.resources.manager.ResourceBndlLoader;
|
||||
import gov.noaa.nws.ncep.viz.ui.display.NatlCntrsEditor;
|
||||
import gov.noaa.nws.ncep.viz.ui.display.NcDisplayMngr;
|
||||
import gov.noaa.nws.ncep.viz.ui.display.NcEditorUtil;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.ui.IViewPart;
|
||||
import org.eclipse.ui.IWorkbenchPage;
|
||||
import org.eclipse.ui.IWorkbenchWindow;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
import org.opengis.referencing.crs.CoordinateReferenceSystem;
|
||||
|
||||
import com.raytheon.uf.viz.core.IGraphicsTarget;
|
||||
import com.raytheon.uf.viz.core.PixelExtent;
|
||||
import com.raytheon.uf.viz.core.VizApp;
|
||||
import com.raytheon.uf.viz.core.drawables.IFont;
|
||||
import com.raytheon.uf.viz.core.drawables.PaintProperties;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
import com.raytheon.uf.viz.core.map.IMapDescriptor;
|
||||
import com.raytheon.uf.viz.core.map.MapDescriptor;
|
||||
import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
|
||||
import com.raytheon.uf.viz.core.rsc.IInputHandler;
|
||||
import com.raytheon.uf.viz.core.rsc.LoadProperties;
|
||||
import com.raytheon.uf.viz.core.rsc.ResourceProperties;
|
||||
import com.raytheon.uf.viz.core.rsc.capabilities.EditableCapability;
|
||||
import com.raytheon.viz.ui.editor.AbstractEditor;
|
||||
import com.raytheon.viz.ui.input.EditableManager;
|
||||
import com.vividsolutions.jts.geom.Coordinate;
|
||||
|
||||
public class NcradaruiResource extends
|
||||
AbstractVizResource<NcradaruiResourceData, MapDescriptor> {
|
||||
|
||||
private static NcradaruiResourceData ncradaruiResourceData;
|
||||
|
||||
private static NcradaruiResource ncradaruiResource = null;
|
||||
|
||||
/** The set of symbols with similar attributes across many locations */
|
||||
private SymbolLocationSet symbolSet = null;
|
||||
|
||||
private SymbolLocationSet pickedSymbolSet = null;
|
||||
|
||||
private static NatlCntrsEditor mapEditor = null;
|
||||
|
||||
// private static int mapEditorNum=0;
|
||||
private static NcradaruiMouseHandler mouseHandler;
|
||||
|
||||
/*
|
||||
* public static NCMapEditor getOrCreateMapEditor() { if(mapEditor== null)
|
||||
* createMapEditor(); return mapEditor; }
|
||||
*/
|
||||
public static NatlCntrsEditor getMapEditor() {
|
||||
|
||||
return mapEditor;
|
||||
}
|
||||
|
||||
private List<NcradarStationInfo> points = new ArrayList<NcradarStationInfo>();
|
||||
|
||||
private List<NcradarStationInfo> pickedStnPt = new ArrayList<NcradarStationInfo>();
|
||||
|
||||
public List<NcradarStationInfo> getPickedStnPt() {
|
||||
return pickedStnPt;
|
||||
}
|
||||
|
||||
public void setPickedStnPt(List<NcradarStationInfo> pickedStnPt) {
|
||||
if (pickedStnPt == null)
|
||||
this.pickedStnPt.clear();
|
||||
else
|
||||
this.pickedStnPt = pickedStnPt;
|
||||
}
|
||||
|
||||
public List<NcradarStationInfo> getPoints() {
|
||||
return points;
|
||||
}
|
||||
|
||||
public void setPoints(List<NcradarStationInfo> points) {
|
||||
if (points == null)
|
||||
this.points.clear();
|
||||
else
|
||||
this.points = points;
|
||||
}
|
||||
|
||||
private static void createMapEditor() {
|
||||
// create an editor MapEditor
|
||||
if (mapEditor != null)
|
||||
return;
|
||||
|
||||
try {
|
||||
|
||||
// TODO: what if the active editor is not a Map Editor ?
|
||||
// should we find one, create one or prompt
|
||||
//
|
||||
AbstractEditor ed = NcDisplayMngr.getActiveNatlCntrsEditor();
|
||||
|
||||
if (NcEditorUtil.getNcDisplayType(ed) == NcDisplayType.NMAP_DISPLAY) {
|
||||
mapEditor = (NatlCntrsEditor) ed;
|
||||
} else {
|
||||
mapEditor = (NatlCntrsEditor) NcDisplayMngr
|
||||
.createNatlCntrsEditor(NcDisplayType.NMAP_DISPLAY,
|
||||
"Select NCRADAR Data");
|
||||
|
||||
// get this to set the editor to 'NCRADAR'
|
||||
ResourceBndlLoader rbdLoader = new ResourceBndlLoader("NCRADAR");
|
||||
rbdLoader.addDefaultRBD(NcDisplayType.NMAP_DISPLAY, mapEditor);
|
||||
VizApp.runSync(rbdLoader);
|
||||
}
|
||||
// register mouse handler
|
||||
mouseHandler = getMouseHandler();
|
||||
mapEditor.registerMouseHandler((IInputHandler) mouseHandler);
|
||||
// System.out.println("NcradaruiPaletteWindow create editor "+
|
||||
// mapEditor.toString());
|
||||
} catch (Exception ve) {
|
||||
System.out.println("Could not load initial editor: "
|
||||
+ ve.getMessage());
|
||||
ve.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static NcradaruiResource getNcradaruiResource() {
|
||||
if (ncradaruiResource == null) {
|
||||
if (mapEditor == null)
|
||||
createMapEditor();
|
||||
// ncradaruiResource = createNewResource(mapEditor);
|
||||
if (mapEditor != null) {
|
||||
IMapDescriptor desc = (IMapDescriptor) mapEditor
|
||||
.getActiveDisplayPane().getRenderableDisplay()
|
||||
.getDescriptor();
|
||||
try {
|
||||
if (ncradaruiResourceData == null)
|
||||
ncradaruiResourceData = new NcradaruiResourceData();
|
||||
ncradaruiResource = ncradaruiResourceData.construct(
|
||||
new LoadProperties(), desc);
|
||||
desc.getResourceList().add(ncradaruiResource);
|
||||
ncradaruiResource.init(mapEditor.getActiveDisplayPane()
|
||||
.getTarget());
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
return ncradaruiResource;
|
||||
}
|
||||
|
||||
/**
|
||||
* Default constructor
|
||||
*/
|
||||
protected NcradaruiResource(NcradaruiResourceData resourceData,
|
||||
LoadProperties loadProperties) {
|
||||
super(resourceData, loadProperties);
|
||||
getCapability(EditableCapability.class).setEditable(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when resource is disposed
|
||||
*
|
||||
* @see com.raytheon.viz.core.rsc.IVizResource#dispose()
|
||||
*/
|
||||
@Override
|
||||
public void disposeInternal() {
|
||||
// System.out.println("NcradaruiResource:disposeInternal");
|
||||
if (mapEditor != null) {
|
||||
mapEditor.unregisterMouseHandler(mouseHandler);
|
||||
mouseHandler = null;
|
||||
// close editor
|
||||
// if((PlatformUI.getWorkbench()!=
|
||||
// null)&&(PlatformUI.getWorkbench().getActiveWorkbenchWindow()!=
|
||||
// null)
|
||||
// &&
|
||||
// (PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()!=null)){
|
||||
|
||||
// System.out.println("NcradaruiResource:disposeInternal close map editor");
|
||||
// PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().closeEditor(mapEditor,
|
||||
// false);
|
||||
// }
|
||||
mapEditor = null;
|
||||
// mapEditorNum=0;
|
||||
}
|
||||
closeTextView();
|
||||
ncradaruiResource = null;
|
||||
ncradaruiResourceData = null;
|
||||
}
|
||||
|
||||
public static void registerMouseHandler() {
|
||||
mouseHandler = getMouseHandler();
|
||||
if (mapEditor != null && mouseHandler != null)
|
||||
mapEditor.registerMouseHandler((IInputHandler) mouseHandler);
|
||||
}
|
||||
|
||||
public static void unregisterMouseHandler() {
|
||||
mouseHandler = getMouseHandler();
|
||||
if (mapEditor != null && mouseHandler != null)
|
||||
mapEditor.unregisterMouseHandler((IInputHandler) mouseHandler);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void propertiesChanged(ResourceProperties updatedProps) {
|
||||
// System.out.println("NcradaruiResource:propertiesChanged");
|
||||
if (updatedProps.isVisible()) {
|
||||
reopenTextView();
|
||||
} else {
|
||||
hideTextView();
|
||||
}
|
||||
}
|
||||
|
||||
private void hideTextView() {
|
||||
IWorkbenchPage wpage = PlatformUI.getWorkbench()
|
||||
.getActiveWorkbenchWindow().getActivePage();
|
||||
// System.out.println("NcradaruiResource:hideTextView");
|
||||
IViewPart vpart = wpage.findView("edu.ucar.unidata.ui.NCRADARUI");
|
||||
if (wpage.isPartVisible(vpart)) {
|
||||
NcradaruiPaletteWindow paletteWin = NcradaruiPaletteWindow
|
||||
.getAccess();
|
||||
paletteWin.setEditorVisible(false);
|
||||
wpage.hideView(vpart);
|
||||
}
|
||||
}
|
||||
|
||||
private void closeTextView() {
|
||||
// System.out.println("NcradaruiResource:closeTextView");
|
||||
IWorkbenchWindow win = PlatformUI.getWorkbench()
|
||||
.getActiveWorkbenchWindow();
|
||||
if (win == null)
|
||||
return;
|
||||
IWorkbenchPage wpage = win.getActivePage();
|
||||
if (wpage != null) {
|
||||
IViewPart vpart = wpage.findView("edu.ucar.unidata.ui.NCRADARUI");
|
||||
wpage.hideView(vpart);
|
||||
}
|
||||
|
||||
NcDisplayMngr.setPanningMode();
|
||||
}
|
||||
|
||||
private void reopenTextView() {
|
||||
// System.out.println("NcradaruiResource:reopenTextView");
|
||||
IWorkbenchPage wpage = PlatformUI.getWorkbench()
|
||||
.getActiveWorkbenchWindow().getActivePage();
|
||||
|
||||
IViewPart vpart = wpage.findView("edu.ucar.unidata.ui.NCRADARUI");
|
||||
if (!wpage.isPartVisible(vpart)) {
|
||||
NcradaruiPaletteWindow paletteWin = NcradaruiPaletteWindow
|
||||
.getAccess();
|
||||
paletteWin.setEditorVisible(true);
|
||||
try {
|
||||
vpart = wpage.showView("edu.ucar.unidata.ui.NCRADARUI");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.viz.core.rsc.IVizResource#getCoordinateReferenceSystem()
|
||||
*/
|
||||
public CoordinateReferenceSystem getCoordinateReferenceSystem() {
|
||||
|
||||
if (descriptor == null)
|
||||
return null;
|
||||
|
||||
return descriptor.getCRS();
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.core.rsc.IVizResource#getName()
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
|
||||
return "NCRadar";
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.core.rsc.IVizResource#init(com.raytheon.viz.core.
|
||||
* IGraphicsTarget)
|
||||
*/
|
||||
@Override
|
||||
public void initInternal(IGraphicsTarget target) throws VizException {
|
||||
// System.out.println("NcradaruiResource:initInternal");
|
||||
EditableManager.makeEditable(this,
|
||||
getCapability(EditableCapability.class).isEditable());
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.viz.core.rsc.IVizResource#isApplicable(com.raytheon.viz.
|
||||
* core.PixelExtent)
|
||||
*/
|
||||
public boolean isApplicable(PixelExtent extent) {
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
private void generateSymbolForDrawing() {
|
||||
String type;
|
||||
float lineWidth = resourceData.getMarkerWidth();
|
||||
Boolean clear = false;
|
||||
;
|
||||
String category = new String("Marker");
|
||||
double sizeScale = resourceData.getMarkerSize();
|
||||
// NcradaruiPaletteWindow ncradaruiPaletteWindow =
|
||||
// NcradaruiPaletteWindow.getAccess();
|
||||
if (points.isEmpty() == true) {
|
||||
symbolSet = null;
|
||||
} else {
|
||||
// SymbolLocationSet constructor requires a positive-length array of
|
||||
// Coordinate
|
||||
Coordinate[] locations = new Coordinate[points.size()];
|
||||
|
||||
// System.out.println( "generateSymbolSet: size ="+ points.size());
|
||||
int i = 0;
|
||||
for (NcradarStationInfo p : points) {
|
||||
double lon, lat;
|
||||
lon = p.getLongitude();
|
||||
lat = p.getLatitude();
|
||||
locations[i++] = new Coordinate(lon, lat);
|
||||
|
||||
}
|
||||
|
||||
Color[] colors = new Color[] { new Color(
|
||||
resourceData.getColor().red, resourceData.getColor().green,
|
||||
resourceData.getColor().blue) };
|
||||
type = resourceData.getMarkerType().toString();
|
||||
// System.out.println( "generateSymbolSet done size ="+ i);
|
||||
symbolSet = new SymbolLocationSet(null, colors, lineWidth,
|
||||
sizeScale, clear, locations, category, type);
|
||||
|
||||
}
|
||||
if (pickedStnPt.isEmpty() == true) {
|
||||
pickedSymbolSet = null;
|
||||
} else {
|
||||
// SymbolLocationSet constructor requires a positive-length array of
|
||||
// Coordinate
|
||||
Coordinate[] locations = new Coordinate[pickedStnPt.size()];
|
||||
|
||||
// System.out.println( "generatePickedSymbolSet: size ="+
|
||||
// pickedStnPt.size());
|
||||
int i = 0;
|
||||
for (NcradarStationInfo p : pickedStnPt) {
|
||||
double lon, lat;
|
||||
lon = p.getLongitude();
|
||||
lat = p.getLatitude();
|
||||
locations[i++] = new Coordinate(lon, lat);
|
||||
}
|
||||
|
||||
Color[] colors = new Color[] { new Color(
|
||||
resourceData.getPkStncolor().red,
|
||||
resourceData.getPkStncolor().green,
|
||||
resourceData.getPkStncolor().blue) };
|
||||
type = resourceData.getPkStnmarkerType().toString();
|
||||
|
||||
pickedSymbolSet = new SymbolLocationSet(null, colors, lineWidth,
|
||||
sizeScale, clear, locations, category, type);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.viz.core.drawables.IRenderable#paint(com.raytheon.viz.core
|
||||
* .IGraphicsTarget, com.raytheon.viz.core.drawables.PaintProperties)
|
||||
*/
|
||||
@Override
|
||||
public void paintInternal(IGraphicsTarget target, PaintProperties paintProps)
|
||||
throws VizException {
|
||||
// System.out.println("paintInternal called!");
|
||||
IFont font = target.initializeFont("Monospace",
|
||||
(float) (12 * resourceData.getMarkerTextSize()
|
||||
.getSoftwareSize()), null);
|
||||
|
||||
generateSymbolForDrawing();
|
||||
|
||||
if (symbolSet != null) {
|
||||
|
||||
DisplayElementFactory df = new DisplayElementFactory(target,
|
||||
this.descriptor);
|
||||
ArrayList<IDisplayable> elements = df.createDisplayElements(
|
||||
symbolSet, paintProps);
|
||||
for (IDisplayable each : elements) {
|
||||
try {
|
||||
each.draw(target, paintProps);
|
||||
each.dispose();
|
||||
} catch (Exception e) {
|
||||
|
||||
e.printStackTrace();
|
||||
// System.out.println("paintInternal caught draw exception!");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (pickedSymbolSet != null) {
|
||||
|
||||
DisplayElementFactory df = new DisplayElementFactory(target,
|
||||
this.descriptor);
|
||||
ArrayList<IDisplayable> elements = df.createDisplayElements(
|
||||
pickedSymbolSet, paintProps);
|
||||
for (IDisplayable each : elements) {
|
||||
try {
|
||||
each.draw(target, paintProps);
|
||||
each.dispose();
|
||||
} catch (Exception e) {
|
||||
|
||||
// e.printStackTrace();
|
||||
// System.out.println("paintInternal caught draw exception on pickedSymbolSet!");
|
||||
}
|
||||
}
|
||||
}
|
||||
font.dispose();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.viz.core.rsc.capabilities.IProjectableResource#isProjectable
|
||||
* (org.opengis.referencing.crs.CoordinateReferenceSystem)
|
||||
*/
|
||||
public boolean isProjectable(CoordinateReferenceSystem mapData) {
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.viz.core.rsc.capabilities.IProjectableResource#project(org
|
||||
* .opengis.referencing.crs.CoordinateReferenceSystem)
|
||||
*/
|
||||
@Override
|
||||
public void project(CoordinateReferenceSystem mapData) throws VizException {
|
||||
// System.out.println("NcradaruiResource: project ");
|
||||
}
|
||||
|
||||
private static NcradaruiMouseHandler getMouseHandler() {
|
||||
|
||||
if (mouseHandler == null) {
|
||||
|
||||
mouseHandler = new NcradaruiMouseHandler();
|
||||
|
||||
}
|
||||
|
||||
return mouseHandler;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the resource is currently editable
|
||||
*
|
||||
* @return editable
|
||||
*/
|
||||
public boolean isEditable() {
|
||||
return getCapability(EditableCapability.class).isEditable();
|
||||
}
|
||||
|
||||
public void setEditable(boolean enable) {
|
||||
getCapability(EditableCapability.class).setEditable(enable);
|
||||
EditableManager.makeEditable(this,
|
||||
getCapability(EditableCapability.class).isEditable());
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,181 @@
|
|||
/*
|
||||
* edu.ucar.unidata.ui.ncradarui.rsc.NcradaruiResourceData
|
||||
*
|
||||
* 1/7/2010
|
||||
*
|
||||
* This code has been developed by the SIB for use in the AWIPS2 system.
|
||||
*
|
||||
* @author Chin Chen
|
||||
* @version 1.0
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 06/28/2011 T402 X. Guo Re-format NCRADAR view panel, check
|
||||
* the click action on nctext legend
|
||||
*/
|
||||
package edu.ucar.unidata.ui.ncradarui.rsc;
|
||||
|
||||
import gov.noaa.nws.ncep.viz.common.ui.Markers.MarkerState;
|
||||
import gov.noaa.nws.ncep.viz.common.ui.Markers.MarkerTextSize;
|
||||
import gov.noaa.nws.ncep.viz.common.ui.Markers.MarkerType;
|
||||
|
||||
import org.eclipse.swt.graphics.RGB;
|
||||
|
||||
import com.raytheon.uf.viz.core.drawables.IDescriptor;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
import com.raytheon.uf.viz.core.rsc.AbstractResourceData;
|
||||
import com.raytheon.uf.viz.core.rsc.LoadProperties;
|
||||
|
||||
public class NcradaruiResourceData extends AbstractResourceData {
|
||||
|
||||
private RGB color = new RGB(255, 0, 0);
|
||||
|
||||
private MarkerState markerState = MarkerState.MARKER_PLUS_TEXT;
|
||||
|
||||
private MarkerType markerType = MarkerType.DIAMOND;
|
||||
|
||||
private RGB pkStncolor = new RGB(0, 255, 0);
|
||||
|
||||
private MarkerState pkStnmarkerState = MarkerState.MARKER_PLUS_TEXT;
|
||||
|
||||
private MarkerType pkStnmarkerType = MarkerType.PLUS_SIGN;
|
||||
|
||||
private Float markerSize = 1.5f;
|
||||
|
||||
private Integer markerWidth = 2;
|
||||
|
||||
private MarkerTextSize markerTextSize = MarkerTextSize.MEDIUM;
|
||||
|
||||
private String mapName = "NCRADARUI";
|
||||
|
||||
public NcradaruiResourceData() {
|
||||
super();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.viz.core.rsc.AbstractResourceData#construct(com.raytheon
|
||||
* .uf.viz.core.comm.LoadProperties,
|
||||
* com.raytheon.uf.viz.core.drawables.IDescriptor)
|
||||
*/
|
||||
@Override
|
||||
public NcradaruiResource construct(LoadProperties loadProperties,
|
||||
IDescriptor descriptor) throws VizException {
|
||||
// TODO Auto-generated method stub
|
||||
return new NcradaruiResource(this, loadProperties);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.viz.core.rsc.AbstractResourceData#update(java.lang.Object
|
||||
* )
|
||||
*/
|
||||
@Override
|
||||
public void update(Object updateData) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null || !(obj instanceof NcradaruiResourceData))
|
||||
return false;
|
||||
NcradaruiResourceData rdata = (NcradaruiResourceData) obj;
|
||||
if (this.markerState.equals(rdata.getMarkerState())
|
||||
&& this.markerType.equals(rdata.getMarkerType())
|
||||
&& this.markerSize.equals(rdata.getMarkerSize())
|
||||
&& this.markerWidth.equals(rdata.getMarkerWidth())
|
||||
&& this.markerTextSize.equals(rdata.getMarkerTextSize())
|
||||
&& this.markerWidth.equals(rdata.getMarkerWidth())
|
||||
&& this.pkStnmarkerState.equals(rdata.getPkStnmarkerState())
|
||||
&& this.pkStnmarkerType.equals(rdata.getPkStnmarkerType())
|
||||
&& this.pkStncolor.equals(rdata.getPkStncolor())
|
||||
&& this.color.equals(rdata.getColor()))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public RGB getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public void setColor(RGB color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public MarkerState getMarkerState() {
|
||||
return markerState;
|
||||
}
|
||||
|
||||
public void setMarkerState(MarkerState markerState) {
|
||||
this.markerState = markerState;
|
||||
}
|
||||
|
||||
public MarkerType getMarkerType() {
|
||||
return markerType;
|
||||
}
|
||||
|
||||
public void setMarkerType(MarkerType markerType) {
|
||||
this.markerType = markerType;
|
||||
}
|
||||
|
||||
public Float getMarkerSize() {
|
||||
return markerSize;
|
||||
}
|
||||
|
||||
public void setMarkerSize(Float markerSize) {
|
||||
this.markerSize = markerSize;
|
||||
}
|
||||
|
||||
public Integer getMarkerWidth() {
|
||||
return markerWidth;
|
||||
}
|
||||
|
||||
public void setMarkerWidth(Integer markerWidth) {
|
||||
this.markerWidth = markerWidth;
|
||||
}
|
||||
|
||||
public MarkerTextSize getMarkerTextSize() {
|
||||
return markerTextSize;
|
||||
}
|
||||
|
||||
public void setMarkerTextSize(MarkerTextSize markerTextSize) {
|
||||
this.markerTextSize = markerTextSize;
|
||||
}
|
||||
|
||||
public String getMapName() {
|
||||
return mapName;
|
||||
}
|
||||
|
||||
public void setMapName(String mapName) {
|
||||
this.mapName = mapName;
|
||||
}
|
||||
|
||||
public RGB getPkStncolor() {
|
||||
return pkStncolor;
|
||||
}
|
||||
|
||||
public void setPkStncolor(RGB pkStncolor) {
|
||||
this.pkStncolor = pkStncolor;
|
||||
}
|
||||
|
||||
public MarkerState getPkStnmarkerState() {
|
||||
return pkStnmarkerState;
|
||||
}
|
||||
|
||||
public void setPkStnmarkerState(MarkerState pkStnmarkerState) {
|
||||
this.pkStnmarkerState = pkStnmarkerState;
|
||||
}
|
||||
|
||||
public MarkerType getPkStnmarkerType() {
|
||||
return pkStnmarkerType;
|
||||
}
|
||||
|
||||
public void setPkStnmarkerType(MarkerType plStnmarkerType) {
|
||||
this.pkStnmarkerType = plStnmarkerType;
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue