📄 elevationtask.java
字号:
if (result.getUnit() == 1) {
// FEET
m_elevationFeet = String.valueOf(result.getElevation());
m_elevationMeters = String.valueOf(result.getElevation() * 0.3048);
m_taskInfo.elevationCalculatedState();
} else if (result.getUnit() == 2) {
// METERS
m_elevationMeters = String.valueOf(result.getElevation());
m_elevationFeet = String.valueOf(result.getElevation() * 3.2808399);
m_taskInfo.elevationCalculatedState();
} else {
m_elevationMeters = "";
m_elevationFeet = "";
m_taskInfo.elevationNotFoundErrorState();
}
LOG.debug("Elevation Feet: " + m_elevationFeet);
LOG.debug("Elevation Meters: " + m_elevationMeters);
} catch (ServicesException e) {
LOG.warn("", e);
m_taskInfo.generalErrorState(getErrorCode(e.getFaultString()));
} catch (RemoteException e) {
LOG.warn("", e);
m_taskInfo.generalErrorState("REMOTE_EXCEPTION");
} finally {
reRender();
LOG.debug("Exiting method");
}
}
/**
* Retrieves the error code from the error message. The format
* of the error message is "code:message".
*
* @param message Error Message.
* @return Error Code, or <code>null</code> if the message
* is <code>null</code>.
*/
private String getErrorCode(String message) {
if (message == null) {
return null;
}
String[] comps = message.split(":");
String code = comps[1];
code = code.trim();
return code;
}
/**
* Indicates if the elevation calculation has been executed.
* If this method is invoked after
* {@link #calculateElevation(TaskEvent)}
* and it did not generate an error then <code>true</code>
* will be returned. Otherwise, <code>false</code> will be
* returned.
*
* @return Execution indicator.
*/
public boolean getExecuted() {
return m_executed;
}
/**
* Returns the error message if the {@link #calculateElevation(TaskEvent)}
* method generated an error during invocation.
*
* @return Error Message.
*/
public String getError() {
return m_error;
}
/**
* Sets the error message that was generated by the {@link #calculateElevation(TaskEvent)}
* invocation.
*
* @param str Error Message.
*/
void setError(String str) {
m_error = str;
}
/**
* Indicates if an error occurred during the {@link #calculateElevation(TaskEvent)}
* invocation.
*
* @return Error Indicator
*/
public boolean getErrorOccurred() {
return m_errorOccurred;
}
/**
* Sets the indicator that an error has occurred.
*
* @param b Desired indicator.
*/
void setErrorOccurred(boolean b) {
m_errorOccurred = b;
}
/**
* Clears the current elevation results and associated marker (if drawn)
* as well as any error messages. This effectively puts the UI
* in the start state.
*
* @param event
*/
public void clear(TaskEvent event) {
if (m_showMarker) {
for (GraphicElement g : m_graphics) {
event.getWebContext().getWebGraphics().removeGraphics(g);
}
event.getWebContext().refresh();
}
setElevationFeet("");
setElevationMeters("");
m_taskInfo.startState();
reRender();
}
/**
* Returns the elevation result in feet. This method will
* return <code>null</code> or a blank string if invoked
* before the {@link #calculateElevation(TaskEvent)} method.
*
* @return Elevation result in feet.
*/
public String getElevationFeet() {
return m_elevationFeet;
}
/**
* Allows the Task Info bean or this object to set the
* elevation result in feet.
*
* @param feet Elevation result in feet.
*/
void setElevationFeet(String feet) {
m_elevationFeet = feet;
}
/**
* Returns the elevation result in meters. This method will
* return <code>null</code> or a blank string if invoked
* before the {@link #calculateElevation(TaskEvent)} method.
*
* @return Elevation result in meters.
*/
public String getElevationMeters() {
return m_elevationMeters;
}
/**
* Allows the Task Info bean or this object to set the
* elevation result in meters.
*
* @param feet Elevation result in meters.
*/
void setElevationMeters(String meters) {
m_elevationMeters = meters;
}
/**
* Returns the X-coordinate of the location entered or
* picked by the user. This method will return null
* or blank if invoked prior to {@link #calculateElevation(TaskEvent)}
*
* @return X-coordinate
*/
public String getX() {
return m_x;
}
/**
* Returns the Y-coordinate of the location entered or
* picked by the user. This method will return null
* or blank if invoked prior to {@link #calculateElevation(TaskEvent)}
*
* @return Y-coordinate
*/
public String getY() {
return m_y;
}
/**
* Sets the X-coordinate of the location. The X-coordinate
* could have been typed into a text box by the user or chosen
* by the user clicking a point on the map.
*
* @param x X-coordinate.
*/
public void setX(String x) {
this.m_x = x;
}
/**
* Sets the Y-coordinate of the location. The Y-coordinate
* could have been typed into a text box by the user or chosen
* by the user clicking a point on the map.
*
* @param x Y-coordinate.
*/
public void setY(String y) {
this.m_y = y;
}
/**
* Indicates if a location on the map has been chosen.
*
* @return Location Picked indicator.
*/
public boolean getLocationPicked() {
return m_locationPicked;
}
/**
* Indicates that a marker should be shown for the location
* that the user entered or chosen.
*
* @return Show Marker Indicator
*/
public boolean getShowMarker() {
return m_showMarker;
}
/**
* Sets the Show Marker indicator. This is set by a user
* checking the Show Marker check box in the UI.
*
* @param showMarker Show Marker indicator.
*/
public void setShowMarker(boolean showMarker) {
this.m_showMarker = showMarker;
}
/**
* Returns the <code>TaskInfo</code> bean for this
* task.
*
* @return Task Info bean
*/
public SimpleTaskInfo getTaskInfo() {
return m_taskInfo;
}
/*
* (non-Javadoc)
* @see com.esri.adf.web.data.WebContextInitialize#destroy()
*/
public void destroy() {
}
/*
* (non-Javadoc)
* @see com.esri.adf.web.data.WebContextInitialize#init(com.esri.adf.web.data.WebContext)
*/
public void init(WebContext context) {
}
/**
* This method has no implementation.
*/
public void setTaskInfo(TaskInfo taskInfo) {
}
/**
* Returns the proxy object to the Elevation Calculator
* Web Service.
*
* @return Web Service proxy object.
*/
public ElevationCalculator getElevationCalculator() {
return this.m_elevCalc;
}
/**
* Sets the proxy object for the Elevation Calculator web
* service.
*
* @param calc Web Service proxy object.
* @throws NullPointerException Thrown if the <code>calc</code>
* argument is <code>null</code>.
*/
public void setElevationCalculator(ElevationCalculator calc) {
if (calc == null) {
throw new NullPointerException();
}
this.m_elevCalc = calc;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -