removed dbquery and resource from ncradar

This commit is contained in:
AWIPS User 2015-04-17 09:32:31 -06:00
parent 705e4f95a9
commit 3a3f36c4fa
6 changed files with 0 additions and 2273 deletions

View file

@ -1,15 +0,0 @@
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; }
}

View file

@ -1,65 +0,0 @@
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;
}
}

View file

@ -1,322 +0,0 @@
/*
* 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;
}
}

View file

@ -1,505 +0,0 @@
/*
* 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());
}
}

View file

@ -1,181 +0,0 @@
/*
* 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;
}
}