Changeset 32394 in osm for applications/editors/josm/plugins/seachart/src/symbols/Symbols.java
- Timestamp:
- 2016-06-24T03:48:12+02:00 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/seachart/src/symbols/Symbols.java
r32393 r32394 15 15 import java.awt.Graphics2D; 16 16 import java.awt.font.TextLayout; 17 import java.awt.geom.*; 17 import java.awt.geom.AffineTransform; 18 import java.awt.geom.Arc2D; 19 import java.awt.geom.Ellipse2D; 20 import java.awt.geom.Line2D; 21 import java.awt.geom.Path2D; 22 import java.awt.geom.Rectangle2D; 23 import java.awt.geom.RectangularShape; 24 import java.awt.geom.RoundRectangle2D; 18 25 import java.util.ArrayList; 19 26 20 27 public class Symbols { 21 22 public static final Color Yland = new Color(0xedbc0c); 23 // public static final Color Bwater = new Color(0x78acd2); 24 public static final Color Bwater = new Color(0x9bc5e3); 25 public static final Color Gdries = new Color(0x689868); 26 public static final Color Mline = new Color(0x9a6078); 27 public static final Color Msymb = new Color(0xa30075); 28 public static final Color Mtss = new Color(0xc0c480ff, true); 29 30 public enum Form { 31 BBOX, STRK, COLR, FILL, LINE, RECT, RRCT, ELPS, EARC, PLIN, PGON, RSHP, TEXT, SYMB, N1, N2, P1, P2, H2, H3, H4, H5, V2, V3, D2, D3, D4, B1, S2, S3, S4, C2, X2 32 } 33 34 public enum Patt { 35 Z, H, V, D, B, S, C, X 36 } 37 38 public enum Handle { 39 CC, TL, TR, TC, LC, RC, BL, BR, BC 40 } 41 42 public static class Instr { 43 public Form type; 44 public Object params; 45 46 public Instr(Form itype, Object iparams) { 47 type = itype; 48 params = iparams; 49 } 50 } 51 52 public static class Delta { 53 public Handle h; 54 public AffineTransform t; 55 56 public Delta(Handle ih, AffineTransform it) { 57 h = ih; 58 t = it; 59 } 60 public Delta(Handle ih) { 61 h = ih; 62 t = new AffineTransform(); 63 } 64 } 65 66 public static class Scheme { 67 public ArrayList<Patt> pat; 68 public ArrayList<Color> col; 69 70 public Scheme(ArrayList<Color> icol) { 71 pat = new ArrayList<>(); 72 col = icol; 73 } 74 public Scheme(ArrayList<Patt> ipat, ArrayList<Color> icol) { 75 pat = ipat; 76 col = icol; 77 } 78 public Scheme(Color icol) { 79 pat = new ArrayList<>(); 80 col = new ArrayList<>(); 81 col.add(icol); 82 } 83 public Scheme() { 84 pat = new ArrayList<>(); 85 col = new ArrayList<>(); 86 } 87 } 88 89 public static class Caption { 90 public String string; 91 public Font font; 92 public Color colour; 93 public Delta dd; 94 95 public Caption(String istr, Font ifont, Color icolour, Delta idd) { 96 string = istr; 97 font = ifont; 98 colour = icolour; 99 dd = idd; 100 } 101 } 102 103 public static class LineStyle { 104 public Color line; 105 public float width; 106 public float[] dash; 107 public Color fill; 108 109 public LineStyle(Color ifill) { 110 line = null; 111 width = 0; 112 dash = null; 113 fill = ifill; 114 } 115 public LineStyle(Color iline, float iwidth) { 116 line = iline; 117 width = iwidth; 118 dash = null; 119 fill = null; 120 } 121 public LineStyle(Color iline, float iwidth, float[] idash) { 122 line = iline; 123 width = iwidth; 124 dash = idash; 125 fill = null; 126 } 127 public LineStyle(Color iline, float iwidth, Color ifill) { 128 line = iline; 129 width = iwidth; 130 dash = null; 131 fill = ifill; 132 } 133 public LineStyle(Color iline, float iwidth, float[] idash, Color ifill) { 134 line = iline; 135 width = iwidth; 136 dash = idash; 137 fill = ifill; 138 } 139 } 140 141 public static class Symbol extends ArrayList<Instr> { 142 143 public Symbol() { 144 super(); 145 } 146 } 147 148 public static class SubSymbol { 149 public Symbol instr; 150 public double scale; 151 public double x; 152 public double y; 153 public Delta delta; 154 public Scheme scheme; 155 156 public SubSymbol(Symbol iinstr, double iscale, double ix, double iy, Scheme ischeme, Delta idelta) { 157 instr = iinstr; 158 scale = iscale; 159 x = ix; 160 y = iy; 161 delta = idelta; 162 scheme = ischeme; 163 } 164 } 165 166 public static void drawSymbol(Graphics2D g2, Symbol symbol, double scale, double x, double y, Scheme cs, Delta dd) { 167 int pn = 0; 168 int cn = 0; 169 Patt bpat = Patt.Z; 170 Color bcol = null; 171 g2.setPaint(Color.black); 172 if (cs != null) { 173 if ((cs.pat.size() > 0) && (cs.col.size() > 0) && (cs.pat.get(0) == Patt.B)) { 174 bpat = (cs.pat.remove(0)); 175 bcol = (cs.col.remove(0)); 176 } 177 pn = cs.pat.size(); 178 cn = cs.col.size() - ((pn != 0) ? pn - 1 : 0); 179 if ((pn == 0) && (cs.col.size() == 1)) { 180 g2.setPaint(cs.col.get(0)); 181 } 182 } 183 AffineTransform savetr = g2.getTransform(); 184 g2.translate(x, y); 185 g2.scale(scale, scale); 186 if (symbol != null) { 187 for (Instr item : symbol) { 188 switch (item.type) { 189 case BBOX: 190 Rectangle2D.Double bbox = (Rectangle2D.Double) item.params; 191 double dx = 0.0; 192 double dy = 0.0; 193 if (dd != null) { 194 g2.transform(dd.t); 195 switch (dd.h) { 196 case CC: 197 dx -= bbox.x + (bbox.width / 2.0); 198 dy -= bbox.y + (bbox.height / 2.0); 199 break; 200 case TL: 201 dx -= bbox.x; 202 dy -= bbox.y; 203 break; 204 case TR: 205 dx -= bbox.x + bbox.width; 206 dy -= bbox.y; 207 break; 208 case TC: 209 dx -= bbox.x + (bbox.width / 2.0); 210 dy -= bbox.y; 211 break; 212 case LC: 213 dx -= bbox.x; 214 dy -= bbox.y + (bbox.height / 2.0); 215 break; 216 case RC: 217 dx -= bbox.x + bbox.width; 218 dy -= bbox.y + (bbox.height / 2.0); 219 break; 220 case BL: 221 dx -= bbox.x; 222 dy -= bbox.y + bbox.height; 223 break; 224 case BR: 225 dx -= bbox.x + bbox.width; 226 dy -= bbox.y + bbox.height; 227 break; 228 case BC: 229 dx -= bbox.x + (bbox.width / 2.0); 230 dy -= bbox.y + bbox.height; 231 break; 232 } 233 g2.translate(dx, dy); 234 } 235 break; 236 case COLR: 237 if ((cs != null) && (cs.col != null)) { 238 for (Instr patch : (Symbol) item.params) { 239 switch (patch.type) { 240 case N1: 241 if (cn > 0) { 242 Symbol s = (Symbol) patch.params; 243 drawSymbol(g2, s, 1.0, 0, 0, new Scheme(cs.col.get(0)), null); 244 } 245 break; 246 case N2: 247 if (cn > 0) { 248 Symbol s = (Symbol) patch.params; 249 drawSymbol(g2, s, 1.0, 0, 0, new Scheme((cn > 1) ? cs.col.get(1) : cs.col.get(0)), null); 250 } 251 break; 252 case P1: 253 if (cn > 0) { 254 g2.setPaint(cs.col.get(0)); 255 g2.fill((Path2D.Double) patch.params); 256 } 257 break; 258 case P2: 259 if (cn > 0) { 260 if (cn > 1) { 261 g2.setPaint(cs.col.get(1)); 262 } else { 263 g2.setPaint(cs.col.get(0)); 264 } 265 g2.fill((Path2D.Double) patch.params); 266 } 267 break; 268 case H2: 269 if ((cn > 1) && (pn > 0) && (cs.pat.get(0) == Patt.H)) { 270 g2.setPaint(cs.col.get(cs.col.size() - pn)); 271 g2.fill((Path2D.Double) patch.params); 272 } 273 break; 274 case H3: 275 if ((cn == 3) && (pn > 0) && (cs.pat.get(0) == Patt.H)) { 276 g2.setPaint(cs.col.get(1)); 277 g2.fill((Path2D.Double) patch.params); 278 } 279 break; 280 case H4: 281 if ((cn == 4) && (pn > 0) && (cs.pat.get(0) == Patt.H)) { 282 g2.setPaint(cs.col.get(1)); 283 g2.fill((Path2D.Double) patch.params); 284 } 285 break; 286 case H5: 287 if ((cn == 4) && (pn > 0) && (cs.pat.get(0) == Patt.H)) { 288 g2.setPaint(cs.col.get(2)); 289 g2.fill((Path2D.Double) patch.params); 290 } 291 break; 292 case V2: 293 if ((cn > 1) && (pn > 0) && (cs.pat.get(0) == Patt.V)) { 294 g2.setPaint(cs.col.get(cs.col.size() - pn)); 295 g2.fill((Path2D.Double) patch.params); 296 } 297 break; 298 case V3: 299 if ((cn == 3) && (pn > 0) && (cs.pat.get(0) == Patt.V)) { 300 g2.setPaint(cs.col.get(1)); 301 g2.fill((Path2D.Double) patch.params); 302 } 303 break; 304 case B1: 305 if (bpat == Patt.B) { 306 g2.setPaint(bcol); 307 g2.fill((Path2D.Double) patch.params); 308 } 309 break; 310 case S2: 311 if ((cn > 1) && (pn > 0) && (cs.pat.get(0) == Patt.S)) { 312 g2.setPaint(cs.col.get(1)); 313 g2.fill((Path2D.Double) patch.params); 314 } 315 break; 316 case S3: 317 if ((cn > 2) && (pn > 0) && (cs.pat.get(0) == Patt.S)) { 318 g2.setPaint(cs.col.get(2)); 319 g2.fill((Path2D.Double) patch.params); 320 } 321 break; 322 case S4: 323 if ((cn == 4) && (pn > 0) && (cs.pat.get(0) == Patt.S)) { 324 g2.setPaint(cs.col.get(3)); 325 g2.fill((Path2D.Double) patch.params); 326 } 327 break; 328 default: 329 break; 330 } 331 } 332 } 333 break; 334 case STRK: 335 g2.setStroke((BasicStroke) item.params); 336 break; 337 case FILL: 338 g2.setPaint((Color) item.params); 339 break; 340 case LINE: 341 g2.draw((Line2D.Double) item.params); 342 break; 343 case RECT: 344 g2.draw((Rectangle2D.Double) item.params); 345 break; 346 case RRCT: 347 g2.draw((RoundRectangle2D.Double) item.params); 348 break; 349 case ELPS: 350 g2.draw((Ellipse2D.Double) item.params); 351 break; 352 case EARC: 353 g2.draw((Arc2D.Double) item.params); 354 break; 355 case PLIN: 356 g2.draw((Path2D.Double) item.params); 357 break; 358 case PGON: 359 g2.fill((Path2D.Double) item.params); 360 break; 361 case RSHP: 362 g2.fill((RectangularShape) item.params); 363 break; 364 case SYMB: 365 SubSymbol s = (SubSymbol) item.params; 366 drawSymbol(g2, s.instr, s.scale, s.x, s.y, (s.scheme != null ? s.scheme : cs), s.delta); 367 break; 368 case TEXT: 369 Caption c = (Caption) item.params; 370 g2.setPaint(c.colour); 371 TextLayout layout = new TextLayout(c.string, c.font, g2.getFontRenderContext()); 372 Rectangle2D bb = layout.getBounds(); 373 dx = 0; 374 dy = 0; 375 if (c.dd != null) { 376 if (c.dd.t != null) g2.transform(c.dd.t); 377 switch (c.dd.h) { 378 case CC: 379 dx -= bb.getX() + (bb.getWidth() / 2.0); 380 dy -= bb.getY() + (bb.getHeight() / 2.0); 381 break; 382 case TL: 383 dx -= bb.getX(); 384 dy -= bb.getY(); 385 break; 386 case TR: 387 dx -= bb.getX() + bb.getWidth(); 388 dy -= bb.getY(); 389 break; 390 case TC: 391 dx -= bb.getX() + (bb.getWidth() / 2.0); 392 dy -= bb.getY(); 393 break; 394 case LC: 395 dx -= bb.getX(); 396 dy -= bb.getY() + (bb.getHeight() / 2.0); 397 break; 398 case RC: 399 dx -= bb.getX() + bb.getWidth(); 400 dy -= bb.getY() + (bb.getHeight() / 2.0); 401 break; 402 case BL: 403 dx -= bb.getX(); 404 dy -= bb.getY() + bb.getHeight(); 405 break; 406 case BR: 407 dx -= bb.getX() + bb.getWidth(); 408 dy -= bb.getY() + bb.getHeight(); 409 break; 410 case BC: 411 dx -= bb.getX() + (bb.getWidth() / 2.0); 412 dy -= bb.getY() + bb.getHeight(); 413 break; 414 } 415 } 416 layout.draw(g2, (float)dx, (float)dy); 417 break; 418 default: 419 break; 420 } 421 } 422 } 423 g2.setTransform(savetr); 424 } 28 // CHECKSTYLE.OFF: LineLength 29 public static final Color Yland = new Color(0xedbc0c); 30 // public static final Color Bwater = new Color(0x78acd2); 31 public static final Color Bwater = new Color(0x9bc5e3); 32 public static final Color Gdries = new Color(0x689868); 33 public static final Color Mline = new Color(0x9a6078); 34 public static final Color Msymb = new Color(0xa30075); 35 public static final Color Mtss = new Color(0xc0c480ff, true); 36 37 public enum Form { 38 BBOX, STRK, COLR, FILL, LINE, RECT, RRCT, ELPS, EARC, PLIN, PGON, RSHP, TEXT, SYMB, N1, N2, P1, P2, H2, H3, H4, H5, V2, V3, D2, D3, D4, B1, S2, S3, S4, C2, X2 39 } 40 41 public enum Patt { 42 Z, H, V, D, B, S, C, X 43 } 44 45 public enum Handle { 46 CC, TL, TR, TC, LC, RC, BL, BR, BC 47 } 48 49 public static class Instr { 50 public Form type; 51 public Object params; 52 53 public Instr(Form itype, Object iparams) { 54 type = itype; 55 params = iparams; 56 } 57 } 58 59 public static class Delta { 60 public Handle h; 61 public AffineTransform t; 62 63 public Delta(Handle ih, AffineTransform it) { 64 h = ih; 65 t = it; 66 } 67 68 public Delta(Handle ih) { 69 h = ih; 70 t = new AffineTransform(); 71 } 72 } 73 74 public static class Scheme { 75 public ArrayList<Patt> pat; 76 public ArrayList<Color> col; 77 78 public Scheme(ArrayList<Color> icol) { 79 pat = new ArrayList<>(); 80 col = icol; 81 } 82 83 public Scheme(ArrayList<Patt> ipat, ArrayList<Color> icol) { 84 pat = ipat; 85 col = icol; 86 } 87 88 public Scheme(Color icol) { 89 pat = new ArrayList<>(); 90 col = new ArrayList<>(); 91 col.add(icol); 92 } 93 94 public Scheme() { 95 pat = new ArrayList<>(); 96 col = new ArrayList<>(); 97 } 98 } 99 100 public static class Caption { 101 public String string; 102 public Font font; 103 public Color colour; 104 public Delta dd; 105 106 public Caption(String istr, Font ifont, Color icolour, Delta idd) { 107 string = istr; 108 font = ifont; 109 colour = icolour; 110 dd = idd; 111 } 112 } 113 114 public static class LineStyle { 115 public Color line; 116 public float width; 117 public float[] dash; 118 public Color fill; 119 120 public LineStyle(Color ifill) { 121 line = null; 122 width = 0; 123 dash = null; 124 fill = ifill; 125 } 126 127 public LineStyle(Color iline, float iwidth) { 128 line = iline; 129 width = iwidth; 130 dash = null; 131 fill = null; 132 } 133 134 public LineStyle(Color iline, float iwidth, float[] idash) { 135 line = iline; 136 width = iwidth; 137 dash = idash; 138 fill = null; 139 } 140 141 public LineStyle(Color iline, float iwidth, Color ifill) { 142 line = iline; 143 width = iwidth; 144 dash = null; 145 fill = ifill; 146 } 147 148 public LineStyle(Color iline, float iwidth, float[] idash, Color ifill) { 149 line = iline; 150 width = iwidth; 151 dash = idash; 152 fill = ifill; 153 } 154 } 155 156 public static class Symbol extends ArrayList<Instr> { 157 158 public Symbol() { 159 super(); 160 } 161 } 162 163 public static class SubSymbol { 164 public Symbol instr; 165 public double scale; 166 public double x; 167 public double y; 168 public Delta delta; 169 public Scheme scheme; 170 171 public SubSymbol(Symbol iinstr, double iscale, double ix, double iy, Scheme ischeme, Delta idelta) { 172 instr = iinstr; 173 scale = iscale; 174 x = ix; 175 y = iy; 176 delta = idelta; 177 scheme = ischeme; 178 } 179 } 180 181 public static void drawSymbol(Graphics2D g2, Symbol symbol, double scale, double x, double y, Scheme cs, Delta dd) { 182 int pn = 0; 183 int cn = 0; 184 Patt bpat = Patt.Z; 185 Color bcol = null; 186 g2.setPaint(Color.black); 187 if (cs != null) { 188 if ((cs.pat.size() > 0) && (cs.col.size() > 0) && (cs.pat.get(0) == Patt.B)) { 189 bpat = (cs.pat.remove(0)); 190 bcol = (cs.col.remove(0)); 191 } 192 pn = cs.pat.size(); 193 cn = cs.col.size() - ((pn != 0) ? pn - 1 : 0); 194 if ((pn == 0) && (cs.col.size() == 1)) { 195 g2.setPaint(cs.col.get(0)); 196 } 197 } 198 AffineTransform savetr = g2.getTransform(); 199 g2.translate(x, y); 200 g2.scale(scale, scale); 201 if (symbol != null) { 202 for (Instr item : symbol) { 203 switch (item.type) { 204 case BBOX: 205 Rectangle2D.Double bbox = (Rectangle2D.Double) item.params; 206 double dx = 0.0; 207 double dy = 0.0; 208 if (dd != null) { 209 g2.transform(dd.t); 210 switch (dd.h) { 211 case CC: 212 dx -= bbox.x + (bbox.width / 2.0); 213 dy -= bbox.y + (bbox.height / 2.0); 214 break; 215 case TL: 216 dx -= bbox.x; 217 dy -= bbox.y; 218 break; 219 case TR: 220 dx -= bbox.x + bbox.width; 221 dy -= bbox.y; 222 break; 223 case TC: 224 dx -= bbox.x + (bbox.width / 2.0); 225 dy -= bbox.y; 226 break; 227 case LC: 228 dx -= bbox.x; 229 dy -= bbox.y + (bbox.height / 2.0); 230 break; 231 case RC: 232 dx -= bbox.x + bbox.width; 233 dy -= bbox.y + (bbox.height / 2.0); 234 break; 235 case BL: 236 dx -= bbox.x; 237 dy -= bbox.y + bbox.height; 238 break; 239 case BR: 240 dx -= bbox.x + bbox.width; 241 dy -= bbox.y + bbox.height; 242 break; 243 case BC: 244 dx -= bbox.x + (bbox.width / 2.0); 245 dy -= bbox.y + bbox.height; 246 break; 247 } 248 g2.translate(dx, dy); 249 } 250 break; 251 case COLR: 252 if ((cs != null) && (cs.col != null)) { 253 for (Instr patch : (Symbol) item.params) { 254 switch (patch.type) { 255 case N1: 256 if (cn > 0) { 257 Symbol s = (Symbol) patch.params; 258 drawSymbol(g2, s, 1.0, 0, 0, new Scheme(cs.col.get(0)), null); 259 } 260 break; 261 case N2: 262 if (cn > 0) { 263 Symbol s = (Symbol) patch.params; 264 drawSymbol(g2, s, 1.0, 0, 0, new Scheme((cn > 1) ? cs.col.get(1) : cs.col.get(0)), null); 265 } 266 break; 267 case P1: 268 if (cn > 0) { 269 g2.setPaint(cs.col.get(0)); 270 g2.fill((Path2D.Double) patch.params); 271 } 272 break; 273 case P2: 274 if (cn > 0) { 275 if (cn > 1) { 276 g2.setPaint(cs.col.get(1)); 277 } else { 278 g2.setPaint(cs.col.get(0)); 279 } 280 g2.fill((Path2D.Double) patch.params); 281 } 282 break; 283 case H2: 284 if ((cn > 1) && (pn > 0) && (cs.pat.get(0) == Patt.H)) { 285 g2.setPaint(cs.col.get(cs.col.size() - pn)); 286 g2.fill((Path2D.Double) patch.params); 287 } 288 break; 289 case H3: 290 if ((cn == 3) && (pn > 0) && (cs.pat.get(0) == Patt.H)) { 291 g2.setPaint(cs.col.get(1)); 292 g2.fill((Path2D.Double) patch.params); 293 } 294 break; 295 case H4: 296 if ((cn == 4) && (pn > 0) && (cs.pat.get(0) == Patt.H)) { 297 g2.setPaint(cs.col.get(1)); 298 g2.fill((Path2D.Double) patch.params); 299 } 300 break; 301 case H5: 302 if ((cn == 4) && (pn > 0) && (cs.pat.get(0) == Patt.H)) { 303 g2.setPaint(cs.col.get(2)); 304 g2.fill((Path2D.Double) patch.params); 305 } 306 break; 307 case V2: 308 if ((cn > 1) && (pn > 0) && (cs.pat.get(0) == Patt.V)) { 309 g2.setPaint(cs.col.get(cs.col.size() - pn)); 310 g2.fill((Path2D.Double) patch.params); 311 } 312 break; 313 case V3: 314 if ((cn == 3) && (pn > 0) && (cs.pat.get(0) == Patt.V)) { 315 g2.setPaint(cs.col.get(1)); 316 g2.fill((Path2D.Double) patch.params); 317 } 318 break; 319 case B1: 320 if (bpat == Patt.B) { 321 g2.setPaint(bcol); 322 g2.fill((Path2D.Double) patch.params); 323 } 324 break; 325 case S2: 326 if ((cn > 1) && (pn > 0) && (cs.pat.get(0) == Patt.S)) { 327 g2.setPaint(cs.col.get(1)); 328 g2.fill((Path2D.Double) patch.params); 329 } 330 break; 331 case S3: 332 if ((cn > 2) && (pn > 0) && (cs.pat.get(0) == Patt.S)) { 333 g2.setPaint(cs.col.get(2)); 334 g2.fill((Path2D.Double) patch.params); 335 } 336 break; 337 case S4: 338 if ((cn == 4) && (pn > 0) && (cs.pat.get(0) == Patt.S)) { 339 g2.setPaint(cs.col.get(3)); 340 g2.fill((Path2D.Double) patch.params); 341 } 342 break; 343 default: 344 break; 345 } 346 } 347 } 348 break; 349 case STRK: 350 g2.setStroke((BasicStroke) item.params); 351 break; 352 case FILL: 353 g2.setPaint((Color) item.params); 354 break; 355 case LINE: 356 g2.draw((Line2D.Double) item.params); 357 break; 358 case RECT: 359 g2.draw((Rectangle2D.Double) item.params); 360 break; 361 case RRCT: 362 g2.draw((RoundRectangle2D.Double) item.params); 363 break; 364 case ELPS: 365 g2.draw((Ellipse2D.Double) item.params); 366 break; 367 case EARC: 368 g2.draw((Arc2D.Double) item.params); 369 break; 370 case PLIN: 371 g2.draw((Path2D.Double) item.params); 372 break; 373 case PGON: 374 g2.fill((Path2D.Double) item.params); 375 break; 376 case RSHP: 377 g2.fill((RectangularShape) item.params); 378 break; 379 case SYMB: 380 SubSymbol s = (SubSymbol) item.params; 381 drawSymbol(g2, s.instr, s.scale, s.x, s.y, (s.scheme != null ? s.scheme : cs), s.delta); 382 break; 383 case TEXT: 384 Caption c = (Caption) item.params; 385 g2.setPaint(c.colour); 386 TextLayout layout = new TextLayout(c.string, c.font, g2.getFontRenderContext()); 387 Rectangle2D bb = layout.getBounds(); 388 dx = 0; 389 dy = 0; 390 if (c.dd != null) { 391 if (c.dd.t != null) g2.transform(c.dd.t); 392 switch (c.dd.h) { 393 case CC: 394 dx -= bb.getX() + (bb.getWidth() / 2.0); 395 dy -= bb.getY() + (bb.getHeight() / 2.0); 396 break; 397 case TL: 398 dx -= bb.getX(); 399 dy -= bb.getY(); 400 break; 401 case TR: 402 dx -= bb.getX() + bb.getWidth(); 403 dy -= bb.getY(); 404 break; 405 case TC: 406 dx -= bb.getX() + (bb.getWidth() / 2.0); 407 dy -= bb.getY(); 408 break; 409 case LC: 410 dx -= bb.getX(); 411 dy -= bb.getY() + (bb.getHeight() / 2.0); 412 break; 413 case RC: 414 dx -= bb.getX() + bb.getWidth(); 415 dy -= bb.getY() + (bb.getHeight() / 2.0); 416 break; 417 case BL: 418 dx -= bb.getX(); 419 dy -= bb.getY() + bb.getHeight(); 420 break; 421 case BR: 422 dx -= bb.getX() + bb.getWidth(); 423 dy -= bb.getY() + bb.getHeight(); 424 break; 425 case BC: 426 dx -= bb.getX() + (bb.getWidth() / 2.0); 427 dy -= bb.getY() + bb.getHeight(); 428 break; 429 } 430 } 431 layout.draw(g2, (float) dx, (float) dy); 432 break; 433 default: 434 break; 435 } 436 } 437 } 438 g2.setTransform(savetr); 439 } 425 440 }
Note:
See TracChangeset
for help on using the changeset viewer.
