Index: /trunk/build.xml
===================================================================
--- /trunk/build.xml (revision 3855)
+++ /trunk/build.xml (revision 3856)
@@ -135,4 +135,14 @@
+
+
+
+
+
+
+
+
+
+
Index: /trunk/src/org/openstreetmap/josm/gui/mappaint/AreaElemStyle.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/mappaint/AreaElemStyle.java (revision 3855)
+++ /trunk/src/org/openstreetmap/josm/gui/mappaint/AreaElemStyle.java (revision 3856)
@@ -21,5 +21,5 @@
public static AreaElemStyle create(Cascade c) {
- Color color = c.getColor("fill-color", null);
+ Color color = c.get("fill-color", null, Color.class);
if (color == null)
return null;
Index: /trunk/src/org/openstreetmap/josm/gui/mappaint/Cascade.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/mappaint/Cascade.java (revision 3855)
+++ /trunk/src/org/openstreetmap/josm/gui/mappaint/Cascade.java (revision 3856)
@@ -5,4 +5,5 @@
import java.util.Arrays;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
@@ -26,5 +27,5 @@
* value, def otherwise
*/
- public T get(String key, T def, Class klass) {
+ public T get(String key, T def, Class klass) {
if (def != null && !klass.isInstance(def))
throw new IllegalArgumentException();
@@ -32,10 +33,10 @@
if (o == null)
return def;
- if (klass.isInstance(o)) {
- @SuppressWarnings("unchecked") T res = (T) klass.cast(o);
+ T res = convertTo(o, klass);
+ if (res == null) {
+ System.err.println(String.format("Warning: unable to convert property %s to type %s: found %s of type %s!", key, klass, o, o.getClass()));
+ return def;
+ } else
return res;
- }
- System.err.println(String.format("Warning: wrong type for mappaint property %s: %s expected, but %s of type %s found!", key, klass, o, o.getClass()));
- return def;
}
@@ -44,29 +45,84 @@
}
- public Float getFloat(String key, Float def) {
- Object o = prop.get(key);
+ @SuppressWarnings("unchecked")
+ public static T convertTo(Object o, Class klass) {
if (o == null)
- return def;
+ return null;
+ if (klass.isInstance(o))
+ return (T) o;
+
+ if (klass == float.class || klass == Float.class)
+ return (T) toFloat(o);
+
+ if (klass == double.class || klass == Double.class) {
+ o = toFloat(o);
+ if (o != null) {
+ o = new Double((Float) o);
+ }
+ return (T) o;
+ }
+
+ if (klass == boolean.class || klass == Boolean.class)
+ return (T) toBool(o);
+
+ if (klass == float[].class) {
+ return (T) toFloatArray(o);
+ }
+
+ if (klass == Color.class) {
+ return (T) toColor(o);
+ }
+ return null;
+ }
+
+ private static Float toFloat(Object o) {
if (o instanceof Float)
return (Float) o;
+ if (o instanceof Double)
+ return new Float((Double) o);
if (o instanceof Integer)
return new Float((Integer) o);
- return def;
+ if (o instanceof String) {
+ try {
+ float f = Float.parseFloat((String) o);
+ return f;
+ } catch (NumberFormatException e) {
+ }
+ }
+ return null;
}
- public Color getColor(String key, Color def) {
- Object o = prop.get(key);
- if (o == null)
- return def;
+ private static Boolean toBool(Object o) {
+ if (o instanceof Boolean)
+ return (Boolean) o;
+ if (o instanceof String)
+ return Boolean.parseBoolean((String) o);
+ return null;
+ }
+
+ private static float[] toFloatArray(Object o) {
+ if (o instanceof float[])
+ return (float[]) o;
+ if (o instanceof List) {
+ List l = (List) o;
+ float[] a = new float[l.size()];
+ for (int i=0; i 0) {
+ hasPositive = true;
+ }
+ if (f < 0) {
+ dashes = null;
+ break;
+ }
+ }
+ if (!hasPositive) {
+ dashes = null;
+ }
+ }
+ Color dashesBackground = c.get(prefix + "dashes-background-color", null, Color.class);
return new LineElemStyle(c, width, realWidth, color, dashes, dashesBackground);
Index: /trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Condition.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Condition.java (revision 3855)
+++ /trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Condition.java (revision 3856)
@@ -2,5 +2,4 @@
package org.openstreetmap.josm.gui.mappaint.mapcss;
-import org.openstreetmap.josm.data.osm.OsmPrimitive;
import org.openstreetmap.josm.data.osm.Relation;
import org.openstreetmap.josm.data.osm.Way;
@@ -9,5 +8,5 @@
abstract public class Condition {
- abstract public boolean applies(OsmPrimitive osm);
+ abstract public boolean applies(Environment e);
public static enum Op {EQ, NEQ}
@@ -27,10 +26,10 @@
@Override
- public boolean applies(OsmPrimitive osm) {
+ public boolean applies(Environment e) {
switch (op) {
case EQ:
- return Utils.equal(osm.get(k), v);
+ return Utils.equal(e.osm.get(k), v);
case NEQ:
- return !Utils.equal(osm.get(k), v);
+ return !Utils.equal(e.osm.get(k), v);
default:
throw new AssertionError();
@@ -55,6 +54,6 @@
@Override
- public boolean applies(OsmPrimitive osm) {
- return osm.hasKey(k) ^ not;
+ public boolean applies(Environment e) {
+ return e.osm.hasKey(k) ^ not;
}
@@ -76,9 +75,9 @@
@Override
- public boolean applies(OsmPrimitive osm) {
+ public boolean applies(Environment e) {
if ("closed".equals(id)) {
- if (osm instanceof Way && ((Way) osm).isClosed())
+ if (e.osm instanceof Way && ((Way) e.osm).isClosed())
return true;
- if (osm instanceof Relation && ((Relation) osm).isMultipolygon())
+ if (e.osm instanceof Relation && ((Relation) e.osm).isMultipolygon())
return true;
return false;
@@ -92,4 +91,26 @@
}
}
+
+ public static class ExpressionCondition extends Condition {
+
+ private Expression e;
+
+ public ExpressionCondition(Expression e) {
+ this.e = e;
+ }
+
+ @Override
+ public boolean applies(Environment env) {
+ Object o = e.evaluate(env);
+ if (o instanceof Boolean)
+ return (Boolean) o;
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return "[" + e + "]";
+ }
+ }
}
Index: /trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Expression.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Expression.java (revision 3855)
+++ /trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Expression.java (revision 3856)
@@ -2,7 +2,16 @@
package org.openstreetmap.josm.gui.mappaint.mapcss;
+import java.awt.Color;
+import java.lang.reflect.Array;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.actions.search.SearchCompiler;
+import org.openstreetmap.josm.actions.search.SearchCompiler.Match;
+import org.openstreetmap.josm.actions.search.SearchCompiler.ParseError;
import org.openstreetmap.josm.gui.mappaint.Cascade;
import org.openstreetmap.josm.tools.Utils;
@@ -43,53 +52,209 @@
}
- @Override
- public Object evaluate(Environment env) {
- if (name.equals("eval")) {
- if (args.size() != 1) {
+ public static class EvalFunctions {
+ Environment env;
+
+ public Object eval(Object o) {
+ return o;
+ }
+
+ public static float plus(float... args) {
+ float res = 0;
+ for (float f : args) {
+ res += f;
+ }
+ return res;
+ }
+
+ public Float minus(float... args) {
+ if (args.length == 0)
+ return 0f;
+ float res = args[0];
+ for (int i=1; i allMethods = new ArrayList();
+ allMethods.addAll(Arrays.asList(customMethods));
+ try {
+ allMethods.add(Math.class.getMethod("abs", float.class));
+ allMethods.add(Math.class.getMethod("acos", double.class));
+ allMethods.add(Math.class.getMethod("asin", double.class));
+ allMethods.add(Math.class.getMethod("atan", double.class));
+ allMethods.add(Math.class.getMethod("atan2", double.class, double.class));
+ allMethods.add(Math.class.getMethod("ceil", double.class));
+ allMethods.add(Math.class.getMethod("cos", double.class));
+ allMethods.add(Math.class.getMethod("cosh", double.class));
+ allMethods.add(Math.class.getMethod("exp", double.class));
+ allMethods.add(Math.class.getMethod("floor", double.class));
+ allMethods.add(Math.class.getMethod("log", double.class));
+ allMethods.add(Math.class.getMethod("max", float.class, float.class));
+ allMethods.add(Math.class.getMethod("min", float.class, float.class));
+ allMethods.add(Math.class.getMethod("random"));
+ allMethods.add(Math.class.getMethod("round", float.class));
+ allMethods.add(Math.class.getMethod("signum", double.class));
+ allMethods.add(Math.class.getMethod("sin", double.class));
+ allMethods.add(Math.class.getMethod("sinh", double.class));
+ allMethods.add(Math.class.getMethod("sqrt", double.class));
+ allMethods.add(Math.class.getMethod("tan", double.class));
+ allMethods.add(Math.class.getMethod("tanh", double.class));
+ } catch (NoSuchMethodException ex) {
+ throw new RuntimeException(ex);
+ } catch (SecurityException ex) {
+ throw new RuntimeException(ex);
+ }
+ for (Method m : allMethods) {
+ if (!m.getName().equals(name))
+ continue;
+ Class>[] expectedParameterTypes = m.getParameterTypes();
+ Object[] convertedArgs = new Object[expectedParameterTypes.length];
+
+ if (expectedParameterTypes.length == 1 && expectedParameterTypes[0].isArray())
+ {
+ Class> arrayComponentType = expectedParameterTypes[0].getComponentType();
+ Object arrayArg = Array.newInstance(arrayComponentType, args.size());
+ for (int i=0; i entry : mc.entrySet()) {
- Environment env = new Environment(osm, mc, entry.getKey());
+ env.layer = entry.getKey();
for (Instruction i : r.declaration) {
i.execute(env);
@@ -138,5 +139,5 @@
}
} else {
- Environment env = new Environment(osm, mc, sub);
+ env.layer = sub;
for (Instruction i : r.declaration) {
i.execute(env);
Index: /trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Selector.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Selector.java (revision 3855)
+++ /trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Selector.java (revision 3856)
@@ -34,9 +34,9 @@
}
- public boolean applies(OsmPrimitive osm) {
- if (!baseApplies(osm))
+ public boolean applies(Environment e) {
+ if (!baseApplies(e.osm))
return false;
for (Condition c : conds) {
- if (!c.applies(osm))
+ if (!c.applies(e))
return false;
}
Index: /trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/parser/MapCSSParser.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/parser/MapCSSParser.java (revision 3855)
+++ /trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/parser/MapCSSParser.java (revision 3856)
@@ -33,7 +33,7 @@
* | | |
* zoom condition instruction
- *
+ *
* more general:
- *
+ *
* way|z13-[a=b][c=d]::subpart, way|z-3[u=v]:closed::subpart2 { p1 : val; p2 : val; }
*
@@ -141,5 +141,5 @@
* comma delimited list of floats (at least 2, all >= 0)
*/
- final public float[] float_array() throws ParseException {
+ final public List float_array() throws ParseException {
float f;
List fs = new ArrayList();
@@ -161,9 +161,5 @@
}
}
- float[] a = new float[fs.size()];
- for (int i=0; i= 0) {
la1tokens[jj_kind] = true;
jj_kind = -1;
}
- for (int i = 0; i < 32; i++) {
+ for (int i = 0; i < 35; i++) {
if (jj_la1[i] == jj_gen) {
for (int j = 0; j < 32; j++) {
@@ -986,8 +1167,11 @@
la1tokens[j] = true;
}
+ if ((jj_la1_1[i] & (1<
| < COMMA: "," >
+| < PIPE: "|" >
| < PIPE_Z: "|z" >
| < PLUS: "+" >
| < MINUS: "-" >
+| < AMPERSAND: "&" >
+| < QUESTION: "?" >
| < COMMENT_START: "/*" > : COMMENT
| < UNEXPECTED_CHAR : ~[] > // avoid TokenMgrErrors because they are hard to recover from
@@ -157,5 +160,5 @@
* comma delimited list of floats (at least 2, all >= 0)
*/
-float[] float_array() :
+List float_array() :
{
float f;
@@ -169,9 +172,5 @@
)+
{
- float[] a = new float[fs.size()];
- for (int i=0; i
+ (
+ LOOKAHEAD(2)
+ ( c=simple_key_condition() { return c; } )
+ |
+ LOOKAHEAD(3)
+ c=simple_key_value_condition()
+ |
+ e=expression() { c = new Condition.ExpressionCondition(e); }
+ )
+
+ { return c; }
+}
+
+Condition simple_key_condition() :
+{
+ boolean not = false;
+ String key;
+}
+{
+ ( { not = true; } )?
+ key=string_or_ident()
+ { return new Condition.KeyCondition(key, not); }
+}
+
+Condition simple_key_value_condition() :
+{
boolean not = false;
String key;
@@ -244,15 +274,8 @@
}
{
-
- ( { not = true; } )?
key=string_or_ident()
- (
- ( { not = true; } | )
- val=string_or_ident()
-
- { return new Condition.KeyValueCondition(key, val, not ? Condition.Op.NEQ : Condition.Op.EQ); }
- )?
-
- { return new Condition.KeyCondition(key, not); }
+ ( { not = true; } | )
+ val=string_or_ident()
+ { return new Condition.KeyValueCondition(key, val, not ? Condition.Op.NEQ : Condition.Op.EQ); }
}
@@ -331,14 +354,20 @@
e=primary() { args.add(e); } w()
(
- ( { op = "+"; } w() e=primary() { args.add(e); } w() )+
- |
- ( { op = "*"; } w() e=primary() { args.add(e); } w() )+
- |
- ( { op = "-"; } w() e=primary() { args.add(e); } w() )
- |
- ( { op = "/"; } w() e=primary() { args.add(e); } w() )
+ ( { op = "plus"; } w() e=primary() { args.add(e); } w() )+
+ |
+ ( { op = "times"; } w() e=primary() { args.add(e); } w() )+
+ |
+ ( { op = "minus"; } w() e=primary() { args.add(e); } w() )+
+ |
+ ( { op = "divided_by"; } w() e=primary() { args.add(e); } w() )+
+ |
+ ( { op = "and"; } w() e=primary() { args.add(e); } w() )
+ |
+ ( { op = "or"; } w() e=primary() { args.add(e); } w() )
+ |
+ ( { op = "cond"; } w() e=primary() { args.add(e); } w() w() e=primary() { args.add(e); } w() )
)?
{
- if (args.size() == 1)
+ if (op == null)
return args.get(0);
return new FunctionExpression(op, args);
@@ -371,6 +400,8 @@
tmp= { name = tmp.image; } w()
w()
- arg=expression() { args.add(arg); }
- ( w() arg=expression() { args.add(arg); } )*
+ (
+ arg=expression() { args.add(arg); }
+ ( w() arg=expression() { args.add(arg); } )*
+ )?
{ return new FunctionExpression(name, args); }
Index: /trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/parser/MapCSSParserConstants.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/parser/MapCSSParserConstants.java (revision 3855)
+++ /trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/parser/MapCSSParserConstants.java (revision 3856)
@@ -56,15 +56,21 @@
int COMMA = 22;
/** RegularExpression Id. */
- int PIPE_Z = 23;
+ int PIPE = 23;
/** RegularExpression Id. */
- int PLUS = 24;
+ int PIPE_Z = 24;
/** RegularExpression Id. */
- int MINUS = 25;
+ int PLUS = 25;
/** RegularExpression Id. */
- int COMMENT_START = 26;
+ int MINUS = 26;
/** RegularExpression Id. */
- int UNEXPECTED_CHAR = 27;
+ int AMPERSAND = 27;
/** RegularExpression Id. */
- int COMMENT_END = 28;
+ int QUESTION = 28;
+ /** RegularExpression Id. */
+ int COMMENT_START = 29;
+ /** RegularExpression Id. */
+ int UNEXPECTED_CHAR = 30;
+ /** RegularExpression Id. */
+ int COMMENT_END = 31;
/** Lexical state. */
@@ -98,11 +104,14 @@
"\";\"",
"\",\"",
+ "\"|\"",
"\"|z\"",
"\"+\"",
"\"-\"",
+ "\"&\"",
+ "\"?\"",
"\"/*\"",
"",
"\"*/\"",
- "",
+ "",
};
Index: /trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/parser/MapCSSParserTokenManager.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/parser/MapCSSParserTokenManager.java (revision 3855)
+++ /trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/parser/MapCSSParserTokenManager.java (revision 3856)
@@ -47,4 +47,6 @@
jjmatchedKind = 17;
return jjMoveStringLiteralDfa1_0(0x40000L);
+ case 38:
+ return jjStopAtPos(0, 27);
case 40:
return jjStopAtPos(0, 14);
@@ -54,12 +56,12 @@
return jjStopAtPos(0, 8);
case 43:
- return jjStopAtPos(0, 24);
+ return jjStopAtPos(0, 25);
case 44:
return jjStopAtPos(0, 22);
case 45:
- return jjStopAtPos(0, 25);
+ return jjStopAtPos(0, 26);
case 47:
jjmatchedKind = 9;
- return jjMoveStringLiteralDfa1_0(0x4000000L);
+ return jjMoveStringLiteralDfa1_0(0x20000000L);
case 58:
jjmatchedKind = 19;
@@ -69,4 +71,6 @@
case 61:
return jjStopAtPos(0, 16);
+ case 63:
+ return jjStopAtPos(0, 28);
case 91:
return jjStopAtPos(0, 12);
@@ -76,5 +80,6 @@
return jjStopAtPos(0, 10);
case 124:
- return jjMoveStringLiteralDfa1_0(0x800000L);
+ jjmatchedKind = 23;
+ return jjMoveStringLiteralDfa1_0(0x1000000L);
case 125:
return jjStopAtPos(0, 11);
@@ -93,6 +98,6 @@
{
case 42:
- if ((active0 & 0x4000000L) != 0L)
- return jjStopAtPos(1, 26);
+ if ((active0 & 0x20000000L) != 0L)
+ return jjStopAtPos(1, 29);
break;
case 58:
@@ -105,6 +110,6 @@
break;
case 122:
- if ((active0 & 0x800000L) != 0L)
- return jjStopAtPos(1, 23);
+ if ((active0 & 0x1000000L) != 0L)
+ return jjStopAtPos(1, 24);
break;
default :
@@ -346,5 +351,5 @@
{
case 42:
- return jjMoveStringLiteralDfa1_1(0x10000000L);
+ return jjMoveStringLiteralDfa1_1(0x80000000L);
default :
return 1;
@@ -360,6 +365,6 @@
{
case 47:
- if ((active0 & 0x10000000L) != 0L)
- return jjStopAtPos(1, 28);
+ if ((active0 & 0x80000000L) != 0L)
+ return jjStopAtPos(1, 31);
break;
default :
@@ -388,5 +393,5 @@
"", null, null, null, null, null, null, null, "\52", "\57", "\173", "\175",
"\133", "\135", "\50", "\51", "\75", "\41", "\41\75", "\72", "\72\72", "\73", "\54",
-"\174\172", "\53", "\55", "\57\52", null, "\52\57", null, };
+"\174", "\174\172", "\53", "\55", "\46", "\77", "\57\52", null, "\52\57", null, };
/** Lexer state names. */
@@ -399,11 +404,11 @@
public static final int[] jjnewLexState = {
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, 1, -1, 0, -1,
+ -1, -1, -1, -1, 1, -1, 0, -1,
};
static final long[] jjtoToken = {
- 0x1fffffdfL,
+ 0xffffffdfL,
};
static final long[] jjtoSkip = {
- 0x20000000L,
+ 0x100000000L,
};
protected SimpleCharStream input_stream;
@@ -513,7 +518,7 @@
jjmatchedPos = 0;
curPos = jjMoveStringLiteralDfa0_0();
- if (jjmatchedPos == 0 && jjmatchedKind > 27)
+ if (jjmatchedPos == 0 && jjmatchedKind > 30)
{
- jjmatchedKind = 27;
+ jjmatchedKind = 30;
}
break;
@@ -522,7 +527,7 @@
jjmatchedPos = 0;
curPos = jjMoveStringLiteralDfa0_1();
- if (jjmatchedPos == 0 && jjmatchedKind > 29)
+ if (jjmatchedPos == 0 && jjmatchedKind > 32)
{
- jjmatchedKind = 29;
+ jjmatchedKind = 32;
}
break;
Index: /trunk/src/org/openstreetmap/josm/gui/mappaint/xml/LinePrototype.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/mappaint/xml/LinePrototype.java (revision 3855)
+++ /trunk/src/org/openstreetmap/josm/gui/mappaint/xml/LinePrototype.java (revision 3856)
@@ -3,4 +3,5 @@
import java.awt.Color;
+import java.util.List;
import org.openstreetmap.josm.data.osm.visitor.paint.MapPaintSettings;
@@ -14,5 +15,5 @@
public Integer realWidth; // the real width of this line in meter
public Color color;
- protected float[] dashed;
+ protected List dashed;
public Color dashedColor;
@@ -41,21 +42,27 @@
}
- public float[] getDashed() {
+ public List getDashed() {
return dashed;
}
- public void setDashed(float[] dashed) {
- if (dashed == null || dashed.length == 0) {
- this.dashed = dashed;
+ public void setDashed(List dashed) {
+ if (dashed == null || dashed.isEmpty()) {
+ this.dashed = null;
return;
}
boolean found = false;
- for (int i=0; i 0) {
+ for (Float f : dashed) {
+ if (f == null) {
+ this.dashed = null;
+ return;
+ }
+ if (f > 0) {
found = true;
}
- if (dashed[i] < 0) {
- System.out.println(I18n.tr("Illegal dash pattern, values must be positive"));
+ if (f < 0) {
+ System.err.println(I18n.tr("Illegal dash pattern, values must be positive"));
+ this.dashed = null;
+ return;
}
}
@@ -63,5 +70,5 @@
this.dashed = dashed;
} else {
- System.out.println(I18n.tr("Illegal dash pattern, at least one value must be > 0"));
+ System.err.println(I18n.tr("Illegal dash pattern, at least one value must be > 0"));
}
}
Index: /trunk/src/org/openstreetmap/josm/gui/mappaint/xml/XmlStyleSource.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/mappaint/xml/XmlStyleSource.java (revision 3855)
+++ /trunk/src/org/openstreetmap/josm/gui/mappaint/xml/XmlStyleSource.java (revision 3856)
@@ -303,5 +303,5 @@
def.putOrClear("dashes-background-color", p.line.dashedColor);
}
- Float refWidth = def.getFloat("width", null);
+ Float refWidth = def.get("width", null, Float.class);
if (refWidth != null && p.linemods != null) {
int numOver = 0, numUnder = 0;
Index: /trunk/src/org/openstreetmap/josm/gui/mappaint/xml/XmlStyleSourceHandler.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/mappaint/xml/XmlStyleSourceHandler.java (revision 3855)
+++ /trunk/src/org/openstreetmap/josm/gui/mappaint/xml/XmlStyleSourceHandler.java (revision 3856)
@@ -3,4 +3,5 @@
import java.awt.Color;
+import java.util.Arrays;
import java.util.Collection;
import java.util.LinkedList;
@@ -91,20 +92,20 @@
line.realWidth=Integer.parseInt(atts.getValue(count));
} else if (atts.getQName(count).equals("dashed")) {
- float[] dashed;
+ Float[] dashed;
try {
String[] parts = atts.getValue(count).split(",");
- dashed = new float[parts.length];
+ dashed = new Float[parts.length];
for (int i = 0; i < parts.length; i++) {
- dashed[i] = (Integer.parseInt(parts[i]));
+ dashed[i] = (float) Integer.parseInt(parts[i]);
}
} catch (NumberFormatException nfe) {
boolean isDashed = Boolean.parseBoolean(atts.getValue(count));
if(isDashed) {
- dashed = new float[]{9};
+ dashed = new Float[]{9f};
} else {
dashed = null;
}
}
- line.setDashed(dashed);
+ line.setDashed(dashed == null ? null : Arrays.asList(dashed));
} else if (atts.getQName(count).equals("dashedcolour")) {
line.dashedColor=convertColor(atts.getValue(count));