热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

模仿ArcGIS用Graphics重绘的直方图分级调节器

usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;

,

,
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ESRI.ArcGIS.Geodatabase;
using ESRI.ArcGIS.Controls;
using ESRI.ArcGIS.Carto;
namespace 专题图自动化系统
{
    public partial class ColorMap : Form
    {
        double max, min;
        AxMapControl axMapControl1;
        string FindField;
        public ColorMap(double _max,double _min,AxMapControl ax,string findField)
        {
            InitializeComponent();
            max = _max;
            min = _min;
            axMapControl1 = ax;
            FindField = findField;
        }
        IFeatureClass pFeatureClass;
        private void FindCity()
        {
            IFeatureLayer pFeatureLayer = axMapControl1.get_Layer(0) as IFeatureLayer;
            if (pFeatureLayer != null)
                pFeatureClass = pFeatureLayer.FeatureClass;
            int[] index = new int[2];//name字段+查询依据字段
            for (int i = 0; i             {
                if (i == 0)
                    index[i] = pFeatureClass.Fields.FindField("name");
                else
                    index[i] = pFeatureClass.Fields.FindField(FindField);
            }
            IFeatureCursor pFeatureCursor = pFeatureClass.Search(null,false);
            IFeature pFeature = pFeatureCursor.NextFeature();
            object [] value=new object[index.Length];
            while (pFeature != null)
            {
                for (int i = 0; i                 {
                    value[i] = pFeature.get_Value(index[i]);
                    if (i == 1)
                    {
                        double  a = Convert.ToDouble(value[1].ToString());
                        switch (searchCity.Length)
                        {
                            case 2: N1.Add(value[0].ToString()); break;
                            case 3: if (a <= searchCity[1]) { N1.Add(value[0].ToString());}
                            else{N2.Add(value[0].ToString());}break;
                            case 4: if (a <= searchCity[1]) { N1.Add(value[0].ToString()); }
                                if (a > searchCity[1] && a <= searchCity[2]) { N2.Add(value[0].ToString()); }
                                if (a > searchCity[2]) { N3.Add(value[0].ToString()); }break;
                            case 5: if (a <= searchCity[1]) { N1.Add(value[0].ToString()); }
                                if (a > searchCity[1] && a <= searchCity[2]) { N2.Add(value[0].ToString()); }
                                if (a > searchCity[2]&&a<=searchCity[3]) { N3.Add(value[0].ToString()); }
                                if(a>searchCity[3]){N4.Add(value[0].ToString());}break;
                            case 6: if (a <= searchCity[1]) { N1.Add(value[0].ToString()); }
                                if (a > searchCity[1] && a <= searchCity[2]) { N2.Add(value[0].ToString()); }
                                if (a > searchCity[2] && a <= searchCity[3]) { N3.Add(value[0].ToString()); }
                                if (a > searchCity[3]&&a<=searchCity[4]) { N4.Add(value[0].ToString()); }
                                if(a>searchCity[4]){N5.Add(value[0].ToString());}break;
                        }
                    }
                    
                }
                pFeature = pFeatureCursor.NextFeature();
            }
        }
        List N1 = new List();
        List N2 = new List();
        List N3 = new List();
        List N4 = new List();
        List N5 = new List();
        private void DrawCity()
        {
            Bitmap bt = new Bitmap(panel3.Width,panel3.Height);
            Graphics g = Graphics.FromImage(bt);
            Pen pen = new Pen(Color.Black,1);
            string []n1=new string[6];
            if (N1 != null)
            {
                foreach (string a in N1)
                {
                    n1[1] += a + ",";
                }
            }
            if (N2 != null)
            {
                foreach (string a in N2)
                {
                    n1[2] += a + ",";
                }
            }
            if (N3 != null)
            {
                foreach (string a in N3)
                {
                    n1[3] += a + ",";
                }
            }
            if (N4 != null)
            {
                foreach (string a in N4)
                {
                    n1[4] += a + ",";
                }
            }
            if (N5 != null)
            {
                foreach (string a in N5)
                {
                    n1[5] += a + ",";
                }
            }
            for (int i = 1; i <= n; i++)
            {
                g.DrawString("第" + i + "级:" +n1[i], new Font("黑体", 10), new SolidBrush(Color.Black), new PointF(20, 25 * i));
            }
            panel3.BackgroundImage = bt;
        }
        private void DrawString()
        {
            Bitmap bt = new Bitmap(panel2.Width,panel2.Height);
            Graphics g = Graphics.FromImage(bt);
            Pen pen = new Pen(Color.Black,1);
            double fromValue = min;
            searchCity[0] = fromValue;
            double toValue;
            for (int i = 1; i <= n; i++)
            {
                if (i == index)
                    toValue = min + (x2 - temp[1]) * k / flag;
                else
                    toValue=min + i * k;
                searchCity[i] = toValue;
                g.DrawString("第"+i+"级:"+fromValue+"万到"+toValue+"万",new Font("黑体",10),new SolidBrush(Color.Black),new PointF(20,25*i));
                fromValue=toValue;
            }
            panel2.BackgroundImage = bt;
        }
        double k;
        private void DrawZft()
        {
            Bitmap bt = new Bitmap(panel1.Width,panel1.Height);
            Graphics g = Graphics.FromImage(bt);
            Pen pen = new Pen(Color.White,1);
            g.DrawLine(pen,new Point(30,0),new Point(30,panel1.Height-30));
            g.DrawLine(pen,new Point(30,panel1.Height-30),new Point(panel1.Width-4,panel1.Height-30));
            k = (max - min) / n;
            for (int i = 1; i <= n+1; i++)
            {
                if (i == index)
                {
                    g.DrawString((min + (x2-temp[1]) * k/flag).ToString(), new Font("宋体", 9), new SolidBrush(Color.White), new PointF(x2 - 2, panel1.Height-30));
                    g.DrawLine(pen, new PointF(x2, panel1.Height-30), new PointF(x2, 0));
                }
                else
                {
                    g.DrawString((min + (i-1) * k).ToString(), new Font("宋体", 9), new SolidBrush(Color.White), new PointF(temp[i] - 8, panel1.Height-30));
                    g.DrawLine(pen, new PointF(temp[i], panel1.Height-30), new PointF(temp[i], 0));
                }
            }
            panel1.BackgroundImage = bt;
        }
        int n=0;
        float[] temp;
        int flag;
        double []searchCity;
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            n = int.Parse(comboBox1.SelectedItem.ToString());
            temp = new float[n + 2];
            searchCity=new double[n+1];
            flag = (panel1.Width - 4) / (n + 1);
            for (int i = 1; i <= n+1; i++)
            {
                temp[i] = flag * i;
            }
            if (N1 != null)
                N1.Clear();
            if (N2 != null)
                N2.Clear();
            if (N3 != null)
                N3.Clear();
            if (N4 != null)
                N4.Clear();
            if (N5 != null)
                N5.Clear();
            DrawZft();
            DrawString();
            FindCity();
            DrawCity();
        }
        int index=0;
        int x1, x2, x3;
        private void panel1_MouseDown(object sender, MouseEventArgs e)
        {
            x1 = e.X;
            for (int i = 1; i             {
                if (Math.Abs(x1 - temp[i]) < 3)
                {
                    index = i;
                }
            }
        }
        private void panel1_MouseMove(object sender, MouseEventArgs e)
        {
            x2=e.X;
            if (index != 0)
            {
                if (N1 != null)
                    N1.Clear();
                if (N2 != null)
                    N2.Clear();
                if (N3 != null)
                    N3.Clear();
                if (N4 != null)
                    N4.Clear();
                if (N5 != null)
                    N5.Clear();
                DrawZft();
                DrawString();
                FindCity();
                DrawCity();
            }
        }
        private void panel1_MouseUp(object sender, MouseEventArgs e)
        {
            x3 = e.X;
            temp[index] = x3;
            DrawZft();
            index = 0;
        }
    }
}

模仿ArcGIS用Graphics重绘的直方图分级调节器,,

模仿ArcGIS用Graphics重绘的直方图分级调节器


推荐阅读
  • 本文介绍如何使用 NSTimer 实现倒计时功能,详细讲解了初始化方法、参数配置以及具体实现步骤。通过示例代码展示如何创建和管理定时器,确保在指定时间间隔内执行特定任务。 ... [详细]
  • 本文介绍如何使用阿里云的fastjson库解析包含时间戳、IP地址和参数等信息的JSON格式文本,并进行数据处理和保存。 ... [详细]
  • 本文介绍了在Windows环境下使用pydoc工具的方法,并详细解释了如何通过命令行和浏览器查看Python内置函数的文档。此外,还提供了关于raw_input和open函数的具体用法和功能说明。 ... [详细]
  • 高效解决应用崩溃问题!友盟新版错误分析工具全面升级
    友盟推出的最新版错误分析工具,专为移动开发者设计,提供强大的Crash收集与分析功能。该工具能够实时监控App运行状态,快速发现并修复错误,显著提升应用的稳定性和用户体验。 ... [详细]
  • andr ... [详细]
  • 解决JAX-WS动态客户端工厂弃用问题并迁移到XFire
    在处理Java项目中的JAR包冲突时,我们遇到了JaxWsDynamicClientFactory被弃用的问题,并成功将其迁移到org.codehaus.xfire.client。本文详细介绍了这一过程及解决方案。 ... [详细]
  • VPX611是北京青翼科技推出的一款采用6U VPX架构的高性能数据存储板。该板卡搭载两片Xilinx Kintex-7系列FPGA作为主控单元,内置RAID控制器,支持多达8个mSATA盘,最大存储容量可达8TB,持续写入带宽高达3.2GB/s。 ... [详细]
  • 并发编程:深入理解设计原理与优化
    本文探讨了并发编程中的关键设计原则,特别是Java内存模型(JMM)的happens-before规则及其对多线程编程的影响。文章详细介绍了DCL双重检查锁定模式的问题及解决方案,并总结了不同处理器和内存模型之间的关系,旨在为程序员提供更深入的理解和最佳实践。 ... [详细]
  • MATLAB实现n条线段交点计算
    本文介绍了一种通过逐对比较线段来求解交点的简单算法。此外,还提到了一种基于排序的方法,但该方法较为复杂,尚未完全理解。文中详细描述了如何根据线段端点求交点,并判断交点是否在线段上。 ... [详细]
  • 以下实例展示了locals( ... [详细]
  • 本文介绍如何使用Python进行文本处理,包括分词和生成词云图。通过整合多个文本文件、去除停用词并生成词云图,展示文本数据的可视化分析方法。 ... [详细]
  • 本文介绍如何在Linux服务器之间使用SCP命令进行文件传输。SCP(Secure Copy Protocol)是一种基于SSH的安全文件传输协议,支持从远程机器复制文件到本地服务器或反之。示例包括从192.168.45.147复制tomcat目录到本地/home路径。 ... [详细]
  • 本文详细介绍了如何在CentOS 7操作系统上安装和配置Grafana,包括必要的依赖项安装、插件管理以及服务启动等步骤。 ... [详细]
  • 本文详细介绍了Git分布式版本控制系统中远程仓库的概念和操作方法。通过具体案例,帮助读者更好地理解和掌握如何高效管理代码库。 ... [详细]
  • 本文介绍了两种方法,用于检测 Android 设备是否开启了开发者模式。第一种方法通过检查 USB 调试模式的状态,第二种方法则直接判断开发者选项是否启用。这两种方法均提供了代码示例和详细解释。 ... [详细]
author-avatar
鲁弗斯ll
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有