📄 displaysettingstask.java
字号:
*/
public void handleContextMenuEvent(TocEvent event) {
LOG.debug("Context menu event received");
requestTaskRender();
TocNode node = event.getNode();
TocNodeContent content = node.getContent();
if (content != null && content instanceof TocResourceContent) {
GISResource res = ((TocResourceContent)content).getResource();
m_res = res;
initValuesFromResource();
if (m_mgr != null) {
m_mgr.setOpen(this);
}
}
}
/**
* Sets the ID of this Task. The ID must match the ID given to the
* Task in the Task tag within the JSP page. The ID is needed so
* that the Context Menu Item Task Manager knows which Task Window
* to open.
*
* @param id ID of Task, cannot be <code>null</code>.
* @throws NullPointerException Thrown if the <code>id</code>
* argument is <code>null</code>.
*/
public void setTaskId (String id) {
if (id == null) {
throw new NullPointerException ();
}
m_taskId = id;
}
/**
* Sets the desired brightness of the map for the given GIS Resource.
*
* @param brightness Brightness value (-127 to 127)
*/
public void setBrightness(int brightness) {
m_brightness = brightness;
}
/**
* Sets the desired contrast of the map for the given GIS Resource.
*
* @param contrast Contrast value (1 to 10).
*/
public void setContrast(int contrast) {
m_contrast = contrast;
}
/**
* Sets the desired Tint Red offset of the map for the given GIS
* Resource.
*
* @param tintRed Tint Red offset value (-127 to 127).
*/
public void setTintRed(int tintRed) {
m_tintRed = tintRed;
}
/**
* Sets the desired Tint Green offset of the map for the given GIS
* Resource.
*
* @param tintRed Tint Green offset value (-127 to 127).
*/
public void setTintGreen(int tintGreen) {
m_tintGreen = tintGreen;
}
/**
* Sets the desired Tint Blue offset of the map for the given GIS
* Resource.
*
* @param tintRed Tint Blue offset value (-127 to 127).
*/
public void setTintBlue(int tintBlue) {
m_tintBlue = tintBlue;
}
/**
* Returns the desired brightness value of the map for the given
* GIS Resource.
*
* @return Brightness value (-127 to 127).
*/
public int getBrightness() {
return m_brightness;
}
/**
* Returns the desired contrast value of the map for the given
* GIS Resource.
*
* @return Contrast value (1 to 10).
*/
public int getContrast() {
return m_contrast;
}
/**
* Returns the desired Tint Red offset value of the map for the given
* GIS Resource.
*
* @return Tint Red offset value (-127 to 127).
*/
public int getTintRed() {
return m_tintRed;
}
/**
* Returns the desired Tint Green offset value of the map for the given
* GIS Resource.
*
* @return Tint Green offset value (-127 to 127).
*/
public int getTintGreen() {
return m_tintGreen;
}
/**
* Returns the desired Tint Blue offset value of the map for the given
* GIS Resource.
*
* @return Tint Blue offset value (-127 to 127).
*/
public int getTintBlue() {
return m_tintBlue;
}
/**
* Applies the selected values for Brightness, Contrast, Tint, and
* Transparency to the Map for the GIS Resource. The values will
* be set within the {@link MapFunctionality} and the Map will
* be redrawn.
*
* @param event Contains Task Event information.
*/
public void apply (TaskEvent event) {
MapFunctionality func = (MapFunctionality) m_res.getFunctionality("map");
func.setTransparency(this.m_transparency);
if (func instanceof IBCTMapFunctionality) {
IBCTMapFunctionality bctFunc = (IBCTMapFunctionality) func;
byte brightness = (byte) (m_brightness);
byte contrast = (byte) (m_contrast);
byte tintRed = (byte) (m_tintRed);
byte tintGreen = (byte) (m_tintGreen);
byte tintBlue = (byte) (m_tintBlue);
bctFunc.setBrightness(brightness);
bctFunc.setContrast(contrast);
TintParameters tint = new TintParameters();
tint.setBlueOffset(tintBlue);
tint.setGreenOffset(tintGreen);
tint.setRedOffset(tintRed);
bctFunc.setTint(tint);
}
renderResourceMessage("displaySettingsTask.ui.msg.saveSuccess", messageType.SUCCESS);
event.getWebContext().refresh();
this.requestTaskRender();
}
/**
* Returns the desired Transparency value for the Map for the GIS
* Resource.
*
* @return Transparency value (0.0 to 1.0).
*/
public double getTransparency() {
return m_transparency;
}
/**
* Sets the desired Transparency value for the Map for the GIS Resource.
*
* @param transparency Transparency value (0.0 to 1.0).
*/
public void setTransparency(double transparency) {
m_transparency = transparency;
}
/**
* Returns the collection of predefined Transparency values
* for the drop-down. The collection contains a set of mappings
* between actual value and display value.
*
* @return Predefined Transparency values.
*/
public Map<Double,String> getTransparencyValues () {
return m_transparencyValues;
}
/**
* Sets the collection of predefined Transparency values
* for the drop-down. The collection should contain a set
* of mappings between actual value and display value.
*
* @param values Predefined Transparency values.
*/
public void setTransparencyValues (Map<Double,String> values) {
if (values != null) {
m_transparencyValues.clear();
m_transparencyValues.putAll(values);
}
}
/**
* Indicates if Transparency should be altered for this GIS
* Resource. Transparency cannot be altered if the GIS Resource
* is the last enabled map functionality in the Map, meaning if
* its the bottom layer within the Map.
*
* @return Flag indicating if Transparency can be altered.
*
* @see WebMap#isLastEnabledMapFunctionality(MapFunctionality)
*/
/*public boolean getModifyTransparencyFlag () {
if (this._context == null) {
return false;
}
if (this.m_res == null) {
return false;
}
WebMap map = this._context.getWebMap();
if (map == null) {
return false;
}
MapFunctionality mFunc = (MapFunctionality) m_res.getFunctionality(MapFunctionality.FUNCTIONALITY_NAME);
if (mFunc == null) {
return false;
}
return !map.isLastEnabledMapFunctionality(mFunc);
}*/
/**
* Initializes the values of the Brightness, Contrast, Tint, and
* Transparency from the Map Functionality. A closest match to the
* predefined values will be found if the actual values are not an
* exact match to the values in the Map Functionality.
*/
private void initValuesFromResource() {
WebMap map = this._context.getWebMap();
MapFunctionality mapFunc = (MapFunctionality) m_res.getFunctionality(MapFunctionality.FUNCTIONALITY_NAME);
m_transparency = closestOptionValue(mapFunc.getTransparency(), m_transparencyValues.keySet());
if (map != null) {
m_taskInfo.getTransparencyParam().setDisabled(map.isLastEnabledMapFunctionality(mapFunc));
} else {
m_taskInfo.getTransparencyParam().setDisabled(false);
}
if (mapFunc instanceof IBCTMapFunctionality) {
IBCTMapFunctionality bctMapFunc = (IBCTMapFunctionality) mapFunc;
m_brightness = closestOptionValue(bctMapFunc.getBrightness(), this.m_brightnessValues.keySet());
m_contrast = closestOptionValue(bctMapFunc.getContrast(), this.m_contrastValues.keySet());
if (bctMapFunc.getTint() != null) {
m_tintRed = closestOptionValue(bctMapFunc.getTint().getRedOffset(), this.m_tintRedValues.keySet());
m_tintGreen = closestOptionValue(bctMapFunc.getTint().getGreenOffset(), this.m_tintGreenValues.keySet());
m_tintBlue = closestOptionValue(bctMapFunc.getTint().getBlueOffset(), this.m_tintBlueValues.keySet());
}
}
}
/**
* Finds the closest option value from a predefined set of values based
* on a real value.
*
* @param realValue Real value.
* @param optionSet Set of predefined values.
* @return Closest match between the predefined value and the real value.
*/
private int closestOptionValue (int realValue, Set<Byte> optionSet) {
Byte[] options = new Byte[optionSet.size()];
options = optionSet.toArray(options);
Arrays.sort(options);
if (realValue < options[0]) {
return options[0];
}
if (realValue > options[options.length - 1]) {
return options[options.length - 1];
}
for (int i = 0; i < options.length - 1; i++) {
if (realValue >= options[i] && realValue < options[i + 1]) {
return options[i];
}
}
return realValue;
}
/**
* Finds the closest option value from a predefined set of values based
* on a real value.
*
* @param realValue Real value.
* @param optionSet Set of predefined values.
* @return Closest match between the predefined value and the real value.
*/
private double closestOptionValue (double realValue, Set<Double> optionSet) {
Double[] options = new Double[optionSet.size()];
options = optionSet.toArray(options);
Arrays.sort(options);
if (realValue < options[0]) {
return options[0];
}
if (realValue > options[options.length - 1]) {
return options[options.length - 1];
}
for (int i = 0; i < options.length - 1; i++) {
if (realValue >= options[i] && realValue < options[i + 1]) {
return options[i];
}
}
return realValue;
}
/*
* (non-Javadoc)
* @see com.esri.solutions.jitk.common.contextmenus.IResourceContextMenuItem#shouldDisplay(com.esri.adf.web.data.GISResource)
*/
public boolean shouldDisplay(GISResource resource) {
if (resource instanceof GraphicsResource) {
return false;
}
if (resource instanceof WFSMapResource) {
return false;
}
TileFunctionality tFunc = (TileFunctionality) resource.getFunctionality(
TileFunctionality.FUNCTIONALITY_NAME);
if (tFunc != null && tFunc.isTilingAvailable()) {
return false;
}
return true;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -