[Schmitzm-commits] r780 - in trunk: dist src/schmitzm/geotools/styling src/skrueger/i8n

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Mar 31 15:39:03 CEST 2010


Author: alfonx
Date: 2010-03-31 15:39:02 +0200 (Wed, 31 Mar 2010)
New Revision: 780

Added:
   trunk/src/skrueger/i8n/TranslationTool.java
Modified:
   trunk/dist/schmitzm-2.0.x.jar
   trunk/src/schmitzm/geotools/styling/StylingUtil.java
Log:
neue SLD to outputstrem methode

Modified: trunk/dist/schmitzm-2.0.x.jar
===================================================================
(Binary files differ)

Modified: trunk/src/schmitzm/geotools/styling/StylingUtil.java
===================================================================
--- trunk/src/schmitzm/geotools/styling/StylingUtil.java	2010-03-30 10:29:42 UTC (rev 779)
+++ trunk/src/schmitzm/geotools/styling/StylingUtil.java	2010-03-31 13:39:02 UTC (rev 780)
@@ -37,6 +37,7 @@
 import java.io.FileWriter;
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.OutputStream;
 import java.lang.reflect.Array;
 import java.net.URL;
 import java.nio.charset.Charset;
@@ -1069,12 +1070,15 @@
 			IOUtils.closeQuietly(inputStream);
 		}
 	}
+	
 
+
 	/**
 	 * Saves the {@link Style} to OGC SLD. Overwrites any existing file. If a
 	 * FeatureTypeStyle for selection is used, it is automatically removed. This
 	 * method also checks, whether the style is actually differing from any
-	 * existing style in the File.
+	 * existing style in the {@link File}. If there is no difference, the file
+	 * is not saved again (that is more svn friendly).
 	 * 
 	 * @param origStyle
 	 *            {@link Style} to save. Any selectino related FeatureTypeStyle
@@ -1111,7 +1115,43 @@
 		return true;
 	}
 
+	
+	
 	/**
+	 * Exports the {@link Style} to OGC SLD. If a FeatureTypeStyle for selection is used, it is automatically removed. 
+	 * 
+	 * @param origStyle
+	 *            {@link Style} to save. Any selectino related FeatureTypeStyle
+	 *            will be removed.
+	 * @param charset
+	 *            The charset to use for the XML, e.g. <?xml version="1.0"
+	 *            encoding="UTF-8"?>. If <code>null</code>, non is set and the
+	 *            system default is used.
+	 * 
+	 * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons
+	 *         Kr&uuml;ger</a>
+	 */
+	public static final boolean saveStyleToSLD(Style origStyle,
+			OutputStream exportStream, Charset charset) throws TransformerException {
+
+		SLDTRANSFORMER.setIndentation(2);
+		// LOGGER.debug("default charset = "+ Charset.defaultCharset());
+		// SLDTRANSFORMER.setEncoding(Charset.forName("UTF-8"));
+
+//		Style exportStyle = removeSelectionFeatureTypeStyle(origStyle);
+
+//		if (!isStyleDifferent(exportStyle, exportFile)) {
+//			// LOGGER.debug("Style " + exportFile +
+//			// " didn't change, not saving.");
+//			return false;
+//		}
+
+		SLDTRANSFORMER.transform(origStyle, exportStream);
+
+		return true;
+	}
+
+	/**
 	 * Creates a copy of the given {@link Style}, removing any
 	 * {@link FeatureTypeStyle}s that are only SELECTION related.
 	 * 
@@ -2497,36 +2537,34 @@
 								sym.getGeometryPropertyName()).getLocalPart());
 				if (sym.getLabel() != null)
 					sym.setLabel(copy(sym.getLabel()));
-				
+
 				if (sym.getPriority() != null)
 					sym.setPriority(copy(sym.getPriority()));
-				
 
-//				if (sym.getPriority() instanceof PropertyName) {
-//					PropertyName propertyname = (PropertyName) sym
-//							.getPriority();
-//					sym.setPriority(ff.property(FeatureUtil
-//							.findBestMatchingAttributeFallBackFirst(schema,
-//									propertyname.getPropertyName())));
-//				}
+				// if (sym.getPriority() instanceof PropertyName) {
+				// PropertyName propertyname = (PropertyName) sym
+				// .getPriority();
+				// sym.setPriority(ff.property(FeatureUtil
+				// .findBestMatchingAttributeFallBackFirst(schema,
+				// propertyname.getPropertyName())));
+				// }
 
 				super.visit(sym);
 			}
-			
+
 			@Override
 			public Expression copy(Expression expression) {
 				if (expression instanceof FilterFunction_strConcat) {
 					FilterFunction_strConcat strConcat = (FilterFunction_strConcat) expression;
-					
+
 					List<Expression> children = strConcat.getParameters();
 					List<Expression> correctedChildren = new ArrayList<Expression>();
 					for (Expression o : children) {
-						correctedChildren.add( copy(o));
+						correctedChildren.add(copy(o));
 					}
 					strConcat.setParameters(correctedChildren);
-					
-				} else
-				if (expression instanceof DivideImpl) {
+
+				} else if (expression instanceof DivideImpl) {
 					DivideImpl divFilter = (DivideImpl) expression;
 					divFilter.setExpression1(copy(divFilter.getExpression1()));
 					divFilter.setExpression2(copy(divFilter.getExpression2()));
@@ -2548,8 +2586,7 @@
 					DivideImpl divFilter = (DivideImpl) filter;
 					divFilter.setExpression1(copy(divFilter.getExpression1()));
 					divFilter.setExpression2(copy(divFilter.getExpression2()));
-				} else
-					if (filter instanceof IsNullImpl) {
+				} else if (filter instanceof IsNullImpl) {
 					IsNullImpl isNullFilter = (IsNullImpl) filter;
 					isNullFilter.setExpression1(copy(isNullFilter
 							.getExpression1()));

Added: trunk/src/skrueger/i8n/TranslationTool.java
===================================================================
--- trunk/src/skrueger/i8n/TranslationTool.java	2010-03-30 10:29:42 UTC (rev 779)
+++ trunk/src/skrueger/i8n/TranslationTool.java	2010-03-31 13:39:02 UTC (rev 780)
@@ -0,0 +1,97 @@
+package skrueger.i8n;
+/*******************************************************************************
+ * Copyright (c) 2010 Stefan A. Krüger (soon changing to Stefan A. Tzeggai).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the GNU Public License v2.0
+ * which accompanies this distribution, and is available at
+ * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+ * 
+ * Contributors:
+ *     Stefan A. Krüger (soon changing to Stefan A. Tzeggai) - initial API and implementation
+ ******************************************************************************/
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.HashMap;
+
+
+/**
+ * This tool helps to find missing frensh translations 
+ *
+ */
+public class TranslationTool {
+	
+	static File GPenglish = new File ("/home/stefan/EigeneDateien/code/atlas/trunk/Atlas-Framework/bin/skrueger/creator/resource/locales/Geopublisher.properties");
+	static File GPfrensh = new File ("/home/stefan/EigeneDateien/code/atlas/trunk/Atlas-Framework/bin/skrueger/creator/resource/locales/Geopublisher_fr.properties");
+	
+	static File ASenglish = new File ("/home/stefan/EigeneDateien/code/atlas/trunk/Atlas-Framework/src/skrueger/sld/resources/locales/AtlasStylerTranslation.properties");
+	static File ASfrensh = new File ("/home/stefan/EigeneDateien/code/atlas/trunk/Atlas-Framework/src/skrueger/sld/resources/locales/AtlasStylerTranslation_fr.properties");
+	
+	static File AVenglish = new File ("/home/stefan/EigeneDateien/code/atlas/trunk/Atlas-Framework/src/skrueger/atlas/resource/locales/AtlasViewerTranslation.properties");
+	static File AVfrensh = new File ("/home/stefan/EigeneDateien/code/atlas/trunk/Atlas-Framework/src/skrueger/atlas/resource/locales/AtlasViewerTranslation_fr.properties");
+	
+	
+	private static HashMap<String,String> frenshTranslations = new HashMap<String, String>();
+
+	/**
+	 * @param args
+	 * @throws IOException 
+	 */
+	public static void main(String[] args) throws IOException {
+		
+		
+		BufferedReader en_Reader; 
+		BufferedReader fr_Reader;
+		
+		int mode = 3;
+		
+		if (mode == 1) {
+			en_Reader = new BufferedReader(new FileReader(GPenglish));
+			fr_Reader = new BufferedReader(new FileReader(GPfrensh));
+		} else if (mode == 2) {
+			en_Reader = new BufferedReader(new FileReader(ASenglish));
+			fr_Reader = new BufferedReader(new FileReader(ASfrensh));
+		} else {
+			en_Reader = new BufferedReader(new FileReader(AVenglish));
+			fr_Reader = new BufferedReader(new FileReader(AVfrensh));
+		}
+		
+
+		// Read all frensh translations keys into a HashMap
+		String  readLine = "start";
+		while (readLine != null) {
+			readLine = fr_Reader.readLine();
+			if (readLine != null && !readLine.startsWith("#")) {
+				int indexOf = readLine.indexOf("=");
+				if (indexOf == -1) continue; 
+				String key =  readLine.substring(0,indexOf).trim();
+				String value =  readLine.substring(indexOf+1).trim();
+				frenshTranslations .put(key.trim(),value.trim());
+			}
+		}
+		
+		System.out.println(frenshTranslations.size()+" frensh imported");
+
+		readLine = "start";
+		int missing =0;
+		while (readLine != null) {
+			readLine = en_Reader.readLine();
+			
+			if (readLine != null && !readLine.startsWith("#")) {
+				int indexOf = readLine.indexOf("=");
+				if (indexOf == -1) continue;
+				String key =  readLine.substring(0,indexOf).trim();
+				String value =  readLine.substring(indexOf+1).trim();
+				if (!frenshTranslations.containsKey(key)) {
+					System.out.println("#"+key+"="+value+"\n");
+					missing++;
+				}
+			}
+		}
+		System.out.println("missing = "+missing);
+	}
+
+
+
+}


Property changes on: trunk/src/skrueger/i8n/TranslationTool.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Id URL
Name: svn:eol-style
   + native



More information about the Schmitzm-commits mailing list