Mapxtreme for Java中添加自定义图标

MapXtreme Java提供的图标很少,做出的地图看起来不美观。MapXtreme Java中自定义符号
我目前想用这种方法:
将自定义的符号*.bmp保存到C:/Documents and Settings/Administrator/Application Data/MapInfo/MapInfo/Professional/700/CustSymb即可在pro中使用,如果要在xtreme for java 中使用该符号,要首先将该bmp格式的图标转换为gif格式,然后放在程序目录中并写在属性文件里

取出图的文件名

cximgurl=file:///d://cqyc//Jmap//images//XYCYJ.GIF

//循环DrawPoints/

      for(int i=0 ;i        Vector colvector = (Vector)jhtable.elementAt(i);
        String sjh = (String)colvector.elementAt(0);
        DoublePoint dpjw = (DoublePoint)colvector.elementAt(1);
        String si = i + "";
        if ((sjh!=null) && (dpjw!=null)) {
          DrawPoints(themeMap,sjh,dpjw,si,"Annotations");
        }
      }

// //画一个单一的点对象 

private void DrawPoints(MapJ map, String jh,DoublePoint point,String key,String LayerName)
  {
    PrimaryKey primarykey;
    primarykey = new PrimaryKey();
    Vector columns = new Vector();
    int featlen = 0;
      try
      {
          Layer annotLayer = map.getLayers().getLayer(LayerName);
          if(annotLayer == null)
          {
              AnnotationTableDescHelper annTableDesc = new AnnotationTableDescHelper("Annotations");
              AnnotationDataProviderHelper dpHelper = new AnnotationDataProviderHelper();
              LocalDataProviderRef dpRef = new LocalDataProviderRef(dpHelper);
              annotLayer = map.getLayers().insert(dpRef, annTableDesc, 0, LayerName);
          }

          String imageurl = ConfigFile.chanj_imageurl;
          Feature retFeature = CreatePointFeature(map,point,key,imageurl);
          primarykey = annotLayer.addFeature(retFeature);
      }
      catch(Exception e)
      {
        WriteLog.writeForErrorDebug("HkjTheme.DrawPoints","绘制点异常!",e);
          e.printStackTrace();
      }
  }

//建立点的feature
  private Feature CreatePointFeature(MapJ map, DoublePoint point,String key,String imgurl)
  {
      FeatureFactory ff = map.getFeatureFactory();
      Attribute att[] = new Attribute[1];
      //att[0] = new Attribute("SearchFeature");
      att[0] = new Attribute(key);
      PrimaryKey pk = new PrimaryKey(att[0]);
      //Rendition rend = sysOpition.GetSystemPointRendition();
      //String imgurl = "http://localhost:8080/maptemp/pat.gif";
      Rendition rend = GetSystemPointRendition(Color.white,imgurl);
      Feature retFeature = null;
      DoublePoint dp = point;
      try
      {
          retFeature = ff.createPoint(dp, rend, att, pk);
      }
      catch(Exception exception) { }
      return retFeature;
    }

//根据传过来的颜色和图片的url地址生成专题图的样式
    private com.mapinfo.dp.Rendition GetSystemPointRendition(Color color,String imgurl)
    {
        com.mapinfo.dp.Rendition rend = new com.mapinfo.dp.Rendition();
        rend.setValue(com.mapinfo.graphics.Rendition.FONT_FAMILY, "MapInfo Oil&Gas");
        rend.setValue(com.mapinfo.graphics.Rendition.FONT_SIZE, new Float(15F));
        rend.setValue(com.mapinfo.graphics.Rendition.FONT_WEIGHT, new Float(1.0F));
        rend.setValue(com.mapinfo.graphics.Rendition.FONT_STYLE, com.mapinfo.graphics.Rendition.FontStyle.NORMAL);
        //rend.setValue(com.mapinfo.graphics.Rendition.SYMBOL_MODE, com.mapinfo.graphics.Rendition.SymbolMode.FONT);
        //rend.setValue(com.mapinfo.graphics.Rendition.SYMBOL_STRING, sysOpition.GetStringValue(41));
        //调用自定义的图片
        rend.setValue(Rendition.SYMBOL_MODE, Rendition.SymbolMode.IMAGE);
        //rend.setValue(Rendition.SYMBOL_URL,"http://localhost:8080/images/hkj.gif");
        //rend.setValue(Rendition.SYMBOL_URL, ConfigFile.m_hkjurl);
        //System.out.println("2imgurl:"+imgurl);
        rend.setValue(Rendition.SYMBOL_URL, imgurl);
        rend.setValue(com.mapinfo.graphics.Rendition.SYMBOL_FOREGROUND, color);
        rend.setValue(com.mapinfo.graphics.Rendition.SYMBOL_BACKGROUND, Color.red);
        return rend;
    }

你可能感兴趣的:(java,string,annotations,exception,vector,null)