Ignore:
Timestamp:
2010-05-16T12:43:01+02:00 (14 years ago)
Author:
guardian
Message:

animated per point fly

Location:
applications/editors/josm/plugins/videomapping
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/videomapping/src/org/openstreetmap/josm/plugins/videomapping/PositionLayer.java

    r21295 r21299  
    22
    33
     4import java.util.ArrayList;
     5import java.util.Collection;
    46import java.util.Iterator;
     7import java.util.List;
    58import java.util.Timer;
    69import java.util.TimerTask;
     
    1215import java.awt.Point;
    1316import java.awt.Rectangle;
     17import java.awt.event.KeyEvent;
     18import java.awt.event.KeyListener;
    1419import java.awt.event.MouseEvent;
    1520import java.awt.event.MouseListener;
     
    2227import org.openstreetmap.josm.data.Bounds;
    2328import org.openstreetmap.josm.data.gpx.GpxData;
     29import org.openstreetmap.josm.data.gpx.WayPoint;
    2430import org.openstreetmap.josm.data.osm.DataSet;
    2531import org.openstreetmap.josm.data.osm.Node;
     
    3137import org.openstreetmap.josm.tools.ImageProvider;
    3238
    33 public class PositionLayer extends Layer implements MouseListener {
    34         private DataSet ds;
    35         private Node sel;
    36         private Iterator<Node> it;
    37                
    38         public PositionLayer(String name, final DataSet ds) {
     39public class PositionLayer extends Layer implements MouseListener, KeyListener {
     40        private List<WayPoint> ls;
     41        private Collection<WayPoint> selected;
     42        private WayPoint sel;
     43        private Iterator<WayPoint> it;
     44               
     45        public PositionLayer(String name, final List<WayPoint> ls) {
    3946                super(name);           
    40                 this.ds = ds;
    41                 Main.map.mapView.addMouseListener(this);               
    42                 Timer t  = new Timer();
    43                 it=ds.getNodes().iterator();
    44                
     47                this.ls = ls;
     48                selected = new ArrayList<WayPoint>();
     49                Main.map.mapView.addMouseListener(this);
     50                Main.map.mapView.addKeyListener(this);
     51                it=ls.iterator();
     52                Timer t  = new Timer();         
    4553                t.schedule(new TimerTask() {
    4654                       
     
    4957                                // TODO Auto-generated method stub
    5058                                sel=it.next();
    51                                 System.out.println(sel.getTimestamp());
     59                                System.out.println(sel.getTime());
    5260                                Main.map.mapView.repaint();
    5361                        }
    54                 },1000,1000);
     62                },100,100);
    5563               
    5664        }
     
    103111        public void paint(Graphics2D g, MapView map, Bounds bound) {
    104112                Point p;
    105                 for(Node n: ds.getNodes()) {
     113                g.setColor(Color.green);
     114                for(WayPoint n: ls) {
    106115                        p = Main.map.mapView.getPoint(n.getEastNorth());
    107                         if(n.isHighlighted())
    108                         {
    109                                 g.setColor(Color.red);
    110                                 g.drawString(n.getTimestamp().toString(), p.x+10, p.y);
     116                        g.drawOval(p.x - 2, p.y - 2, 4, 4); // small circles
    111117                        }
    112                         else
    113                         {
    114                                 g.setColor(Color.green);
    115                         }
     118                g.setColor(Color.red);
     119                for(WayPoint n:selected)
     120                {
     121                        p = Main.map.mapView.getPoint(n.getEastNorth());
    116122                        g.drawOval(p.x - 2, p.y - 2, 4, 4); // small circles
    117123                }
    118124                if (sel!=null){
    119                         p=Main.map.mapView.getPoint(sel.getEastNorth());;
    120                         g.setColor(Color.CYAN);
    121                         g.drawRect(p.x, p.y, 100, 100);
     125                        p=Main.map.mapView.getPoint(sel.getEastNorth());
     126                        //TODO Source out redundant calculations
     127                        //TODO make icon transparent
     128                        ImageProvider.get("videomapping.png").paintIcon(null, g, p.x-ImageProvider.get("videomapping.png").getIconWidth()/2, p.y-ImageProvider.get("videomapping.png").getIconHeight()/2);                                     
    122129                };
    123130        }
     
    133140                //only on leftclicks of our layer
    134141                if(e.getButton() == MouseEvent.BUTTON1) {
    135                         JOptionPane.showMessageDialog(Main.parent,"test");
     142                        //JOptionPane.showMessageDialog(Main.parent,"test");
    136143                        getNearestNode(e.getPoint());
    137144                        Main.map.mapView.repaint();
     
    145152                Rectangle rect = new Rectangle(mouse, new Dimension(30, 30));           
    146153                //iterate through all possible notes
    147                 for(Node node : ds.getNodes())
     154                for(WayPoint n : ls)
    148155                {
    149                         p = Main.map.mapView.getPoint(node);
     156                        p = Main.map.mapView.getPoint(n.getEastNorth());
    150157                        if (rect.contains(p))
    151158                        {                               
    152                                 node.setHighlighted(true);
     159                                selected.add(n);
     160                                sel=n;
    153161                        }
    154162                       
     
    176184        }
    177185
     186        public void keyPressed(KeyEvent e) {
     187                System.out.println(e.getKeyCode());
     188                switch(e.getKeyCode())
     189                {
     190                        case KeyEvent.VK_LEFT: sel = ls.get(50);
     191                }
     192               
     193        }
     194
     195        public void keyReleased(KeyEvent e) {
     196                // TODO Auto-generated method stub
     197               
     198        }
     199
     200        public void keyTyped(KeyEvent e) {
     201                // TODO Auto-generated method stub
     202               
     203        }
     204
    178205}
  • applications/editors/josm/plugins/videomapping/src/org/openstreetmap/josm/plugins/videomapping/VideoAction.java

    r21295 r21299  
    33import java.awt.event.ActionEvent;
    44import java.io.File;
     5import java.util.Collections;
     6import java.util.LinkedList;
    57import java.util.List;
    68
     
    3537       
    3638                copyGPSLayer();
    37                 Main.main.addLayer(new PositionLayer("test",ds));
     39                Main.main.addLayer(new PositionLayer("test",ls));
    3840        }
    3941               
     
    4547        //makes a private flat copy for interaction
    4648        private void copyGPSLayer()
    47         {
    48                 //TODO we assume that GPS points are in the correct order!
    49                 ds = new DataSet();
    50             for (GpxTrack trk : gps.tracks) {
    51                 for (GpxTrackSegment segment : trk.getSegments()) {
    52                     Way w = new Way();
    53                     for (WayPoint p : segment.getWayPoints()) {
    54                         Node n = new Node(p.getCoor());
    55                         String timestr = p.getString("time");
    56                         if(timestr != null)
    57                             n.setTimestamp(DateUtils.fromString(timestr));
    58                         ds.addPrimitive(n);
    59                         w.addNode(n);
    60                         //ls.add
    61                     }
    62                     ds.addPrimitive(w);
    63                 }
     49        {
     50                ls = new LinkedList<WayPoint>();
     51        for (GpxTrack trk : gps.tracks) {
     52            for (GpxTrackSegment segment : trk.getSegments()) {
     53                ls.addAll(segment.getWayPoints());
    6454            }
     55        }
     56        Collections.sort(ls); //sort basing upon time
    6557        }
    6658
  • applications/editors/josm/plugins/videomapping/src/org/openstreetmap/josm/plugins/videomapping/VideoMappingPlugin.java

    r21295 r21299  
    3030                super(info);
    3131                //Register for GPS menu
    32                 VMenu = Main.main.menu.addMenu(tr(" Video"), KeyEvent.VK_V, Main.main.menu.defaultMenuPos,ht("/Plugin/Videomapping"));//TODO no more ugly " video" hack
     32                VMenu = Main.main.menu.addMenu(" Video", KeyEvent.VK_V, Main.main.menu.defaultMenuPos,ht("/Plugin/Videomapping"));//TODO no more ugly " video" hack
    3333                VMenu.setEnabled(false); //enabled only on GPS Layers
    3434                VAction = new VideoAction();
Note: See TracChangeset for help on using the changeset viewer.