Ignore:
Timestamp:
2012-12-16T22:26:04+01:00 (12 years ago)
Author:
malcolmh
Message:

save

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/smed2/src/symbols/Symbols.java

    r29074 r29082  
    2323
    2424        public enum Prim {
    25                 BBOX, STRK, COLR, FILL, LINE, RECT, RRCT, ELPS, EARC, PLIN, PGON, SYMB,
    26                 P1, H2, H3, H4, H5, V2, D2, D3, D4, B2, S2, S3, S4, C2, X2
     25                BBOX, STRK, COLR, FILL, LINE, RECT, RRCT, ELPS, EARC, PLIN, PGON, SYMB, P1, P2, H2, H3, H4, H5, V2, D2, D3, D4, B2, S2, S3, S4, C2, X2
    2726        }
    2827
     
    3130        }
    3231
    33         public static final double symbolScale[] = { 256.0, 128.0, 64.0, 32.0, 16.0, 8.0, 4.0, 2.0, 1.0,
    34                 0.61, 0.372, 0.227, 0.138, 0.0843, 0.0514, 0.0313, 0.0191, 0.0117, 0.007, 0.138 };
    35 
    36         public static final double textScale[] = { 256.0, 128.0, 64.0, 32.0, 16.0, 8.0, 4.0, 2.0, 1.0,
    37                 0.5556, 0.3086, 0.1714, 0.0953, 0.0529, 0.0294, 0.0163, 0.0091, 0.0050, 0.0028, 0.0163 };
     32        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,
     33                        0.0843, 0.0514, 0.0313, 0.0191, 0.0117, 0.007, 0.138 };
     34
     35        public static final double textScale[] = { 256.0, 128.0, 64.0, 32.0, 16.0, 8.0, 4.0, 2.0, 1.0, 0.5556, 0.3086, 0.1714, 0.0953,
     36                        0.0529, 0.0294, 0.0163, 0.0091, 0.0050, 0.0028, 0.0163 };
    3837
    3938        private static final EnumMap<ColCOL, Color> bodyColours = new EnumMap<ColCOL, Color>(ColCOL.class);
     
    8685
    8786        public static void drawSymbol(Graphics2D g2, ArrayList<Instr> symbol, int zoom, double x, double y, Delta dd, Scheme cs) {
    88                 int pn = cs.pat.size();
    89                 int cn = cs.col.size() - pn + 1;
     87                int pn = 0;
     88                int cn = 0;
     89                if (cs != null) {
     90                        pn = cs.pat.size();
     91                        cn = cs.col.size() - ((pn != 0) ? pn - 1 : 0);
     92                }
    9093                AffineTransform savetr = g2.getTransform();
    9194                g2.translate(x, y);
     
    9497                        switch (item.type) {
    9598                        case BBOX:
    96                                 Rectangle bbox = (Rectangle)item.params;
     99                                Rectangle bbox = (Rectangle) item.params;
    97100                                double dx = 0.0;
    98101                                double dy = 0.0;
     
    100103                                        switch (dd.h) {
    101104                                        case CC:
    102                                                 dx = bbox.x + (bbox.width/2.0);
    103                                                 dy = bbox.y - (bbox.height/2.0);
     105                                                dx = bbox.x + (bbox.width / 2.0);
     106                                                dy = bbox.y - (bbox.height / 2.0);
    104107                                                break;
    105108                                        case TL:
     
    112115                                                break;
    113116                                        case TC:
    114                                                 dx = bbox.x + (bbox.width/2.0);
     117                                                dx = bbox.x + (bbox.width / 2.0);
    115118                                                dy = bbox.y;
    116119                                                break;
    117120                                        case LC:
    118121                                                dx = bbox.x;
    119                                                 dy = bbox.y - (bbox.height/2.0);
     122                                                dy = bbox.y - (bbox.height / 2.0);
    120123                                                break;
    121124                                        case RC:
    122125                                                dx = bbox.x + bbox.width;
    123                                                 dy = bbox.y - (bbox.height/2.0);
     126                                                dy = bbox.y - (bbox.height / 2.0);
    124127                                                break;
    125128                                        case BL:
     
    132135                                                break;
    133136                                        case BC:
    134                                                 dx = bbox.x + (bbox.width/2.0);
     137                                                dx = bbox.x + (bbox.width / 2.0);
    135138                                                dy = bbox.y - bbox.height;
    136139                                                break;
     
    150153                                                        }
    151154                                                        break;
     155                                                case P2:
     156                                                        if (cn > 0) {
     157                                                                if (cn > 1) {
     158                                                                        g2.setPaint(bodyColours.get(cs.col.get(1)));
     159                                                                } else {
     160                                                                        g2.setPaint(bodyColours.get(cs.col.get(0)));
     161                                                                }
     162                                                                g2.fill((Path2D.Double) patch.params);
     163                                                        }
     164                                                        break;
    152165                                                case H2:
    153166                                                        if ((cn > 1) && (cs.pat.get(0) == ColPAT.PAT_HORI)) {
     
    211224                                g2.fill((Path2D.Double) item.params);
    212225                                break;
     226                        case SYMB:
     227                                drawSymbol(g2, (ArrayList<Instr>) item.params, zoom, 0.0, 0.0, null, null);
     228                                break;
    213229                        }
    214230                }
Note: See TracChangeset for help on using the changeset viewer.