package barchant;
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.List;
import com.mapinfo.dp.ColumnStatistics;
import com.mapinfo.dp.util.Bucketer;
import com.mapinfo.dp.util.LinearRenditionSpreader;
//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.*;
import com.mapinfo.theme.RangedTheme;
import com.mapinfo.theme.ThemeList;
import com.mapinfo.dp.Attribute;
/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2004</p>
* <p>Company: </p>
* @author not attributable
* @version 1.0
*/
public class RangedThemeTest extends JFrame {
public FeatureLayer lyr;//Feature对象用来访问地图对象
// public ArrayList cols;
public VisualMapJ myMap;//可管理地图集的各种状态,并向服务器转发客户请求
//public Hashtable ht;
public RangedThemeTest() {
try{
//指上端的工具栏,工具栏默认包含几种功能,如果想添加其它功能可以看下面代码
MapToolBar myMapToolBar=new MapToolBar();
//在工具栏上添加新功能
RadiusSelectionMapTool radTool =new RadiusSelectionMapTool();
//创建地图
myMap=new VisualMapJ();
myMap.getMapJ().loadMapDefinition("d:\\program files\\MapInfo\\MapXtreme-4.7.0\\examples\\server\\data\\local\\world.mdf");
lyr = (FeatureLayer)myMap.getMapJ().getLayers().getLayer("World Countries");
String colName = "POP_1994";
/*以下示例是用颜色渐变自动显示,所以只定义了两个Rendition
//Rendition类是用来控制图元显示,例如是否填充等
Rendition yellow=new RenditionImpl();//RenditionImpl对象用来描述一个图元,标签等怎样显示
Rendition red=new RenditionImpl();
ColumnStatistics colStats = lyr.fetchColumnStatistics(colName);
// Set number of breaks for data,即定义了5个范围
int numBreaks=5;
// Compute the distribution of data with 5 breaks and Equal Ranges
//Bucketer类是用于计算在RangedTheme中的断点,这些断点被用于构建主题
List rBreaks = (List) Bucketer.computeDistribution(numBreaks,colStats,Bucketer.DISTRIBUTION_TYPE_EQUAL_RANGES);
// Set up a red and a yellow rendition and then spread the colors
yellow.setValue(Rendition.FILL, Color.yellow);
yellow.setValue(Rendition.STROKE_WIDTH, 2);
red.setValue(Rendition.FILL, Color.red);
red.setValue(Rendition.STROKE_WIDTH, 4);
List rends = (List) LinearRenditionSpreader.spread(numBreaks, yellow, red);
// Create Theme object
*/
/*下面示例采用手动方式逐个定义*/
Vector rBreaks=new Vector();
//建立3个范围
rBreaks.addElement(new Attribute(1));
rBreaks.addElement(new Attribute(17661468));
rBreaks.addElement(new Attribute(1136429638));
//为这3个范围分别创建Rendition
Rendition red=new RenditionImpl();
Rendition gray=new RenditionImpl();
Rendition green=new RenditionImpl();
red.setValue(Rendition.FILL, Color.red);
red.setValue(Rendition.STROKE_WIDTH, 2);
gray.setValue(Rendition.FILL, Color.yellow);
gray.setValue(Rendition.STROKE_WIDTH, 2);
green.setValue(Rendition.FILL, Color.green);
green.setValue(Rendition.STROKE_WIDTH, 2);
Vector rends=new Vector();
rends.addElement(red);
rends.addElement(gray);
rends.addElement(green);
RangedTheme rTheme = new RangedTheme(colName, rBreaks, rends, "States by Pop_1994");
// Get ThemeList class object
ThemeList tList=lyr.getThemeList();
// Add theme to Layers themeList
tList.add(rTheme);
//myMap.getMapJ().getLayers().elementAt(1).getThemeList().add(rTheme);
//工具栏放上端
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[]){
RangedThemeTest bclr=new RangedThemeTest();
}
}
MapXtreme代码
需积分: 0 135 浏览量
2008-06-14
09:53:00
上传
评论
收藏 14KB RAR 举报
yinggao888
- 粉丝: 0
- 资源: 6
最新资源
- Alibaba SpringCloud集成Nacos、openFeign实现负载均衡-源码
- 用户研究系列之Persona介绍(用户画像)
- Image_1715110604427.jpg
- mYzh..trashed-1716951334-.jpg
- Alibaba SpringCloud集成nacos实现配置中心
- 那些好的不像话的心流体验
- 基于pytorch的卷积神经网络识别是否为奥特曼的项目python源码+文档说明+数据集(课程设计)
- 基于卷积神经网络的图像风格迁移python源码+文档说明+界面图片(课程设计)
- 河北地质大学毕业设计-基于卷积神经网络的垃圾分类研究代码python源码+文档说明
- 菜鸟网络运营模式的浅析
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
评论0