一、要素色标区间设置

  1. //基础数据图层
  2. List<ColorBreak> breaks = new ArrayList<>();
  3. for (int j = 0; j < colorList.size(); j++) {
  4. PolygonBreak cb4 = new PolygonBreak();
  5. cb4.setCaption(colorList.get(j).get("element_name").toString());
  6. if(colorList.get(j).get("val_min")!=null) {
  7. cb4.setStartValue(Double.valueOf(colorList.get(j).get("val_min")+"").doubleValue());
  8. }
  9. if(colorList.get(j).get("val_max")!=null) {
  10. cb4.setEndValue(Double.valueOf(colorList.get(j).get("val_max")+"").doubleValue());
  11. }
  12. cb4.setNoData(true);
  13. cb4.setColor(new Color(Integer.valueOf(colorList.get(j).get("r").toString()).intValue()
  14. ,Integer.valueOf(colorList.get(j).get("g").toString()).intValue()
  15. ,Integer.valueOf(colorList.get(j).get("b").toString()).intValue()));
  16. breaks.add(cb4);
  17. }

二、生成要素色斑图

  1. MapView mapView = mapFrame.getMapView();
  2. LegendScheme legendScheme = new LegendScheme();
  3. legendScheme.setLegendBreaks(breaks);
  4. legendScheme.setMinValue(-20.0);
  5. legendScheme.setMaxValue(48.0);
  6. legendScheme.setShapeType(ShapeTypes.Image);
  7. legendScheme.setLegendType(LegendType.GraduatedColor);
  8. //读取地图基本数据
  9. VectorLayer shadedLayerGd = DrawMeteoData.createShadedLayer(gridData,legendScheme, "", "Data",true);
  10. shadedLayerGd.setMaskout(true);
  11. mapView.addLayer(shadedLayerGd);
  12. //开启//加入掩膜
  13. mapView.getMaskOut().setMask(true);
  14. mapView.getMaskOut().setMaskLayer(shapeLayer.getLayerName());
  15. mapView.zoomToExtent(shapeLayer.getExtent());
  16. new File(rootPath+outPath).mkdirs();
  17. mapLayout.exportToPicture(rootPath+outPath);