Changeset 8260 in josm for trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss
- Timestamp:
- 2015-04-25T14:00:05+02:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSParser.jj
r8256 r8260 20 20 import org.openstreetmap.josm.gui.mappaint.mapcss.Expression; 21 21 import org.openstreetmap.josm.gui.mappaint.mapcss.ExpressionFactory; 22 import org.openstreetmap.josm.gui.mappaint.mapcss.ExpressionFactory.NullExpression; 22 23 import org.openstreetmap.josm.gui.mappaint.mapcss.Instruction; 23 24 import org.openstreetmap.josm.gui.mappaint.mapcss.LiteralExpression; … … 184 185 | < CARET: "^" > 185 186 | < FULLSTOP: "." > 187 | < DEG: "°" > 186 188 | < ELEMENT_OF: "∈" > 187 189 | < CROSSING: "⧉" > … … 1028 1030 fn=function() { return fn; } 1029 1031 | 1030 lit=literal() { return new LiteralExpression(lit); } 1032 lit=literal() 1033 { 1034 if (lit == null) 1035 return NullExpression.INSTANCE; 1036 return new LiteralExpression(lit); 1037 } 1031 1038 | 1032 1039 <LPAR> w() nested=expression() <RPAR> { return nested; } … … 1054 1061 String val, pref; 1055 1062 Token t; 1056 float f;1063 Float f; 1057 1064 } 1058 1065 { … … 1067 1074 <PLUS> f=ufloat() { return new Instruction.RelativeFloat(f); } 1068 1075 | 1076 LOOKAHEAD(2) 1077 f=ufloat_unit() { return f; } 1078 | 1069 1079 f=ufloat() { return f; } 1070 1080 | 1071 1081 t=<HEXCOLOR> { return ColorHelper.html2color(t.image); } 1082 } 1083 1084 /** 1085 * Number followed by a unit. 1086 * 1087 * Returns angles in radians and lengths in pixels. 1088 */ 1089 Float ufloat_unit() : 1090 { 1091 float f; 1092 String u; 1093 } 1094 { 1095 f=ufloat() ( u=ident() | <DEG> { u = "°"; } ) 1096 { 1097 Double m = unit_factor(u); 1098 if (m == null) 1099 return null; 1100 return (float) (f * m); 1101 } 1102 } 1103 1104 JAVACODE 1105 private Double unit_factor(String unit) { 1106 switch (unit) { 1107 case "deg": 1108 case "°": return Math.PI / 180; 1109 case "rad": return 1.; 1110 case "grad": return Math.PI / 200; 1111 case "turn": return 2 * Math.PI; 1112 case "px": return 1.; 1113 case "cm": return 96/2.54; 1114 case "mm": return 9.6/2.54; 1115 case "in": return 96.; 1116 case "q": return 2.4/2.54; 1117 case "pc": return 16.; 1118 case "pt": return 96./72; 1119 default: return null; 1120 } 1072 1121 } 1073 1122
Note:
See TracChangeset
for help on using the changeset viewer.