爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 6369|回复: 18

我准备做个绘图服务器,碰到些问题。请王老师指导下

[复制链接]

新浪微博达人勋

发表于 2016-8-20 18:29:51 | 显示全部楼层 |阅读模式

登录后查看更多精彩内容~

您需要 登录 才可以下载或查看,没有帐号?立即注册 新浪微博登陆

x
我准备做个绘图服务器。
一、设计思路。
1、应用程序或者WEB服务器提供源数据并向绘图服务器发送参数(参数包括数据源路径、色标设置等)。
2、绘图服务器根据参数绘图并将图片路径返回。
3、应用程序或者WEB服务器根据返回的路劲读取图片。
二、目前开发的进度
1、已经开发完成的WEB服务器
WEB服务器项目.png
这个服务器的功能是调取CIMISS和其他数据源,展示有图表、天地图和百度地图。设计是想增加王老师开发的METEOINFO中的绘图功能。数据源的问题是由这个WEB服务器来负责。他将会向绘图服务器发送参数,并将根据返回的图片路径来展示图片。
2、通过消息模式来传递参数的绘图服务器
绘图服务器项目.png
上图是绘图服务器中的绘图例子代码。

消息模式传递参数的格式 是 IP:端口/项目名/方法名?参数1=XXX&参数2=XXX&参数3=XXX
例子: http://localhost:9091/rest/drawdemo?path=16080120.000 我使用这个参数来测试上图展示的绘图例子
绘图服务器项目1.png
绘图服务器项目2.png
这个是用浏览器模拟WEB服务器向绘图服务器发送参数。这个参数其实就是本机的文件名,文件路径我在方法中写好了。为了测试简单,我没写IP什么。但是这个应该不影响效果,具体使用的时候参数可根据需求设定。只要参数和绘图服务器内方法对应就可以。
我这个列子实现的就是WEB服务器向绘图服务器发送参数,绘图服务器根据参数绘图并返回图片路径,WEB服务器根据返回的图片路径展示图片。
三、目前碰到的问题
相信老师和一些经常绘图的同事已经发现了,我这个绘图没有色标!其实是一个问题,我在用老师的列子的时候,JFROME不能创建。程序一创建JFROME就报错。但是没有JFROME就不能设置色标。我自身编程水平有限,而老师给的帮助文档很有难度啊!!
绘图服务器项目3.png
因此在这里求助老师,想解决如何在mapLayout1中直接添加色标,而不是借助JFRAME。我做的这个WEB绘图服务器想通过上述构想将老师METEOINFO软件的功能在互联网中重现。后面肯定还会遇到各种各样的问题。往各位老师、同事指导。我QQ635216038。

再次补充我现在面临的问题。老师给的例子中在初始化过程会创建一个JFRAME组件。但是我这个WEB项目一创建JFRAME组件就报错。而没有JFRAME组件,添加色标和添加标题那个命令就会报错。代码如下:
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jToolBar2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jSplitPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 748, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 418, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jToolBar2, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
        );
        pack();
老师的类本身就是继承了JFRAME,我自己写的WEB项目需要创建一个JFRAME。其实本质一样。getContentPane()和pack()都是JFRAME的方法,我改为FRAME对象,但是一样报错!!!
在我的WEB项目中没有创建JFRAME,报错的地方变为:
this.addTitle();
LayoutGraphic aTitle = mapLayout1.getTexts().get(0);
        aTitle.setLabelText("雨量图");
        //Add or change the legend in layout
        LayoutLegend aLegend;
        if (mapLayout1.getLegends().size() > 0) {
            aLegend = mapLayout1.getLegends().get(0);
        } else {
            aLegend = mapLayout1.addLegend(650, 100);
        }
        aLegend.setLegendStyle(LegendStyles.Bar_Vertical);
        aLegend.setLegendLayer(aLayer);
        if (this.jTabbedPane1.getSelectedIndex() == 1) {
            mapLayout1.paintGraphics();
        }
就是添加标题和添加色标报错。
我以前只是普通的预报员,目前在气象局做行政工作,编程水平有限。我目前解决办法就是把报错的代码都删掉了。往老师能够指导,色斑图没有色标就没什么用了。
还有个解决办法就是用其他绘图软件重新画色标,然后在和METEOINFO画的色斑图合并。但是我觉得那样做更麻烦,更可能会在以后开发的过程中由于兼容和各种原因造成新的问题。所以我还是想通过学习老师的METEOINFO中的各个类的使用来解决。
上个帖子由于对METEOINFO还不了解,可能问的问题太含糊,对不起老师和各位同事了。这个帖子可能还有些让大家不明白的地方,请大家留言。我会及时回复。万分感谢



密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2016-8-21 12:34:15 | 显示全部楼层
“就是添加标题和添加色标报错。”,报的什么错误信息?
密码修改失败请联系微信:mofangbao
回复 支持 1 反对 0

使用道具 举报

新浪微博达人勋

 楼主| 发表于 2016-8-20 18:34:17 | 显示全部楼层
补充说明:我设计这个绘图服务器是提供对外绘图服务的,可以看做是一个在线API。而不是仅仅支持我自己的WEB项目。我的想法是任何应用程序或者WEB服务器只要遵循参数规则,都可以使用这个绘图服务器。这样就可以让这个绘图服务器中的方法最大化的重用,而且也可以吸引更多绘图使用者的已经和能力,完善这个绘图服务器。
密码修改失败请联系微信:mofangbao

新浪微博达人勋

0
早起挑战累计收入
发表于 2016-8-20 21:00:45 | 显示全部楼层
楼主也可以自己尝试直接绘制一个legend贴上去的
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2016-8-21 00:26:41 | 显示全部楼层
这条路我也考虑了 但是又两个问题和一个隐患
问题1:我的色标必须与色斑图的颜色一致,这就要知道花色斑图的算法。
问题2:我必须先读取色斑图,再在上面画色标。这样做必然会影响服务器绘图速度,也间接影响用户体验。
隐患:自己绘制色标需要导入其他JAR包,以后可能会出现JAR包冲突或者别的异常。
我先试试能不能用METEOINFO中提供的接口画色标,如果实在无法解决,也只能用其他JAR包的方法再色斑图上再绘制色标。
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2016-8-22 00:21:55 | 显示全部楼层
回答老师关于报错的问题
打开老师的例子就报一个错,目前还不影响我使用,但是在这里也反馈给老师
错误1.png

进入正题,为了将清楚我遇到的问题。我重新制作了个简单的例子
上代码:
public FrmMain() throws FileNotFoundException, PrintException, IOException {
     mapLayout1 = new org.meteoinfo.layout.MapLayout();
        layersLegend1 = new org.meteoinfo.legend.LayersLegend();
        jPanel_Layout = new javax.swing.JPanel();  
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jSplitPane1 = new javax.swing.JSplitPane();        
        javax.swing.GroupLayout jPanel_LayoutLayout = new javax.swing.GroupLayout(jPanel_Layout);
        jPanel_Layout.setLayout(jPanel_LayoutLayout);
        jPanel_LayoutLayout.setHorizontalGroup(
            jPanel_LayoutLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(mapLayout1, javax.swing.GroupLayout.DEFAULT_SIZE, 537, Short.MAX_VALUE)
        );
        jPanel_LayoutLayout.setVerticalGroup(
            jPanel_LayoutLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(mapLayout1, javax.swing.GroupLayout.DEFAULT_SIZE, 387, Short.MAX_VALUE)
        );
        jTabbedPane1.addTab("Layout", jPanel_Layout);
        jSplitPane1.setRightComponent(jTabbedPane1);
        jSplitPane1.setLeftComponent(layersLegend1);  
        
        JFrame jframe = new JFrame();
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(jframe.getContentPane());
        jframe.getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jSplitPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 748, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
            .addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 418, Short.MAX_VALUE))
        );
        jframe.pack();      
        layersLegend1.setMapLayout(this.mapLayout1);
        layersLegend1.setIsLayoutView(false);
        mapLayout1.addText("这是一个为了展示报错专门创建的例子", mapLayout1.getWidth() / 2, 20, 16);      
        MeteoDataInfo aDataInfo = new MeteoDataInfo();
        String dataDir = "D:\\Temp\\micaps\\";
        String fileName = dataDir + "10101414.000";
        aDataInfo.openMICAPSData(fileName);
        //Get station data
        StationData stationData = aDataInfo.getStationData("Precipitation6h");
        //Interpolate
        GridDataSetting aGDP = new GridDataSetting();
        aGDP.dataExtent.minX = 60;
        aGDP.dataExtent.maxX = 140;
        aGDP.dataExtent.minY = -20;
        aGDP.dataExtent.maxY = 60;
        aGDP.xNum = 80;
        aGDP.yNum = 80;
        InterpolationSetting gridInterp = new InterpolationSetting();
        gridInterp.setGridDataSetting(aGDP);
        gridInterp.setInterpolationMethod(InterpolationMethods.IDW_Radius);
        gridInterp.setRadius(2);
        gridInterp.setMinPointNum(1);
        GridData gridData = stationData.interpolateData(gridInterp);
        //Create legend scheme
        LegendScheme aLS = LegendManage.createLegendSchemeFromGridData(gridData, LegendType.GraduatedColor,
                ShapeTypes.Polygon);
        ((PolygonBreak) aLS.getLegendBreaks().get(0)).setDrawFill(false);
        //Create layer
        VectorLayer aLayer = new VectorLayer(ShapeTypes.Polygon);
        aLayer = DrawMeteoData.createShadedLayer(gridData, aLS, "Rain", "Rain", true);
        aLayer.setMaskout(true);
        //Add layer
        layersLegend1.getActiveMapFrame().addLayer(aLayer);
        layersLegend1.getActiveMapFrame().moveLayer(aLayer, 0);
        layersLegend1.repaint();
        //Add or change the legend in layout
        LayoutLegend aLegend;
        aLegend = mapLayout1.addLegend(650, 100);
        aLegend.setLegendStyle(LegendStyles.Bar_Vertical);
        aLegend.setLegendLayer(aLayer);
        String drawpath = "D:\\Temp\\draw\\111.png";
        mapLayout1.exportToPicture(drawpath);
    }
这是一个为了展示报错专门创建的例子,完全在老师所给的MeteoInfoDemo例子基础上除去对我没用的代码而来。唯一更改部分就是我创建了一个新的JFrame。因为我要移植到WEB项目中,不能继承JFrame。这个例子在应用程序中能正常运行,是不报错的。
运行界面展示:
错误2.png
生成图片展示:
错误3.png

这个图片很难看,但重点是1、不报错。2、有标题。3、有色标!!!!

进行下一步,我将这个方法移植到WEB项目中。代码基本一样,只是方法名不同和返回一个字符串。
上代码:
@RequestMapping(path="/drawdemo",method=RequestMethod.GET)
   public String Getdrawdemo(String path) throws Exception {
    mapLayout1 = new org.meteoinfo.layout.MapLayout();
       layersLegend1 = new org.meteoinfo.legend.LayersLegend();
       jPanel_Layout = new javax.swing.JPanel();  
       jTabbedPane1 = new javax.swing.JTabbedPane();
       jSplitPane1 = new javax.swing.JSplitPane();        
       javax.swing.GroupLayout jPanel_LayoutLayout = new javax.swing.GroupLayout(jPanel_Layout);
       jPanel_Layout.setLayout(jPanel_LayoutLayout);
       jPanel_LayoutLayout.setHorizontalGroup(
           jPanel_LayoutLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
           .addComponent(mapLayout1, javax.swing.GroupLayout.DEFAULT_SIZE, 537, Short.MAX_VALUE)
       );
       jPanel_LayoutLayout.setVerticalGroup(
           jPanel_LayoutLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
           .addComponent(mapLayout1, javax.swing.GroupLayout.DEFAULT_SIZE, 387, Short.MAX_VALUE)
       );
       jTabbedPane1.addTab("Layout", jPanel_Layout);
       jSplitPane1.setRightComponent(jTabbedPane1);
       jSplitPane1.setLeftComponent(layersLegend1);  
       //报第一个错的地方
       JFrame jframe = new JFrame();
       javax.swing.GroupLayout layout = new javax.swing.GroupLayout(jframe.getContentPane());
       jframe.getContentPane().setLayout(layout);
       layout.setHorizontalGroup(
           layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
           .addComponent(jSplitPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 748, Short.MAX_VALUE)
       );
       layout.setVerticalGroup(
           layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
           .addGroup(layout.createSequentialGroup()
           .addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 418, Short.MAX_VALUE))
       );
       jframe.pack();      
       layersLegend1.setMapLayout(this.mapLayout1);
       layersLegend1.setIsLayoutView(false);
       //报第二个错的地方
       mapLayout1.addText("这是一个为了展示报错专门创建的例子", mapLayout1.getWidth() / 2, 20, 16);      
       MeteoDataInfo aDataInfo = new MeteoDataInfo();
       String dataDir = "D:\\Temp\\micaps\\";
       String fileName = dataDir + "10101414.000";
       aDataInfo.openMICAPSData(fileName);
       //Get station data
       StationData stationData = aDataInfo.getStationData("Precipitation6h");
       //Interpolate
       GridDataSetting aGDP = new GridDataSetting();
       aGDP.dataExtent.minX = 60;
       aGDP.dataExtent.maxX = 140;
       aGDP.dataExtent.minY = -20;
       aGDP.dataExtent.maxY = 60;
       aGDP.xNum = 80;
       aGDP.yNum = 80;
       InterpolationSetting gridInterp = new InterpolationSetting();
       gridInterp.setGridDataSetting(aGDP);
       gridInterp.setInterpolationMethod(InterpolationMethods.IDW_Radius);
       gridInterp.setRadius(2);
       gridInterp.setMinPointNum(1);
       GridData gridData = stationData.interpolateData(gridInterp);
       //Create legend scheme
       LegendScheme aLS = LegendManage.createLegendSchemeFromGridData(gridData, LegendType.GraduatedColor,
               ShapeTypes.Polygon);
       ((PolygonBreak) aLS.getLegendBreaks().get(0)).setDrawFill(false);
       //Create layer
       VectorLayer aLayer = new VectorLayer(ShapeTypes.Polygon);
       aLayer = DrawMeteoData.createShadedLayer(gridData, aLS, "Rain", "Rain", true);
       aLayer.setMaskout(true);
       //Add layer
       layersLegend1.getActiveMapFrame().addLayer(aLayer);
       layersLegend1.getActiveMapFrame().moveLayer(aLayer, 0);
       layersLegend1.repaint();
       //Add or change the legend in layout
       LayoutLegend aLegend;
       //报第三个错的地方
       aLegend = mapLayout1.addLegend(650, 100);
       aLegend.setLegendStyle(LegendStyles.Bar_Vertical);
       aLegend.setLegendLayer(aLayer);
       String drawpath = "D:\\Temp\\draw\\111.png";
       mapLayout1.exportToPicture(drawpath);
       return drawpath;  
   }

现在运行会在报一个错的地方报错!
上异常代码:
java.awt.HeadlessException: null
at java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:207) ~[na:1.7.0_80]
at java.awt.Window.<init>(Window.java:535) ~[na:1.7.0_80]
at java.awt.Frame.<init>(Frame.java:420) ~[na:1.7.0_80]
at java.awt.Frame.<init>(Frame.java:385) ~[na:1.7.0_80]
at javax.swing.JFrame.<init>(JFrame.java:180) ~[na:1.7.0_80]
at cn.monkeylee.sample.provider.mvc.UserInfoControler.Getdrawdemo(UserInfoControler.java:1063) ~[bin/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_80]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[na:1.7.0_80]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_80]
at java.lang.reflect.Method.invoke(Method.java:606) ~[na:1.7.0_80]
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221) ~[spring-web-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136) ~[spring-web-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110) ~[spring-webmvc-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:817) ~[spring-webmvc-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:731) ~[spring-webmvc-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) ~[spring-webmvc-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959) ~[spring-webmvc-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893) ~[spring-webmvc-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:968) ~[spring-webmvc-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:859) ~[spring-webmvc-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:622) ~[tomcat-embed-core-8.0.32.jar:8.0.32]
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:844) ~[spring-webmvc-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) ~[tomcat-embed-core-8.0.32.jar:8.0.32]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292) ~[tomcat-embed-core-8.0.32.jar:8.0.32]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) ~[tomcat-embed-core-8.0.32.jar:8.0.32]
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) ~[tomcat-embed-websocket-8.0.32.jar:8.0.32]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) ~[tomcat-embed-core-8.0.32.jar:8.0.32]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) ~[tomcat-embed-core-8.0.32.jar:8.0.32]
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99) ~[spring-web-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) ~[tomcat-embed-core-8.0.32.jar:8.0.32]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) ~[tomcat-embed-core-8.0.32.jar:8.0.32]
at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:87) ~[spring-web-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) ~[tomcat-embed-core-8.0.32.jar:8.0.32]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) ~[tomcat-embed-core-8.0.32.jar:8.0.32]
at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77) ~[spring-web-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) ~[tomcat-embed-core-8.0.32.jar:8.0.32]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) ~[tomcat-embed-core-8.0.32.jar:8.0.32]
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:121) ~[spring-web-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) ~[tomcat-embed-core-8.0.32.jar:8.0.32]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) ~[tomcat-embed-core-8.0.32.jar:8.0.32]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212) ~[tomcat-embed-core-8.0.32.jar:8.0.32]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106) [tomcat-embed-core-8.0.32.jar:8.0.32]
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502) [tomcat-embed-core-8.0.32.jar:8.0.32]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141) [tomcat-embed-core-8.0.32.jar:8.0.32]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) [tomcat-embed-core-8.0.32.jar:8.0.32]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88) [tomcat-embed-core-8.0.32.jar:8.0.32]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:522) [tomcat-embed-core-8.0.32.jar:8.0.32]
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1095) [tomcat-embed-core-8.0.32.jar:8.0.32]
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:672) [tomcat-embed-core-8.0.32.jar:8.0.32]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500) [tomcat-embed-core-8.0.32.jar:8.0.32]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456) [tomcat-embed-core-8.0.32.jar:8.0.32]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [na:1.7.0_80]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [na:1.7.0_80]
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-8.0.32.jar:8.0.32]
at java.lang.Thread.run(Thread.java:745) [na:1.7.0_80]
我上网查了下这个异常,我自己的理解是这个属于无头绘图。而JFrame属于重量级组件,需要输入设备或者显示器给他一个参数。而我这个WEB项目没有给他参数,所以报了null。我也试着网上的办法解决,最后解决不了!!

最后我的粗暴解决办法就是把异常的部分都删掉!!!
更改后的代码:
@RequestMapping(path="/drawdemo",method=RequestMethod.GET)
   public String Getdrawdemo(String path) throws Exception {
    mapLayout1 = new org.meteoinfo.layout.MapLayout();
       layersLegend1 = new org.meteoinfo.legend.LayersLegend();
      
       //删除了很多容器代码,.......
      
       layersLegend1.setMapLayout(this.mapLayout1);
       layersLegend1.setIsLayoutView(false);
       //报第二个错的地方
       mapLayout1.addText("这是一个为了展示报错专门创建的例子", mapLayout1.getWidth() / 2, 20, 16);      
       MeteoDataInfo aDataInfo = new MeteoDataInfo();
       String dataDir = "D:\\Temp\\micaps\\";
       String fileName = dataDir + "10101414.000";
       aDataInfo.openMICAPSData(fileName);
       //Get station data
       StationData stationData = aDataInfo.getStationData("Precipitation6h");
       //Interpolate
       GridDataSetting aGDP = new GridDataSetting();
       aGDP.dataExtent.minX = 60;
       aGDP.dataExtent.maxX = 140;
       aGDP.dataExtent.minY = -20;
       aGDP.dataExtent.maxY = 60;
       aGDP.xNum = 80;
       aGDP.yNum = 80;
       InterpolationSetting gridInterp = new InterpolationSetting();
       gridInterp.setGridDataSetting(aGDP);
       gridInterp.setInterpolationMethod(InterpolationMethods.IDW_Radius);
       gridInterp.setRadius(2);
       gridInterp.setMinPointNum(1);
       GridData gridData = stationData.interpolateData(gridInterp);
       //Create legend scheme
       LegendScheme aLS = LegendManage.createLegendSchemeFromGridData(gridData, LegendType.GraduatedColor,
               ShapeTypes.Polygon);
       ((PolygonBreak) aLS.getLegendBreaks().get(0)).setDrawFill(false);
       //Create layer
       VectorLayer aLayer = new VectorLayer(ShapeTypes.Polygon);
       aLayer = DrawMeteoData.createShadedLayer(gridData, aLS, "Rain", "Rain", true);
       aLayer.setMaskout(true);
       //Add layer
       layersLegend1.getActiveMapFrame().addLayer(aLayer);
       layersLegend1.getActiveMapFrame().moveLayer(aLayer, 0);
       layersLegend1.repaint();
       //Add or change the legend in layout
       LayoutLegend aLegend;
       //报第三个错的地方
       aLegend = mapLayout1.addLegend(650, 100);
       aLegend.setLegendStyle(LegendStyles.Bar_Vertical);
       aLegend.setLegendLayer(aLayer);
       String drawpath = "D:\\Temp\\draw\\111.png";
       mapLayout1.exportToPicture(drawpath);
       return drawpath;  
   }
这个方法中把很多容器的代码删掉了,但是会在第二个报错点报错
异常展示:
java.lang.NullPointerException: null
at org.meteoinfo.layout.LayoutGraphic.updateControlSize(SourceFile:256) ~[MeteoInfoLib.jar:na]
at org.meteoinfo.layout.LayoutGraphic.setGraphic(SourceFile:175) ~[MeteoInfoLib.jar:na]
at org.meteoinfo.layout.LayoutGraphic.<init>(SourceFile:77) ~[MeteoInfoLib.jar:na]
at org.meteoinfo.layout.MapLayout.addText(SourceFile:2722) ~[MeteoInfoLib.jar:na]
at org.meteoinfo.layout.MapLayout.addText(SourceFile:2702) ~[MeteoInfoLib.jar:na]
at cn.monkeylee.sample.provider.mvc.UserInfoControler.Getdrawdemo(UserInfoControler.java:1052) ~[bin/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_80]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[na:1.7.0_80]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_80]
at java.lang.reflect.Method.invoke(Method.java:606) ~[na:1.7.0_80]
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221) ~[spring-web-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136) ~[spring-web-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110) ~[spring-webmvc-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:817) ~[spring-webmvc-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:731) ~[spring-webmvc-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) ~[spring-webmvc-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959) ~[spring-webmvc-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893) ~[spring-webmvc-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:968) ~[spring-webmvc-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:859) ~[spring-webmvc-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:622) ~[tomcat-embed-core-8.0.32.jar:8.0.32]
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:844) ~[spring-webmvc-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) ~[tomcat-embed-core-8.0.32.jar:8.0.32]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292) ~[tomcat-embed-core-8.0.32.jar:8.0.32]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) ~[tomcat-embed-core-8.0.32.jar:8.0.32]
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) ~[tomcat-embed-websocket-8.0.32.jar:8.0.32]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) ~[tomcat-embed-core-8.0.32.jar:8.0.32]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) ~[tomcat-embed-core-8.0.32.jar:8.0.32]
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99) ~[spring-web-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) ~[tomcat-embed-core-8.0.32.jar:8.0.32]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) ~[tomcat-embed-core-8.0.32.jar:8.0.32]
at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:87) ~[spring-web-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) ~[tomcat-embed-core-8.0.32.jar:8.0.32]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) ~[tomcat-embed-core-8.0.32.jar:8.0.32]
at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77) ~[spring-web-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) ~[tomcat-embed-core-8.0.32.jar:8.0.32]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) ~[tomcat-embed-core-8.0.32.jar:8.0.32]
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:121) ~[spring-web-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) ~[tomcat-embed-core-8.0.32.jar:8.0.32]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) ~[tomcat-embed-core-8.0.32.jar:8.0.32]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212) ~[tomcat-embed-core-8.0.32.jar:8.0.32]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106) [tomcat-embed-core-8.0.32.jar:8.0.32]
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502) [tomcat-embed-core-8.0.32.jar:8.0.32]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141) [tomcat-embed-core-8.0.32.jar:8.0.32]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) [tomcat-embed-core-8.0.32.jar:8.0.32]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88) [tomcat-embed-core-8.0.32.jar:8.0.32]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:522) [tomcat-embed-core-8.0.32.jar:8.0.32]
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1095) [tomcat-embed-core-8.0.32.jar:8.0.32]
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:672) [tomcat-embed-core-8.0.32.jar:8.0.32]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500) [tomcat-embed-core-8.0.32.jar:8.0.32]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456) [tomcat-embed-core-8.0.32.jar:8.0.32]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [na:1.7.0_80]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [na:1.7.0_80]
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-8.0.32.jar:8.0.32]
at java.lang.Thread.run(Thread.java:745) [na:1.7.0_80]

报错的语句:
错误4.png

继续删除报错的的代码,删除后的代码如下:
   @RequestMapping(path="/drawdemo",method=RequestMethod.GET)
   public String Getdrawdemo(String path) throws Exception {
    mapLayout1 = new org.meteoinfo.layout.MapLayout();
       layersLegend1 = new org.meteoinfo.legend.LayersLegend();
      
       //删除了很多容器代码,.......
      
       layersLegend1.setMapLayout(this.mapLayout1);
       layersLegend1.setIsLayoutView(false);
       //报第二个错的地方
       //删除了添加标题的语句!!
       MeteoDataInfo aDataInfo = new MeteoDataInfo();
       String dataDir = "D:\\Temp\\micaps\\";
       String fileName = dataDir + "10101414.000";
       aDataInfo.openMICAPSData(fileName);
       //Get station data
       StationData stationData = aDataInfo.getStationData("Precipitation6h");
       //Interpolate
       GridDataSetting aGDP = new GridDataSetting();
       aGDP.dataExtent.minX = 60;
       aGDP.dataExtent.maxX = 140;
       aGDP.dataExtent.minY = -20;
       aGDP.dataExtent.maxY = 60;
       aGDP.xNum = 80;
       aGDP.yNum = 80;
       InterpolationSetting gridInterp = new InterpolationSetting();
       gridInterp.setGridDataSetting(aGDP);
       gridInterp.setInterpolationMethod(InterpolationMethods.IDW_Radius);
       gridInterp.setRadius(2);
       gridInterp.setMinPointNum(1);
       GridData gridData = stationData.interpolateData(gridInterp);
       //Create legend scheme
       LegendScheme aLS = LegendManage.createLegendSchemeFromGridData(gridData, LegendType.GraduatedColor,
               ShapeTypes.Polygon);
       ((PolygonBreak) aLS.getLegendBreaks().get(0)).setDrawFill(false);
       //Create layer
       VectorLayer aLayer = new VectorLayer(ShapeTypes.Polygon);
       aLayer = DrawMeteoData.createShadedLayer(gridData, aLS, "Rain", "Rain", true);
       aLayer.setMaskout(true);
       //Add layer
       layersLegend1.getActiveMapFrame().addLayer(aLayer);
       layersLegend1.getActiveMapFrame().moveLayer(aLayer, 0);
       layersLegend1.repaint();
       //Add or change the legend in layout
       LayoutLegend aLegend;
       //报第三个错的地方
       aLegend = mapLayout1.addLegend(650, 100);
       aLegend.setLegendStyle(LegendStyles.Bar_Vertical);
       aLegend.setLegendLayer(aLayer);
       String drawpath = "D:\\Temp\\draw\\111.png";
       mapLayout1.exportToPicture(drawpath);
       return drawpath;  
   }

继续报错,异常如下:
java.lang.NullPointerException: null
at org.meteoinfo.layout.LayoutLegend.b(SourceFile:915) ~[MeteoInfoLib.jar:na]
at org.meteoinfo.layout.LayoutLegend.updateLegendSize(SourceFile:951) ~[MeteoInfoLib.jar:na]
at org.meteoinfo.layout.LayoutLegend.setLegendLayer(SourceFile:184) ~[MeteoInfoLib.jar:na]
at org.meteoinfo.layout.MapLayout.addLegend(SourceFile:2743) ~[MeteoInfoLib.jar:na]
at cn.monkeylee.sample.provider.mvc.UserInfoControler.Getdrawdemo(UserInfoControler.java:1089) ~[bin/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_80]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[na:1.7.0_80]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_80]
at java.lang.reflect.Method.invoke(Method.java:606) ~[na:1.7.0_80]
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221) ~[spring-web-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136) ~[spring-web-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110) ~[spring-webmvc-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:817) ~[spring-webmvc-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:731) ~[spring-webmvc-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) ~[spring-webmvc-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959) ~[spring-webmvc-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893) ~[spring-webmvc-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:968) ~[spring-webmvc-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:859) ~[spring-webmvc-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:622) ~[tomcat-embed-core-8.0.32.jar:8.0.32]
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:844) ~[spring-webmvc-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) ~[tomcat-embed-core-8.0.32.jar:8.0.32]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292) ~[tomcat-embed-core-8.0.32.jar:8.0.32]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) ~[tomcat-embed-core-8.0.32.jar:8.0.32]
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) ~[tomcat-embed-websocket-8.0.32.jar:8.0.32]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) ~[tomcat-embed-core-8.0.32.jar:8.0.32]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) ~[tomcat-embed-core-8.0.32.jar:8.0.32]
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99) ~[spring-web-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) ~[tomcat-embed-core-8.0.32.jar:8.0.32]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) ~[tomcat-embed-core-8.0.32.jar:8.0.32]
at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:87) ~[spring-web-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) ~[tomcat-embed-core-8.0.32.jar:8.0.32]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) ~[tomcat-embed-core-8.0.32.jar:8.0.32]
at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77) ~[spring-web-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) ~[tomcat-embed-core-8.0.32.jar:8.0.32]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) ~[tomcat-embed-core-8.0.32.jar:8.0.32]
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:121) ~[spring-web-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) ~[tomcat-embed-core-8.0.32.jar:8.0.32]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) ~[tomcat-embed-core-8.0.32.jar:8.0.32]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212) ~[tomcat-embed-core-8.0.32.jar:8.0.32]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106) [tomcat-embed-core-8.0.32.jar:8.0.32]
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502) [tomcat-embed-core-8.0.32.jar:8.0.32]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141) [tomcat-embed-core-8.0.32.jar:8.0.32]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) [tomcat-embed-core-8.0.32.jar:8.0.32]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88) [tomcat-embed-core-8.0.32.jar:8.0.32]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:522) [tomcat-embed-core-8.0.32.jar:8.0.32]
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1095) [tomcat-embed-core-8.0.32.jar:8.0.32]
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:672) [tomcat-embed-core-8.0.32.jar:8.0.32]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500) [tomcat-embed-core-8.0.32.jar:8.0.32]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456) [tomcat-embed-core-8.0.32.jar:8.0.32]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [na:1.7.0_80]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [na:1.7.0_80]
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-8.0.32.jar:8.0.32]
at java.lang.Thread.run(Thread.java:745) [na:1.7.0_80]

报错的语句:
错误5.png

继续删除报错的语句,最终代码:
   @RequestMapping(path="/drawdemo",method=RequestMethod.GET)
   public String Getdrawdemo(String path) throws Exception {
    mapLayout1 = new org.meteoinfo.layout.MapLayout();
       layersLegend1 = new org.meteoinfo.legend.LayersLegend();
      
       //删除了很多容器代码,.......
      
       layersLegend1.setMapLayout(this.mapLayout1);
       layersLegend1.setIsLayoutView(false);
       //报第二个错的地方
       //删除了添加标题的语句!!
       MeteoDataInfo aDataInfo = new MeteoDataInfo();
       String dataDir = "D:\\Temp\\micaps\\";
       String fileName = dataDir + "10101414.000";
       aDataInfo.openMICAPSData(fileName);
       //Get station data
       StationData stationData = aDataInfo.getStationData("Precipitation6h");
       //Interpolate
       GridDataSetting aGDP = new GridDataSetting();
       aGDP.dataExtent.minX = 60;
       aGDP.dataExtent.maxX = 140;
       aGDP.dataExtent.minY = -20;
       aGDP.dataExtent.maxY = 60;
       aGDP.xNum = 80;
       aGDP.yNum = 80;
       InterpolationSetting gridInterp = new InterpolationSetting();
       gridInterp.setGridDataSetting(aGDP);
       gridInterp.setInterpolationMethod(InterpolationMethods.IDW_Radius);
       gridInterp.setRadius(2);
       gridInterp.setMinPointNum(1);
       GridData gridData = stationData.interpolateData(gridInterp);
       //Create legend scheme
       LegendScheme aLS = LegendManage.createLegendSchemeFromGridData(gridData, LegendType.GraduatedColor,
               ShapeTypes.Polygon);
       ((PolygonBreak) aLS.getLegendBreaks().get(0)).setDrawFill(false);
       //Create layer
       VectorLayer aLayer = new VectorLayer(ShapeTypes.Polygon);
       aLayer = DrawMeteoData.createShadedLayer(gridData, aLS, "Rain", "Rain", true);
       aLayer.setMaskout(true);
       //Add layer
       layersLegend1.getActiveMapFrame().addLayer(aLayer);
       layersLegend1.getActiveMapFrame().moveLayer(aLayer, 0);
       layersLegend1.repaint();
       //Add or change the legend in layout
       LayoutLegend aLegend;
       //报第三个错的地方
       //删除报错的添加色标的代码
       String drawpath = "D:\\Temp\\draw\\111.png";
       mapLayout1.exportToPicture(drawpath);
       return drawpath;  
   }

这个帖子第一次发的列子就是在这个代码基础行改的,就是增加了图层和修改了参数。本质上和这个代码是一样的!!
上运行效果:
错误6.png
运行没有报任何异常,只是没有标题,没有色标!!!!!!
恳请老师帮助解决!!
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2016-8-22 09:18:52 | 显示全部楼层
kafuka123 发表于 2016-8-22 00:21
回答老师关于报错的问题
打开老师的例子就报一个错,目前还不影响我使用,但是在这里也反馈给老师

你用的是最新版本的MeteoInfo吗,如果不是,下载最新版本再试试。
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2016-8-22 11:20:57 来自手机 | 显示全部楼层
是最新版的。我这个问题和版本关系不大啊。我想知道如何不通过JFrame来添加色标!
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2016-8-22 13:04:55 | 显示全部楼层
学习了  赞
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2016-8-22 14:10:11 | 显示全部楼层
kafuka123 发表于 2016-8-22 11:20
是最新版的。我这个问题和版本关系不大啊。我想知道如何不通过JFrame来添加色标!

我对了一下错误信息显示的出错的程序行和我目前的代码不是很匹配,因此问你版本的问题。
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

Copyright ©2011-2014 bbs.06climate.com All Rights Reserved.  Powered by Discuz! (京ICP-10201084)

本站信息均由会员发表,不代表气象家园立场,禁止在本站发表与国家法律相抵触言论

快速回复 返回顶部 返回列表