1、在jbuilderX中建立mapxtreme java471应用学习笔记在jbuilderX中建立mapxtreme java4.7应用学习笔记(bj_meng)2004-05-151、 配置环境a) 安装mapXtreme java 4.7,最好使用自带的jdkb) 配置jbx环境i. 引入mapXtreme java的lib:进入jbx的tools的configure libraries中。ii. 选择new,Define a new library specification iii. Name为mapinfotreme,Location为User Home,然后单击Add按钮,把Pro
2、gram FilesMapInfoMapXtreme-4.7.0lib目录下的client、common和server中的jar全部加入,记住一定要选择文件。iv. 单击OK完成引入 c) 配置jbx的jdk:进入jbx的tools的configure jdks中,选择new:d) 指向mapinfo自带的jdk目录e) 设置结果如下图:f) 其他2、 在jbx中创建一个project,命名为barChant。3、 新建一个classBarChartLocalRend,放在package barchart中。4、 进入barChart的properties中。5、 在Paths的Require
3、d Libraries中将上面创建的mapinfotreme加入工程中。6、 BarChartLocalRend的代码如下(mapinfo官方提供的):package barchart;import java.lang.*;import java.util.*;import java.util.Hashtable;import java.awt.*;import com.mapinfo.mapj.*;import com.mapinfo.graphics.Rendition;import com.mapinfo.graphics.RenditionImpl;import java.util.A
4、rrayList;import com.mapinfo.dp.analysis.AnalysisTableDescHelper;import com.mapinfo.legend.AnalysisLayerChartLegend;import javax.swing.*;import com.mapinfo.mapj.BarChartProperties;import com.mapinfo.beans.vmapj.VisualMapJ;import com.mapinfo.beans.tools.MapToolBar;public class BarChartLocalRend extend
5、s JFrame public FeatureLayer world;public ArrayList cols;public VisualMapJ myMap;public Hashtable ht;BarChartLocalRend()tryMapToolBar myMapToolBar = new MapToolBar();myMap = new VisualMapJ();myMap.getMapJ().loadMapDefinition(c:program filesmapinfoMapXtreme-4.7.0examplesserverdatalocalworld.mdf);worl
6、d = (FeatureLayer)myMap.getMapJ().getLayers().get(World Countries);/columns in world layer to analyzecols = new ArrayList(3);cols.add(Pop_0_14);cols.add(Pop_1994);cols.add(Pop_65Plus);/create AnalysisTableDescHelper from world layersAnalysisTableDescHelper atdh = new AnalysisTableDescHelper(world.ge
7、tTableDescHelper(),cols, AnalysisLayerType.SIDE_BY_SIDE_BAR_CHART);AnalysisLayer analysis = (AnalysisLayer)myMap.getMapJ().getLayers().insertLayer(world.getDataProviderRef(),atdh, 0, World Population Analysis);BarChartProperties bcp = (BarChartProperties)analysis.getAnalysisProperties();Rendition re
8、d = new RenditionImpl();red.setValue(Rendition.FILL, Color.red);Rendition yellow = new RenditionImpl();yellow.setValue(Rendition.FILL, Color.yellow);Rendition orange = new RenditionImpl();orange.setValue(Rendition.FILL, Color.orange);ht = new Hashtable();ht.put(Pop_0_14, new Integer(0);ht.put(Pop_19
9、94, new Integer(1);ht.put(Pop_65Plus, new Integer(2);AnalysisLayerChartLegend legend = new AnalysisLayerChartLegend(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, B
10、orderLayout.NORTH);this.getContentPane().add(myMap, BorderLayout.CENTER);this.getContentPane().add(legend, BorderLayout.EAST);this.setVisible(true);this.show();catch (Exception e)System.out.println(Error);e.printStackTrace();public static void main (String args)BarChartLocalRend bclr = new BarChartL
11、ocalRend(); /end Class BarChartLocalRend7、 在make project前,还需要设置8、 进入Configurations中,单击new9、 如下图设置即可:10、 现在project就可以编译运行了。11、 今天先写到这里,祝大家好运。2004-05-17网上流行的mapdemo范例,是个非常不错的学习例子,可惜不能正常运行。经调试,总于找到了原因。只要修改C:Program FilesMapInfoMapXtreme-4.7.0Tomcat-4.1webappsmapdemoWEB-INF目录下的web.xml文件即可。以下是要修改的部分(红色部分
12、): filetype gst 濡傛灉鏁版嵁婧愪负file锛屾寚瀹氬湴鍥惧畾涔夌被鍨嬫槸gst杩樻槸mdf锛岄粯璁负mdf mdfpath 濡傛灉鏁版嵁婧愪负file锛屽湴鍥惧畾涔夌被鍨嬩负mdf锛屾寚瀹氬湴鍥惧畾涔夋枃浠惰矾寰?/description gstpath c:program filesmapinfoMapXtreme-4.7.0Tomcat-4.1webappsmapdemomaps 濡傛灉鏁版嵁婧愪负file锛屽湴鍥惧畾涔夌被鍨嬩负gst锛屾寚瀹歵ab鏂囦欢瀛樻斁璺 緞 mapdef china.gst 璁惧畾鍦板浘瀹氫箟鍚嶇锛屽 鏋滄槸gst鏂囦欢鎴杕df鏂囦欢锛屽繀椤诲姞涓婃墿灞曞悕 gst鏂囦欢蹇呴鍐欑粷瀵硅矾寰勪笖gst涓巘ab鏂囦欢蹇呴鍦悓涓鐩 綍涓嬪苟涓攇st涓嶆彁渚涘 鏁版嵁搴撳浘灞傜殑鏀 寔 文件类型采用gst,并指向gst所在的目录。至于是否需要在jbx中重新编译则没有考证,不过本人使用的class已经在jbx中编译过。之前本人已经把class反编译(居于开源的思想,应该不算侵权),需要加入j2ee.jar包,同时附上。乱码没有解决,请那位仁兄靓妹帮忙搞定。效果图如下:
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1