一、要素色标区间设置
//基础数据图层List<ColorBreak> breaks = new ArrayList<>();for (int j = 0; j < colorList.size(); j++) { PolygonBreak cb4 = new PolygonBreak(); cb4.setCaption(colorList.get(j).get("element_name").toString()); if(colorList.get(j).get("val_min")!=null) { cb4.setStartValue(Double.valueOf(colorList.get(j).get("val_min")+"").doubleValue()); } if(colorList.get(j).get("val_max")!=null) { cb4.setEndValue(Double.valueOf(colorList.get(j).get("val_max")+"").doubleValue()); } cb4.setNoData(true); cb4.setColor(new Color(Integer.valueOf(colorList.get(j).get("r").toString()).intValue() ,Integer.valueOf(colorList.get(j).get("g").toString()).intValue() ,Integer.valueOf(colorList.get(j).get("b").toString()).intValue())); breaks.add(cb4); }
二、生成要素色斑图
MapView mapView = mapFrame.getMapView();LegendScheme legendScheme = new LegendScheme();legendScheme.setLegendBreaks(breaks); legendScheme.setMinValue(-20.0);legendScheme.setMaxValue(48.0);legendScheme.setShapeType(ShapeTypes.Image);legendScheme.setLegendType(LegendType.GraduatedColor); //读取地图基本数据VectorLayer shadedLayerGd = DrawMeteoData.createShadedLayer(gridData,legendScheme, "", "Data",true);shadedLayerGd.setMaskout(true); mapView.addLayer(shadedLayerGd);//开启//加入掩膜mapView.getMaskOut().setMask(true);mapView.getMaskOut().setMaskLayer(shapeLayer.getLayerName());mapView.zoomToExtent(shapeLayer.getExtent());new File(rootPath+outPath).mkdirs();mapLayout.exportToPicture(rootPath+outPath);