Trajectories.java
Go to the documentation of this file.
00001 package edu.tum.cs.ias.knowrob.vis.items;
00002 
00003 import java.util.Vector;
00004 
00005 import edu.tum.cs.ias.knowrob.vis.Canvas;
00006 
00007 
00008 
00009 public class Trajectories extends ItemBase{
00010         public float pointSize = 0.0f, sphereSize = 120.0f;
00011         public int pointColor = 0xffcbcbcb, sphereColor = 0x99ffff00;
00012         public int lineColor = 0xffffffff;
00013         public Vector<Point> pointsTraj;
00014         public Vector<Point> point;
00015         public int cont =0;
00016         
00017         public Trajectories() {
00018                 pointsTraj = new Vector<Point>();
00019         }
00020         
00021         public void addTraj(float x, float y, float z) {
00022                 pointsTraj.add(new Point(x, y, z, pointColor, pointSize));
00023         }
00024         
00025         public void addPoint(float x, float y, float z, float radius){
00026                 point.add(new Point(x,y,z,pointColor, pointSize));
00027         }
00028         
00029         public void draw(Canvas c, int step) {
00030                 c.pushMatrix();
00031                 //c.scale(100);
00032                 
00033                 Point prev=null;
00034                 c.sphereDetail(3);
00035         
00036                 for(Point p : pointsTraj) {
00037                 p.draw(c);
00038                 //System.out.println("p.v= "+p.v);
00039                 if (cont<=0 && p.v.x!=0 ){
00040                         prev=p; 
00041                         //System.out.println("prev: "+prev.v);
00042                         
00043                         cont++;
00044                 } else if (p.v.x !=0) {
00045                          // draw line connecting previous point with current point
00046                                 //System.out.println("prev: " +prev.v +" current: "+p.v);
00047                                 c.drawLine(prev.v, p.v, lineColor);
00048                                 
00049                                 //add the point
00050                                 prev = p;
00051                                 //System.out.println("p.v= "+p.v);
00052                         } else if (p.v.x==0){
00053                                 cont=0;
00054                                 //lineColor=0xFFFF0000;
00055                                 //System.out.println("0000000");
00056                           }
00057                         
00058                 }
00059                 c.sphereDetail(30);
00060                 c.popMatrix();
00061         }
00062         
00063 }


mod_vis
Author(s): Moritz Tenorth, Jakob Engel
autogenerated on Sat Dec 28 2013 17:09:49