Changeset 18404 in osm for applications/editors/josm/plugins/piclayer
- Timestamp:
- 2009-11-01T13:19:59+01:00 (15 years ago)
- Location:
- applications/editors/josm/plugins/piclayer
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/piclayer/build.xml
r17323 r18404 81 81 <attribute name="Plugin-Date" value="${version.entry.commit.date}"/> 82 82 <attribute name="Plugin-Description" value="This plugin allows to display any picture as a background in the editor and align it with the map."/> 83 <attribute name="Plugin-Mainversion" value=" 1728"/>83 <attribute name="Plugin-Mainversion" value="2323"/> 84 84 <attribute name="Plugin-Version" value="${version.entry.commit.revision}"/> 85 85 </manifest> -
applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/PicLayerPlugin.java
r17321 r18404 21 21 package org.openstreetmap.josm.plugins.piclayer; 22 22 23 import static org.openstreetmap.josm.gui.help.HelpUtil.ht; 24 import static org.openstreetmap.josm.tools.I18n.tr; 25 23 26 import java.awt.event.KeyEvent; 24 27 import javax.swing.JMenu; … … 35 38 */ 36 39 public class PicLayerPlugin extends Plugin implements LayerChangeListener { 37 38 // Plugin menu39 private JMenu m_menu = null;40 41 // Toolbar buttons42 private IconToggleButton m_movePictureButton = null;43 private IconToggleButton m_rotatePictureButton = null;44 private IconToggleButton m_scalexPictureButton = null;45 private IconToggleButton m_scaleyPictureButton = null;46 private IconToggleButton m_scalexyPictureButton = null;47 48 // Menu actions49 private NewLayerFromFileAction m_newFromFileAction = null;50 private NewLayerFromClipboardAction m_newFromClipAction = null;51 40 52 /** 53 * Constructor... 54 */ 55 public PicLayerPlugin() { 56 57 // Create menu entry 58 if ( Main.main.menu != null ) { 59 m_menu = Main.main.menu.addMenu( "PicLayer" , KeyEvent.VK_I, Main.main.menu.defaultMenuPos ); 60 } 61 62 // Add menu items 63 if ( m_menu != null ) { 64 m_menu.add( m_newFromFileAction = new NewLayerFromFileAction() ); 65 m_menu.add( m_newFromClipAction = new NewLayerFromClipboardAction() ); 66 m_menu.addSeparator(); 67 m_menu.add( new HelpAction() ); 68 m_newFromFileAction.setEnabled( false ); 69 m_newFromClipAction.setEnabled( false ); 70 } 71 72 // Listen to layers 73 Layer.listeners.add( this ); 74 75 } 76 41 // Plugin menu 42 private JMenu m_menu = null; 43 44 // Toolbar buttons 45 private IconToggleButton m_movePictureButton = null; 46 private IconToggleButton m_rotatePictureButton = null; 47 private IconToggleButton m_scalexPictureButton = null; 48 private IconToggleButton m_scaleyPictureButton = null; 49 private IconToggleButton m_scalexyPictureButton = null; 50 51 // Menu actions 52 private NewLayerFromFileAction m_newFromFileAction = null; 53 private NewLayerFromClipboardAction m_newFromClipAction = null; 54 55 /** 56 * Constructor... 57 */ 58 public PicLayerPlugin() { 59 60 // Create menu entry 61 if ( Main.main.menu != null ) { 62 m_menu = Main.main.menu.addMenu(tr("PicLayer") , KeyEvent.VK_I, Main.main.menu.defaultMenuPos, ht("/Plugin/PicLayer")); 63 } 64 65 // Add menu items 66 if ( m_menu != null ) { 67 m_menu.add( m_newFromFileAction = new NewLayerFromFileAction() ); 68 m_menu.add( m_newFromClipAction = new NewLayerFromClipboardAction() ); 69 m_menu.addSeparator(); 70 m_menu.add( new HelpAction() ); 71 m_newFromFileAction.setEnabled( false ); 72 m_newFromClipAction.setEnabled( false ); 73 } 74 75 // Listen to layers 76 Layer.listeners.add( this ); 77 78 } 79 77 80 /** 78 81 * Called when the map is created. Creates the toolbar buttons. … … 80 83 public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) { 81 84 if(newFrame != null) { 82 83 84 85 86 87 88 89 85 // Create plugin map modes 86 MovePictureAction movePictureAction = new MovePictureAction(newFrame); 87 RotatePictureAction rotatePictureAction = new RotatePictureAction(newFrame); 88 ScaleXYPictureAction scaleXYPictureAction = new ScaleXYPictureAction(newFrame); 89 ScaleXPictureAction scaleXPictureAction = new ScaleXPictureAction(newFrame); 90 ScaleYPictureAction scaleYPictureAction = new ScaleYPictureAction(newFrame); 91 // Create plugin buttons and add them to the toolbar 92 m_movePictureButton = new IconToggleButton(movePictureAction); 90 93 m_rotatePictureButton = new IconToggleButton(rotatePictureAction); 91 94 m_scalexyPictureButton = new IconToggleButton(scaleXYPictureAction); … … 109 112 } 110 113 111 112 113 114 115 114 /** 115 * The toolbar buttons shall be active only when the PicLayer is active. 116 */ 117 public void activeLayerChange(Layer oldLayer, Layer newLayer) { 118 } 116 119 117 118 119 120 121 122 123 124 125 120 /** 121 * The menu is enabled once another layer is first created. This is needed 122 * because the picture must be positioned based on the current mapview (so 123 * one must exist first). User should not be able to load a picture too early. 124 */ 125 public void layerAdded(Layer arg0) { 126 m_newFromFileAction.setEnabled( true ); 127 m_newFromClipAction.setEnabled( true ); 128 } 126 129 127 /** 128 * When all layers are gone - the menu is gone too. 129 */ 130 public void layerRemoved(Layer arg0) { 131 boolean enable = Main.map.mapView.getAllLayers().size() != 0; 132 m_newFromFileAction.setEnabled( enable ); 133 m_newFromClipAction.setEnabled( enable ); 134 } 135 130 /** 131 * When all layers are gone - the menu is gone too. 132 */ 133 public void layerRemoved(Layer arg0) { 134 boolean enable = Main.map.mapView.getAllLayers().size() != 0; 135 m_newFromFileAction.setEnabled( enable ); 136 m_newFromClipAction.setEnabled( enable ); 137 } 136 138 };
Note:
See TracChangeset
for help on using the changeset viewer.