Revision 45739 trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.api/src/main/java/org/gvsig/expressionevaluator/ExpressionUtils.java
ExpressionUtils.java | ||
---|---|---|
13 | 13 |
import static org.gvsig.expressionevaluator.ExpressionEvaluatorManager.DYNAMICTEXT_ENDTAG; |
14 | 14 |
import static org.gvsig.expressionevaluator.ExpressionEvaluatorManager.DYNAMICTEXT_STARTTAG; |
15 | 15 |
import org.gvsig.expressionevaluator.spi.DynObjectSymbolTable; |
16 |
import org.gvsig.tools.dataTypes.DataTypeUtils; |
|
16 | 17 |
import org.gvsig.tools.dynobject.DynObject; |
17 | 18 |
import org.gvsig.tools.util.ListBuilder; |
18 | 19 |
|
... | ... | |
174 | 175 |
} |
175 | 176 |
|
176 | 177 |
public static MutableSymbolTable createSymbolTable(DynObject obj) { |
177 |
DynObjectSymbolTable symbolTable = new DynObjectSymbolTable(obj); |
|
178 |
DynObjectSymbolTable symbolTable = new DynObjectSymbolTable("object",obj);
|
|
178 | 179 |
return symbolTable; |
179 | 180 |
} |
180 | 181 |
|
182 |
public static MutableSymbolTable createSymbolTable(String name, DynObject obj) { |
|
183 |
DynObjectSymbolTable symbolTable = new DynObjectSymbolTable(name, obj); |
|
184 |
return symbolTable; |
|
185 |
} |
|
186 |
|
|
181 | 187 |
public static String surroundByDynamicTextTag(String source) { |
182 | 188 |
return surroundByDynamicTextTag(source, true); |
183 | 189 |
} |
... | ... | |
498 | 504 |
return defaultValue; |
499 | 505 |
} |
500 | 506 |
|
501 |
private static final Pattern COLOR_PATTERN3 = Pattern.compile("COLOR[(][ ]*(?<R>[0-9]{1,3})[ ]*,[ ]*(?<G>[0-9]{1,3})[ ]*,[ ]*(?<A>[0-9]{1,3})[ ]*[)]", Pattern.CASE_INSENSITIVE);
|
|
507 |
private static final Pattern COLOR_PATTERN3 = Pattern.compile("COLOR[(][ ]*(?<R>[0-9]{1,3})[ ]*,[ ]*(?<G>[0-9]{1,3})[ ]*,[ ]*(?<B>[0-9]{1,3})[ ]*[)]", Pattern.CASE_INSENSITIVE);
|
|
502 | 508 |
private static final Pattern COLOR_PATTERN4 = Pattern.compile("COLOR[(][ ]*(?<R>[0-9]{1,3})[ ]*,[ ]*(?<G>[0-9]{1,3})[ ]*,[ ]*(?<B>[0-9]{1,3})[ ]*,[ ]*(?<A>[0-9]{1,3})[ ]*[)]", Pattern.CASE_INSENSITIVE); |
503 | 509 |
|
504 | 510 |
public static Color parseColor(SymbolTable symbolTable, String expression, Color defaultValue) { |
... | ... | |
506 | 512 |
return defaultValue; |
507 | 513 |
} |
508 | 514 |
try { |
515 |
Color color; |
|
509 | 516 |
if( StringUtils.startsWithIgnoreCase(expression, "color(") && |
510 | 517 |
StringUtils.endsWithIgnoreCase(expression, ")")) { |
511 | 518 |
Matcher m = COLOR_PATTERN4.matcher(expression); |
512 | 519 |
if( m != null && m.matches()) { |
513 |
Color color = new Color(
|
|
520 |
color = new Color( |
|
514 | 521 |
Integer.valueOf(m.group("R")), |
515 | 522 |
Integer.valueOf(m.group("G")), |
516 | 523 |
Integer.valueOf(m.group("B")), |
... | ... | |
520 | 527 |
} |
521 | 528 |
m = COLOR_PATTERN3.matcher(expression); |
522 | 529 |
if( m != null && m.matches()) { |
523 |
Color color = new Color(
|
|
530 |
color = new Color( |
|
524 | 531 |
Integer.valueOf(m.group("R")), |
525 | 532 |
Integer.valueOf(m.group("G")), |
526 |
Integer.valueOf(m.group("B")), |
|
527 |
Integer.valueOf(m.group("A")) |
|
533 |
Integer.valueOf(m.group("B")) |
|
528 | 534 |
); |
529 | 535 |
return color; |
530 | 536 |
} |
... | ... | |
535 | 541 |
if( x instanceof Color ) { |
536 | 542 |
return (Color) x; |
537 | 543 |
} |
538 |
if( x instanceof Number ) { |
|
539 |
return new Color(((Number) x).intValue()); |
|
544 |
color = (Color) DataTypeUtils.coerce(DataTypes.COLOR, expression, null); |
|
545 |
if( color != null ) { |
|
546 |
return color; |
|
540 | 547 |
} |
541 | 548 |
} catch(Exception ex) { |
542 | 549 |
} |
Also available in: Unified diff