Changeset 31 in josm for src/org/openstreetmap/josm/gui
- Timestamp:
- 2005-12-06T23:23:20+01:00 (19 years ago)
- Location:
- src/org/openstreetmap/josm/gui
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/org/openstreetmap/josm/gui/PreferenceDialog.java
r30 r31 243 243 map.add(Box.createVerticalGlue(), GBC.eol().fill(GBC.VERTICAL)); 244 244 245 245 246 246 tabPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT); 247 247 … … 261 261 pack(); 262 262 Dimension s = Main.main.getSize(); 263 setLocation( s.width/2-getWidth()/2,s.height/2-getHeight()/2);263 setLocation(Main.main.getX()+s.width/2-getWidth()/2, Main.main.getY()+s.height/2-getHeight()/2); 264 264 } 265 265 -
src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java
r30 r31 2 2 3 3 import java.awt.Graphics; 4 import java.io.FileWriter;5 import java.io.StringWriter;6 4 import java.util.LinkedList; 5 import java.util.Stack; 7 6 8 7 import javax.swing.Icon; … … 16 15 import org.openstreetmap.josm.data.osm.Track; 17 16 import org.openstreetmap.josm.data.osm.visitor.BoundingVisitor; 18 import org.openstreetmap.josm.data.osm.visitor.CsvVisitor;19 17 import org.openstreetmap.josm.data.osm.visitor.SimplePaintVisitor; 20 18 import org.openstreetmap.josm.data.projection.Projection; … … 41 39 */ 42 40 private LinkedList<Command> commands = new LinkedList<Command>(); 43 private LinkedList<String> debugDsBefore = new LinkedList<String>(); 41 /** 42 * The stack for redoing commands 43 */ 44 private Stack<Command> redoCommands = new Stack<Command>(); 44 45 45 46 /** … … 71 72 SimplePaintVisitor visitor = new SimplePaintVisitor(g, mv, null); 72 73 74 for (LineSegment ls : data.lineSegments) 75 visitor.visit(ls); 73 76 for (Track t : data.tracks) 74 77 visitor.visit(t); 75 for (LineSegment ls : data.lineSegments)76 visitor.visit(ls);77 78 for (Node n : data.nodes) 78 79 visitor.visit(n); … … 117 118 118 119 /** 120 * @return the last command added or <code>null</code> if no command in queue. 121 */ 122 public Command lastCommand() { 123 return commands.isEmpty() ? null : commands.getLast(); 124 } 125 126 /** 119 127 * Execute the command and add it to the intern command queue. Also mark all 120 128 * primitives in the command as modified. 121 129 */ 122 130 public void add(Command c) { 123 StringWriter sw = new StringWriter();124 CsvVisitor v = new CsvVisitor(sw);125 for (Node n : Main.main.ds.nodes) {126 v.visit(n);127 sw.append('\n');128 }129 for (LineSegment ls : Main.main.ds.lineSegments) {130 v.visit(ls);131 sw.append('\n');132 }133 for (Track t : Main.main.ds.tracks) {134 v.visit(t);135 sw.append('\n');136 }137 debugDsBefore.add(sw.getBuffer().toString());138 139 131 c.executeCommand(); 140 132 commands.add(c); 133 redoCommands.clear(); 134 // TODO: Replace with listener scheme 135 Main.main.undoAction.setEnabled(true); 136 Main.main.redoAction.setEnabled(false); 141 137 } 142 138 … … 149 145 Command c = commands.removeLast(); 150 146 c.undoCommand(); 151 152 //DEBUG 153 StringWriter sw = new StringWriter(); 154 CsvVisitor v = new CsvVisitor(sw); 155 for (Node n : Main.main.ds.nodes) { 156 v.visit(n); 157 sw.append('\n'); 158 } 159 for (LineSegment ls : Main.main.ds.lineSegments) { 160 v.visit(ls); 161 sw.append('\n'); 162 } 163 for (Track t : Main.main.ds.tracks) { 164 v.visit(t); 165 sw.append('\n'); 166 } 167 String s = Main.main.getMapFrame().mapView.editLayer().debugDsBefore.removeLast(); 168 if (!s.equals(sw.getBuffer().toString())) { 169 try { 170 FileWriter fw = new FileWriter("/home/imi/richtig"); 171 fw.append(sw.getBuffer().toString()); 172 fw.close(); 173 fw = new FileWriter("/home/imi/falsch"); 174 fw.append(s); 175 fw.close(); 176 } catch (Exception x) { 177 x.printStackTrace(); 178 } 179 } 147 redoCommands.push(c); 148 //TODO: Replace with listener scheme 149 Main.main.undoAction.setEnabled(!commands.isEmpty()); 150 Main.main.redoAction.setEnabled(true); 151 } 152 /** 153 * Redoes the last undoed command. 154 */ 155 public void redo() { 156 if (redoCommands.isEmpty()) 157 return; 158 Command c = redoCommands.pop(); 159 c.executeCommand(); 160 commands.add(c); 161 //TODO: Replace with listener scheme 162 Main.main.undoAction.setEnabled(true); 163 Main.main.redoAction.setEnabled(!redoCommands.isEmpty()); 180 164 } 181 165 }
Note:
See TracChangeset
for help on using the changeset viewer.