Changeset 29377 in osm for applications/editors/josm/plugins/imagery_offset_db/src/iodb/OffsetInfoAction.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/OffsetInfoAction.java
r29371 r29377 2 2 3 3 import java.awt.event.ActionEvent; 4 import java.text.SimpleDateFormat; 4 5 import javax.swing.AbstractAction; 5 6 import javax.swing.JOptionPane; 6 7 import org.openstreetmap.josm.Main; 8 import org.openstreetmap.josm.data.coor.LatLon; 7 9 import static org.openstreetmap.josm.tools.I18n.tr; 8 10 import org.openstreetmap.josm.tools.ImageProvider; … … 14 16 */ 15 17 public class OffsetInfoAction extends AbstractAction { 16 private ImageryOffsetBase offset; 18 public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd"); 19 20 private Object info; 17 21 18 22 public OffsetInfoAction( ImageryOffsetBase offset ) { 19 23 super(tr("Offset Information")); 20 putValue(SMALL_ICON, ImageProvider.get("dialogs", "delete")); 21 this.offset = offset; 24 putValue(SMALL_ICON, ImageProvider.get("info")); 25 if( offset != null ) 26 this.info = getInformationObject(offset); 22 27 setEnabled(offset != null); 23 28 } 24 29 25 30 public void actionPerformed(ActionEvent e) { 26 JOptionPane.showMessageDialog(Main.parent, "TODO", ImageryOffsetTools.DIALOG_TITLE, JOptionPane.PLAIN_MESSAGE); 31 JOptionPane.showMessageDialog(Main.parent, info, ImageryOffsetTools.DIALOG_TITLE, JOptionPane.PLAIN_MESSAGE); 32 } 33 34 public static Object getInformationObject( ImageryOffsetBase offset ) { 35 StringBuilder sb = new StringBuilder(); 36 if( offset instanceof ImageryOffset ) { 37 double[] ld = getLengthAndDirection((ImageryOffset)offset); 38 sb.append(tr("An imagery offset of {0} m to {1}", ld[0], explainDirection(ld[1]))).append('\n'); 39 sb.append("Imagery ID: ").append(((ImageryOffset)offset).getImagery()); 40 } else 41 sb.append(tr("A calibration {0}", getGeometryType((CalibrationObject)offset))); 42 sb.append("\n\nCreated by ").append(offset.getAuthor()); 43 sb.append(" on ").append(DATE_FORMAT.format(offset.getDate())).append("\n"); 44 sb.append("Description: ").append(offset.getDescription()); 45 if( offset.isDeprecated() ) { 46 sb.append("\n\nThis geometry was marked obsolete\n"); 47 sb.append("by ").append(offset.getAbandonAuthor()); 48 sb.append(" on ").append(DATE_FORMAT.format(offset.getAbandonDate())).append("\n"); 49 sb.append("Reason: ").append(offset.getAbandonReason()); 50 } 51 return sb.toString(); 52 } 53 54 public static String getGeometryType( CalibrationObject obj ) { 55 if( obj.getGeometry() == null ) 56 return tr("nothing"); 57 int n = obj.getGeometry().length; 58 if( n == 1 ) 59 return tr("point"); 60 else if( n > 1 && !obj.getGeometry()[0].equals(obj.getGeometry()[n - 1]) ) 61 return tr("path ({0} nodes)", n); 62 else if( n > 1 && obj.getGeometry()[0].equals(obj.getGeometry()[n - 1]) ) 63 return tr("polygon ({0} nodes)", n - 1); 64 else 65 return "geometry"; 66 } 67 68 public static double[] getLengthAndDirection( ImageryOffset offset ) { 69 return getLengthAndDirection(offset, 0.0, 0.0); 70 } 71 72 public static double[] getLengthAndDirection( ImageryOffset offset, double dx, double dy ) { 73 double length = 0.0; 74 double direction = 0.0; 75 // todo: calculate length and angular direction 76 return new double[] { length, direction }; 77 } 78 79 public static String explainDirection( double dir ) { 80 return "nowhere"; // todo 27 81 } 28 82 }
Note:
See TracChangeset
for help on using the changeset viewer.
