forked from geodmms/xdgnjobs

?? ?
2008-05-05 4d3cc8c2a0d8297341fab014798aa3a06020fae9
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/DefaultColorTable.java
@@ -289,7 +289,7 @@
        colortable.add(254, new Color(30, 52, 0));
    }
    public List getCode(Color color)
    public List findId(Color color)
    {
        ArrayList<Integer> codelist = new ArrayList<Integer>();
        for (int i = 0; i < colortable.size(); i++)
@@ -308,6 +308,11 @@
        return colortable.get(i);
    }
    public String getColorCode(int i)
    {
        return colorToString(colortable.get(i));
    }
    public boolean contain(Color color)
    {
        for (Color colorDef : colortable)
@@ -319,4 +324,37 @@
        }
        return false;
    }
    private static String colorToString(Color c) {
      char[] buf = new char[7];
      buf[0] = '#';
      String s = Integer.toHexString(c.getRed());
      if (s.length() == 1) {
         buf[1] = '0';
         buf[2] = s.charAt(0);
      }
      else {
         buf[1] = s.charAt(0);
         buf[2] = s.charAt(1);
      }
      s = Integer.toHexString(c.getGreen());
      if (s.length() == 1) {
         buf[3] = '0';
         buf[4] = s.charAt(0);
      }
      else {
         buf[3] = s.charAt(0);
         buf[4] = s.charAt(1);
      }
      s = Integer.toHexString(c.getBlue());
      if (s.length() == 1) {
         buf[5] = '0';
         buf[6] = s.charAt(0);
      }
      else {
         buf[5] = s.charAt(0);
         buf[6] = s.charAt(1);
      }
      return String.valueOf(buf);
   }
}