Changeset 29377 in osm for applications/editors/josm/plugins/imagery_offset_db/src/iodb/OffsetDialogButton.java
- Timestamp:
- 2013-03-20T08:05:48+01:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/imagery_offset_db/src/iodb/OffsetDialogButton.java
r29371 r29377 1 1 package iodb; 2 2 3 import java.awt.Component; 4 import java.awt.Dimension; 5 import java.awt.Graphics; 6 import javax.swing.Icon; 7 import javax.swing.ImageIcon; 3 8 import javax.swing.JButton; 9 import org.openstreetmap.josm.gui.layer.ImageryLayer; 10 import org.openstreetmap.josm.tools.ImageProvider; 4 11 5 12 /** … … 11 18 12 19 private ImageryOffsetBase offset; 20 private double offsetLength; 21 private double distance; 22 private double direction; 13 23 14 24 public OffsetDialogButton( ImageryOffsetBase offset ) { 15 super(offset.getDescription() + " (" + Math.round(offset.getPosition().greatCircleDistance(ImageryOffsetTools.getMapCenter())) + " m)"); 25 super(); 26 // todo: fix layout 27 setMinimumSize(new Dimension(500, 80)); 28 setMaximumSize(new Dimension(500, 140)); 29 setText("<html>" 30 + Math.round(offset.getPosition().greatCircleDistance(ImageryOffsetTools.getMapCenter())) + " m: " 31 + offset.getDescription() + "</html>"); 32 setIcon(new OffsetIcon(offset)); 16 33 this.offset = offset; 34 35 offsetLength = offset instanceof ImageryOffset ? getLengthAndDirection((ImageryOffset)offset)[0] : 0.0; 36 // todo: layout, info, map distance and direction 17 37 } 18 38 … … 20 40 return offset; 21 41 } 22 42 43 /* @Override 44 public Dimension getPreferredSize() { 45 return new Dimension(500, super.getPreferredSize().height); 46 }*/ 47 48 private double[] getLengthAndDirection( ImageryOffset offset ) { 49 ImageryLayer layer = ImageryOffsetTools.getTopImageryLayer(); 50 double[] dxy = layer == null ? new double[] {0.0, 0.0} : new double[] {layer.getDx(), layer.getDy()}; 51 return OffsetInfoAction.getLengthAndDirection((ImageryOffset)offset, dxy[0], dxy[1]); 52 } 53 54 class OffsetIcon implements Icon { 55 private boolean isDeprecated; 56 private boolean isCalibration; 57 private double direction; 58 private double length; 59 private ImageIcon background; 60 61 public OffsetIcon( ImageryOffsetBase offset ) { 62 isDeprecated = offset.isDeprecated(); 63 isCalibration = offset instanceof CalibrationObject; 64 if( offset instanceof ImageryOffset ) { 65 background = ImageProvider.get("offset"); 66 ImageryLayer layer = ImageryOffsetTools.getTopImageryLayer(); 67 double[] dxy = layer == null ? new double[] {0.0, 0.0} : new double[] { layer.getDx(), layer.getDy() }; 68 double[] ld = OffsetInfoAction.getLengthAndDirection((ImageryOffset)offset, dxy[0], dxy[1]); 69 length = ld[0]; 70 direction = ld[1]; 71 } else { 72 background = ImageProvider.get("calibration"); 73 } 74 } 75 76 public void paintIcon( Component c, Graphics g, int x, int y ) { 77 background.paintIcon(c, g, x, y); 78 // todo: draw an arrow 79 // todo: apply deprecation 80 } 81 82 public int getIconWidth() { 83 return background.getIconWidth(); 84 } 85 86 public int getIconHeight() { 87 return background.getIconHeight(); 88 } 89 } 23 90 }
Note:
See TracChangeset
for help on using the changeset viewer.
