Changeset 33086 in osm for applications/editors/josm/plugins/imagewaypoint
- Timestamp:
- 2016-11-25T23:38:21+01:00 (8 years ago)
- Location:
- applications/editors/josm/plugins/imagewaypoint
- Files:
-
- 1 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/imagewaypoint/.project
r32286 r33086 16 16 </arguments> 17 17 </buildCommand> 18 <buildCommand> 19 <name>net.sf.eclipsecs.core.CheckstyleBuilder</name> 20 <arguments> 21 </arguments> 22 </buildCommand> 18 23 </buildSpec> 19 24 <natures> 20 25 <nature>org.eclipse.jdt.core.javanature</nature> 26 <nature>net.sf.eclipsecs.core.CheckstyleNature</nature> 21 27 </natures> 22 28 </projectDescription> -
applications/editors/josm/plugins/imagewaypoint/src/org/insignificant/josm/plugins/imagewaypoint/IImageChangeListener.java
r13497 r33086 1 // License: GPL. For details, see LICENSE file. 1 2 package org.insignificant.josm.plugins.imagewaypoint; 2 3 -
applications/editors/josm/plugins/imagewaypoint/src/org/insignificant/josm/plugins/imagewaypoint/ImageEntries.java
r32915 r33086 1 // License: GPL. For details, see LICENSE file. 1 2 package org.insignificant.josm.plugins.imagewaypoint; 2 3 … … 18 19 private final ImageEntries imageEntries; 19 20 20 publicImageReadyListener(final ImageEntries imageEntries) {21 ImageReadyListener(final ImageEntries imageEntries) { 21 22 this.imageEntries = imageEntries; 22 23 } 23 24 24 25 @Override 25 public finalvoid onImageReady(final ImageEntry imageEntry,26 public void onImageReady(final ImageEntry imageEntry, 26 27 final Image image) { 27 28 this.imageEntries.setCurrentImage(imageEntry, image); … … 49 50 } 50 51 51 public static finalImageEntries getInstance() {52 public static ImageEntries getInstance() { 52 53 return ImageEntries.INSTANCE; 53 54 } 54 55 55 public finalvoid addListener(final IImageChangeListener listener) {56 public void addListener(final IImageChangeListener listener) { 56 57 this.listeners.add(listener); 57 58 } 58 59 59 public finalvoid removeListener(final IImageChangeListener listener) {60 public void removeListener(final IImageChangeListener listener) { 60 61 this.listeners.remove(listener); 61 62 } 62 63 63 public finalvoid add(final File[] imageFiles) {64 public void add(final File[] imageFiles) { 64 65 if (null != imageFiles) { 65 66 for (int index = 0; index < imageFiles.length; index++) { … … 70 71 } 71 72 72 public finalvoid associateAllLayers() {73 public void associateAllLayers() { 73 74 for (int index = 0; index < this.images.size(); index++) { 74 75 this.images.get(index).setWayPoint(null); … … 92 93 } 93 94 94 private finalvoid doAssociateLayer(final GpxLayer gpxLayer) {95 private void doAssociateLayer(final GpxLayer gpxLayer) { 95 96 if (null != gpxLayer && null != gpxLayer.data 96 97 && !gpxLayer.data.fromServer) { … … 109 110 } 110 111 111 private final List<String> getTextContentsFromWayPoint( 112 final WayPoint wayPoint) { 113 final List<String> texts = new ArrayList<>(); 114 for(String s : new String[]{"name", "cmt", "desc"}) 115 { 116 String t = wayPoint.getString(s); 117 if(null != t && 0 < t.length()) 118 texts.add(t); 119 } 120 121 return texts; 112 private List<String> getTextContentsFromWayPoint( 113 final WayPoint wayPoint) { 114 final List<String> texts = new ArrayList<>(); 115 for (String s : new String[]{"name", "cmt", "desc"}) { 116 String t = wayPoint.getString(s); 117 if (null != t && 0 < t.length()) 118 texts.add(t); 119 } 120 121 return texts; 122 122 } 123 123 … … 132 132 // } 133 133 134 private finalImageEntry findImageEntryWithFileName(final String fileName) {134 private ImageEntry findImageEntryWithFileName(final String fileName) { 135 135 ImageEntry foundimage = null; 136 136 … … 146 146 } 147 147 148 private final void setCurrentImage(final ImageEntry imageEntry, 149 final Image image) { 148 private void setCurrentImage(final ImageEntry imageEntry, final Image image) { 150 149 if (imageEntry == this.currentImageEntry) { 151 150 this.currentImage = image; … … 157 156 } 158 157 159 public finalImageEntry[] getImages() {158 public ImageEntry[] getImages() { 160 159 return this.locatedImages.toArray(new ImageEntry[this.locatedImages.size()]); 161 160 } 162 161 163 public finalImageEntry getCurrentImageEntry() {162 public ImageEntry getCurrentImageEntry() { 164 163 return this.currentImageEntry; 165 164 } 166 165 167 public finalImage getCurrentImage() {166 public Image getCurrentImage() { 168 167 return this.currentImage; 169 168 } 170 169 171 public finalboolean hasNext() {170 public boolean hasNext() { 172 171 return null != this.currentImageEntry 173 172 && this.locatedImages.indexOf(this.currentImageEntry) < this.locatedImages.size() - 1; 174 173 } 175 174 176 public finalboolean hasPrevious() {175 public boolean hasPrevious() { 177 176 return null != this.currentImageEntry 178 177 && this.locatedImages.indexOf(this.currentImageEntry) > 0; 179 178 } 180 179 181 public finalvoid next() {180 public void next() { 182 181 if (null != this.currentImageEntry 183 182 && this.locatedImages.indexOf(this.currentImageEntry) < this.locatedImages.size() - 1) { … … 186 185 } 187 186 188 public finalvoid previous() {187 public void previous() { 189 188 if (null != this.currentImageEntry 190 189 && this.locatedImages.indexOf(this.currentImageEntry) > 0) { … … 193 192 } 194 193 195 public finalvoid rotateCurrentImageLeft() {194 public void rotateCurrentImageLeft() { 196 195 if (null != this.currentImageEntry) { 197 196 this.currentImageEntry.setOrientation(this.currentImageEntry.getOrientation() … … 202 201 } 203 202 204 public finalvoid rotateCurrentImageRight() {203 public void rotateCurrentImageRight() { 205 204 if (null != this.currentImageEntry) { 206 205 this.currentImageEntry.setOrientation(this.currentImageEntry.getOrientation() … … 211 210 } 212 211 213 public finalvoid setCurrentImageEntry(final ImageEntry imageEntry) {212 public void setCurrentImageEntry(final ImageEntry imageEntry) { 214 213 if (null == imageEntry || this.locatedImages.contains(imageEntry)) { 215 214 if (null != this.currentImageEntry) … … 219 218 this.currentImage = null; 220 219 221 for (IImageChangeListener listener : this.listeners) 220 for (IImageChangeListener listener : this.listeners) { 222 221 listener.onSelectedImageEntryChanged(this); 223 224 if(imageEntry != null) // now try to get the image 222 } 223 224 if (imageEntry != null) // now try to get the image 225 225 this.currentImageEntry.requestImage(this.listener); 226 226 } -
applications/editors/josm/plugins/imagewaypoint/src/org/insignificant/josm/plugins/imagewaypoint/ImageEntry.java
r32915 r33086 1 /** 2 * 3 */ 1 // License: GPL. For details, see LICENSE file. 4 2 package org.insignificant.josm.plugins.imagewaypoint; 5 3 … … 29 27 private final ImageEntry imageEntry; 30 28 31 publicObserver(final ImageEntry imageEntry) {29 Observer(final ImageEntry imageEntry) { 32 30 this.imageEntry = imageEntry; 33 31 } … … 40 38 */ 41 39 @Override 42 public finalboolean imageUpdate(final Image image,40 public boolean imageUpdate(final Image image, 43 41 final int infoflags, final int x, final int y, final int width, 44 42 final int height) { … … 72 70 } 73 71 74 public finalOrientation rotateRight() {72 public Orientation rotateRight() { 75 73 if (this.index < Orientation.orientations.length - 1) { 76 74 return Orientation.orientations[this.index + 1]; … … 80 78 } 81 79 82 public finalOrientation rotateLeft() {80 public Orientation rotateLeft() { 83 81 if (this.index == 0) { 84 82 return Orientation.orientations[Orientation.orientations.length - 1]; … … 121 119 122 120 @Override 123 public final int compareTo(final ImageEntry image) { 124 return this.fileName.compareTo(image.fileName); 125 } 126 127 public final String getFileName() { 128 return fileName; 129 } 130 131 public final WayPoint getWayPoint() { 132 return wayPoint; 133 } 134 135 public final void setWayPoint(final WayPoint wayPoint) { 136 this.wayPoint = wayPoint; 137 } 138 139 public final Orientation getOrientation() { 140 return orientation; 141 } 142 143 public final void setOrientation(final Orientation orientation) { 144 this.orientation = orientation; 145 this.normalImage = null; 146 this.rotatedImage = null; 147 } 148 149 public final Rectangle getBounds(final MapView mapView) { 150 final Rectangle bounds; 151 152 if (null == this.wayPoint) { 153 bounds = null; 154 } else { 155 final Point point = mapView.getPoint(this.getWayPoint().getCoor()); 156 bounds = new Rectangle(point.x - ImageEntry.ICON_WIDTH, 157 point.y - ImageEntry.ICON_HEIGHT, 158 ImageEntry.ICON_WIDTH, 159 ImageEntry.ICON_WIDTH); 160 } 161 162 return bounds; 163 } 164 165 public final void requestImage(final IImageReadyListener imageReadyListener) { 166 this.listener = imageReadyListener; 167 168 if (null == this.rotatedImage) { 169 final Image image = Toolkit.getDefaultToolkit() 170 .getImage(this.filePath); 171 if (Toolkit.getDefaultToolkit().prepareImage(image, 172 -1, 173 -1, 174 this.observer)) { 175 this.imageLoaded(image); 176 } 177 } else if (null != this.listener) { 178 this.listener.onImageReady(this, this.rotatedImage); 179 } 180 } 181 182 public final void flush() { 183 if (null != this.normalImage) { 184 this.normalImage.flush(); 121 public int compareTo(final ImageEntry image) { 122 return this.fileName.compareTo(image.fileName); 123 } 124 125 public String getFileName() { 126 return fileName; 127 } 128 129 public WayPoint getWayPoint() { 130 return wayPoint; 131 } 132 133 public void setWayPoint(final WayPoint wayPoint) { 134 this.wayPoint = wayPoint; 135 } 136 137 public Orientation getOrientation() { 138 return orientation; 139 } 140 141 public void setOrientation(final Orientation orientation) { 142 this.orientation = orientation; 185 143 this.normalImage = null; 186 }187 188 if (null != this.rotatedImage) {189 this.rotatedImage.flush();190 144 this.rotatedImage = null; 191 145 } 192 } 193 194 private final void imageLoaded(final Image image) { 146 147 public Rectangle getBounds(final MapView mapView) { 148 final Rectangle bounds; 149 150 if (null == this.wayPoint) { 151 bounds = null; 152 } else { 153 final Point point = mapView.getPoint(this.getWayPoint().getCoor()); 154 bounds = new Rectangle(point.x - ImageEntry.ICON_WIDTH, 155 point.y - ImageEntry.ICON_HEIGHT, 156 ImageEntry.ICON_WIDTH, 157 ImageEntry.ICON_WIDTH); 158 } 159 160 return bounds; 161 } 162 163 public void requestImage(final IImageReadyListener imageReadyListener) { 164 this.listener = imageReadyListener; 165 166 if (null == this.rotatedImage) { 167 final Image image = Toolkit.getDefaultToolkit() 168 .getImage(this.filePath); 169 if (Toolkit.getDefaultToolkit().prepareImage(image, 170 -1, 171 -1, 172 this.observer)) { 173 this.imageLoaded(image); 174 } 175 } else if (null != this.listener) { 176 this.listener.onImageReady(this, this.rotatedImage); 177 } 178 } 179 180 public void flush() { 181 if (null != this.normalImage) { 182 this.normalImage.flush(); 183 this.normalImage = null; 184 } 185 186 if (null != this.rotatedImage) { 187 this.rotatedImage.flush(); 188 this.rotatedImage = null; 189 } 190 } 191 192 private void imageLoaded(final Image image) { 195 193 if (Orientation.NORMAL == this.getOrientation()) { 196 194 this.rotatedImage = image; -
applications/editors/josm/plugins/imagewaypoint/src/org/insignificant/josm/plugins/imagewaypoint/ImageWayPointDialog.java
r32915 r33086 1 // License: GPL. For details, see LICENSE file. 1 2 package org.insignificant.josm.plugins.imagewaypoint; 2 3 … … 26 27 private Image image; 27 28 28 publicImageComponent() {29 ImageComponent() { 29 30 this.image = null; 30 31 } 31 32 32 33 @Override 33 public finalvoid paint(final Graphics g) {34 public void paint(final Graphics g) { 34 35 if (null == this.image || 0 >= this.image.getWidth(null) 35 36 || 0 >= this.image.getHeight(null)) { … … 71 72 } 72 73 73 public finalvoid setImage(final Image image) {74 public void setImage(final Image image) { 74 75 this.image = image; 75 76 this.repaint(); … … 81 82 private final ImageWayPointDialog dialog; 82 83 83 publicImageChangeListener(final ImageWayPointDialog dialog) {84 ImageChangeListener(final ImageWayPointDialog dialog) { 84 85 this.dialog = dialog; 85 86 } 86 87 87 88 @Override 88 public finalvoid onAvailableImageEntriesChanged(89 public void onAvailableImageEntriesChanged( 89 90 final ImageEntries entries) { 90 91 this.dialog.imageDisplay.setImage(entries.getCurrentImage()); … … 93 94 94 95 @Override 95 public finalvoid onSelectedImageEntryChanged(final ImageEntries entries) {96 public void onSelectedImageEntryChanged(final ImageEntries entries) { 96 97 this.dialog.imageDisplay.setImage(entries.getCurrentImage()); 97 98 this.dialog.updateUI(); … … 101 102 private static final class PreviousAction extends JosmAction { 102 103 103 publicPreviousAction() {104 super(tr("Previous"),105 null,106 tr("Previous image"),107 null,108 false);109 }110 111 @Override112 public finalvoid actionPerformed(final ActionEvent actionEvent) {113 if (ImageEntries.getInstance().hasPrevious()) {114 ImageEntries.getInstance().previous();115 }116 }104 PreviousAction() { 105 super(tr("Previous"), 106 null, 107 tr("Previous image"), 108 null, 109 false); 110 } 111 112 @Override 113 public void actionPerformed(final ActionEvent actionEvent) { 114 if (ImageEntries.getInstance().hasPrevious()) { 115 ImageEntries.getInstance().previous(); 116 } 117 } 117 118 } 118 119 119 120 private static final class NextAction extends JosmAction { 120 121 121 publicNextAction() {122 super(tr("Next"), null, tr("Next image"), null, false);123 }124 125 @Override126 public finalvoid actionPerformed(final ActionEvent actionEvent) {127 if (ImageEntries.getInstance().hasNext()) {128 ImageEntries.getInstance().next();129 }130 }122 NextAction() { 123 super(tr("Next"), null, tr("Next image"), null, false); 124 } 125 126 @Override 127 public void actionPerformed(final ActionEvent actionEvent) { 128 if (ImageEntries.getInstance().hasNext()) { 129 ImageEntries.getInstance().next(); 130 } 131 } 131 132 } 132 133 133 134 private static final class RotateLeftAction extends JosmAction { 134 135 135 publicRotateLeftAction() {136 super(tr("Rotate left"),137 null,138 tr("Rotate image left"),139 null,140 false);141 }142 143 @Override144 public finalvoid actionPerformed(final ActionEvent actionEvent) {145 ImageEntries.getInstance().rotateCurrentImageLeft();146 }136 RotateLeftAction() { 137 super(tr("Rotate left"), 138 null, 139 tr("Rotate image left"), 140 null, 141 false); 142 } 143 144 @Override 145 public void actionPerformed(final ActionEvent actionEvent) { 146 ImageEntries.getInstance().rotateCurrentImageLeft(); 147 } 147 148 } 148 149 149 150 private static final class RotateRightAction extends JosmAction { 150 151 151 publicRotateRightAction() {152 super(tr("Rotate right"),153 null,154 tr("Rotate image right"),155 null,156 false);157 }158 159 @Override160 public finalvoid actionPerformed(final ActionEvent actionEvent) {161 ImageEntries.getInstance().rotateCurrentImageRight();162 }152 RotateRightAction() { 153 super(tr("Rotate right"), 154 null, 155 tr("Rotate image right"), 156 null, 157 false); 158 } 159 160 @Override 161 public void actionPerformed(final ActionEvent actionEvent) { 162 ImageEntries.getInstance().rotateCurrentImageRight(); 163 } 163 164 } 164 165 … … 212 213 } 213 214 214 private finalvoid updateUI() {215 this.previousAction.setEnabled(ImageEntries.getInstance().hasPrevious());216 this.nextAction.setEnabled(ImageEntries.getInstance().hasNext());217 this.rotateLeftAction.setEnabled(null != ImageEntries.getInstance()218 .getCurrentImageEntry());219 this.rotateRightAction.setEnabled(null != ImageEntries.getInstance()220 .getCurrentImageEntry());221 222 if (null != Main.map) {223 Main.map.repaint();224 }215 private void updateUI() { 216 this.previousAction.setEnabled(ImageEntries.getInstance().hasPrevious()); 217 this.nextAction.setEnabled(ImageEntries.getInstance().hasNext()); 218 this.rotateLeftAction.setEnabled(null != ImageEntries.getInstance() 219 .getCurrentImageEntry()); 220 this.rotateRightAction.setEnabled(null != ImageEntries.getInstance() 221 .getCurrentImageEntry()); 222 223 if (null != Main.map) { 224 Main.map.repaint(); 225 } 225 226 } 226 227 227 228 public static ImageWayPointDialog getInstance() { 228 return ImageWayPointDialog.INSTANCE;229 } 230 231 public finalToggleDialog getDisplayComponent() {232 return this.dialog;229 return ImageWayPointDialog.INSTANCE; 230 } 231 232 public ToggleDialog getDisplayComponent() { 233 return this.dialog; 233 234 } 234 235 } -
applications/editors/josm/plugins/imagewaypoint/src/org/insignificant/josm/plugins/imagewaypoint/ImageWayPointLayer.java
r32915 r33086 1 // License: GPL. For details, see LICENSE file. 1 2 package org.insignificant.josm.plugins.imagewaypoint; 2 3 … … 23 24 private final ImageWayPointLayer layer; 24 25 25 publicImageWayPointMouseListener(final ImageWayPointLayer layer) {26 ImageWayPointMouseListener(final ImageWayPointLayer layer) { 26 27 this.layer = layer; 27 28 } 28 29 29 30 @Override 30 public finalvoid mouseClicked(final MouseEvent event) {31 public void mouseClicked(final MouseEvent event) { 31 32 if (MouseEvent.BUTTON1 == event.getButton() && this.layer.isVisible()) { 32 33 final ImageEntry[] images = ImageEntries.getInstance() … … 53 54 private static final class ImageChangeListener implements IImageChangeListener { 54 55 @Override 55 public final void onAvailableImageEntriesChanged( 56 final ImageEntries entries) { 56 public void onAvailableImageEntriesChanged(final ImageEntries entries) { 57 57 Main.map.repaint(); 58 58 } 59 59 60 60 @Override 61 public finalvoid onSelectedImageEntryChanged(final ImageEntries entries) {61 public void onSelectedImageEntryChanged(final ImageEntries entries) { 62 62 Main.map.repaint(); 63 63 } … … 80 80 81 81 @Override 82 public finalIcon getIcon() {82 public Icon getIcon() { 83 83 return ImageProvider.get("dialogs/imagewaypoint"); 84 84 } 85 85 86 86 @Override 87 public finalObject getInfoComponent() {87 public Object getInfoComponent() { 88 88 return null; 89 89 } 90 90 91 91 @Override 92 public finalAction[] getMenuEntries() {92 public Action[] getMenuEntries() { 93 93 return new Action[0]; 94 94 } 95 95 96 96 @Override 97 public finalString getToolTipText() {97 public String getToolTipText() { 98 98 // TODO 99 99 return ""; … … 101 101 102 102 @Override 103 public finalboolean isMergable(final Layer other) {103 public boolean isMergable(final Layer other) { 104 104 // TODO 105 105 return false; … … 107 107 108 108 @Override 109 public finalvoid mergeFrom(final Layer from) {109 public void mergeFrom(final Layer from) { 110 110 // TODO not supported yet 111 111 } 112 112 113 113 @Override 114 public finalvoid paint(final Graphics2D graphics, final MapView mapView, Bounds box) {114 public void paint(final Graphics2D graphics, final MapView mapView, Bounds box) { 115 115 final ImageEntry[] images = ImageEntries.getInstance().getImages(); 116 116 … … 139 139 140 140 @Override 141 public finalvoid visitBoundingBox(final BoundingXYVisitor visitor) {141 public void visitBoundingBox(final BoundingXYVisitor visitor) { 142 142 final ImageEntry[] images = ImageEntries.getInstance().getImages(); 143 143 … … 153 153 154 154 @Override 155 public finalvoid destroy() {155 public void destroy() { 156 156 super.destroy(); 157 157 -
applications/editors/josm/plugins/imagewaypoint/src/org/insignificant/josm/plugins/imagewaypoint/ImageWayPointPlugin.java
r32288 r33086 1 // License: GPL. For details, see LICENSE file. 1 2 package org.insignificant.josm.plugins.imagewaypoint; 2 3 … … 21 22 private final class ImageWaypointImporter extends FileImporter { 22 23 23 publicImageWaypointImporter() {24 ImageWaypointImporter() { 24 25 super(new ExtensionFileFilter("jpg,jpeg,png,gif", "jpg", "Image files [by ImageWayPoint plugin] (*.jpg, *.jpeg, *.png, *.gif)")); 25 26 } … … 38 39 public void importData(List<File> files, ProgressMonitor progressMonitor) throws IOException, IllegalDataException { 39 40 if (null != files && !files.isEmpty()) { 40 41 41 42 // recursively find all files 42 43 final List<File> allFiles = new ArrayList<>(); … … 72 73 public ImageWayPointPlugin(PluginInformation info) { 73 74 super(info); 74 75 ExtensionFileFilter.addImporter(new ImageWaypointImporter()); 75 76 } 76 77 77 78 @Override 78 public final void mapFrameInitialized(final MapFrame oldFrame, 79 final MapFrame newFrame) { 79 public void mapFrameInitialized(final MapFrame oldFrame, final MapFrame newFrame) { 80 80 if (newFrame != null) { 81 81 newFrame.addToggleDialog(ImageWayPointDialog.getInstance()
Note:
See TracChangeset
for help on using the changeset viewer.