From 94ae08701bbd7585a0b7e5a92d1975965a503c03 Mon Sep 17 00:00:00 2001 From: Dennis Kao <ulysseskao@gmail.com> Date: Wed, 15 Jan 2014 11:28:52 +0800 Subject: [PATCH] Merge branch 'origin/2.1.x' --- xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/DefaultColorTable.java | 63 ++++++++++--------------------- 1 files changed, 21 insertions(+), 42 deletions(-) diff --git a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/DefaultColorTable.java b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/DefaultColorTable.java index 36c1a5f..ade64f4 100644 --- a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/DefaultColorTable.java +++ b/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); } -- Gitblit v0.0.0-SNAPSHOT