Changeset 20427 in osm for applications/editors


Ignore:
Timestamp:
2010-03-11T21:26:09+01:00 (14 years ago)
Author:
jttt
Message:

OsmPrimitive.highlighted => OsmPrimitive.setHighlighted()

Location:
applications/editors/josm/plugins/routes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/routes/build.xml

    r19473 r20427  
    1818**
    1919** To build against the core in ../../core, create a correct manifest and deploy to
    20 ** SVN, 
     20** SVN,
    2121**    set the properties commit.message and plugin.main.version
    2222** and run
     
    2828
    2929        <property name="commit.message" value="Changed the constructor signature of the plugin main class" />
    30         <property name="plugin.main.version" value="2830" />
     30        <property name="plugin.main.version" value="3116" />
    3131
    3232        <property name="josm"                   location="../../core/dist/josm-custom.jar"/>
     
    9696
    9797        <!--
    98                  ************************** Publishing the plugin *********************************** 
     98                 ************************** Publishing the plugin ***********************************
    9999                -->
    100100        <!--
    101                 ** extracts the JOSM release for the JOSM version in ../core and saves it in the 
     101                ** extracts the JOSM release for the JOSM version in ../core and saves it in the
    102102                ** property ${coreversion.info.entry.revision}
    103103                **
     
    148148
    149149        <!--
    150                 ** commits the plugin.jar 
     150                ** commits the plugin.jar
    151151                -->
    152152        <target name="commit-dist">
    153153                <echo>
    154154        ***** Properties of published ${plugin.jar} *****
    155         Commit message    : '${commit.message}'                                 
     155        Commit message    : '${commit.message}'
    156156        Plugin-Mainversion: ${plugin.main.version}
    157157        JOSM build version: ${coreversion.info.entry.revision}
    158158        Plugin-Version    : ${version.entry.commit.revision}
    159         ***** / Properties of published ${plugin.jar} *****                                     
    160                                                
     159        ***** / Properties of published ${plugin.jar} *****
     160
    161161        Now commiting ${plugin.jar} ...
    162162        </echo>
  • applications/editors/josm/plugins/routes/src/org/openstreetmap/josm/plugins/routes/RelationEditMode.java

    r19242 r20427  
    2222public class RelationEditMode extends MapMode {
    2323        private static final long serialVersionUID = -7767329767438266289L;
    24        
     24
    2525        private Way highlightedWay;
    26        
     26
    2727        public RelationEditMode(MapFrame mapFrame) {
    28         super(tr("Edit relation"), "node/autonode", tr("Edit relations"),
    29                 Shortcut.registerShortcut("mapmode:editRelation", tr("Mode: {0}", tr("Edit relation")), KeyEvent.VK_H, Shortcut.GROUP_EDIT),
    30                 mapFrame, Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
     28                super(tr("Edit relation"), "node/autonode", tr("Edit relations"),
     29                                Shortcut.registerShortcut("mapmode:editRelation", tr("Mode: {0}", tr("Edit relation")), KeyEvent.VK_H, Shortcut.GROUP_EDIT),
     30                                mapFrame, Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
    3131        }
    32        
    33     @Override
     32
     33        @Override
    3434        public void enterMode() {
    35         super.enterMode();
    36         Main.map.mapView.addMouseListener(this);
    37         Main.map.mapView.addMouseMotionListener(this);
    38     }
    39    
    40     @Override
     35                super.enterMode();
     36                Main.map.mapView.addMouseListener(this);
     37                Main.map.mapView.addMouseMotionListener(this);
     38        }
     39
     40        @Override
    4141        public void exitMode() {
    42         super.exitMode();
    43         Main.map.mapView.removeMouseListener(this);
    44         Main.map.mapView.removeMouseMotionListener(this);
    45     }
    46    
    47     @Override
    48     public void mouseMoved(MouseEvent e) {
    49         Way nearestWay = Main.map.mapView.getNearestWay(e.getPoint());
    50         if (nearestWay != highlightedWay) {
    51                 if (highlightedWay != null) {
    52                         highlightedWay.highlighted = false;
    53                 }
    54                 if (nearestWay != null) {
    55                         nearestWay.highlighted = true;
    56                 }
    57                 highlightedWay = nearestWay;
    58                         Main.map.mapView.repaint();     
    59         }
    60     }
    61    
    62     @Override
     42                super.exitMode();
     43                Main.map.mapView.removeMouseListener(this);
     44                Main.map.mapView.removeMouseMotionListener(this);
     45        }
     46
     47        @Override
     48        public void mouseMoved(MouseEvent e) {
     49                Way nearestWay = Main.map.mapView.getNearestWay(e.getPoint());
     50                if (nearestWay != highlightedWay) {
     51                        if (highlightedWay != null) {
     52                                highlightedWay.setHighlighted(false);
     53                        }
     54                        if (nearestWay != null) {
     55                                nearestWay.setHighlighted(true);
     56                        }
     57                        highlightedWay = nearestWay;
     58                        Main.map.mapView.repaint();
     59                }
     60        }
     61
     62        @Override
    6363        public void mouseClicked(MouseEvent e) {
    64         Way way = Main.map.mapView.getNearestWay(e.getPoint());
    65        
    66         Collection<Relation> selectedRelations = Main.main.getCurrentDataSet().getSelectedRelations();
    67        
    68         if (way != null) {
    69                
    70                 if (selectedRelations.isEmpty()) {
    71                         JOptionPane.showMessageDialog(Main.parent, tr("No relation is selected"));
    72                 }
    73                
    74                 for (OsmPrimitive rel:selectedRelations) {
    75                         Relation r = (Relation)rel;
    76                         RelationMember foundMember = null;
    77                         for (RelationMember member:r.getMembers()) {
    78                                 if (member.getMember() == way) {
    79                                         foundMember = member;
    80                                         break;
    81                                 }
    82                         }
    83                        
    84                         if (foundMember != null) {
    85                                 Main.main.undoRedo.add(new RemoveRelationMemberCommand(r, new RelationMember("", way)));
    86                         } else {
    87                                 Relation newRelation = new Relation(r);
    88                                 newRelation.addMember(new RelationMember("", way));
    89                     Main.main.undoRedo.add(new ChangeCommand(r, newRelation));
    90                         }
    91                 }
    92         }
    93     }
     64                Way way = Main.map.mapView.getNearestWay(e.getPoint());
    9465
    95        
     66                Collection<Relation> selectedRelations = Main.main.getCurrentDataSet().getSelectedRelations();
     67
     68                if (way != null) {
     69
     70                        if (selectedRelations.isEmpty()) {
     71                                JOptionPane.showMessageDialog(Main.parent, tr("No relation is selected"));
     72                        }
     73
     74                        for (OsmPrimitive rel:selectedRelations) {
     75                                Relation r = (Relation)rel;
     76                                RelationMember foundMember = null;
     77                                for (RelationMember member:r.getMembers()) {
     78                                        if (member.getMember() == way) {
     79                                                foundMember = member;
     80                                                break;
     81                                        }
     82                                }
     83
     84                                if (foundMember != null) {
     85                                        Main.main.undoRedo.add(new RemoveRelationMemberCommand(r, new RelationMember("", way)));
     86                                } else {
     87                                        Relation newRelation = new Relation(r);
     88                                        newRelation.addMember(new RelationMember("", way));
     89                                        Main.main.undoRedo.add(new ChangeCommand(r, newRelation));
     90                                }
     91                        }
     92                }
     93        }
     94
     95
    9696
    9797}
Note: See TracChangeset for help on using the changeset viewer.