① 如何用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,就可以搜索插件下载安装了。