Changeset 30036 in osm for applications/editors/josm/plugins/smed2/src/seamap/Renderer.java
- Timestamp:
- 2013-11-02T17:09:51+01:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/smed2/src/seamap/Renderer.java
r30033 r30036 28 28 public class Renderer { 29 29 30 public static final EnumMap<ColCOL, Color> bodyColours = new EnumMap<ColCOL, Color>(ColCOL.class);31 static {32 bodyColours.put(ColCOL.COL_UNK, new Color(0, true));33 bodyColours.put(ColCOL.COL_WHT, new Color(0xffffff));34 bodyColours.put(ColCOL.COL_BLK, new Color(0x000000));35 bodyColours.put(ColCOL.COL_RED, new Color(0xd40000));36 bodyColours.put(ColCOL.COL_GRN, new Color(0x00d400));37 bodyColours.put(ColCOL.COL_BLU, Color.blue);38 bodyColours.put(ColCOL.COL_YEL, new Color(0xffd400));39 bodyColours.put(ColCOL.COL_GRY, Color.gray);40 bodyColours.put(ColCOL.COL_BRN, new Color(0x8b4513));41 bodyColours.put(ColCOL.COL_AMB, new Color(0xfbf00f));42 bodyColours.put(ColCOL.COL_VIO, new Color(0xee82ee));43 bodyColours.put(ColCOL.COL_ORG, Color.orange);44 bodyColours.put(ColCOL.COL_MAG, new Color(0xf000f0));45 bodyColours.put(ColCOL.COL_PNK, Color.pink);46 }47 48 public static final EnumMap<ColPAT, Patt> pattMap = new EnumMap<ColPAT, Patt>(ColPAT.class);49 static {50 pattMap.put(ColPAT.PAT_UNKN, Patt.Z);51 pattMap.put(ColPAT.PAT_HORI, Patt.H);52 pattMap.put(ColPAT.PAT_VERT, Patt.V);53 pattMap.put(ColPAT.PAT_DIAG, Patt.D);54 pattMap.put(ColPAT.PAT_BRDR, Patt.B);55 pattMap.put(ColPAT.PAT_SQUR, Patt.S);56 pattMap.put(ColPAT.PAT_CROS, Patt.C);57 pattMap.put(ColPAT.PAT_SALT, Patt.X);58 pattMap.put(ColPAT.PAT_STRP, Patt.H);59 }60 61 30 public static final double symbolScale[] = { 256.0, 128.0, 64.0, 32.0, 16.0, 8.0, 4.0, 2.0, 1.0, 0.61, 0.372, 0.227, 0.138, 0.0843, 0.0514, 0.0313, 0.0191, 0.0117, 0.007, 0.138 }; 62 31 … … 83 52 } 84 53 85 public static AttMap getAtts(Feature feature, Obj obj, int idx) { 86 HashMap<Integer, AttMap> objs = feature.objs.get(obj); 87 if (objs == null) 88 return null; 89 else 90 return objs.get(idx); 91 } 92 93 public static Object getAttVal(Feature feature, Obj obj, int idx, Att att) { 94 AttMap atts = getAtts(feature, obj, idx); 95 if (atts == null) 96 return S57val.nullVal(att); 97 else { 98 AttItem item = atts.get(att); 99 if (item == null) 100 return S57val.nullVal(att); 101 return item.val; 102 } 103 } 104 105 public static void symbol(Feature feature, Symbol symbol, Obj obj, Scheme scheme, Delta delta) { 106 Point2D point = context.getPoint(feature.centre); 107 if (obj == null) { 108 Symbols.drawSymbol(g2, symbol, sScale, point.getX(), point.getY(), scheme, delta); 109 } else { 110 ArrayList<Color> colours = new ArrayList<Color>(); 111 for (ColCOL col : (ArrayList<ColCOL>)getAttVal(feature, obj, 0, Att.COLOUR)) { 112 colours.add(bodyColours.get(col)); 113 } 114 ArrayList<Patt> patterns = new ArrayList<Patt>(); 115 for(ColPAT pat: (ArrayList<ColPAT>) getAttVal(feature, obj, 0, Att.COLPAT)) { 116 patterns.add(pattMap.get(pat)); 117 } 118 Symbols.drawSymbol(g2, symbol, sScale, point.getX(), point.getY(), new Scheme(patterns, colours), delta); 119 } 54 public static void symbol(Feature feature, Symbol symbol) { 55 Point2D point = context.getPoint(feature.centre); 56 Symbols.drawSymbol(g2, symbol, sScale, point.getX(), point.getY(), null, null); 57 } 58 59 public static void symbol(Feature feature, Symbol symbol, Scheme scheme) { 60 Point2D point = context.getPoint(feature.centre); 61 Symbols.drawSymbol(g2, symbol, sScale, point.getX(), point.getY(), scheme, null); 62 } 63 64 public static void symbol(Feature feature, Symbol symbol, Delta delta) { 65 Point2D point = context.getPoint(feature.centre); 66 Symbols.drawSymbol(g2, symbol, sScale, point.getX(), point.getY(), null, delta); 67 } 68 69 public static void symbol(Feature feature, Symbol symbol, Scheme scheme, Delta delta) { 70 Point2D point = context.getPoint(feature.centre); 71 Symbols.drawSymbol(g2, symbol, sScale, point.getX(), point.getY(), scheme, delta); 120 72 } 121 73 … … 133 85 switch (symbols.size()) { 134 86 case 1: 135 symbol(feature, symbols.get(0), n ull, null, new Delta(Handle.CC, new AffineTransform()));87 symbol(feature, symbols.get(0), new Delta(Handle.CC, new AffineTransform())); 136 88 break; 137 89 case 2: 138 symbol(feature, symbols.get(0), n ull, null, new Delta(Handle.RC, new AffineTransform()));139 symbol(feature, symbols.get(1), n ull, null, new Delta(Handle.LC, new AffineTransform()));90 symbol(feature, symbols.get(0), new Delta(Handle.RC, new AffineTransform())); 91 symbol(feature, symbols.get(1), new Delta(Handle.LC, new AffineTransform())); 140 92 break; 141 93 case 3: 142 symbol(feature, symbols.get(0), n ull, null, new Delta(Handle.BC, new AffineTransform()));143 symbol(feature, symbols.get(1), n ull, null, new Delta(Handle.TR, new AffineTransform()));144 symbol(feature, symbols.get(2), n ull, null, new Delta(Handle.TL, new AffineTransform()));94 symbol(feature, symbols.get(0), new Delta(Handle.BC, new AffineTransform())); 95 symbol(feature, symbols.get(1), new Delta(Handle.TR, new AffineTransform())); 96 symbol(feature, symbols.get(2), new Delta(Handle.TL, new AffineTransform())); 145 97 break; 146 98 case 4: 147 symbol(feature, symbols.get(0), n ull, null, new Delta(Handle.BR, new AffineTransform()));148 symbol(feature, symbols.get(1), n ull, null, new Delta(Handle.BL, new AffineTransform()));149 symbol(feature, symbols.get(2), n ull, null, new Delta(Handle.TR, new AffineTransform()));150 symbol(feature, symbols.get(3), n ull, null, new Delta(Handle.TL, new AffineTransform()));99 symbol(feature, symbols.get(0), new Delta(Handle.BR, new AffineTransform())); 100 symbol(feature, symbols.get(1), new Delta(Handle.BL, new AffineTransform())); 101 symbol(feature, symbols.get(2), new Delta(Handle.TR, new AffineTransform())); 102 symbol(feature, symbols.get(3), new Delta(Handle.TL, new AffineTransform())); 151 103 break; 152 104 case 5: 153 symbol(feature, symbols.get(0), n ull, null, new Delta(Handle.BR, new AffineTransform()));154 symbol(feature, symbols.get(1), n ull, null, new Delta(Handle.BL, new AffineTransform()));155 symbol(feature, symbols.get(2), n ull, null, new Delta(Handle.TR, AffineTransform.getTranslateInstance(-bbox.width/2, 0)));156 symbol(feature, symbols.get(3), n ull, null, new Delta(Handle.TC, new AffineTransform()));157 symbol(feature, symbols.get(4), n ull, null, new Delta(Handle.TL, AffineTransform.getTranslateInstance(bbox.width/2, 0)));105 symbol(feature, symbols.get(0), new Delta(Handle.BR, new AffineTransform())); 106 symbol(feature, symbols.get(1), new Delta(Handle.BL, new AffineTransform())); 107 symbol(feature, symbols.get(2), new Delta(Handle.TR, AffineTransform.getTranslateInstance(-bbox.width/2, 0))); 108 symbol(feature, symbols.get(3), new Delta(Handle.TC, new AffineTransform())); 109 symbol(feature, symbols.get(4), new Delta(Handle.TL, AffineTransform.getTranslateInstance(bbox.width/2, 0))); 158 110 break; 159 111 case 6: 160 symbol(feature, symbols.get(0), n ull, null, new Delta(Handle.BR, AffineTransform.getTranslateInstance(-bbox.width/2, 0)));161 symbol(feature, symbols.get(1), n ull, null, new Delta(Handle.BC, new AffineTransform()));162 symbol(feature, symbols.get(2), n ull, null, new Delta(Handle.BL, AffineTransform.getTranslateInstance(bbox.width/2, 0)));163 symbol(feature, symbols.get(3), n ull, null, new Delta(Handle.TR, AffineTransform.getTranslateInstance(-bbox.width/2, 0)));164 symbol(feature, symbols.get(4), n ull, null, new Delta(Handle.TC, new AffineTransform()));165 symbol(feature, symbols.get(5), n ull, null, new Delta(Handle.TL, AffineTransform.getTranslateInstance(bbox.width/2, 0)));112 symbol(feature, symbols.get(0), new Delta(Handle.BR, AffineTransform.getTranslateInstance(-bbox.width/2, 0))); 113 symbol(feature, symbols.get(1), new Delta(Handle.BC, new AffineTransform())); 114 symbol(feature, symbols.get(2), new Delta(Handle.BL, AffineTransform.getTranslateInstance(bbox.width/2, 0))); 115 symbol(feature, symbols.get(3), new Delta(Handle.TR, AffineTransform.getTranslateInstance(-bbox.width/2, 0))); 116 symbol(feature, symbols.get(4), new Delta(Handle.TC, new AffineTransform())); 117 symbol(feature, symbols.get(5), new Delta(Handle.TL, AffineTransform.getTranslateInstance(bbox.width/2, 0))); 166 118 break; 167 119 case 7: 168 symbol(feature, symbols.get(0), n ull, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -bbox.height/2)));169 symbol(feature, symbols.get(1), n ull, null, new Delta(Handle.RC, AffineTransform.getTranslateInstance(-bbox.width/2, 0)));170 symbol(feature, symbols.get(2), n ull, null, new Delta(Handle.CC, new AffineTransform()));171 symbol(feature, symbols.get(3), n ull, null, new Delta(Handle.LC, AffineTransform.getTranslateInstance(bbox.width/2, 0)));172 symbol(feature, symbols.get(4), n ull, null, new Delta(Handle.TR, AffineTransform.getTranslateInstance(-bbox.width/2, bbox.height/2)));173 symbol(feature, symbols.get(5), n ull, null, new Delta(Handle.TC, AffineTransform.getTranslateInstance(0, bbox.height/2)));174 symbol(feature, symbols.get(6), n ull, null, new Delta(Handle.TL, AffineTransform.getTranslateInstance(bbox.width/2, bbox.height/2)));120 symbol(feature, symbols.get(0), new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -bbox.height/2))); 121 symbol(feature, symbols.get(1), new Delta(Handle.RC, AffineTransform.getTranslateInstance(-bbox.width/2, 0))); 122 symbol(feature, symbols.get(2), new Delta(Handle.CC, new AffineTransform())); 123 symbol(feature, symbols.get(3), new Delta(Handle.LC, AffineTransform.getTranslateInstance(bbox.width/2, 0))); 124 symbol(feature, symbols.get(4), new Delta(Handle.TR, AffineTransform.getTranslateInstance(-bbox.width/2, bbox.height/2))); 125 symbol(feature, symbols.get(5), new Delta(Handle.TC, AffineTransform.getTranslateInstance(0, bbox.height/2))); 126 symbol(feature, symbols.get(6), new Delta(Handle.TL, AffineTransform.getTranslateInstance(bbox.width/2, bbox.height/2))); 175 127 break; 176 128 case 8: 177 symbol(feature, symbols.get(0), n ull, null, new Delta(Handle.BR, AffineTransform.getTranslateInstance(0, -bbox.height/2)));178 symbol(feature, symbols.get(1), n ull, null, new Delta(Handle.BL, AffineTransform.getTranslateInstance(0, -bbox.height/2)));179 symbol(feature, symbols.get(2), n ull, null, new Delta(Handle.RC, AffineTransform.getTranslateInstance(-bbox.width/2, 0)));180 symbol(feature, symbols.get(3), n ull, null, new Delta(Handle.CC, new AffineTransform()));181 symbol(feature, symbols.get(4), n ull, null, new Delta(Handle.LC, AffineTransform.getTranslateInstance(bbox.width/2, 0)));182 symbol(feature, symbols.get(5), n ull, null, new Delta(Handle.TR, AffineTransform.getTranslateInstance(-bbox.width/2, bbox.height/2)));183 symbol(feature, symbols.get(6), n ull, null, new Delta(Handle.TC, AffineTransform.getTranslateInstance(0, bbox.height/2)));184 symbol(feature, symbols.get(7), n ull, null, new Delta(Handle.TL, AffineTransform.getTranslateInstance(bbox.width/2, bbox.height/2)));129 symbol(feature, symbols.get(0), new Delta(Handle.BR, AffineTransform.getTranslateInstance(0, -bbox.height/2))); 130 symbol(feature, symbols.get(1), new Delta(Handle.BL, AffineTransform.getTranslateInstance(0, -bbox.height/2))); 131 symbol(feature, symbols.get(2), new Delta(Handle.RC, AffineTransform.getTranslateInstance(-bbox.width/2, 0))); 132 symbol(feature, symbols.get(3), new Delta(Handle.CC, new AffineTransform())); 133 symbol(feature, symbols.get(4), new Delta(Handle.LC, AffineTransform.getTranslateInstance(bbox.width/2, 0))); 134 symbol(feature, symbols.get(5), new Delta(Handle.TR, AffineTransform.getTranslateInstance(-bbox.width/2, bbox.height/2))); 135 symbol(feature, symbols.get(6), new Delta(Handle.TC, AffineTransform.getTranslateInstance(0, bbox.height/2))); 136 symbol(feature, symbols.get(7), new Delta(Handle.TL, AffineTransform.getTranslateInstance(bbox.width/2, bbox.height/2))); 185 137 break; 186 138 case 9: 187 symbol(feature, symbols.get(0), n ull, null, new Delta(Handle.BR, AffineTransform.getTranslateInstance(-bbox.width/2, -bbox.height/2)));188 symbol(feature, symbols.get(1), n ull, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -bbox.height/2)));189 symbol(feature, symbols.get(2), n ull, null, new Delta(Handle.BL, AffineTransform.getTranslateInstance(bbox.width/2, -bbox.height/2)));190 symbol(feature, symbols.get(3), n ull, null, new Delta(Handle.RC, AffineTransform.getTranslateInstance(-bbox.width/2, 0)));191 symbol(feature, symbols.get(4), n ull, null, new Delta(Handle.CC, new AffineTransform()));192 symbol(feature, symbols.get(5), n ull, null, new Delta(Handle.LC, AffineTransform.getTranslateInstance(bbox.width/2, 0)));193 symbol(feature, symbols.get(6), n ull, null, new Delta(Handle.TR, AffineTransform.getTranslateInstance(-bbox.width/2, bbox.height/2)));194 symbol(feature, symbols.get(7), n ull, null, new Delta(Handle.TC, AffineTransform.getTranslateInstance(0, bbox.height/2)));195 symbol(feature, symbols.get(8), n ull, null, new Delta(Handle.TL, AffineTransform.getTranslateInstance(bbox.width/2, bbox.height/2)));139 symbol(feature, symbols.get(0), new Delta(Handle.BR, AffineTransform.getTranslateInstance(-bbox.width/2, -bbox.height/2))); 140 symbol(feature, symbols.get(1), new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -bbox.height/2))); 141 symbol(feature, symbols.get(2), new Delta(Handle.BL, AffineTransform.getTranslateInstance(bbox.width/2, -bbox.height/2))); 142 symbol(feature, symbols.get(3), new Delta(Handle.RC, AffineTransform.getTranslateInstance(-bbox.width/2, 0))); 143 symbol(feature, symbols.get(4), new Delta(Handle.CC, new AffineTransform())); 144 symbol(feature, symbols.get(5), new Delta(Handle.LC, AffineTransform.getTranslateInstance(bbox.width/2, 0))); 145 symbol(feature, symbols.get(6), new Delta(Handle.TR, AffineTransform.getTranslateInstance(-bbox.width/2, bbox.height/2))); 146 symbol(feature, symbols.get(7), new Delta(Handle.TC, AffineTransform.getTranslateInstance(0, bbox.height/2))); 147 symbol(feature, symbols.get(8), new Delta(Handle.TL, AffineTransform.getTranslateInstance(bbox.width/2, bbox.height/2))); 196 148 break; 197 149 }
Note:
See TracChangeset
for help on using the changeset viewer.