我给大家一个详细的解决办法,肯定可以! 在jbuilderX中建立mapxtreme java4.7应用学习笔记 (bj_meng) 2004-05-15 1、 配置环境 a) 安装mapXtreme java 4.7,最好使用自带的jdk b) 配置jbx环境 i. 引入mapXtreme java的lib:进入jbx的tools的configure libraries中。 ii. 选择new,Define a new library specification iii. Name为mapinfotreme,Location为User Home,然后单击Add按钮,把\Program Files\MapInfo\MapXtreme-4.7.0\lib目录下的client、common和server中的jar全部加入,记住一定要选择文件。 iv. 单击OK完成引入 c) 配置jbx的jdk:进入jbx的tools的configure jdks中,选择new: d) 指向mapinfo自带的jdk目录 e) 设置结果如下图: f) 其他 2、 在jbx中创建一个project,命名为barChant。 3、 新建一个class-》BarChartLocalRend,放在package barchart中。 4、 进入barChart的properties中。 5、 在Paths的Required 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.ArrayList; 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 extends JFrame { public FeatureLayer world; public ArrayList cols; public VisualMapJ myMap; public Hashtable ht; BarChartLocalRend() { try{ MapToolBar myMapToolBar = new MapToolBar(); myMap = new VisualMapJ(); myMap.getMapJ().loadMapDefinition("c:\\program files\\mapinfo\\MapXtreme-4.7.0\\examples\\server\\data\\local\\world.mdf"); world = (FeatureLayer)myMap.getMapJ().getLayers().get("World Countries"); //columns in world layer to analyze cols = new ArrayList(3); cols.add("Pop_0_14"); cols.add("Pop_1994"); cols.add("Pop_65Plus"); //create AnalysisTableDescHelper from world layer's AnalysisTableDescHelper atdh = new AnalysisTableDescHelper(world.getTableDescHelper(), 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 red = 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_1994", 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, BorderLayout.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 BarChartLocalRend(); } } //end Class BarChartLocalRend 7、 在make project前,还需要设置 8、 进入Configurations中,单击new 9、 如下图设置即可: 10、 现在project就可以编译运行了。 11、 今天先写到这里,祝大家好运。
|