Changeset 23193 in osm
- Timestamp:
- 2010-09-15T19:01:04+02:00 (14 years ago)
- Location:
- applications/editors/josm/plugins
- Files:
-
- 40 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/irsrectify
-
Property svn:ignore
set to
build
-
Property svn:ignore
set to
-
applications/editors/josm/plugins/measurement/src/org/openstreetmap/josm/plugins/measurement/MeasurementPlugin.java
r19450 r23193 20 20 21 21 public MeasurementPlugin(PluginInformation info) { 22 22 super(info); 23 23 mode = new MeasurementMode(Main.map, "measurement", tr("measurement mode")); 24 24 btn = new IconToggleButton(mode); … … 47 47 } 48 48 public void layerRemoved(final Layer oldLayer) { 49 50 49 if (oldLayer != null && oldLayer == currentLayer) 50 MapView.removeLayerChangeListener(this); 51 51 } 52 52 }); -
applications/editors/josm/plugins/michigan_left/src/MichiganLeft/MichiganLeft.java
r22369 r23193 41 41 private class MichiganLeftAction extends JosmAction { 42 42 /** 43 * 44 43 * 44 */ 45 45 private static final long serialVersionUID = 1L; 46 46 private LinkedList<Command> cmds = new LinkedList<Command>(); … … 57 57 Collection<OsmPrimitive> mainSelection = Main.main.getCurrentDataSet() 58 58 .getSelected(); 59 59 60 60 ArrayList<OsmPrimitive> selection = new ArrayList<OsmPrimitive>(); 61 61 62 62 for (OsmPrimitive prim: mainSelection) selection.add(prim); 63 63 -
applications/editors/josm/plugins/simplifyarea/src/sk/zdila/josm/plugin/simplify/SimplifyAreaAction.java
r21870 r23193 36 36 public class SimplifyAreaAction extends JosmAction { 37 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 38 private static final long serialVersionUID = 6854238214548011750L; 39 40 public SimplifyAreaAction() { 41 super(tr("Simplify Area"), "simplify", tr("Delete unnecessary nodes from an area."), 42 Shortcut.registerShortcut("tools:simplifyArea", tr("Tool: {0}", tr("Simplify Area")), KeyEvent.VK_A, Shortcut.GROUP_EDIT, Shortcut.SHIFT_DEFAULT), true); 43 } 44 45 46 private List<Bounds> getCurrentEditBounds() { 47 final LinkedList<Bounds> bounds = new LinkedList<Bounds>(); 48 final OsmDataLayer dataLayer = Main.map.mapView.getEditLayer(); 49 for (final DataSource ds : dataLayer.data.dataSources) { 50 if (ds.bounds != null) { 51 bounds.add(ds.bounds); 52 } 53 } 54 return bounds; 55 } 56 57 58 private boolean isInBounds(final Node node, final List<Bounds> bounds) { 59 for (final Bounds b : bounds) { 60 if (b.contains(node.getCoor())) { 61 return true; 62 } 63 } 64 return false; 65 } 66 67 68 private boolean confirmWayWithNodesOutsideBoundingBox() { 69 final ButtonSpec[] options = new ButtonSpec[] { new ButtonSpec(tr("Yes, delete nodes"), ImageProvider.get("ok"), tr("Delete nodes outside of downloaded data regions"), null), 70 new ButtonSpec(tr("No, abort"), ImageProvider.get("cancel"), tr("Cancel operation"), null) }; 71 final int ret = HelpAwareOptionPane.showOptionDialog( 72 Main.parent, 73 "<html>" + trn("The selected way has nodes outside of the downloaded data region.", "The selected ways have nodes outside of the downloaded data region.", getCurrentDataSet().getSelectedWays().size()) 74 + "<br>" + tr("This can lead to nodes being deleted accidentally.") + "<br>" + tr("Do you want to delete them anyway?") + "</html>", 75 tr("Delete nodes outside of data regions?"), JOptionPane.WARNING_MESSAGE, null, // no special icon 76 options, options[0], null); 77 return ret == 0; 78 } 79 80 81 private void alertSelectAtLeastOneWay() { 82 HelpAwareOptionPane.showOptionDialog(Main.parent, tr("Please select at least one way to simplify."), tr("Warning"), JOptionPane.WARNING_MESSAGE, null); 83 } 84 85 86 private boolean confirmSimplifyManyWays(final int numWays) { 87 final ButtonSpec[] options = new ButtonSpec[] { new ButtonSpec(tr("Yes"), ImageProvider.get("ok"), tr("Simplify all selected ways"), null), 88 new ButtonSpec(tr("Cancel"), ImageProvider.get("cancel"), tr("Cancel operation"), null) }; 89 final int ret = HelpAwareOptionPane.showOptionDialog(Main.parent, tr("The selection contains {0} ways. Are you sure you want to simplify them all?", numWays), tr("Simplify ways?"), 90 JOptionPane.WARNING_MESSAGE, null, // no special icon 91 options, options[0], null); 92 return ret == 0; 93 } 94 95 96 @Override 97 public void actionPerformed(final ActionEvent e) { 98 final Collection<OsmPrimitive> selection = getCurrentDataSet().getSelected(); 99 100 final List<Bounds> bounds = getCurrentEditBounds(); 101 for (final OsmPrimitive prim : selection) { 102 if (prim instanceof Way && bounds.size() > 0) { 103 final Way way = (Way) prim; 104 // We check if each node of each way is at least in one download 105 // bounding box. Otherwise nodes may get deleted that are necessary by 106 // unloaded ways (see Ticket #1594) 107 for (final Node node : way.getNodes()) { 108 if (!isInBounds(node, bounds)) { 109 if (!confirmWayWithNodesOutsideBoundingBox()) { 110 return; 111 } 112 break; 113 } 114 } 115 } 116 } 117 final List<Way> ways = OsmPrimitive.getFilteredList(selection, Way.class); 118 if (ways.isEmpty()) { 119 alertSelectAtLeastOneWay(); 120 return; 121 } else if (ways.size() > 10) { 122 if (!confirmSimplifyManyWays(ways.size())) { 123 return; 124 } 125 } 126 127 final Collection<Command> allCommands = new LinkedList<Command>(); 128 for (final Way way : ways) { 129 final SequenceCommand simplifyCommand = simplifyWay(way); 130 if (simplifyCommand == null) { 131 continue; 132 } 133 allCommands.add(simplifyCommand); 134 } 135 136 if (!allCommands.isEmpty()) { 137 final SequenceCommand rootCommand = new SequenceCommand(trn("Simplify {0} way", "Simplify {0} ways", allCommands.size(), allCommands.size()), allCommands); 138 Main.main.undoRedo.add(rootCommand); 139 Main.map.repaint(); 140 } 141 } 142 143 144 /** 145 * Replies true if <code>node</code> is a required node which can't be removed in order to simplify the way. 146 * 147 * @param way 148 * the way to be simplified 149 * @param node 150 * the node to check 151 * @return true if <code>node</code> is a required node which can't be removed in order to simplify the way. 152 */ 153 private boolean isRequiredNode(final Way way, final Node node) { 154 final List<OsmPrimitive> parents = new LinkedList<OsmPrimitive>(node.getReferrers()); 155 parents.remove(way); 156 return !parents.isEmpty() || node.isTagged(); 157 } 158 159 160 /** 161 * Simplifies a way 162 * 163 * @param w 164 * the way to simplify 165 */ 166 private SequenceCommand simplifyWay(final Way w) { 167 final double angleThreshold = Double.parseDouble(Main.pref.get("simplify-area.angle", "10.0")); 168 final double distanceTreshold = Double.parseDouble(Main.pref.get("simplify-area.distance", "0.2")); 169 final double areaTreshold = Double.parseDouble(Main.pref.get("simplify-area.area", "5.0")); 170 171 final List<Node> nodes = w.getNodes(); 172 final int size = nodes.size(); 173 174 if (size == 0) { 175 return null; 176 } 177 178 final List<MoveCommand> moveCommandList = new ArrayList<MoveCommand>(); 179 180 final boolean closed = nodes.get(0).equals(nodes.get(size - 1)); 181 182 final List<Node> newNodes = new ArrayList<Node>(size); 183 184 if (closed) { 185 nodes.remove(size - 1); // remove end node ( = start node) 186 } 187 188 { 189 // remove near nodes 190 for (int i = 0; i < size; i++) { 191 final boolean closing = closed && i == size - 1; 192 final Node n1 = closing ? nodes.get(0) : nodes.get(i); 193 194 if (newNodes.isEmpty()) { 195 newNodes.add(n1); 196 continue; 197 } 198 199 final Node n2 = newNodes.get(newNodes.size() - 1); 200 201 final LatLon coord1 = n1.getCoor(); 202 final LatLon coord2 = n2.getCoor(); 203 204 if (isRequiredNode(w, n1) || isRequiredNode(w, n2) || computeDistance(coord1, coord2) > distanceTreshold) { 205 if (!closing) { 206 newNodes.add(n1); 207 } 208 } else { 209 moveCommandList.add(new MoveCommand(n2, new LatLon((coord1.lat() + coord2.lat()) / 2.0, (coord1.lon() + coord2.lon()) / 2.0))); 210 if (closing) { 211 newNodes.remove(0); 212 } 213 } 214 } 215 } 216 217 final int size2 = newNodes.size(); 218 219 final List<Node> newNodes2 = new ArrayList<Node>(size2); 220 221 Node prevNode = null; 222 LatLon coord1 = null; 223 LatLon coord2 = null; 224 225 for (int i = 0, len = size2 + 1 + (closed ? 1 : 0); i < len; i++) { 226 final Node n = newNodes.get(i % size2); 227 final LatLon coord3 = n.getCoor(); 228 229 if (coord1 != null) { 230 if (isRequiredNode(w, prevNode) || 231 Math.abs(computeBearing(coord2, coord3) - computeBearing(coord1, coord2)) > angleThreshold || 232 computeArea(coord1, coord2, coord3) > areaTreshold) { 233 newNodes2.add(prevNode); 234 } else { 235 coord2 = coord1; // at the end of the iteration preserve coord1 236 } 237 } else if (!closed && prevNode != null) { 238 newNodes2.add(prevNode); 239 } 240 241 coord1 = coord2; 242 coord2 = coord3; 243 prevNode = n; 244 } 245 246 if (closed) { 247 newNodes2.add(newNodes2.get(0)); // set end node ( = start node) 248 } 249 250 final HashSet<Node> delNodes = new HashSet<Node>(); 251 delNodes.addAll(nodes); 252 delNodes.removeAll(newNodes2); 253 254 if (delNodes.isEmpty()) { 255 return null; 256 } 257 258 final Collection<Command> cmds = new LinkedList<Command>(); 259 final Way newWay = new Way(w); 260 newWay.setNodes(newNodes2); 261 262 cmds.addAll(moveCommandList); 263 cmds.add(new ChangeCommand(w, newWay)); 264 cmds.add(new DeleteCommand(delNodes)); 265 return new SequenceCommand(trn("Simplify Way (remove {0} node)", "Simplify Way (remove {0} nodes)", delNodes.size(), delNodes.size()), cmds); 266 } 267 268 269 private double computeBearing(final LatLon coord1, final LatLon coord2) { 270 final double lon1 = Math.toRadians(coord1.getX()); 271 final double lat1 = Math.toRadians(coord1.getY()); 272 273 final double lon2 = Math.toRadians(coord2.getX()); 274 final double lat2 = Math.toRadians(coord2.getY()); 275 276 final double dLon = lon2 - lon1; 277 final double y = Math.sin(dLon) * Math.cos(lat2); 278 final double x = Math.cos(lat1) * Math.sin(lat2) - Math.sin(lat1) * Math.cos(lat2) * Math.cos(dLon); 279 return Math.toDegrees(Math.atan2(y, x)); 280 } 281 282 283 private double computeDistance(final LatLon coord1, final LatLon coord2) { 284 final double lon1 = Math.toRadians(coord1.getX()); 285 final double lon2 = Math.toRadians(coord2.getX()); 286 final double lat1 = Math.toRadians(coord1.getY()); 287 final double lat2 = Math.toRadians(coord2.getY()); 288 289 final double R = 6378137d; // m 290 final double dLon = lon2 - lon1; 291 final double dLat = lat2 - lat1; 292 final double a = Math.sin(dLat / 2d) * Math.sin(dLat / 2d) + Math.cos(lat1) * Math.cos(lat2) * Math.sin(dLon / 2d) * Math.sin(dLon / 2d); 293 final double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)); 294 return R * c; 295 } 296 297 298 private double computeArea(final LatLon coord1, final LatLon coord2, final LatLon coord3) { 299 final double a = computeDistance(coord1, coord2); 300 final double b = computeDistance(coord2, coord3); 301 final double c = computeDistance(coord3, coord1); 302 303 final double p = (a + b + c) / 2.0; 304 305 return Math.sqrt(p * (p - a) * (p - b) * (p - c)); 306 } 307 308 309 @Override 310 protected void updateEnabledState() { 311 if (getCurrentDataSet() == null) { 312 setEnabled(false); 313 } else { 314 updateEnabledState(getCurrentDataSet().getSelected()); 315 } 316 } 317 318 319 @Override 320 protected void updateEnabledState(final Collection<? extends OsmPrimitive> selection) { 321 setEnabled(selection != null && !selection.isEmpty()); 322 } 323 323 324 324 } -
applications/editors/josm/plugins/simplifyarea/src/sk/zdila/josm/plugin/simplify/SimplifyAreaPlugin.java
r21870 r23193 8 8 public class SimplifyAreaPlugin extends Plugin { 9 9 10 11 12 13 10 public SimplifyAreaPlugin(final PluginInformation info) { 11 super(info); 12 MainMenu.add(Main.main.menu.toolsMenu, new SimplifyAreaAction()); 13 } 14 14 15 15 } -
applications/editors/josm/plugins/smed/src/smed/Smed.java
r23178 r23193 26 26 27 27 public class Smed extends Plugin{ 28 29 private JMenuItem item;30 private SmedTabAction SmedTab;31 32 public Smed(PluginInformation info) {33 super(info);34 35 String os = "";36 String userHome = "";37 38 File pluginDir = Main.pref.getPluginsDirectory();39 String pluginDirName = pluginDir.getAbsolutePath();40 File splug = new File(pluginDirName + "/splug");41 if(!splug.exists()) splug.mkdir();42 43 // build smed_ifc.jar from smed.jar44 JarEntry ent = null;45 BufferedInputStream inp = null;46 String entName = null;47 byte[] buffer = new byte[16384];48 int len;49 28 50 try { 51 JarFile file = new JarFile(pluginDirName + "/smed.jar"); 52 FileOutputStream fos = new FileOutputStream(pluginDirName + "/splug/smed_ifc.jar"); 53 JarOutputStream jos = new JarOutputStream(fos); 54 BufferedOutputStream oos = new BufferedOutputStream( jos); 29 private JMenuItem item; 30 private SmedTabAction SmedTab; 55 31 56 ent = file.getJarEntry("smed/plug/ifc/SmedPluggable.class"); 57 inp = new BufferedInputStream(file.getInputStream( ent )); 58 entName = ent.getName(); 32 public Smed(PluginInformation info) { 33 super(info); 59 34 60 jos.putNextEntry(new JarEntry(entName)); 61 62 while ((len = inp.read(buffer)) > 0) { 63 oos.write(buffer, 0, len); 35 String os = ""; 36 String userHome = ""; 37 38 File pluginDir = Main.pref.getPluginsDirectory(); 39 String pluginDirName = pluginDir.getAbsolutePath(); 40 File splug = new File(pluginDirName + "/splug"); 41 if(!splug.exists()) splug.mkdir(); 42 43 // build smed_ifc.jar from smed.jar 44 JarEntry ent = null; 45 BufferedInputStream inp = null; 46 String entName = null; 47 byte[] buffer = new byte[16384]; 48 int len; 49 50 try { 51 JarFile file = new JarFile(pluginDirName + "/smed.jar"); 52 FileOutputStream fos = new FileOutputStream(pluginDirName + "/splug/smed_ifc.jar"); 53 JarOutputStream jos = new JarOutputStream(fos); 54 BufferedOutputStream oos = new BufferedOutputStream( jos); 55 56 ent = file.getJarEntry("smed/plug/ifc/SmedPluggable.class"); 57 inp = new BufferedInputStream(file.getInputStream( ent )); 58 entName = ent.getName(); 59 60 jos.putNextEntry(new JarEntry(entName)); 61 62 while ((len = inp.read(buffer)) > 0) { 63 oos.write(buffer, 0, len); 64 64 } 65 65 66 67 68 69 70 71 72 73 74 75 66 oos.flush(); 67 inp.close(); 68 69 ent = file.getJarEntry("smed/plug/ifc/SmedPluginManager.class"); 70 inp = new BufferedInputStream(file.getInputStream( ent )); 71 entName = ent.getName(); 72 jos.putNextEntry(new JarEntry(entName)); 73 74 while ((len = inp.read(buffer)) > 0) { 75 oos.write(buffer, 0, len); 76 76 } 77 77 78 oos.flush(); 79 oos.close(); 80 fos.flush(); 81 fos.close(); 82 inp.close(); 83 84 } catch (Exception e) { 85 e.printStackTrace(); 86 } 78 oos.flush(); 79 oos.close(); 80 fos.flush(); 81 fos.close(); 82 inp.close(); 87 83 88 89 // add smed_ifc.jar to classpath (josm need this archive, or perhaps only the interface) 90 File f = new java.io.File(pluginDirName + "/splug/smed_ifc.jar"); 91 ClassLoader myClassLoader = Thread.currentThread().getContextClassLoader(); 84 } catch (Exception e) { 85 e.printStackTrace(); 86 } 92 87 93 try {94 Method addUrlMethod = URLClassLoader.class.getDeclaredMethod("addURL", new Class[]{URL.class});95 addUrlMethod.setAccessible(true);96 addUrlMethod.invoke(myClassLoader, f.toURI().toURL());97 } catch (Exception e) {98 e.printStackTrace();99 }100 101 SmedTab = new SmedTabAction();102 item = Main.main.menu.toolsMenu.add(SmedTab);103 104 item.setEnabled(false);105 88 106 } 107 108 @Override 109 public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) { 110 if (oldFrame == null && newFrame != null) { 111 item.setEnabled(true); 112 } else { 113 item.setEnabled(false); 114 // SmpDialog.CloseDialog(); 115 } 116 } 89 // add smed_ifc.jar to classpath (josm need this archive, or perhaps only the interface) 90 File f = new java.io.File(pluginDirName + "/splug/smed_ifc.jar"); 91 ClassLoader myClassLoader = Thread.currentThread().getContextClassLoader(); 92 93 try { 94 Method addUrlMethod = URLClassLoader.class.getDeclaredMethod("addURL", new Class[]{URL.class}); 95 addUrlMethod.setAccessible(true); 96 addUrlMethod.invoke(myClassLoader, f.toURI().toURL()); 97 } catch (Exception e) { 98 e.printStackTrace(); 99 } 100 101 SmedTab = new SmedTabAction(); 102 item = Main.main.menu.toolsMenu.add(SmedTab); 103 104 item.setEnabled(false); 105 106 } 107 108 @Override 109 public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) { 110 if (oldFrame == null && newFrame != null) { 111 item.setEnabled(true); 112 } else { 113 item.setEnabled(false); 114 // SmpDialog.CloseDialog(); 115 } 116 } 117 117 118 118 } -
applications/editors/josm/plugins/smed/src/smed/plug/SmedPluginApp.java
r23178 r23193 12 12 public class SmedPluginApp implements Runnable { 13 13 14 15 16 17 18 19 20 21 14 @Override 15 public void run() { 16 try { 17 runPlugins(); 18 } catch (IOException e) { 19 e.printStackTrace(); 20 } 21 } 22 22 23 24 25 26 27 28 23 public static void runPlugins() throws IOException { 24 String pluginDirName = Main.pref.getPluginsDirectory().getAbsolutePath(); 25 26 List<SmedPluggable> plugins = SmedPluginLoader.loadPlugins(new File(pluginDirName + "/splug")); 27 28 } 29 29 30 30 } -
applications/editors/josm/plugins/smed/src/smed/plug/ifc/SmedPluggable.java
r23178 r23193 6 6 public interface SmedPluggable { 7 7 8 9 10 11 12 13 8 boolean start(); 9 boolean start(JComponent panel); 10 boolean stop(); 11 String getName(); 12 13 void setPluginManager(SmedPluginManager manager); 14 14 } 15 15 -
applications/editors/josm/plugins/smed/src/smed/plug/ifc/SmedPluginManager.java
r23178 r23193 2 2 3 3 public interface SmedPluginManager { 4 4 void showVisualMessage(String message); 5 5 } -
applications/editors/josm/plugins/smed/src/smed/plug/util/JARFileFilter.java
r23178 r23193 6 6 public class JARFileFilter implements FileFilter { 7 7 8 9 10 11 8 @Override 9 public boolean accept(File f) { 10 return f.getName().toLowerCase().endsWith(".jar"); 11 } 12 12 13 13 } -
applications/editors/josm/plugins/smed/src/smed/plug/util/SmedPluginLoader.java
r23178 r23193 19 19 public class SmedPluginLoader { 20 20 21 22 23 24 25 26 27 28 29 30 31 32 21 public static List<SmedPluggable> loadPlugins(File plugDir) throws IOException { 22 File[] plugJars = plugDir.listFiles(new JARFileFilter()); 23 24 URL[] urls = fileArrayToURLArray(plugJars); 25 if(urls == null) return null; 26 27 ClassLoader cl = new URLClassLoader(urls); 28 List<Class<SmedPluggable>> plugClasses = extractClassesFromJARs(plugJars, cl); 29 30 if(plugClasses == null) return null; 31 else return createPluggableObjects(plugClasses); 32 } 33 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 34 private static List<SmedPluggable> createPluggableObjects(List<Class<SmedPluggable>> pluggables) { 35 List<SmedPluggable> plugs = new ArrayList<SmedPluggable>(pluggables.size()); 36 for(Class<SmedPluggable> plug : pluggables) { 37 try { 38 plugs.add(plug.newInstance()); 39 } catch (InstantiationException e) { 40 System.err.println("Can't instantiate plugin: " + plug.getName()); 41 e.printStackTrace(); 42 } catch (IllegalAccessException e) { 43 System.err.println("IllegalAccess for plugin: " + plug.getName()); 44 e.printStackTrace(); 45 } 46 } 47 48 return plugs; 49 } 50 50 51 52 53 54 55 56 51 private static List<Class<SmedPluggable>> extractClassesFromJARs(File[] jars, ClassLoader cl) throws FileNotFoundException, IOException { 52 List<Class<SmedPluggable>> classes = new ArrayList<Class<SmedPluggable>>(); 53 54 for(File jar : jars) { 55 classes.addAll(extractClassesFromJAR(jar, cl)); 56 } 57 57 58 59 60 58 if(classes.isEmpty()) return null; 59 else return classes; 60 } 61 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 62 @SuppressWarnings("unchecked") 63 private static Collection<? extends Class<SmedPluggable>> extractClassesFromJAR (File jar, ClassLoader cl) throws FileNotFoundException, IOException { 64 List<Class<SmedPluggable>> classes = new ArrayList<Class<SmedPluggable>>(); 65 JarInputStream jaris = new JarInputStream(new FileInputStream(jar)); 66 JarEntry ent = null; 67 68 while ((ent = jaris.getNextJarEntry()) != null) { 69 String entName = ent.getName(); //.toLowerCase(); 70 71 if (entName.endsWith(".class")) { 72 try { 73 Class<?> cls = cl.loadClass(entName.substring(0, entName.length()- 6).replace('/', '.')); 74 if(isPluggableSmedClass(cls)) classes.add((Class<SmedPluggable>) cls); 75 } catch (ClassNotFoundException e) { 76 System.err.println("Can't load Class" + entName); 77 e.printStackTrace(); 78 } 79 } 80 } 81 82 jaris.close(); 83 84 return classes; 85 } 86 86 87 88 89 90 91 92 93 87 private static boolean isPluggableSmedClass(Class<?> cls) { 88 for (Class<?> i: cls.getInterfaces()) { 89 if (i.equals(SmedPluggable.class)) return true; 90 } 91 92 return false; 93 } 94 94 95 96 97 98 99 100 101 102 103 104 105 106 107 95 private static URL[] fileArrayToURLArray(File[] files) throws MalformedURLException { 96 // splug contains at least smed_ifc.jar, but smed_ifc.jar isn't pluggable 97 if(files.length <= 1) return null; 98 99 URL[] urls = new URL[files.length]; 100 101 102 for(int i = 0; i < files.length; i++) { 103 urls[i] = files[i].toURI().toURL(); 104 } 105 106 return urls; 107 } 108 108 } -
applications/editors/josm/plugins/smed/src/smed/tabs/SmedTabAction.java
r23178 r23193 17 17 public class SmedTabAction extends JosmAction { 18 18 19 /** 20 * 21 */ 22 private static final long serialVersionUID = 1L; 23 24 public SmedTabAction() { 25 super( "Seekarten Editor", "Smed","Seekarten Editor", Shortcut.registerShortcut( 26 "tools:Semmaps", 27 tr("Tool: {0}", "Seekarten Editor"), KeyEvent.VK_K, //$NON-NLS-1$ //$NON-NLS-2$ 28 Shortcut.GROUP_EDIT, Shortcut.SHIFT_DEFAULT), true); 19 /** 20 * 21 */ 22 private static final long serialVersionUID = 1L; 29 23 30 try { 31 UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); 32 } catch (Exception e) { 33 e.printStackTrace(); 34 } 35 } 24 public SmedTabAction() { 25 super( "Seekarten Editor", "Smed","Seekarten Editor", Shortcut.registerShortcut( 26 "tools:Semmaps", 27 tr("Tool: {0}", "Seekarten Editor"), KeyEvent.VK_K, //$NON-NLS-1$ //$NON-NLS-2$ 28 Shortcut.GROUP_EDIT, Shortcut.SHIFT_DEFAULT), true); 36 29 37 38 @Override 39 public void actionPerformed(ActionEvent e) { 40 SwingUtilities.invokeLater(new Runnable() { 41 public void run() { 42 createAndShowTabs(); 43 } 44 }); 45 } 30 try { 31 UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); 32 } catch (Exception e) { 33 e.printStackTrace(); 34 } 35 } 46 36 47 37 48 protected void createAndShowTabs() { 38 @Override 39 public void actionPerformed(ActionEvent e) { 40 SwingUtilities.invokeLater(new Runnable() { 41 public void run() { 42 createAndShowTabs(); 43 } 44 }); 45 } 46 47 48 protected void createAndShowTabs() { 49 49 //Create and set up the window. 50 50 JFrame frame = new JFrame("TabbedPaneDemo"); … … 52 52 // frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); 53 53 frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); 54 54 55 55 //Add content to the window. 56 56 frame.add(new SmedTabbedPane(), BorderLayout.CENTER); … … 59 59 frame.pack(); 60 60 frame.setVisible(true); 61 61 } 62 62 63 63 -
applications/editors/josm/plugins/smed/src/smed/tabs/SmedTabbedPane.java
r23178 r23193 21 21 public class SmedTabbedPane extends JPanel { 22 22 23 24 * 25 26 23 /** 24 * 25 */ 26 private static final long serialVersionUID = 1L; 27 27 28 29 30 31 32 33 34 35 36 37 38 39 28 @SuppressWarnings("null") 29 public SmedTabbedPane() { 30 super(new GridLayout(1, 1)); 31 32 List<SmedPluggable> plugins = null; 33 String pluginDirName = Main.pref.getPluginsDirectory().getAbsolutePath(); 34 try { 35 plugins = SmedPluginLoader.loadPlugins(new File(pluginDirName + "/splug")); 36 } catch (IOException e) { 37 e.printStackTrace(); 38 } 39 40 40 Icon icon = null; 41 41 JTabbedPane tabbedPane = new JTabbedPane(); 42 42 43 44 45 46 43 JComponent panel1; 44 if(plugins == null) { 45 panel1 = makeTextPanel("Panel #1"); 46 tabbedPane.addTab("Tab 1", icon , panel1, "Does nothing"); 47 47 } else { 48 49 50 48 panel1 = new JPanel(); 49 plugins.get(0).start(panel1); 50 tabbedPane.addTab(plugins.get(0).getName(), icon , panel1, "say hello"); 51 51 } 52 53 tabbedPane.setMnemonicAt(0, KeyEvent.VK_1);54 52 55 53 tabbedPane.setMnemonicAt(0, KeyEvent.VK_1); 54 55 56 56 JComponent panel2 = makeTextPanel("Panel #2"); 57 57 tabbedPane.addTab("Tab 2", icon, panel2, "Does twice as much nothing"); 58 58 tabbedPane.setMnemonicAt(1, KeyEvent.VK_2); 59 59 60 60 JComponent panel3 = makeTextPanel("Panel #3"); 61 61 tabbedPane.addTab("Tab 3", icon, panel3, "Still does nothing"); 62 62 tabbedPane.setMnemonicAt(2, KeyEvent.VK_3); 63 63 64 64 JComponent panel4 = makeTextPanel( "Panel #4 (has a preferred size of 410 x 50)."); 65 65 panel4.setPreferredSize(new Dimension(410, 50)); 66 66 tabbedPane.addTab("Tab 4", icon, panel4, "Does nothing at all"); 67 67 tabbedPane.setMnemonicAt(3, KeyEvent.VK_4); 68 68 69 69 //Add the tabbed pane to this panel. 70 70 add(tabbedPane); 71 71 72 72 //The following line enables to use scrolling tabs. 73 73 tabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT); 74 74 } 75 75 76 77 78 79 80 76 private JComponent makeTextPanel(String text) { 77 JPanel panel = new JPanel(false); 78 JLabel filler = new JLabel(text); 79 filler.setHorizontalAlignment(JLabel.CENTER); 80 panel.setLayout(new GridLayout(1, 1)); 81 81 panel.add(filler); 82 83 84 82 83 return panel; 84 } 85 85 } -
applications/editors/josm/plugins/toms/src/toms/Messages.java
r23007 r23193 5 5 6 6 public class Messages { 7 7 private static final String BUNDLE_NAME = "toms.msg.messages"; //$NON-NLS-1$ 8 8 9 10 9 private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle 10 .getBundle(BUNDLE_NAME); 11 11 12 13 12 private Messages() { 13 } 14 14 15 16 17 18 19 20 21 15 public static String getString(String key) { 16 try { 17 return RESOURCE_BUNDLE.getString(key); 18 } catch (MissingResourceException e) { 19 return '!' + key + '!'; 20 } 21 } 22 22 } -
applications/editors/josm/plugins/toms/src/toms/Toms.java
r23121 r23193 53 53 public class Toms extends Plugin { 54 54 55 56 55 private JMenuItem Smp; 56 private SmpDialogAction SmpDialog; 57 57 58 59 58 public Toms(PluginInformation info) { 59 super(info); 60 60 61 62 61 String os = ""; //$NON-NLS-1$ 62 String userHome = ""; //$NON-NLS-1$ 63 63 64 65 66 64 SmpDialog = new SmpDialogAction(); 65 Smp = Main.main.menu.toolsMenu.add(SmpDialog); 66 // Smp = MainMenu.add(Main.main.menu.toolsMenu, SmpDialog); 67 67 68 69 70 71 68 SmpDialog.setSmpItem(Smp); 69 SmpDialog.setOs(os); 70 SmpDialog.setUserHome(userHome); 71 Smp.setEnabled(false); 72 72 73 74 75 76 77 78 79 80 81 82 83 73 File pluginDir = Main.pref.getPluginsDirectory(); 74 String pluginDirName = pluginDir.getAbsolutePath(); 75 File tplug = new File(pluginDirName + "/tplug"); 76 if(!tplug.exists()) tplug.mkdir(); 77 78 // build ifc.jar from toms.jar 79 JarEntry ent = null; 80 BufferedInputStream inp = null; 81 String entName = null; 82 byte[] buffer = new byte[16384]; 83 int len; 84 84 85 86 87 88 89 85 try { 86 JarFile file = new JarFile(pluginDirName + "/toms.jar"); 87 FileOutputStream fos = new FileOutputStream(pluginDirName + "/tplug/ifc.jar"); 88 JarOutputStream jos = new JarOutputStream(fos); 89 BufferedOutputStream oos = new BufferedOutputStream( jos); 90 90 91 92 93 91 ent = file.getJarEntry("toms/plug/ifc/Pluggable.class"); 92 inp = new BufferedInputStream(file.getInputStream( ent )); 93 entName = ent.getName(); 94 94 95 96 97 98 95 jos.putNextEntry(new JarEntry(entName)); 96 97 while ((len = inp.read(buffer)) > 0) { 98 oos.write(buffer, 0, len); 99 99 } 100 100 101 102 103 104 105 106 107 108 109 110 101 oos.flush(); 102 inp.close(); 103 104 ent = file.getJarEntry("toms/plug/ifc/PluginManager.class"); 105 inp = new BufferedInputStream(file.getInputStream( ent )); 106 entName = ent.getName(); 107 jos.putNextEntry(new JarEntry(entName)); 108 109 while ((len = inp.read(buffer)) > 0) { 110 oos.write(buffer, 0, len); 111 111 } 112 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 113 oos.flush(); 114 oos.close(); 115 fos.flush(); 116 fos.close(); 117 inp.close(); 118 119 } catch (Exception e) { 120 e.printStackTrace(); 121 } 122 123 124 // add ifc.jar to classpath (josm need this archive, or perhaps only the interface) 125 File f = new java.io.File(pluginDirName + "/tplug/ifc.jar"); 126 ClassLoader myClassLoader = Thread.currentThread().getContextClassLoader(); 127 127 128 129 130 131 132 133 134 128 try { 129 Method addUrlMethod = URLClassLoader.class.getDeclaredMethod("addURL", new Class[]{URL.class}); 130 addUrlMethod.setAccessible(true); 131 addUrlMethod.invoke(myClassLoader, f.toURI().toURL()); 132 } catch (Exception e) { 133 e.printStackTrace(); 134 } 135 135 136 137 138 139 140 141 136 137 try { 138 PluginApp.runPlugins(); 139 } catch (Exception e) { 140 e.printStackTrace(); 141 } 142 142 143 143 } 144 144 145 145 146 147 148 149 150 151 152 153 154 146 @Override 147 public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) { 148 if (oldFrame == null && newFrame != null) { 149 Smp.setEnabled(true); 150 } else { 151 Smp.setEnabled(false); 152 SmpDialog.CloseDialog(); 153 } 154 } 155 155 156 156 } -
applications/editors/josm/plugins/toms/src/toms/dialogs/SmpDialogAction.java
r23179 r23193 62 62 63 63 public class SmpDialogAction extends JosmAction { 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 * 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 64 private static final long serialVersionUID = -2976230949744302905L; 65 66 /** 67 * lokale Variable, private 68 */ 69 private SmpDialogAction dia = null; // Variable für den Handle von 70 // SmpDialogAction 71 private Buoy buoy = null; // Variable für Objekte des Typs "Tonne" // 72 // @jve:decl-index=0: 73 private boolean isOpen = false; // zeigt den Status des Dialogs an 74 private Node onode = null; // gemerkter Knoten 75 private Buoy obuoy = null; // gemerkte Tonne // @jve:decl-index=0: 76 private JMenuItem SmpItem = null; // Info über item in der Werkzeugleiste 77 private String smt = ""; // value vom key "seamark:type" // @jve:decl-index=0: //$NON-NLS-1$ 78 private String smb = ""; // value vom key "seamark" // @jve:decl-index=0: //$NON-NLS-1$ 79 private Collection<? extends OsmPrimitive> Selection = null; // @jve:decl-index=0: 80 private OsmPrimitive SelNode = null; 81 private String Os = ""; // @jve:decl-index=0: //$NON-NLS-1$ 82 private String UserHome = ""; // @jve:decl-index=0: //$NON-NLS-1$ 83 84 // SelectionChangedListner der in die Eventqueue von josm eingehängt wird 85 private SelectionChangedListener SmpListener = new SelectionChangedListener() { 86 public void selectionChanged(Collection<? extends OsmPrimitive> newSelection) { 87 Node node; 88 Selection = newSelection; 89 90 // System.out.println("hello"); 91 for (OsmPrimitive osm : Selection) { 92 if (osm instanceof Node) { 93 node = (Node) osm; 94 if (Selection.size() == 1) 95 // Absicherung gegen Doppelevents 96 if (node.compareTo(SelNode) != 0) { 97 SelNode = node; 98 parseSeaMark(); 99 buoy.paintSign(); 100 } 101 } 102 } 103 104 Selection = null; 105 106 } 107 }; 108 109 /** 110 * lokale Variable der Maske 111 */ 112 private JDialog dM01SeaMap = null; 113 private JPanel pM01SeaMap = null; 114 private JLabel lM01Head = null; 115 private JLabel lM01Region = null; 116 private JLabel lM02Region = null; 117 public ButtonGroup bgM01Region = null; 118 public JRadioButton rbM01RegionA = null; 119 public JRadioButton rbM01RegionB = null; 120 public JLabel lM01Icon = null; // Shape 121 public JLabel lM02Icon = null; // Light 122 public JLabel lM03Icon = null; // Reflector 123 public JLabel lM04Icon = null; // Racon 124 public JLabel lM05Icon = null; // Fog 125 public JLabel lM01FireMark = null; 126 private JLabel lM01TypeOfMark = null; 127 public JComboBox cbM01TypeOfMark = null; 128 public JLabel lM01CatOfMark = null; 129 public JComboBox cbM01CatOfMark = null; 130 public JLabel lM01StyleOfMark = null; 131 public JComboBox cbM01StyleOfMark = null; 132 private JLabel lM01Name = null; 133 public JTextField tfM01Name = null; 134 private JLabel lM01Props02 = null; 135 public JCheckBox cM01TopMark = null; 136 public JComboBox cbM01TopMark = null; 137 public JCheckBox cM01Radar = null; 138 public JCheckBox cM01Racon = null; 139 public JComboBox cbM01Racon = null; 140 public JTextField tfM01Racon = null; 141 public JLabel lM01Racon = null; 142 public JCheckBox cM01Fog = null; 143 public JComboBox cbM01Fog = null; 144 public JLabel lM01FogGroup = null; 145 public JTextField tfM01FogGroup = null; 146 public JLabel lM01FogPeriod = null; 147 public JTextField tfM01FogPeriod = null; 148 public JCheckBox cM01Fired = null; 149 public ButtonGroup bgM01Fired = null; 150 public JRadioButton rbM01Fired1 = null; 151 public JRadioButton rbM01FiredN = null; 152 public JLabel lM01Kennung = null; 153 public JComboBox cbM01Kennung = null; 154 public JLabel lM01Height = null; 155 public JTextField tfM01Height = null; 156 public JLabel lM01Range = null; 157 public JTextField tfM01Range = null; 158 public JLabel lM01Group = null; 159 public JTextField tfM01Group = null; 160 public JLabel lM01RepeatTime = null; 161 public JTextField tfM01RepeatTime = null; 162 public JLabel lM01Sector = null; 163 public JComboBox cbM01Sector = null; 164 public JLabel lM01Colour = null; 165 public JComboBox cbM01Colour = null; 166 public JLabel lM01Bearing = null; 167 public JTextField tfM01Bearing = null; 168 public JTextField tfM02Bearing = null; 169 public JTextField tfM01Radius = null; 170 public JButton bM01Save = null; 171 public JButton bM01Close = null; 172 public JCheckBox cM01IconVisible = null; 173 public JTextField sM01StatusBar = null; 174 175 public boolean paintlock = false; 176 177 public JMenuItem getSmpItem() { 178 return SmpItem; 179 } 180 181 public void setSmpItem(JMenuItem smpItem) { 182 SmpItem = smpItem; 183 } 184 185 public boolean isOpen() { 186 return isOpen; 187 } 188 189 public void setOpen(boolean isOpen) { 190 this.isOpen = isOpen; 191 } 192 193 public String getOs() { 194 return Os; 195 } 196 197 public void setOs(String os) { 198 Os = os; 199 } 200 201 public String getUserHome() { 202 return UserHome; 203 } 204 205 public void setUserHome(String userHome) { 206 UserHome = userHome; 207 } 208 209 public SmpDialogAction() { 210 super( 211 Messages.getString("SmpDialogAction.4"), "Smp", Messages.getString("SmpDialogAction.0"), Shortcut //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 212 .registerShortcut( 213 "tools:Semarks", //$NON-NLS-1$ 214 tr("Tool: {0}", Messages.getString("SmpDialogAction.9")), KeyEvent.VK_S, //$NON-NLS-1$ //$NON-NLS-2$ 215 Shortcut.GROUP_EDIT, Shortcut.SHIFT_DEFAULT), true); 216 217 dia = this; 218 String str = Main.pref.get("mappaint.style.sources"); //$NON-NLS-1$ 219 if (!str.contains("dev.openseamap.org")) { //$NON-NLS-1$ 220 if (!str.isEmpty()) //$NON-NLS-1$ 221 str += new String(new char[] { 0x1e }); 222 Main.pref.put("mappaint.style.sources", str //$NON-NLS-1$ 223 + "http://dev.openseamap.org/josm/seamark_styles.xml"); //$NON-NLS-1$ 224 } 225 str = Main.pref.get("color.background"); //$NON-NLS-1$ 226 if (str.equals("#000000") || str.isEmpty()) //$NON-NLS-1$ //$NON-NLS-2$ 227 Main.pref.put("color.background", "#606060"); //$NON-NLS-1$ //$NON-NLS-2$ 228 } 229 230 public void CloseDialog() { 231 onode = null; 232 DataSet.removeSelectionListener(SmpListener); 233 Selection = null; 234 235 if (isOpen) 236 dM01SeaMap.dispose(); 237 isOpen = false; 238 239 } 240 241 public void actionPerformed(ActionEvent e) { 242 243 /* 244 * int option = JOptionPane.showConfirmDialog(Main.parent, 245 * tr("THIS IS EXPERIMENTAL. Save your work and verify before uploading.\n" 246 * + "Are you really sure to continue?"), 247 * tr("Please abort if you are not sure"), JOptionPane.YES_NO_OPTION, 248 * JOptionPane.WARNING_MESSAGE); 249 * 250 * if (option != JOptionPane.YES_OPTION) { return; } 251 */ 252 253 onode = null; 254 obuoy = null; 255 256 SwingUtilities.invokeLater(new Runnable() { 257 public void run() { 258 JDialog dialog = getDM01SeaMap(); 259 260 if (SmpItem == null) { 261 } 262 dialog.setVisible(true); 263 } 264 }); 265 266 setOpen(true); 267 268 if (SmpItem == null) { 269 return; 270 } 271 SmpItem.setEnabled(false); 272 273 // Ausprobe: Möglichkeit der Benachrichtigung, wenn etwas neu 274 // selektiert wird (ueber SelectionChangedListener) 275 // private Collection<? extends OsmPrimitive> sel; 276 // siehe org.openstreetmap.josm.plugins.osb -> OsbLayer.java 277 // Einhängen des Listeners in die Eventqueue von josm 278 DataSet.addSelectionListener(SmpListener); 279 } 280 281 private void PicRebuild() { 282 283 DataSet ds = Main.main.getCurrentDataSet(); 284 285 if (obuoy == null) { 286 return; 287 } 288 289 Node n = obuoy.getNode(); 290 291 if (n != null) { 292 Command c; 293 294 if (smb != "") { //$NON-NLS-1$ 295 296 c = new ChangePropertyCommand(n, "seamark", smb); //$NON-NLS-1$ 297 c.executeCommand(); 298 ds.fireSelectionChanged(); 299 300 smb = ""; //$NON-NLS-1$ 301 } 302 303 if (smt != "") { //$NON-NLS-1$ 304 305 c = new ChangePropertyCommand(n, "seamark:type", smt); //$NON-NLS-1$ 306 c.executeCommand(); 307 ds.fireSelectionChanged(); 308 309 smt = ""; //$NON-NLS-1$ 310 } 311 } 312 313 obuoy = null; 314 315 } 316 317 private void parseSeaMark() { 318 319 int nodes = 0; 320 Node node = null; 321 Collection<Node> selection = null; 322 Map<String, String> keys; 323 DataSet ds; 324 325 ds = Main.main.getCurrentDataSet(); 326 327 if (ds == null) { 328 buoy = new BuoyUkn(this, Messages.getString("SmpDialogAction.26")); //$NON-NLS-1$ 329 buoy.setNode(null); 330 return; 331 } 332 333 selection = ds.getSelectedNodes(); 334 nodes = selection.size(); 335 336 if (nodes == 0) { 337 buoy = new BuoyUkn(this, Messages.getString("SmpDialogAction.27")); //$NON-NLS-1$ 338 buoy.setNode(null); 339 return; 340 } 341 342 if (nodes > 1) { 343 buoy = new BuoyUkn(this, Messages.getString("SmpDialogAction.28")); //$NON-NLS-1$ 344 buoy.setNode(null); 345 return; 346 } 347 348 Iterator<Node> it = selection.iterator(); 349 node = it.next(); 350 351 if (onode != null) 352 if (node.equals(onode)) 353 return; 354 355 // Knoten wurde gewechselt -> die alten tags (benutzt zum Ausblenden der 356 // Pictogramme) wiederherstellen 357 if (obuoy != null) 358 PicRebuild(); 359 360 onode = node; 361 362 cM01IconVisible.setEnabled(true); 363 cM01IconVisible.setIcon(new ImageIcon(getClass().getResource( 364 "/images/Auge.png"))); //$NON-NLS-1$ 365 366 cbM01TypeOfMark.setEnabled(true); 367 368 // Soweit das Vorspiel. Ab hier beginnt das Parsen 369 String type = ""; //$NON-NLS-1$ 370 String str = ""; //$NON-NLS-1$ 371 372 keys = node.getKeys(); 373 374 // vorsorglich den Namen holen und verwenden, wenn es ein 375 // Seezeichen ist. Name kann durch die weiteren Tags ueber- 376 // schrieben werden 377 378 if (keys.containsKey("seamark:type")) //$NON-NLS-1$ 379 type = keys.get("seamark:type"); //$NON-NLS-1$ 380 381 if (type.equals("buoy_lateral") || type.equals("beacon_lateral") //$NON-NLS-1$ //$NON-NLS-2$ 382 || keys.containsKey("seamark:buoy_lateral:category") //$NON-NLS-1$ 383 || keys.containsKey("seamark:buoy_lateral:shape") //$NON-NLS-1$ 384 || keys.containsKey("seamark:buoy_lateral:colour") //$NON-NLS-1$ 385 || keys.containsKey("seamark:beacon_lateral:category") //$NON-NLS-1$ 386 || keys.containsKey("seamark:beacon_lateral:shape") //$NON-NLS-1$ 387 || keys.containsKey("seamark:beacon_lateral:colour")) { //$NON-NLS-1$ 388 buoy = new BuoyLat(this, node); 389 return; 390 391 } else if (type.equals("buoy_cardinal") || type.equals("beacon_cardinal") //$NON-NLS-1$ //$NON-NLS-2$ 392 || keys.containsKey("seamark:buoy_cardinal:category") //$NON-NLS-1$ 393 || keys.containsKey("seamark:buoy_cardinal:shape") //$NON-NLS-1$ 394 || keys.containsKey("seamark:buoy_cardinal:colour") //$NON-NLS-1$ 395 || keys.containsKey("seamark:beacon_cardinal:category") //$NON-NLS-1$ 396 || keys.containsKey("seamark:beacon_cardinal:shape") //$NON-NLS-1$ 397 || keys.containsKey("seamark:beacon_cardinal:colour")) { //$NON-NLS-1$ 398 buoy = new BuoyCard(this, node); 399 return; 400 401 } else if (type.equals("buoy_safe_water") //$NON-NLS-1$ 402 || type.equals("beacon_safe_water") //$NON-NLS-1$ 403 || keys.containsKey("seamark:buoy_safe_water:shape") //$NON-NLS-1$ 404 || keys.containsKey("seamark:buoy_safe_water:colour") //$NON-NLS-1$ 405 || keys.containsKey("seamark:beacon_safe_water:shape") //$NON-NLS-1$ 406 || keys.containsKey("seamark:beacon_safe_water:colour")) { //$NON-NLS-1$ 407 buoy = new BuoySaw(this, node); 408 return; 409 410 } else if (type.equals("buoy_special_purpose") //$NON-NLS-1$ 411 || type.equals("beacon_special_purpose") //$NON-NLS-1$ 412 || keys.containsKey("seamark:buoy_special_purpose:shape") //$NON-NLS-1$ 413 || keys.containsKey("seamark:buoy_special_purpose:colour") //$NON-NLS-1$ 414 || keys.containsKey("seamark:beacon_special_purpose:shape") //$NON-NLS-1$ 415 || keys.containsKey("seamark:beacon_special_purpose:colour")) { //$NON-NLS-1$ 416 buoy = new BuoySpec(this, node); 417 return; 418 419 } else if (type.equals("buoy_isolated_danger") //$NON-NLS-1$ 420 || type.equals("beacon_isolated_danger") //$NON-NLS-1$ 421 || keys.containsKey("seamark:buoy_isolated_danger:shape") //$NON-NLS-1$ 422 || keys.containsKey("seamark:buoy_isolated_danger:colour") //$NON-NLS-1$ 423 || keys.containsKey("seamark:beacon_isolated_danger:shape") //$NON-NLS-1$ 424 || keys.containsKey("seamark:beacon_isolated_danger:colour")) { //$NON-NLS-1$ 425 buoy = new BuoyIsol(this, node); 426 return; 427 428 } else if (type.equals("landmark") || type.equals("light_vessel") //$NON-NLS-1$ 429 || type.equals("light_major") || type.equals("light_minor")) { //$NON-NLS-1$ 430 buoy = new BuoyNota(this, node); 431 return; 432 433 } else if (type.equals("light_float")) { //$NON-NLS-1$ 434 if (keys.containsKey("seamark:light_float:colour")) { //$NON-NLS-1$ 435 str = keys.get("seamark:light_float:colour"); //$NON-NLS-1$ 436 if (str.equals("red") || str.equals("green") //$NON-NLS-1$ //$NON-NLS-2$ 437 || str.equals("red;green;red") || str.equals("green;red;green")) { //$NON-NLS-1$ //$NON-NLS-2$ 438 buoy = new BuoyLat(this, node); 439 return; 440 } else if (str.equals("black;yellow") //$NON-NLS-1$ 441 || str.equals("black;yellow;black") || str.equals("yellow;black") //$NON-NLS-1$ //$NON-NLS-2$ 442 || str.equals("yellow;black;yellow")) { //$NON-NLS-1$ 443 buoy = new BuoyCard(this, node); 444 return; 445 } else if (str.equals("black;red;black")) { //$NON-NLS-1$ 446 buoy = new BuoyIsol(this, node); 447 return; 448 } else if (str.equals("red;white")) { //$NON-NLS-1$ 449 buoy = new BuoySaw(this, node); 450 return; 451 } else if (str.equals("yellow")) { //$NON-NLS-1$ 452 buoy = new BuoySpec(this, node); 453 return; 454 } 455 } else if (keys.containsKey("seamark:light_float:topmark:shape")) { //$NON-NLS-1$ 456 str = keys.get("seamark:light_float:topmark:shape"); //$NON-NLS-1$ 457 if (str.equals("cylinder") || str.equals("cone, point up")) { //$NON-NLS-1$ //$NON-NLS-2$ 458 buoy = new BuoyLat(this, node); 459 return; 460 } 461 } else if (keys.containsKey("seamark:light_float:topmark:colour")) { //$NON-NLS-1$ 462 str = keys.get("seamark:light_float:topmark:colour"); //$NON-NLS-1$ 463 if (str.equals("red") || str.equals("green")) { //$NON-NLS-1$ //$NON-NLS-2$ 464 buoy = new BuoyLat(this, node); 465 return; 466 } 467 } 468 } 469 470 buoy = new BuoyUkn(this, Messages.getString("SmpDialogAction.91")); //$NON-NLS-1$ 471 buoy.setNode(node); 472 return; 473 } 474 475 private JDialog getDM01SeaMap() { 476 477 if (dM01SeaMap == null) { 478 dM01SeaMap = new JDialog(); 479 dM01SeaMap.setSize(new Dimension(400, 400)); 480 dM01SeaMap.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); 481 dM01SeaMap.setModal(false); 482 dM01SeaMap.setResizable(false); 483 dM01SeaMap.setContentPane(getPM01SeaMap()); 484 dM01SeaMap.setTitle(Messages.getString("SmpDialogAction.9")); //$NON-NLS-1$ 485 dM01SeaMap.setVisible(false); 486 dM01SeaMap.setAlwaysOnTop(true); 487 dM01SeaMap.addWindowListener(new java.awt.event.WindowAdapter() { 488 public void windowClosing(java.awt.event.WindowEvent e) { 489 490 // Pictogramme wiederherstellen und aufraeumen 491 if (obuoy != null) 492 PicRebuild(); 493 // Deaktivierung des Listeners 494 DataSet.removeSelectionListener(SmpListener); 495 Selection = null; 496 497 SmpItem.setEnabled(true); 498 } 499 500 public void windowActivated(WindowEvent arg0) { 501 parseSeaMark(); 502 buoy.paintSign(); 503 } 504 }); 505 } 506 return dM01SeaMap; 507 } 508 509 private JPanel getPM01SeaMap() { 510 if (pM01SeaMap == null) { 511 512 lM01Icon = new JLabel(); 513 lM01Icon.setBounds(new Rectangle(210, 20, 150, 200)); 514 lM01Icon.setIcon(null); 515 lM01Icon.setText(""); //$NON-NLS-1$ 516 517 lM02Icon = new JLabel(); 518 lM02Icon.setBounds(new Rectangle(210, 20, 150, 200)); 519 lM02Icon.setIcon(null); 520 lM02Icon.setText(""); //$NON-NLS-1$ 521 522 lM03Icon = new JLabel(); 523 lM03Icon.setBounds(new Rectangle(210, -50, 150, 200)); 524 lM03Icon.setIcon(null); 525 lM03Icon.setText(""); //$NON-NLS-1$ 526 527 lM04Icon = new JLabel(); 528 lM04Icon.setBounds(new Rectangle(210, 20, 150, 200)); 529 lM04Icon.setIcon(null); 530 lM04Icon.setText(""); //$NON-NLS-1$ 531 532 lM05Icon = new JLabel(); 533 lM05Icon.setBounds(new Rectangle(210, 20, 150, 200)); 534 lM05Icon.setIcon(null); 535 lM05Icon.setText(""); //$NON-NLS-1$ 536 537 lM01FireMark = new JLabel(); 538 lM01FireMark.setBounds(new Rectangle(300, 85, 95, 20)); 539 lM01FireMark.setFont(new Font("Dialog", Font.PLAIN, 12)); //$NON-NLS-1$ 540 lM01FireMark.setText(""); //$NON-NLS-1$ 541 542 lM01Head = new JLabel(); 543 lM01Head.setBounds(new Rectangle(5, 3, 316, 16)); 544 lM01Head.setText(Messages.getString("SmpDialogAction.97")); //$NON-NLS-1$ 545 546 lM01Region = new JLabel(); 547 lM01Region.setBounds(new Rectangle(220, 7, 120, 16)); 548 lM01Region.setFont(new Font("Dialog", Font.PLAIN, 12)); //$NON-NLS-1$ 549 lM01Region.setText(Messages.getString("SmpDialogAction.99")); //$NON-NLS-1$ 550 551 lM02Region = new JLabel(); 552 lM02Region.setBounds(new Rectangle(270, 7, 120, 16)); 553 lM02Region.setFont(new Font("Dialog", Font.BOLD, 12)); //$NON-NLS-1$ 554 lM02Region.setText(Messages.getString("SmpDialogAction.101")); //$NON-NLS-1$ 555 556 lM01TypeOfMark = new JLabel(); 557 lM01TypeOfMark.setBounds(new Rectangle(5, 28, 120, 16)); 558 lM01TypeOfMark.setFont(new Font("Dialog", Font.PLAIN, 12)); //$NON-NLS-1$ 559 lM01TypeOfMark.setText(Messages.getString("SmpDialogAction.103")); //$NON-NLS-1$ 560 561 lM01CatOfMark = new JLabel(); 562 lM01CatOfMark.setBounds(new Rectangle(5, 58, 120, 16)); 563 lM01CatOfMark.setFont(new Font("Dialog", Font.PLAIN, 12)); //$NON-NLS-1$ 564 lM01CatOfMark.setText(Messages.getString("SmpDialogAction.1")); //$NON-NLS-1$ 565 566 lM01StyleOfMark = new JLabel(); 567 lM01StyleOfMark.setBounds(new Rectangle(5, 88, 148, 16)); 568 lM01StyleOfMark.setFont(new Font("Dialog", Font.PLAIN, 12)); //$NON-NLS-1$ 569 lM01StyleOfMark.setText(Messages.getString("SmpDialogAction.107")); //$NON-NLS-1$ 570 571 lM01Name = new JLabel(); 572 lM01Name.setBounds(new Rectangle(5, 120, 82, 16)); 573 lM01Name.setFont(new Font("Dialog", Font.PLAIN, 12)); //$NON-NLS-1$ 574 lM01Name.setText(Messages.getString("SmpDialogAction.109")); //$NON-NLS-1$ 575 576 lM01Props02 = new JLabel(); 577 lM01Props02.setBounds(new Rectangle(5, 150, 172, 16)); 578 lM01Props02.setFont(new Font("Dialog", Font.PLAIN, 12)); //$NON-NLS-1$ 579 lM01Props02.setText(Messages.getString("SmpDialogAction.111")); //$NON-NLS-1$ 580 581 lM01Racon = new JLabel(); 582 lM01Racon.setBounds(new Rectangle(335, 195, 65, 20)); 583 lM01Racon.setFont(new Font("Dialog", Font.PLAIN, 12)); //$NON-NLS-1$ 584 lM01Racon.setText(Messages.getString("SmpDialogAction.113")); //$NON-NLS-1$ 585 586 lM01FogGroup = new JLabel(); 587 lM01FogGroup.setBounds(new Rectangle(190, 220, 100, 20)); 588 lM01FogGroup.setFont(new Font("Dialog", Font.PLAIN, 12)); //$NON-NLS-1$ 589 lM01FogGroup.setText(Messages.getString("SmpDialogAction.115")); //$NON-NLS-1$ 590 591 lM01FogPeriod = new JLabel(); 592 lM01FogPeriod.setBounds(new Rectangle(300, 220, 100, 20)); 593 lM01FogPeriod.setFont(new Font("Dialog", Font.PLAIN, 12)); //$NON-NLS-1$ 594 lM01FogPeriod.setText(Messages.getString("SmpDialogAction.117")); //$NON-NLS-1$ 595 596 lM01Kennung = new JLabel(); 597 lM01Kennung.setBounds(new Rectangle(240, 245, 60, 20)); 598 lM01Kennung.setFont(new Font("Dialog", Font.PLAIN, 12)); //$NON-NLS-1$ 599 lM01Kennung.setText(Messages.getString("SmpDialogAction.119")); //$NON-NLS-1$ 600 601 lM01Height = new JLabel(); 602 lM01Height.setBounds(new Rectangle(10, 270, 100, 20)); 603 lM01Height.setFont(new Font("Dialog", Font.PLAIN, 12)); //$NON-NLS-1$ 604 lM01Height.setText(Messages.getString("SmpDialogAction.121")); //$NON-NLS-1$ 605 606 lM01Range = new JLabel(); 607 lM01Range.setBounds(new Rectangle(108, 270, 100, 20)); 608 lM01Range.setFont(new Font("Dialog", Font.PLAIN, 12)); //$NON-NLS-1$ 609 lM01Range.setText(Messages.getString("SmpDialogAction.123")); //$NON-NLS-1$ 610 611 lM01Group = new JLabel(); 612 lM01Group.setBounds(new Rectangle(204, 270, 100, 20)); 613 lM01Group.setFont(new Font("Dialog", Font.PLAIN, 12)); //$NON-NLS-1$ 614 lM01Group.setText(Messages.getString("SmpDialogAction.125")); //$NON-NLS-1$ 615 616 lM01RepeatTime = new JLabel(); 617 lM01RepeatTime.setBounds(new Rectangle(300, 270, 100, 20)); 618 lM01RepeatTime.setFont(new Font("Dialog", Font.PLAIN, 12)); //$NON-NLS-1$ 619 lM01RepeatTime.setText(Messages.getString("SmpDialogAction.127")); //$NON-NLS-1$ 620 621 lM01Sector = new JLabel(); 622 lM01Sector.setBounds(new Rectangle(10, 295, 180, 20)); 623 lM01Sector.setFont(new Font("Dialog", Font.PLAIN, 12)); //$NON-NLS-1$ 624 lM01Sector.setText(Messages.getString("SmpDialogAction.129")); //$NON-NLS-1$ 625 626 lM01Colour = new JLabel(); 627 lM01Colour.setBounds(new Rectangle(120, 295, 180, 20)); 628 lM01Colour.setFont(new Font("Dialog", Font.PLAIN, 12)); //$NON-NLS-1$ 629 lM01Colour.setText(Messages.getString("SmpDialogAction.131")); //$NON-NLS-1$ 630 631 lM01Bearing = new JLabel(); 632 lM01Bearing.setBounds(new Rectangle(228, 295, 180, 20)); 633 lM01Bearing.setFont(new Font("Dialog", Font.PLAIN, 12)); //$NON-NLS-1$ 634 lM01Bearing.setText(Messages.getString("SmpDialogAction.133")); //$NON-NLS-1$ 635 636 rbM01RegionA = new JRadioButton( 637 Messages.getString("SmpDialogAction.134"), Main.pref.get("tomsplugin.IALA") //$NON-NLS-1$ //$NON-NLS-2$ 638 .equals("A")); //$NON-NLS-1$ 639 rbM01RegionA.setBounds(new Rectangle(305, 0, 50, 30)); 640 rbM01RegionB = new JRadioButton("-B", Main.pref.get("tomsplugin.IALA") //$NON-NLS-1$ //$NON-NLS-2$ 641 .equals("B")); //$NON-NLS-1$ 642 rbM01RegionB.setBounds(new Rectangle(352, 0, 50, 30)); 643 bgM01Region = new ButtonGroup(); 644 bgM01Region.add(rbM01RegionA); 645 bgM01Region.add(rbM01RegionB); 646 647 ActionListener alM01Region = new ActionListener() { 648 public void actionPerformed(java.awt.event.ActionEvent e) { 649 if (buoy instanceof BuoyLat) { 650 buoy.setRegion(rbM01RegionB.isSelected()); 651 buoy.setLightColour(); 652 buoy.paintSign(); 653 } 654 } 655 }; 656 rbM01RegionA.addActionListener(alM01Region); 657 rbM01RegionB.addActionListener(alM01Region); 658 659 rbM01Fired1 = new JRadioButton( 660 Messages.getString("SmpDialogAction.140"), true); //$NON-NLS-1$ 661 rbM01Fired1.setBounds(new Rectangle(85, 240, 70, 30)); 662 rbM01FiredN = new JRadioButton( 663 Messages.getString("SmpDialogAction.141"), false); //$NON-NLS-1$ 664 rbM01FiredN.setBounds(new Rectangle(155, 240, 80, 30)); 665 bgM01Fired = new ButtonGroup(); 666 bgM01Fired.add(rbM01Fired1); 667 bgM01Fired.add(rbM01FiredN); 668 669 ActionListener alM01Fired = new ActionListener() { 670 public void actionPerformed(java.awt.event.ActionEvent e) { 671 buoy.setSectored(rbM01FiredN.isSelected()); 672 cbM01Sector.setSelectedIndex(0); 673 buoy.setSectorIndex(0); 674 buoy.paintSign(); 675 } 676 }; 677 rbM01Fired1.addActionListener(alM01Fired); 678 rbM01FiredN.addActionListener(alM01Fired); 679 680 pM01SeaMap = new JPanel(); 681 pM01SeaMap.setLayout(null); 682 pM01SeaMap.add(lM01Head, null); 683 pM01SeaMap.add(rbM01RegionA, null); 684 pM01SeaMap.add(rbM01RegionB, null); 685 pM01SeaMap.add(lM01Region, null); 686 pM01SeaMap.add(lM02Region, null); 687 pM01SeaMap.add(lM01Icon, null); 688 pM01SeaMap.add(lM02Icon, null); 689 pM01SeaMap.add(lM03Icon, null); 690 pM01SeaMap.add(lM04Icon, null); 691 pM01SeaMap.add(lM05Icon, null); 692 pM01SeaMap.add(getCbM01TypeOfMark(), null); 693 pM01SeaMap.add(lM01TypeOfMark, null); 694 pM01SeaMap.add(getCbM01CatOfMark(), null); 695 pM01SeaMap.add(lM01CatOfMark, null); 696 pM01SeaMap.add(getCbM01StyleOfMark(), null); 697 pM01SeaMap.add(lM01StyleOfMark, null); 698 pM01SeaMap.add(lM01Name, null); 699 pM01SeaMap.add(getTfM01Name(), null); 700 pM01SeaMap.add(lM01Props02, null); 701 pM01SeaMap.add(getCM01TopMark(), null); 702 pM01SeaMap.add(getCbM01TopMark(), null); 703 pM01SeaMap.add(getCM01Radar(), null); 704 pM01SeaMap.add(getCM01Racon(), null); 705 pM01SeaMap.add(getCbM01Racon(), null); 706 pM01SeaMap.add(getTfM01Racon(), null); 707 pM01SeaMap.add(lM01Racon, null); 708 pM01SeaMap.add(getCM01Fog(), null); 709 pM01SeaMap.add(getCbM01Fog(), null); 710 pM01SeaMap.add(getTfM01FogGroup(), null); 711 pM01SeaMap.add(lM01FogGroup, null); 712 pM01SeaMap.add(getTfM01FogPeriod(), null); 713 pM01SeaMap.add(lM01FogPeriod, null); 714 pM01SeaMap.add(getCM01Fired(), null); 715 pM01SeaMap.add(rbM01Fired1, null); 716 pM01SeaMap.add(rbM01FiredN, null); 717 pM01SeaMap.add(getTfM01RepeatTime(), null); 718 pM01SeaMap.add(lM01RepeatTime, null); 719 pM01SeaMap.add(getCbM01Kennung(), null); 720 pM01SeaMap.add(lM01Kennung, null); 721 pM01SeaMap.add(lM01Group, null); 722 pM01SeaMap.add(getTfM01Group(), null); 723 pM01SeaMap.add(lM01Sector, null); 724 pM01SeaMap.add(getCbM01Sector(), null); 725 pM01SeaMap.add(lM01Colour, null); 726 pM01SeaMap.add(getCbM01Colour(), null); 727 pM01SeaMap.add(lM01Bearing, null); 728 pM01SeaMap.add(getTfM01Bearing(), null); 729 pM01SeaMap.add(getTfM02Bearing(), null); 730 pM01SeaMap.add(getTfM01Radius(), null); 731 pM01SeaMap.add(lM01Height, null); 732 pM01SeaMap.add(getTfM01Height(), null); 733 pM01SeaMap.add(lM01Range, null); 734 pM01SeaMap.add(getTfM01Range(), null); 735 pM01SeaMap.add(lM01FireMark, null); 736 pM01SeaMap.add(getBM01Save(), null); 737 pM01SeaMap.add(getSM01StatusBar(), null); 738 pM01SeaMap.add(getBM01Close(), null); 739 pM01SeaMap.add(getCM01IconVisible(), null); 740 } 741 return pM01SeaMap; 742 } 743 744 private JComboBox getCbM01TypeOfMark() { 745 746 if (cbM01TypeOfMark == null) { 747 748 cbM01TypeOfMark = new JComboBox(); 749 750 // Inhalt der ComboBox 751 cbM01TypeOfMark.addItem(Messages.getString("SmpDialogAction.142")); //$NON-NLS-1$ 752 cbM01TypeOfMark.addItem(Messages.getString("SmpDialogAction.143")); //$NON-NLS-1$ 753 cbM01TypeOfMark.addItem(Messages.getString("SmpDialogAction.144")); //$NON-NLS-1$ 754 cbM01TypeOfMark.addItem(Messages.getString("SmpDialogAction.145")); //$NON-NLS-1$ 755 cbM01TypeOfMark.addItem(Messages.getString("SmpDialogAction.146")); //$NON-NLS-1$ 756 cbM01TypeOfMark.addItem(Messages.getString("SmpDialogAction.147")); //$NON-NLS-1$ 757 cbM01TypeOfMark.addItem(Messages.getString("SmpDialogAction.148")); //$NON-NLS-1$ 758 759 cbM01TypeOfMark.setBounds(new Rectangle(45, 25, 165, 25)); 760 // cbM01TypeOfMark.setEditable(false); 761 cbM01TypeOfMark.setFont(new Font("Dialog", Font.PLAIN, 12)); //$NON-NLS-1$ 762 cbM01TypeOfMark.setEnabled(true); 763 764 cbM01TypeOfMark.addActionListener(new ActionListener() { 765 public void actionPerformed(java.awt.event.ActionEvent e) { 766 int type = cbM01TypeOfMark.getSelectedIndex(); 767 768 if (buoy == null) { 769 buoy = new BuoyUkn(dia, Messages.getString("SmpDialogAction.150")); //$NON-NLS-1$ 770 return; 771 } 772 773 Node n = buoy.getNode(); 774 if (n == null) 775 return; 776 777 paintlock = true; 778 switch (type) { 779 780 case SeaMark.UNKNOWN_TYPE: 781 if (!(buoy instanceof BuoyUkn)) 782 buoy = new BuoyUkn(dia, Messages.getString("SmpDialogAction.150")); //$NON-NLS-1$ 783 buoy.setBuoyIndex(type); 784 break; 785 786 case SeaMark.LATERAL: 787 if (!(buoy instanceof BuoyLat)) { 788 buoy = new BuoyLat(dia, n); 789 buoy.setBuoyIndex(0); 790 } 791 break; 792 793 case SeaMark.CARDINAL: 794 if (!(buoy instanceof BuoyCard)) { 795 buoy = new BuoyCard(dia, n); 796 buoy.setBuoyIndex(0); 797 } 798 break; 799 800 case SeaMark.SAFE_WATER: 801 if (!(buoy instanceof BuoySaw)) { 802 buoy = new BuoySaw(dia, n); 803 } 804 buoy.setBuoyIndex(type); 805 break; 806 807 case SeaMark.ISOLATED_DANGER: 808 if (!(buoy instanceof BuoyIsol)) { 809 buoy = new BuoyIsol(dia, n); 810 } 811 buoy.setBuoyIndex(type); 812 break; 813 814 case SeaMark.SPECIAL_PURPOSE: 815 if (!(buoy instanceof BuoySpec)) { 816 buoy = new BuoySpec(dia, n); 817 } 818 buoy.setBuoyIndex(type); 819 break; 820 821 case SeaMark.LIGHT: 822 if (!(buoy instanceof BuoyNota)) { 823 buoy = new BuoyNota(dia, n); 824 buoy.setBuoyIndex(0); 825 } 826 break; 827 } 828 829 buoy.refreshStyles(); 830 buoy.refreshLights(); 831 buoy.setLightColour(); 832 paintlock = false; 833 buoy.paintSign(); 834 } 835 }); 836 } 837 return cbM01TypeOfMark; 838 } 839 840 private JComboBox getCbM01CatOfMark() { 841 if (cbM01CatOfMark == null) { 842 cbM01CatOfMark = new JComboBox(); 843 cbM01CatOfMark.setBounds(new Rectangle(60, 55, 150, 25)); 844 cbM01CatOfMark.setFont(new Font("Dialog", Font.PLAIN, 12)); //$NON-NLS-1$ 845 cbM01CatOfMark.setEnabled(true); 846 847 cbM01CatOfMark.addActionListener(new ActionListener() { 848 public void actionPerformed(ActionEvent e) { 849 int cat = cbM01CatOfMark.getSelectedIndex(); 850 851 if (buoy == null) { 852 buoy = new BuoyUkn(dia, Messages.getString("SmpDialogAction.150")); //$NON-NLS-1$ 853 return; 854 } 855 856 Node n = buoy.getNode(); 857 if (n == null) 858 return; 859 860 if (cbM01TypeOfMark.getSelectedIndex() == SeaMark.LATERAL) { 861 if (!(buoy instanceof BuoyLat)) 862 buoy = new BuoyLat(dia, n); 863 buoy.setBuoyIndex(cat); 864 } 865 if (cbM01TypeOfMark.getSelectedIndex() == SeaMark.CARDINAL) { 866 if (!(buoy instanceof BuoyCard)) 867 buoy = new BuoyCard(dia, n); 868 buoy.setBuoyIndex(cat); 869 } 870 if (cbM01TypeOfMark.getSelectedIndex() == SeaMark.LIGHT) { 871 if (!(buoy instanceof BuoyNota)) 872 buoy = new BuoyNota(dia, n); 873 buoy.setBuoyIndex(cat); 874 } 875 876 buoy.refreshStyles(); 877 buoy.refreshLights(); 878 buoy.setLightColour(); 879 buoy.paintSign(); 880 } 881 }); 882 } 883 return cbM01CatOfMark; 884 } 885 886 private JComboBox getCbM01StyleOfMark() { 887 if (cbM01StyleOfMark == null) { 888 cbM01StyleOfMark = new JComboBox(); 889 cbM01StyleOfMark.setBounds(new Rectangle(45, 85, 165, 25)); 890 cbM01StyleOfMark.setFont(new Font("Dialog", Font.PLAIN, 12)); //$NON-NLS-1$ 891 cbM01StyleOfMark.addActionListener(new ActionListener() { 892 public void actionPerformed(ActionEvent e) { 893 int style = cbM01StyleOfMark.getSelectedIndex(); 894 if (buoy != null && style != buoy.getStyleIndex()) { 895 buoy.setStyleIndex(style); 896 buoy.paintSign(); 897 } 898 } 899 }); 900 } 901 return cbM01StyleOfMark; 902 } 903 904 private JTextField getTfM01Name() { 905 if (tfM01Name == null) { 906 tfM01Name = new JTextField(); 907 tfM01Name.setBounds(new Rectangle(50, 120, 150, 20)); 908 tfM01Name.addFocusListener(new FocusAdapter() { 909 public void focusLost(FocusEvent e) { 910 buoy.setName(tfM01Name.getText()); 911 } 912 }); 913 } 914 return tfM01Name; 915 } 916 917 private JCheckBox getCM01TopMark() { 918 if (cM01TopMark == null) { 919 cM01TopMark = new JCheckBox(); 920 cM01TopMark.setBounds(new Rectangle(10, 170, 100, 20)); 921 cM01TopMark.setFont(new Font("Dialog", Font.PLAIN, 12)); //$NON-NLS-1$ 922 cM01TopMark.setText(Messages.getString("SmpDialogAction.166")); //$NON-NLS-1$ 923 cM01TopMark.addItemListener(new ItemListener() { 924 public void itemStateChanged(ItemEvent e) { 925 if (buoy == null) { 926 return; 927 } 928 buoy.setTopMark(cM01TopMark.isSelected()); 929 buoy.paintSign(); 930 } 931 }); 932 } 933 return cM01TopMark; 934 } 935 936 private JComboBox getCbM01TopMark() { 937 if (cbM01TopMark == null) { 938 cbM01TopMark = new JComboBox(); 939 cbM01TopMark.setBounds(new Rectangle(110, 170, 80, 20)); 940 cbM01TopMark.setFont(new Font("Dialog", Font.PLAIN, 12)); //$NON-NLS-1$ 941 cbM01TopMark.addActionListener(new ActionListener() { 942 public void actionPerformed(ActionEvent e) { 943 int top = cbM01TopMark.getSelectedIndex(); 944 buoy.paintSign(); 945 } 946 }); 947 } 948 return cbM01TopMark; 949 } 950 951 private JCheckBox getCM01Radar() { 952 if (cM01Radar == null) { 953 cM01Radar = new JCheckBox(); 954 cM01Radar.setBounds(new Rectangle(10, 195, 120, 20)); 955 cM01Radar.setFont(new Font("Dialog", Font.PLAIN, 12)); //$NON-NLS-1$ 956 cM01Radar.setText(Messages.getString("SmpDialogAction.169")); //$NON-NLS-1$ 957 cM01Radar.addActionListener(new ActionListener() { 958 public void actionPerformed(ActionEvent e) { 959 if (cM01Radar.isSelected()) { 960 buoy.setRadar(true); 961 buoy.setRacon(false); 962 cM01Racon.setSelected(false); 963 } else { 964 buoy.setRadar(false); 965 } 966 buoy.paintSign(); 967 } 968 }); 969 } 970 return cM01Radar; 971 } 972 973 private JCheckBox getCM01Racon() { 974 if (cM01Racon == null) { 975 cM01Racon = new JCheckBox(); 976 cM01Racon.setBounds(new Rectangle(130, 195, 110, 20)); 977 cM01Racon.setFont(new Font("Dialog", Font.PLAIN, 12)); //$NON-NLS-1$ 978 cM01Racon.setText(Messages.getString("SmpDialogAction.171")); //$NON-NLS-1$ 979 cM01Racon.addActionListener(new ActionListener() { 980 public void actionPerformed(ActionEvent e) { 981 if (cM01Racon.isSelected()) { 982 buoy.setRacon(true); 983 buoy.setRadar(false); 984 cM01Radar.setSelected(false); 985 } else { 986 buoy.setRacon(false); 987 } 988 buoy.paintSign(); 989 } 990 }); 991 } 992 return cM01Racon; 993 } 994 995 private JComboBox getCbM01Racon() { 996 if (cbM01Racon == null) { 997 cbM01Racon = new JComboBox(); 998 cbM01Racon.setBounds(new Rectangle(240, 195, 80, 20)); 999 cbM01Racon.setFont(new Font("Dialog", Font.PLAIN, 12)); //$NON-NLS-1$ 1000 cbM01Racon.removeAllItems(); 1001 cbM01Racon.addItem("Any"); 1002 cbM01Racon.addItem("Racon"); 1003 cbM01Racon.addItem("Ramark"); 1004 cbM01Racon.addItem("Leading"); 1005 cbM01Racon.addActionListener(new ActionListener() { 1006 public void actionPerformed(ActionEvent e) { 1007 int rac = cbM01Racon.getSelectedIndex(); 1008 buoy.setRaType(rac); 1009 buoy.paintSign(); 1010 } 1011 }); 1012 } 1013 return cbM01Racon; 1014 } 1015 1016 private JTextField getTfM01Racon() { 1017 if (tfM01Racon == null) { 1018 tfM01Racon = new JTextField(); 1019 tfM01Racon.setBounds(new Rectangle(345, 195, 30, 20)); 1020 tfM01Racon.addFocusListener(new FocusAdapter() { 1021 public void focusLost(FocusEvent e) { 1022 buoy.setRaconGroup(tfM01Racon.getText().trim()); 1023 } 1024 }); 1025 } 1026 return tfM01Racon; 1027 } 1028 1029 private JCheckBox getCM01Fog() { 1030 if (cM01Fog == null) { 1031 cM01Fog = new JCheckBox(); 1032 cM01Fog.setBounds(new Rectangle(10, 220, 90, 20)); 1033 cM01Fog.setFont(new Font("Dialog", Font.PLAIN, 12)); //$NON-NLS-1$ 1034 cM01Fog.setText(Messages.getString("SmpDialogAction.174")); //$NON-NLS-1$ 1035 cM01Fog.addActionListener(new ActionListener() { 1036 public void actionPerformed(ActionEvent e) { 1037 buoy.setFog(cM01Fog.isSelected()); 1038 buoy.paintSign(); 1039 } 1040 }); 1041 } 1042 return cM01Fog; 1043 } 1044 1045 private JComboBox getCbM01Fog() { 1046 if (cbM01Fog == null) { 1047 cbM01Fog = new JComboBox(); 1048 cbM01Fog.setBounds(new Rectangle(100, 220, 70, 20)); 1049 cbM01Fog.setFont(new Font("Dialog", Font.PLAIN, 12)); //$NON-NLS-1$ 1050 cbM01Fog.removeAllItems(); 1051 cbM01Fog.addItem("Any"); 1052 cbM01Fog.addItem("Horn"); 1053 cbM01Fog.addItem("Siren"); 1054 cbM01Fog.addItem("Dia"); 1055 cbM01Fog.addItem("Bell"); 1056 cbM01Fog.addItem("Whis"); 1057 cbM01Fog.addItem("Gong"); 1058 cbM01Fog.addItem("Explos"); 1059 cbM01Fog.addActionListener(new ActionListener() { 1060 public void actionPerformed(ActionEvent e) { 1061 if (cbM01Fog.getSelectedIndex() > 0) 1062 buoy.setFogSound(cbM01Fog.getSelectedIndex()); 1063 else 1064 buoy.setFogSound(0); 1065 buoy.paintSign(); 1066 } 1067 }); 1068 } 1069 return cbM01Fog; 1070 } 1071 1072 private JTextField getTfM01FogGroup() { 1073 if (tfM01FogGroup == null) { 1074 tfM01FogGroup = new JTextField(); 1075 tfM01FogGroup.setBounds(new Rectangle(243, 220, 30, 20)); 1076 tfM01FogGroup.addFocusListener(new FocusAdapter() { 1077 public void focusLost(FocusEvent e) { 1078 buoy.setFogGroup(tfM01FogGroup.getText().trim()); 1079 } 1080 }); 1081 } 1082 return tfM01FogGroup; 1083 } 1084 1085 private JTextField getTfM01FogPeriod() { 1086 if (tfM01FogPeriod == null) { 1087 tfM01FogPeriod = new JTextField(); 1088 tfM01FogPeriod.setBounds(new Rectangle(345, 220, 30, 20)); 1089 tfM01FogPeriod.addFocusListener(new FocusAdapter() { 1090 public void focusLost(FocusEvent e) { 1091 buoy.setFogPeriod(tfM01FogPeriod.getText().trim()); 1092 } 1093 }); 1094 } 1095 return tfM01FogPeriod; 1096 } 1097 1098 private JCheckBox getCM01Fired() { 1099 if (cM01Fired == null) { 1100 cM01Fired = new JCheckBox(); 1101 cM01Fired.setBounds(new Rectangle(10, 245, 75, 20)); 1102 cM01Fired.setFont(new Font("Dialog", Font.PLAIN, 12)); //$NON-NLS-1$ 1103 cM01Fired.setText(Messages.getString("SmpDialogAction.177")); //$NON-NLS-1$ 1104 cM01Fired.addItemListener(new ItemListener() { 1105 public void itemStateChanged(ItemEvent e) { 1106 if (buoy == null) { 1107 return; 1108 } 1109 buoy.setFired(cM01Fired.isSelected()); 1110 buoy.setLightColour(); 1111 buoy.paintSign(); 1112 } 1113 }); 1114 } 1115 1116 return cM01Fired; 1117 } 1118 1119 private JComboBox getCbM01Kennung() { 1120 if (cbM01Kennung == null) { 1121 cbM01Kennung = new JComboBox(); 1122 cbM01Kennung.setBounds(new Rectangle(305, 245, 70, 20)); 1123 cbM01Kennung.addActionListener(new ActionListener() { 1124 public void actionPerformed(ActionEvent e) { 1125 int i1, i2; 1126 String c = ""; //$NON-NLS-1$ //$NON-NLS-2$ 1127 String it = (String) cbM01Kennung.getSelectedItem(); 1128 1129 if (it == null) 1130 return; 1131 if (it.equals(Messages.getString("SmpDialogAction.212"))) //$NON-NLS-1$ 1132 return; 1133 if (buoy == null) 1134 return; 1135 1136 if (it.contains("(")) { 1137 i1 = it.indexOf("("); 1138 i2 = it.indexOf(")"); 1139 c = it.substring(i1+1, i2); 1140 it = it.substring(0, i1) + it.substring(i2+1); 1141 } 1142 if (!c.isEmpty()) 1143 buoy.setLightGroup(c);; 1144 buoy.setLightChar(it); 1145 buoy.paintSign(); 1146 } 1147 }); 1148 } 1149 return cbM01Kennung; 1150 } 1151 1152 private JTextField getTfM01Height() { 1153 if (tfM01Height == null) { 1154 tfM01Height = new JTextField(); 1155 tfM01Height.setBounds(new Rectangle(54, 270, 30, 20)); 1156 tfM01Height.addFocusListener(new FocusAdapter() { 1157 public void focusLost(FocusEvent e) { 1158 buoy.setHeight(tfM01Height.getText().trim()); 1159 } 1160 }); 1161 } 1162 return tfM01Height; 1163 } 1164 1165 private JTextField getTfM01Range() { 1166 if (tfM01Range == null) { 1167 tfM01Range = new JTextField(); 1168 tfM01Range.setBounds(new Rectangle(151, 270, 30, 20)); 1169 tfM01Range.addFocusListener(new FocusAdapter() { 1170 public void focusLost(FocusEvent e) { 1171 buoy.setRange(tfM01Range.getText().trim()); 1172 } 1173 }); 1174 } 1175 return tfM01Range; 1176 } 1177 1178 private JTextField getTfM01Group() { 1179 if (tfM01Group == null) { 1180 tfM01Group = new JTextField(); 1181 tfM01Group.setBounds(new Rectangle(255, 270, 30, 20)); 1182 tfM01Group.addFocusListener(new FocusAdapter() { 1183 public void focusLost(FocusEvent e) { 1184 buoy.setLightGroup(tfM01Group.getText().trim()); 1185 buoy.paintSign(); 1186 } 1187 }); 1188 } 1189 return tfM01Group; 1190 } 1191 1192 private JTextField getTfM01RepeatTime() { 1193 if (tfM01RepeatTime == null) { 1194 tfM01RepeatTime = new JTextField(); 1195 tfM01RepeatTime.setBounds(new Rectangle(345, 270, 30, 20)); 1196 tfM01RepeatTime.addActionListener(new ActionListener() { 1197 public void actionPerformed(ActionEvent e) { 1198 buoy.setLightPeriod(tfM01RepeatTime.getText().trim()); 1199 buoy.paintSign(); 1200 } 1201 }); 1202 1203 tfM01RepeatTime.addFocusListener(new FocusAdapter() { 1204 public void focusLost(FocusEvent e) { 1205 buoy.setLightPeriod(tfM01RepeatTime.getText().trim()); 1206 buoy.paintSign(); 1207 } 1208 }); 1209 } 1210 return tfM01RepeatTime; 1211 } 1212 1213 private JComboBox getCbM01Colour() { 1214 if (cbM01Colour == null) { 1215 cbM01Colour = new JComboBox(); 1216 cbM01Colour.setBounds(new Rectangle(165, 295, 40, 20)); 1217 cbM01Colour.setFont(new Font("Dialog", Font.PLAIN, 12)); //$NON-NLS-1$ 1218 cbM01Colour.addItem(""); //$NON-NLS-1$ 1219 cbM01Colour.addItem(Messages.getString("SmpDialogAction.190")); //$NON-NLS-1$ 1220 cbM01Colour.addItem(Messages.getString("SmpDialogAction.191")); //$NON-NLS-1$ 1221 cbM01Colour.addItem(Messages.getString("SmpDialogAction.192")); //$NON-NLS-1$ 1222 cbM01Colour.addActionListener(new ActionListener() { 1223 public void actionPerformed(ActionEvent e) { 1224 buoy.setLightColour((String)cbM01Colour.getSelectedItem()); 1225 buoy.paintSign(); 1226 } 1227 }); 1228 } 1229 return cbM01Colour; 1230 } 1231 1232 private JComboBox getCbM01Sector() { 1233 if (cbM01Sector == null) { 1234 cbM01Sector = new JComboBox(); 1235 cbM01Sector.setBounds(new Rectangle(55, 295, 50, 20)); 1236 cbM01Sector.setFont(new Font("Dialog", Font.PLAIN, 12)); //$NON-NLS-1$ 1237 cbM01Sector.addItem(Messages.getString("SmpDialogAction.194")); //$NON-NLS-1$ 1238 cbM01Sector.addItem(Messages.getString("SmpDialogAction.195")); //$NON-NLS-1$ 1239 cbM01Sector.addItem(Messages.getString("SmpDialogAction.196")); //$NON-NLS-1$ 1240 cbM01Sector.addItem(Messages.getString("SmpDialogAction.197")); //$NON-NLS-1$ 1241 cbM01Sector.addItem(Messages.getString("SmpDialogAction.198")); //$NON-NLS-1$ 1242 cbM01Sector.addItem(Messages.getString("SmpDialogAction.199")); //$NON-NLS-1$ 1243 cbM01Sector.addItem(Messages.getString("SmpDialogAction.200")); //$NON-NLS-1$ 1244 cbM01Sector.addItem(Messages.getString("SmpDialogAction.201")); //$NON-NLS-1$ 1245 cbM01Sector.addItem(Messages.getString("SmpDialogAction.202")); //$NON-NLS-1$ 1246 cbM01Sector.addItem(Messages.getString("SmpDialogAction.203")); //$NON-NLS-1$ 1247 cbM01Sector.addActionListener(new ActionListener() { 1248 public void actionPerformed(ActionEvent e) { 1249 buoy.setSectorIndex(cbM01Sector.getSelectedIndex()); 1250 buoy.paintSign(); 1251 } 1252 }); 1253 } 1254 return cbM01Sector; 1255 } 1256 1257 private JTextField getTfM01Bearing() { 1258 if (tfM01Bearing == null) { 1259 tfM01Bearing = new JTextField(); 1260 tfM01Bearing.setBounds(new Rectangle(255, 295, 30, 20)); 1261 tfM01Bearing.addFocusListener(new FocusAdapter() { 1262 public void focusLost(FocusEvent e) { 1263 buoy.setBearing1(tfM01Bearing.getText().trim()); 1264 } 1265 }); 1266 } 1267 return tfM01Bearing; 1268 } 1269 1270 private JTextField getTfM02Bearing() { 1271 if (tfM02Bearing == null) { 1272 tfM02Bearing = new JTextField(); 1273 tfM02Bearing.setBounds(new Rectangle(300, 295, 30, 20)); 1274 tfM02Bearing.addFocusListener(new FocusAdapter() { 1275 public void focusLost(FocusEvent e) { 1276 buoy.setBearing2(tfM02Bearing.getText().trim()); 1277 } 1278 }); 1279 } 1280 return tfM02Bearing; 1281 } 1282 1283 private JTextField getTfM01Radius() { 1284 if (tfM01Radius == null) { 1285 tfM01Radius = new JTextField(); 1286 tfM01Radius.setBounds(new Rectangle(355, 295, 30, 20)); 1287 tfM01Radius.addFocusListener(new FocusAdapter() { 1288 public void focusLost(FocusEvent e) { 1289 buoy.setRadius(tfM01Radius.getText().trim()); 1290 } 1291 }); 1292 } 1293 return tfM01Radius; 1294 } 1295 1296 private JButton getBM01Close() { 1297 if (bM01Close == null) { 1298 bM01Close = new JButton(); 1299 bM01Close.setBounds(new Rectangle(20, 325, 110, 20)); 1300 bM01Close.setText(tr("Close")); 1301 bM01Close.addActionListener(new ActionListener() { 1302 public void actionPerformed(ActionEvent e) { 1303 // aufraeumen 1304 if (obuoy != null) 1305 PicRebuild(); 1306 // Deaktivierung des Listeners 1307 DataSet.removeSelectionListener(SmpListener); 1308 Selection = null; 1309 SmpItem.setEnabled(true); 1310 onode = null; 1311 1312 dM01SeaMap.dispose(); 1313 } 1314 }); 1315 } 1316 1317 return bM01Close; 1318 } 1319 1320 private JButton getBM01Save() { 1321 if (bM01Save == null) { 1322 bM01Save = new JButton(); 1323 bM01Save.setBounds(new Rectangle(150, 325, 110, 20)); 1324 bM01Save.setText(tr("Save")); 1325 bM01Save.setEnabled(false); 1326 1327 bM01Save.addActionListener(new ActionListener() { 1328 public void actionPerformed(ActionEvent e) { 1329 cM01IconVisible.setIcon(new ImageIcon(getClass().getResource( 1330 "/images/Auge.png"))); //$NON-NLS-1$ 1331 cM01IconVisible.setSelected(true); 1332 1333 buoy.saveSign(); 1334 } 1335 }); 1336 } 1337 1338 return bM01Save; 1339 } 1340 1341 private JCheckBox getCM01IconVisible() { 1342 if (cM01IconVisible == null) { 1343 cM01IconVisible = new JCheckBox(); 1344 cM01IconVisible.setBounds(new Rectangle(310, 325, 30, 21)); 1345 cM01IconVisible.setIcon(new ImageIcon(getClass().getResource( 1346 "/images/AugeN.png"))); //$NON-NLS-1$ 1347 cM01IconVisible.setSelected(false); 1348 cM01IconVisible.addActionListener(new ActionListener() { 1349 public void actionPerformed(ActionEvent e) { 1350 Command c; 1351 Node n = null; 1352 DataSet ds = Main.main.getCurrentDataSet(); 1353 1354 if (buoy != null) 1355 n = buoy.getNode(); 1356 1357 if (cM01IconVisible.isSelected()) { 1358 cM01IconVisible.setIcon(new ImageIcon(getClass().getResource( 1359 "/images/AugeN.png"))); //$NON-NLS-1$ 1360 if (n != null) { 1361 // seamark loeschen, wenn notwendig 1362 if (n.getKeys().containsKey("seamark")) { //$NON-NLS-1$ 1363 smb = n.getKeys().get("seamark"); // smb merken //$NON-NLS-1$ 1364 1365 c = new ChangePropertyCommand(n, "seamark", null); //$NON-NLS-1$ 1366 c.executeCommand(); 1367 ds.fireSelectionChanged(); 1368 obuoy = buoy; 1369 } 1370 1371 // seamark:type loeschen, wenn notwendig 1372 if (n.getKeys().containsKey("seamark:type")) { //$NON-NLS-1$ 1373 smt = n.getKeys().get("seamark:type"); // smt merken //$NON-NLS-1$ 1374 1375 c = new ChangePropertyCommand(n, "seamark:type", null); //$NON-NLS-1$ 1376 c.executeCommand(); 1377 ds.fireSelectionChanged(); 1378 obuoy = buoy; 1379 } 1380 1381 } 1382 } else { 1383 cM01IconVisible.setIcon(new ImageIcon(getClass().getResource( 1384 "/images/Auge.png"))); //$NON-NLS-1$ 1385 PicRebuild(); 1386 obuoy = null; 1387 } 1388 buoy.paintSign(); 1389 } 1390 }); 1391 } 1392 return cM01IconVisible; 1393 } 1394 1395 private JTextField getSM01StatusBar() { 1396 if (sM01StatusBar == null) { 1397 sM01StatusBar = new JTextField(); 1398 sM01StatusBar.setBounds(new Rectangle(7, 355, 385, 20)); 1399 sM01StatusBar.setBackground(SystemColor.activeCaptionBorder); 1400 } 1401 return sM01StatusBar; 1402 } 1403 1403 1404 1404 } -
applications/editors/josm/plugins/toms/src/toms/plug/PluginApp.java
r23138 r23193 13 13 14 14 public class PluginApp implements Runnable { 15 16 public static void runPlugins() throws IOException {17 String pluginDirName = Main.pref.getPluginsDirectory().getAbsolutePath();18 15 19 //!! List<Pluggable> plugins = PluginLoader.loadPlugins(new File(pluginDirName + "/tplug")); 16 public static void runPlugins() throws IOException { 17 String pluginDirName = Main.pref.getPluginsDirectory().getAbsolutePath(); 20 18 21 //!! if(plugins == null) return; 22 23 //!! PluginManager manager = new PluginManagerImpl(); 24 25 //!! for(Pluggable p : plugins) p.setPluginManager(manager); 26 //!! for(Pluggable p : plugins) p.start(); 27 28 // wait 29 try { 30 Thread.sleep(10000); 31 } catch (InterruptedException e) { 32 e.printStackTrace(); 33 } 34 35 //!! for(Pluggable p: plugins) p.stop(); 36 } 19 //!! List<Pluggable> plugins = PluginLoader.loadPlugins(new File(pluginDirName + "/tplug")); 37 20 38 @Override 39 public void run() { 40 try { 41 runPlugins(); 42 } catch (IOException e) { 43 e.printStackTrace(); 44 } 45 46 } 21 //!! if(plugins == null) return; 22 23 //!! PluginManager manager = new PluginManagerImpl(); 24 25 //!! for(Pluggable p : plugins) p.setPluginManager(manager); 26 //!! for(Pluggable p : plugins) p.start(); 27 28 // wait 29 try { 30 Thread.sleep(10000); 31 } catch (InterruptedException e) { 32 e.printStackTrace(); 33 } 34 35 //!! for(Pluggable p: plugins) p.stop(); 36 } 37 38 @Override 39 public void run() { 40 try { 41 runPlugins(); 42 } catch (IOException e) { 43 e.printStackTrace(); 44 } 45 46 } 47 47 48 48 } -
applications/editors/josm/plugins/toms/src/toms/plug/ifc/Pluggable.java
r23079 r23193 3 3 public interface Pluggable { 4 4 5 6 7 8 5 boolean start(); 6 boolean stop(); 7 8 void setPluginManager(PluginManager manager); 9 9 } -
applications/editors/josm/plugins/toms/src/toms/plug/ifc/PluginManager.java
r23079 r23193 2 2 3 3 public interface PluginManager { 4 4 void showVisualMessage(String message); 5 5 } -
applications/editors/josm/plugins/toms/src/toms/plug/util/PluginLoader.java
r23138 r23193 19 19 public class PluginLoader { 20 20 21 //!! public static List<Pluggable> loadPlugins(File plugDir) throws IOException { 22 //!! File[] plugJars = plugDir.listFiles(new JARFileFilter()); 23 //!! ClassLoader cl = new URLClassLoader(PluginLoader.fileArrayToURLArray(plugJars)); 24 25 //!! if(cl == null) return null; 26 27 //!! List<Class<Pluggable>> plugClasses = PluginLoader.extractClassesFromJARs(plugJars, cl); 28 29 //!! return PluginLoader.createPluggableObjects(plugClasses); 30 //!! } 21 //!! public static List<Pluggable> loadPlugins(File plugDir) throws IOException { 22 //!! File[] plugJars = plugDir.listFiles(new JARFileFilter()); 23 //!! ClassLoader cl = new URLClassLoader(PluginLoader.fileArrayToURLArray(plugJars)); 31 24 32 private static List<Pluggable> createPluggableObjects(List<Class<Pluggable>> pluggables) { 33 List<Pluggable> plugs = new ArrayList<Pluggable>(pluggables.size()); 34 for(Class<Pluggable> plug : pluggables) { 35 try { 36 plugs.add(plug.newInstance()); 37 } catch (InstantiationException e) { 38 System.err.println("Can't instantiate plugin: " + plug.getName()); 39 e.printStackTrace(); 40 } catch (IllegalAccessException e) { 41 System.err.println("IllegalAccess for plugin: " + plug.getName()); 42 e.printStackTrace(); 43 } 44 } 45 46 return plugs; 25 //!! if(cl == null) return null; 47 26 48 } 27 //!! List<Class<Pluggable>> plugClasses = PluginLoader.extractClassesFromJARs(plugJars, cl); 49 28 50 private static List<Class<Pluggable>> extractClassesFromJARs( File[] jars, ClassLoader cl) throws FileNotFoundException, IOException { 51 List<Class<Pluggable>> classes = new ArrayList<Class<Pluggable>>(); 52 53 for(File jar : jars) { 54 classes.addAll(PluginLoader.extractClassesFromJAR(jar, cl)); 55 } 29 //!! return PluginLoader.createPluggableObjects(plugClasses); 30 //!! } 56 31 57 return classes; 58 } 32 private static List<Pluggable> createPluggableObjects(List<Class<Pluggable>> pluggables) { 33 List<Pluggable> plugs = new ArrayList<Pluggable>(pluggables.size()); 34 for(Class<Pluggable> plug : pluggables) { 35 try { 36 plugs.add(plug.newInstance()); 37 } catch (InstantiationException e) { 38 System.err.println("Can't instantiate plugin: " + plug.getName()); 39 e.printStackTrace(); 40 } catch (IllegalAccessException e) { 41 System.err.println("IllegalAccess for plugin: " + plug.getName()); 42 e.printStackTrace(); 43 } 44 } 59 45 60 @SuppressWarnings("unchecked") 61 private static Collection<? extends Class<Pluggable>> extractClassesFromJAR(File jar, ClassLoader cl) throws FileNotFoundException, IOException { 62 List<Class<Pluggable>> classes = new ArrayList<Class<Pluggable>>(); 63 JarInputStream jaris = new JarInputStream(new FileInputStream(jar)); 64 JarEntry ent = null; 65 66 while ((ent = jaris.getNextJarEntry()) != null) { 67 String entName = ent.getName(); //.toLowerCase(); 68 69 if (entName.endsWith(".class")) { 70 try { 71 Class<?> cls = cl.loadClass(entName.substring(0, entName.length()- 6).replace('/', '.')); 72 if (PluginLoader.isPluggableClass(cls)) classes.add((Class<Pluggable>) cls); 73 } catch (ClassNotFoundException e) { 74 System.err.println("Can't load Class" + entName); 75 e.printStackTrace(); 76 } 77 } 78 } 79 80 jaris.close(); 81 82 return classes; 83 } 46 return plugs; 84 47 85 private static boolean isPluggableClass(Class<?> cls) { 86 for (Class<?> i: cls.getInterfaces()) { 87 if (i.equals(Pluggable.class)) return true; 88 } 89 90 return false; 48 } 91 49 92 } 50 private static List<Class<Pluggable>> extractClassesFromJARs( File[] jars, ClassLoader cl) throws FileNotFoundException, IOException { 51 List<Class<Pluggable>> classes = new ArrayList<Class<Pluggable>>(); 93 52 94 private static URL[] fileArrayToURLArray(File[] files) throws MalformedURLException { 95 URL[] urls = new URL[files.length]; 96 97 if(urls == null) return null; 98 99 for(int i = 0; i < files.length; i++) { 100 urls[i] = files[i].toURI().toURL(); 101 } 102 103 return urls; 104 } 53 for(File jar : jars) { 54 classes.addAll(PluginLoader.extractClassesFromJAR(jar, cl)); 55 } 56 57 return classes; 58 } 59 60 @SuppressWarnings("unchecked") 61 private static Collection<? extends Class<Pluggable>> extractClassesFromJAR(File jar, ClassLoader cl) throws FileNotFoundException, IOException { 62 List<Class<Pluggable>> classes = new ArrayList<Class<Pluggable>>(); 63 JarInputStream jaris = new JarInputStream(new FileInputStream(jar)); 64 JarEntry ent = null; 65 66 while ((ent = jaris.getNextJarEntry()) != null) { 67 String entName = ent.getName(); //.toLowerCase(); 68 69 if (entName.endsWith(".class")) { 70 try { 71 Class<?> cls = cl.loadClass(entName.substring(0, entName.length()- 6).replace('/', '.')); 72 if (PluginLoader.isPluggableClass(cls)) classes.add((Class<Pluggable>) cls); 73 } catch (ClassNotFoundException e) { 74 System.err.println("Can't load Class" + entName); 75 e.printStackTrace(); 76 } 77 } 78 } 79 80 jaris.close(); 81 82 return classes; 83 } 84 85 private static boolean isPluggableClass(Class<?> cls) { 86 for (Class<?> i: cls.getInterfaces()) { 87 if (i.equals(Pluggable.class)) return true; 88 } 89 90 return false; 91 92 } 93 94 private static URL[] fileArrayToURLArray(File[] files) throws MalformedURLException { 95 URL[] urls = new URL[files.length]; 96 97 if(urls == null) return null; 98 99 for(int i = 0; i < files.length; i++) { 100 urls[i] = files[i].toURI().toURL(); 101 } 102 103 return urls; 104 } 105 105 106 106 } -
applications/editors/josm/plugins/toms/src/toms/seamarks/SeaMark.java
r23176 r23193 14 14 abstract public class SeaMark { 15 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 16 /** 17 * CONSTANTS 18 */ 19 20 /** 21 * Colours 22 */ 23 24 public final static int UNKNOWN_COLOUR = 0; 25 public final static int RED = 1; 26 public final static int GREEN = 2; 27 public final static int RED_GREEN_RED = 3; 28 public final static int GREEN_RED_GREEN = 4; 29 public final static int RED_WHITE = 5; 30 public final static int BLACK_YELLOW = 6; 31 public final static int BLACK_YELLOW_BLACK = 7; 32 public final static int YELLOW_BLACK = 8; 33 public final static int YELLOW_BLACK_YELLOW = 9; 34 public final static int BLACK_RED_BLACK = 10; 35 public final static int YELLOW = 11; 36 public final static int WHITE_LIGHT = 1; 37 public final static int RED_LIGHT = 2; 38 public final static int GREEN_LIGHT = 3; 39 40 /** 41 * Types - correspond to TypeIndex 42 */ 43 public final static int UNKNOWN_TYPE = 0; 44 public final static int LATERAL = 1; 45 public final static int CARDINAL = 2; 46 public final static int SAFE_WATER = 3; 47 public final static int ISOLATED_DANGER = 4; 48 public final static int SPECIAL_PURPOSE = 5; 49 public final static int LIGHT = 6; 50 51 /** 52 * Categories - correspond to CatIndex 53 */ 54 public final static int UNKNOWN_CAT = 0; 55 public final static int PORT_HAND = 1; 56 public final static int STARBOARD_HAND = 2; 57 public final static int PREF_PORT_HAND = 3; 58 public final static int PREF_STARBOARD_HAND = 4; 59 public final static int CARD_NORTH = 1; 60 public final static int CARD_EAST = 2; 61 public final static int CARD_SOUTH = 3; 62 public final static int CARD_WEST = 4; 63 public final static int LIGHT_HOUSE = 1; 64 public final static int LIGHT_MAJOR = 2; 65 public final static int LIGHT_MINOR = 3; 66 public final static int LIGHT_VESSEL = 4; 67 68 /** 69 * Regions 70 */ 71 public final static boolean IALA_A = false; 72 public final static boolean IALA_B = true; 73 74 /** 75 * Shapes - correspond to StyleIndex 76 */ 77 public final static int UNKNOWN_SHAPE = 0; 78 public final static int LAT_CAN = 1; 79 public final static int LAT_CONE = 1; 80 public final static int LAT_PILLAR = 2; 81 public final static int LAT_SPAR = 3; 82 public final static int LAT_BEACON = 4; 83 public final static int LAT_TOWER = 5; 84 public final static int LAT_FLOAT = 6; 85 public final static int LAT_PERCH = 7; 86 public final static int CARD_PILLAR = 1; 87 public final static int CARD_SPAR = 2; 88 public final static int CARD_BEACON = 3; 89 public final static int CARD_TOWER = 4; 90 public final static int CARD_FLOAT = 5; 91 public final static int SAFE_PILLAR = 1; 92 public final static int SAFE_SPAR = 2; 93 public final static int SAFE_SPHERE = 3; 94 public final static int SAFE_BEACON = 4; 95 public final static int SAFE_FLOAT = 5; 96 public final static int ISOL_PILLAR = 1; 97 public final static int ISOL_SPAR = 2; 98 public final static int ISOL_BEACON = 3; 99 public final static int ISOL_TOWER = 4; 100 public final static int ISOL_FLOAT = 5; 101 public final static int SPEC_PILLAR = 1; 102 public final static int SPEC_CAN = 2; 103 public final static int SPEC_CONE = 3; 104 public final static int SPEC_SPAR = 4; 105 public final static int SPEC_BEACON = 5; 106 public final static int SPEC_TOWER = 6; 107 public final static int SPEC_FLOAT = 7; 108 public final static int SPEC_SPHERE = 8; 109 public final static int SPEC_BARREL = 9; 110 111 /** 112 * Radar Beacons - correspond to Ratyp Index 113 */ 114 115 public final static int UNKNOWN_RATYPE = 0; 116 public final static int RATYPE_RACON = 1; 117 public final static int RATYPE_RAMARK = 2; 118 public final static int RATYPE_LEADING = 3; 119 120 /** 121 * Fog Signals - correspond to FogSound Index 122 */ 123 124 public final static int UNKNOWN_FOG = 0; 125 public final static int FOG_HORN = 1; 126 public final static int FOG_SIREN = 2; 127 public final static int FOG_DIA = 3; 128 public final static int FOG_BELL = 4; 129 public final static int FOG_WHIS = 5; 130 public final static int FOG_GONG = 6; 131 public final static int FOG_EXPLOS = 7; 132 133 /** 134 * Variables 135 */ 136 137 /** 138 * private Variablen 139 */ 140 141 public abstract void paintSign(); 142 143 public abstract void saveSign(); 144 145 private int Colour = UNKNOWN_COLOUR; 146 147 public int getColour() { 148 return Colour; 149 } 150 151 public void setColour(int colour) { 152 if (colour < UNKNOWN_COLOUR || colour > RED_WHITE) { 153 return; 154 } 155 Colour = colour; 156 157 } 158 159 private String ErrMsg = null; 160 161 public String getErrMsg() { 162 return ErrMsg; 163 } 164 165 public void setErrMsg(String errMsg) { 166 ErrMsg = errMsg; 167 } 168 169 private String Name; 170 171 public String getName() { 172 return Name; 173 } 174 175 public void setName(String name) { 176 Name = name; 177 } 178 179 private boolean valid = true; 180 181 public boolean isValid() { 182 return valid; 183 } 184 185 public void setValid(boolean valid) { 186 this.valid = valid; 187 188 } 189 190 protected void delSeaMarkKeys(Node node) { 191 Iterator<String> it = node.getKeys().keySet().iterator(); 192 String str; 193 194 while (it.hasNext()) { 195 str = it.next(); 196 197 if (str.contains("seamark") == true) 198 if (str.compareTo("seamark") != 0) { 199 Main.main.undoRedo.add(new ChangePropertyCommand(node, str, null)); 200 } 201 } 202 } 203 203 204 204 } -
applications/editors/josm/plugins/toms/src/toms/seamarks/buoys/Buoy.java
r23176 r23193 23 23 abstract public class Buoy extends SeaMark { 24 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 25 public abstract void setLightColour(); 26 27 /** 28 * private Variablen 29 */ 30 31 private int BuoyIndex = 0; 32 33 public int getBuoyIndex() { 34 return BuoyIndex; 35 } 36 37 public void setBuoyIndex(int buoyIndex) { 38 BuoyIndex = buoyIndex; 39 } 40 41 private int StyleIndex = 0; 42 43 public int getStyleIndex() { 44 return StyleIndex; 45 } 46 47 public void setStyleIndex(int styleIndex) { 48 StyleIndex = styleIndex; 49 } 50 51 private boolean Region = false; 52 53 public boolean getRegion() { 54 return Region; 55 } 56 57 public void setRegion(boolean region) { 58 Region = region; 59 } 60 61 private boolean Radar = false; 62 63 public boolean hasRadar() { 64 return Radar; 65 } 66 67 public void setRadar(boolean radar) { 68 Radar = radar; 69 } 70 71 private boolean Racon = false; 72 73 public boolean hasRacon() { 74 return Racon; 75 } 76 77 public void setRacon(boolean racon) { 78 Racon = racon; 79 } 80 81 private int RaType = 0; 82 83 public int getRaType() { 84 return RaType; 85 } 86 87 public void setRaType(int type) { 88 RaType = type; 89 } 90 91 private String RaconGroup = ""; 92 93 public String getRaconGroup() { 94 return RaconGroup; 95 } 96 97 public void setRaconGroup(String raconGroup) { 98 RaconGroup = raconGroup; 99 } 100 101 private boolean Fog = false; 102 103 public boolean hasFog() { 104 return Fog; 105 } 106 107 public void setFog(boolean fog) { 108 Fog = fog; 109 } 110 111 private int FogSound = 0; 112 113 public int getFogSound() { 114 return FogSound; 115 } 116 117 public void setFogSound(int sound) { 118 FogSound = sound; 119 } 120 121 private String FogGroup = ""; 122 123 public String getFogGroup() { 124 return FogGroup; 125 } 126 127 public void setFogGroup(String group) { 128 FogGroup = group; 129 } 130 131 private String FogPeriod = ""; 132 133 public String getFogPeriod() { 134 return FogPeriod; 135 } 136 137 public void setFogPeriod(String period) { 138 FogPeriod = period; 139 } 140 141 private boolean Fired = false; 142 143 public boolean isFired() { 144 return Fired; 145 } 146 147 public void setFired(boolean fired) { 148 Fired = fired; 149 } 150 151 private boolean Sectored = false; 152 153 public boolean isSectored() { 154 return Sectored; 155 } 156 157 public void setSectored(boolean sectored) { 158 Sectored = sectored; 159 } 160 161 private int SectorIndex = 0; 162 163 public int getSectorIndex() { 164 return SectorIndex; 165 } 166 167 public void setSectorIndex(int sector) { 168 SectorIndex = sector; 169 } 170 171 private String[] LightChar = new String[10]; 172 173 public String getLightChar() { 174 if (LightChar[SectorIndex] == null) 175 return (LightChar[0]); 176 return LightChar[SectorIndex]; 177 } 178 179 public void setLightChar(String lightChar) { 180 if (SectorIndex == 0) 181 LightChar = new String[10]; 182 LightChar[SectorIndex] = lightChar; 183 } 184 185 private String[] LightColour = new String[10]; 186 187 public String getLightColour() { 188 if (LightColour[SectorIndex] == null) 189 return (LightColour[0]); 190 return LightColour[SectorIndex]; 191 } 192 193 public void setLightColour(String lightColour) { 194 if (SectorIndex == 0) 195 LightColour = new String[10]; 196 LightColour[SectorIndex] = lightColour; 197 } 198 199 private String[] LightGroup = new String[10]; 200 201 public String getLightGroup() { 202 if (LightGroup[SectorIndex] == null) 203 return (LightGroup[0]); 204 return LightGroup[SectorIndex]; 205 } 206 207 public void setLightGroup(String lightGroup) { 208 if (SectorIndex == 0) 209 LightGroup = new String[10]; 210 LightGroup[SectorIndex] = lightGroup; 211 } 212 213 protected void setLightGroup(Map<String, String> k) { 214 String s = ""; 215 if (k.containsKey("seamark:light:group")) { 216 s = k.get("seamark:light:group"); 217 setLightGroup(s); 218 } 219 } 220 221 private String[] Height = new String[10]; 222 223 public String getHeight() { 224 if (Height[SectorIndex] == null) 225 return (Height[0]); 226 return Height[SectorIndex]; 227 } 228 229 public void setHeight(String height) { 230 if (SectorIndex == 0) 231 Height = new String[10]; 232 Height[SectorIndex] = height; 233 } 234 235 private String[] Range = new String[10]; 236 237 public String getRange() { 238 if (Range[SectorIndex] == null) 239 return (Range[0]); 240 return Range[SectorIndex]; 241 } 242 243 public void setRange(String range) { 244 if (SectorIndex == 0) 245 Range = new String[10]; 246 Range[SectorIndex] = range; 247 } 248 249 private String[] Bearing1 = new String[10]; 250 251 public String getBearing1() { 252 if (Bearing1[SectorIndex] == null) 253 return (Bearing1[0]); 254 return Bearing1[SectorIndex]; 255 } 256 257 public void setBearing1(String bearing) { 258 if (SectorIndex == 0) 259 Bearing1 = new String[10]; 260 Bearing1[SectorIndex] = bearing; 261 } 262 263 private String[] Bearing2 = new String[10]; 264 265 public String getBearing2() { 266 if (Bearing2[SectorIndex] == null) 267 return (Bearing2[0]); 268 return Bearing2[SectorIndex]; 269 } 270 271 public void setBearing2(String bearing) { 272 if (SectorIndex == 0) 273 Bearing2 = new String[10]; 274 Bearing2[SectorIndex] = bearing; 275 } 276 277 private String[] Radius = new String[10]; 278 279 public String getRadius() { 280 if (Radius[SectorIndex] == null) 281 return (Radius[0]); 282 return Radius[SectorIndex]; 283 } 284 285 public void setRadius(String radius) { 286 if (SectorIndex == 0) 287 Radius = new String[10]; 288 Radius[SectorIndex] = radius; 289 } 290 291 private String[] LightPeriod = new String[10]; 292 293 public String getLightPeriod() { 294 if (LightPeriod[SectorIndex] == null) 295 return (LightPeriod[0]); 296 return LightPeriod[SectorIndex]; 297 } 298 299 public void setLightPeriod(String lightPeriod) { 300 String regex = "^[\\d\\s.]+$"; 301 302 if (!lightPeriod.isEmpty()) { 303 304 Pattern pat = Pattern.compile(regex); 305 Matcher matcher = pat.matcher(lightPeriod); 306 307 if (matcher.find()) { 308 setErrMsg(null); 309 } else { 310 setErrMsg("Must be a number"); 311 lightPeriod = ""; 312 dlg.tfM01RepeatTime.requestFocus(); 313 } 314 } 315 if (SectorIndex == 0) 316 LightPeriod = new String[10]; 317 LightPeriod[SectorIndex] = lightPeriod; 318 } 319 320 private Node Node = null; 321 322 public Node getNode() { 323 return Node; 324 } 325 326 public void setNode(Node node) { 327 Node = node; 328 } 329 330 private boolean TopMark = false; 331 332 public boolean hasTopMark() { 333 return TopMark; 334 } 335 336 public void setTopMark(boolean topMark) { 337 TopMark = topMark; 338 /* 339 * if (dlg.cM01TopMark == null) { return; } 340 */ 341 dlg.cM01TopMark.setSelected(topMark); 342 } 343 344 protected SmpDialogAction dlg = null; // hier wird der Dialog referenziert 345 346 public SmpDialogAction getDlg() { 347 return dlg; 348 } 349 350 public void setDlg(SmpDialogAction dlg) { 351 this.dlg = dlg; 352 } 353 354 protected Buoy(SmpDialogAction dia) { 355 dlg = dia; 356 } 357 358 public boolean isValid() { 359 return false; 360 } 361 362 public void parseLights(Map<String, String> k) { 363 setFired(false); 364 setSectored(false); 365 Iterator it = k.entrySet().iterator(); 366 while (it.hasNext()) { 367 Map.Entry entry = (Map.Entry) it.next(); 368 String key = (String) entry.getKey(); 369 String value = ((String) entry.getValue()).trim(); 370 if (key.contains("seamark:light:")) { 371 setFired(true); 372 int index = 0; 373 key = key.substring(14); 374 if (key.matches("^\\d:.*")) { 375 index = key.charAt(0) - '0'; 376 key = key.substring(2); 377 } else if (key.matches("^\\d$")) { 378 index = key.charAt(0) - '0'; 379 String values[] = value.split(":"); 380 if (values[0].equals("red")) 381 LightColour[index] = "R"; 382 else if (values[0].equals("green")) 383 LightColour[index] = "G"; 384 else if (values[0].equals("white")) 385 LightColour[index] = "W"; 386 Bearing1[index] = values[1]; 387 Bearing2[index] = values[2]; 388 Radius[index] = values[3]; 389 } else { 390 index = 0; 391 } 392 if (index != 0) 393 setSectored(true); 394 if (key.equals("colour")) { 395 if (value.equals("red")) 396 LightColour[index] = "R"; 397 else if (value.equals("green")) 398 LightColour[index] = "G"; 399 else if (value.equals("white")) 400 LightColour[index] = "W"; 401 } else if (key.equals("character")) { 402 LightChar[index] = value; 403 } else if (key.equals("group")) { 404 LightGroup[index] = value; 405 } else if (key.equals("period")) { 406 LightPeriod[index] = value; 407 } else if (key.equals("height")) { 408 Height[index] = value; 409 } else if (key.equals("range")) { 410 Range[index] = value; 411 } 412 } 413 } 414 setSectorIndex(0); 415 dlg.cbM01Sector.setSelectedIndex(0); 416 dlg.cM01Fired.setSelected(isFired()); 417 dlg.rbM01Fired1.setSelected(!isSectored()); 418 dlg.rbM01FiredN.setSelected(isSectored()); 419 dlg.cbM01Kennung.setSelectedItem(getLightChar()); 420 dlg.tfM01Height.setText(getHeight()); 421 dlg.tfM01Range.setText(getRange()); 422 dlg.tfM01Group.setText(getLightGroup()); 423 dlg.tfM01RepeatTime.setText(getLightPeriod()); 424 dlg.cbM01Colour.setSelectedItem(getLightColour()); 425 } 426 427 public void parseFogRadar(Map<String, String> k) { 428 String str; 429 setFog(false); 430 setRadar(false); 431 setRacon(false); 432 if (k.containsKey("seamark:fog_signal") 433 || k.containsKey("seamark:fog_signal:category") 434 || k.containsKey("seamark:fog_signal:group") 435 || k.containsKey("seamark:fog_signal:period")) { 436 setFog(true); 437 if (k.containsKey("seamark:fog_signal:category")) { 438 str = k.get("seamark:fog_signal:category"); 439 if (str.equals("horn")) 440 setFogSound(FOG_HORN); 441 else if (str.equals("siren")) 442 setFogSound(FOG_SIREN); 443 else if (str.equals("diaphone")) 444 setFogSound(FOG_DIA); 445 else if (str.equals("bell")) 446 setFogSound(FOG_BELL); 447 else if (str.equals("whis")) 448 setFogSound(FOG_WHIS); 449 else if (str.equals("gong")) 450 setFogSound(FOG_GONG); 451 else if (str.equals("explosive")) 452 setFogSound(FOG_EXPLOS); 453 else 454 setFogSound(UNKNOWN_FOG); 455 } 456 if (k.containsKey("seamark:fog_signal:group")) 457 setFogGroup(k.get("seamark:fog_signal:group")); 458 if (k.containsKey("seamark:fog_signal:period")) 459 setFogPeriod(k.get("seamark:fog_signal:period")); 460 } 461 dlg.cM01Fog.setSelected(hasFog()); 462 dlg.cbM01Fog.setSelectedIndex(getFogSound()); 463 dlg.tfM01FogGroup.setText(getFogGroup()); 464 dlg.tfM01FogPeriod.setText(getFogPeriod()); 465 466 if (k.containsKey("seamark:radar_transponder") 467 || k.containsKey("seamark:radar_transponder:category") 468 || k.containsKey("seamark:radar_transponder:group")) { 469 setRacon(true); 470 if (k.containsKey("seamark:radar_transponder:category")) { 471 str = k.get("seamark:radar_transponder:category"); 472 if (str.equals("racon")) 473 setRaType(RATYPE_RACON); 474 else if (str.equals("ramark")) 475 setRaType(RATYPE_RAMARK); 476 else if (str.equals("leading")) 477 setRaType(RATYPE_LEADING); 478 else 479 setRaType(UNKNOWN_RATYPE); 480 } 481 if (k.containsKey("seamark:radar_transponder:group")) 482 setRaconGroup(k.get("seamark:radar_transponder:group")); 483 } else if (k.containsKey("seamark:radar_reflector")) 484 setRadar(true); 485 dlg.cM01Radar.setSelected(hasRadar()); 486 dlg.cM01Racon.setSelected(hasRacon()); 487 dlg.cbM01Racon.setSelectedIndex(getRaType()); 488 dlg.tfM01Racon.setText(getRaconGroup()); 489 } 490 491 public void paintSign() { 492 493 if (dlg.paintlock) 494 return; 495 else 496 dlg.paintlock = true; 497 498 dlg.lM01Icon.setIcon(null); 499 dlg.lM02Icon.setIcon(null); 500 dlg.lM03Icon.setIcon(null); 501 dlg.lM04Icon.setIcon(null); 502 dlg.lM05Icon.setIcon(null); 503 504 dlg.rbM01RegionA.setSelected(!getRegion()); 505 dlg.rbM01RegionB.setSelected(getRegion()); 506 507 if (isValid()) { 508 dlg.bM01Save.setEnabled(true); 509 510 dlg.cM01TopMark.setSelected(hasTopMark()); 511 dlg.cM01Fired.setSelected(isFired()); 512 513 dlg.tfM01RepeatTime.setText(getLightPeriod()); 514 515 dlg.tfM01Name.setText(getName()); 516 dlg.tfM01Name.setEnabled(true); 517 518 if (hasRadar()) { 519 dlg.lM03Icon.setIcon(new ImageIcon(getClass().getResource( 520 "/images/Radar_Reflector.png"))); 521 } 522 523 if (hasRacon()) { 524 dlg.lM04Icon.setIcon(new ImageIcon(getClass().getResource( 525 "/images/Radar_Station.png"))); 526 dlg.cbM01Racon.setVisible(true); 527 if (getRaType() == RATYPE_RACON) { 528 dlg.lM01Racon.setVisible(true); 529 dlg.tfM01Racon.setVisible(true); 530 dlg.tfM01Racon.setEnabled(true); 531 } else { 532 dlg.lM01Racon.setVisible(false); 533 dlg.tfM01Racon.setVisible(false); 534 } 535 } else { 536 dlg.cbM01Racon.setVisible(false); 537 dlg.lM01Racon.setVisible(false); 538 dlg.tfM01Racon.setVisible(false); 539 } 540 541 if (hasFog()) { 542 dlg.lM05Icon.setIcon(new ImageIcon(getClass().getResource( 543 "/images/Fog_Signal.png"))); 544 dlg.cbM01Fog.setVisible(true); 545 if (getFogSound() == 0) { 546 dlg.lM01FogGroup.setVisible(false); 547 dlg.tfM01FogGroup.setVisible(false); 548 dlg.lM01FogPeriod.setVisible(false); 549 dlg.tfM01FogPeriod.setVisible(false); 550 } else { 551 dlg.lM01FogGroup.setVisible(true); 552 dlg.tfM01FogGroup.setVisible(true); 553 dlg.lM01FogPeriod.setVisible(true); 554 dlg.tfM01FogPeriod.setVisible(true); 555 } 556 } else { 557 dlg.cbM01Fog.setVisible(false); 558 dlg.lM01FogGroup.setVisible(false); 559 dlg.tfM01FogGroup.setVisible(false); 560 dlg.lM01FogPeriod.setVisible(false); 561 dlg.tfM01FogPeriod.setVisible(false); 562 } 563 564 if (isFired()) { 565 String lp, c; 566 String tmp = null; 567 int i1; 568 569 String col = getLightColour(); 570 if (col.equals("W")) { 571 dlg.lM02Icon.setIcon(new ImageIcon(getClass().getResource( 572 "/images/Light_White_120.png"))); 573 dlg.cbM01Colour.setSelectedIndex(WHITE_LIGHT); 574 } else if (col.equals("R")) { 575 dlg.lM02Icon.setIcon(new ImageIcon(getClass().getResource( 576 "/images/Light_Red_120.png"))); 577 dlg.cbM01Colour.setSelectedIndex(RED_LIGHT); 578 } else if (col.equals("G")) { 579 dlg.lM02Icon.setIcon(new ImageIcon(getClass().getResource( 580 "/images/Light_Green_120.png"))); 581 dlg.cbM01Colour.setSelectedIndex(GREEN_LIGHT); 582 } else { 583 dlg.lM02Icon.setIcon(new ImageIcon(getClass().getResource( 584 "/images/Light_Magenta_120.png"))); 585 dlg.cbM01Colour.setSelectedIndex(UNKNOWN_COLOUR); 586 } 587 588 c = getLightChar(); 589 if (c.contains("+")) { 590 i1 = c.indexOf("+"); 591 tmp = c.substring(i1, c.length()); 592 c = c.substring(0, i1); 593 if (!getLightGroup().isEmpty()) { 594 c = c + "(" + getLightGroup() + ")"; 595 } 596 if (tmp != null) 597 c = c + tmp; 598 } 599 dlg.cbM01Kennung.setSelectedItem(c); 600 if (((dlg.cbM01Kennung.getSelectedIndex() == 0) && !getLightGroup() 601 .isEmpty()) 602 || (((String) dlg.cbM01Kennung.getSelectedItem()).contains("(")) 603 && !(((String) dlg.cbM01Kennung.getSelectedItem()).contains("+"))) { 604 c = c + "(" + getLightGroup() + ")"; 605 dlg.cbM01Kennung.setSelectedItem(c); 606 } 607 c = c + " " + getLightColour(); 608 lp = getLightPeriod(); 609 if (!lp.isEmpty()) 610 c = c + " " + lp + "s"; 611 dlg.lM01FireMark.setText(c); 612 dlg.cM01Fired.setVisible(true); 613 dlg.lM01Kennung.setVisible(true); 614 dlg.cbM01Kennung.setVisible(true); 615 if (((String) dlg.cbM01Kennung.getSelectedItem()).contains("(")) { 616 dlg.tfM01Group.setVisible(false); 617 dlg.lM01Group.setVisible(false); 618 } else { 619 dlg.lM01Group.setVisible(true); 620 dlg.tfM01Group.setVisible(true); 621 } 622 dlg.tfM01Group.setText(getLightGroup()); 623 dlg.lM01RepeatTime.setVisible(true); 624 dlg.tfM01RepeatTime.setVisible(true); 625 if (isSectored()) { 626 dlg.rbM01Fired1.setSelected(false); 627 dlg.rbM01FiredN.setSelected(true); 628 if ((getSectorIndex() != 0) && (!LightChar[0].isEmpty())) 629 dlg.cbM01Kennung.setEnabled(false); 630 else 631 dlg.cbM01Kennung.setEnabled(true); 632 dlg.cbM01Kennung.setSelectedItem(getLightChar()); 633 if ((getSectorIndex() != 0) && (!LightGroup[0].isEmpty())) 634 dlg.tfM01Group.setEnabled(false); 635 else 636 dlg.tfM01Group.setEnabled(true); 637 dlg.tfM01Group.setText(getLightGroup()); 638 if ((getSectorIndex() != 0) && (!LightPeriod[0].isEmpty())) 639 dlg.tfM01RepeatTime.setEnabled(false); 640 else 641 dlg.tfM01RepeatTime.setEnabled(true); 642 dlg.tfM01RepeatTime.setText(getLightPeriod()); 643 if ((getSectorIndex() != 0) && (!Height[0].isEmpty())) 644 dlg.tfM01Height.setEnabled(false); 645 else 646 dlg.tfM01Height.setEnabled(true); 647 dlg.tfM01Height.setText(getHeight()); 648 if ((getSectorIndex() != 0) && (!Range[0].isEmpty())) 649 dlg.tfM01Range.setEnabled(false); 650 else 651 dlg.tfM01Range.setEnabled(true); 652 dlg.tfM01Range.setText(getRange()); 653 dlg.lM01Sector.setVisible(true); 654 dlg.cbM01Sector.setVisible(true); 655 if (getSectorIndex() == 0) { 656 dlg.lM01Colour.setVisible(false); 657 dlg.cbM01Colour.setVisible(false); 658 dlg.lM01Bearing.setVisible(false); 659 dlg.tfM01Bearing.setVisible(false); 660 dlg.tfM02Bearing.setVisible(false); 661 dlg.tfM01Radius.setVisible(false); 662 } else { 663 dlg.lM01Colour.setVisible(true); 664 dlg.cbM01Colour.setVisible(true); 665 dlg.lM01Bearing.setVisible(true); 666 dlg.tfM01Bearing.setVisible(true); 667 dlg.tfM01Bearing.setText(getBearing1()); 668 dlg.tfM02Bearing.setVisible(true); 669 dlg.tfM02Bearing.setText(getBearing2()); 670 dlg.tfM01Radius.setVisible(true); 671 dlg.tfM01Radius.setText(getRadius()); 672 } 673 } else { 674 dlg.rbM01FiredN.setSelected(false); 675 dlg.rbM01Fired1.setSelected(true); 676 dlg.cbM01Kennung.setEnabled(true); 677 dlg.tfM01Group.setEnabled(true); 678 dlg.tfM01RepeatTime.setEnabled(true); 679 dlg.tfM01Height.setEnabled(true); 680 dlg.tfM01Range.setEnabled(true); 681 dlg.lM01Colour.setVisible(true); 682 dlg.cbM01Colour.setVisible(true); 683 dlg.lM01Sector.setVisible(false); 684 dlg.cbM01Sector.setVisible(false); 685 dlg.lM01Bearing.setVisible(false); 686 dlg.tfM01Bearing.setVisible(false); 687 dlg.tfM02Bearing.setVisible(false); 688 dlg.tfM01Radius.setVisible(false); 689 } 690 } else { 691 dlg.lM01FireMark.setText(""); 692 dlg.rbM01Fired1.setVisible(false); 693 dlg.rbM01FiredN.setVisible(false); 694 dlg.cbM01Kennung.setVisible(false); 695 dlg.lM01Kennung.setVisible(false); 696 dlg.tfM01Height.setVisible(false); 697 dlg.lM01Height.setVisible(false); 698 dlg.tfM01Range.setVisible(false); 699 dlg.lM01Range.setVisible(false); 700 dlg.cbM01Colour.setVisible(false); 701 dlg.lM01Colour.setVisible(false); 702 dlg.cbM01Sector.setVisible(false); 703 dlg.lM01Sector.setVisible(false); 704 dlg.tfM01Group.setVisible(false); 705 dlg.lM01Group.setVisible(false); 706 dlg.tfM01RepeatTime.setVisible(false); 707 dlg.lM01RepeatTime.setVisible(false); 708 dlg.tfM01Bearing.setVisible(false); 709 dlg.lM01Bearing.setVisible(false); 710 dlg.tfM02Bearing.setVisible(false); 711 dlg.tfM01Radius.setVisible(false); 712 } 713 } else { 714 dlg.bM01Save.setEnabled(false); 715 dlg.tfM01Name.setEnabled(false); 716 dlg.cM01TopMark.setVisible(false); 717 dlg.cbM01TopMark.setVisible(false); 718 dlg.cM01Radar.setVisible(false); 719 dlg.cM01Racon.setVisible(false); 720 dlg.cbM01Racon.setVisible(false); 721 dlg.tfM01Racon.setVisible(false); 722 dlg.lM01Racon.setVisible(false); 723 dlg.cM01Fog.setVisible(false); 724 dlg.cbM01Fog.setVisible(false); 725 dlg.tfM01FogGroup.setVisible(false); 726 dlg.lM01FogGroup.setVisible(false); 727 dlg.tfM01FogPeriod.setVisible(false); 728 dlg.lM01FogPeriod.setVisible(false); 729 dlg.cM01Fired.setVisible(false); 730 dlg.rbM01Fired1.setVisible(false); 731 dlg.rbM01FiredN.setVisible(false); 732 dlg.cbM01Kennung.setVisible(false); 733 dlg.lM01Kennung.setVisible(false); 734 dlg.tfM01Height.setVisible(false); 735 dlg.lM01Height.setVisible(false); 736 dlg.tfM01Range.setVisible(false); 737 dlg.lM01Range.setVisible(false); 738 dlg.cbM01Colour.setVisible(false); 739 dlg.lM01Colour.setVisible(false); 740 dlg.cbM01Sector.setVisible(false); 741 dlg.lM01Sector.setVisible(false); 742 dlg.tfM01Group.setVisible(false); 743 dlg.lM01Group.setVisible(false); 744 dlg.tfM01RepeatTime.setVisible(false); 745 dlg.lM01RepeatTime.setVisible(false); 746 dlg.tfM01Bearing.setVisible(false); 747 dlg.lM01Bearing.setVisible(false); 748 dlg.tfM02Bearing.setVisible(false); 749 dlg.tfM01Radius.setVisible(false); 750 } 751 dlg.paintlock = false; 752 } 753 754 public void saveSign(String type) { 755 delSeaMarkKeys(Node); 756 757 String str = dlg.tfM01Name.getText(); 758 if (!str.isEmpty()) 759 Main.main.undoRedo.add(new ChangePropertyCommand(Node, "seamark:name", 760 str)); 761 Main.main.undoRedo 762 .add(new ChangePropertyCommand(Node, "seamark:type", type)); 763 } 764 765 protected void saveLightData() { 766 String colour; 767 if (dlg.cM01Fired.isSelected()) { 768 if (!(colour = LightColour[0]).isEmpty()) 769 if (colour.equals("R")) { 770 Main.main.undoRedo.add(new ChangePropertyCommand(Node, 771 "seamark:light:colour", "red")); 772 } else if (colour.equals("G")) { 773 Main.main.undoRedo.add(new ChangePropertyCommand(Node, 774 "seamark:light:colour", "green")); 775 } else if (colour.equals("W")) { 776 Main.main.undoRedo.add(new ChangePropertyCommand(Node, 777 "seamark:light:colour", "white")); 778 } 779 780 if (!LightPeriod[0].isEmpty()) 781 Main.main.undoRedo.add(new ChangePropertyCommand(Node, 782 "seamark:light:period", LightPeriod[0])); 783 784 if (!LightChar[0].isEmpty()) 785 Main.main.undoRedo.add(new ChangePropertyCommand(Node, 786 "seamark:light:character", LightChar[0])); 787 788 if (!LightGroup[0].isEmpty()) 789 Main.main.undoRedo.add(new ChangePropertyCommand(Node, 790 "seamark:light:group", LightGroup[0])); 791 792 if (!Height[0].isEmpty()) 793 Main.main.undoRedo.add(new ChangePropertyCommand(Node, 794 "seamark:light:height", Height[0])); 795 796 if (!Range[0].isEmpty()) 797 Main.main.undoRedo.add(new ChangePropertyCommand(Node, 798 "seamark:light:range", Range[0])); 799 800 for (int i = 1; i < 10; i++) { 801 if ((colour = LightColour[i]) != null) 802 if (colour.equals("R")) { 803 Main.main.undoRedo.add(new ChangePropertyCommand(Node, 804 "seamark:light:" + i + ":colour", "red")); 805 if ((Bearing1[i] != null) && (Bearing2[i] != null) 806 && (Radius[i] != null)) 807 Main.main.undoRedo.add(new ChangePropertyCommand(Node, 808 "seamark:light:" + i, "red:" + Bearing1[i] + ":" 809 + Bearing2[i] + ":" + Radius[i])); 810 } else if (colour.equals("G")) { 811 Main.main.undoRedo.add(new ChangePropertyCommand(Node, 812 "seamark:light:" + i + ":colour", "green")); 813 if ((Bearing1[i] != null) && (Bearing2[i] != null) 814 && (Radius[i] != null)) 815 Main.main.undoRedo.add(new ChangePropertyCommand(Node, 816 "seamark:light:" + i, "green:" + Bearing1[i] + ":" 817 + Bearing2[i] + ":" + Radius[i])); 818 } else if (colour.equals("W")) { 819 Main.main.undoRedo.add(new ChangePropertyCommand(Node, 820 "seamark:light:" + i + ":colour", "white")); 821 if ((Bearing1[i] != null) && (Bearing2[i] != null) 822 && (Radius[i] != null)) 823 Main.main.undoRedo.add(new ChangePropertyCommand(Node, 824 "seamark:light:" + i, "white:" + Bearing1[i] + ":" 825 + Bearing2[i] + ":" + Radius[i])); 826 } 827 828 if (LightPeriod[i] != null) 829 Main.main.undoRedo.add(new ChangePropertyCommand(Node, 830 "seamark:light:" + i + ":period", LightPeriod[i])); 831 832 if (LightChar[i] != null) 833 Main.main.undoRedo.add(new ChangePropertyCommand(Node, 834 "seamark:light:" + i + ":character", LightChar[i])); 835 836 if (LightGroup[i] != null) 837 Main.main.undoRedo.add(new ChangePropertyCommand(Node, 838 "seamark:light:" + i + ":group", LightGroup[i])); 839 840 if (Height[i] != null) 841 Main.main.undoRedo.add(new ChangePropertyCommand(Node, 842 "seamark:light:" + i + ":height", Height[i])); 843 844 if (Range[i] != null) 845 Main.main.undoRedo.add(new ChangePropertyCommand(Node, 846 "seamark:light:" + i + ":range", Range[i])); 847 848 if (Bearing1[i] != null) 849 Main.main.undoRedo.add(new ChangePropertyCommand(Node, 850 "seamark:light:" + i + ":sector_start", Bearing1[i])); 851 852 if (Bearing2[i] != null) 853 Main.main.undoRedo.add(new ChangePropertyCommand(Node, 854 "seamark:light:" + i + ":sector_end", Bearing2[i])); 855 } 856 } 857 } 858 859 protected void saveTopMarkData(String shape, String colour) { 860 if (dlg.cM01TopMark.isSelected()) { 861 Main.main.undoRedo.add(new ChangePropertyCommand(Node, 862 "seamark:topmark:shape", shape)); 863 Main.main.undoRedo.add(new ChangePropertyCommand(Node, 864 "seamark:topmark:colour", colour)); 865 } 866 } 867 868 protected void saveRadarFogData() { 869 if (hasRadar()) { 870 Main.main.undoRedo.add(new ChangePropertyCommand(Node, 871 "seamark:radar_reflector", "yes")); 872 } 873 if (hasRacon()) { 874 switch (RaType) { 875 case RATYPE_RACON: 876 Main.main.undoRedo.add(new ChangePropertyCommand(Node, 877 "seamark:radar_transponder:category", "racon")); 878 if (!getRaconGroup().isEmpty()) 879 Main.main.undoRedo.add(new ChangePropertyCommand(Node, 880 "seamark:radar_transponder:group", getRaconGroup())); 881 break; 882 case RATYPE_RAMARK: 883 Main.main.undoRedo.add(new ChangePropertyCommand(Node, 884 "seamark:radar_transponder:category", "ramark")); 885 break; 886 case RATYPE_LEADING: 887 Main.main.undoRedo.add(new ChangePropertyCommand(Node, 888 "seamark:radar_transponder:category", "leading")); 889 break; 890 default: 891 Main.main.undoRedo.add(new ChangePropertyCommand(Node, 892 "seamark:radar_transponder", "yes")); 893 } 894 } 895 if (hasFog()) { 896 if (getFogSound() == 0) { 897 Main.main.undoRedo.add(new ChangePropertyCommand(Node, 898 "seamark:fog_signal", "yes")); 899 } else { 900 switch (getFogSound()) { 901 case FOG_HORN: 902 Main.main.undoRedo.add(new ChangePropertyCommand(Node, 903 "seamark:fog_signal:category", "horn")); 904 break; 905 case FOG_SIREN: 906 Main.main.undoRedo.add(new ChangePropertyCommand(Node, 907 "seamark:fog_signal:category", "siren")); 908 break; 909 case FOG_DIA: 910 Main.main.undoRedo.add(new ChangePropertyCommand(Node, 911 "seamark:fog_signal:category", "diaphone")); 912 break; 913 case FOG_BELL: 914 Main.main.undoRedo.add(new ChangePropertyCommand(Node, 915 "seamark:fog_signal:category", "bell")); 916 break; 917 case FOG_WHIS: 918 Main.main.undoRedo.add(new ChangePropertyCommand(Node, 919 "seamark:fog_signal:category", "whistle")); 920 break; 921 case FOG_GONG: 922 Main.main.undoRedo.add(new ChangePropertyCommand(Node, 923 "seamark:fog_signal:category", "gong")); 924 break; 925 case FOG_EXPLOS: 926 Main.main.undoRedo.add(new ChangePropertyCommand(Node, 927 "seamark:fog_signal:category", "explosive")); 928 break; 929 } 930 if (!getFogGroup().isEmpty()) 931 Main.main.undoRedo.add(new ChangePropertyCommand(Node, 932 "seamark:fog_signal:group", getFogGroup())); 933 if (!getFogPeriod().isEmpty()) 934 Main.main.undoRedo.add(new ChangePropertyCommand(Node, 935 "seamark:fog_signal:period", getFogPeriod())); 936 } 937 } 938 } 939 940 public void refreshStyles() { 941 } 942 943 public void refreshLights() { 944 dlg.cbM01Kennung.removeAllItems(); 945 dlg.cbM01Kennung.addItem(Messages.getString("SmpDialogAction.212")); //$NON-NLS-1$ 946 dlg.cbM01Kennung.addItem("Fl"); //$NON-NLS-1$ 947 dlg.cbM01Kennung.addItem("LFl"); //$NON-NLS-1$ 948 dlg.cbM01Kennung.addItem("Iso"); //$NON-NLS-1$ 949 dlg.cbM01Kennung.addItem("F"); //$NON-NLS-1$ 950 dlg.cbM01Kennung.addItem("FFl"); //$NON-NLS-1$ 951 dlg.cbM01Kennung.addItem("Oc"); //$NON-NLS-1$ 952 dlg.cbM01Kennung.addItem("Q"); //$NON-NLS-1$ 953 dlg.cbM01Kennung.addItem("IQ"); //$NON-NLS-1$ 954 dlg.cbM01Kennung.addItem("VQ"); //$NON-NLS-1$ 955 dlg.cbM01Kennung.addItem("IVQ"); //$NON-NLS-1$ 956 dlg.cbM01Kennung.addItem("UQ"); //$NON-NLS-1$ 957 dlg.cbM01Kennung.addItem("IUQ"); //$NON-NLS-1$ 958 dlg.cbM01Kennung.addItem("Mo"); //$NON-NLS-1$ 959 dlg.cbM01Kennung.setSelectedIndex(0); 960 } 961 962 public void resetMask() { 963 setRegion(Main.pref.get("tomsplugin.IALA").equals("B")); 964 965 dlg.lM01Icon.setIcon(null); 966 dlg.lM02Icon.setIcon(null); 967 dlg.lM03Icon.setIcon(null); 968 dlg.lM04Icon.setIcon(null); 969 970 dlg.rbM01RegionA.setEnabled(false); 971 dlg.rbM01RegionB.setEnabled(false); 972 dlg.lM01FireMark.setText(""); 973 dlg.cbM01CatOfMark.removeAllItems(); 974 dlg.cbM01CatOfMark.setVisible(false); 975 dlg.lM01CatOfMark.setVisible(false); 976 setBuoyIndex(0); 977 dlg.cbM01StyleOfMark.removeAllItems(); 978 dlg.cbM01StyleOfMark.setVisible(false); 979 dlg.lM01StyleOfMark.setVisible(false); 980 setStyleIndex(0); 981 dlg.tfM01Name.setText(""); 982 dlg.tfM01Name.setEnabled(false); 983 setName(""); 984 dlg.cM01TopMark.setSelected(false); 985 dlg.cM01TopMark.setVisible(false); 986 dlg.cbM01TopMark.removeAllItems(); 987 dlg.cbM01TopMark.setVisible(false); 988 setTopMark(false); 989 dlg.cM01Radar.setSelected(false); 990 dlg.cM01Radar.setVisible(false); 991 setRadar(false); 992 dlg.cM01Racon.setSelected(false); 993 dlg.cM01Racon.setVisible(false); 994 dlg.cbM01Racon.setVisible(false); 995 dlg.tfM01Racon.setText(""); 996 dlg.tfM01Racon.setVisible(false); 997 dlg.lM01Racon.setVisible(false); 998 setRacon(false); 999 setRaType(0); 1000 dlg.cM01Fog.setSelected(false); 1001 dlg.cM01Fog.setVisible(false); 1002 dlg.cbM01Fog.setVisible(false); 1003 setFogSound(0); 1004 dlg.tfM01FogGroup.setText(""); 1005 dlg.tfM01FogGroup.setVisible(false); 1006 dlg.lM01FogGroup.setVisible(false); 1007 dlg.tfM01FogPeriod.setText(""); 1008 dlg.tfM01FogPeriod.setVisible(false); 1009 dlg.lM01FogPeriod.setVisible(false); 1010 setFog(false); 1011 dlg.cM01Fired.setSelected(false); 1012 dlg.cM01Fired.setVisible(false); 1013 setFired(false); 1014 dlg.rbM01Fired1.setVisible(false); 1015 dlg.rbM01Fired1.setSelected(true); 1016 dlg.rbM01FiredN.setVisible(false); 1017 dlg.rbM01FiredN.setSelected(false); 1018 setSectored(false); 1019 dlg.cbM01Kennung.removeAllItems(); 1020 dlg.cbM01Kennung.setVisible(false); 1021 dlg.lM01Kennung.setVisible(false); 1022 setLightChar(""); 1023 dlg.tfM01Height.setText(""); 1024 dlg.tfM01Height.setVisible(false); 1025 dlg.lM01Height.setVisible(false); 1026 setHeight(""); 1027 dlg.tfM01Range.setText(""); 1028 dlg.tfM01Range.setVisible(false); 1029 dlg.lM01Range.setVisible(false); 1030 setRange(""); 1031 dlg.cbM01Colour.setVisible(false); 1032 dlg.lM01Colour.setVisible(false); 1033 setLightColour(""); 1034 dlg.cbM01Sector.setVisible(false); 1035 dlg.lM01Sector.setVisible(false); 1036 setSectorIndex(0); 1037 dlg.tfM01Group.setText(""); 1038 dlg.tfM01Group.setVisible(false); 1039 dlg.lM01Group.setVisible(false); 1040 setLightGroup(""); 1041 dlg.tfM01RepeatTime.setText(""); 1042 dlg.tfM01RepeatTime.setVisible(false); 1043 dlg.lM01RepeatTime.setVisible(false); 1044 setLightPeriod(""); 1045 dlg.tfM01Bearing.setText(""); 1046 dlg.tfM01Bearing.setVisible(false); 1047 dlg.lM01Bearing.setVisible(false); 1048 setBearing1(""); 1049 dlg.tfM02Bearing.setText(""); 1050 dlg.tfM02Bearing.setVisible(false); 1051 setBearing2(""); 1052 dlg.tfM01Radius.setText(""); 1053 dlg.tfM01Radius.setVisible(false); 1054 setRadius(""); 1055 1056 dlg.bM01Save.setEnabled(false); 1057 } 1058 1058 1059 1059 } -
applications/editors/josm/plugins/toms/src/toms/seamarks/buoys/BuoyCard.java
r23179 r23193 18 18 public class BuoyCard extends Buoy { 19 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 20 public BuoyCard(SmpDialogAction dia, Node node) { 21 super(dia); 22 23 String str; 24 Map<String, String> keys; 25 keys = node.getKeys(); 26 setNode(node); 27 28 resetMask(); 29 dlg.cbM01CatOfMark.removeAllItems(); 30 dlg.cbM01CatOfMark.addItem(Messages.getString("SmpDialogAction.157")); //$NON-NLS-1$ 31 dlg.cbM01CatOfMark.addItem(Messages.getString("SmpDialogAction.158")); //$NON-NLS-1$ 32 dlg.cbM01CatOfMark.addItem(Messages.getString("SmpDialogAction.159")); //$NON-NLS-1$ 33 dlg.cbM01CatOfMark.addItem(Messages.getString("SmpDialogAction.160")); //$NON-NLS-1$ 34 dlg.cbM01CatOfMark.addItem(Messages.getString("SmpDialogAction.161")); //$NON-NLS-1$ 35 36 dlg.cbM01CatOfMark.setEnabled(true); 37 dlg.cbM01CatOfMark.setVisible(true); 38 dlg.lM01CatOfMark.setVisible(true); 39 40 dlg.cbM01StyleOfMark.removeAllItems(); 41 dlg.cbM01StyleOfMark.addItem(Messages.getString("SmpDialogAction.212")); //$NON-NLS-1$ 42 dlg.cbM01StyleOfMark.addItem(Messages.getString("Buoy.01")); //$NON-NLS-1$ 43 dlg.cbM01StyleOfMark.addItem(Messages.getString("Buoy.04")); //$NON-NLS-1$ 44 dlg.cbM01StyleOfMark.addItem(Messages.getString("Buoy.05")); //$NON-NLS-1$ 45 dlg.cbM01StyleOfMark.addItem(Messages.getString("Buoy.06")); //$NON-NLS-1$ 46 dlg.cbM01StyleOfMark.addItem(Messages.getString("Buoy.07")); //$NON-NLS-1$ 47 dlg.cbM01StyleOfMark.setVisible(true); 48 dlg.lM01StyleOfMark.setVisible(true); 49 50 dlg.cbM01TypeOfMark.setSelectedIndex(CARDINAL); 51 52 setRegion(Main.pref.get("tomsplugin.IALA").equals("B")); //$NON-NLS-1$ //$NON-NLS-2$ 53 if (keys.containsKey("name")) //$NON-NLS-1$ 54 setName(keys.get("name")); //$NON-NLS-1$ 55 56 if (keys.containsKey("seamark:name")) //$NON-NLS-1$ 57 setName(keys.get("seamark:name")); //$NON-NLS-1$ 58 59 if (keys.containsKey("seamark:buoy_cardinal:name")) //$NON-NLS-1$ 60 setName(keys.get("seamark:buoy_cardinal:name")); //$NON-NLS-1$ 61 else if (keys.containsKey("seamark:beacon_cardinal:name")) //$NON-NLS-1$ 62 setName(keys.get("seamark:beacon_cardinal:name")); //$NON-NLS-1$ 63 else if (keys.containsKey("seamark:light_float:name")) //$NON-NLS-1$ 64 setName(keys.get("seamark:light_float:name")); //$NON-NLS-1$ 65 66 String cat = ""; //$NON-NLS-1$ 67 String col = ""; //$NON-NLS-1$ 68 69 if (keys.containsKey("seamark:buoy_cardinal:category")) //$NON-NLS-1$ 70 cat = keys.get("seamark:buoy_cardinal:category"); //$NON-NLS-1$ 71 else if (keys.containsKey("seamark:beacon_cardinal:category")) //$NON-NLS-1$ 72 cat = keys.get("seamark:beacon_cardinal:category"); //$NON-NLS-1$ 73 74 if (keys.containsKey("seamark:buoy_cardinal:colour")) //$NON-NLS-1$ 75 col = keys.get("seamark:buoy_cardinal:colour"); //$NON-NLS-1$ 76 else if (keys.containsKey("seamark:beacon_cardinal:colour")) //$NON-NLS-1$ 77 col = keys.get("seamark:beacon_cardinal:colour"); //$NON-NLS-1$ 78 else if (keys.containsKey("seamark:light_float:colour")) //$NON-NLS-1$ 79 col = keys.get("seamark:light_float:colour"); //$NON-NLS-1$ 80 81 if (cat.isEmpty()) { //$NON-NLS-1$ 82 if (col.equals("black;yellow")) { //$NON-NLS-1$ 83 setBuoyIndex(CARD_NORTH); 84 setColour(BLACK_YELLOW); 85 } else if (col.equals("black;yellow;black")) { //$NON-NLS-1$ 86 setBuoyIndex(CARD_EAST); 87 setColour(BLACK_YELLOW_BLACK); 88 } else if (col.equals("yellow;black")) { //$NON-NLS-1$ 89 setBuoyIndex(CARD_SOUTH); 90 setColour(YELLOW_BLACK); 91 } else if (col.equals("yellow;black;yellow")) { //$NON-NLS-1$ 92 setBuoyIndex(CARD_WEST); 93 setColour(YELLOW_BLACK_YELLOW); 94 } 95 } else if (cat.equals("north")) { //$NON-NLS-1$ 96 setBuoyIndex(CARD_NORTH); 97 setColour(BLACK_YELLOW); 98 } else if (cat.equals("east")) { //$NON-NLS-1$ 99 setBuoyIndex(CARD_EAST); 100 setColour(BLACK_YELLOW_BLACK); 101 } else if (cat.equals("south")) { //$NON-NLS-1$ 102 setBuoyIndex(CARD_SOUTH); 103 setColour(YELLOW_BLACK); 104 } else if (cat.equals("west")) { //$NON-NLS-1$ 105 setBuoyIndex(CARD_WEST); 106 setColour(YELLOW_BLACK_YELLOW); 107 } 108 109 if (keys.containsKey("seamark:buoy_cardinal:shape")) { //$NON-NLS-1$ 110 str = keys.get("seamark:buoy_cardinal:shape"); //$NON-NLS-1$ 111 112 if (str.equals("pillar")) //$NON-NLS-1$ 113 setStyleIndex(CARD_PILLAR); 114 else if (str.equals("spar")) //$NON-NLS-1$ 115 setStyleIndex(CARD_SPAR); 116 } else if (keys.containsKey("seamark:beacon_cardinal:colour")) { //$NON-NLS-1$ 117 if (keys.containsKey("seamark:beacon_cardinal:shape")) { //$NON-NLS-1$ 118 str = keys.get("seamark:beacon_cardinal:shape"); //$NON-NLS-1$ 119 120 if (str.equals("tower")) //$NON-NLS-1$ 121 setStyleIndex(CARD_TOWER); 122 else 123 setStyleIndex(CARD_BEACON); 124 } else 125 setStyleIndex(CARD_BEACON); 126 } else if (keys.containsKey("seamark:type") //$NON-NLS-1$ 127 && (keys.get("seamark:type").equals("light_float"))) { //$NON-NLS-1$ //$NON-NLS-2$ 128 setStyleIndex(CARD_FLOAT); 129 } 130 131 if (getStyleIndex() >= dlg.cbM01StyleOfMark.getItemCount()) 132 setStyleIndex(0); 133 134 refreshLights(); 135 parseLights(keys); 136 parseFogRadar(keys); 137 138 dlg.cbM01CatOfMark.setSelectedIndex(getBuoyIndex()); 139 dlg.cbM01StyleOfMark.setSelectedIndex(getStyleIndex()); 140 dlg.tfM01Name.setText(getName()); 141 dlg.cM01TopMark.setSelected(hasTopMark()); 142 } 143 144 public void refreshLights() { 145 int type = getBuoyIndex(); 146 147 dlg.cbM01Kennung.removeAllItems(); 148 dlg.cbM01Kennung.addItem(Messages.getString("SmpDialogAction.212")); //$NON-NLS-1$ 149 dlg.cbM01Kennung.setSelectedIndex(0); 150 151 switch (type) { 152 case SeaMark.CARD_NORTH: 153 dlg.cbM01Kennung.addItem("Q"); //$NON-NLS-1$ 154 dlg.cbM01Kennung.addItem("VQ"); //$NON-NLS-1$ 155 break; 156 157 case SeaMark.CARD_EAST: 158 dlg.cbM01Kennung.addItem("Q(3)"); //$NON-NLS-1$ 159 dlg.cbM01Kennung.addItem("VQ(3)"); //$NON-NLS-1$ 160 break; 161 162 case SeaMark.CARD_SOUTH: 163 dlg.cbM01Kennung.addItem("Q(6)+LFl"); //$NON-NLS-1$ 164 dlg.cbM01Kennung.addItem("VQ(6)+LFl"); //$NON-NLS-1$ 165 break; 166 167 case SeaMark.CARD_WEST: 168 dlg.cbM01Kennung.addItem("Q(9)"); //$NON-NLS-1$ 169 dlg.cbM01Kennung.addItem("VQ(9)"); //$NON-NLS-1$ 170 break; 171 172 default: 173 } 174 175 } 176 177 public boolean isValid() { 178 return (getBuoyIndex() > 0) && (getStyleIndex() > 0); 179 } 180 181 public void paintSign() { 182 if (dlg.paintlock) 183 return; 184 super.paintSign(); 185 186 dlg.sM01StatusBar.setText(getErrMsg()); 187 188 if (isValid()) { 189 dlg.tfM01Name.setEnabled(true); 190 dlg.tfM01Name.setText(getName()); 191 dlg.cM01TopMark.setSelected(true); 192 dlg.cM01TopMark.setVisible(true); 193 dlg.cM01TopMark.setEnabled(false); 194 dlg.cM01Radar.setVisible(true); 195 dlg.cM01Racon.setVisible(true); 196 dlg.cM01Fog.setVisible(true); 197 dlg.cM01Fired.setEnabled(true); 198 dlg.cM01Fired.setVisible(true); 199 dlg.cbM01Colour.setVisible(false); 200 dlg.lM01Colour.setVisible(false); 201 dlg.rbM01Fired1.setVisible(false); 202 dlg.rbM01FiredN.setVisible(false); 203 dlg.lM01Height.setVisible(false); 204 dlg.tfM01Height.setVisible(false); 205 dlg.lM01Range.setVisible(false); 206 dlg.tfM01Range.setVisible(false); 207 208 if (isFired()) { 209 switch (getStyleIndex()) { 210 case LAT_BEACON: 211 case LAT_TOWER: 212 dlg.rbM01Fired1.setVisible(true); 213 dlg.rbM01FiredN.setVisible(true); 214 dlg.lM01Height.setVisible(true); 215 dlg.tfM01Height.setVisible(true); 216 dlg.lM01Range.setVisible(true); 217 dlg.tfM01Range.setVisible(true); 218 break; 219 case LAT_FLOAT: 220 dlg.lM01Height.setVisible(true); 221 dlg.tfM01Height.setVisible(true); 222 dlg.lM01Range.setVisible(true); 223 dlg.tfM01Range.setVisible(true); 224 break; 225 default: 226 } 227 } 228 String image = "/images/Cardinal"; //$NON-NLS-1$ 229 230 switch (getStyleIndex()) { 231 case SeaMark.CARD_PILLAR: 232 image += "_Pillar"; //$NON-NLS-1$ 233 break; 234 235 case SeaMark.CARD_SPAR: 236 image += "_Spar"; //$NON-NLS-1$ 237 break; 238 239 case SeaMark.CARD_BEACON: 240 image += "_Beacon"; //$NON-NLS-1$ 241 break; 242 243 case SeaMark.CARD_TOWER: 244 image += "_Tower"; //$NON-NLS-1$ 245 break; 246 247 case SeaMark.CARD_FLOAT: 248 image += "_Float"; //$NON-NLS-1$ 249 break; 250 251 default: 252 return; 253 } 254 255 switch (getBuoyIndex()) { 256 case CARD_NORTH: 257 image += "_North"; //$NON-NLS-1$ 258 break; 259 case CARD_EAST: 260 image += "_East"; //$NON-NLS-1$ 261 break; 262 case CARD_SOUTH: 263 image += "_South"; //$NON-NLS-1$ 264 break; 265 case CARD_WEST: 266 image += "_West"; //$NON-NLS-1$ 267 break; 268 default: 269 return; 270 } 271 272 if (!image.equals("/images/Cardinal")) { //$NON-NLS-1$ 273 image += ".png"; //$NON-NLS-1$ 274 dlg.lM01Icon.setIcon(new ImageIcon(getClass().getResource(image))); 275 276 } else 277 dlg.lM01Icon.setIcon(null); 278 } 279 } 280 281 public void setLightColour() { 282 super.setLightColour("W"); //$NON-NLS-1$ 283 } 284 285 public void saveSign() { 286 Node node = getNode(); 287 if (node == null) { 288 return; 289 } 290 291 String shape = ""; //$NON-NLS-1$ 292 293 switch (getStyleIndex()) { 294 case CARD_PILLAR: 295 super.saveSign("buoy_cardinal"); //$NON-NLS-1$ 296 Main.main.undoRedo.add(new ChangePropertyCommand(node, 297 "seamark:buoy_cardinal:shape", "pillar")); //$NON-NLS-1$ //$NON-NLS-2$ 298 break; 299 case CARD_SPAR: 300 super.saveSign("buoy_cardinal"); //$NON-NLS-1$ 301 Main.main.undoRedo.add(new ChangePropertyCommand(node, 302 "seamark:buoy_cardinal:shape", "spar")); //$NON-NLS-1$ //$NON-NLS-2$ 303 break; 304 case CARD_BEACON: 305 super.saveSign("beacon_cardinal"); //$NON-NLS-1$ 306 break; 307 case CARD_TOWER: 308 super.saveSign("beacon_cardinal"); //$NON-NLS-1$ 309 Main.main.undoRedo.add(new ChangePropertyCommand(node, 310 "seamark:beacon_cardinal:shape", "tower")); //$NON-NLS-1$ //$NON-NLS-2$ 311 break; 312 case CARD_FLOAT: 313 super.saveSign("light_float"); //$NON-NLS-1$ 314 break; 315 default: 316 } 317 318 switch (getStyleIndex()) { 319 case CARD_PILLAR: 320 case CARD_SPAR: 321 switch (getBuoyIndex()) { 322 case SeaMark.CARD_NORTH: 323 Main.main.undoRedo.add(new ChangePropertyCommand(node, 324 "seamark:buoy_cardinal:category", "north")); //$NON-NLS-1$ //$NON-NLS-2$ 325 Main.main.undoRedo.add(new ChangePropertyCommand(node, 326 "seamark:buoy_cardinal:colour", "black;yellow")); //$NON-NLS-1$ //$NON-NLS-2$ 327 shape = "2 cones up"; //$NON-NLS-1$ 328 break; 329 330 case SeaMark.CARD_EAST: 331 Main.main.undoRedo.add(new ChangePropertyCommand(node, 332 "seamark:buoy_cardinal:category", "east")); //$NON-NLS-1$ //$NON-NLS-2$ 333 Main.main.undoRedo.add(new ChangePropertyCommand(node, 334 "seamark:buoy_cardinal:colour", "black;yellow;black")); //$NON-NLS-1$ //$NON-NLS-2$ 335 shape = "2 cones base together"; //$NON-NLS-1$ 336 break; 337 338 case SeaMark.CARD_SOUTH: 339 Main.main.undoRedo.add(new ChangePropertyCommand(node, 340 "seamark:buoy_cardinal:category", "south")); //$NON-NLS-1$ //$NON-NLS-2$ 341 Main.main.undoRedo.add(new ChangePropertyCommand(node, 342 "seamark:buoy_cardinal:colour", "yellow;black")); //$NON-NLS-1$ //$NON-NLS-2$ 343 shape = "2 cones down"; //$NON-NLS-1$ 344 break; 345 346 case SeaMark.CARD_WEST: 347 Main.main.undoRedo.add(new ChangePropertyCommand(node, 348 "seamark:buoy_cardinal:category", "west")); //$NON-NLS-1$ //$NON-NLS-2$ 349 Main.main.undoRedo.add(new ChangePropertyCommand(node, 350 "seamark:buoy_cardinal:colour", "yellow;black;yellow")); //$NON-NLS-1$ //$NON-NLS-2$ 351 shape = "2 cones point together"; //$NON-NLS-1$ 352 break; 353 } 354 Main.main.undoRedo.add(new ChangePropertyCommand(node, 355 "seamark:buoy_cardinal:colour_pattern", "horizontal stripes")); //$NON-NLS-1$ //$NON-NLS-2$ 356 break; 357 case CARD_BEACON: 358 case CARD_TOWER: 359 switch (getBuoyIndex()) { 360 case SeaMark.CARD_NORTH: 361 Main.main.undoRedo.add(new ChangePropertyCommand(node, 362 "seamark:beacon_cardinal:category", "north")); //$NON-NLS-1$ //$NON-NLS-2$ 363 Main.main.undoRedo.add(new ChangePropertyCommand(node, 364 "seamark:beacon_cardinal:colour", "black;yellow")); //$NON-NLS-1$ //$NON-NLS-2$ 365 shape = "2 cones up"; //$NON-NLS-1$ 366 break; 367 368 case SeaMark.CARD_EAST: 369 Main.main.undoRedo.add(new ChangePropertyCommand(node, 370 "seamark:beacon_cardinal:category", "east")); //$NON-NLS-1$ //$NON-NLS-2$ 371 Main.main.undoRedo.add(new ChangePropertyCommand(node, 372 "seamark:beacon_cardinal:colour", "black;yellow;black")); //$NON-NLS-1$ //$NON-NLS-2$ 373 shape = "2 cones base together"; //$NON-NLS-1$ 374 break; 375 376 case SeaMark.CARD_SOUTH: 377 Main.main.undoRedo.add(new ChangePropertyCommand(node, 378 "seamark:beacon_cardinal:category", "south")); //$NON-NLS-1$ //$NON-NLS-2$ 379 Main.main.undoRedo.add(new ChangePropertyCommand(node, 380 "seamark:beacon_cardinal:colour", "yellow;black")); //$NON-NLS-1$ //$NON-NLS-2$ 381 shape = "2 cones down"; //$NON-NLS-1$ 382 break; 383 384 case SeaMark.CARD_WEST: 385 Main.main.undoRedo.add(new ChangePropertyCommand(node, 386 "seamark:beacon_cardinal:category", "west")); //$NON-NLS-1$ //$NON-NLS-2$ 387 Main.main.undoRedo.add(new ChangePropertyCommand(node, 388 "seamark:beacon_cardinal:colour", "yellow;black;yellow")); //$NON-NLS-1$ //$NON-NLS-2$ 389 shape = "2 cones point together"; //$NON-NLS-1$ 390 break; 391 } 392 Main.main.undoRedo.add(new ChangePropertyCommand(node, 393 "seamark:beacon_cardinal:colour_pattern", "horizontal stripes")); //$NON-NLS-1$ //$NON-NLS-2$ 394 break; 395 case CARD_FLOAT: 396 switch (getBuoyIndex()) { 397 case SeaMark.CARD_NORTH: 398 Main.main.undoRedo.add(new ChangePropertyCommand(node, 399 "seamark:light_float:colour", "black;yellow")); //$NON-NLS-1$ //$NON-NLS-2$ 400 shape = "2 cones up"; //$NON-NLS-1$ 401 break; 402 403 case SeaMark.CARD_EAST: 404 Main.main.undoRedo.add(new ChangePropertyCommand(node, 405 "seamark:light_float:colour", "black;yellow;black")); //$NON-NLS-1$ //$NON-NLS-2$ 406 shape = "2 cones base together"; //$NON-NLS-1$ 407 break; 408 409 case SeaMark.CARD_SOUTH: 410 Main.main.undoRedo.add(new ChangePropertyCommand(node, 411 "seamark:light_float:colour", "yellow;black")); //$NON-NLS-1$ //$NON-NLS-2$ 412 shape = "2 cones down"; //$NON-NLS-1$ 413 break; 414 415 case SeaMark.CARD_WEST: 416 Main.main.undoRedo.add(new ChangePropertyCommand(node, 417 "seamark:light_float:colour", "yellow;black;yellow")); //$NON-NLS-1$ //$NON-NLS-2$ 418 shape = "2 cones point together"; //$NON-NLS-1$ 419 break; 420 } 421 Main.main.undoRedo.add(new ChangePropertyCommand(node, 422 "seamark:light_float:colour_pattern", "horizontal stripes")); //$NON-NLS-1$ //$NON-NLS-2$ 423 break; 424 } 425 saveTopMarkData(shape, "black"); //$NON-NLS-1$ 426 saveLightData(); //$NON-NLS-1$ 427 saveRadarFogData(); 428 } 429 429 } -
applications/editors/josm/plugins/toms/src/toms/seamarks/buoys/BuoyIsol.java
r23179 r23193 17 17 18 18 public class BuoyIsol extends Buoy { 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 19 public BuoyIsol(SmpDialogAction dia, Node node) { 20 super(dia); 21 22 String str; 23 Map<String, String> keys; 24 keys = node.getKeys(); 25 setNode(node); 26 27 resetMask(); 28 29 dlg.cbM01TypeOfMark.setSelectedIndex(ISOLATED_DANGER); 30 31 dlg.cbM01StyleOfMark.removeAllItems(); 32 dlg.cbM01StyleOfMark.addItem(Messages.getString("SmpDialogAction.212")); //$NON-NLS-1$ 33 dlg.cbM01StyleOfMark.addItem(Messages.getString("Buoy.01")); //$NON-NLS-1$ 34 dlg.cbM01StyleOfMark.addItem(Messages.getString("Buoy.04")); //$NON-NLS-1$ 35 dlg.cbM01StyleOfMark.addItem(Messages.getString("Buoy.05")); //$NON-NLS-1$ 36 dlg.cbM01StyleOfMark.addItem(Messages.getString("Buoy.06")); //$NON-NLS-1$ 37 dlg.cbM01StyleOfMark.addItem(Messages.getString("Buoy.07")); //$NON-NLS-1$ 38 dlg.cbM01StyleOfMark.setVisible(true); 39 dlg.lM01StyleOfMark.setVisible(true); 40 41 setBuoyIndex(ISOLATED_DANGER); 42 setColour(SeaMark.BLACK_RED_BLACK); 43 setLightColour("W"); //$NON-NLS-1$ 44 setTopMark(true); 45 setRegion(Main.pref.get("tomsplugin.IALA").equals("B")); //$NON-NLS-1$ //$NON-NLS-2$ 46 47 if (keys.containsKey("name")) //$NON-NLS-1$ 48 setName(keys.get("name")); //$NON-NLS-1$ 49 50 if (keys.containsKey("seamark:name")) //$NON-NLS-1$ 51 setName(keys.get("seamark:name")); //$NON-NLS-1$ 52 53 if (keys.containsKey("seamark:buoy_isolated_danger:name")) //$NON-NLS-1$ 54 setName(keys.get("seamark:buoy_isolated_danger:name")); //$NON-NLS-1$ 55 else if (keys.containsKey("seamark:beacon_isolated_danger:name")) //$NON-NLS-1$ 56 setName(keys.get("seamark:beacon_isolated_danger:name")); //$NON-NLS-1$ 57 else if (keys.containsKey("seamark:light_float:name")) //$NON-NLS-1$ 58 setName(keys.get("seamark:light_float:name")); //$NON-NLS-1$ 59 60 if (keys.containsKey("seamark:buoy_isolated_danger:shape")) { //$NON-NLS-1$ 61 str = keys.get("seamark:buoy_isolated_danger:shape"); //$NON-NLS-1$ 62 63 if (str.equals("pillar")) //$NON-NLS-1$ 64 setStyleIndex(ISOL_PILLAR); 65 else if (str.equals("spar")) //$NON-NLS-1$ 66 setStyleIndex(ISOL_SPAR); 67 } else if (keys.containsKey("seamark:beacon_isolated_danger:colour")) { //$NON-NLS-1$ 68 if (keys.containsKey("seamark:beacon_isolated_danger:shape")) { //$NON-NLS-1$ 69 str = keys.get("seamark:beacon_isolated_danger:shape"); //$NON-NLS-1$ 70 71 if (str.equals("tower")) //$NON-NLS-1$ 72 setStyleIndex(ISOL_TOWER); 73 else 74 setStyleIndex(ISOL_BEACON); 75 } else 76 setStyleIndex(ISOL_BEACON); 77 } else if (keys.containsKey("seamark:type") //$NON-NLS-1$ 78 && (keys.get("seamark:type").equals("light_float"))) { //$NON-NLS-1$ //$NON-NLS-2$ 79 setStyleIndex(CARD_FLOAT); 80 } 81 82 if (getStyleIndex() >= dlg.cbM01StyleOfMark.getItemCount()) 83 setStyleIndex(0); 84 dlg.cbM01StyleOfMark.setSelectedIndex(getStyleIndex()); 85 86 if (keys.containsKey("seamark:topmark:shape") //$NON-NLS-1$ 87 || keys.containsKey("seamark:topmark:colour")) { //$NON-NLS-1$ 88 setTopMark(true); 89 } 90 91 refreshLights(); 92 parseLights(keys); 93 parseFogRadar(keys); 94 95 dlg.cbM01StyleOfMark.setSelectedIndex(getStyleIndex()); 96 dlg.tfM01Name.setText(getName()); 97 dlg.cM01TopMark.setSelected(hasTopMark()); 98 } 99 100 public void refreshLights() { 101 dlg.cbM01Kennung.removeAllItems(); 102 dlg.cbM01Kennung.addItem(Messages.getString("SmpDialogAction.212")); //$NON-NLS-1$ 103 dlg.cbM01Kennung.addItem("Fl(2)"); //$NON-NLS-1$ 104 dlg.cbM01Kennung.setSelectedIndex(0); 105 } 106 107 public boolean isValid() { 108 return (getBuoyIndex() > 0) && (getStyleIndex() > 0); 109 } 110 111 public void paintSign() { 112 if (dlg.paintlock) 113 return; 114 115 super.paintSign(); 116 117 dlg.sM01StatusBar.setText(getErrMsg()); 118 119 if (isValid()) { 120 dlg.tfM01Name.setEnabled(true); 121 dlg.tfM01Name.setText(getName()); 122 dlg.cM01TopMark.setVisible(true); 123 dlg.cM01Radar.setVisible(true); 124 dlg.cM01Racon.setVisible(true); 125 dlg.cM01Fog.setVisible(true); 126 dlg.cM01Fired.setVisible(true); 127 dlg.cbM01Colour.setVisible(false); 128 dlg.lM01Colour.setVisible(false); 129 dlg.rbM01Fired1.setVisible(false); 130 dlg.rbM01FiredN.setVisible(false); 131 dlg.lM01Height.setVisible(false); 132 dlg.tfM01Height.setVisible(false); 133 dlg.lM01Range.setVisible(false); 134 dlg.tfM01Range.setVisible(false); 135 136 if (isFired()) { 137 switch (getStyleIndex()) { 138 case SPEC_FLOAT: 139 dlg.lM01Height.setVisible(true); 140 dlg.tfM01Height.setVisible(true); 141 dlg.lM01Range.setVisible(true); 142 dlg.tfM01Range.setVisible(true); 143 break; 144 case SPEC_BEACON: 145 case SPEC_TOWER: 146 dlg.rbM01Fired1.setVisible(true); 147 dlg.rbM01FiredN.setVisible(true); 148 dlg.lM01Height.setVisible(true); 149 dlg.tfM01Height.setVisible(true); 150 dlg.lM01Range.setVisible(true); 151 dlg.tfM01Range.setVisible(true); 152 break; 153 default: 154 } 155 } 156 157 String image = "/images/Cardinal"; //$NON-NLS-1$ 158 159 switch (getStyleIndex()) { 160 case ISOL_PILLAR: 161 image += "_Pillar_Single"; //$NON-NLS-1$ 162 break; 163 case ISOL_SPAR: 164 image += "_Spar_Single"; //$NON-NLS-1$ 165 break; 166 case ISOL_BEACON: 167 image += "_Beacon_Single"; //$NON-NLS-1$ 168 break; 169 case ISOL_TOWER: 170 image += "_Tower_Single"; //$NON-NLS-1$ 171 break; 172 case ISOL_FLOAT: 173 image += "_Float_Single"; //$NON-NLS-1$ 174 break; 175 default: 176 } 177 178 if (!image.equals("/images/Cardinal")) { //$NON-NLS-1$ 179 image += ".png"; //$NON-NLS-1$ 180 dlg.lM01Icon.setIcon(new ImageIcon(getClass().getResource(image))); 181 } else 182 dlg.lM01Icon.setIcon(null); 183 } else { 184 dlg.tfM01Name.setEnabled(false); 185 dlg.tfM01Name.setText(""); //$NON-NLS-1$ 186 dlg.cM01TopMark.setVisible(false); 187 dlg.cM01Radar.setVisible(false); 188 dlg.cM01Racon.setVisible(false); 189 dlg.cM01Fog.setVisible(false); 190 dlg.cM01Fired.setVisible(false); 191 } 192 } 193 194 public void saveSign() { 195 Node node = getNode(); 196 197 if (node == null) { 198 return; 199 } 200 201 switch (getStyleIndex()) { 202 case ISOL_PILLAR: 203 super.saveSign("buoy_isolated_danger"); //$NON-NLS-1$ 204 Main.main.undoRedo.add(new ChangePropertyCommand(node, 205 "seamark:buoy_isolated_danger:shape", "pillar")); //$NON-NLS-1$ //$NON-NLS-2$ 206 break; 207 case ISOL_SPAR: 208 super.saveSign("buoy_isolated_danger"); //$NON-NLS-1$ 209 Main.main.undoRedo.add(new ChangePropertyCommand(node, 210 "seamark:buoy_isolated_danger:shape", "spar")); //$NON-NLS-1$ //$NON-NLS-2$ 211 break; 212 case ISOL_BEACON: 213 super.saveSign("beacon_isolated_danger"); //$NON-NLS-1$ 214 break; 215 case ISOL_TOWER: 216 super.saveSign("beacon_isolated_danger"); //$NON-NLS-1$ 217 Main.main.undoRedo.add(new ChangePropertyCommand(node, 218 "seamark:beacon_isolated_danger:shape", "tower")); //$NON-NLS-1$ //$NON-NLS-2$ 219 break; 220 case ISOL_FLOAT: 221 super.saveSign("light_float"); //$NON-NLS-1$ 222 break; 223 default: 224 } 225 226 switch (getStyleIndex()) { 227 case ISOL_PILLAR: 228 case ISOL_SPAR: 229 Main.main.undoRedo.add(new ChangePropertyCommand(node, 230 "seamark:buoy_isolated_danger:colour_pattern", "horizontal stripes")); //$NON-NLS-1$ //$NON-NLS-2$ 231 Main.main.undoRedo.add(new ChangePropertyCommand(node, 232 "seamark:buoy_isolated_danger:colour", "black;red;black")); //$NON-NLS-1$ //$NON-NLS-2$ 233 break; 234 case ISOL_BEACON: 235 case ISOL_TOWER: 236 Main.main.undoRedo 237 .add(new ChangePropertyCommand(node, 238 "seamark:beacon_isolated_danger:colour_pattern", //$NON-NLS-1$ 239 "horizontal stripes")); //$NON-NLS-1$ 240 Main.main.undoRedo.add(new ChangePropertyCommand(node, 241 "seamark:beacon_isolated_danger:colour", "black;red;black")); //$NON-NLS-1$ //$NON-NLS-2$ 242 break; 243 case ISOL_FLOAT: 244 Main.main.undoRedo.add(new ChangePropertyCommand(node, 245 "seamark:light_float:colour_pattern", "horizontal stripes")); //$NON-NLS-1$ //$NON-NLS-2$ 246 Main.main.undoRedo.add(new ChangePropertyCommand(node, 247 "seamark:light_float:colour", "black;red;black")); //$NON-NLS-1$ //$NON-NLS-2$ 248 break; 249 } 250 251 saveTopMarkData("2 spheres", "black"); //$NON-NLS-1$ //$NON-NLS-2$ 252 saveLightData(); //$NON-NLS-1$ 253 saveRadarFogData(); 254 255 } 256 257 public void setLightColour() { 258 super.setLightColour("W"); //$NON-NLS-1$ 259 } 260 260 261 261 } -
applications/editors/josm/plugins/toms/src/toms/seamarks/buoys/BuoyLat.java
r23179 r23193 16 16 17 17 public class BuoyLat extends Buoy { 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 18 public BuoyLat(SmpDialogAction dia, Node node) { 19 super(dia); 20 21 String str; 22 Map<String, String> keys; 23 keys = node.getKeys(); 24 setNode(node); 25 26 resetMask(); 27 28 dlg.cbM01CatOfMark.removeAllItems(); 29 dlg.cbM01CatOfMark.addItem(Messages.getString("SmpDialogAction.152")); //$NON-NLS-1$ 30 dlg.cbM01CatOfMark.addItem(Messages.getString("SmpDialogAction.153")); //$NON-NLS-1$ 31 dlg.cbM01CatOfMark.addItem(Messages.getString("SmpDialogAction.154")); //$NON-NLS-1$ 32 dlg.cbM01CatOfMark.addItem(Messages.getString("SmpDialogAction.155")); //$NON-NLS-1$ 33 dlg.cbM01CatOfMark.addItem(Messages.getString("SmpDialogAction.156")); //$NON-NLS-1$ 34 35 dlg.rbM01RegionA.setEnabled(true); 36 dlg.rbM01RegionB.setEnabled(true); 37 dlg.cbM01CatOfMark.setEnabled(true); 38 dlg.cbM01CatOfMark.setVisible(true); 39 dlg.lM01CatOfMark.setVisible(true); 40 41 dlg.cbM01StyleOfMark.removeAllItems(); 42 dlg.cbM01StyleOfMark.addItem(Messages.getString("SmpDialogAction.212")); //$NON-NLS-1$ 43 dlg.cbM01StyleOfMark.addItem(Messages.getString("Buoy.01")); //$NON-NLS-1$ 44 dlg.cbM01StyleOfMark.addItem(Messages.getString("Buoy.04")); //$NON-NLS-1$ 45 dlg.cbM01StyleOfMark.addItem(Messages.getString("Buoy.05")); //$NON-NLS-1$ 46 dlg.cbM01StyleOfMark.addItem(Messages.getString("Buoy.06")); //$NON-NLS-1$ 47 dlg.cbM01StyleOfMark.addItem(Messages.getString("Buoy.07")); //$NON-NLS-1$ 48 dlg.cbM01StyleOfMark.setEnabled(true); 49 50 dlg.cbM01TypeOfMark.setSelectedIndex(LATERAL); 51 52 if (keys.containsKey("name")) //$NON-NLS-1$ 53 setName(keys.get("name")); //$NON-NLS-1$ 54 55 if (keys.containsKey("seamark:name")) //$NON-NLS-1$ 56 setName(keys.get("seamark:name")); //$NON-NLS-1$ 57 58 if (keys.containsKey("seamark:buoy_lateral:name")) //$NON-NLS-1$ 59 setName(keys.get("seamark:buoy_lateral:name")); //$NON-NLS-1$ 60 else if (keys.containsKey("seamark:beacon_lateral:name")) //$NON-NLS-1$ 61 setName(keys.get("seamark:beacon_lateral:name")); //$NON-NLS-1$ 62 else if (keys.containsKey("seamark:light_float:name")) //$NON-NLS-1$ 63 setName(keys.get("seamark:light_float:name")); //$NON-NLS-1$ 64 65 String cat = ""; //$NON-NLS-1$ 66 String col = ""; //$NON-NLS-1$ 67 String top = ""; //$NON-NLS-1$ 68 69 if (getStyleIndex() != LAT_PERCH) { 70 if (keys.containsKey("seamark:topmark:shape")) { //$NON-NLS-1$ 71 top = keys.get("seamark:topmark:shape"); //$NON-NLS-1$ 72 setTopMark(true); 73 } 74 if (keys.containsKey("seamark:topmark:colour")) { //$NON-NLS-1$ 75 setTopMark(true); 76 } 77 } 78 79 if (keys.containsKey("seamark:buoy_lateral:colour")) //$NON-NLS-1$ 80 col = keys.get("seamark:buoy_lateral:colour"); //$NON-NLS-1$ 81 else if (keys.containsKey("seamark:beacon_lateral:colour")) //$NON-NLS-1$ 82 col = keys.get("seamark:beacon_lateral:colour"); //$NON-NLS-1$ 83 else if (keys.containsKey("seamark:light_float:colour")) //$NON-NLS-1$ 84 col = keys.get("seamark:light_float:colour"); //$NON-NLS-1$ 85 86 if (keys.containsKey("seamark:buoy_lateral:category")) //$NON-NLS-1$ 87 cat = keys.get("seamark:buoy_lateral:category"); //$NON-NLS-1$ 88 else if (keys.containsKey("seamark:beacon_lateral:category")) //$NON-NLS-1$ 89 cat = keys.get("seamark:beacon_lateral:category"); //$NON-NLS-1$ 90 91 if (cat.isEmpty()) { //$NON-NLS-1$ 92 if (col.equals("red")) { //$NON-NLS-1$ 93 setColour(RED); 94 if (top.equals("cylinder")) { //$NON-NLS-1$ 95 setBuoyIndex(PORT_HAND); 96 setRegion(IALA_A); 97 } else if (top.equals("cone, point up")) { //$NON-NLS-1$ 98 setBuoyIndex(STARBOARD_HAND); 99 setRegion(IALA_B); 100 } else { 101 if (getRegion() == IALA_A) 102 setBuoyIndex(PORT_HAND); 103 else 104 setBuoyIndex(STARBOARD_HAND); 105 } 106 } else if (col.equals("green")) { //$NON-NLS-1$ 107 setColour(GREEN); 108 if (top.equals("cone, point up")) { //$NON-NLS-1$ 109 setBuoyIndex(STARBOARD_HAND); 110 setRegion(IALA_A); 111 } else if (top.equals("cylinder")) { //$NON-NLS-1$ 112 setBuoyIndex(PORT_HAND); 113 setRegion(IALA_B); 114 } else { 115 if (getRegion() == IALA_A) 116 setBuoyIndex(STARBOARD_HAND); 117 else 118 setBuoyIndex(PORT_HAND); 119 } 120 } else if (col.equals("red;green;red")) { //$NON-NLS-1$ 121 setColour(RED_GREEN_RED); 122 if (top.equals("cylinder")) { //$NON-NLS-1$ 123 setBuoyIndex(PREF_PORT_HAND); 124 setRegion(IALA_A); 125 } else if (top.equals("cone, point up")) { //$NON-NLS-1$ 126 setBuoyIndex(PREF_STARBOARD_HAND); 127 setRegion(IALA_B); 128 } else { 129 if (getRegion() == IALA_A) 130 setBuoyIndex(PREF_PORT_HAND); 131 else 132 setBuoyIndex(PREF_STARBOARD_HAND); 133 } 134 } else if (col.equals("green;red;green")) { //$NON-NLS-1$ 135 setColour(GREEN_RED_GREEN); 136 if (top.equals("cone, point up")) { //$NON-NLS-1$ 137 setBuoyIndex(PREF_STARBOARD_HAND); 138 setRegion(IALA_A); 139 } else if (top.equals("cylinder")) { //$NON-NLS-1$ 140 setBuoyIndex(PREF_PORT_HAND); 141 setRegion(IALA_B); 142 } else { 143 if (getRegion() == IALA_A) 144 setBuoyIndex(PREF_STARBOARD_HAND); 145 else 146 setBuoyIndex(PREF_PORT_HAND); 147 } 148 } 149 } else if (cat.equals("port")) { //$NON-NLS-1$ 150 151 setBuoyIndex(PORT_HAND); 152 153 if (col.equals("red")) { //$NON-NLS-1$ 154 setRegion(IALA_A); 155 setColour(RED); 156 } else if (col.equals("green")) { //$NON-NLS-1$ 157 setRegion(IALA_B); 158 setColour(GREEN); 159 } else { 160 if (getRegion() == IALA_A) 161 setColour(RED); 162 else 163 setColour(GREEN); 164 } 165 } else if (cat.equals("starboard")) { //$NON-NLS-1$ 166 167 setBuoyIndex(STARBOARD_HAND); 168 169 if (col.equals("green")) { //$NON-NLS-1$ 170 setRegion(IALA_A); 171 setColour(GREEN); 172 } else if (col.equals("red")) { //$NON-NLS-1$ 173 setRegion(IALA_B); 174 setColour(RED); 175 } else { 176 if (getRegion() == IALA_A) 177 setColour(GREEN); 178 else 179 setColour(RED); 180 } 181 } else if (cat.equals("preferred_channel_port")) { //$NON-NLS-1$ 182 183 setBuoyIndex(PREF_PORT_HAND); 184 185 if (col.equals("red;green;red")) { //$NON-NLS-1$ 186 setRegion(IALA_A); 187 setColour(RED_GREEN_RED); 188 } else if (col.equals("green;red;green")) { //$NON-NLS-1$ 189 setRegion(IALA_B); 190 setColour(GREEN_RED_GREEN); 191 } else { 192 if (getRegion() == IALA_A) 193 setColour(RED_GREEN_RED); 194 else 195 setColour(GREEN_RED_GREEN); 196 } 197 198 } else if (cat.equals("preferred_channel_starboard")) { //$NON-NLS-1$ 199 200 setBuoyIndex(PREF_STARBOARD_HAND); 201 202 if (col.equals("green;red;green")) { //$NON-NLS-1$ 203 setRegion(IALA_A); 204 setColour(GREEN_RED_GREEN); 205 } else if (col.equals("red;green;red")) { //$NON-NLS-1$ 206 setRegion(IALA_B); 207 setColour(RED_GREEN_RED); 208 } else { 209 if (getRegion() == IALA_A) 210 setColour(GREEN_RED_GREEN); 211 else 212 setColour(RED_GREEN_RED); 213 } 214 } 215 216 if (keys.containsKey("seamark:buoy_lateral:shape")) { //$NON-NLS-1$ 217 str = keys.get("seamark:buoy_lateral:shape"); //$NON-NLS-1$ 218 219 switch (getBuoyIndex()) { 220 case PORT_HAND: 221 if (str.equals("can")) //$NON-NLS-1$ 222 setStyleIndex(LAT_CAN); 223 else if (str.equals("pillar")) //$NON-NLS-1$ 224 setStyleIndex(LAT_PILLAR); 225 else if (str.equals("spar")) //$NON-NLS-1$ 226 setStyleIndex(LAT_SPAR); 227 break; 228 229 case PREF_PORT_HAND: 230 if (str.equals("can")) //$NON-NLS-1$ 231 setStyleIndex(LAT_CAN); 232 else if (str.equals("pillar")) //$NON-NLS-1$ 233 setStyleIndex(LAT_PILLAR); 234 else if (str.equals("spar")) //$NON-NLS-1$ 235 setStyleIndex(LAT_SPAR); 236 break; 237 238 case STARBOARD_HAND: 239 if (str.equals("conical")) //$NON-NLS-1$ 240 setStyleIndex(LAT_CONE); 241 else if (str.equals("pillar")) //$NON-NLS-1$ 242 setStyleIndex(LAT_PILLAR); 243 else if (str.equals("spar")) //$NON-NLS-1$ 244 setStyleIndex(LAT_SPAR); 245 break; 246 247 case PREF_STARBOARD_HAND: 248 if (str.equals("conical")) //$NON-NLS-1$ 249 setStyleIndex(LAT_CONE); 250 else if (str.equals("pillar")) //$NON-NLS-1$ 251 setStyleIndex(LAT_PILLAR); 252 else if (str.equals("spar")) //$NON-NLS-1$ 253 setStyleIndex(LAT_SPAR); 254 break; 255 } 256 } else if (keys.containsKey("seamark:beacon_lateral:shape")) { //$NON-NLS-1$ 257 str = keys.get("seamark:beacon_lateral:shape"); //$NON-NLS-1$ 258 if (str.equals("tower")) //$NON-NLS-1$ 259 setStyleIndex(LAT_TOWER); 260 else if (str.equals("perch")) //$NON-NLS-1$ 261 setStyleIndex(LAT_PERCH); 262 else 263 setStyleIndex(LAT_BEACON); 264 } else if (keys.containsKey("seamark:type") //$NON-NLS-1$ 265 && (keys.get("seamark:type").equals("beacon_lateral"))) { //$NON-NLS-1$ //$NON-NLS-2$ 266 setStyleIndex(LAT_BEACON); 267 } else if (keys.containsKey("seamark:type") //$NON-NLS-1$ 268 && (keys.get("seamark:type").equals("light_float"))) { //$NON-NLS-1$ //$NON-NLS-2$ 269 setStyleIndex(LAT_FLOAT); 270 } 271 272 refreshStyles(); 273 refreshLights(); 274 setLightColour(); 275 parseLights(keys); 276 parseFogRadar(keys); 277 278 dlg.cbM01CatOfMark.setSelectedIndex(getBuoyIndex()); 279 dlg.cbM01StyleOfMark.setSelectedIndex(getStyleIndex()); 280 dlg.tfM01Name.setText(getName()); 281 dlg.cM01TopMark.setSelected(hasTopMark()); 282 } 283 284 public void refreshStyles() { 285 int type = getBuoyIndex(); 286 int style = getStyleIndex(); 287 288 dlg.cbM01StyleOfMark.removeAllItems(); 289 dlg.cbM01StyleOfMark.addItem(Messages.getString("SmpDialogAction.213")); //$NON-NLS-1$ 290 291 switch (type) { 292 case PORT_HAND: 293 dlg.cbM01StyleOfMark.addItem(Messages.getString("Buoy.02")); //$NON-NLS-1$ 294 dlg.cbM01StyleOfMark.addItem(Messages.getString("Buoy.01")); //$NON-NLS-1$ 295 dlg.cbM01StyleOfMark.addItem(Messages.getString("Buoy.04")); //$NON-NLS-1$ 296 dlg.cbM01StyleOfMark.addItem(Messages.getString("Buoy.05")); //$NON-NLS-1$ 297 dlg.cbM01StyleOfMark.addItem(Messages.getString("Buoy.06")); //$NON-NLS-1$ 298 dlg.cbM01StyleOfMark.addItem(Messages.getString("Buoy.07")); //$NON-NLS-1$ 299 dlg.cbM01StyleOfMark.addItem(Messages.getString("Buoy.10")); //$NON-NLS-1$ 300 break; 301 302 case STARBOARD_HAND: 303 dlg.cbM01StyleOfMark.addItem(Messages.getString("Buoy.03")); //$NON-NLS-1$ 304 dlg.cbM01StyleOfMark.addItem(Messages.getString("Buoy.01")); //$NON-NLS-1$ 305 dlg.cbM01StyleOfMark.addItem(Messages.getString("Buoy.04")); //$NON-NLS-1$ 306 dlg.cbM01StyleOfMark.addItem(Messages.getString("Buoy.05")); //$NON-NLS-1$ 307 dlg.cbM01StyleOfMark.addItem(Messages.getString("Buoy.06")); //$NON-NLS-1$ 308 dlg.cbM01StyleOfMark.addItem(Messages.getString("Buoy.07")); //$NON-NLS-1$ 309 dlg.cbM01StyleOfMark.addItem(Messages.getString("Buoy.10")); //$NON-NLS-1$ 310 break; 311 312 case PREF_PORT_HAND: 313 dlg.cbM01StyleOfMark.addItem(Messages.getString("Buoy.02")); //$NON-NLS-1$ 314 dlg.cbM01StyleOfMark.addItem(Messages.getString("Buoy.01")); //$NON-NLS-1$ 315 dlg.cbM01StyleOfMark.addItem(Messages.getString("Buoy.04")); //$NON-NLS-1$ 316 dlg.cbM01StyleOfMark.addItem(Messages.getString("Buoy.05")); //$NON-NLS-1$ 317 dlg.cbM01StyleOfMark.addItem(Messages.getString("Buoy.06")); //$NON-NLS-1$ 318 dlg.cbM01StyleOfMark.addItem(Messages.getString("Buoy.07")); //$NON-NLS-1$ 319 break; 320 321 case PREF_STARBOARD_HAND: 322 dlg.cbM01StyleOfMark.addItem(Messages.getString("Buoy.03")); //$NON-NLS-1$ 323 dlg.cbM01StyleOfMark.addItem(Messages.getString("Buoy.01")); //$NON-NLS-1$ 324 dlg.cbM01StyleOfMark.addItem(Messages.getString("Buoy.04")); //$NON-NLS-1$ 325 dlg.cbM01StyleOfMark.addItem(Messages.getString("Buoy.05")); //$NON-NLS-1$ 326 dlg.cbM01StyleOfMark.addItem(Messages.getString("Buoy.06")); //$NON-NLS-1$ 327 dlg.cbM01StyleOfMark.addItem(Messages.getString("Buoy.07")); //$NON-NLS-1$ 328 break; 329 330 default: 331 } 332 333 if (style >= dlg.cbM01StyleOfMark.getItemCount()) 334 style = 0; 335 setStyleIndex(style); 336 dlg.cbM01StyleOfMark.setSelectedIndex(style); 337 dlg.cbM01StyleOfMark.setVisible(true); 338 dlg.lM01StyleOfMark.setVisible(true); 339 } 340 341 public boolean isValid() { 342 return (getBuoyIndex() > 0) && (getStyleIndex() > 0); 343 } 344 345 public void paintSign() { 346 if (dlg.paintlock) 347 return; 348 super.paintSign(); 349 350 dlg.sM01StatusBar.setText(getErrMsg()); 351 352 if (isValid()) { 353 dlg.tfM01Name.setEnabled(true); 354 dlg.tfM01Name.setText(getName()); 355 356 int cat = getBuoyIndex(); 357 boolean region = getRegion(); 358 int style = getStyleIndex(); 359 360 if (style == LAT_PERCH) { 361 dlg.cM01TopMark.setVisible(false); 362 dlg.cM01TopMark.setSelected(false); 363 dlg.cM01Radar.setVisible(false); 364 dlg.cM01Racon.setVisible(false); 365 dlg.cM01Fog.setVisible(false); 366 dlg.cM01Fired.setVisible(false); 367 dlg.cM01Fired.setSelected(false); 368 } else { 369 dlg.cM01TopMark.setEnabled(true); 370 dlg.cM01TopMark.setVisible(true); 371 dlg.cM01Radar.setVisible(true); 372 dlg.cM01Racon.setVisible(true); 373 dlg.cM01Fog.setVisible(true); 374 dlg.cM01Fired.setVisible(true); 375 dlg.cM01Fired.setEnabled(true); 376 dlg.cM01TopMark.setEnabled(true); 377 } 378 dlg.cbM01Colour.setVisible(false); 379 dlg.lM01Colour.setVisible(false); 380 dlg.rbM01Fired1.setVisible(false); 381 dlg.rbM01FiredN.setVisible(false); 382 dlg.lM01Height.setVisible(false); 383 dlg.tfM01Height.setVisible(false); 384 dlg.lM01Range.setVisible(false); 385 dlg.tfM01Range.setVisible(false); 386 387 if (isFired()) { 388 switch (style) { 389 case LAT_BEACON: 390 case LAT_TOWER: 391 dlg.rbM01Fired1.setVisible(true); 392 dlg.rbM01FiredN.setVisible(true); 393 dlg.lM01Height.setVisible(true); 394 dlg.tfM01Height.setVisible(true); 395 dlg.lM01Range.setVisible(true); 396 dlg.tfM01Range.setVisible(true); 397 break; 398 case LAT_FLOAT: 399 dlg.lM01Height.setVisible(true); 400 dlg.tfM01Height.setVisible(true); 401 dlg.lM01Range.setVisible(true); 402 dlg.tfM01Range.setVisible(true); 403 break; 404 default: 405 } 406 } 407 String image = "/images/Lateral"; //$NON-NLS-1$ 408 409 switch (getBuoyIndex()) { 410 case PORT_HAND: 411 if (region == IALA_A) 412 switch (style) { 413 case LAT_CAN: 414 image += "_Can_Red"; //$NON-NLS-1$ 415 break; 416 case LAT_PILLAR: 417 image += "_Pillar_Red"; //$NON-NLS-1$ 418 break; 419 case LAT_SPAR: 420 image += "_Spar_Red"; //$NON-NLS-1$ 421 break; 422 case LAT_BEACON: 423 image += "_Beacon_Red"; //$NON-NLS-1$ 424 break; 425 case LAT_TOWER: 426 image += "_Tower_Red"; //$NON-NLS-1$ 427 break; 428 case LAT_FLOAT: 429 image += "_Float_Red"; //$NON-NLS-1$ 430 break; 431 case LAT_PERCH: 432 image += "_Perch_Port"; //$NON-NLS-1$ 433 break; 434 default: 435 } 436 else 437 switch (style) { 438 case LAT_CAN: 439 image += "_Can_Green"; //$NON-NLS-1$ 440 break; 441 case LAT_PILLAR: 442 image += "_Pillar_Green"; //$NON-NLS-1$ 443 break; 444 case LAT_SPAR: 445 image += "_Spar_Green"; //$NON-NLS-1$ 446 break; 447 case LAT_BEACON: 448 image += "_Beacon_Green"; //$NON-NLS-1$ 449 break; 450 case LAT_TOWER: 451 image += "_Tower_Green"; //$NON-NLS-1$ 452 break; 453 case LAT_FLOAT: 454 image += "_Float_Green"; //$NON-NLS-1$ 455 break; 456 case LAT_PERCH: 457 image += "_Perch_Port"; //$NON-NLS-1$ 458 break; 459 default: 460 } 461 break; 462 463 case STARBOARD_HAND: 464 if (region == IALA_A) 465 switch (style) { 466 case LAT_CONE: 467 image += "_Cone_Green"; //$NON-NLS-1$ 468 break; 469 case LAT_PILLAR: 470 image += "_Pillar_Green"; //$NON-NLS-1$ 471 break; 472 case LAT_SPAR: 473 image += "_Spar_Green"; //$NON-NLS-1$ 474 break; 475 case LAT_BEACON: 476 image += "_Beacon_Green"; //$NON-NLS-1$ 477 break; 478 case LAT_TOWER: 479 image += "_Tower_Green"; //$NON-NLS-1$ 480 break; 481 case LAT_FLOAT: 482 image += "_Float_Green"; //$NON-NLS-1$ 483 break; 484 case LAT_PERCH: 485 image += "_Perch_Starboard"; //$NON-NLS-1$ 486 break; 487 default: 488 } 489 else 490 switch (style) { 491 case LAT_CONE: 492 image += "_Cone_Red"; //$NON-NLS-1$ 493 break; 494 case LAT_PILLAR: 495 image += "_Pillar_Red"; //$NON-NLS-1$ 496 break; 497 case LAT_SPAR: 498 image += "_Spar_Red"; //$NON-NLS-1$ 499 break; 500 case LAT_BEACON: 501 image += "_Beacon_Red"; //$NON-NLS-1$ 502 break; 503 case LAT_TOWER: 504 image += "_Tower_Red"; //$NON-NLS-1$ 505 break; 506 case LAT_FLOAT: 507 image += "_Float_Red"; //$NON-NLS-1$ 508 break; 509 case LAT_PERCH: 510 image += "_Perch_Starboard"; //$NON-NLS-1$ 511 break; 512 default: 513 } 514 break; 515 516 case PREF_PORT_HAND: 517 if (region == IALA_A) 518 switch (style) { 519 case LAT_CAN: 520 image += "_Can_Red_Green_Red"; //$NON-NLS-1$ 521 break; 522 case LAT_PILLAR: 523 image += "_Pillar_Red_Green_Red"; //$NON-NLS-1$ 524 break; 525 case LAT_SPAR: 526 image += "_Spar_Red_Green_Red"; //$NON-NLS-1$ 527 break; 528 case LAT_BEACON: 529 image += "_Beacon_Red_Green_Red"; //$NON-NLS-1$ 530 break; 531 case LAT_TOWER: 532 image += "_Tower_Red_Green_Red"; //$NON-NLS-1$ 533 break; 534 case LAT_FLOAT: 535 image += "_Float_Red_Green_Red"; //$NON-NLS-1$ 536 break; 537 default: 538 } 539 else 540 switch (style) { 541 case LAT_CAN: 542 image += "_Can_Green_Red_Green"; //$NON-NLS-1$ 543 break; 544 case LAT_PILLAR: 545 image += "_Pillar_Green_Red_Green"; //$NON-NLS-1$ 546 break; 547 case LAT_SPAR: 548 image += "_Spar_Green_Red_Green"; //$NON-NLS-1$ 549 break; 550 case LAT_BEACON: 551 image += "_Beacon_Green_Red_Green"; //$NON-NLS-1$ 552 break; 553 case LAT_TOWER: 554 image += "_Tower_Green_Red_Green"; //$NON-NLS-1$ 555 break; 556 case LAT_FLOAT: 557 image += "_Float_Green_Red_Green"; //$NON-NLS-1$ 558 break; 559 default: 560 } 561 break; 562 563 case PREF_STARBOARD_HAND: 564 if (region == IALA_A) 565 switch (style) { 566 case LAT_CONE: 567 image += "_Cone_Green_Red_Green"; //$NON-NLS-1$ 568 break; 569 case LAT_PILLAR: 570 image += "_Pillar_Green_Red_Green"; //$NON-NLS-1$ 571 break; 572 case LAT_SPAR: 573 image += "_Spar_Green_Red_Green"; //$NON-NLS-1$ 574 break; 575 case LAT_BEACON: 576 image += "_Beacon_Green_Red_Green"; //$NON-NLS-1$ 577 break; 578 case LAT_TOWER: 579 image += "_Tower_Green_Red_Green"; //$NON-NLS-1$ 580 break; 581 case LAT_FLOAT: 582 image += "_Float_Green_Red_Green"; //$NON-NLS-1$ 583 break; 584 default: 585 } 586 else 587 switch (style) { 588 case LAT_CONE: 589 image += "_Cone_Red_Green_Red"; //$NON-NLS-1$ 590 break; 591 case LAT_PILLAR: 592 image += "_Pillar_Red_Green_Red"; //$NON-NLS-1$ 593 break; 594 case LAT_SPAR: 595 image += "_Spar_Red_Green_Red"; //$NON-NLS-1$ 596 break; 597 case LAT_BEACON: 598 image += "_Beacon_Red_Green_Red"; //$NON-NLS-1$ 599 break; 600 case LAT_TOWER: 601 image += "_Tower_Red_Green_Red"; //$NON-NLS-1$ 602 break; 603 case LAT_FLOAT: 604 image += "_Float_Red_Green_Red"; //$NON-NLS-1$ 605 break; 606 default: 607 } 608 break; 609 610 default: 611 } 612 613 if (!image.equals("/images/Lateral")) { //$NON-NLS-1$ 614 615 if (hasTopMark()) { 616 if (cat == PORT_HAND || cat == PREF_PORT_HAND) 617 image += "_Can"; //$NON-NLS-1$ 618 else 619 image += "_Cone"; //$NON-NLS-1$ 620 } 621 image += ".png"; //$NON-NLS-1$ 622 dlg.lM01Icon.setIcon(new ImageIcon(getClass().getResource(image))); 623 624 if (hasRadar()) { 625 dlg.lM03Icon.setIcon(new ImageIcon(getClass().getResource( 626 "/images/Radar_Reflector.png"))); //$NON-NLS-1$ 627 } 628 629 } else 630 dlg.lM01Icon.setIcon(null); 631 } 632 } 633 634 public void saveSign() { 635 Node node = getNode(); 636 637 if (node == null) { 638 return; 639 } 640 641 int cat = getBuoyIndex(); 642 String shape = ""; //$NON-NLS-1$ 643 String colour = ""; //$NON-NLS-1$ 644 645 switch (cat) { 646 647 case PORT_HAND: 648 switch (getStyleIndex()) { 649 case LAT_CAN: 650 super.saveSign("buoy_lateral"); //$NON-NLS-1$ 651 Main.main.undoRedo.add(new ChangePropertyCommand(node, 652 "seamark:buoy_lateral:shape", "can")); //$NON-NLS-1$ //$NON-NLS-2$ 653 break; 654 case LAT_PILLAR: 655 super.saveSign("buoy_lateral"); //$NON-NLS-1$ 656 Main.main.undoRedo.add(new ChangePropertyCommand(node, 657 "seamark:buoy_lateral:shape", "pillar")); //$NON-NLS-1$ //$NON-NLS-2$ 658 break; 659 case LAT_SPAR: 660 super.saveSign("buoy_lateral"); //$NON-NLS-1$ 661 Main.main.undoRedo.add(new ChangePropertyCommand(node, 662 "seamark:buoy_lateral:shape", "spar")); //$NON-NLS-1$ //$NON-NLS-2$ 663 break; 664 case LAT_BEACON: 665 super.saveSign("beacon_lateral"); //$NON-NLS-1$ 666 break; 667 case LAT_TOWER: 668 super.saveSign("beacon_lateral"); //$NON-NLS-1$ 669 Main.main.undoRedo.add(new ChangePropertyCommand(node, 670 "seamark:beacon_lateral:shape", "tower")); //$NON-NLS-1$ //$NON-NLS-2$ 671 break; 672 case LAT_FLOAT: 673 super.saveSign("light_float"); //$NON-NLS-1$ 674 break; 675 case LAT_PERCH: 676 super.saveSign("beacon_lateral"); //$NON-NLS-1$ 677 Main.main.undoRedo.add(new ChangePropertyCommand(node, 678 "seamark:beacon_lateral:shape", "perch")); //$NON-NLS-1$ //$NON-NLS-2$ 679 break; 680 default: 681 } 682 switch (getStyleIndex()) { 683 case LAT_CAN: 684 case LAT_PILLAR: 685 case LAT_SPAR: 686 Main.main.undoRedo.add(new ChangePropertyCommand(node, 687 "seamark:buoy_lateral:category", "port")); //$NON-NLS-1$ //$NON-NLS-2$ 688 if (getRegion() == IALA_A) { 689 Main.main.undoRedo.add(new ChangePropertyCommand(node, 690 "seamark:buoy_lateral:colour", "red")); //$NON-NLS-1$ //$NON-NLS-2$ 691 colour = "red"; //$NON-NLS-1$ 692 } else { 693 Main.main.undoRedo.add(new ChangePropertyCommand(node, 694 "seamark:buoy_lateral:colour", "green")); //$NON-NLS-1$ //$NON-NLS-2$ 695 colour = "green"; //$NON-NLS-1$ 696 } 697 break; 698 case LAT_PERCH: 699 Main.main.undoRedo.add(new ChangePropertyCommand(node, 700 "seamark:beacon_lateral:category", "port")); //$NON-NLS-1$ //$NON-NLS-2$ 701 break; 702 case LAT_BEACON: 703 case LAT_TOWER: 704 Main.main.undoRedo.add(new ChangePropertyCommand(node, 705 "seamark:beacon_lateral:category", "port")); //$NON-NLS-1$ //$NON-NLS-2$ 706 if (getRegion() == IALA_A) { 707 Main.main.undoRedo.add(new ChangePropertyCommand(node, 708 "seamark:beacon_lateral:colour", "red")); //$NON-NLS-1$ //$NON-NLS-2$ 709 colour = "red"; //$NON-NLS-1$ 710 } else { 711 Main.main.undoRedo.add(new ChangePropertyCommand(node, 712 "seamark:beacon_lateral:colour", "green")); //$NON-NLS-1$ //$NON-NLS-2$ 713 colour = "green"; //$NON-NLS-1$ 714 } 715 break; 716 case LAT_FLOAT: 717 if (getRegion() == IALA_A) { 718 Main.main.undoRedo.add(new ChangePropertyCommand(node, 719 "seamark:light_float:colour", "red")); //$NON-NLS-1$ //$NON-NLS-2$ 720 colour = "red"; //$NON-NLS-1$ 721 } else { 722 Main.main.undoRedo.add(new ChangePropertyCommand(node, 723 "seamark:light_float:colour", "green")); //$NON-NLS-1$ //$NON-NLS-2$ 724 colour = "green"; //$NON-NLS-1$ 725 } 726 break; 727 } 728 shape = "cylinder"; //$NON-NLS-1$ 729 break; 730 731 case PREF_PORT_HAND: 732 switch (getStyleIndex()) { 733 case LAT_CAN: 734 super.saveSign("buoy_lateral"); //$NON-NLS-1$ 735 Main.main.undoRedo.add(new ChangePropertyCommand(node, 736 "seamark:buoy_lateral:shape", "can")); //$NON-NLS-1$ //$NON-NLS-2$ 737 break; 738 case LAT_PILLAR: 739 super.saveSign("buoy_lateral"); //$NON-NLS-1$ 740 Main.main.undoRedo.add(new ChangePropertyCommand(node, 741 "seamark:buoy_lateral:shape", "pillar")); //$NON-NLS-1$ //$NON-NLS-2$ 742 break; 743 case LAT_SPAR: 744 super.saveSign("buoy_lateral"); //$NON-NLS-1$ 745 Main.main.undoRedo.add(new ChangePropertyCommand(node, 746 "seamark:buoy_lateral:shape", "spar")); //$NON-NLS-1$ //$NON-NLS-2$ 747 break; 748 case LAT_BEACON: 749 super.saveSign("beacon_lateral"); //$NON-NLS-1$ 750 break; 751 case LAT_TOWER: 752 super.saveSign("beacon_lateral"); //$NON-NLS-1$ 753 Main.main.undoRedo.add(new ChangePropertyCommand(node, 754 "seamark:beacon_lateral:shape", "tower")); //$NON-NLS-1$ //$NON-NLS-2$ 755 break; 756 case LAT_FLOAT: 757 super.saveSign("light_float"); //$NON-NLS-1$ 758 break; 759 default: 760 } 761 switch (getStyleIndex()) { 762 case LAT_CAN: 763 case LAT_PILLAR: 764 case LAT_SPAR: 765 Main.main.undoRedo.add(new ChangePropertyCommand(node, 766 "seamark:buoy_lateral:category", "preferred_channel_port")); //$NON-NLS-1$ //$NON-NLS-2$ 767 Main.main.undoRedo.add(new ChangePropertyCommand(node, 768 "seamark:buoy_lateral:colour_pattern", "horizontal stripes")); //$NON-NLS-1$ //$NON-NLS-2$ 769 if (getRegion() == IALA_A) { 770 Main.main.undoRedo.add(new ChangePropertyCommand(node, 771 "seamark:buoy_lateral:colour", "red;green;red")); //$NON-NLS-1$ //$NON-NLS-2$ 772 colour = "red"; //$NON-NLS-1$ 773 } else { 774 Main.main.undoRedo.add(new ChangePropertyCommand(node, 775 "seamark:buoy_lateral:colour", "green;red;green")); //$NON-NLS-1$ //$NON-NLS-2$ 776 colour = "green"; //$NON-NLS-1$ 777 } 778 break; 779 case LAT_BEACON: 780 case LAT_TOWER: 781 Main.main.undoRedo.add(new ChangePropertyCommand(node, 782 "seamark:beacon_lateral:category", "preferred_channel_port")); //$NON-NLS-1$ //$NON-NLS-2$ 783 Main.main.undoRedo.add(new ChangePropertyCommand(node, 784 "seamark:beacon_lateral:colour_pattern", "horizontal stripes")); //$NON-NLS-1$ //$NON-NLS-2$ 785 if (getRegion() == IALA_A) { 786 Main.main.undoRedo.add(new ChangePropertyCommand(node, 787 "seamark:beacon_lateral:colour", "red;green;red")); //$NON-NLS-1$ //$NON-NLS-2$ 788 colour = "red"; //$NON-NLS-1$ 789 } else { 790 Main.main.undoRedo.add(new ChangePropertyCommand(node, 791 "seamark:beacon_lateral:colour", "green;red;green")); //$NON-NLS-1$ //$NON-NLS-2$ 792 colour = "green"; //$NON-NLS-1$ 793 } 794 break; 795 case LAT_FLOAT: 796 Main.main.undoRedo.add(new ChangePropertyCommand(node, 797 "seamark:light_float:colour_pattern", "horizontal stripes")); //$NON-NLS-1$ //$NON-NLS-2$ 798 if (getRegion() == IALA_A) { 799 Main.main.undoRedo.add(new ChangePropertyCommand(node, 800 "seamark:light_float:colour", "red;green;red")); //$NON-NLS-1$ //$NON-NLS-2$ 801 colour = "red"; //$NON-NLS-1$ 802 } else { 803 Main.main.undoRedo.add(new ChangePropertyCommand(node, 804 "seamark:light_float:colour", "green;red;green")); //$NON-NLS-1$ //$NON-NLS-2$ 805 colour = "green"; //$NON-NLS-1$ 806 } 807 break; 808 } 809 shape = "cylinder"; //$NON-NLS-1$ 810 break; 811 812 case STARBOARD_HAND: 813 switch (getStyleIndex()) { 814 case LAT_CONE: 815 super.saveSign("buoy_lateral"); //$NON-NLS-1$ 816 Main.main.undoRedo.add(new ChangePropertyCommand(node, 817 "seamark:buoy_lateral:shape", "conical")); //$NON-NLS-1$ //$NON-NLS-2$ 818 break; 819 case LAT_PILLAR: 820 super.saveSign("buoy_lateral"); //$NON-NLS-1$ 821 Main.main.undoRedo.add(new ChangePropertyCommand(node, 822 "seamark:buoy_lateral:shape", "pillar")); //$NON-NLS-1$ //$NON-NLS-2$ 823 break; 824 case LAT_SPAR: 825 super.saveSign("buoy_lateral"); //$NON-NLS-1$ 826 Main.main.undoRedo.add(new ChangePropertyCommand(node, 827 "seamark:buoy_lateral:shape", "spar")); //$NON-NLS-1$ //$NON-NLS-2$ 828 break; 829 case LAT_BEACON: 830 super.saveSign("beacon_lateral"); //$NON-NLS-1$ 831 Main.main.undoRedo.add(new ChangePropertyCommand(node, 832 "seamark:beacon_lateral:shape", "stake")); //$NON-NLS-1$ //$NON-NLS-2$ 833 break; 834 case LAT_TOWER: 835 super.saveSign("beacon_lateral"); //$NON-NLS-1$ 836 Main.main.undoRedo.add(new ChangePropertyCommand(node, 837 "seamark:beacon_lateral:shape", "tower")); //$NON-NLS-1$ //$NON-NLS-2$ 838 break; 839 case LAT_FLOAT: 840 super.saveSign("light_float"); //$NON-NLS-1$ 841 break; 842 case LAT_PERCH: 843 super.saveSign("beacon_lateral"); //$NON-NLS-1$ 844 Main.main.undoRedo.add(new ChangePropertyCommand(node, 845 "seamark:beacon_lateral:shape", "perch")); //$NON-NLS-1$ //$NON-NLS-2$ 846 break; 847 default: 848 } 849 switch (getStyleIndex()) { 850 case LAT_CAN: 851 case LAT_PILLAR: 852 case LAT_SPAR: 853 Main.main.undoRedo.add(new ChangePropertyCommand(node, 854 "seamark:buoy_lateral:category", "starboard")); //$NON-NLS-1$ //$NON-NLS-2$ 855 if (getRegion() == IALA_A) { 856 Main.main.undoRedo.add(new ChangePropertyCommand(node, 857 "seamark:buoy_lateral:colour", "green")); //$NON-NLS-1$ //$NON-NLS-2$ 858 colour = "green"; //$NON-NLS-1$ 859 } else { 860 Main.main.undoRedo.add(new ChangePropertyCommand(node, 861 "seamark:buoy_lateral:colour", "red")); //$NON-NLS-1$ //$NON-NLS-2$ 862 colour = "red"; //$NON-NLS-1$ 863 } 864 break; 865 case LAT_BEACON: 866 case LAT_TOWER: 867 Main.main.undoRedo.add(new ChangePropertyCommand(node, 868 "seamark:beacon_lateral:category", "starboard")); //$NON-NLS-1$ //$NON-NLS-2$ 869 if (getRegion() == IALA_A) { 870 Main.main.undoRedo.add(new ChangePropertyCommand(node, 871 "seamark:beacon_lateral:colour", "green")); //$NON-NLS-1$ //$NON-NLS-2$ 872 colour = "green"; //$NON-NLS-1$ 873 } else { 874 Main.main.undoRedo.add(new ChangePropertyCommand(node, 875 "seamark:beacon_lateral:colour", "red")); //$NON-NLS-1$ //$NON-NLS-2$ 876 colour = "red"; //$NON-NLS-1$ 877 } 878 break; 879 case LAT_FLOAT: 880 if (getRegion() == IALA_A) { 881 Main.main.undoRedo.add(new ChangePropertyCommand(node, 882 "seamark:light_float:colour", "green")); //$NON-NLS-1$ //$NON-NLS-2$ 883 colour = "green"; //$NON-NLS-1$ 884 } else { 885 Main.main.undoRedo.add(new ChangePropertyCommand(node, 886 "seamark:light_float:colour", "red")); //$NON-NLS-1$ //$NON-NLS-2$ 887 colour = "red"; //$NON-NLS-1$ 888 } 889 break; 890 case LAT_PERCH: 891 Main.main.undoRedo.add(new ChangePropertyCommand(node, 892 "seamark:beacon_lateral:category", "starboard")); //$NON-NLS-1$ //$NON-NLS-2$ 893 break; 894 } 895 shape = "cone, point up"; //$NON-NLS-1$ 896 break; 897 898 case PREF_STARBOARD_HAND: 899 switch (getStyleIndex()) { 900 case LAT_CONE: 901 super.saveSign("buoy_lateral"); //$NON-NLS-1$ 902 Main.main.undoRedo.add(new ChangePropertyCommand(node, 903 "seamark:buoy_lateral:shape", "conical")); //$NON-NLS-1$ //$NON-NLS-2$ 904 break; 905 case LAT_PILLAR: 906 super.saveSign("buoy_lateral"); //$NON-NLS-1$ 907 Main.main.undoRedo.add(new ChangePropertyCommand(node, 908 "seamark:buoy_lateral:shape", "pillar")); //$NON-NLS-1$ //$NON-NLS-2$ 909 break; 910 case LAT_SPAR: 911 super.saveSign("buoy_lateral"); //$NON-NLS-1$ 912 Main.main.undoRedo.add(new ChangePropertyCommand(node, 913 "seamark:buoy_lateral:shape", "spar")); //$NON-NLS-1$ //$NON-NLS-2$ 914 break; 915 case LAT_BEACON: 916 super.saveSign("beacon_lateral"); //$NON-NLS-1$ 917 Main.main.undoRedo.add(new ChangePropertyCommand(node, 918 "seamark:beacon_lateral:shape", "stake")); //$NON-NLS-1$ //$NON-NLS-2$ 919 break; 920 case LAT_TOWER: 921 super.saveSign("beacon_lateral"); //$NON-NLS-1$ 922 Main.main.undoRedo.add(new ChangePropertyCommand(node, 923 "seamark:beacon_lateral:shape", "tower")); //$NON-NLS-1$ //$NON-NLS-2$ 924 break; 925 case LAT_FLOAT: 926 super.saveSign("light_float"); //$NON-NLS-1$ 927 break; 928 default: 929 } 930 switch (getStyleIndex()) { 931 case LAT_CAN: 932 case LAT_PILLAR: 933 case LAT_SPAR: 934 Main.main.undoRedo.add(new ChangePropertyCommand(node, 935 "seamark:buoy_lateral:category", "preferred_channel_starboard")); //$NON-NLS-1$ //$NON-NLS-2$ 936 Main.main.undoRedo.add(new ChangePropertyCommand(node, 937 "seamark:buoy_lateral:colour_pattern", "horizontal stripes")); //$NON-NLS-1$ //$NON-NLS-2$ 938 if (getRegion() == IALA_A) { 939 Main.main.undoRedo.add(new ChangePropertyCommand(node, 940 "seamark:buoy_lateral:colour", "green;red;green")); //$NON-NLS-1$ //$NON-NLS-2$ 941 colour = "green"; //$NON-NLS-1$ 942 } else { 943 Main.main.undoRedo.add(new ChangePropertyCommand(node, 944 "seamark:buoy_lateral:colour", "red;green;red")); //$NON-NLS-1$ //$NON-NLS-2$ 945 colour = "red"; //$NON-NLS-1$ 946 } 947 break; 948 case LAT_BEACON: 949 case LAT_TOWER: 950 Main.main.undoRedo.add(new ChangePropertyCommand(node, 951 "seamark:beacon_lateral:category", "preferred_channel_starboard")); //$NON-NLS-1$ //$NON-NLS-2$ 952 Main.main.undoRedo.add(new ChangePropertyCommand(node, 953 "seamark:beacon_lateral:colour_pattern", "horizontal stripes")); //$NON-NLS-1$ //$NON-NLS-2$ 954 if (getRegion() == IALA_A) { 955 Main.main.undoRedo.add(new ChangePropertyCommand(node, 956 "seamark:beacon_lateral:colour", "green;red;green")); //$NON-NLS-1$ //$NON-NLS-2$ 957 colour = "green"; //$NON-NLS-1$ 958 } else { 959 Main.main.undoRedo.add(new ChangePropertyCommand(node, 960 "seamark:beacon_lateral:colour", "red;green;red")); //$NON-NLS-1$ //$NON-NLS-2$ 961 colour = "red"; //$NON-NLS-1$ 962 } 963 break; 964 case LAT_FLOAT: 965 Main.main.undoRedo.add(new ChangePropertyCommand(node, 966 "seamark:light_float:colour_pattern", "horizontal stripes")); //$NON-NLS-1$ //$NON-NLS-2$ 967 if (getRegion() == IALA_A) { 968 Main.main.undoRedo.add(new ChangePropertyCommand(node, 969 "seamark:light_float:colour", "green;red;green")); //$NON-NLS-1$ //$NON-NLS-2$ 970 colour = "green"; //$NON-NLS-1$ 971 } else { 972 Main.main.undoRedo.add(new ChangePropertyCommand(node, 973 "seamark:light_float:colour", "red;green;red")); //$NON-NLS-1$ //$NON-NLS-2$ 974 colour = "red"; //$NON-NLS-1$ 975 } 976 break; 977 } 978 shape = "cone, point up"; //$NON-NLS-1$ 979 break; 980 981 default: 982 } 983 saveTopMarkData(shape, colour); 984 saveLightData(); 985 saveRadarFogData(); 986 987 Main.pref.put("tomsplugin.IALA", getRegion() ? "B" : "A"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 988 } 989 990 public void setLightColour() { 991 if (getRegion() == IALA_A) { 992 if (getBuoyIndex() == PORT_HAND || getBuoyIndex() == PREF_PORT_HAND) 993 super.setLightColour("R"); //$NON-NLS-1$ 994 else 995 super.setLightColour("G"); //$NON-NLS-1$ 996 } else { 997 if (getBuoyIndex() == PORT_HAND || getBuoyIndex() == PREF_PORT_HAND) 998 super.setLightColour("G"); //$NON-NLS-1$ 999 else 1000 super.setLightColour("R"); //$NON-NLS-1$ 1001 } 1002 } 1003 1004 public void setLightColour(String str) { 1005 int cat = getBuoyIndex(); 1006 1007 if (str == null) { 1008 return; 1009 } 1010 1011 switch (cat) { 1012 case PORT_HAND: 1013 case PREF_PORT_HAND: 1014 if (getRegion() == IALA_A) { 1015 if (str.equals("red")) { //$NON-NLS-1$ 1016 setFired(true); 1017 super.setLightColour("R"); //$NON-NLS-1$ 1018 } else { 1019 super.setLightColour(""); //$NON-NLS-1$ 1020 } 1021 } else { 1022 if (str.equals("green")) { //$NON-NLS-1$ 1023 setFired(true); 1024 super.setLightColour("G"); //$NON-NLS-1$ 1025 } else { 1026 super.setLightColour(""); //$NON-NLS-1$ 1027 } 1028 } 1029 break; 1030 1031 case STARBOARD_HAND: 1032 case PREF_STARBOARD_HAND: 1033 if (getRegion() == IALA_A) { 1034 if (str.equals("green")) { //$NON-NLS-1$ 1035 setFired(true); 1036 super.setLightColour("G"); //$NON-NLS-1$ 1037 } else { 1038 super.setLightColour(""); //$NON-NLS-1$ 1039 } 1040 } else { 1041 if (str.equals("red")) { //$NON-NLS-1$ 1042 setFired(true); 1043 super.setLightColour("R"); //$NON-NLS-1$ 1044 } else { 1045 super.setLightColour(""); //$NON-NLS-1$ 1046 } 1047 } 1048 break; 1049 default: 1050 } 1051 } 1052 1052 1053 1053 } -
applications/editors/josm/plugins/toms/src/toms/seamarks/buoys/BuoyNota.java
r23174 r23193 17 17 18 18 public class BuoyNota extends Buoy { 19 20 19 public BuoyNota(SmpDialogAction dia, Node node) { 20 super(dia); 21 21 22 23 24 22 Map<String, String> keys; 23 keys = node.getKeys(); 24 setNode(node); 25 25 26 26 resetMask(); 27 27 28 28 dlg.cbM01TypeOfMark.setSelectedIndex(LIGHT); 29 29 30 31 32 30 dlg.cbM01CatOfMark.setEnabled(true); 31 dlg.cbM01CatOfMark.setVisible(true); 32 dlg.lM01CatOfMark.setVisible(true); 33 33 34 35 36 37 38 39 34 dlg.cbM01CatOfMark.removeAllItems(); 35 dlg.cbM01CatOfMark.addItem(Messages.getString("SmpDialogAction.157")); //$NON-NLS-1$ 36 dlg.cbM01CatOfMark.addItem(Messages.getString("SmpDialogAction.206")); //$NON-NLS-1$ 37 dlg.cbM01CatOfMark.addItem(Messages.getString("SmpDialogAction.207")); //$NON-NLS-1$ 38 dlg.cbM01CatOfMark.addItem(Messages.getString("SmpDialogAction.208")); //$NON-NLS-1$ 39 dlg.cbM01CatOfMark.addItem(Messages.getString("SmpDialogAction.209")); //$NON-NLS-1$ 40 40 41 41 setRegion(Main.pref.get("tomsplugin.IALA").equals("B")); //$NON-NLS-1$ //$NON-NLS-2$ 42 42 43 44 43 if (keys.containsKey("name")) //$NON-NLS-1$ 44 setName(keys.get("name")); //$NON-NLS-1$ 45 45 46 47 46 if (keys.containsKey("seamark:name")) //$NON-NLS-1$ 47 setName(keys.get("seamark:name")); //$NON-NLS-1$ 48 48 49 50 51 52 53 54 55 56 49 if (keys.containsKey("seamark:landmark:name")) //$NON-NLS-1$ 50 setName(keys.get("seamark:landmark:name")); //$NON-NLS-1$ 51 else if (keys.containsKey("seamark:light_major:name")) //$NON-NLS-1$ 52 setName(keys.get("seamark:light_major:name")); //$NON-NLS-1$ 53 else if (keys.containsKey("seamark:light_minor:name")) //$NON-NLS-1$ 54 setName(keys.get("seamark:light_minor:name")); //$NON-NLS-1$ 55 else if (keys.containsKey("seamark:light_vessel:name")) //$NON-NLS-1$ 56 setName(keys.get("seamark:light_vessel:name")); //$NON-NLS-1$ 57 57 58 59 60 61 62 63 64 65 66 67 68 58 if (keys.containsKey("seamark:type")) { //$NON-NLS-1$ 59 String type = keys.get("seamark:type"); //$NON-NLS-1$ 60 if (type.equals("landmark")) 61 setBuoyIndex(LIGHT_HOUSE); 62 else if (type.equals("light_major")) 63 setBuoyIndex(LIGHT_MAJOR); 64 else if (type.equals("light_minor")) 65 setBuoyIndex(LIGHT_MINOR); 66 else if (type.equals("light_vessel")) 67 setBuoyIndex(LIGHT_VESSEL); 68 } 69 69 70 71 72 73 74 70 refreshLights(); 71 parseLights(keys); 72 parseFogRadar(keys); 73 setTopMark(false); 74 setFired(true); 75 75 76 77 78 79 80 76 dlg.cbM01CatOfMark.setSelectedIndex(getBuoyIndex()); 77 dlg.tfM01Name.setText(getName()); 78 dlg.cM01Fired.setEnabled(false); 79 dlg.cM01Fired.setSelected(true); 80 } 81 81 82 83 84 82 public boolean isValid() { 83 return (getBuoyIndex() > 0); 84 } 85 85 86 87 88 89 86 public void paintSign() { 87 if (dlg.paintlock) 88 return; 89 super.paintSign(); 90 90 91 91 dlg.sM01StatusBar.setText(getErrMsg()); 92 92 93 94 95 96 93 if (isValid()) { 94 dlg.cM01Radar.setVisible(true); 95 dlg.cM01Racon.setVisible(true); 96 dlg.cM01Fog.setVisible(true); 97 97 98 99 100 101 102 103 98 dlg.rbM01Fired1.setVisible(true); 99 dlg.rbM01FiredN.setVisible(true); 100 dlg.lM01Height.setVisible(true); 101 dlg.tfM01Height.setVisible(true); 102 dlg.lM01Range.setVisible(true); 103 dlg.tfM01Range.setVisible(true); 104 104 105 106 107 108 109 105 switch (getBuoyIndex()) { 106 case SeaMark.LIGHT_HOUSE: 107 dlg.lM01Icon.setIcon(new ImageIcon(getClass().getResource( 108 "/images/Light_House.png"))); //$NON-NLS-1$ 109 break; 110 110 111 112 113 114 111 case SeaMark.LIGHT_MAJOR: 112 dlg.lM01Icon.setIcon(new ImageIcon(getClass().getResource( 113 "/images/Light_Major.png"))); //$NON-NLS-1$ 114 break; 115 115 116 117 118 119 116 case SeaMark.LIGHT_MINOR: 117 dlg.lM01Icon.setIcon(new ImageIcon(getClass().getResource( 118 "/images/Light_Minor.png"))); //$NON-NLS-1$ 119 break; 120 120 121 122 123 124 121 case SeaMark.LIGHT_VESSEL: 122 dlg.lM01Icon.setIcon(new ImageIcon(getClass().getResource( 123 "/images/Major_Float.png"))); //$NON-NLS-1$ 124 break; 125 125 126 127 128 129 126 default: 127 } 128 } 129 } 130 130 131 132 131 public void saveSign() { 132 Node node = getNode(); 133 133 134 135 136 134 if (node == null) { 135 return; 136 } 137 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 138 switch (getBuoyIndex()) { 139 case LIGHT_HOUSE: 140 super.saveSign("landmark"); //$NON-NLS-1$ 141 break; 142 case LIGHT_MAJOR: 143 super.saveSign("light_major"); //$NON-NLS-1$ 144 break; 145 case LIGHT_MINOR: 146 super.saveSign("light_minor"); //$NON-NLS-1$ 147 break; 148 case LIGHT_VESSEL: 149 super.saveSign("light_vessel"); //$NON-NLS-1$ 150 break; 151 default: 152 } 153 saveLightData(); //$NON-NLS-1$ 154 saveRadarFogData(); 155 } 156 156 157 158 157 public void setLightColour() { 158 } 159 159 160 160 } -
applications/editors/josm/plugins/toms/src/toms/seamarks/buoys/BuoySaw.java
r23179 r23193 17 17 18 18 public class BuoySaw extends Buoy { 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 19 public BuoySaw(SmpDialogAction dia, Node node) { 20 super(dia); 21 22 String str; 23 Map<String, String> keys; 24 keys = node.getKeys(); 25 setNode(node); 26 27 resetMask(); 28 29 dlg.cbM01TypeOfMark.setSelectedIndex(SAFE_WATER); 30 31 dlg.cbM01StyleOfMark.removeAllItems(); 32 dlg.cbM01StyleOfMark.addItem(Messages.getString("SmpDialogAction.212")); //$NON-NLS-1$ 33 dlg.cbM01StyleOfMark.addItem(Messages.getString("Buoy.01")); //$NON-NLS-1$ 34 dlg.cbM01StyleOfMark.addItem(Messages.getString("Buoy.04")); //$NON-NLS-1$ 35 dlg.cbM01StyleOfMark.addItem(Messages.getString("Buoy.08")); //$NON-NLS-1$ 36 dlg.cbM01StyleOfMark.addItem(Messages.getString("Buoy.05")); //$NON-NLS-1$ 37 dlg.cbM01StyleOfMark.addItem(Messages.getString("Buoy.07")); //$NON-NLS-1$ 38 dlg.cbM01StyleOfMark.setVisible(true); 39 dlg.lM01StyleOfMark.setVisible(true); 40 41 setBuoyIndex(SAFE_WATER); 42 setColour(SeaMark.RED_WHITE); 43 setLightColour("W"); //$NON-NLS-1$ 44 setRegion(Main.pref.get("tomsplugin.IALA").equals("B")); //$NON-NLS-1$ //$NON-NLS-2$ 45 46 if (keys.containsKey("name")) //$NON-NLS-1$ 47 setName(keys.get("name")); //$NON-NLS-1$ 48 49 if (keys.containsKey("seamark:name")) //$NON-NLS-1$ 50 setName(keys.get("seamark:name")); //$NON-NLS-1$ 51 52 if (keys.containsKey("seamark:buoy_safe_water:name")) //$NON-NLS-1$ 53 setName(keys.get("seamark:buoy_safe_water:name")); //$NON-NLS-1$ 54 else if (keys.containsKey("seamark:beacon_safe_water:name")) //$NON-NLS-1$ 55 setName(keys.get("seamark:beacon_safe_water:name")); //$NON-NLS-1$ 56 else if (keys.containsKey("seamark:light_float:name")) //$NON-NLS-1$ 57 setName(keys.get("seamark:light_float:name")); //$NON-NLS-1$ 58 59 if (keys.containsKey("seamark:buoy_safe_water:shape")) { //$NON-NLS-1$ 60 str = keys.get("seamark:buoy_safe_water:shape"); //$NON-NLS-1$ 61 62 if (str.equals("pillar")) //$NON-NLS-1$ 63 setStyleIndex(SAFE_PILLAR); 64 else if (str.equals("spar")) //$NON-NLS-1$ 65 setStyleIndex(SAFE_SPAR); 66 else if (str.equals("sphere")) //$NON-NLS-1$ 67 setStyleIndex(SAFE_SPHERE); 68 } else if ((keys.containsKey("seamark:type")) //$NON-NLS-1$ 69 && (keys.get("seamark:type").equals("light_float"))) { //$NON-NLS-1$ //$NON-NLS-2$ 70 setStyleIndex(SAFE_FLOAT); 71 } else if ((keys.containsKey("seamark:type")) //$NON-NLS-1$ 72 && (keys.get("seamark:type").equals("beacon_safe_water"))) { //$NON-NLS-1$ //$NON-NLS-2$ 73 setStyleIndex(SAFE_BEACON); 74 } 75 76 if (getStyleIndex() >= dlg.cbM01StyleOfMark.getItemCount()) 77 setStyleIndex(0); 78 79 if (keys.containsKey("seamark:topmark:shape") //$NON-NLS-1$ 80 || keys.containsKey("seamark:topmark:colour")) { //$NON-NLS-1$ 81 setTopMark(true); 82 } 83 84 refreshLights(); 85 parseLights(keys); 86 parseFogRadar(keys); 87 88 dlg.cbM01StyleOfMark.setSelectedIndex(getStyleIndex()); 89 dlg.tfM01Name.setText(getName()); 90 dlg.cM01TopMark.setSelected(hasTopMark()); 91 } 92 93 public void refreshLights() { 94 dlg.cbM01Kennung.removeAllItems(); 95 dlg.cbM01Kennung.addItem(Messages.getString("SmpDialogAction.212")); //$NON-NLS-1$ 96 dlg.cbM01Kennung.addItem("Iso"); //$NON-NLS-1$ 97 dlg.cbM01Kennung.addItem("Oc"); //$NON-NLS-1$ 98 dlg.cbM01Kennung.addItem("LFl"); //$NON-NLS-1$ 99 dlg.cbM01Kennung.addItem("Mo"); //$NON-NLS-1$ 100 dlg.cbM01Kennung.setSelectedIndex(0); 101 } 102 103 public boolean isValid() { 104 return (getBuoyIndex() > 0) && (getStyleIndex() > 0); 105 } 106 107 public void paintSign() { 108 if (dlg.paintlock) 109 return; 110 super.paintSign(); 111 112 dlg.sM01StatusBar.setText(getErrMsg()); 113 114 if (isValid()) { 115 dlg.tfM01Name.setEnabled(true); 116 dlg.tfM01Name.setText(getName()); 117 dlg.cM01TopMark.setEnabled(true); 118 dlg.cM01TopMark.setVisible(true); 119 dlg.cM01Radar.setVisible(true); 120 dlg.cM01Racon.setVisible(true); 121 dlg.cM01Fog.setVisible(true); 122 dlg.cM01Fired.setVisible(true); 123 dlg.cM01Fired.setEnabled(true); 124 dlg.cbM01Colour.setVisible(false); 125 dlg.lM01Colour.setVisible(false); 126 dlg.rbM01Fired1.setVisible(false); 127 dlg.rbM01FiredN.setVisible(false); 128 dlg.lM01Height.setVisible(false); 129 dlg.tfM01Height.setVisible(false); 130 dlg.lM01Range.setVisible(false); 131 dlg.tfM01Range.setVisible(false); 132 133 if (isFired()) { 134 switch (getStyleIndex()) { 135 case SPEC_FLOAT: 136 dlg.lM01Height.setVisible(true); 137 dlg.tfM01Height.setVisible(true); 138 dlg.lM01Range.setVisible(true); 139 dlg.tfM01Range.setVisible(true); 140 break; 141 case SPEC_BEACON: 142 case SPEC_TOWER: 143 dlg.rbM01Fired1.setVisible(true); 144 dlg.rbM01FiredN.setVisible(true); 145 dlg.lM01Height.setVisible(true); 146 dlg.tfM01Height.setVisible(true); 147 dlg.lM01Range.setVisible(true); 148 dlg.tfM01Range.setVisible(true); 149 break; 150 default: 151 } 152 } 153 154 String image = "/images/Safe_Water"; //$NON-NLS-1$ 155 156 switch (getStyleIndex()) { 157 case SAFE_PILLAR: 158 image += "_Pillar"; //$NON-NLS-1$ 159 break; 160 case SAFE_SPAR: 161 image += "_Spar"; //$NON-NLS-1$ 162 break; 163 case SAFE_SPHERE: 164 image += "_Sphere"; //$NON-NLS-1$ 165 break; 166 case SAFE_BEACON: 167 image += "_Beacon"; //$NON-NLS-1$ 168 break; 169 case SAFE_FLOAT: 170 image += "_Float"; //$NON-NLS-1$ 171 break; 172 default: 173 } 174 175 if (!image.equals("/images/Safe_Water")) { //$NON-NLS-1$ 176 if (hasTopMark()) 177 image += "_Sphere"; //$NON-NLS-1$ 178 image += ".png"; //$NON-NLS-1$ 179 dlg.lM01Icon.setIcon(new ImageIcon(getClass().getResource(image))); 180 } else 181 dlg.lM01Icon.setIcon(null); 182 } 183 } 184 185 public void saveSign() { 186 Node node = getNode(); 187 188 if (node == null) { 189 return; 190 } 191 192 switch (getStyleIndex()) { 193 case SAFE_PILLAR: 194 super.saveSign("buoy_safe_water"); //$NON-NLS-1$ 195 Main.main.undoRedo.add(new ChangePropertyCommand(node, 196 "seamark:buoy_safe_water:shape", "pillar")); //$NON-NLS-1$ //$NON-NLS-2$ 197 break; 198 case SAFE_SPAR: 199 super.saveSign("buoy_safe_water"); //$NON-NLS-1$ 200 Main.main.undoRedo.add(new ChangePropertyCommand(node, 201 "seamark:buoy_safe_water:shape", "spar")); //$NON-NLS-1$ //$NON-NLS-2$ 202 break; 203 case SAFE_SPHERE: 204 super.saveSign("buoy_safe_water"); //$NON-NLS-1$ 205 Main.main.undoRedo.add(new ChangePropertyCommand(node, 206 "seamark:buoy_safe_water:shape", "sphere")); //$NON-NLS-1$ //$NON-NLS-2$ 207 break; 208 case SAFE_BEACON: 209 super.saveSign("beacon_safe_water"); //$NON-NLS-1$ 210 break; 211 case SAFE_FLOAT: 212 super.saveSign("light_float"); //$NON-NLS-1$ 213 break; 214 default: 215 } 216 217 switch (getStyleIndex()) { 218 case SAFE_PILLAR: 219 case SAFE_SPAR: 220 case SAFE_SPHERE: 221 Main.main.undoRedo.add(new ChangePropertyCommand(node, 222 "seamark:buoy_safe_water:colour_pattern", "vertical stripes")); //$NON-NLS-1$ //$NON-NLS-2$ 223 Main.main.undoRedo.add(new ChangePropertyCommand(node, 224 "seamark:buoy_safe_water:colour", "red;white")); //$NON-NLS-1$ //$NON-NLS-2$ 225 break; 226 case SAFE_BEACON: 227 Main.main.undoRedo.add(new ChangePropertyCommand(node, 228 "seamark:beacon_safe_water:colour_pattern", "vertical stripes")); //$NON-NLS-1$ //$NON-NLS-2$ 229 Main.main.undoRedo.add(new ChangePropertyCommand(node, 230 "seamark:beacon_safe_water:colour", "red;white")); //$NON-NLS-1$ //$NON-NLS-2$ 231 break; 232 case SAFE_FLOAT: 233 Main.main.undoRedo.add(new ChangePropertyCommand(node, 234 "seamark:light_float:colour_pattern", "vertical stripes")); //$NON-NLS-1$ //$NON-NLS-2$ 235 Main.main.undoRedo.add(new ChangePropertyCommand(node, 236 "seamark:light_float:colour", "red;white")); //$NON-NLS-1$ //$NON-NLS-2$ 237 break; 238 default: 239 } 240 saveTopMarkData("spherical", "red"); //$NON-NLS-1$ //$NON-NLS-2$ 241 saveLightData(); //$NON-NLS-1$ 242 saveRadarFogData(); 243 } 244 245 public void setLightColour() { 246 super.setLightColour("W"); //$NON-NLS-1$ 247 } 248 248 249 249 } -
applications/editors/josm/plugins/toms/src/toms/seamarks/buoys/BuoySpec.java
r23179 r23193 17 17 18 18 public class BuoySpec extends Buoy { 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 // 237 // 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 19 public BuoySpec(SmpDialogAction dia, Node node) { 20 super(dia); 21 22 String str; 23 Map<String, String> keys; 24 keys = node.getKeys(); 25 setNode(node); 26 27 resetMask(); 28 29 dlg.cbM01TypeOfMark.setSelectedIndex(SPECIAL_PURPOSE); 30 31 dlg.cbM01StyleOfMark.removeAllItems(); 32 dlg.cbM01StyleOfMark.addItem(Messages.getString("SmpDialogAction.212")); //$NON-NLS-1$ 33 dlg.cbM01StyleOfMark.addItem(Messages.getString("Buoy.01")); //$NON-NLS-1$ 34 dlg.cbM01StyleOfMark.addItem(Messages.getString("Buoy.02")); //$NON-NLS-1$ 35 dlg.cbM01StyleOfMark.addItem(Messages.getString("Buoy.03")); //$NON-NLS-1$ 36 dlg.cbM01StyleOfMark.addItem(Messages.getString("Buoy.04")); //$NON-NLS-1$ 37 dlg.cbM01StyleOfMark.addItem(Messages.getString("Buoy.05")); //$NON-NLS-1$ 38 dlg.cbM01StyleOfMark.addItem(Messages.getString("Buoy.06")); //$NON-NLS-1$ 39 dlg.cbM01StyleOfMark.addItem(Messages.getString("Buoy.07")); //$NON-NLS-1$ 40 dlg.cbM01StyleOfMark.addItem(Messages.getString("Buoy.08")); //$NON-NLS-1$ 41 dlg.cbM01StyleOfMark.addItem(Messages.getString("Buoy.09")); //$NON-NLS-1$ 42 dlg.cbM01StyleOfMark.setVisible(true); 43 dlg.lM01StyleOfMark.setVisible(true); 44 45 dlg.cbM01TopMark.removeAllItems(); 46 dlg.cbM01TopMark.addItem(Messages.getString("SmpDialogAction.212")); 47 dlg.cbM01TopMark.addItem(Messages.getString("SmpDialogAction.210")); //$NON-NLS-1$ 48 dlg.cbM01TopMark.addItem(Messages.getString("SmpDialogAction.211")); //$NON-NLS-1$ 49 50 dlg.cM01TopMark.setEnabled(true); 51 52 setBuoyIndex(SPECIAL_PURPOSE); 53 setColour(SeaMark.YELLOW); 54 setLightColour("W"); //$NON-NLS-1$ 55 setRegion(Main.pref.get("tomsplugin.IALA").equals("B")); //$NON-NLS-1$ //$NON-NLS-2$ 56 57 if (keys.containsKey("name")) //$NON-NLS-1$ 58 setName(keys.get("name")); //$NON-NLS-1$ 59 60 if (keys.containsKey("seamark:name")) //$NON-NLS-1$ 61 setName(keys.get("seamark:name")); //$NON-NLS-1$ 62 63 if (keys.containsKey("seamark:buoy_special_purpose:name")) //$NON-NLS-1$ 64 setName(keys.get("seamark:buoy_special_purpose:name")); //$NON-NLS-1$ 65 else if (keys.containsKey("seamark:beacon_special_purpose:name")) //$NON-NLS-1$ 66 setName(keys.get("seamark:beacon_special_purpose:name")); //$NON-NLS-1$ 67 else if (keys.containsKey("seamark:light_float:name")) //$NON-NLS-1$ 68 setName(keys.get("seamark:light_float:name")); //$NON-NLS-1$ 69 70 if (keys.containsKey("seamark:buoy_special_purpose:shape")) { //$NON-NLS-1$ 71 str = keys.get("seamark:buoy_special_purpose:shape"); //$NON-NLS-1$ 72 73 if (str.equals("pillar")) //$NON-NLS-1$ 74 setStyleIndex(SPEC_PILLAR); 75 else if (str.equals("can")) //$NON-NLS-1$ 76 setStyleIndex(SPEC_CAN); 77 else if (str.equals("conical")) //$NON-NLS-1$ 78 setStyleIndex(SPEC_CONE); 79 else if (str.equals("spar")) //$NON-NLS-1$ 80 setStyleIndex(SPEC_SPAR); 81 else if (str.equals("sphere")) //$NON-NLS-1$ 82 setStyleIndex(SPEC_SPHERE); 83 else if (str.equals("barrel")) //$NON-NLS-1$ 84 setStyleIndex(SPEC_BARREL); 85 } 86 87 if (keys.containsKey("seamark:beacon_special_purpose:shape")) { //$NON-NLS-1$ 88 str = keys.get("seamark:beacon_special_purpose:shape"); //$NON-NLS-1$ 89 if (str.equals("tower")) //$NON-NLS-1$ 90 setStyleIndex(SPEC_TOWER); 91 else 92 setStyleIndex(SPEC_BEACON); 93 } 94 95 if (keys.containsKey("seamark:light_float:colour")) { 96 setStyleIndex(SPEC_FLOAT); 97 } 98 99 if ((keys.containsKey("seamark:type") && keys.get("seamark:type").equals( //$NON-NLS-1$ //$NON-NLS-2$ 100 "beacon_special_purpose")) //$NON-NLS-1$ 101 || keys.containsKey("seamark:beacon_special_purpose:colour") //$NON-NLS-1$ 102 || keys.containsKey("seamark:beacon_special_purpose:shape")) { //$NON-NLS-1$ 103 if (keys.containsKey("seamark:beacon_special_purpose:shape") //$NON-NLS-1$ 104 && keys.get("seamark:beacon_special_purpose:shape").equals("tower")) //$NON-NLS-1$ //$NON-NLS-2$ 105 setStyleIndex(SPEC_TOWER); 106 else 107 setStyleIndex(SPEC_BEACON); 108 } else if (keys.containsKey("seamark:light_float:colour") //$NON-NLS-1$ 109 && keys.get("seamark:light_float:colour").equals("yellow")) //$NON-NLS-1$ //$NON-NLS-2$ 110 setStyleIndex(SPEC_FLOAT); 111 112 if (getStyleIndex() >= dlg.cbM01StyleOfMark.getItemCount()) 113 setStyleIndex(0); 114 115 keys = node.getKeys(); 116 if (keys.containsKey("seamark:topmark:shape")) { //$NON-NLS-1$ 117 str = keys.get("seamark:topmark:shape"); //$NON-NLS-1$ 118 119 if (str.equals("x-shape")) { //$NON-NLS-1$ 120 setTopMark(true); 121 } 122 } 123 124 refreshLights(); 125 parseLights(keys); 126 parseFogRadar(keys); 127 128 dlg.cbM01StyleOfMark.setSelectedIndex(getStyleIndex()); 129 dlg.tfM01Name.setText(getName()); 130 dlg.cM01TopMark.setSelected(hasTopMark()); 131 } 132 133 public void setStyleIndex(int styleIndex) { 134 super.setStyleIndex(styleIndex); 135 if (styleIndex == SPEC_BARREL) { 136 dlg.cM01Fired.setSelected(false); 137 dlg.cM01Fired.setEnabled(false); 138 dlg.cM01TopMark.setEnabled(true); 139 } else { 140 dlg.cM01Fired.setEnabled(true); 141 dlg.cM01TopMark.setEnabled(true); 142 } 143 } 144 145 public boolean isValid() { 146 return (getBuoyIndex() > 0) && (getStyleIndex() > 0); 147 } 148 149 public void paintSign() { 150 if (dlg.paintlock) 151 return; 152 super.paintSign(); 153 154 dlg.sM01StatusBar.setText(getErrMsg()); 155 156 if (isValid()) { 157 dlg.tfM01Name.setEnabled(true); 158 dlg.tfM01Name.setText(getName()); 159 dlg.cM01Radar.setVisible(true); 160 dlg.cM01Racon.setVisible(true); 161 dlg.cM01TopMark.setEnabled(true); 162 dlg.cM01TopMark.setVisible(true); 163 if (hasTopMark()) { 164 dlg.cbM01TopMark.setEnabled(true); 165 dlg.cbM01TopMark.setVisible(true); 166 } else { 167 dlg.cbM01TopMark.setVisible(false); 168 } 169 dlg.cM01Fog.setVisible(true); 170 dlg.cM01Fired.setVisible(true); 171 dlg.cM01Fired.setEnabled(true); 172 dlg.cbM01Colour.setVisible(false); 173 dlg.lM01Colour.setVisible(false); 174 dlg.rbM01Fired1.setVisible(false); 175 dlg.rbM01FiredN.setVisible(false); 176 dlg.lM01Height.setVisible(false); 177 dlg.tfM01Height.setVisible(false); 178 dlg.lM01Range.setVisible(false); 179 dlg.tfM01Range.setVisible(false); 180 181 if (isFired()) { 182 switch (getStyleIndex()) { 183 case SPEC_FLOAT: 184 dlg.lM01Height.setVisible(true); 185 dlg.tfM01Height.setVisible(true); 186 dlg.lM01Range.setVisible(true); 187 dlg.tfM01Range.setVisible(true); 188 break; 189 case SPEC_BEACON: 190 case SPEC_TOWER: 191 dlg.rbM01Fired1.setVisible(true); 192 dlg.rbM01FiredN.setVisible(true); 193 dlg.lM01Height.setVisible(true); 194 dlg.tfM01Height.setVisible(true); 195 dlg.lM01Range.setVisible(true); 196 dlg.tfM01Range.setVisible(true); 197 break; 198 default: 199 } 200 } 201 202 String image = "/images/Special_Purpose"; //$NON-NLS-1$ 203 204 switch (getStyleIndex()) { 205 case SPEC_PILLAR: 206 image += "_Pillar"; //$NON-NLS-1$ 207 break; 208 case SPEC_CAN: 209 image += "_Can"; //$NON-NLS-1$ 210 break; 211 case SPEC_CONE: 212 image += "_Cone"; //$NON-NLS-1$ 213 break; 214 case SPEC_SPAR: 215 image += "_Spar"; //$NON-NLS-1$ 216 break; 217 case SPEC_SPHERE: 218 image += "_Sphere"; //$NON-NLS-1$ 219 break; 220 case SPEC_BARREL: 221 image += "_Barrel"; //$NON-NLS-1$ 222 break; 223 case SPEC_FLOAT: 224 image += "_Float"; //$NON-NLS-1$ 225 break; 226 case SPEC_BEACON: 227 image += "_Beacon"; //$NON-NLS-1$ 228 break; 229 case SPEC_TOWER: 230 image += "_Tower"; //$NON-NLS-1$ 231 break; 232 default: 233 } 234 235 if (!image.equals("/images/Special_Purpose")) { //$NON-NLS-1$ 236 // if (hasTopMark()) 237 // image += "_CrossY"; //$NON-NLS-1$ 238 image += ".png"; //$NON-NLS-1$ 239 dlg.lM01Icon.setIcon(new ImageIcon(getClass().getResource(image))); 240 } else 241 dlg.lM01Icon.setIcon(null); 242 } 243 } 244 245 public void saveSign() { 246 Node node = getNode(); 247 248 if (node == null) { 249 return; 250 } 251 252 switch (getStyleIndex()) { 253 case SPEC_PILLAR: 254 super.saveSign("buoy_special_purpose"); //$NON-NLS-1$ 255 Main.main.undoRedo.add(new ChangePropertyCommand(node, 256 "seamark:buoy_special_purpose:shape", "pillar")); //$NON-NLS-1$ //$NON-NLS-2$ 257 Main.main.undoRedo.add(new ChangePropertyCommand(node, 258 "seamark:buoy_special_purpose:colour", "yellow")); //$NON-NLS-1$ //$NON-NLS-2$ 259 break; 260 case SPEC_SPAR: 261 super.saveSign("buoy_special_purpose"); //$NON-NLS-1$ 262 Main.main.undoRedo.add(new ChangePropertyCommand(node, 263 "seamark:buoy_special_purpose:shape", "spar")); //$NON-NLS-1$ //$NON-NLS-2$ 264 Main.main.undoRedo.add(new ChangePropertyCommand(node, 265 "seamark:buoy_special_purpose:colour", "yellow")); //$NON-NLS-1$ //$NON-NLS-2$ 266 break; 267 case SPEC_SPHERE: 268 super.saveSign("buoy_special_purpose"); //$NON-NLS-1$ 269 Main.main.undoRedo.add(new ChangePropertyCommand(node, 270 "seamark:buoy_special_purpose:shape", "sphere")); //$NON-NLS-1$ //$NON-NLS-2$ 271 Main.main.undoRedo.add(new ChangePropertyCommand(node, 272 "seamark:buoy_special_purpose:colour", "yellow")); //$NON-NLS-1$ //$NON-NLS-2$ 273 break; 274 case SPEC_BARREL: 275 super.saveSign("buoy_special_purpose"); //$NON-NLS-1$ 276 Main.main.undoRedo.add(new ChangePropertyCommand(node, 277 "seamark:buoy_special_purpose:shape", "barrel")); //$NON-NLS-1$ //$NON-NLS-2$ 278 Main.main.undoRedo.add(new ChangePropertyCommand(node, 279 "seamark:buoy_special_purpose:colour", "yellow")); //$NON-NLS-1$ //$NON-NLS-2$ 280 break; 281 case SPEC_FLOAT: 282 super.saveSign("light_float"); //$NON-NLS-1$ 283 Main.main.undoRedo.add(new ChangePropertyCommand(node, 284 "seamark:light_float:colour", "yellow")); //$NON-NLS-1$ //$NON-NLS-2$ 285 break; 286 case SPEC_BEACON: 287 super.saveSign("beacon_special_purpose"); //$NON-NLS-1$ 288 Main.main.undoRedo.add(new ChangePropertyCommand(node, 289 "seamark:beacon_special_purpose:colour", "yellow")); //$NON-NLS-1$ //$NON-NLS-2$ 290 break; 291 case SPEC_TOWER: 292 super.saveSign("beacon_special_purpose"); //$NON-NLS-1$ 293 Main.main.undoRedo.add(new ChangePropertyCommand(node, 294 "seamark:beacon_special_purpose:shape", "tower")); //$NON-NLS-1$ //$NON-NLS-2$ 295 Main.main.undoRedo.add(new ChangePropertyCommand(node, 296 "seamark:beacon_special_purpose:colour", "yellow")); //$NON-NLS-1$ //$NON-NLS-2$ 297 break; 298 default: 299 } 300 saveTopMarkData("x-shape", "yellow"); //$NON-NLS-1$ //$NON-NLS-2$ 301 saveLightData(); //$NON-NLS-1$ 302 saveRadarFogData(); 303 } 304 305 public void setLightColour() { 306 super.setLightColour("W"); //$NON-NLS-1$ 307 } 308 308 309 309 } -
applications/editors/josm/plugins/toms/src/toms/seamarks/buoys/BuoyUkn.java
r23047 r23193 11 11 12 12 public class BuoyUkn extends Buoy { 13 14 15 16 17 18 19 20 21 13 public BuoyUkn(SmpDialogAction dia, String Msg) { 14 super(dia); 15 resetMask(); 16 dlg.cbM01TypeOfMark.setSelectedIndex(0); 17 dlg.cbM01CatOfMark.removeAllItems(); 18 dlg.cbM01CatOfMark.setEnabled(false); 19 dlg.tfM01Name.setText(getName()); 20 setErrMsg(Msg); 21 } 22 22 23 24 25 23 public void paintSign() { 24 if (dlg.paintlock) return; 25 super.paintSign(); 26 26 27 28 27 if (getErrMsg() != null) 28 dlg.sM01StatusBar.setText(getErrMsg()); 29 29 30 31 30 setErrMsg(null); 31 } 32 32 33 34 35 33 public void setLightColour() { 34 super.setLightColour(""); 35 } 36 36 37 38 37 public void saveSign() { 38 } 39 39 } -
applications/editors/josm/plugins/touchscreenhelper/src/touchscreenhelper/BrowseAction.java
r21569 r23193 16 16 MouseMotionListener { 17 17 18 19 20 21 18 public BrowseAction(MapFrame mapFrame) { 19 super(tr("Browse"), "browse", tr("Browse map with left button"), 20 mapFrame, Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR)); 21 } 22 22 23 24 23 @Override public void enterMode() { 24 super.enterMode(); 25 25 26 27 28 26 Main.map.mapView.addMouseListener(this); 27 Main.map.mapView.addMouseMotionListener(this); 28 } 29 29 30 31 30 @Override public void exitMode() { 31 super.exitMode(); 32 32 33 34 35 33 Main.map.mapView.removeMouseListener(this); 34 Main.map.mapView.removeMouseMotionListener(this); 35 } 36 36 37 38 39 40 41 42 37 public void mouseDragged(MouseEvent e) { 38 if ((e.getModifiersEx() & MouseEvent.BUTTON1_DOWN_MASK) != 39 MouseEvent.BUTTON1_DOWN_MASK) { 40 endMovement(); 41 return; 42 } 43 43 44 45 46 47 48 49 50 51 44 if (mousePosMove == null) 45 startMovement(e); 46 EastNorth center = Main.map.mapView.getCenter(); 47 EastNorth mouseCenter = Main.map.mapView.getEastNorth(e.getX(), e.getY()); 48 Main.map.mapView.zoomTo(new EastNorth( 49 mousePosMove.east() + center.east() - mouseCenter.east(), 50 mousePosMove.north() + center.north() - mouseCenter.north())); 51 } 52 52 53 54 55 56 53 @Override public void mousePressed(MouseEvent e) { 54 if (e.getButton() == MouseEvent.BUTTON1) 55 startMovement(e); 56 } 57 57 58 59 60 61 58 @Override public void mouseReleased(MouseEvent e) { 59 if (e.getButton() == MouseEvent.BUTTON1) 60 endMovement(); 61 } 62 62 63 64 63 private EastNorth mousePosMove; 64 private boolean movementInPlace = false; 65 65 66 67 68 69 70 71 66 private void startMovement(MouseEvent e) { 67 if (movementInPlace) 68 return; 69 movementInPlace = true; 70 mousePosMove = Main.map.mapView.getEastNorth(e.getX(), e.getY()); 71 } 72 72 73 74 75 76 77 78 73 private void endMovement() { 74 if (!movementInPlace) 75 return; 76 movementInPlace = false; 77 mousePosMove = null; 78 } 79 79 } -
applications/editors/josm/plugins/touchscreenhelper/src/touchscreenhelper/TouchScreenHelperPlugin.java
r21569 r23193 8 8 9 9 public class TouchScreenHelperPlugin extends Plugin { 10 11 12 13 14 15 16 17 18 10 public TouchScreenHelperPlugin(PluginInformation info) { 11 super(info); 12 } 13 @Override public void mapFrameInitialized(MapFrame oldFrame, 14 MapFrame newFrame) { 15 if (oldFrame == null && newFrame != null) { 16 Main.map.addMapMode(new IconToggleButton(new BrowseAction(Main.map))); 17 } 18 } 19 19 } -
applications/editors/josm/plugins/videomapping/src/org/openstreetmap/josm/plugins/videomapping/GpsPlayer.java
r23173 r23193 17 17 //for GPS play control, secure stepping through list and interpolation work in current projection 18 18 public class GpsPlayer { 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 { 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 } 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 {int a,b,length,lengthSeg;223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 19 private List<WayPoint> ls; 20 private WayPoint prev,curr,next; 21 private WayPoint start; 22 private Timer t; 23 private TimerTask ani; //for moving trough the list 24 private boolean autoCenter; 25 26 27 public WayPoint getPrev() { 28 return prev; 29 } 30 31 public WayPoint getCurr() { 32 return curr; 33 } 34 35 public WayPoint getNext() { 36 return next; 37 } 38 39 public WayPoint getWaypoint(long relTime) 40 { 41 int pos = Math.round(relTime/1000);//TODO ugly quick hack 42 return ls.get(pos); 43 } 44 45 public GpsPlayer(List<WayPoint> l) { 46 super(); 47 this.ls = l; 48 //set start position 49 start=ls.get(0); 50 prev=null; 51 curr=ls.get(0); 52 next=ls.get(1); 53 } 54 55 // one secure step forward 56 public void next() { 57 if(ls.indexOf(curr)+1<ls.size()) 58 { 59 prev=curr; 60 curr=next; 61 if(ls.indexOf(curr)+1==ls.size()) next=null; 62 else next=ls.get(ls.indexOf(curr)+1); 63 } 64 else next=null; 65 66 } 67 68 //one secure step backward 69 public void prev() 70 { 71 if(ls.indexOf(curr)>0) 72 { 73 next =curr; 74 curr=prev; 75 if(ls.indexOf(curr)==0) prev=null;else prev=ls.get(ls.indexOf(curr)-1); 76 } 77 else prev=null; 78 } 79 80 //select the given waypoint as center 81 public void jump(WayPoint p) 82 { 83 if(ls.contains(p)) 84 { 85 curr=p; 86 if(ls.indexOf(curr)>0) 87 { 88 prev=ls.get(ls.indexOf(curr)-1); 89 } 90 else prev=null; 91 if(ls.indexOf(curr)+1<ls.size()) 92 { 93 next=ls.get(ls.indexOf(curr)+1); 94 } 95 else next=null; 96 } 97 } 98 99 //walk k waypoints forward/backward 100 public void jumpRel(int k) 101 { 102 103 if ((ls.indexOf(curr)+k>0)&&(ls.indexOf(curr)<ls.size())) //check range 104 { 105 jump(ls.get(ls.indexOf(curr)+k)); 106 } 107 Main.map.mapView.repaint(); //seperate modell and view logic... 108 } 109 110 //select the k-th waypoint 111 public void jump(int k) 112 { 113 if (k>0) 114 { 115 if ((ls.indexOf(curr)+k>0)&&(ls.indexOf(curr)<ls.size())) //check range 116 { 117 jump(ls.get(k)); 118 } 119 Main.map.mapView.repaint(); 120 } 121 } 122 123 //go to the position at the timecode e.g.g "14:00:01"; 124 public void jump(Time GPSAbsTime) 125 { 126 jump(getWaypoint(GPSAbsTime.getTime()-start.getTime().getTime())); //TODO replace Time by Date? 127 } 128 129 //go to the position at 130 public void jump(Date GPSDate) 131 { 132 long s,m,h,diff; 133 //calculate which waypoint is at the offset 134 System.out.println(start.getTime()); 135 System.out.println(start.getTime().getHours()+":"+start.getTime().getMinutes()+":"+start.getTime().getSeconds()); 136 s=GPSDate.getSeconds()-start.getTime().getSeconds(); 137 m=GPSDate.getMinutes()-start.getTime().getMinutes(); 138 h=GPSDate.getHours()-start.getTime().getHours(); 139 diff=s*1000+m*60*1000+h*60*60*1000; //TODO ugly hack but nothing else works right 140 jump(getWaypoint(diff)); 141 } 142 143 //gets only points on the line of the GPS track (between waypoints) nearby the point m 144 private Point getInterpolated(Point m) 145 { 146 Point leftP,rightP,highP,lowP; 147 boolean invalid = false; //when we leave this segment 148 Point p1 = Main.map.mapView.getPoint(getCurr().getEastNorth()); 149 Point p2 = getEndpoint(); 150 //determine which point is what 151 leftP=getLeftPoint(p1, p2); 152 rightP=getRightPoint(p1,p2); 153 highP=getHighPoint(p1, p2); 154 lowP=getLowPoint(p1, p2); 155 if(getNext()!=null) 156 { 157 //we might switch to one neighbor segment 158 if(m.x<leftP.x) 159 { 160 Point c = Main.map.mapView.getPoint(getCurr().getEastNorth()); 161 Point n = Main.map.mapView.getPoint(getNext().getEastNorth()); 162 if(n.x<c.x) next(); else prev(); 163 invalid=true; 164 m=leftP; 165 System.out.println("entering left segment"); 166 } 167 if(m.x>rightP.x) 168 { 169 Point c = Main.map.mapView.getPoint(getCurr().getEastNorth()); 170 Point n = Main.map.mapView.getPoint(getNext().getEastNorth()); 171 if(n.x>c.x) next(); else prev(); 172 invalid=true; 173 m=rightP; 174 System.out.println("entering right segment"); 175 } 176 if(!invalid) 177 { 178 float slope = getSlope(highP, lowP); 179 m.y = highP.y+Math.round(slope*(m.x-highP.x)); 180 } 181 } 182 else 183 { 184 //currently we are at the end 185 if(m.x>rightP.x) 186 { 187 m=rightP; //we can't move anywhere 188 } 189 else 190 { 191 prev(); //walk back to the segment before 192 } 193 } 194 return m; 195 } 196 197 //returns a point on the p% of the current selected segment 198 private Point getInterpolated(float percent) 199 { 200 201 int dX,dY; 202 Point p; 203 Point leftP,rightP; 204 Point c = Main.map.mapView.getPoint(getCurr().getEastNorth()); 205 Point p1 = Main.map.mapView.getPoint(getCurr().getEastNorth()); 206 Point p2 = getEndpoint(); 207 //determine which point is what 208 leftP=getLeftPoint(p1, p2); 209 rightP=getRightPoint(p1,p2); 210 //we will never go over the segment 211 percent=percent/100; 212 dX=Math.round((rightP.x-leftP.x)*percent); 213 dY=Math.round((rightP.y-leftP.y)*percent); 214 //move in the right direction 215 p=new Point(rightP.x-dX,rightP.y-dY); 216 217 return p; 218 } 219 220 //gets further infos for a point between two Waypoints 221 public WayPoint getInterpolatedWaypoint(Point m) 222 { int a,b,length,lengthSeg; 223 long timeSeg; 224 float ratio; 225 Time base; 226 Point p2; 227 228 Point curr =Main.map.mapView.getPoint(getCurr().getEastNorth()); 229 m =getInterpolated(m); //get the right position 230 //get the right time 231 p2=getEndpoint(); 232 if (getNext()!=null) 233 { 234 timeSeg=getNext().getTime().getTime()-getCurr().getTime().getTime(); 235 } 236 else 237 { 238 timeSeg=-(getPrev().getTime().getTime()-getCurr().getTime().getTime()); 239 } 240 WayPoint w =new WayPoint(Main.map.mapView.getLatLon(m.x, m.y)); 241 //calc total traversal length 242 lengthSeg = getTraversalLength(p2, curr); 243 length = getTraversalLength(p2, m); 244 length=lengthSeg-length; 245 //calc time difference 246 ratio=(float)length/(float)lengthSeg; 247 long inc=(long) (timeSeg*ratio); 248 long old = getCurr().getTime().getTime(); 249 old=old+inc; 250 Date t = new Date(old); 251 w.time = t.getTime()/1000; //TODO need better way to set time and sync it 252 SimpleDateFormat df = new SimpleDateFormat("hh:mm:ss:S"); 253 /*System.out.print(length+"px "); 254 System.out.print(ratio+"% "); 255 System.out.print(inc+"ms "); 256 System.out.println(df.format(t.getTime()));+*/ 257 System.out.println(df.format(w.getTime())); 258 //TODO we have to publish the new date to the node... 259 return w; 260 } 261 262 //returns a point and time for the current segment 263 private WayPoint getInterpolatedWaypoint(float percentage) 264 { 265 Point p = getInterpolated(percentage); 266 WayPoint w =new WayPoint(Main.map.mapView.getLatLon(p.x, p.y)); 267 return w; 268 } 269 270 //returns n points on the current segment 271 public List<WayPoint> getInterpolatedLine(int interval) 272 { 273 List<WayPoint> ls; 274 Point p2; 275 float step; 276 int length; 277 278 step=100/(float)interval; 279 ls=new LinkedList<WayPoint>(); 280 for(float i=step;i<100;i+=step) 281 { 282 ls.add(getInterpolatedWaypoint(i)); 283 } 284 return ls; 285 } 286 287 private Point getLeftPoint(Point p1,Point p2) 288 { 289 if(p1.x<p2.x) return p1; else return p2; 290 } 291 292 private Point getRightPoint(Point p1, Point p2) 293 { 294 if(p1.x>p2.x) return p1; else return p2; 295 } 296 297 private Point getHighPoint(Point p1, Point p2) 298 { 299 if(p1.y<p2.y)return p1; else return p2; 300 } 301 302 private Point getLowPoint(Point p1, Point p2) 303 { 304 if(p1.y>p2.y)return p1; else return p2; 305 } 306 307 private Point getEndpoint() { 308 if(getNext()!=null) 309 { 310 return Main.map.mapView.getPoint(getNext().getEastNorth()); 311 } 312 else 313 { 314 return Main.map.mapView.getPoint(getPrev().getEastNorth()); 315 } 316 317 } 318 319 private float getSlope(Point highP, Point lowP) { 320 float slope=(float)(highP.y-lowP.y) / (float)(highP.x - lowP.x); 321 return slope; 322 } 323 324 private int getTraversalLength(Point p2, Point curr) { 325 int a; 326 int b; 327 int lengthSeg; 328 a=Math.abs(curr.x-p2.x); 329 b=Math.abs(curr.y-p2.y); 330 lengthSeg= (int) Math.sqrt(Math.pow(a, 2)+Math.pow(b, 2)); 331 return lengthSeg; 332 } 333 334 //returns time in ms relatie to startpoint 335 public long getRelativeTime() 336 { 337 return getRelativeTime(curr); 338 } 339 340 public long getRelativeTime(WayPoint p) 341 { 342 return p.getTime().getTime()-start.getTime().getTime(); //TODO assumes timeintervall is constant!!!! 343 } 344 345 346 //jumps to a specific time 347 public void jump(long relTime) { 348 int pos = Math.round(relTime/1000);//TODO ugly quick hack 349 jump(pos); 350 //if (autoCenter) Main.map.mapView. 351 } 352 353 //toggles walking along the track 354 public void play() 355 { /* 356 if (t==null) 357 { 358 //start 359 t= new Timer(); 360 ani=new TimerTask() { 361 @Override 362 //some cheap animation stuff 363 public void run() { 364 next(); 365 if(autoCenter) Main.map.mapView.zoomTo(getCurr().getEastNorth()); 366 Main.map.mapView.repaint(); 367 } 368 }; 369 t.schedule(ani,1000,1000); 370 } 371 else 372 { 373 //stop 374 ani.cancel(); 375 ani=null; 376 t.cancel(); 377 t=null; 378 }*/ 379 } 380 381 public long getLength() { 382 return ls.size()*1000; //FIXME this is a poor hack 383 } 384 385 public void setAutoCenter(boolean b) 386 { 387 this.autoCenter=b; 388 } 389 390 public List<WayPoint> getTrack() 391 { 392 return ls; 393 } 394 395 396 397 398 398 } -
applications/editors/josm/plugins/videomapping/src/org/openstreetmap/josm/plugins/videomapping/PlayerObserver.java
r22690 r23193 3 3 //an Interface for communication for both players 4 4 public interface PlayerObserver { 5 6 7 5 void playing(long time); 6 void jumping(long time); 7 void metadata(long time,boolean subtitles); 8 8 9 9 } -
applications/editors/josm/plugins/videomapping/src/org/openstreetmap/josm/plugins/videomapping/PositionLayer.java
r23173 r23193 55 55 //Basic rendering and GPS layer interaction 56 56 public class PositionLayer extends Layer implements MouseListener,MouseMotionListener { 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 57 private static Set<PlayerObserver> observers = new HashSet<PlayerObserver>(); //we have to implement our own Observer pattern 58 private List<WayPoint> ls; 59 public GpsPlayer player; 60 private boolean dragIcon=false; //do we move the icon by hand? 61 private WayPoint iconPosition; 62 private Point mouse; 63 private ImageIcon icon; 64 private SimpleDateFormat mins; 65 private SimpleDateFormat ms; 66 private SimpleDateFormat gpsTimeCode; 67 private GPSVideoPlayer gps; 68 69 public PositionLayer(String name, final List<WayPoint> ls) { 70 super(name); 71 this.ls=ls; 72 player= new GpsPlayer(ls); 73 icon = new ImageIcon("images/videomapping.png"); 74 mins = new SimpleDateFormat("hh:mm:ss:S"); 75 ms= new SimpleDateFormat("mm:ss"); 76 gpsTimeCode= new SimpleDateFormat("hh:mm:ss"); 77 Main.map.mapView.addMouseListener(this); 78 Main.map.mapView.addMouseMotionListener(this); 79 80 } 81 82 83 @Override 84 public Icon getIcon() { 85 return icon; 86 } 87 88 @Override 89 public Object getInfoComponent() { 90 String temp; 91 String sep=System.getProperty("line.separator"); 92 temp=tr("{0} {1}% of GPS track",gps.getVideo().getName(),gps.getCoverage()*10+sep); 93 temp=temp+gps.getNativePlayerInfos(); 94 return temp; 95 } 96 97 @Override 98 public Component[] getMenuEntries() { 99 99 return new Component[]{ 100 100 new JMenuItem(LayerListDialog.getInstance().createShowHideLayerAction(this)), … … 104 104 new JSeparator(), 105 105 new JMenuItem(new LayerListPopup.InfoAction(this))};//TODO here infos about the linked videos 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 { 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 { 273 274 275 276 277 278 279 280 281 282 283 284 285 { 286 287 288 289 290 291 292 293 294 295 296 297 { 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 106 } 107 108 109 110 @Override 111 public String getToolTipText() { 112 return tr("Shows current position in the video"); 113 } 114 115 // no merging necessary 116 @Override 117 public boolean isMergable(Layer arg0) { 118 return false; 119 } 120 121 @Override 122 public void mergeFrom(Layer arg0) { 123 124 } 125 126 127 128 @Override 129 //Draw the current position, infos, waypoints 130 public void paint(Graphics2D g, MapView map, Bounds bound) { 131 Point p; 132 //TODO Source out redundant calculations 133 //TODO make icon transparent 134 //draw all GPS points 135 g.setColor(Color.YELLOW); //new Color(0,255,0,128) 136 for(WayPoint n: ls) { 137 p = Main.map.mapView.getPoint(n.getEastNorth()); 138 g.drawOval(p.x - 2, p.y - 2, 4, 4); 139 } 140 //draw synced points 141 g.setColor(Color.GREEN); 142 for(WayPoint n: ls) { 143 if(n.attr.containsKey("synced")) 144 { 145 p = Main.map.mapView.getPoint(n.getEastNorth()); 146 g.drawOval(p.x - 2, p.y - 2, 4, 4); 147 } 148 } 149 //draw current segment points 150 g.setColor(Color.YELLOW); 151 if(player.getPrev()!=null) 152 { 153 p = Main.map.mapView.getPoint(player.getPrev().getEastNorth()); 154 g.drawOval(p.x - 2, p.y - 2, 4, 4); 155 Point p2 = Main.map.mapView.getPoint(player.getCurr().getEastNorth()); 156 g.drawLine(p.x, p.y, p2.x, p2.y); 157 } 158 if(player.getNext()!=null) 159 { 160 p = Main.map.mapView.getPoint(player.getNext().getEastNorth()); 161 g.drawOval(p.x - 2, p.y - 2, 4, 4); 162 Point p2 = Main.map.mapView.getPoint(player.getCurr().getEastNorth()); 163 g.drawLine(p.x, p.y, p2.x, p2.y); 164 } 165 //draw interpolated points 166 g.setColor(Color.CYAN); 167 g.setBackground(Color.CYAN); 168 LinkedList<WayPoint> ipo=(LinkedList<WayPoint>) player.getInterpolatedLine(5); 169 for (WayPoint wp : ipo) { 170 p=Main.map.mapView.getPoint(wp.getEastNorth()); 171 g.fillArc(p.x, p.y, 4, 4, 0, 360); 172 //g.drawOval(p.x - 2, p.y - 2, 4, 4); 173 } 174 //draw cam icon 175 g.setColor(Color.RED); 176 if(dragIcon) 177 { 178 if(iconPosition!=null) 179 { 180 p=Main.map.mapView.getPoint(iconPosition.getEastNorth()); 181 icon.paintIcon(null, g, p.x-icon.getIconWidth()/2, p.y-icon.getIconHeight()/2); 182 //g.drawString(mins.format(iconPosition.getTime()),p.x-10,p.y-10); //TODO when synced we might wan't to use a different layout 183 g.drawString(gpsTimeCode.format(iconPosition.getTime()),p.x-10,p.y-10); 184 } 185 } 186 else 187 { 188 if (player.getCurr()!=null){ 189 p=Main.map.mapView.getPoint(player.getCurr().getEastNorth()); 190 icon.paintIcon(null, g, p.x-icon.getIconWidth()/2, p.y-icon.getIconHeight()/2); 191 g.drawString(gpsTimeCode.format(player.getCurr().getTime()),p.x-10,p.y-10); 192 } 193 } 194 } 195 196 //finds the first waypoint that is nearby the given point 197 private WayPoint getNearestWayPoint(Point mouse) 198 { 199 final int MAX=10; 200 Point p; 201 Rectangle rect = new Rectangle(mouse.x-MAX/2,mouse.y-MAX/2,MAX,MAX); 202 //iterate through all possible notes 203 for(WayPoint n : ls) //TODO this is not very clever, what better way to find this WP? Hashmaps? Divide and Conquer? 204 { 205 p = Main.map.mapView.getPoint(n.getEastNorth()); 206 if (rect.contains(p)) 207 { 208 return n; 209 } 210 211 } 212 return null; 213 214 } 215 216 //upper left corner like rectangle 217 private Rectangle getIconRect() 218 { 219 Point p = Main.map.mapView.getPoint(player.getCurr().getEastNorth()); 220 return new Rectangle(p.x-icon.getIconWidth()/2,p.y-icon.getIconHeight()/2,icon.getIconWidth(),icon.getIconHeight()); 221 } 222 223 224 @Override 225 public void visitBoundingBox(BoundingXYVisitor arg0) { 226 // TODO don't know what to do here 227 228 } 229 230 public void mouseClicked(MouseEvent e) { 231 } 232 233 public void mouseEntered(MouseEvent arg0) { 234 } 235 236 public void mouseExited(MouseEvent arg0) { 237 } 238 239 //init drag&drop 240 public void mousePressed(MouseEvent e) { 241 if(e.getButton() == MouseEvent.BUTTON1) { 242 //is it on the cam icon? 243 if (player.getCurr()!=null) 244 { 245 if (getIconRect().contains(e.getPoint())) 246 { 247 mouse=e.getPoint(); 248 dragIcon=true; 249 } 250 } 251 } 252 253 } 254 255 // 256 public void mouseReleased(MouseEvent e) { 257 //only leftclicks on our layer 258 if(e.getButton() == MouseEvent.BUTTON1) { 259 if(dragIcon) 260 { 261 dragIcon=false; 262 } 263 else 264 { 265 //simple click 266 WayPoint wp = getNearestWayPoint(e.getPoint()); 267 if(wp!=null) 268 { 269 player.jump(wp); 270 //jump if we know position 271 if(wp.attr.containsKey("synced")) 272 { 273 if(gps!=null) notifyObservers(player.getRelativeTime()); //call videoplayers to set right position 274 } 275 } 276 } 277 Main.map.mapView.repaint(); 278 } 279 280 } 281 282 //slide and restrict during movement 283 public void mouseDragged(MouseEvent e) { 284 if(dragIcon) 285 { 286 mouse=e.getPoint(); 287 //restrict to GPS track 288 iconPosition=player.getInterpolatedWaypoint(mouse); 289 290 Main.map.mapView.repaint(); 291 } 292 } 293 294 //visualize drag&drop 295 public void mouseMoved(MouseEvent e) { 296 if (player.getCurr()!=null) 297 { 298 if (getIconRect().contains(e.getPoint())) 299 { 300 Main.map.mapView.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); 301 } 302 else 303 { 304 Main.map.mapView.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); 305 } 306 } 307 308 } 309 310 public void setGPSPlayer(GPSVideoPlayer player) { 311 this.gps = player; 312 313 } 314 315 public static void addObserver(PlayerObserver observer) { 316 316 317 317 observers.add(observer); -
applications/editors/josm/plugins/videomapping/src/org/openstreetmap/josm/plugins/videomapping/VideoMappingPlugin.java
r23173 r23193 49 49 //Here we manage properties and start the other classes 50 50 public class VideoMappingPlugin extends Plugin implements LayerChangeListener{ 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 { 172 173 } 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 51 private JMenu VMenu,VDeinterlacer; 52 private GpxData GPSTrack; 53 private List<WayPoint> ls; 54 private JosmAction VAdd,VRemove,VStart,Vbackward,Vforward,VJump,Vfaster,Vslower,Vloop; 55 private JRadioButtonMenuItem VIntBob,VIntNone,VIntLinear; 56 private JCheckBoxMenuItem VCenterIcon,VSubTitles; 57 private JMenuItem VJumpLength,VLoopLength; 58 private GPSVideoPlayer player; 59 private PositionLayer layer; 60 private final String VM_DEINTERLACER="videomapping.deinterlacer"; //where we store settings 61 private final String VM_MRU="videomapping.mru"; 62 private final String VM_AUTOCENTER="videomapping.autocenter"; 63 private final String VM_JUMPLENGTH="videomapping.jumplength"; 64 private final String VM_LOOPLENGTH="videomapping.looplength"; 65 private boolean autocenter; 66 private String deinterlacer; 67 private Integer jumplength,looplength; 68 private String mru; 69 //TODO What more to store during sessions? Size/Position 70 71 72 public VideoMappingPlugin(PluginInformation info) { 73 super(info); 74 MapView.addLayerChangeListener(this); 75 //Register for GPS menu 76 VMenu = Main.main.menu.addMenu(" Video", KeyEvent.VK_V, Main.main.menu.defaultMenuPos,ht("/Plugin/Videomapping"));//TODO no more ugly " video" hack 77 addMenuItems(); 78 enableControlMenus(true); 79 loadSettings(); 80 applySettings(); 81 //further plugin informations are provided by build.xml properties 82 } 83 84 //only use with GPS and own layers 85 public void activeLayerChange(Layer oldLayer, Layer newLayer) { 86 System.out.println(newLayer); 87 if (newLayer instanceof GpxLayer) 88 { 89 VAdd.setEnabled(true); 90 GPSTrack=((GpxLayer) newLayer).data; 91 //TODO append to GPS Layer menu 92 } 93 else 94 {/* 95 VAdd.setEnabled(false); 96 if(newLayer instanceof PositionLayer) 97 { 98 enableControlMenus(true); 99 } 100 else 101 { 102 enableControlMenus(false); 103 }*/ 104 } 105 106 } 107 108 public void layerAdded(Layer arg0) { 109 activeLayerChange(null,arg0); 110 } 111 112 public void layerRemoved(Layer arg0) { 113 } //well ok we have a local copy of the GPS track.... 114 115 //register main controls 116 private void addMenuItems() { 117 VAdd= new JosmAction(tr("Import Video"),"videomapping",tr("Sync a video against this GPS track"),null,false) { 118 private static final long serialVersionUID = 1L; 119 120 public void actionPerformed(ActionEvent arg0) { 121 JFileChooser fc = new JFileChooser("C:\\TEMP\\"); 122 //fc.setSelectedFile(new File(mru)); 123 if(fc.showOpenDialog(Main.main.parent)!=JFileChooser.CANCEL_OPTION) 124 { 125 saveSettings(); 126 ls=copyGPSLayer(GPSTrack); 127 enableControlMenus(true); 128 layer = new PositionLayer(fc.getSelectedFile().getName(),ls); 129 Main.main.addLayer(layer); 130 player = new GPSVideoPlayer(fc.getSelectedFile(), layer.player); 131 //TODO Check here if we can sync allready now 132 layer.setGPSPlayer(player); 133 layer.addObserver(player); 134 VAdd.setEnabled(false); 135 VRemove.setEnabled(true); 136 player.setSubtitleAction(VSubTitles); 137 } 138 } 139 140 }; 141 VRemove= new JosmAction(tr("Remove Video"),"videomapping",tr("removes current video from layer"),null,false) { 142 private static final long serialVersionUID = 1L; 143 144 public void actionPerformed(ActionEvent arg0) { 145 player.removeVideo(); 146 } 147 }; 148 149 VStart = new JosmAction(tr("Play/Pause"), "audio-playpause", tr("starts/pauses video playback"), 150 Shortcut.registerShortcut("videomapping:startstop","",KeyEvent.VK_NUMPAD5, Shortcut.GROUP_DIRECT), false) { 151 152 public void actionPerformed(ActionEvent e) { 153 if(player.playing()) player.pause(); else player.play(); 154 } 155 }; 156 Vbackward = new JosmAction(tr("Backward"), "audio-prev", tr("jumps n sec back"), 157 Shortcut.registerShortcut("videomapping:backward","",KeyEvent.VK_NUMPAD4, Shortcut.GROUP_DIRECT), false) { 158 public void actionPerformed(ActionEvent e) { 159 player.backward(); 160 161 } 162 }; 163 Vbackward = new JosmAction(tr("Jump To"), null, tr("jumps to the entered gps time"),null, false) { 164 public void actionPerformed(ActionEvent e) { 165 String s =JOptionPane.showInputDialog(tr("please enter GPS timecode"),"10:07:57"); 166 SimpleDateFormat format= new SimpleDateFormat("hh:mm:ss"); 167 Date t; 168 try { 169 t = format.parse(s); 170 if (t!=null) 171 { 172 player.jumpToGPSTime(t.getTime()); 173 } 174 } catch (ParseException e1) { 175 // TODO Auto-generated catch block 176 e1.printStackTrace(); 177 } 178 179 } 180 }; 181 Vforward= new JosmAction(tr("Forward"), "audio-next", tr("jumps n sec forward"), 182 Shortcut.registerShortcut("videomapping:forward","",KeyEvent.VK_NUMPAD6, Shortcut.GROUP_DIRECT), false) { 183 184 public void actionPerformed(ActionEvent e) { 185 player.forward(); 186 187 } 188 }; 189 Vfaster= new JosmAction(tr("Faster"), "audio-faster", tr("faster playback"), 190 Shortcut.registerShortcut("videomapping:faster","",KeyEvent.VK_NUMPAD8, Shortcut.GROUP_DIRECT), false) { 191 192 public void actionPerformed(ActionEvent e) { 193 player.faster(); 194 195 } 196 }; 197 Vslower= new JosmAction(tr("Slower"), "audio-slower", tr("slower playback"), 198 Shortcut.registerShortcut("videomapping:slower","",KeyEvent.VK_NUMPAD2, Shortcut.GROUP_DIRECT), false) { 199 200 public void actionPerformed(ActionEvent e) { 201 player.slower(); 202 203 } 204 }; 205 Vloop= new JosmAction(tr("Loop"), null, tr("loops n sec around current position"), 206 Shortcut.registerShortcut("videomapping:loop","",KeyEvent.VK_NUMPAD7, Shortcut.GROUP_DIRECT), false) { 207 208 public void actionPerformed(ActionEvent e) { 209 player.loop(); 210 211 } 212 }; 213 214 //now the options menu 215 VCenterIcon = new JCheckBoxMenuItem(new JosmAction(tr("Keep centered"), null, tr("follows the video icon automaticly"),null, false) { 216 217 public void actionPerformed(ActionEvent e) { 218 autocenter=VCenterIcon.isSelected(); 219 player.setAutoCenter(autocenter); 220 applySettings(); 221 saveSettings(); 222 223 } 224 }); 225 //now the options menu 226 VSubTitles = new JCheckBoxMenuItem(new JosmAction(tr("Subtitles"), null, tr("Show subtitles in video"),null, false) { 227 228 public void actionPerformed(ActionEvent e) { 229 player.toggleSubtitles(); 230 231 } 232 }); 233 234 VJumpLength = new JMenuItem(new JosmAction(tr("Jump length"), null, tr("Set the length of a jump"),null, false) { 235 236 public void actionPerformed(ActionEvent e) { 237 Object[] possibilities = {"200", "500", "1000", "2000", "10000"}; 238 String s = (String)JOptionPane.showInputDialog(Main.parent,tr("Jump in video for x ms"),tr("Jump length"),JOptionPane.QUESTION_MESSAGE,null,possibilities,jumplength); 239 jumplength=Integer.getInteger(s); 240 applySettings(); 241 saveSettings(); 242 } 243 }); 244 245 VLoopLength = new JMenuItem(new JosmAction(tr("Loop length"), null, tr("Set the length around a looppoint"),null, false) { 246 247 public void actionPerformed(ActionEvent e) { 248 Object[] possibilities = {"500", "1000", "3000", "5000", "10000"}; 249 String s = (String)JOptionPane.showInputDialog(Main.parent,tr("Jump in video for x ms"),tr("Loop length"),JOptionPane.QUESTION_MESSAGE,null,possibilities,looplength); 250 looplength=Integer.getInteger(s); 251 applySettings(); 252 saveSettings(); 253 254 } 255 }); 256 257 VDeinterlacer= new JMenu("Deinterlacer"); 258 VIntNone= new JRadioButtonMenuItem(new JosmAction(tr("none"), null, tr("no deinterlacing"),null, false) { 259 260 public void actionPerformed(ActionEvent e) { 261 deinterlacer=null; 262 applySettings(); 263 saveSettings(); 264 } 265 }); 266 VIntBob= new JRadioButtonMenuItem(new JosmAction("bob", null, tr("deinterlacing using line doubling"),null, false) { 267 268 public void actionPerformed(ActionEvent e) { 269 deinterlacer="bob"; 270 applySettings(); 271 saveSettings(); 272 } 273 }); 274 VIntLinear= new JRadioButtonMenuItem(new JosmAction("linear", null, tr("deinterlacing using linear interpolation"),null, false) { 275 276 public void actionPerformed(ActionEvent e) { 277 deinterlacer="linear"; 278 applySettings(); 279 saveSettings(); 280 } 281 }); 282 VDeinterlacer.add(VIntNone); 283 VDeinterlacer.add(VIntBob); 284 VDeinterlacer.add(VIntLinear); 285 286 VMenu.add(VAdd); 287 VMenu.add(VStart); 288 VMenu.add(Vbackward); 289 VMenu.add(Vforward); 290 VMenu.add(Vfaster); 291 VMenu.add(Vslower); 292 VMenu.add(Vloop); 293 VMenu.addSeparator(); 294 VMenu.add(VCenterIcon); 295 VMenu.add(VJumpLength); 296 VMenu.add(VLoopLength); 297 VMenu.add(VDeinterlacer); 298 VMenu.add(VSubTitles); 299 300 } 301 302 303 304 //we can only work on our own layer 305 private void enableControlMenus(boolean enabled) 306 { 307 VStart.setEnabled(enabled); 308 Vbackward.setEnabled(enabled); 309 Vforward.setEnabled(enabled); 310 Vloop.setEnabled(enabled); 311 } 312 313 //load all properties or set defaults 314 private void loadSettings() { 315 String temp; 316 temp=Main.pref.get(VM_AUTOCENTER); 317 if((temp!=null)&&(temp.length()!=0))autocenter=Boolean.getBoolean(temp); else autocenter=false; 318 temp=Main.pref.get(VM_DEINTERLACER); 319 if((temp!=null)&&(temp.length()!=0)) deinterlacer=Main.pref.get(temp); 320 temp=Main.pref.get(VM_JUMPLENGTH); 321 if((temp!=null)&&(temp.length()!=0)) jumplength=Integer.valueOf(temp); else jumplength=1000; 322 temp=Main.pref.get(VM_LOOPLENGTH); 323 if((temp!=null)&&(temp.length()!=0)) looplength=Integer.valueOf(temp); else looplength=6000; 324 temp=Main.pref.get(VM_MRU); 325 if((temp!=null)&&(temp.length()!=0)) mru=Main.pref.get(VM_MRU);else mru=System.getProperty("user.home"); 326 } 327 328 private void applySettings(){ 329 //Internals 330 if(player!=null) 331 { 332 player.setAutoCenter(autocenter); 333 player.setDeinterlacer(deinterlacer); 334 player.setJumpLength(jumplength); 335 player.setLoopLength(looplength); 336 } 337 //GUI 338 VCenterIcon.setSelected(autocenter); 339 VIntNone.setSelected(true); 340 if(deinterlacer=="bob")VIntBob.setSelected(true); 341 if(deinterlacer=="linear")VIntLinear.setSelected(true); 342 343 } 344 345 private void saveSettings(){ 346 Main.pref.put(VM_AUTOCENTER, autocenter); 347 Main.pref.put(VM_DEINTERLACER, deinterlacer); 348 Main.pref.put(VM_JUMPLENGTH, jumplength.toString()); 349 Main.pref.put(VM_LOOPLENGTH, looplength.toString()); 350 Main.pref.put(VM_MRU, mru); 351 } 352 353 //make a flat copy 354 private List<WayPoint> copyGPSLayer(GpxData route) 355 { 356 ls = new LinkedList<WayPoint>(); 357 357 for (GpxTrack trk : route.tracks) { 358 358 for (GpxTrackSegment segment : trk.getSegments()) { … … 362 362 Collections.sort(ls); //sort basing upon time 363 363 return ls; 364 364 } 365 365 } -
applications/editors/josm/plugins/videomapping/src/org/openstreetmap/josm/plugins/videomapping/video/GPSVideoFile.java
r21631 r23193 4 4 // a specific synced video 5 5 public class GPSVideoFile extends File{ 6 7 8 9 10 11 6 public long offset; //time difference in ms between GPS and Video track 7 8 public GPSVideoFile(File f, long offset) { 9 super(f.getAbsoluteFile().toString()); 10 this.offset=offset; 11 } 12 12 13 13 } -
applications/editors/josm/plugins/videomapping/src/org/openstreetmap/josm/plugins/videomapping/video/GPSVideoPlayer.java
r23173 r23193 22 22 //combines video and GPS playback, major control has the video player 23 23 public class GPSVideoPlayer implements PlayerObserver{ 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 } 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 24 Timer t; 25 TimerTask updateGPSTrack; 26 private GpsPlayer gps; 27 private SimpleVideoPlayer video; 28 private JButton syncBtn; 29 private GPSVideoFile file; 30 private boolean synced=false; //do we playback the players together? 31 private JCheckBoxMenuItem subtTitleComponent; 32 33 34 public GPSVideoPlayer(File f, final GpsPlayer pl) { 35 super(); 36 this.gps = pl; 37 //test sync 38 video = new SimpleVideoPlayer(); 39 /* 40 long gpsT=(9*60+20)*1000; 41 long videoT=10*60*1000+5*1000; 42 setFile(new GPSVideoFile(f, gpsT-videoT)); */ 43 setFile(new GPSVideoFile(f, 0L)); 44 //add Sync Button to the Player 45 syncBtn= new JButton("sync"); 46 syncBtn.setBackground(Color.RED); 47 syncBtn.addActionListener(new ActionListener() { 48 //do a sync 49 public void actionPerformed(ActionEvent e) { 50 long diff=gps.getRelativeTime()-video.getTime(); 51 file= new GPSVideoFile(file, diff); 52 syncBtn.setBackground(Color.GREEN); 53 synced=true; 54 markSyncedPoints(); 55 video.play(); 56 //gps.play(); 57 } 58 }); 59 setAsyncMode(true); 60 video.addComponent(syncBtn); 61 //a observer to communicate 62 SimpleVideoPlayer.addObserver(new PlayerObserver() { //TODO has o become this 63 64 public void playing(long time) { 65 //sync the GPS back 66 if(synced) gps.jump(getGPSTime(time)); 67 68 } 69 70 public void jumping(long time) { 71 72 } 73 74 //a push way to set video attirbutes 75 public void metadata(long time, boolean subtitles) { 76 if(subtTitleComponent!=null) subtTitleComponent.setSelected(subtitles); 77 } 78 79 }); 80 t = new Timer(); 81 } 82 83 //marks all points that are covered by video AND GPS track 84 private void markSyncedPoints() { 85 //GPS or video stream starts first in time? 86 WayPoint start,end; 87 long t; 88 if(gps.getLength()<video.getLength()) 89 { 90 //GPS is within video timeperiod 91 start=gps.getWaypoint(0); 92 end=gps.getWaypoint(gps.getLength()); 93 } 94 else 95 { 96 //video is within gps timeperiod 97 t=getGPSTime(0); 98 if(t<0) t=0; 99 start=gps.getWaypoint(t); 100 end=gps.getWaypoint(getGPSTime(video.getLength())); 101 } 102 //mark as synced 103 List<WayPoint> ls = gps.getTrack().subList(gps.getTrack().indexOf(start), gps.getTrack().indexOf(end)); 104 105 for (WayPoint wp : ls) { 106 wp.attr.put("synced", "true"); 107 } 108 } 109 110 public void setAsyncMode(boolean b) 111 { 112 if(b) 113 { 114 syncBtn.setVisible(true); 115 } 116 else 117 { 118 syncBtn.setVisible(false); 119 } 120 } 121 122 123 public void setFile(GPSVideoFile f) 124 { 125 126 file=f; 127 video.setFile(f.getAbsoluteFile()); 128 //video.play(); 129 } 130 131 public void play(long gpsstart) 132 { 133 //video is already playing 134 jumpToGPSTime(gpsstart); 135 gps.jump(gpsstart); 136 //gps.play(); 137 } 138 139 public void play() 140 { 141 video.play(); 142 } 143 144 public void pause() 145 { 146 video.pause(); 147 } 148 149 //jumps in video to the corresponding linked time 150 public void jumpToGPSTime(Time GPSTime) 151 { 152 gps.jump(GPSTime); 153 } 154 155 //jumps in video to the corresponding linked time 156 public void jumpToGPSTime(long gpsT) 157 { 158 if(!synced) 159 { 160 //when not synced we can just move the icon to the right position 161 gps.jump(new Date(gpsT)); 162 Main.map.mapView.repaint(); 163 } 164 video.jump(getVideoTime(gpsT)); 165 } 166 167 //calc synced timecode from video 168 private long getVideoTime(long GPStime) 169 { 170 return GPStime-file.offset; 171 } 172 173 //calc corresponding GPS time 174 private long getGPSTime(long videoTime) 175 { 176 return videoTime+file.offset; 177 } 178 179 180 181 public void setJumpLength(Integer integer) { 182 video.setJumpLength(integer); 183 184 } 185 186 public void setLoopLength(Integer integer) { 187 video.setLoopLength(integer); 188 189 } 190 191 public boolean isSynced() 192 { 193 return isSynced(); 194 } 195 196 public void loop() { 197 video.loop(); 198 199 } 200 201 public void forward() { 202 video.forward(); 203 204 } 205 206 public void backward() { 207 video.backward(); 208 209 } 210 211 public void removeVideo() { 212 video.removeVideo(); 213 214 } 215 216 public File getVideo() { 217 return file; 218 } 219 220 public float getCoverage() { 221 return gps.getLength()/video.getLength(); 222 } 223 224 public void setDeinterlacer(String string) { 225 video.setDeinterlacer(string); 226 227 } 228 229 public void setAutoCenter(boolean selected) { 230 gps.setAutoCenter(selected); 231 232 } 233 234 235 //not called by GPS 236 public boolean playing() { 237 return video.playing(); 238 } 239 240 //when we clicked on the layer, here we update the video position 241 public void jumping(long time) { 242 if(synced) jumpToGPSTime(gps.getRelativeTime()); 243 244 } 245 246 public String getNativePlayerInfos() { 247 return video.getNativePlayerInfos(); 248 } 249 250 public void faster() { 251 video.faster(); 252 253 } 254 255 public void slower() { 256 video.slower(); 257 258 } 259 260 public void playing(long time) { 261 // TODO Auto-generated method stub 262 263 } 264 265 public void toggleSubtitles() { 266 video.toggleSubs(); 267 268 } 269 270 public boolean hasSubtitles(){ 271 return video.hasSubtitles(); 272 } 273 274 public void setSubtitleAction(JCheckBoxMenuItem a) 275 { 276 subtTitleComponent=a; 277 } 278 279 public void metadata(long time, boolean subtitles) { 280 // TODO Auto-generated method stub 281 282 } 283 284 285 286 287 288 288 } -
applications/editors/josm/plugins/videomapping/src/org/openstreetmap/josm/plugins/videomapping/video/SimpleVideoPlayer.java
r22690 r23193 49 49 //basic class of a videoplayer for one video 50 50 public class SimpleVideoPlayer extends JFrame implements MediaPlayerEventListener, WindowListener{ 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 } 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 } 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 51 private EmbeddedMediaPlayer mp; 52 private Timer t; 53 private JPanel screenPanel,controlsPanel; 54 private JSlider timeline; 55 private JButton play,back,forward; 56 private JToggleButton loop,mute; 57 private JSlider speed; 58 private Canvas scr; 59 private final String[] mediaOptions = {""}; 60 private boolean syncTimeline=false; 61 private boolean looping=false; 62 private SimpleDateFormat ms; 63 private static final Logger LOG = Logger.getLogger(MediaPlayerFactory.class); 64 private int jumpLength=1000; 65 private int loopLength=6000; 66 private static Set<PlayerObserver> observers = new HashSet<PlayerObserver>(); //we have to implement our own Observer pattern 67 68 public SimpleVideoPlayer() { 69 super(); 70 /*TODO new EnvironmentCheckerFactory().newEnvironmentChecker().checkEnvironment(); 71 * if(RuntimeUtil.isWindows()) { 72 vlcArgs.add("--plugin-path=" + WindowsRuntimeUtil.getVlcInstallDir() + "\\plugins"); 73 } 74 */ 75 try 76 { 77 //we don't need any options 78 String[] libvlcArgs = {""}; 79 String[] standardMediaOptions = {""}; 80 81 //System.out.println("libvlc version: " + LibVlc.INSTANCE.libvlc_get_version()); 82 //setup Media Player 83 //TODO we have to deal with unloading things.... 84 MediaPlayerFactory mediaPlayerFactory = new MediaPlayerFactory(libvlcArgs); 85 FullScreenStrategy fullScreenStrategy = new DefaultFullScreenStrategy(this); 86 mp = mediaPlayerFactory.newMediaPlayer(fullScreenStrategy); 87 mp.setStandardMediaOptions(standardMediaOptions); 88 //setup GUI 89 setSize(400, 300); //later we apply movie size 90 setAlwaysOnTop(true); 91 createUI(); 92 setLayout(); 93 addListeners(); //registering shortcuts is task of the outer plugin class! 94 //embed vlc player 95 scr.setVisible(true); 96 setVisible(true); 97 mp.setVideoSurface(scr); 98 mp.addMediaPlayerEventListener(this); 99 //mp.pause(); 100 //jump(0); 101 //create updater 102 ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor(); 103 executorService.scheduleAtFixedRate(new Syncer(this), 0L, 1000L, TimeUnit.MILLISECONDS); 104 //setDefaultCloseOperation(EXIT_ON_CLOSE); 105 addWindowListener(this); 106 } 107 catch (NoClassDefFoundError e) 108 { 109 System.err.println(tr("Unable to find JNA Java library!")); 110 } 111 catch (UnsatisfiedLinkError e) 112 { 113 System.err.println(tr("Unable to find native libvlc library!")); 114 } 115 116 } 117 118 private void createUI() { 119 //setIconImage(); 120 ms = new SimpleDateFormat("hh:mm:ss"); 121 scr=new Canvas(); 122 timeline = new JSlider(0,100,0); 123 timeline.setMajorTickSpacing(10); 124 timeline.setMajorTickSpacing(5); 125 timeline.setPaintTicks(true); 126 //TODO we need Icons instead 127 play= new JButton(tr("play")); 128 back= new JButton("<"); 129 forward= new JButton(">"); 130 loop= new JToggleButton(tr("loop")); 131 mute= new JToggleButton(tr("mute")); 132 speed = new JSlider(-200,200,0); 133 speed.setMajorTickSpacing(100); 134 speed.setPaintTicks(true); 135 speed.setOrientation(Adjustable.VERTICAL); 136 Hashtable labelTable = new Hashtable(); 137 labelTable.put( new Integer( 0 ), new JLabel("1x") ); 138 labelTable.put( new Integer( -200 ), new JLabel("-2x") ); 139 labelTable.put( new Integer( 200 ), new JLabel("2x") ); 140 speed.setLabelTable( labelTable ); 141 speed.setPaintLabels(true); 142 } 143 144 //creates a layout like the most mediaplayers are... 145 private void setLayout() { 146 this.setLayout(new BorderLayout()); 147 screenPanel=new JPanel(); 148 screenPanel.setLayout(new BorderLayout()); 149 controlsPanel=new JPanel(); 150 controlsPanel.setLayout(new FlowLayout()); 151 add(screenPanel,BorderLayout.CENTER); 152 add(controlsPanel,BorderLayout.SOUTH); 153 //fill screen panel 154 screenPanel.add(scr,BorderLayout.CENTER); 155 screenPanel.add(timeline,BorderLayout.SOUTH); 156 screenPanel.add(speed,BorderLayout.EAST); 157 controlsPanel.add(play); 158 controlsPanel.add(back); 159 controlsPanel.add(forward); 160 controlsPanel.add(loop); 161 controlsPanel.add(mute); 162 loop.setSelected(false); 163 mute.setSelected(false); 164 } 165 166 //add UI functionality 167 private void addListeners() { 168 timeline.addChangeListener(new ChangeListener() { 169 public void stateChanged(ChangeEvent e) { 170 if(!syncTimeline) //only if user moves the slider by hand 171 { 172 if(!timeline.getValueIsAdjusting()) //and the slider is fixed 173 { 174 //recalc to 0.x percent value 175 mp.setPosition((float)timeline.getValue()/100.0f); 176 } 177 } 178 } 179 }); 180 181 play.addActionListener(new ActionListener() { 182 183 public void actionPerformed(ActionEvent arg0) { 184 if(mp.isPlaying()) mp.pause(); else mp.play(); 185 } 186 }); 187 188 back.addActionListener(new ActionListener() { 189 190 public void actionPerformed(ActionEvent arg0) { 191 backward(); 192 } 193 }); 194 195 forward.addActionListener(new ActionListener() { 196 197 public void actionPerformed(ActionEvent arg0) { 198 forward(); 199 } 200 }); 201 202 loop.addActionListener(new ActionListener() { 203 204 public void actionPerformed(ActionEvent arg0) { 205 loop(); 206 } 207 }); 208 209 mute.addActionListener(new ActionListener() { 210 211 public void actionPerformed(ActionEvent arg0) { 212 mute(); 213 } 214 }); 215 216 speed.addChangeListener(new ChangeListener() { 217 218 public void stateChanged(ChangeEvent arg0) { 219 if(!speed.getValueIsAdjusting()&&(mp.isPlaying())) 220 { 221 int perc = speed.getValue(); 222 float ratio= (float) (perc/400f*1.75); 223 ratio=ratio+(9/8); 224 mp.setRate(ratio); 225 } 226 227 } 228 }); 229 230 } 231 232 public void finished(MediaPlayer arg0) { 233 234 } 235 236 public void lengthChanged(MediaPlayer arg0, long arg1) { 237 238 } 239 240 public void metaDataAvailable(MediaPlayer arg0, VideoMetaData data) { 241 final float perc = 0.5f; 242 Dimension org=data.getVideoDimension(); 243 scr.setSize(new Dimension((int)(org.width*perc), (int)(org.height*perc))); 244 pack(); 245 //send out metadatas to all observers 246 for (PlayerObserver o : observers) { 247 247 o.metadata(0, hasSubtitles()); 248 248 } 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 249 } 250 251 public void paused(MediaPlayer arg0) { 252 253 } 254 255 public void playing(MediaPlayer arg0) { 256 257 } 258 259 public void positionChanged(MediaPlayer arg0, float arg1) { 260 261 } 262 263 public void stopped(MediaPlayer arg0) { 264 265 } 266 267 public void timeChanged(MediaPlayer arg0, long arg1) { 268 269 } 270 271 272 public void windowActivated(WindowEvent arg0) { } 273 274 public void windowClosed(WindowEvent arg0) { } 275 276 //we have to unload and disconnect to the VLC engine 277 public void windowClosing(WindowEvent evt) { 278 278 if(LOG.isDebugEnabled()) {LOG.debug("windowClosing(evt=" + evt + ")");} 279 279 mp.release(); … … 282 282 } 283 283 284 285 286 287 288 289 290 }291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 else 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 284 public void windowDeactivated(WindowEvent arg0) { } 285 286 public void windowDeiconified(WindowEvent arg0) { } 287 288 public void windowIconified(WindowEvent arg0) { } 289 290 public void windowOpened(WindowEvent arg0) { } 291 292 public void setFile(File f) 293 { 294 String mediaPath = f.getAbsoluteFile().toString(); 295 mp.playMedia(mediaPath, mediaOptions); 296 pack(); 297 } 298 299 public void play() 300 { 301 mp.play(); 302 } 303 304 public void jump(long time) 305 { 306 /*float pos = (float)mp.getLength()/(float)time; 307 mp.setPosition(pos);*/ 308 mp.setTime(time); 309 } 310 311 public long getTime() 312 { 313 return mp.getTime(); 314 } 315 316 public float getPosition() 317 { 318 return mp.getPosition(); 319 } 320 321 public boolean isPlaying() 322 { 323 return mp.isPlaying(); 324 } 325 326 //gets called by the Syncer thread to update all observers 327 public void updateTime () 328 { 329 if(mp.isPlaying()) 330 { 331 setTitle(ms.format(new Date(mp.getTime()))); 332 syncTimeline=true; 333 timeline.setValue(Math.round(mp.getPosition()*100)); 334 syncTimeline=false; 335 notifyObservers(mp.getTime()); 336 } 337 } 338 339 //allow externals to extend the ui 340 public void addComponent(JComponent c) 341 { 342 controlsPanel.add(c); 343 pack(); 344 } 345 346 public long getLength() { 347 return mp.getLength(); 348 } 349 350 public void setDeinterlacer(String string) { 351 mp.setDeinterlace(string); 352 353 } 354 355 public void setJumpLength(Integer integer) { 356 jumpLength=integer; 357 358 } 359 360 public void setLoopLength(Integer integer) { 361 loopLength = integer; 362 363 } 364 365 public void loop() { 366 if(looping) 367 { 368 t.cancel(); 369 looping=false; 370 } 371 else 372 { 373 final long resetpoint=(long) mp.getTime()-loopLength/2; 374 TimerTask ani=new TimerTask() { 375 376 @Override 377 public void run() { 378 mp.setTime(resetpoint); 379 } 380 }; 381 t= new Timer(); 382 t.schedule(ani,loopLength/2,loopLength); //first run a half looptime till reset 383 looping=true; 384 } 385 386 } 387 388 protected void mute() { 389 mp.mute(); 390 391 } 392 393 public void forward() { 394 mp.setTime((long) (mp.getTime()+jumpLength)); 395 } 396 397 public void backward() { 398 mp.setTime((long) (mp.getTime()-jumpLength)); 399 400 } 401 402 public void removeVideo() { 403 if (mp.isPlaying()) mp.stop(); 404 mp.release(); 405 406 } 407 408 public void toggleSubs() 409 { 410 //vlc manages it's subtitles in a own list so we have to cycle trough 411 int spu = mp.getSpu(); 412 412 if(spu > -1) { 413 413 spu++; … … 420 420 } 421 421 mp.setSpu(spu); 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 422 } 423 424 public static void addObserver(PlayerObserver observer) { 425 426 observers.add(observer); 427 428 } 429 430 431 432 public static void removeObserver(PlayerObserver observer) { 433 434 observers.remove(observer); 435 436 } 437 438 private static void notifyObservers(long newTime) { 439 440 for (PlayerObserver o : observers) { 441 o.playing(newTime); 442 } 443 444 } 445 446 public String getNativePlayerInfos() { 447 return "VLC "+LibVlc.INSTANCE.libvlc_get_version(); 448 } 449 450 public void faster() { 451 speed.setValue(speed.getValue()+100); 452 453 } 454 455 public void slower() { 456 speed.setValue(speed.getValue()-100); 457 458 } 459 460 public void pause() { 461 if (mp.isPlaying()) mp.pause(); 462 463 } 464 465 public boolean playing() { 466 return mp.isPlaying(); 467 } 468 469 public void error(MediaPlayer arg0) { 470 // TODO Auto-generated method stub 471 472 } 473 474 public void mediaChanged(MediaPlayer arg0) { 475 // TODO Auto-generated method stub 476 477 } 478 479 public boolean hasSubtitles() { 480 if (mp.getSpuCount()==0) return false; else return true; 481 } 482 483 484 484 485 485 } -
applications/editors/josm/plugins/videomapping/src/org/openstreetmap/josm/plugins/videomapping/video/Syncer.java
r21656 r23193 17 17 public void run() { 18 18 SwingUtilities.invokeLater(new Runnable() { 19 19 //here we update 20 20 public void run() { 21 21 if (pl.isPlaying()) pl.updateTime(); //if the video is seeking we get a mess 22 22 } 23 23 }); -
applications/editors/josm/plugins/videomapping/test/videotest.java
r22690 r23193 21 21 public class videotest { 22 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 23 /** 24 * @param args 25 */ 26 public static void main(String[] args) { 27 final SimpleVideoPlayer sVP = new SimpleVideoPlayer(); 28 sVP.setFile(new File("C:\\TEMP\\122_0159.MOV")); 29 //sVP.play(); //FIXME We have a bug so we get out of sync if we jump before the video is up (and this we CAN'T DETECT!!!) 30 /* 31 JButton b = new JButton("jump"); 32 b.addActionListener(new ActionListener() { 33 34 public void actionPerformed(ActionEvent e) { 35 sVP.jump(610000); 36 } 37 }); 38 sVP.add(b); 39 */ 40 } 41 41 42 42 }
Note:
See TracChangeset
for help on using the changeset viewer.