Changeset 26163 in osm for applications/editors


Ignore:
Timestamp:
2011-06-20T18:30:38+02:00 (13 years ago)
Author:
stoecker
Message:

add I18N notes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/turbopen/src/org/openstreetmap/josm/plugins/fastdraw/FastDrawingMode.java

    r26111 r26163  
    55 * Licence: GPL v2 or later
    66 * Author:  Alexei Kasatkin, 2011
    7  * Thanks to authors of BuildingTools, ImproveWayAccuracy and LakeWalker 
     7 * Thanks to authors of BuildingTools, ImproveWayAccuracy and LakeWalker
    88 * for good sample code
    99 */
     
    5353        AWTEventListener {
    5454    private static final String SIMPLIFYMODE_MESSAGE=
    55             "Press Enter to simplify or save, Ctrl-Enter to save with tags, Up/Down to tune simplification";
     55            tr("Press Enter to simplify or save, Ctrl-Enter to save with tags, Up/Down to tune simplification");
    5656    private static final String DRAWINGMODE_MESSAGE=
    57     "Click or Click&drag to continue, Ctrl-Click to add fixed node, Shift-Click to delete, Enter to simplify or save, Ctrl-Shift-Click to start new line";
    58    
     57    tr("Click or Click&drag to continue, Ctrl-Click to add fixed node, Shift-Click to delete, Enter to simplify or save, Ctrl-Shift-Click to start new line");
     58
    5959    private Color COLOR_FIXED;
    6060    private Color COLOR_NORMAL;
     
    6262    private Color COLOR_SELECTEDFRAGMENT;
    6363    private Color COLOR_EDITEDFRAGMENT;
    64    
     64
    6565    private double maxDist;
    6666    private double epsilonMult;
     
    7070    /// Initial tolerance for Douglas-Pecker algorithm
    7171    private double startingEps;
    72    
     72
    7373    private DrawnPolyLine line;
    7474    private MapView mv;
     
    9292    private Stroke strokeForDelete;
    9393    private int dragNode=-1;
    94    
     94
    9595
    9696    FastDrawingMode(MapFrame mapFrame) {
     
    121121        mv = Main.map.mapView;
    122122        line.setMv(mv);
    123        
     123
    124124        if (getCurrentDataSet() == null) return;
    125        
     125
    126126        Main.map.mapView.addMouseListener(this);
    127127        Main.map.mapView.addMouseMotionListener(this);
    128128        Main.map.mapView.addTemporaryLayer(this);
    129        
     129
    130130        Main.map.mapView.setCursor(cursorDraw);
    131131
     
    166166
    167167    //////////    Event listener methods
    168    
     168
    169169    @Override
    170170    public void paint(Graphics2D g, MapView mv, Bounds bbox) {
    171171        LinkedList<LatLon> pts=line.getPoints();
    172172        if (pts.isEmpty()) return;
    173        
     173
    174174        if (line.wasSimplified()) {
    175175            // we are drawing simplified version, that exists
     
    178178            g.setStroke(strokeForOriginal);
    179179        }
    180        
     180
    181181        Point p1, p2;
    182182        LatLon pp1, pp2;
     
    246246        if (!isEnabled()) return;
    247247        if (e.getButton() != MouseEvent.BUTTON1) return;
    248        
    249        
     248
     249
    250250        int idx=line.findClosestPoint(e.getPoint(),maxDist);
    251251        if (idx==0 && !line.isClosed()) {
     
    256256            updateCursor();
    257257            return;
    258         } 
    259        
     258        }
     259
    260260        if (ctrl && shift) newDrawing();
    261261        if (!ctrl && shift) {
    262262            if (idx>=0) {line.deleteNode(idx); nearestIdx=-1;}
    263             else line.tryToDeleteSegment(e.getPoint()); 
     263            else line.tryToDeleteSegment(e.getPoint());
    264264            return;
    265265        }
     
    267267            if (ctrl) {
    268268                // toggle fixed point
    269                 line.toggleFixed(idx);               
     269                line.toggleFixed(idx);
    270270            }
    271271            // node dragging
     
    276276        //if (line.isClosed()) { setStatusLine(tr(SIMPLIFYMODE_MESSAGE));return;  }
    277277        drawing = true;
    278        
     278
    279279        LatLon p = getLatLon(e);
    280280        Node nd1 = getNearestNode(e.getPoint(), maxDist);
     
    284284            p=nd1.getCoor();
    285285            line.fixPoint(p);
    286         }         
    287        
     286        }
     287
    288288        line.addLast(p);
    289289        if (ctrl) line.fixPoint(p);
    290290        line.clearSimplifiedVersion();
    291                
     291
    292292        setStatusLine(tr("Please move the mouse to draw new way"));
    293293        repaint();
    294294
    295295    }
    296  
     296
    297297    @Override
    298298    public void mouseReleased(MouseEvent e) {
     
    302302        drawing = false;
    303303        highlighted=null;
    304         if (!line.isClosed()) setStatusLine(tr(DRAWINGMODE_MESSAGE));
     304        if (!line.isClosed()) setStatusLine(DRAWINGMODE_MESSAGE);
    305305        repaint();
    306306    }
     
    315315        if (!isEnabled()) return;
    316316        Node nd1 = getNearestNode(e.getPoint(), maxDist);
    317         boolean nearpoint2=nd1!=null; 
     317        boolean nearpoint2=nd1!=null;
    318318        if (nearpoint!=nearpoint2) {nearpoint=nearpoint2;updateCursor();}
    319        
     319
    320320        nearestIdx=line.findClosestPoint(e.getPoint(),maxDist);
    321        
     321
    322322        if (!drawing) {
    323323            if (dragNode>=0) {
     
    333333                    highlighted=h2;
    334334                    repaint();
    335                 } 
     335                }
    336336            }
    337337            return;
    338338        }
    339         if (line.isClosed()) setStatusLine(tr(SIMPLIFYMODE_MESSAGE));
    340        
     339        if (line.isClosed()) setStatusLine(SIMPLIFYMODE_MESSAGE);
     340
    341341        // do not draw points close to existing points - we do not want self-intersections
    342342        if (nearestIdx>=0) { return; }
    343        
     343
    344344        Point lastP = line.getLastPoint(); // last point of line fragment being edited
    345                
     345
    346346        if (nearpoint){
    347347            if ( Math.hypot(e.getX() - lastP.x, e.getY() - lastP.y) > 1e-2) {
    348348                line.addFixed(nd1.getCoor()); // snap to node coords
    349349                repaint();
    350             } 
     350            }
    351351        } else {
    352352            if (Math.hypot(e.getX() - lastP.x, e.getY() - lastP.y) > minPixelsBetweenPoints) {
     
    355355            }
    356356        }
    357        
     357
    358358        //statusText = getLatLon(e).toString();        updateStatusLine();
    359359    }
     
    373373            if (!line.wasSimplified()) {
    374374                line.simplify(eps);
    375                 setStatusLine(tr(SIMPLIFYMODE_MESSAGE));
     375                setStatusLine(SIMPLIFYMODE_MESSAGE);
    376376            } else saveAsWay();
    377377        }
     
    391391            line.moveToTheEnd();
    392392        }
    393              
     393
    394394
    395395    }
     
    421421        int n = pts.size();
    422422        if (n == 0) return;
    423        
     423
    424424        Collection<Command> cmds = new LinkedList<Command>();
    425425        int i = 0;
     
    427427        LatLon first=pts.get(0);
    428428        Node firstNode=null;
    429        
     429
    430430        for (LatLon p : pts) {
    431431            Node nd=null;
     
    482482        //System.out.println(tr("Eps={0}", eps));
    483483        eps*=k;
    484         setStatusLine(tr("Eps={0}", eps));
     484        /* I18N: Eps = Epsilon, the tolerance parameter */ setStatusLine(tr("Eps={0}", eps));
    485485        line.simplify(eps);
    486486        repaint();
    487487    }
    488    
     488
    489489    private void setStatusLine(String tr) {
    490490        statusText=tr;
     
    509509    }*/
    510510
    511    
     511
    512512    void loadPrefs() {
    513513        COLOR_DELETE = Main.pref.getColor("fastdraw.color.delete", Color.red);
     
    523523        eps=startingEps;
    524524    }
    525    
     525
    526526    void savePrefs() {
    527527         Main.pref.putColor("fastdraw.color.delete", COLOR_DELETE );
     
    546546        if (nearpoint) Main.map.mapView.setCursor(cursorCtrl); else
    547547        Main.map.mapView.setCursor(cursorDraw);
    548        
    549        
     548
     549
    550550    }
    551551// </editor-fold>
    552552
    553553// <editor-fold defaultstate="collapsed" desc="Helper functions">
    554    
     554
    555555    private Node getNearestNode(Point point, double maxDist) {
    556556       Node nd = Main.map.mapView.getNearestNode(point, OsmPrimitive.isUsablePredicate);
    557        if (nd!=null && line.getPoint(nd.getCoor()).distance(point)<=maxDist) return nd; 
     557       if (nd!=null && line.getPoint(nd.getCoor()).distance(point)<=maxDist) return nd;
    558558       else return null;
    559559    }
     
    563563    }
    564564// </editor-fold>
    565    
     565
    566566}
Note: See TracChangeset for help on using the changeset viewer.