① 如何用java寫出泰森多邊形演算法代碼我找了好多資源表示無解呀
packagecom.wangyin.seapay.loginkgo;
importjava.util.HashMap;
importjava.util.Map;
importjava.util.logging.Level;
importjava.util.logging.Logger;
importorg.geotools.data.simple.SimpleFeatureCollection;
importorg.geotools.process.Process;
importorg.geotools.process.ProcessException;
importorg.geotools.process.ProcessFactory;
importorg.geotools.process.spatialstatistics.core.Params;
importorg.geotools.process.spatialstatistics.enumeration.ThiessenAttributeMode;
importorg.geotools.process.spatialstatistics.operations.ThiessenPolygonOperation;
importorg.geotools.text.Text;
importorg.geotools.util.NullProgressListener;
importorg.geotools.util.logging.Logging;
importorg.opengis.util.ProgressListener;
importcom.vividsolutions.jts.geom.Geometry;
/**
*Createdbyhanxiaofeion2018/4/11.
*/
{
=Logging.getLogger(ThiessenPolygonProcess.class);
privatebooleanstarted=false;
publicThiessenPolygonProcess(ProcessFactoryfactory){
super(factory);
}
(){
returnfactory;
}
(,
,GeometryclipArea,ProgressListenermonitor){
Map<String,Object>map=newHashMap<String,Object>();
map.put(ThiessenPolygonProcessFactory.inputFeatures.key,inputFeatures);
map.put(ThiessenPolygonProcessFactory.attributes.key,attributes);
map.put(ThiessenPolygonProcessFactory.clipArea.key,clipArea);
Processprocess=newThiessenPolygonProcess(null);
Map<String,Object>resultMap;
try{
resultMap=process.execute(map,monitor);
return(SimpleFeatureCollection)resultMap
.get(ThiessenPolygonProcessFactory.RESULT.key);
}catch(ProcessExceptione){
LOGGER.log(Level.FINER,e.getMessage(),e);
}
returnnull;
}
@Override
publicMap<String,Object>execute(Map<String,Object>input,ProgressListenermonitor)
throwsProcessException{
if(started)
thrownewIllegalStateException("Processcanonlyberunonce");
started=true;
if(monitor==null)
monitor=newNullProgressListener();
try{
monitor.started();
monitor.setTask(Text.text("Grabbingarguments"));
monitor.progress(10.0f);
=(SimpleFeatureCollection)Params.getValue(
input,ThiessenPolygonProcessFactory.inputFeatures,null);
if(inputFeatures==null){
thrownewNullPointerException("");
}
=(ThiessenAttributeMode)Params.getValue(input,
ThiessenPolygonProcessFactory.attributes,
ThiessenPolygonProcessFactory.attributes.sample);
GeometryclipArea=(Geometry)Params.getValue(input,
ThiessenPolygonProcessFactory.clipArea,null);
monitor.setTask(Text.text("Processing..."));
monitor.progress(25.0f);
if(monitor.isCanceled()){
returnnull;//userhascanceledthisoperation
}
//startprocess
=newThiessenPolygonOperation();
operation.setAttributeMode(attributes);
if(clipArea!=null){
operation.setClipArea(clipArea);
}
=operation.execute(inputFeatures);
//endprocess
monitor.setTask(Text.text("Encodingresult"));
monitor.progress(90.0f);
Map<String,Object>resultMap=newHashMap<String,Object>();
resultMap.put(ThiessenPolygonProcessFactory.RESULT.key,resultFc);
monitor.complete();//sameas100.0f
returnresultMap;
}catch(Exceptioneek){
monitor.exceptionOccurred(eek);
returnnull;
}finally{
monitor.dispose();
}
}
}
② eclipse顏色設置
剛剛安裝Eclipse,結果背景色是白色的.個人比較喜歡背景色暗一點的,最好的全黑的,就上網網路了一下如何調顏色的問題.
第一種:我們可以直接換背景色以及其他顏色(譬如:注釋,關鍵字等)
window->Preferences 搜索 color->java->Editor->Syntax Coloring->java 然後就可以下面進行顏色的變換了.(有一點不好的是,換完之後好多顏色都不協調,還要換好多.而且再往回去換,要很麻煩,所以新手還是不建議自己換)
第二種: 使用著色器
1 找到eclipse左上角的Help
2 help->Eclipse Marketplace->find中搜索"Theme"
3 搜索完成後 找到 "Eclipse Color Theme" 點擊Install
4 在彈出的對話框中,點擊「Next」,接下來選擇「I accept the terms of the license agreement」,然後點擊「Finish」等待安裝
5 .安裝過程Eclipse會彈出安全警告「Security Warning」,直接點擊「OK」繼續
6.在安裝完後Eclipse會彈出重啟軟體提示「Software Updates」,直接點擊「Yes」重啟Eclipse
7.當Eclipse重啟完成後,就可以使用著色插件(Eclipse Color Theme)了
如何使用
window->Preferences 搜索 color theme 選擇自己喜歡的->Apply->ok,就行了
(
Eclipse Marketplace是個插件應用商店,很實用的一個功能。
打開 eclipse,help--Eclipse Marketplace Client就能找到
有的eclipse中沒有這個功能就需手動添加Eclipse Marketplace Client。
help--install new software
地址欄輸入:http://download.eclipse.org/mpc/indigo/ (這里使用Eclipse indigo版本,根據你的Eclipse版本替換URL中的indigo字元串,Eclipse中各個版本的名稱見下面)
輸入回車後,選擇General Purpose Tools - Marketplace Client, 然後一路Next或Agree
下載完成後,重啟eclipse,選擇help--Eclipse Marketplace Client,就可以搜索插件下載安裝了。