forked from geodmms/xdgnjobs

Dennis Kao
2014-01-15 94ae08701bbd7585a0b7e5a92d1975965a503c03
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/DefaultColorTable.java
@@ -4,14 +4,11 @@
import java.util.ArrayList;
import java.util.List;
public class DefaultColorTable implements ColorTableMapping
{
public class DefaultColorTable implements ColorTableMapping {
    private static DefaultColorTable _instance = null;
    public static ColorTableMapping getInstance()
    {
        if (_instance == null)
        {
    public static ColorTableMapping getInstance() {
        if (_instance == null) {
            _instance = new DefaultColorTable();
        }
@@ -20,15 +17,12 @@
    private ArrayList<Color> colortable = null;
    private DefaultColorTable()
    {
    private DefaultColorTable() {
        initializeColorTable();
    }
    private void initializeColorTable()
    {
        if (colortable != null)
        {
    private void initializeColorTable() {
        if (colortable != null) {
            return;
        }
@@ -290,76 +284,61 @@
        colortable.add(254, new Color(30, 52, 0));
    }
    public List findId(Color color)
    {
    public List findId(Color color) {
        ArrayList<Integer> codelist = new ArrayList<Integer>();
        for (int i = 0; i < colortable.size(); i++)
        {
        for (int i = 0; i < colortable.size(); i++) {
            Color colorDef = colortable.get(i);
            if (colorDef.equals(color))
            {
            if (colorDef.equals(color)) {
                codelist.add(i);
            }
        }
        return codelist;
    }
    public Color getColor(int i)
    {
    public Color getColor(int i) {
        return colortable.get(i);
    }
    public String getColorCode(int i)
    {
    public String getColorCode(int i) {
        Color color = colortable.get(i);
        if (!color.equals(Color.WHITE))
            return colorToString(colortable.get(i));
        return colorToString(Color.GRAY);
    }
    public boolean contain(Color color)
    {
        for (Color colorDef : colortable)
        {
            if (colorDef.equals(color))
            {
    public boolean contain(Color color) {
        for (Color colorDef : colortable) {
            if (colorDef.equals(color)) {
                return true;
            }
        }
        return false;
    }
    private static String colorToString(Color c)
    {
    private static String colorToString(Color c) {
        char[] buf = new char[7];
        buf[0] = '#';
        String s = Integer.toHexString(c.getRed());
        if (s.length() == 1)
        {
        if (s.length() == 1) {
            buf[1] = '0';
            buf[2] = s.charAt(0);
        } else
        {
        } else {
            buf[1] = s.charAt(0);
            buf[2] = s.charAt(1);
        }
        s = Integer.toHexString(c.getGreen());
        if (s.length() == 1)
        {
        if (s.length() == 1) {
            buf[3] = '0';
            buf[4] = s.charAt(0);
        } else
        {
        } else {
            buf[3] = s.charAt(0);
            buf[4] = s.charAt(1);
        }
        s = Integer.toHexString(c.getBlue());
        if (s.length() == 1)
        {
        if (s.length() == 1) {
            buf[5] = '0';
            buf[6] = s.charAt(0);
        } else
        {
        } else {
            buf[5] = s.charAt(0);
            buf[6] = s.charAt(1);
        }