在jbuilderX中建立mapxtreme java471应用学习笔记.docx
《在jbuilderX中建立mapxtreme java471应用学习笔记.docx》由会员分享,可在线阅读,更多相关《在jbuilderX中建立mapxtreme java471应用学习笔记.docx(11页珍藏版)》请在冰豆网上搜索。
在jbuilderX中建立mapxtremejava471应用学习笔记
在jbuilderX中建立mapxtremejava4.7应用学习笔记
(bj_meng)
2004-05-15
1、配置环境
a)安装mapXtremejava4.7,最好使用自带的jdk
b)配置jbx环境
i.引入mapXtremejava的lib:
进入jbx的tools的configurelibraries中。
ii.选择new,Defineanewlibraryspecification
iii.Name为mapinfotreme,Location为UserHome,然后单击Add按钮,把\ProgramFiles\MapInfo\MapXtreme-4.7.0\lib目录下的client、common和server中的jar全部加入,记住一定要选择文件。
iv.单击OK完成引入
c)配置jbx的jdk:
进入jbx的tools的configurejdks中,选择new:
d)指向mapinfo自带的jdk目录
e)设置结果如下图:
f)其他
2、在jbx中创建一个project,命名为barChant。
3、新建一个class-》BarChartLocalRend,放在packagebarchart中。
4、进入barChart的properties中。
5、在Paths的RequiredLibraries中将上面创建的mapinfotreme加入工程中。
6、BarChartLocalRend的代码如下(mapinfo官方提供的):
packagebarchart;
importjava.lang.*;
importjava.util.*;
importjava.util.Hashtable;
importjava.awt.*;
importcom.mapinfo.mapj.*;
importcom.mapinfo.graphics.Rendition;
importcom.mapinfo.graphics.RenditionImpl;
importjava.util.ArrayList;
importcom.mapinfo.dp.analysis.AnalysisTableDescHelper;
importcom.mapinfo.legend.AnalysisLayerChartLegend;
importjavax.swing.*;
importcom.mapinfo.mapj.BarChartProperties;
importcom.mapinfo.beans.vmapj.VisualMapJ;
importcom.mapinfo.beans.tools.MapToolBar;
publicclassBarChartLocalRendextendsJFrame{
publicFeatureLayerworld;
publicArrayListcols;
publicVisualMapJmyMap;
publicHashtableht;
BarChartLocalRend()
{
try{
MapToolBarmyMapToolBar=newMapToolBar();
myMap=newVisualMapJ();
myMap.getMapJ().loadMapDefinition("c:
\\programfiles\\mapinfo\\MapXtreme-4.7.0\\examples\\server\\data\\local\\world.mdf");
world=(FeatureLayer)myMap.getMapJ().getLayers().get("WorldCountries");
//columnsinworldlayertoanalyze
cols=newArrayList(3);
cols.add("Pop_0_14");
cols.add("Pop_1994");
cols.add("Pop_65Plus");
//createAnalysisTableDescHelperfromworldlayer's
AnalysisTableDescHelperatdh=newAnalysisTableDescHelper(world.getTableDescHelper(),
cols,AnalysisLayerType.SIDE_BY_SIDE_BAR_CHART);
AnalysisLayeranalysis=(AnalysisLayer)myMap.getMapJ().getLayers().insertLayer(world.getDataProviderRef(),
atdh,0,"WorldPopulationAnalysis");
BarChartPropertiesbcp=(BarChartProperties)analysis.getAnalysisProperties();
Renditionred=newRenditionImpl();
red.setValue(Rendition.FILL,Color.red);
Renditionyellow=newRenditionImpl();
yellow.setValue(Rendition.FILL,Color.yellow);
Renditionorange=newRenditionImpl();
orange.setValue(Rendition.FILL,Color.orange);
ht=newHashtable();
ht.put("Pop_0_14",newInteger(0));
ht.put("Pop_1994",newInteger
(1));
ht.put("Pop_65Plus",newInteger
(2));
AnalysisLayerChartLegendlegend=newAnalysisLayerChartLegend(bcp,ht);
legend.setRenditionAt(red,0);
legend.setRenditionAt(yellow,1);
legend.setRenditionAt(orange,2);
bcp.setWidth(15);
this.setSize(800,500);
this.getContentPane().add(myMapToolBar,BorderLayout.NORTH);
this.getContentPane().add(myMap,BorderLayout.CENTER);
this.getContentPane().add(legend,BorderLayout.EAST);
this.setVisible(true);
this.show();
}
catch(Exceptione)
{
System.out.println("Error");
e.printStackTrace();
}
}
publicstaticvoidmain(Stringargs[])
{
BarChartLocalRendbclr=newBarChartLocalRend();
}
}//endClassBarChartLocalRend
7、在makeproject前,还需要设置
8、进入Configurations中,单击new
9、如下图设置即可:
10、现在project就可以编译运行了。
11、今天先写到这里,祝大家好运。
2004-05-17
网上流行的mapdemo范例,是个非常不错的学习例子,可惜不能正常运行。
经调试,总于找到了原因。
只要修改C:
\ProgramFiles\MapInfo\MapXtreme-4.7.0\Tomcat-4.1\webapps\mapdemo\WEB-INF目录下的web.xml文件即可。
以下是要修改的部分(红色部分):
filetype
gst
濡傛灉鏁版嵁婧愪负file锛屾寚瀹氬湴鍥惧畾涔夌被鍨嬫槸gst杩樻槸mdf锛岄粯璁や负mdf
mdfpath
濡傛灉鏁版嵁婧愪负file锛屽湴鍥惧畾涔夌被鍨嬩负mdf锛屾寚瀹氬湴鍥惧畾涔夋枃浠惰矾寰?
/description>
gstpath
c:
\\programfiles\\mapinfo\\MapXtreme-4.7.0\\Tomcat-4.1\\webapps\\mapdemo\\maps\\
濡傛灉鏁版嵁婧愪负file锛屽湴鍥惧畾涔夌被鍨嬩负gst锛屾寚瀹歵ab鏂囦欢瀛樻斁璺緞
mapdef
china.gst
璁惧畾鍦板浘瀹氫箟鍚嶇О锛屽鏋滄槸gst鏂囦欢鎴杕df鏂囦欢锛屽繀椤诲姞涓婃墿灞曞悕
gst鏂囦欢蹇呴』鍐欑粷瀵硅矾寰勪笖gst涓巘ab鏂囦欢蹇呴』鍦ㄥ悓涓€鐩綍涓嬪苟涓攇st涓嶆彁渚涘鏁版嵁搴撳浘灞傜殑鏀寔
文件类型采用gst,并指向gst所在的目录。
至于是否需要在jbx中重新编译则没有考证,不过本人使用的class已经在jbx中编译过。
之前本人已经把class反编译(居于开源的思想,应该不算侵权),需要加入j2ee.jar包,同时附上。
乱码没有解决,请那位仁兄靓妹帮忙搞定。
效果图如下: