From 4d3cc8c2a0d8297341fab014798aa3a06020fae9 Mon Sep 17 00:00:00 2001
From: ?? ? <ulysseskao@ximple.com.tw>
Date: Mon, 05 May 2008 16:57:27 +0800
Subject: [PATCH] update for EOFM-68

---
 xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/ColorTableMapping.java          |    5 +++--
 xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/CreateShapeStrategy.java      |    3 +++
 xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/DefaultColorTable.java          |   40 +++++++++++++++++++++++++++++++++++++++-
 xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/CreateLineStringStrategy.java |    4 ++++
 xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/CreateLineTextStrategy.java   |    5 +++++
 5 files changed, 54 insertions(+), 3 deletions(-)

diff --git a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/CreateLineStringStrategy.java b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/CreateLineStringStrategy.java
index 06209ef..ebe84cd 100644
--- a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/CreateLineStringStrategy.java
+++ b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/CreateLineStringStrategy.java
@@ -58,6 +58,7 @@
             typeBuilder.addType(AttributeTypeFactory.newAttributeType("CID", Integer.class));
             typeBuilder.addType(AttributeTypeFactory.newAttributeType("LID", Integer.class));
             typeBuilder.addType(AttributeTypeFactory.newAttributeType("LEVEL", Integer.class));
+            typeBuilder.addType(AttributeTypeFactory.newAttributeType("COLOR", String.class));
             typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMCOLOR", Integer.class));
             typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMWEIGHT", Integer.class));
             typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMSTYLE", Integer.class));
@@ -81,6 +82,7 @@
                     (int) fLinkage.getComponentID(),
                     0,
                     lineStringElement.getLevelIndex(),
+                    colorTable.getColorCode(lineStringElement.getColorIndex()),
                     colorTable.getColor(lineStringElement.getColorIndex()).getRGB(),
                     lineStringElement.getWeight(),
                     lineStringElement.getLineStyle()
@@ -97,6 +99,7 @@
                     (int) fLinkage.getComponentID(),
                     0,
                     complexChain.getLevelIndex(),
+                    colorTable.getColorCode(complexChain.getColorIndex()),
                     colorTable.getColor(complexChain.getColorIndex()).getRGB(),
                     complexChain.getWeight(),
                     complexChain.getLineStyle()
@@ -113,6 +116,7 @@
                     (int) fLinkage.getComponentID(),
                     0,
                     lineElement.getLevelIndex(),
+                    colorTable.getColorCode(lineElement.getColorIndex()),
                     colorTable.getColor(lineElement.getColorIndex()).getRGB(),
                     lineElement.getWeight(),
                     lineElement.getLineStyle()
diff --git a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/CreateLineTextStrategy.java b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/CreateLineTextStrategy.java
index ae14638..97e69e7 100644
--- a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/CreateLineTextStrategy.java
+++ b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/CreateLineTextStrategy.java
@@ -62,6 +62,7 @@
             typeBuilder.addType(AttributeTypeFactory.newAttributeType("CID", Integer.class));
             typeBuilder.addType(AttributeTypeFactory.newAttributeType("LID", Integer.class));
             typeBuilder.addType(AttributeTypeFactory.newAttributeType("LEVEL", Integer.class));
+            typeBuilder.addType(AttributeTypeFactory.newAttributeType("COLOR", String.class));
             typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMCOLOR", Integer.class));
             typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMWEIGHT", Integer.class));
             typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMSTYLE", Integer.class));
@@ -85,6 +86,7 @@
                     (int) fLinkage.getComponentID(),
                     0,
                     lineStringElement.getLevelIndex(),
+                    colorTable.getColorCode(lineStringElement.getColorIndex()),
                     colorTable.getColor(lineStringElement.getColorIndex()).getRGB(),
                     lineStringElement.getWeight(),
                     lineStringElement.getLineStyle()
@@ -114,6 +116,7 @@
                     (int) fLinkage.getComponentID(),
                     0,
                     txtElement.getLevelIndex(),
+                    colorTable.getColorCode(txtElement.getColorIndex()),
                     colorTable.getColor(txtElement.getColorIndex()).getRGB(),
                     txtElement.getWeight(),
                     txtElement.getLineStyle()
@@ -130,6 +133,7 @@
                     (int) fLinkage.getComponentID(),
                     0,
                     complexChain.getLevelIndex(),
+                    colorTable.getColorCode(complexChain.getColorIndex()),
                     colorTable.getColor(complexChain.getColorIndex()).getRGB(),
                     complexChain.getWeight(),
                     complexChain.getLineStyle()
@@ -146,6 +150,7 @@
                     (int) fLinkage.getComponentID(),
                     0,
                     lineElement.getLevelIndex(),
+                    colorTable.getColorCode(lineElement.getColorIndex()),
                     colorTable.getColor(lineElement.getColorIndex()).getRGB(),
                     lineElement.getWeight(),
                     lineElement.getLineStyle()
diff --git a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/CreateShapeStrategy.java b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/CreateShapeStrategy.java
index 40cbc6b..3657701 100644
--- a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/CreateShapeStrategy.java
+++ b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/CreateShapeStrategy.java
@@ -57,6 +57,7 @@
             typeBuilder.addType(AttributeTypeFactory.newAttributeType("CID", Integer.class));
             typeBuilder.addType(AttributeTypeFactory.newAttributeType("LID", Integer.class));
             typeBuilder.addType(AttributeTypeFactory.newAttributeType("LEVEL", Integer.class));
+            typeBuilder.addType(AttributeTypeFactory.newAttributeType("COLOR", String.class));
             typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMCOLOR", Integer.class));
             typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMWEIGHT", Integer.class));
             typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMSTYLE", Integer.class));
@@ -80,6 +81,7 @@
                     (int) fLinkage.getComponentID(),
                     0,
                     shapeElement.getLevelIndex(),
+                    colorTable.getColorCode(shapeElement.getColorIndex()),
                     colorTable.getColor(shapeElement.getColorIndex()).getRGB(),
                     shapeElement.getWeight(),
                     shapeElement.getLineStyle()
@@ -96,6 +98,7 @@
                     (int) fLinkage.getComponentID(),
                     0,
                     complexShape.getLevelIndex(),
+                    colorTable.getColorCode(complexShape.getColorIndex()),
                     colorTable.getColor(complexShape.getColorIndex()).getRGB(),
                     complexShape.getWeight(),
                     complexShape.getLineStyle()
diff --git a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/ColorTableMapping.java b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/ColorTableMapping.java
index 8466942..b0e3715 100644
--- a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/ColorTableMapping.java
+++ b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/ColorTableMapping.java
@@ -5,7 +5,8 @@
 
 public interface ColorTableMapping
 {
-    List getCode(Color color);
-    Color getColor(int value);
     boolean contain(Color color);
+    List findId(Color color);
+    Color getColor(int value);
+    String getColorCode(int i);
 }
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 787b15a..f5cf464 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
@@ -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);
+	}
 }

--
Gitblit v0.0.0-SNAPSHOT