00001 package de.tum.in.fipm.kipm.gui.visualisation.applets;
00002
00003 import java.awt.event.ActionEvent;
00004 import java.awt.event.ActionListener;
00005 import java.awt.event.KeyEvent;
00006 import java.awt.event.MouseEvent;
00007 import java.awt.event.MouseListener;
00008 import java.awt.event.MouseMotionListener;
00009 import java.io.BufferedReader;
00010
00011 import java.io.IOException;
00012
00013 import java.util.ArrayList;
00014 import java.util.HashMap;
00015 import java.util.Vector;
00016
00017 import javax.swing.JFrame;
00018 import javax.swing.JOptionPane;
00019 import javax.swing.Timer;
00020
00021 import peasy.PeasyCam;
00022 import peasy.CameraState;
00023 import peasy.org.apache.commons.math.geometry.*;
00024
00025 import processing.core.PFont;
00026 import processing.core.PMatrix;
00027
00028 import de.tum.in.fipm.kipm.gui.visualisation.base.PrologVisualizationCanvas;
00029 import de.tum.in.fipm.kipm.gui.visualisation.items.*;
00030 import de.tum.in.fipm.kipm.util.datastructures.Point;
00031
00032 import edu.tum.cs.vis.AnimatedCanvas;
00033 import edu.tum.cs.vis.Canvas;
00034 import edu.tum.cs.vis.model.ItemModel;
00035
00036
00037
00038 public class StandaloneKitchenVisApplet extends AnimatedCanvas implements MouseListener, MouseMotionListener {
00039
00040 static final long serialVersionUID=0;
00041
00042 public static final double ROTATE_Y_DELTA = 0.05;
00043
00045
00046
00047
00048
00050
00051
00052
00053
00055
00056 private PFont verdana;
00057 private PFont verdanaBold;
00058 private PFont dejavu;
00059 private ArrayList<int[]> colors = new ArrayList<int[]>(12);
00060 private PrologVisualizationCanvas prologVisCanvas = null;
00061 public MenuHuman menu_human = new MenuHuman();
00062
00063
00065
00066 private int[] grayValues = new int[] {160,190,210,170,220,180,200,165,185,205,175,195,215};
00067 private static int grayLevelCounter = 0;
00068 private EmptyCanvas buffer;
00069 private JFrame bufferFrame;
00070
00071
00072
00074
00075
00080 private HashMap<String,ItemBase> animatedItemsRef = new HashMap<String, ItemBase>();
00081 private ArrayList<ItemBase> allItems = new ArrayList<ItemBase>();
00082 private ArrayList<float[]> meshpoints = new ArrayList<float[]>();
00083 private ArrayList<int[]> meshtriangles = new ArrayList<int[]>();
00084 private float[] framesToTimes;
00085
00086
00088
00089 private int numberFrames = 1;
00090 private int currentFrame = 0;
00091
00092 PeasyCam cam;
00093
00094
00095
00097
00098 private boolean drawMeshes = true;
00099 public boolean isInitialized = false;
00100 private boolean playingForward = true;
00101 boolean record = false;
00102
00103
00107
00108
00109
00110
00115 public void setup() {
00116
00117 size(700, 600, P3D);
00118
00119
00120
00121 cam = new PeasyCam(this, 0,0,0, 50);
00122
00123
00124 cam.setMinimumDistance(1);
00125 cam.setMaximumDistance(500);
00126
00127 cam.setRightDragHandler(cam.getPanDragHandler());
00128 cam.setLeftDragHandler(cam.getRotateDragHandler());
00129 cam.setDampingFactor(0.03);
00130
00131
00132 cam.setRotations(1.9074943, -0.6844337, 0.14366905);
00133
00134
00135 buffer = new EmptyCanvas(700,600,P3D);
00136
00137 verdana = createFont("Verdana", 11);
00138 verdanaBold = createFont("Verdana-Bold", 18);
00139 dejavu = createFont("DejaVu Sans",13);
00140 textFont(verdana);
00141 textFont(verdanaBold);
00142 textFont(dejavu);
00143
00144 ellipseMode(RADIUS);
00145
00146
00147 sphereDetail(10);
00148
00149
00150 setColors();
00151
00152
00153
00154 hint(ENABLE_DEPTH_TEST);
00155
00156
00157
00158
00159
00160
00161
00162 draw();
00163 isInitialized = true;
00164 if(prologVisCanvas != null) {
00165 prologVisCanvas.validate();
00166 prologVisCanvas.setSize(1270, 620);
00167 }
00168
00169
00170 }
00171
00172
00173
00174
00178
00179
00180
00181
00182
00186 @Override
00187 public void draw() {
00188 PMatrix save = getMatrix();
00189 try{
00190
00191
00192 if (record) {
00193 beginRaw(PDF, "output.pdf");
00194 }
00195
00196 scale(10);
00197
00198 background(20, 20, 20);
00199
00200 pushMatrix();
00201
00202 applyMatrix( 1, 0, 0, 0,
00203 0, 1, 0, 0,
00204 0, 0, -1, 0,
00205 0, 0, 0, 1);
00206 lights();
00207
00208 strokeWeight(1.5f);
00209 stroke(255, 0, 0); line(0, 0, 0, 500, 0, 0);
00210 stroke(0, 255, 0); line(0, 0, 0, 0, 500, 0);
00211 stroke(0, 0, 255); line(0, 0, 0, 0, 0, 500);
00212 stroke(0, 0, 0);
00213
00214
00215 if(drawMeshes)
00216 drawMeshes();
00217
00218
00219 for(int i=0;i<allItems.size();i++) {
00220
00221 allItems.get(i).draw(this, currentFrame);
00222 }
00223
00224 popMatrix();
00225
00226 if (record) {
00227 endRaw();
00228 System.err.println("Writing PDF...");
00229 record = false;
00230 }
00231
00232 }catch(ArrayIndexOutOfBoundsException e) {
00233 System.out.println("Some Drawing error occured... ");
00234 resetMatrix();
00235 record = false;
00236 applyMatrix(save);
00237 }
00238 }
00239
00240 private String getItemAt(int x, int y) {
00241
00242 String[] id = null;
00243 int clicked = -1;
00244
00245 try{
00246
00247
00248 buffer.setSize(700, 600);
00249
00250
00251 buffer.resetMatrix();
00252 cam.getState().apply(buffer);
00253 buffer.noLights();
00254 buffer.scale(10);
00255
00256 buffer.pushMatrix();
00257
00258
00259
00260 buffer.applyMatrix( 1, 0, 0, 0,
00261 0, 1, 0, 0,
00262 0, 0, -1, 0,
00263 0, 0, 0, 1);
00264 buffer.ellipseMode(RADIUS);
00265 buffer.pushMatrix();
00266
00267
00268 id = new String[allItems.size()];
00269 for(int i=0;i<allItems.size();i++) {
00270 ItemBase itm = allItems.get(i);
00271 itm.colorOverride = 0xff000000 | ( 1*i + 1);
00272 allItems.get(i).draw(buffer, currentFrame);
00273 itm.colorOverride = 0;
00274 id[i] = itm.name;
00275 }
00276
00277
00278 clicked = ((buffer.get(x,y)-1) & 0x00ffffff)/1;
00279
00280 buffer.freeze();
00281 buffer.redraw();
00282
00283 buffer.popMatrix();
00284 buffer.popMatrix();
00285
00286 }catch(Exception e){}
00287
00288 if(clicked >= 0 && clicked<id.length)
00289 return id[clicked];
00290 else
00291 return null;
00292 }
00293
00294
00295
00299 private void drawMeshes() {
00300
00301 pushMatrix();
00302 scale(100);
00303 strokeWeight(0.2f);
00304
00305
00306 stroke(90, 90, 90);
00307
00308
00309
00310 noFill();
00311
00312 beginShape(TRIANGLES);
00313
00314 for (int i = 0; i < meshtriangles.size(); i++) {
00315
00316 int p0 = meshtriangles.get(i)[0];
00317 int p1 = meshtriangles.get(i)[1];
00318 int p2 = meshtriangles.get(i)[2];
00319
00320 vertex(meshpoints.get(p0)[0], meshpoints.get(p0)[1], meshpoints.get(p0)[2]);
00321 vertex(meshpoints.get(p1)[0], meshpoints.get(p1)[1], meshpoints.get(p1)[2]);
00322 vertex(meshpoints.get(p2)[0], meshpoints.get(p2)[1], meshpoints.get(p2)[2]);
00323
00324 }
00325 endShape();
00326 popMatrix();
00327 }
00328
00329
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00351 private void displayMessage(String message){
00352 System.out.println(message);
00353 return;
00354 }
00355 public void setPrologVisCanvas(PrologVisualizationCanvas c){
00356 prologVisCanvas = c;
00357 }
00358
00359
00363
00364
00365
00366
00367
00368
00369 public void addItem(ItemBase item) {
00370 this.allItems.add(item);
00371 animatedItemsRef.put(item.name, item);
00372 }
00373
00374 public void addObject(String identifier) {
00375
00376 ItemBase item = getItem(identifier);
00377
00378 if(item != null) {
00379 removeObject(identifier);
00380 addItem(item);
00381 }
00382 }
00383
00384 public void addObjectWithChildren(String identifier) {
00385 HashMap<String, Vector<Object>> physicalParts = PrologVisualizationCanvas.executeQuery(
00386 "rdf_reachable("+identifier+", knowrob:properPhysicalPartTypes, PART)",null);
00387
00388 if(physicalParts.get("PART") != null)
00389 for(int i=0;i<physicalParts.get("PART").size();i++)
00390 if(!physicalParts.get("PART").get(i).toString().equals(identifier))
00391 addObject(physicalParts.get("PART").get(i).toString());
00392
00393 HashMap<String, Vector<Object>> mapParts = PrologVisualizationCanvas.executeQuery(
00394 "rdf_reachable(PART, knowrob:describedInMap, "+identifier+")",null);
00395
00396
00397 if(mapParts.get("PART") != null)
00398 for(int i=0;i<mapParts.get("PART").size();i++)
00399 if(!mapParts.get("PART").get(i).toString().equals(identifier))
00400 {
00401 HashMap<String, Vector<Object>> parts = PrologVisualizationCanvas.executeQuery(
00402 "rdf_reachable("+mapParts.get("PART").get(i).toString()+", knowrob:properPhysicalParts, P)"
00403 ,null);
00404
00405 Vector<Object> p = parts.get("P");
00406
00407 if(p != null)
00408 for(int j=0;j<p.size();j++)
00409 if(!p.get(j).toString().equals(mapParts.get("PART").get(i).toString()))
00410 addObject(p.get(j).toString());
00411
00412 addObject(mapParts.get("PART").get(i).toString());
00413 }
00414 addObject(identifier);
00415
00416 }
00417
00418
00419 public void removeItem(ItemBase item) {
00420 allItems.remove(item);
00421 animatedItemsRef.remove(item.name);
00422 }
00423
00424
00425 public void removeObject(String identifier) {
00426
00427 ItemBase item = animatedItemsRef.get(identifier);
00428 if(item == null) {
00429 return;
00430 }
00431 removeItem(item);
00432 }
00433
00434
00435 public void removeObjectWithChildren(String identifier) {
00436 HashMap<String, Vector<Object>> physicalParts = PrologVisualizationCanvas.executeQuery(
00437 "rdf_reachable("+identifier+", knowrob:properPhysicalPartTypes, PART)",null);
00438
00439 if(physicalParts.get("PART") != null)
00440 for(int i=0;i<physicalParts.get("PART").size();i++)
00441 if(!physicalParts.get("PART").get(i).toString().equals(identifier))
00442 removeObject(physicalParts.get("PART").get(i).toString());
00443
00444 HashMap<String, Vector<Object>> mapParts = PrologVisualizationCanvas.executeQuery(
00445 "rdf_reachable(PART, knowrob:describedInMap, "+identifier+")",null);
00446
00447 if(mapParts.get("PART") != null)
00448 for(int i=0;i<mapParts.get("PART").size();i++)
00449 if(!mapParts.get("PART").get(i).toString().equals(identifier))
00450 {
00451 HashMap<String, Vector<Object>> parts = PrologVisualizationCanvas.executeQuery(
00452 "rdf_reachable("+mapParts.get("PART").get(i).toString()+", knowrob:properPhysicalPartTypes, P)"
00453 ,null);
00454
00455 Vector<Object> p = parts.get("P");
00456
00457 if(p != null)
00458 for(int j=0;j<p.size();j++)
00459 if(!p.get(j).toString().equals(mapParts.get("PART").get(i).toString()))
00460 addObject(p.get(j).toString());
00461
00462 removeObject(mapParts.get("PART").get(i).toString());
00463 }
00464 removeObject(identifier);
00465
00466 }
00467
00468
00472
00473
00474
00475
00476
00477
00478
00483 public void highlightItem(String identifier, boolean highlight, int color) {
00484 ItemBase itm = animatedItemsRef.get(identifier);
00485 if(itm == null) {
00486 displayMessage("item "+identifier+" not in scene");
00487 return;
00488 }
00489
00490 if(highlight)
00491 itm.setColor(color);
00492 else
00493 itm.setColor(itm.defaultColor);
00494 }
00495
00496 public void highlightItem(String identifier, boolean highlight) {
00497 highlightItem(identifier, highlight, convertColor(255, 0, 0, 255));
00498 }
00499
00503 public void highlightReachable(String identifier, boolean highlight) {
00504 highlightItem(identifier, highlight);
00505
00506 HashMap<String, Vector<Object>> others = PrologVisualizationCanvas.executeQuery(
00507 "rdf_reachable("+identifier+", knowrob:properPhysicalPartTypes, I)", null);
00508
00509 Vector<Object> itms = others.get("I");
00510 if(itms == null) return;
00511
00512 for(Object o : itms)
00513 highlightItem(o.toString(), highlight);
00514
00515 }
00516
00517 public void clearHighlights() {
00518
00519 for(String j : animatedItemsRef.keySet()) {
00520 animatedItemsRef.get(j).setColor(animatedItemsRef.get(j).defaultColor);
00521 }
00522 }
00523
00524
00525
00526
00527
00531
00532
00533
00534
00535
00536
00543 public void displayAction(String identifier)
00544 {
00545
00546 clear();
00547 addObjectWithChildren("'http://ias.cs.tum.edu/kb/ccrl2_semantic_map.owl#SemanticEnvironmentMap0'");
00548 addObjectWithChildren("'http://ias.cs.tum.edu/kb/ias_map_addons.owl#table0'");
00549
00550
00551 addObject("'http://ias.cs.tum.edu/kb/knowrob.owl#placemat1'");
00552 addObject("'http://ias.cs.tum.edu/kb/ias_entities.owl#napkin1'");
00553 addObject("'http://ias.cs.tum.edu/kb/ias_entities.owl#spoon1'");
00554 addObject("'http://ias.cs.tum.edu/kb/ias_entities.owl#plate1'");
00555 addObject("'http://ias.cs.tum.edu/kb/ias_entities.owl#fork1'");
00556 addObject("'http://ias.cs.tum.edu/kb/ias_entities.owl#knife1'");
00557
00558 try{
00559 HashMap<String, Vector<Object>> c = PrologVisualizationCanvas.executeQuery(
00560 "rdf_has("+identifier+", 'http://ias.cs.tum.edu/kb/knowrob.owl#startTime', S), "
00561 +"rdf_has("+identifier+", 'http://ias.cs.tum.edu/kb/knowrob.owl#endTime', E)",null);
00562
00563 String startTimeStr = (String)c.get("S").get(0);
00564 startTimeStr = startTimeStr.substring(1,startTimeStr.length()-1);
00565
00566 if(startTimeStr.contains("#")) {
00567 startTimeStr=startTimeStr.split("#")[1];
00568 startTimeStr=startTimeStr.split("_")[1];
00569 }
00570 System.out.println(startTimeStr);
00571
00572 float startTime = Float.parseFloat(startTimeStr);
00573
00574
00575 String endTimeStr = (String)c.get("E").get(0);
00576 endTimeStr = endTimeStr.substring(1,endTimeStr.length()-1);
00577 if(endTimeStr.contains("#")) {
00578 endTimeStr=endTimeStr.split("#")[1];
00579 endTimeStr=endTimeStr.split("_")[1];
00580 }
00581 float endTime = Float.parseFloat(endTimeStr);
00582
00583
00584 c = PrologVisualizationCanvas.executeQuery(
00585 "rdf_has(A, rdf:type, knowrob:'Posture-Configuration'), rdf_has(A, knowrob:bodyPartsUsed, 'left'), rdf_triple(knowrob:startTime, A, T)",null);
00586
00587 Vector<Object> allTimePoints = c.get("T");
00588 BodyPoseSequence skeleton = new BodyPoseSequence();
00589 float[] poses = null;
00590 int totalFrames = 0;
00591
00592
00593
00594 for(Object s : allTimePoints) {
00595
00596
00597 String timePointStr = ((String)s).substring(1, ((String)s).length()-1);
00598 timePointStr = timePointStr.substring(1,timePointStr.length()-1);
00599 if(timePointStr.contains("#")) {
00600 timePointStr=timePointStr.split("#")[1];
00601 timePointStr=timePointStr.split("_")[1];
00602 }
00603 float timePoint = Float.parseFloat(timePointStr);
00604
00605 if(timePoint >= startTime && timePoint <= endTime) {
00606 try{
00607 HashMap<String, Vector<Object>> frameInfo = PrologVisualizationCanvas.executeQuery(
00608 "rdf_triple(ias_human:postureAtTimePoint, "+s.toString()+", P)",
00609 null);
00610
00611 if(frameInfo.get("P") == null || frameInfo.get("P").size() == 0){
00612 if(poses != null){
00613 skeleton.addPose(0, timePoint, "", poses);
00614 System.out.println("pose at point "+s.toString()+" not found; re-added previous pose.");
00615 }
00616 else
00617 {
00618 System.out.println("pose at point "+s.toString()+" not found.");
00619 }
00620 continue;
00621 }
00622
00623 String[] split = ((String)frameInfo.get("P").get(0)).split("\\)-\\(");
00624
00625 poses = new float[84];
00626
00627 for(int j=0;j<83;j++) {
00628 poses[j] = Float.parseFloat(split[j+4]);
00629 }
00630 poses[83] = Float.parseFloat(split[87].substring(0,split[87].length()-2));
00631 skeleton.addPose(0, timePoint, "", poses);
00632 totalFrames++;
00633
00634 }catch (Exception e) {
00635 e.printStackTrace();
00636 System.out.println("ERROR adding point: "+s.toString());
00637 }
00638 }
00639
00640 }
00641
00642 allItems.add(skeleton);
00643 animatedItemsRef.put("skeleton", skeleton);
00644
00645 numberFrames = totalFrames;
00646
00647
00648 c = PrologVisualizationCanvas.executeQuery(
00649 "rdf_triple('http://ias.cs.tum.edu/kb/knowrob.owl#fromLocation', "+identifier+", From)",null);
00650 if(c!=null && c.get("From")!= null) {
00651 String fromLoc = (String)c.get("From").get(0);
00652 if(fromLoc!=null) {
00653 addObject(fromLoc);
00654 }
00655 }
00656
00657 c = PrologVisualizationCanvas.executeQuery(
00658 "rdf_triple('http://ias.cs.tum.edu/kb/knowrob.owl#toLocation', "+identifier+", To)",null);
00659 if(c!=null && c.get("To")!=null) {
00660 String toLoc = (String)c.get("To").get(0);
00661 if(toLoc!=null) {
00662 addObject(toLoc);
00663 }
00664 }
00665
00666 }
00667 catch(NullPointerException e)
00668 {
00669 displayMessage("Action "+identifier+" not found.");
00670 drawBackground();
00671 }
00672 catch(Exception e)
00673 {
00674 displayMessage("Error displaying Action "+identifier+".");
00675 e.printStackTrace();
00676 drawBackground();
00677 }
00678 }
00679
00686 public void displayHumanTrajectory(String identifier, String handUsed) {
00687 Integer Occ=0, auxOcc=0;
00688 boolean band=true;
00689 int row=0, contP=0, col=0;
00690 float[][] Xp=new float[80][19];
00691 float[][] Yp=new float[80][19];
00692 float[][] Zp=new float[80][19];
00693
00694 Trajectories traj = new Trajectories();
00695
00696 HashMap<String, Vector<Object>> o= PrologVisualizationCanvas.executeQuery(""+"handTrajectory("+handUsed+", "+identifier+", T, P, X, Y, Z)", null);
00697
00698 Vector<Object> pointID = o.get("P");
00699 Vector<Object> Xc = o.get("X");
00700 Vector<Object> Yc = o.get("Y");
00701 Vector<Object> Zc = o.get("Z");
00702
00703 for (Object p: pointID){
00704 String s_p=p.toString();
00705 String[] tokenP=s_p.split("_");
00706 if (Occ.equals(Integer.parseInt(tokenP[2])) && band==true){
00707 Xp[row][col]=Float.parseFloat(Xc.get(contP).toString());
00708 Yp[row][col]=Float.parseFloat(Yc.get(contP).toString());
00709 Zp[row][col]=Float.parseFloat(Zc.get(contP).toString());
00710 row=row+1;
00711
00712 } else {
00713 Occ=Integer.parseInt(tokenP[2]);
00714 if (Occ > auxOcc) {
00715 col=col+1; row=0; band=true; auxOcc=Occ;
00716 System.out.println("Occ=" +Occ);
00717 } else {band=false;}
00718
00719 }
00720 contP=contP+1;
00721 }
00722 System.out.println("columnas"+Xp[0].length);
00723
00724 for (int j=0;j<Xp[0].length;j++ ){
00725
00726 for (int i=0;i<(Xp.length)-1; i++) {
00727 if (Xp[i][j]!=0.0 && Yp[i][j]!=0){
00728 traj.addTraj(Xp[i][j], Yp[i][j], Zp[i][j]);
00729
00730 }
00731 }
00732 traj.addTraj(0, 0, 0);
00733
00734 }
00735 allItems.add(traj);
00736 animatedItemsRef.put("traj", traj);
00737 }
00738
00743 public void displayEyeTrajectory (String identifier) {
00744 Integer Occ=1, auxOcc=1;
00745 int col=0, contP=0 ;
00746 int[][] Xc, Yc;
00747 boolean band=true;
00748
00749 Trajectories traj = new Trajectories();
00750
00751 HashMap<String, Vector<Object>> o= PrologVisualizationCanvas.executeQuery(""+ "readEyeTrajectory("+identifier+", T, P, XCoor, YCoor)", null);
00752
00753 Vector<Object> pointId = o.get("P");
00754 Vector<Object> XCoor = o.get("XCoor");
00755 Vector<Object> YCoor = o.get("YCoor");
00756 Xc= new int[35][4];
00757 Yc= new int[35][4];
00758 for (Object p: pointId){
00759 String s_p=p.toString();
00760 String[] tokenP=s_p.split("_");
00761
00762 if (Occ.equals(Integer.parseInt(tokenP[1])) && band==true) {
00763
00764
00765 Xc[Integer.parseInt(tokenP[2])][col] = Integer.parseInt(XCoor.get(contP).toString());
00766 Yc[Integer.parseInt(tokenP[2])][col] = Integer.parseInt(YCoor.get(contP).toString());
00767
00768
00769
00770 } else {
00771 Occ=Integer.parseInt(tokenP[1]);
00772 if (Occ>auxOcc) {
00773 col=Occ-1; band=true; auxOcc=Occ;
00774 Xc[Integer.parseInt(tokenP[2])][col] = Integer.parseInt(XCoor.get(contP).toString());
00775 Yc[Integer.parseInt(tokenP[2])][col] = Integer.parseInt(YCoor.get(contP).toString());
00776 }else{ band=false;}
00777 }
00778 contP=contP+1;
00779 }
00780
00781 for (int j=0;j<Xc[0].length;j++ ){
00782 for (int i=0;i<(Xc.length)-1; i++) {
00783 traj.addTraj(Xc[i][j], Yc[i][j], 0);
00784
00785 }
00786 }
00787 allItems.add(traj);
00788 animatedItemsRef.put("traj", traj);
00789
00790 }
00791
00798 public void displayActionFixedIdent(String identifier)
00799 {
00800 HashMap<String, Vector<Object>> c = PrologVisualizationCanvas.executeQuery(""+
00801 "readPostureSeqForAction("+identifier+", P, EPISODENR, INSTANCENR, TIME, BECX, BECY, BECZ, ULWX, ULWY, ULWZ, OLWX, OLWY, OLWZ, UBWX, UBWY, UBWZ, OBWX, OBWY, OBWZ, UHWX, UHWY, UHWZ, BRKX, BRKY, BRKZ, OHWX, OHWY, OHWZ, KOX, KOY, KOZ, SEHX, SEHY, SEHZ, OSLX, OSLY, OSLZ, USLX, USLY, USLZ, FULX, FULY, FULZ, FBLX, FBLY, FBLZ, OSRX, OSRY, OSRZ, USRX, USRY, USRZ, FURX, FURY, FURZ, FBRX, FBRY, FBRZ, SBLX, SBLY, SBLZ, OALX, OALY, OALZ, UALX, UALY, UALZ, HALX, HALY, HALZ, FILX, FILY, FILZ, SBRX, SBRY, SBRZ, OARX, OARY, OARZ, UARX, UARY, UARZ, HARX, HARY, HARZ, FIRX, FIRY, FIRZ)"
00802 ,null);
00803
00804 if(c.get("TIME") == null)
00805 {
00806 drawBackground();
00807 displayMessage("could not find Action "+identifier+"");
00808 numberFrames = 1;
00809 return;
00810 }
00811
00812
00813 Vector<Object> times = c.get("TIME");
00814 framesToTimes = new float[times.size()];
00815 for(int i=0;i<framesToTimes.length;i++) framesToTimes[i] = Float.parseFloat(times.get(i).toString());
00816
00817 BodyPoseSequence skeleton = new BodyPoseSequence();
00818
00819 float[][] poses = new float[times.size()][];
00820 for(int i=0;i<poses.length;i++) poses[i] = new float[84];
00821 String[] posIdents = "BECX, BECY, BECZ, ULWX, ULWY, ULWZ, OLWX, OLWY, OLWZ, UBWX, UBWY, UBWZ, OBWX, OBWY, OBWZ, UHWX, UHWY, UHWZ, BRKX, BRKY, BRKZ, OHWX, OHWY, OHWZ, KOX, KOY, KOZ, SEHX, SEHY, SEHZ, OSLX, OSLY, OSLZ, USLX, USLY, USLZ, FULX, FULY, FULZ, FBLX, FBLY, FBLZ, OSRX, OSRY, OSRZ, USRX, USRY, USRZ, FURX, FURY, FURZ, FBRX, FBRY, FBRZ, SBLX, SBLY, SBLZ, OALX, OALY, OALZ, UALX, UALY, UALZ, HALX, HALY, HALZ, FILX, FILY, FILZ, SBRX, SBRY, SBRZ, OARX, OARY, OARZ, UARX, UARY, UARZ, HARX, HARY, HARZ, FIRX, FIRY, FIRZ".split(", ");
00822
00823 for(int j=0;j<84;j++) {
00824 Vector<Object> d = c.get(posIdents[j]);
00825 for(int i=0;i<d.size() && i<poses.length;i++) {
00826 poses[i][j] = Float.parseFloat(d.get(i).toString());
00827 }
00828 }
00829
00830 for(int i=0;i<poses.length;i++)
00831 skeleton.addPose(0, Float.parseFloat(times.get(i).toString()), "", poses[i]);
00832
00833 allItems.add(skeleton);
00834 animatedItemsRef.put("skeleton", skeleton);
00835
00836
00837
00838 numberFrames = times.size();
00839
00840 System.out.print("ALL DONE");
00841 }
00842
00843
00844
00845
00846
00853 public void drawBackground() {
00854 clear();
00855
00856 HashMap<String, Vector<Object>> tpe = PrologVisualizationCanvas.executeQuery(
00857 "rdf_has(SUBJECT, rdf:type, knowrob:'SemanticEnvironmentMap')",null);
00858 String type = null;
00859
00860
00861 try{
00862 type = tpe.get("SUBJECT").get(0).toString();
00863
00864
00865 } catch(Exception e) {
00866 displayMessage("Semantic map not found");
00867 }
00868 addObjectWithChildren(type);
00869 }
00870
00871
00875 public void clear() {
00876 allItems.clear();
00877 animatedItemsRef.clear();
00878 numberFrames = 1;
00879 currentFrame = 0;
00880 grayLevelCounter = 0;
00881 }
00882
00883
00884
00885
00886
00887
00888
00892
00893
00894
00895
00896 private float[] getDimensionsOfItem(String identifier) {
00897 try{
00898 HashMap<String, Vector<Object>> nfo = PrologVisualizationCanvas.executeQuery(
00899 "rdf_has("+identifier+",knowrob:widthOfObject,literal(type(_,_W)))," +
00900 "rdf_has("+identifier+",knowrob:heightOfObject,literal(type(_,_H))), " +
00901 "rdf_has("+identifier+",knowrob:depthOfObject,literal(type(_,_D))), " +
00902 "atom_to_term(_W,W,_), atom_to_term(_H,H,_), atom_to_term(_D,D,_)" , null);
00903
00904 return new float[] {
00905 Float.parseFloat(nfo.get("D").get(0).toString()),
00906 Float.parseFloat(nfo.get("W").get(0).toString()),
00907 Float.parseFloat(nfo.get("H").get(0).toString())};
00908
00909 } catch(Exception e) {
00910 return null;
00911 }
00912 }
00913
00914
00915 private float[] getOrientationOfItem(String identifier) {
00916 try{
00917
00918 HashMap<String, Vector<Object>> nfo = PrologVisualizationCanvas.executeQuery(
00919 "rdf_triple(knowrob:orientation,"+identifier+",Or), " +
00920
00921 "rdf_triple(knowrob:m00,Or,_M00l), actionmodel:am_strip_literal_type(_M00l, _M00), term_to_atom(M00,_M00)," +
00922 "rdf_triple(knowrob:m01,Or,_M01l), actionmodel:am_strip_literal_type(_M01l, _M01), term_to_atom(M01,_M01)," +
00923 "rdf_triple(knowrob:m02,Or,_M02l), actionmodel:am_strip_literal_type(_M02l, _M02), term_to_atom(M02,_M02)," +
00924 "rdf_triple(knowrob:m03,Or,_M03l), actionmodel:am_strip_literal_type(_M03l, _M03), term_to_atom(M03,_M03)," +
00925
00926 "rdf_triple(knowrob:m10,Or,_M10l), actionmodel:am_strip_literal_type(_M10l, _M10), term_to_atom(M10,_M10)," +
00927 "rdf_triple(knowrob:m11,Or,_M11l), actionmodel:am_strip_literal_type(_M11l, _M11), term_to_atom(M11,_M11)," +
00928 "rdf_triple(knowrob:m12,Or,_M12l), actionmodel:am_strip_literal_type(_M12l, _M12), term_to_atom(M12,_M12)," +
00929 "rdf_triple(knowrob:m13,Or,_M13l), actionmodel:am_strip_literal_type(_M13l, _M13), term_to_atom(M13,_M13)," +
00930
00931 "rdf_triple(knowrob:m20,Or,_M20l), actionmodel:am_strip_literal_type(_M20l, _M20), term_to_atom(M20,_M20)," +
00932 "rdf_triple(knowrob:m21,Or,_M21l), actionmodel:am_strip_literal_type(_M21l, _M21), term_to_atom(M21,_M21)," +
00933 "rdf_triple(knowrob:m22,Or,_M22l), actionmodel:am_strip_literal_type(_M22l, _M22), term_to_atom(M22,_M22)," +
00934 "rdf_triple(knowrob:m23,Or,_M23l), actionmodel:am_strip_literal_type(_M23l, _M23), term_to_atom(M23,_M23)," +
00935
00936 "rdf_triple(knowrob:m30,Or,_M30l), actionmodel:am_strip_literal_type(_M30l, _M30), term_to_atom(M30,_M30)," +
00937 "rdf_triple(knowrob:m31,Or,_M31l), actionmodel:am_strip_literal_type(_M31l, _M31), term_to_atom(M31,_M31)," +
00938 "rdf_triple(knowrob:m32,Or,_M32l), actionmodel:am_strip_literal_type(_M32l, _M32), term_to_atom(M32,_M32)," +
00939 "rdf_triple(knowrob:m33,Or,_M33l), actionmodel:am_strip_literal_type(_M33l, _M33), term_to_atom(M33,_M33)", null);
00940 return new float[] {
00941 Float.parseFloat(nfo.get("M00").get(0).toString()),
00942 Float.parseFloat(nfo.get("M01").get(0).toString()),
00943 Float.parseFloat(nfo.get("M02").get(0).toString()),
00944 Float.parseFloat(nfo.get("M03").get(0).toString()),
00945 Float.parseFloat(nfo.get("M10").get(0).toString()),
00946 Float.parseFloat(nfo.get("M11").get(0).toString()),
00947 Float.parseFloat(nfo.get("M12").get(0).toString()),
00948 Float.parseFloat(nfo.get("M13").get(0).toString()),
00949 Float.parseFloat(nfo.get("M20").get(0).toString()),
00950 Float.parseFloat(nfo.get("M21").get(0).toString()),
00951 Float.parseFloat(nfo.get("M22").get(0).toString()),
00952 Float.parseFloat(nfo.get("M23").get(0).toString()),
00953 Float.parseFloat(nfo.get("M30").get(0).toString()),
00954 Float.parseFloat(nfo.get("M31").get(0).toString()),
00955 Float.parseFloat(nfo.get("M32").get(0).toString()),
00956 Float.parseFloat(nfo.get("M33").get(0).toString())};
00957 } catch(Exception e) {
00958 return null;
00959 }
00960 }
00961
00962 private ItemModel getModelOfItem(String identifier) {
00963 try {
00964 HashMap<String, Vector<Object>> nfo = PrologVisualizationCanvas
00965 .executeQuery(
00966 "rdf_has("
00967 + identifier
00968 + ",knowrob:pathModel,literal(type(_,_P))) "
00969 + "atom_to_term(_P,P,_)",
00970 null);
00971
00972 return new ItemModel(nfo.get("P").get(0).toString());
00973 } catch (Exception e) {
00974 return null;
00975 }
00976 }
00977
00978
00979
00980 private ItemBase getItem(String identifier) {
00981
00982
00983 HashMap<String, Vector<Object>> tpe = PrologVisualizationCanvas.executeQuery(
00984 "rdf_has("+identifier+", rdf:type, OBJECTCLASS)," +
00985 "OBJECTCLASS\\='http://www.w3.org/2002/07/owl#NamedIndividual'",null);
00986 String type = null;
00987
00988
00989
00990 try{
00991 type = tpe.get("OBJECTCLASS").get(0).toString();
00992 } catch(Exception e) {
00993 displayMessage("item "+identifier+" not found");
00994 return null;
00995 }
00996
00997
00998 if(type.equals("'http://ias.cs.tum.edu/kb/knowrob.owl#SemanticEnvironmentMap'")
00999 || type.equals("'http://ias.cs.tum.edu/kb/knowrob.owl#HingedJoint'")
01000 || type.equals("'http://ias.cs.tum.edu/kb/knowrob.owl#Door'")
01001 || type.equals("'http://ias.cs.tum.edu/kb/knowrob.owl#WallOfAConstruction'")
01002 ) {
01003 return null;
01004
01005 }
01006
01007
01008 ItemBase it =itemForObjType(type);
01009
01010
01011 if(it!=null) {
01012 float[] o = getOrientationOfItem(identifier);
01013 if(o!=null) {
01014 it.setPose(o);
01015 } else {System.out.println("NO ORIENTATION FOR " + identifier);}
01016
01017 float[] d = getDimensionsOfItem(identifier);
01018 if(d!=null) {
01019 it.setDimensions(d[0],d[1],d[2]);
01020 }
01021
01022 it.setModel(getModelOfItem(identifier));
01023
01024 it.name = identifier;
01025 return it;
01026
01027 } else {
01028
01029
01030 HashMap<String, Vector<Object>> storage = PrologVisualizationCanvas.executeQuery(
01031 "rdf_has("+identifier+", rdf:type, OBJECTCLASS)," +
01032 "rdf_reachable(OBJECTCLASS, rdfs:subClassOf, knowrob:'StorageConstruct')," +
01033 "rdf_has("+identifier+",knowrob:widthOfObject,literal(type(_,_W)))," +
01034 "rdf_has("+identifier+",knowrob:heightOfObject,literal(type(_,_H))), " +
01035 "rdf_has("+identifier+",knowrob:depthOfObject,literal(type(_,_D))), " +
01036
01037 "rdf_triple(knowrob:orientation,"+identifier+",Or), " +
01038
01039 "rdf_triple(knowrob:m00,Or,literal(type(_,_M00))), term_to_atom(M00,_M00)," +
01040 "rdf_triple(knowrob:m01,Or,literal(type(_,_M01))), term_to_atom(M01,_M01)," +
01041 "rdf_triple(knowrob:m02,Or,literal(type(_,_M02))), term_to_atom(M02,_M02)," +
01042 "rdf_triple(knowrob:m03,Or,literal(type(_,_M03))), term_to_atom(M03,_M03)," +
01043
01044 "rdf_triple(knowrob:m10,Or,literal(type(_,_M10))), term_to_atom(M10,_M10)," +
01045 "rdf_triple(knowrob:m11,Or,literal(type(_,_M11))), term_to_atom(M11,_M11)," +
01046 "rdf_triple(knowrob:m12,Or,literal(type(_,_M12))), term_to_atom(M12,_M12)," +
01047 "rdf_triple(knowrob:m13,Or,literal(type(_,_M13))), term_to_atom(M13,_M13)," +
01048
01049 "rdf_triple(knowrob:m20,Or,literal(type(_,_M20))), term_to_atom(M20,_M20)," +
01050 "rdf_triple(knowrob:m21,Or,literal(type(_,_M21))), term_to_atom(M21,_M21)," +
01051 "rdf_triple(knowrob:m22,Or,literal(type(_,_M22))), term_to_atom(M22,_M22)," +
01052 "rdf_triple(knowrob:m23,Or,literal(type(_,_M23))), term_to_atom(M23,_M23)," +
01053
01054 "rdf_triple(knowrob:m30,Or,literal(type(_,_M30))), term_to_atom(M30,_M30)," +
01055 "rdf_triple(knowrob:m31,Or,literal(type(_,_M31))), term_to_atom(M31,_M31)," +
01056 "rdf_triple(knowrob:m32,Or,literal(type(_,_M32))), term_to_atom(M32,_M32)," +
01057 "rdf_triple(knowrob:m33,Or,literal(type(_,_M33))), term_to_atom(M33,_M33)," +
01058
01059 "atom_to_term(_W,W,_), atom_to_term(_H,H,_), atom_to_term(_D,D,_)", null);
01060 if( storage.get("W") != null && storage.get("W").size() > 0) {
01061 StorageFacility c = null;
01062 if(storage.get("OBJECTCLASS").get(0).toString().endsWith("Cupboard'")) {
01063 c = new Cupboard(
01064 Float.valueOf(storage.get("M00").get(0).toString()),
01065 Float.valueOf(storage.get("M01").get(0).toString()),
01066 Float.valueOf(storage.get("M02").get(0).toString()),
01067 Float.valueOf(storage.get("M03").get(0).toString()),
01068
01069 Float.valueOf(storage.get("M10").get(0).toString()),
01070 Float.valueOf(storage.get("M11").get(0).toString()),
01071 Float.valueOf(storage.get("M12").get(0).toString()),
01072 Float.valueOf(storage.get("M13").get(0).toString()),
01073
01074 Float.valueOf(storage.get("M20").get(0).toString()),
01075 Float.valueOf(storage.get("M21").get(0).toString()),
01076 Float.valueOf(storage.get("M22").get(0).toString()),
01077 Float.valueOf(storage.get("M23").get(0).toString()),
01078
01079 Float.valueOf(storage.get("M30").get(0).toString()),
01080 Float.valueOf(storage.get("M31").get(0).toString()),
01081 Float.valueOf(storage.get("M32").get(0).toString()),
01082 Float.valueOf(storage.get("M33").get(0).toString()),
01083
01084 Float.valueOf(storage.get("D").get(0).toString()),
01085 Float.valueOf(storage.get("W").get(0).toString()),
01086 Float.valueOf(storage.get("H").get(0).toString()));
01087 } else {
01088 c = new Drawer(
01089 Float.valueOf(storage.get("M00").get(0).toString()),
01090 Float.valueOf(storage.get("M01").get(0).toString()),
01091 Float.valueOf(storage.get("M02").get(0).toString()),
01092 Float.valueOf(storage.get("M03").get(0).toString()),
01093
01094 Float.valueOf(storage.get("M10").get(0).toString()),
01095 Float.valueOf(storage.get("M11").get(0).toString()),
01096 Float.valueOf(storage.get("M12").get(0).toString()),
01097 Float.valueOf(storage.get("M13").get(0).toString()),
01098
01099 Float.valueOf(storage.get("M20").get(0).toString()),
01100 Float.valueOf(storage.get("M21").get(0).toString()),
01101 Float.valueOf(storage.get("M22").get(0).toString()),
01102 Float.valueOf(storage.get("M23").get(0).toString()),
01103
01104 Float.valueOf(storage.get("M30").get(0).toString()),
01105 Float.valueOf(storage.get("M31").get(0).toString()),
01106 Float.valueOf(storage.get("M32").get(0).toString()),
01107 Float.valueOf(storage.get("M33").get(0).toString()),
01108
01109 Float.valueOf(storage.get("D").get(0).toString()),
01110 Float.valueOf(storage.get("W").get(0).toString()),
01111 Float.valueOf(storage.get("H").get(0).toString()));
01112 }
01113 int col = grayValues[(++grayLevelCounter) % grayValues.length];
01114
01115 c.defaultColor = convertColor(col, col, col, 255);
01116 c.setColor(c.defaultColor);
01117 c.name = identifier;
01118
01119 return c;
01120 }
01121
01122
01123
01124
01125 HashMap<String, Vector<Object>> handles = PrologVisualizationCanvas.executeQuery(
01126 "rdf_has("+identifier+", rdf:type, knowrob:'Handle'), " +
01127 "rdf_has("+identifier+",knowrob:widthOfObject,literal(type(_,_W)))," +
01128 "rdf_has("+identifier+",knowrob:heightOfObject,literal(type(_,_H))), " +
01129 "rdf_has("+identifier+",knowrob:depthOfObject,literal(type(_,_D))), " +
01130
01131 "rdf_triple(knowrob:orientation,"+identifier+",Or), " +
01132
01133 "rdf_triple(knowrob:m00,Or,literal(type(_,_M00))), term_to_atom(M00,_M00)," +
01134 "rdf_triple(knowrob:m01,Or,literal(type(_,_M01))), term_to_atom(M01,_M01)," +
01135 "rdf_triple(knowrob:m02,Or,literal(type(_,_M02))), term_to_atom(M02,_M02)," +
01136 "rdf_triple(knowrob:m03,Or,literal(type(_,_M03))), term_to_atom(M03,_M03)," +
01137
01138 "rdf_triple(knowrob:m10,Or,literal(type(_,_M10))), term_to_atom(M10,_M10)," +
01139 "rdf_triple(knowrob:m11,Or,literal(type(_,_M11))), term_to_atom(M11,_M11)," +
01140 "rdf_triple(knowrob:m12,Or,literal(type(_,_M12))), term_to_atom(M12,_M12)," +
01141 "rdf_triple(knowrob:m13,Or,literal(type(_,_M13))), term_to_atom(M13,_M13)," +
01142
01143 "rdf_triple(knowrob:m20,Or,literal(type(_,_M20))), term_to_atom(M20,_M20)," +
01144 "rdf_triple(knowrob:m21,Or,literal(type(_,_M21))), term_to_atom(M21,_M21)," +
01145 "rdf_triple(knowrob:m22,Or,literal(type(_,_M22))), term_to_atom(M22,_M22)," +
01146 "rdf_triple(knowrob:m23,Or,literal(type(_,_M23))), term_to_atom(M23,_M23)," +
01147
01148 "rdf_triple(knowrob:m30,Or,literal(type(_,_M30))), term_to_atom(M30,_M30)," +
01149 "rdf_triple(knowrob:m31,Or,literal(type(_,_M31))), term_to_atom(M31,_M31)," +
01150 "rdf_triple(knowrob:m32,Or,literal(type(_,_M32))), term_to_atom(M32,_M32)," +
01151 "rdf_triple(knowrob:m33,Or,literal(type(_,_M33))), term_to_atom(M33,_M33)," +
01152
01153 "atom_to_term(_W,W,_), atom_to_term(_H,H,_), atom_to_term(_D,D,_)", null);
01154 if (handles.get("M00") != null && handles.get("M00").size() > 0)
01155 {
01156 ItemBase item = new BoxHandle(
01157 Float.valueOf(handles.get("M00").get(0).toString()),
01158 Float.valueOf(handles.get("M01").get(0).toString()),
01159 Float.valueOf(handles.get("M02").get(0).toString()),
01160 Float.valueOf(handles.get("M03").get(0).toString()),
01161
01162 Float.valueOf(handles.get("M10").get(0).toString()),
01163 Float.valueOf(handles.get("M11").get(0).toString()),
01164 Float.valueOf(handles.get("M12").get(0).toString()),
01165 Float.valueOf(handles.get("M13").get(0).toString()),
01166
01167 Float.valueOf(handles.get("M20").get(0).toString()),
01168 Float.valueOf(handles.get("M21").get(0).toString()),
01169 Float.valueOf(handles.get("M22").get(0).toString()),
01170 Float.valueOf(handles.get("M23").get(0).toString()),
01171
01172 Float.valueOf(handles.get("M30").get(0).toString()),
01173 Float.valueOf(handles.get("M31").get(0).toString()),
01174 Float.valueOf(handles.get("M32").get(0).toString()),
01175 Float.valueOf(handles.get("M33").get(0).toString()),
01176
01177 Float.valueOf(handles.get("D").get(0).toString()),
01178 Float.valueOf(handles.get("W").get(0).toString()),
01179 Float.valueOf(handles.get("H").get(0).toString()));
01180 item.name = identifier;
01181 return item;
01182 }
01183
01184
01185 HashMap<String, Vector<Object>> knobs = PrologVisualizationCanvas.executeQuery(
01186 "rdf_has("+identifier+", rdf:type, knowrob:'ControlKnob'), " +
01187 "rdf_has("+identifier+",knowrob:widthOfObject,literal(type(_,_W)))," +
01188 "rdf_has("+identifier+",knowrob:heightOfObject,literal(type(_,_H))), " +
01189 "rdf_has("+identifier+",knowrob:depthOfObject,literal(type(_,_D))), " +
01190
01191 "rdf_triple(knowrob:orientation,"+identifier+",Or), " +
01192
01193 "rdf_triple(knowrob:m00,Or,literal(type(_,_M00))), term_to_atom(M00,_M00)," +
01194 "rdf_triple(knowrob:m01,Or,literal(type(_,_M01))), term_to_atom(M01,_M01)," +
01195 "rdf_triple(knowrob:m02,Or,literal(type(_,_M02))), term_to_atom(M02,_M02)," +
01196 "rdf_triple(knowrob:m03,Or,literal(type(_,_M03))), term_to_atom(M03,_M03)," +
01197
01198 "rdf_triple(knowrob:m10,Or,literal(type(_,_M10))), term_to_atom(M10,_M10)," +
01199 "rdf_triple(knowrob:m11,Or,literal(type(_,_M11))), term_to_atom(M11,_M11)," +
01200 "rdf_triple(knowrob:m12,Or,literal(type(_,_M12))), term_to_atom(M12,_M12)," +
01201 "rdf_triple(knowrob:m13,Or,literal(type(_,_M13))), term_to_atom(M13,_M13)," +
01202
01203 "rdf_triple(knowrob:m20,Or,literal(type(_,_M20))), term_to_atom(M20,_M20)," +
01204 "rdf_triple(knowrob:m21,Or,literal(type(_,_M21))), term_to_atom(M21,_M21)," +
01205 "rdf_triple(knowrob:m22,Or,literal(type(_,_M22))), term_to_atom(M22,_M22)," +
01206 "rdf_triple(knowrob:m23,Or,literal(type(_,_M23))), term_to_atom(M23,_M23)," +
01207
01208 "rdf_triple(knowrob:m30,Or,literal(type(_,_M30))), term_to_atom(M30,_M30)," +
01209 "rdf_triple(knowrob:m31,Or,literal(type(_,_M31))), term_to_atom(M31,_M31)," +
01210 "rdf_triple(knowrob:m32,Or,literal(type(_,_M32))), term_to_atom(M32,_M32)," +
01211 "rdf_triple(knowrob:m33,Or,literal(type(_,_M33))), term_to_atom(M33,_M33)," +
01212
01213 "atom_to_term(_W,W,_), atom_to_term(_H,H,_), atom_to_term(_D,D,_)", null);
01214 if (knobs.get("M00") != null && knobs.get("M00").size() > 0)
01215 {
01216 Sphere item = new Sphere(
01217 Float.valueOf(knobs.get("M00").get(0).toString()),
01218 Float.valueOf(knobs.get("M01").get(0).toString()),
01219 Float.valueOf(knobs.get("M02").get(0).toString()),
01220 Float.valueOf(knobs.get("M03").get(0).toString()),
01221
01222 Float.valueOf(knobs.get("M10").get(0).toString()),
01223 Float.valueOf(knobs.get("M11").get(0).toString()),
01224 Float.valueOf(knobs.get("M12").get(0).toString()),
01225 Float.valueOf(knobs.get("M13").get(0).toString()),
01226
01227 Float.valueOf(knobs.get("M20").get(0).toString()),
01228 Float.valueOf(knobs.get("M21").get(0).toString()),
01229 Float.valueOf(knobs.get("M22").get(0).toString()),
01230 Float.valueOf(knobs.get("M23").get(0).toString()),
01231
01232 Float.valueOf(knobs.get("M30").get(0).toString()),
01233 Float.valueOf(knobs.get("M31").get(0).toString()),
01234 Float.valueOf(knobs.get("M32").get(0).toString()),
01235 Float.valueOf(knobs.get("M33").get(0).toString()),
01236
01237 Float.valueOf(knobs.get("D").get(0).toString()),
01238 Float.valueOf(knobs.get("W").get(0).toString()),
01239 Float.valueOf(knobs.get("H").get(0).toString()));
01240
01241 item.name = identifier;
01242 return item;
01243 }
01244
01245
01246
01247 HashMap<String, Vector<Object>> tables = PrologVisualizationCanvas.executeQuery(
01248 "rdf_has("+identifier+", rdf:type, OBJECTCLASS)," +
01249 "rdf_reachable(OBJECTCLASS, rdfs:subClassOf, knowrob:'Table-PieceOfFurniture')," +
01250
01251 "rdf_has("+identifier+",knowrob:widthOfObject,literal(type(_,_W)))," +
01252 "rdf_has("+identifier+",knowrob:heightOfObject,literal(type(_,_H))), " +
01253 "rdf_has("+identifier+",knowrob:depthOfObject,literal(type(_,_D))), " +
01254
01255 "rdf_triple(knowrob:orientation,"+identifier+",Or), " +
01256
01257 "rdf_triple(knowrob:m00,Or,literal(type(_,_M00))), term_to_atom(M00,_M00)," +
01258 "rdf_triple(knowrob:m01,Or,literal(type(_,_M01))), term_to_atom(M01,_M01)," +
01259 "rdf_triple(knowrob:m02,Or,literal(type(_,_M02))), term_to_atom(M02,_M02)," +
01260 "rdf_triple(knowrob:m03,Or,literal(type(_,_M03))), term_to_atom(M03,_M03)," +
01261
01262 "rdf_triple(knowrob:m10,Or,literal(type(_,_M10))), term_to_atom(M10,_M10)," +
01263 "rdf_triple(knowrob:m11,Or,literal(type(_,_M11))), term_to_atom(M11,_M11)," +
01264 "rdf_triple(knowrob:m12,Or,literal(type(_,_M12))), term_to_atom(M12,_M12)," +
01265 "rdf_triple(knowrob:m13,Or,literal(type(_,_M13))), term_to_atom(M13,_M13)," +
01266
01267 "rdf_triple(knowrob:m20,Or,literal(type(_,_M20))), term_to_atom(M20,_M20)," +
01268 "rdf_triple(knowrob:m21,Or,literal(type(_,_M21))), term_to_atom(M21,_M21)," +
01269 "rdf_triple(knowrob:m22,Or,literal(type(_,_M22))), term_to_atom(M22,_M22)," +
01270 "rdf_triple(knowrob:m23,Or,literal(type(_,_M23))), term_to_atom(M23,_M23)," +
01271
01272 "rdf_triple(knowrob:m30,Or,literal(type(_,_M30))), term_to_atom(M30,_M30)," +
01273 "rdf_triple(knowrob:m31,Or,literal(type(_,_M31))), term_to_atom(M31,_M31)," +
01274 "rdf_triple(knowrob:m32,Or,literal(type(_,_M32))), term_to_atom(M32,_M32)," +
01275 "rdf_triple(knowrob:m33,Or,literal(type(_,_M33))), term_to_atom(M33,_M33)," +
01276
01277 "atom_to_term(_W,W,_), atom_to_term(_H,H,_), atom_to_term(_D,D,_)", null);
01278 if (tables.get("M00") != null && tables.get("M00").size() > 0)
01279 {
01280 ItemBase item = new Table(
01281 Float.valueOf(tables.get("M00").get(0).toString()),
01282 Float.valueOf(tables.get("M01").get(0).toString()),
01283 Float.valueOf(tables.get("M02").get(0).toString()),
01284 Float.valueOf(tables.get("M03").get(0).toString()),
01285
01286 Float.valueOf(tables.get("M10").get(0).toString()),
01287 Float.valueOf(tables.get("M11").get(0).toString()),
01288 Float.valueOf(tables.get("M12").get(0).toString()),
01289 Float.valueOf(tables.get("M13").get(0).toString()),
01290
01291 Float.valueOf(tables.get("M20").get(0).toString()),
01292 Float.valueOf(tables.get("M21").get(0).toString()),
01293 Float.valueOf(tables.get("M22").get(0).toString()),
01294 Float.valueOf(tables.get("M23").get(0).toString()),
01295
01296 Float.valueOf(tables.get("M30").get(0).toString()),
01297 Float.valueOf(tables.get("M31").get(0).toString()),
01298 Float.valueOf(tables.get("M32").get(0).toString()),
01299 Float.valueOf(tables.get("M33").get(0).toString()),
01300
01301 Float.valueOf(tables.get("D").get(0).toString()),
01302 Float.valueOf(tables.get("W").get(0).toString()),
01303 Float.valueOf(tables.get("H").get(0).toString()));
01304
01305 int col = grayValues[(++grayLevelCounter) % grayValues.length];
01306 item.defaultColor = convertColor(col, col, col, 255);
01307
01308 item.setColor(item.defaultColor);
01309 item.name = identifier;
01310 return item;
01311 }
01312
01313
01314
01315 HashMap<String, Vector<Object>> counter = PrologVisualizationCanvas.executeQuery(
01316 "rdf_has("+identifier+", rdf:type, OBJECTCLASS)," +
01317 "rdf_reachable(OBJECTCLASS, rdfs:subClassOf, knowrob:'CounterTop')," +
01318 "rdf_has("+identifier+",knowrob:widthOfObject,literal(type(_,_W)))," +
01319 "rdf_has("+identifier+",knowrob:heightOfObject,literal(type(_,_H))), " +
01320 "rdf_has("+identifier+",knowrob:depthOfObject,literal(type(_,_D))), " +
01321
01322 "rdf_triple(knowrob:orientation,"+identifier+",Or), " +
01323
01324 "rdf_triple(knowrob:m00,Or,literal(type(_,_M00))), term_to_atom(M00,_M00)," +
01325 "rdf_triple(knowrob:m01,Or,literal(type(_,_M01))), term_to_atom(M01,_M01)," +
01326 "rdf_triple(knowrob:m02,Or,literal(type(_,_M02))), term_to_atom(M02,_M02)," +
01327 "rdf_triple(knowrob:m03,Or,literal(type(_,_M03))), term_to_atom(M03,_M03)," +
01328
01329 "rdf_triple(knowrob:m10,Or,literal(type(_,_M10))), term_to_atom(M10,_M10)," +
01330 "rdf_triple(knowrob:m11,Or,literal(type(_,_M11))), term_to_atom(M11,_M11)," +
01331 "rdf_triple(knowrob:m12,Or,literal(type(_,_M12))), term_to_atom(M12,_M12)," +
01332 "rdf_triple(knowrob:m13,Or,literal(type(_,_M13))), term_to_atom(M13,_M13)," +
01333
01334 "rdf_triple(knowrob:m20,Or,literal(type(_,_M20))), term_to_atom(M20,_M20)," +
01335 "rdf_triple(knowrob:m21,Or,literal(type(_,_M21))), term_to_atom(M21,_M21)," +
01336 "rdf_triple(knowrob:m22,Or,literal(type(_,_M22))), term_to_atom(M22,_M22)," +
01337 "rdf_triple(knowrob:m23,Or,literal(type(_,_M23))), term_to_atom(M23,_M23)," +
01338
01339 "rdf_triple(knowrob:m30,Or,literal(type(_,_M30))), term_to_atom(M30,_M30)," +
01340 "rdf_triple(knowrob:m31,Or,literal(type(_,_M31))), term_to_atom(M31,_M31)," +
01341 "rdf_triple(knowrob:m32,Or,literal(type(_,_M32))), term_to_atom(M32,_M32)," +
01342 "rdf_triple(knowrob:m33,Or,literal(type(_,_M33))), term_to_atom(M33,_M33)," +
01343
01344 "atom_to_term(_W,W,_), atom_to_term(_H,H,_), atom_to_term(_D,D,_)" , null);
01345
01346 if( counter.get("M00") != null && counter.get("M00").size() > 0) {
01347
01348 CounterTop c = new CounterTop(
01349 Float.valueOf(counter.get("M00").get(0).toString()),
01350 Float.valueOf(counter.get("M01").get(0).toString()),
01351 Float.valueOf(counter.get("M02").get(0).toString()),
01352 Float.valueOf(counter.get("M03").get(0).toString()),
01353
01354 Float.valueOf(counter.get("M10").get(0).toString()),
01355 Float.valueOf(counter.get("M11").get(0).toString()),
01356 Float.valueOf(counter.get("M12").get(0).toString()),
01357 Float.valueOf(counter.get("M13").get(0).toString()),
01358
01359 Float.valueOf(counter.get("M20").get(0).toString()),
01360 Float.valueOf(counter.get("M21").get(0).toString()),
01361 Float.valueOf(counter.get("M22").get(0).toString()),
01362 Float.valueOf(counter.get("M23").get(0).toString()),
01363
01364 Float.valueOf(counter.get("M30").get(0).toString()),
01365 Float.valueOf(counter.get("M31").get(0).toString()),
01366 Float.valueOf(counter.get("M32").get(0).toString()),
01367 Float.valueOf(counter.get("M33").get(0).toString()),
01368
01369 Float.valueOf(counter.get("D").get(0).toString()),
01370 Float.valueOf(counter.get("W").get(0).toString()),
01371 Float.valueOf(counter.get("H").get(0).toString()));
01372
01373 int col = grayValues[(++grayLevelCounter) % grayValues.length];
01374 c.defaultColor = convertColor(col, col, col, 255);
01375 c.setColor(c.defaultColor);
01376 c.name = identifier;
01377
01378 return c;
01379 }
01380
01381 HashMap<String, Vector<Object>> building = PrologVisualizationCanvas.executeQuery(
01382 "rdf_has("+identifier+", rdf:type, OBJECTCLASS)," +
01383 "rdf_reachable(OBJECTCLASS, rdfs:subClassOf, knowrob:'Building')," +
01384 "rdf_has("+identifier+",knowrob:widthOfObject,literal(type(_,_W)))," +
01385 "rdf_has("+identifier+",knowrob:heightOfObject,literal(type(_,_H))), " +
01386 "rdf_has("+identifier+",knowrob:depthOfObject,literal(type(_,_D))), " +
01387
01388 "rdf_triple(knowrob:orientation,"+identifier+",Or), " +
01389
01390 "rdf_triple(knowrob:m00,Or,literal(type(_,_M00))), term_to_atom(M00,_M00)," +
01391 "rdf_triple(knowrob:m01,Or,literal(type(_,_M01))), term_to_atom(M01,_M01)," +
01392 "rdf_triple(knowrob:m02,Or,literal(type(_,_M02))), term_to_atom(M02,_M02)," +
01393 "rdf_triple(knowrob:m03,Or,literal(type(_,_M03))), term_to_atom(M03,_M03)," +
01394
01395 "rdf_triple(knowrob:m10,Or,literal(type(_,_M10))), term_to_atom(M10,_M10)," +
01396 "rdf_triple(knowrob:m11,Or,literal(type(_,_M11))), term_to_atom(M11,_M11)," +
01397 "rdf_triple(knowrob:m12,Or,literal(type(_,_M12))), term_to_atom(M12,_M12)," +
01398 "rdf_triple(knowrob:m13,Or,literal(type(_,_M13))), term_to_atom(M13,_M13)," +
01399
01400 "rdf_triple(knowrob:m20,Or,literal(type(_,_M20))), term_to_atom(M20,_M20)," +
01401 "rdf_triple(knowrob:m21,Or,literal(type(_,_M21))), term_to_atom(M21,_M21)," +
01402 "rdf_triple(knowrob:m22,Or,literal(type(_,_M22))), term_to_atom(M22,_M22)," +
01403 "rdf_triple(knowrob:m23,Or,literal(type(_,_M23))), term_to_atom(M23,_M23)," +
01404
01405 "rdf_triple(knowrob:m30,Or,literal(type(_,_M30))), term_to_atom(M30,_M30)," +
01406 "rdf_triple(knowrob:m31,Or,literal(type(_,_M31))), term_to_atom(M31,_M31)," +
01407 "rdf_triple(knowrob:m32,Or,literal(type(_,_M32))), term_to_atom(M32,_M32)," +
01408 "rdf_triple(knowrob:m33,Or,literal(type(_,_M33))), term_to_atom(M33,_M33)," +
01409
01410 "atom_to_term(_W,W,_), atom_to_term(_H,H,_), atom_to_term(_D,D,_)" , null);
01411
01412 if( building.get("M00") != null && building.get("M00").size() > 0) {
01413
01414 Building b = new Building(
01415 Float.valueOf(building.get("M00").get(0).toString()),
01416 Float.valueOf(building.get("M01").get(0).toString()),
01417 Float.valueOf(building.get("M02").get(0).toString()),
01418 100*Float.valueOf(building.get("M03").get(0).toString()),
01419
01420 Float.valueOf(building.get("M10").get(0).toString()),
01421 Float.valueOf(building.get("M11").get(0).toString()),
01422 Float.valueOf(building.get("M12").get(0).toString()),
01423 100*Float.valueOf(building.get("M13").get(0).toString()),
01424
01425 Float.valueOf(building.get("M20").get(0).toString()),
01426 Float.valueOf(building.get("M21").get(0).toString()),
01427 Float.valueOf(building.get("M22").get(0).toString()),
01428 100*Float.valueOf(building.get("M23").get(0).toString()),
01429
01430 Float.valueOf(building.get("M30").get(0).toString()),
01431 Float.valueOf(building.get("M31").get(0).toString()),
01432 Float.valueOf(building.get("M32").get(0).toString()),
01433 Float.valueOf(building.get("M33").get(0).toString()),
01434
01435 100*Float.valueOf(building.get("D").get(0).toString()),
01436 100*Float.valueOf(building.get("W").get(0).toString()),
01437 100*Float.valueOf(building.get("H").get(0).toString()));
01438
01439 int col = grayValues[(++grayLevelCounter) % grayValues.length];
01440 b.defaultColor = convertColor(col, col, col, 255);
01441 b.setColor(b.defaultColor);
01442 b.name = identifier;
01443
01444 return b;
01445 }
01446
01447
01448 HashMap<String, Vector<Object>> level = PrologVisualizationCanvas.executeQuery(
01449 "rdf_has("+identifier+", rdf:type, OBJECTCLASS)," +
01450 "rdf_reachable(OBJECTCLASS, rdfs:subClassOf, knowrob:'LevelOfAConstruction')," +
01451 "rdf_has("+identifier+",knowrob:widthOfObject,literal(type(_,_W)))," +
01452 "rdf_has("+identifier+",knowrob:heightOfObject,literal(type(_,_H))), " +
01453 "rdf_has("+identifier+",knowrob:depthOfObject,literal(type(_,_D))), " +
01454
01455 "rdf_triple(knowrob:orientation,"+identifier+",Or), " +
01456
01457 "rdf_triple(knowrob:m00,Or,literal(type(_,_M00))), term_to_atom(M00,_M00)," +
01458 "rdf_triple(knowrob:m01,Or,literal(type(_,_M01))), term_to_atom(M01,_M01)," +
01459 "rdf_triple(knowrob:m02,Or,literal(type(_,_M02))), term_to_atom(M02,_M02)," +
01460 "rdf_triple(knowrob:m03,Or,literal(type(_,_M03))), term_to_atom(M03,_M03)," +
01461
01462 "rdf_triple(knowrob:m10,Or,literal(type(_,_M10))), term_to_atom(M10,_M10)," +
01463 "rdf_triple(knowrob:m11,Or,literal(type(_,_M11))), term_to_atom(M11,_M11)," +
01464 "rdf_triple(knowrob:m12,Or,literal(type(_,_M12))), term_to_atom(M12,_M12)," +
01465 "rdf_triple(knowrob:m13,Or,literal(type(_,_M13))), term_to_atom(M13,_M13)," +
01466
01467 "rdf_triple(knowrob:m20,Or,literal(type(_,_M20))), term_to_atom(M20,_M20)," +
01468 "rdf_triple(knowrob:m21,Or,literal(type(_,_M21))), term_to_atom(M21,_M21)," +
01469 "rdf_triple(knowrob:m22,Or,literal(type(_,_M22))), term_to_atom(M22,_M22)," +
01470 "rdf_triple(knowrob:m23,Or,literal(type(_,_M23))), term_to_atom(M23,_M23)," +
01471
01472 "rdf_triple(knowrob:m30,Or,literal(type(_,_M30))), term_to_atom(M30,_M30)," +
01473 "rdf_triple(knowrob:m31,Or,literal(type(_,_M31))), term_to_atom(M31,_M31)," +
01474 "rdf_triple(knowrob:m32,Or,literal(type(_,_M32))), term_to_atom(M32,_M32)," +
01475 "rdf_triple(knowrob:m33,Or,literal(type(_,_M33))), term_to_atom(M33,_M33)," +
01476
01477 "atom_to_term(_W,W,_), atom_to_term(_H,H,_), atom_to_term(_D,D,_)" , null);
01478
01479 if( level.get("M00") != null && level.get("M00").size() > 0) {
01480
01481 LevelOfAConstruction l = new LevelOfAConstruction(
01482 Float.valueOf(level.get("M00").get(0).toString()),
01483 Float.valueOf(level.get("M01").get(0).toString()),
01484 Float.valueOf(level.get("M02").get(0).toString()),
01485 Float.valueOf(level.get("M03").get(0).toString()),
01486
01487 Float.valueOf(level.get("M10").get(0).toString()),
01488 Float.valueOf(level.get("M11").get(0).toString()),
01489 Float.valueOf(level.get("M12").get(0).toString()),
01490 Float.valueOf(level.get("M13").get(0).toString()),
01491
01492 Float.valueOf(level.get("M20").get(0).toString()),
01493 Float.valueOf(level.get("M21").get(0).toString()),
01494 Float.valueOf(level.get("M22").get(0).toString()),
01495 Float.valueOf(level.get("M23").get(0).toString()),
01496
01497 Float.valueOf(level.get("M30").get(0).toString()),
01498 Float.valueOf(level.get("M31").get(0).toString()),
01499 Float.valueOf(level.get("M32").get(0).toString()),
01500 Float.valueOf(level.get("M33").get(0).toString()),
01501
01502 Float.valueOf(level.get("D").get(0).toString()),
01503 Float.valueOf(level.get("W").get(0).toString()),
01504 Float.valueOf(level.get("H").get(0).toString()));
01505
01506 int col = grayValues[(++grayLevelCounter) % grayValues.length];
01507 l.defaultColor = convertColor(col, col, col, 255);
01508 l.setColor(l.defaultColor);
01509 l.name = identifier;
01510
01511 return l;
01512 }
01513
01514
01515
01516 HashMap<String, Vector<Object>> room = PrologVisualizationCanvas.executeQuery(
01517 "rdf_has("+identifier+", rdf:type, OBJECTCLASS)," +
01518 "( rdf_reachable(OBJECTCLASS, rdfs:subClassOf, knowrob:'RoomInAConstruction');" +
01519 " rdf_reachable(OBJECTCLASS, rdfs:subClassOf, knowrob:'MultiRoomUnit') )," +
01520 "rdf_has("+identifier+",knowrob:widthOfObject,literal(type(_,_W)))," +
01521 "rdf_has("+identifier+",knowrob:heightOfObject,literal(type(_,_H))), " +
01522 "rdf_has("+identifier+",knowrob:depthOfObject,literal(type(_,_D))), " +
01523
01524 "rdf_triple(knowrob:orientation,"+identifier+",Or), " +
01525
01526 "rdf_triple(knowrob:m00,Or,literal(type(_,_M00))), term_to_atom(M00,_M00)," +
01527 "rdf_triple(knowrob:m01,Or,literal(type(_,_M01))), term_to_atom(M01,_M01)," +
01528 "rdf_triple(knowrob:m02,Or,literal(type(_,_M02))), term_to_atom(M02,_M02)," +
01529 "rdf_triple(knowrob:m03,Or,literal(type(_,_M03))), term_to_atom(M03,_M03)," +
01530
01531 "rdf_triple(knowrob:m10,Or,literal(type(_,_M10))), term_to_atom(M10,_M10)," +
01532 "rdf_triple(knowrob:m11,Or,literal(type(_,_M11))), term_to_atom(M11,_M11)," +
01533 "rdf_triple(knowrob:m12,Or,literal(type(_,_M12))), term_to_atom(M12,_M12)," +
01534 "rdf_triple(knowrob:m13,Or,literal(type(_,_M13))), term_to_atom(M13,_M13)," +
01535
01536 "rdf_triple(knowrob:m20,Or,literal(type(_,_M20))), term_to_atom(M20,_M20)," +
01537 "rdf_triple(knowrob:m21,Or,literal(type(_,_M21))), term_to_atom(M21,_M21)," +
01538 "rdf_triple(knowrob:m22,Or,literal(type(_,_M22))), term_to_atom(M22,_M22)," +
01539 "rdf_triple(knowrob:m23,Or,literal(type(_,_M23))), term_to_atom(M23,_M23)," +
01540
01541 "rdf_triple(knowrob:m30,Or,literal(type(_,_M30))), term_to_atom(M30,_M30)," +
01542 "rdf_triple(knowrob:m31,Or,literal(type(_,_M31))), term_to_atom(M31,_M31)," +
01543 "rdf_triple(knowrob:m32,Or,literal(type(_,_M32))), term_to_atom(M32,_M32)," +
01544 "rdf_triple(knowrob:m33,Or,literal(type(_,_M33))), term_to_atom(M33,_M33)," +
01545
01546 "atom_to_term(_W,W,_), atom_to_term(_H,H,_), atom_to_term(_D,D,_)" , null);
01547
01548 if( room.get("M00") != null && room.get("M00").size() > 0) {
01549
01550 RoomInAConstruction ro = new RoomInAConstruction(
01551 Float.valueOf(room.get("M00").get(0).toString()),
01552 Float.valueOf(room.get("M01").get(0).toString()),
01553 Float.valueOf(room.get("M02").get(0).toString()),
01554 Float.valueOf(room.get("M03").get(0).toString()),
01555
01556 Float.valueOf(room.get("M10").get(0).toString()),
01557 Float.valueOf(room.get("M11").get(0).toString()),
01558 Float.valueOf(room.get("M12").get(0).toString()),
01559 Float.valueOf(room.get("M13").get(0).toString()),
01560
01561 Float.valueOf(room.get("M20").get(0).toString()),
01562 Float.valueOf(room.get("M21").get(0).toString()),
01563 Float.valueOf(room.get("M22").get(0).toString()),
01564 Float.valueOf(room.get("M23").get(0).toString()),
01565
01566 Float.valueOf(room.get("M30").get(0).toString()),
01567 Float.valueOf(room.get("M31").get(0).toString()),
01568 Float.valueOf(room.get("M32").get(0).toString()),
01569 Float.valueOf(room.get("M33").get(0).toString()),
01570
01571 Float.valueOf(room.get("D").get(0).toString()),
01572 Float.valueOf(room.get("W").get(0).toString()),
01573 Float.valueOf(room.get("H").get(0).toString()));
01574
01575 int col = grayValues[(++grayLevelCounter) % grayValues.length];
01576 ro.defaultColor = convertColor(col, col, col, 255);
01577 ro.setColor(ro.defaultColor);
01578 ro.name = identifier;
01579
01580 return ro;
01581 }
01582
01583 HashMap<String, Vector<Object>> pose = PrologVisualizationCanvas.executeQuery(
01584 "rdf_has("+identifier+", rdf:type, OBJECTCLASS)," +
01585 "rdf_reachable(OBJECTCLASS, rdfs:subClassOf, knowrob:'Place')," +
01586 "rdf_triple(knowrob:orientation,"+identifier+",Or), " +
01587 "rdf_triple(knowrob:m00,Or,_LM00),strip_literal_type(_LM00,_M00),atom_to_term(_M00,M00,_)," +
01588 "rdf_triple(knowrob:m01,Or,_LM01),strip_literal_type(_LM01,_M01),atom_to_term(_M01,M01,_)," +
01589 "rdf_triple(knowrob:m02,Or,_LM02),strip_literal_type(_LM02,_M02),atom_to_term(_M02,M02,_)," +
01590 "rdf_triple(knowrob:m03,Or,_LM03),strip_literal_type(_LM03,_M03),atom_to_term(_M03,M03,_)," +
01591 "rdf_triple(knowrob:m10,Or,_LM10),strip_literal_type(_LM10,_M10),atom_to_term(_M10,M10,_)," +
01592 "rdf_triple(knowrob:m11,Or,_LM11),strip_literal_type(_LM11,_M11),atom_to_term(_M11,M11,_)," +
01593 "rdf_triple(knowrob:m12,Or,_LM12),strip_literal_type(_LM12,_M12),atom_to_term(_M12,M12,_)," +
01594 "rdf_triple(knowrob:m13,Or,_LM13),strip_literal_type(_LM13,_M13),atom_to_term(_M13,M13,_)," +
01595 "rdf_triple(knowrob:m20,Or,_LM20),strip_literal_type(_LM20,_M20),atom_to_term(_M20,M20,_)," +
01596 "rdf_triple(knowrob:m21,Or,_LM21),strip_literal_type(_LM21,_M21),atom_to_term(_M21,M21,_)," +
01597 "rdf_triple(knowrob:m22,Or,_LM22),strip_literal_type(_LM22,_M22),atom_to_term(_M22,M22,_)," +
01598 "rdf_triple(knowrob:m23,Or,_LM23),strip_literal_type(_LM23,_M23),atom_to_term(_M23,M23,_)," +
01599 "rdf_triple(knowrob:m30,Or,_LM30),strip_literal_type(_LM30,_M30),atom_to_term(_M30,M30,_)," +
01600 "rdf_triple(knowrob:m31,Or,_LM31),strip_literal_type(_LM31,_M31),atom_to_term(_M31,M31,_)," +
01601 "rdf_triple(knowrob:m32,Or,_LM32),strip_literal_type(_LM32,_M32),atom_to_term(_M32,M32,_)," +
01602 "rdf_triple(knowrob:m33,Or,_LM33),strip_literal_type(_LM33,_M33),atom_to_term(_M33,M33,_)", null);
01603
01604 if( pose.get("M00") != null && pose.get("M00").size() > 0) {
01605
01606 Pose p = new Pose(
01607 Float.valueOf(pose.get("M00").get(0).toString()),
01608 Float.valueOf(pose.get("M01").get(0).toString()),
01609 Float.valueOf(pose.get("M02").get(0).toString()),
01610 Float.valueOf(pose.get("M03").get(0).toString()),
01611
01612 Float.valueOf(pose.get("M10").get(0).toString()),
01613 Float.valueOf(pose.get("M11").get(0).toString()),
01614 Float.valueOf(pose.get("M12").get(0).toString()),
01615 Float.valueOf(pose.get("M13").get(0).toString()),
01616
01617 Float.valueOf(pose.get("M20").get(0).toString()),
01618 Float.valueOf(pose.get("M21").get(0).toString()),
01619 Float.valueOf(pose.get("M22").get(0).toString()),
01620 Float.valueOf(pose.get("M23").get(0).toString()),
01621
01622 Float.valueOf(pose.get("M30").get(0).toString()),
01623 Float.valueOf(pose.get("M31").get(0).toString()),
01624 Float.valueOf(pose.get("M32").get(0).toString()),
01625 Float.valueOf(pose.get("M33").get(0).toString()),
01626
01627 0.35f,
01628 0.35f,
01629 0.0f);
01630
01631 int col = grayValues[(++grayLevelCounter) % grayValues.length];
01632 p.defaultColor = convertColor(col, col, col, 255);
01633 p.setColor(p.defaultColor);
01634 p.name = identifier;
01635
01636 return p;
01637 }
01638
01639
01640 HashMap<String, Vector<Object>> box = PrologVisualizationCanvas.executeQuery(
01641 "rdf_has("+identifier+", rdf:type, OBJECTCLASS)," +
01642
01643 "( rdf_reachable(OBJECTCLASS, rdfs:subClassOf, knowrob:'ConstructionArtifact');" +
01644 "rdf_reachable(OBJECTCLASS, rdfs:subClassOf, knowrob:'FurniturePiece'))," +
01645
01646 "rdf_has("+identifier+",knowrob:widthOfObject,literal(type(_,_W)))," +
01647 "rdf_has("+identifier+",knowrob:heightOfObject,literal(type(_,_H))), " +
01648 "rdf_has("+identifier+",knowrob:depthOfObject,literal(type(_,_D))), " +
01649
01650
01651 "rdf_triple(knowrob:orientation,"+identifier+",Or), " +
01652
01653 "rdf_triple(knowrob:m00,Or,literal(type(_,_M00))), term_to_atom(M00,_M00)," +
01654 "rdf_triple(knowrob:m01,Or,literal(type(_,_M01))), term_to_atom(M01,_M01)," +
01655 "rdf_triple(knowrob:m02,Or,literal(type(_,_M02))), term_to_atom(M02,_M02)," +
01656 "rdf_triple(knowrob:m03,Or,literal(type(_,_M03))), term_to_atom(M03,_M03)," +
01657
01658 "rdf_triple(knowrob:m10,Or,literal(type(_,_M10))), term_to_atom(M10,_M10)," +
01659 "rdf_triple(knowrob:m11,Or,literal(type(_,_M11))), term_to_atom(M11,_M11)," +
01660 "rdf_triple(knowrob:m12,Or,literal(type(_,_M12))), term_to_atom(M12,_M12)," +
01661 "rdf_triple(knowrob:m13,Or,literal(type(_,_M13))), term_to_atom(M13,_M13)," +
01662
01663 "rdf_triple(knowrob:m20,Or,literal(type(_,_M20))), term_to_atom(M20,_M20)," +
01664 "rdf_triple(knowrob:m21,Or,literal(type(_,_M21))), term_to_atom(M21,_M21)," +
01665 "rdf_triple(knowrob:m22,Or,literal(type(_,_M22))), term_to_atom(M22,_M22)," +
01666 "rdf_triple(knowrob:m23,Or,literal(type(_,_M23))), term_to_atom(M23,_M23)," +
01667
01668 "rdf_triple(knowrob:m30,Or,literal(type(_,_M30))), term_to_atom(M30,_M30)," +
01669 "rdf_triple(knowrob:m31,Or,literal(type(_,_M31))), term_to_atom(M31,_M31)," +
01670 "rdf_triple(knowrob:m32,Or,literal(type(_,_M32))), term_to_atom(M32,_M32)," +
01671 "rdf_triple(knowrob:m33,Or,literal(type(_,_M33))), term_to_atom(M33,_M33)," +
01672
01673 "atom_to_term(_W,W,_), atom_to_term(_H,H,_), atom_to_term(_D,D,_)" , null);
01674
01675 if( box.get("M00") != null && box.get("M00").size() > 0) {
01676
01677 Box b = new Box(
01678 Float.valueOf(box.get("M00").get(0).toString()),
01679 Float.valueOf(box.get("M01").get(0).toString()),
01680 Float.valueOf(box.get("M02").get(0).toString()),
01681 Float.valueOf(box.get("M03").get(0).toString()),
01682
01683 Float.valueOf(box.get("M10").get(0).toString()),
01684 Float.valueOf(box.get("M11").get(0).toString()),
01685 Float.valueOf(box.get("M12").get(0).toString()),
01686 Float.valueOf(box.get("M13").get(0).toString()),
01687
01688 Float.valueOf(box.get("M20").get(0).toString()),
01689 Float.valueOf(box.get("M21").get(0).toString()),
01690 Float.valueOf(box.get("M22").get(0).toString()),
01691 Float.valueOf(box.get("M23").get(0).toString()),
01692
01693 Float.valueOf(box.get("M30").get(0).toString()),
01694 Float.valueOf(box.get("M31").get(0).toString()),
01695 Float.valueOf(box.get("M32").get(0).toString()),
01696 Float.valueOf(box.get("M33").get(0).toString()),
01697
01698 Float.valueOf(box.get("D").get(0).toString()),
01699 Float.valueOf(box.get("W").get(0).toString()),
01700 Float.valueOf(box.get("H").get(0).toString()));
01701
01702 int col = grayValues[(++grayLevelCounter) % grayValues.length];
01703 b.defaultColor = convertColor(col, col, col, 255);
01704 b.setColor(b.defaultColor);
01705 b.name = identifier;
01706
01707 return b;
01708 }
01709
01710
01711
01712 }
01713 displayMessage("could not find how to add Item "+identifier+"\nType was: "+type);
01714 return null;
01715
01716 }
01717
01718
01719
01723
01724
01725
01726
01727
01728
01729
01730
01731
01732
01733
01734
01735
01736
01737
01738
01739
01740
01741
01742
01743
01744
01745
01746
01747
01748
01749
01750
01751
01752
01753
01754
01755
01756
01757
01758
01759
01760
01761
01762
01763
01764
01765
01766
01767
01768
01769
01770
01771
01772
01773
01774
01775
01776
01777
01778
01779
01780
01781
01782
01783
01784
01785
01786
01787
01788
01789
01790
01791
01792
01793
01794 public void mouseClicked(MouseEvent e) {
01795 String clickedOn = getItemAt(e.getX(), e.getY());
01796 displayMessage(clickedOn+"");
01797 if(clickedOn != null) {
01798 prologVisCanvas.displayInfoFor(clickedOn);
01799 }
01800 delay(100);
01801 redraw();
01802 }
01803
01804
01805
01806
01807
01808
01809
01810
01811
01812
01813
01814
01815
01816
01817
01818
01819
01820
01821
01822
01823
01824
01825
01826
01827
01828
01829
01830
01831
01832
01833
01834
01835
01836
01837
01838
01839
01840
01841
01842
01843
01844
01845
01846 public void keyPressed(){
01847
01848 switch(keyCode) {
01849 case RIGHT:
01850 currentFrame++;
01851 break;
01852 case LEFT:
01853 currentFrame--;
01854 break;
01855 case java.awt.event.KeyEvent.VK_PAGE_UP:
01856 currentFrame+=10;
01857 break;
01858 case java.awt.event.KeyEvent.VK_PAGE_DOWN:
01859 currentFrame-=10;
01860 timer.stop();
01861 break;
01862 case java.awt.event.KeyEvent.VK_SPACE:
01863 if(timer.isRunning())
01864 timer.stop();
01865 else
01866 timer.start();
01867 break;
01868 case KeyEvent.VK_C:
01869 clear();
01870 break;
01871 case KeyEvent.VK_B:
01872 drawBackground();
01873 break;
01874 case KeyEvent.VK_X:
01875 bufferFrame.setVisible(!bufferFrame.isVisible());
01876 break;
01877 case KeyEvent.VK_Y:
01878 buffer.resetMatrix();
01879 this.resetMatrix();
01880 case KeyEvent.VK_P:
01881 this.record = true;
01882 break;
01883 case KeyEvent.VK_Q:
01884 cam.setRotations(-Math.PI/2,Math.PI/4,-Math.PI);
01885 cam.lookAt(0.0,0.0,0.0,cam.getDistance());
01886 break;
01887 case KeyEvent.VK_E:
01888 cam.setRotations(-Math.PI,0.0,0.0);
01889 cam.lookAt(0.0,0.0,0.0,cam.getDistance());
01890 break;
01891 case KeyEvent.VK_A:
01892 cam.rotateY(-ROTATE_Y_DELTA);
01893 break;
01894 case KeyEvent.VK_D:
01895 cam.rotateY(ROTATE_Y_DELTA);
01896 break;
01897 case KeyEvent.VK_W:
01898 float[] rpy = cam.getRotations();
01899 float[] lat = cam.getLookAt();
01900
01901 double dist = cam.getDistance();
01902 CameraState state = new CameraState(new Rotation(RotationOrder.XYZ,
01903 rpy[0],
01904 rpy[1],
01905 rpy[2]),
01906 new Vector3D((lat[0])* 0.75,
01907 (lat[1])* 0.75,
01908 (lat[2])* 0.75),
01909 dist);
01910 state.apply(this);
01911 cam.setState(state);
01912 break;
01913 case KeyEvent.VK_S:
01914 float[] rpy2 = cam.getRotations();
01915 float[] lat2 = cam.getLookAt();
01916 float[] pos2 = cam.getPosition();
01917 double dist2 = cam.getDistance();
01918 CameraState state2 = new CameraState(new Rotation(RotationOrder.XYZ,
01919 rpy2[0],
01920 rpy2[1],
01921 rpy2[2]),
01922 new Vector3D((lat2[0] + pos2[0])/2,
01923 (lat2[1] + pos2[1])/2,
01924 (lat2[2] + pos2[2])/2),
01925 dist2);
01926 state2.apply(this);
01927 cam.setState(state2);
01928
01929 break;
01930 case KeyEvent.VK_J:
01931 hint(DISABLE_DEPTH_SORT);
01932 break;
01933 case KeyEvent.VK_K:
01934 hint(ENABLE_DEPTH_SORT);
01935 break;
01936
01937 }
01938 if(currentFrame < 0) currentFrame = 0;
01939 if(currentFrame>= numberFrames) currentFrame = numberFrames-1;
01940 delay(100);
01941 redraw();
01942 }
01943
01944
01945
01946
01947
01949
01950
01951
01952
01953 public void setViewParameters(float xShift, float yShift, float xRot, float yRot, float zoom) {
01954 this.xShiftDisplay = xShift;
01955 this.yShiftDisplay = yShift;
01956 this.xRotDisplay = xRot;
01957 this.yRotDisplay = yRot;
01958 this.zoomDisplay = zoom;
01959 }
01960
01961
01962 public ArrayList<Point[]> sortArray(ArrayList<Point[]> actionsArray){
01963
01964 for(int i = 0; i < actionsArray.size()-1; i++){
01965 for(int j = i+1; j < actionsArray.size(); j++){
01966 if(actionsArray.get(i)[0].time > actionsArray.get(j)[0].time){
01967 Point aux = new Point();
01968 for (int l = 0; l < 28; l++){
01969 aux = actionsArray.get(j)[l];
01970 actionsArray.get(j)[l] = actionsArray.get(i)[l];
01971 actionsArray.get(i)[l] = aux;
01972 }
01973 }
01974 }
01975 }
01976 return actionsArray;
01977 }
01978
01979
01980 public int[] makeColor(int r,int g,int b){
01981 int[] color = new int[3];
01982 color[0] = r; color[1] = g; color[2] = b;
01983 return color;
01984 }
01985
01986
01987
01988 public void setColors(){
01989
01990 colors.add(makeColor(0,0,255));
01991 colors.add(makeColor(30,144,255));
01992
01993 colors.add(makeColor(0,255,255));
01994 colors.add(makeColor(180,255,255));
01995
01996 colors.add(makeColor(255,215,0));
01997 colors.add(makeColor(238,221,130));
01998
01999 colors.add(makeColor(250,128,114));
02000 colors.add(makeColor(255,160,122));
02001
02002 colors.add(makeColor(255,105,180));
02003 colors.add(makeColor(255,228,225));
02004
02005 colors.add(makeColor(186,85,211));
02006 colors.add(makeColor(221,160,221));
02007 }
02008
02009 final Timer timer = new Timer(40, new ActionListener() {
02010 public void actionPerformed(ActionEvent event) {
02011 int frameBefore = currentFrame;
02012 if(playingForward == true) currentFrame++;
02013 if(playingForward == false) currentFrame--;
02014 if(currentFrame < 0) currentFrame = 0;
02015 if(currentFrame>= numberFrames) currentFrame = numberFrames-1;
02016 if(currentFrame != frameBefore) redraw();
02017 }
02018 });
02019
02020
02021 public class MenuHuman{
02022
02023
02024 int xtr = 10; int ytr = 10;
02025 int widthtr = 70; int heighttr = 20;
02026 int xtxt = 15; int ytxt = 15;
02027 int widthtxt = 60; int heighttxt = 10;
02028
02029
02030 int xrew1 = 90; int xrew2 = 115; int xrew3 = 115;
02031 int yrew1 = 20; int yrew2 = 10; int yrew3 = 30;
02032
02033
02034 int xps = 125; int xps1 = 128; int xps2 = 137;
02035 int yps = 10; int yps1 = 10; int yps2 = 10;
02036 int widthps = 20; int widthps1 = 5; int widthps2 = 5;
02037 int heightps = 20; int heightps1 = 20; int heightps2 = 20;
02038
02039
02040
02041 int xpl1 = 155; int xpl2 = 155; int xpl3 = 180;
02042 int ypl1 = 10; int ypl2 = 30; int ypl3 = 20;
02043
02044
02045 int xstop = 190; int ystop = 10;
02046 int widthstop = 20; int heightstop = 20;
02047
02048
02049 int xrews = 220; int yrews = 10;
02050 int widthrews = 25; int heightrews = 20;
02051
02052 int xrews1 = 220; int xrews2 = 235; int xrews3 = 235; int xrews4 = 239;
02053 int yrews1 = 20; int yrews2 = 10; int yrews3 = 30; int yrews4 = 10;
02054 int widthrews4 = 5; int heightrews4 = 20;
02055
02056
02057 int widthpls = 25; int heightpls = 20; int widthpls4 = 5; int heightpls4 = 20;
02058
02059 int xpls = 255; int xpls1 = 264; int xpls2 = 264; int xpls3 = 279; int xpls4 = 255;
02060 int ypls = 10; int ypls1 = 10; int ypls2 = 30; int ypls3 = 20; int ypls4 = 10;
02061
02062
02063 public void drawMenu(){
02064 noStroke();
02065
02066 fill(238,238,224);
02067 rect(xtr, ytr, widthtr, heighttr);
02068 fill(238,238,224);
02069 triangle(xrew1, yrew1, xrew2, yrew2, xrew3, yrew3);
02070 rect(xps1, yps1, widthps1, heightps1);
02071 rect(xps2, yps2, widthps2, heightps2);
02072 triangle(xpl1, ypl1, xpl2, ypl2, xpl3, ypl3);
02073 rect(xstop, ystop, widthstop, heightstop);
02074 triangle(xpls1, ypls1, xpls2, ypls2, xpls3, ypls3);
02075 rect(xpls4, ypls4, widthpls4, heightpls4);
02076 triangle(xrews1, yrews1, xrews2, yrews2, xrews3, yrews3);
02077 rect(xrews4, yrews4, widthrews4, heightrews4);
02078
02079
02080 fill(0,0,0);stroke(0);
02081 textFont(verdanaBold);
02082 textMode(SCREEN);
02083 textAlign(LEFT);
02084 String s = "Trajectory";
02085 text(s, xtxt, ytxt, widthtxt, heighttxt);
02086 }
02087
02088 public boolean mouseInTriangle(int xm, int ym, int x1, int y1, int x2, int y2, int x3, int y3){
02089 int fAB = (ym-y1)*(x2-x1) - (xm-x1)*(y2-y1);
02090 int fCA = (ym-y3)*(x1-x3) - (xm-x3)*(y1-y3);
02091 int fBC = (ym-y2)*(x3-x2) - (xm-x2)*(y3-y2);
02092
02093 if ((fAB*fBC > 0) && (fBC*fCA>0))
02094 return true;
02095 return false;
02096 }
02097
02098 public boolean mouseInRectangle(int xm, int ym, int xr, int yr, int width, int height){
02099 if ((xm >= xr) && (xm <= xr+width) && (ym >= yr) && (ym <= yr+height)) {
02100 return true;
02101 } else {
02102 return false;
02103 }
02104 }
02105
02106 public int trackingDialog(){
02107
02108 String[] possibilities = {"BEC", "ULW", "OLW", "UBW", "OBW", "UHW", "BRK", "OHW", "KO", "SEH", "OSL", "USL", "FUL", "FBL",
02109 "OST", "USR", "FUR", "FBR", "SBL", "OAL", "UAL", "HAL", "FIL", "SBR", "OAR", "UAR", "HAR", "FIR"};
02110
02111
02112 for(int i = 0; i < possibilities.length; i++){
02113 for (int j = i+1; j < 28; j++){
02114 if (possibilities[i].compareTo(possibilities[j]) > 0){
02115 String aux = possibilities[i];
02116 possibilities[i] = possibilities[j];
02117 possibilities[j] = aux;
02118 }
02119 }
02120 }
02121 JOptionPane.showInputDialog(null, "Select the body part you want to track:\n","Customized Dialog",
02122 JOptionPane.PLAIN_MESSAGE, null, possibilities, "");
02123
02124
02125
02126
02127
02128
02129
02130 return -1;
02131 }
02132
02133 }
02134
02135 public static int convertColor(int red, int green, int blue, int alpha) {
02136 return (((((alpha << 8) + red) << 8) + green) << 8) + blue;
02137 }
02138
02139
02144 private void readMeshData(String file) {
02145
02146 BufferedReader reader = createReader(file);
02147 try{
02148
02149 String line;
02150 boolean pointFlag=false, triangleFlag=false;
02151
02152
02153 int ptOffset = meshpoints.size();
02154
02155 while(true) {
02156
02157 line = reader.readLine();
02158 if(line==null){break;}
02159
02160
02161
02162 if(pointFlag && (line.matches("\\-?[\\d]*\\.?[\\d]*e?\\-?[\\d]* \\-?[\\d]*\\.?[\\d]*e?\\-?[\\d]* \\-?[\\d]*\\.?[\\d]*e?\\-?[\\d]*"))) {
02163 String[] coords = line.split(" ");
02164 if(coords.length==3) {
02165
02166 this.meshpoints.add(new float[] {
02167 Float.valueOf(coords[0]),
02168 Float.valueOf(coords[1]),
02169 Float.valueOf(coords[2])});
02170 }
02171 continue;
02172 }
02173
02174
02175
02176 if(triangleFlag && (line.matches("3 [\\d]* [\\d]* [\\d]*"))) {
02177 String[] pts = line.split(" ");
02178 if(pts.length==4) {
02179
02180 this.meshtriangles.add(new int[] {
02181 Integer.valueOf(pts[1])+ptOffset,
02182 Integer.valueOf(pts[2])+ptOffset,
02183 Integer.valueOf(pts[3])+ptOffset});
02184
02185 }
02186 continue;}
02187
02188
02189 if(line.matches("POINTS.*")) {
02190 pointFlag=true;
02191 triangleFlag=false;
02192 continue;
02193 }
02194
02195 if(line.matches("POLYGONS.*")) {
02196 pointFlag=false;
02197 triangleFlag=true;
02198 continue;
02199 }
02200 }
02201
02202 } catch (IOException e) {}
02203 }
02204
02205
02206 ItemBase itemForObjType(String type) {
02207
02209
02210
02211 if(type.endsWith("#Cup'")) {
02212 return new Cup(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1, 0,0,0);
02213
02214 } else if(type.endsWith("#DrinkingMug'")) {
02215 return new Cup(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1, 0,0,0);
02216
02217 } else if(type.endsWith("#DinnerPlate'")) {
02218 return new Plate(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1, 0,0,0);
02219
02220 } else if (type.endsWith("#DrinkingGlass'")) {
02221 return new DrinkingGlass(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1, 0,0,0);
02222
02223 } else if (type.endsWith("#Bowl-Eating'")) {
02224 return new BowlEating(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1, 0,0,0);
02225
02226 } else if (type.endsWith("#DrinkingBottle'")) {
02227 return new Box(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1, 0.05f,0.05f,0.15f);
02228
02229 } else if (type.endsWith("#Kettle'")) {
02230 return new Kettle(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1, 0,0,0);
02231
02233
02234
02235 } else if(type.endsWith("#DinnerFork'")) {
02236 return new Fork(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1, 0,0,0);
02237
02238 } else if(type.endsWith("#TableKnife'")) {
02239 return new Knife(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1, 0,0,0);
02240
02241 } else if(type.endsWith("#Knife'")) {
02242 return new Knife(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1, 0,0,0);
02243
02244 } else if(type.endsWith("#SoupSpoon'")) {
02245 return new Spoon(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1, 0,0,0);
02246
02247
02249
02250
02251 } else if(type.endsWith("#Sponge-CleaningImplement'")) {
02252 return new Box(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1, 0.05f,0.10f,0.05f);
02253
02254 } else if(type.endsWith("#Napkin'")) {
02255 return new Napkin(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1, 0,0,0);
02256
02257 } else if(type.endsWith("#PlaceMat'")) {
02258 return new PlaceMat(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1, 0,0,0);
02259
02260 } else if(type.endsWith("#Tray'")) {
02261 return new PlaceMat(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1, 0,0,0);
02262
02263 } else if (type.endsWith("#Platter'")) {
02264 return new Platter(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1, 0,0,0);
02265
02266 } else if(type.endsWith("#CookingPot'")) {
02267 return new CookingPot(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1, 0,0,0);
02268
02269 } else if(type.endsWith("#Spatula'")) {
02270 return new Spatula(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1, 0,0,0);
02271
02272 } else if(type.endsWith("#PancakeMaker'")) {
02273 return new PancakeMaker(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1, 0,0,0);
02274
02275
02277
02278
02279 } else if (type.endsWith("#Bread'")) {
02280 return new Bread(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1, 0,0,0);
02281
02282 } else if (type.endsWith("#Cheese'")) {
02283 return new Cheese(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1, 0,0,0);
02284
02285 } else if (type.endsWith("#Sausage'")) {
02286 return new Sausage(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1, 0,0,0);
02287
02288 } else if (type.endsWith("#Cake'")) {
02289 return new Cake(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1, 0,0,0);
02290
02291 } else if (type.endsWith("#BreakfastCereal'")) {
02292 return new CerealBox(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1, 0,0,0);
02293
02294 } else if (type.endsWith("#PancakeMix'")) {
02295 return new PancakeMix(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1, 0,0,0);
02296
02297 } else if (type.endsWith("#Pancake'")) {
02298 return new Pancake(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1, 0,0,0);
02299
02300
02302
02303
02304 } else if (type.endsWith("#Pizza'")) {
02305 return new Pizza(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1, 0,0,0);
02306
02307 } else if (type.endsWith("#Salad'")) {
02308 return new SaladBowl(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1, 0,0,0);
02309
02310 } else if (type.endsWith("#Pasta'")) {
02311 return new SaladBowl(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1, 0,0,0);
02312
02313 } else if (type.endsWith("#Soup'")) {
02314 return new SoupPlate(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1, 0,0,0);
02315
02316
02317
02319
02320
02321 } else if (type.endsWith("#Water'")) {
02322 return new Bottle(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1, 0,0,0);
02323
02324 } else if (type.endsWith("#Pitcher'")) {
02325 return new Thermos(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1, 0,0,0);
02326
02327 } else if (type.endsWith("#Tea-Beverage'")) {
02328 return new Bread(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1, 0,0,0);
02329
02330 } else if (type.endsWith("#Coffee-Beverage'")) {
02331 return new Thermos(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1, 0,0,0);
02332
02333 } else if (type.endsWith("#Juice'")) {
02334 return new Tetrapak(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1, 0,0,0);
02335
02336 } else if (type.endsWith("#Tea-Iced'")) {
02337 return new Tetrapak(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1, 0,0,0);
02338
02339 } else if(type.endsWith("#Tetrapak'")) {
02340 return new Tetrapak(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1, 0,0,0);
02341
02342 } else if (type.endsWith("#CardboardBox'")) {
02343 return new Bread(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1, 0,0,0);
02344
02345 } else if (type.endsWith("#CowsMilk-Product'")) {
02346 return new Tetrapak(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1, 0,0,0);
02347
02348
02350
02351
02352 } else if(type.endsWith("#Chair-PieceOfFurniture'")) {
02353 return new Chair(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1, 0,0,0);
02354
02355
02357
02358
02359 } else if(type.endsWith("#SpatialThing-Localized'")) {
02360 return new Ellipse(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1, 0,0,0);
02361
02362
02363
02364
02365 } else if(type.endsWith("#Point3D'")) {
02366 return new Sphere(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1, 0.03f,0.03f,0.03f);
02367 }
02368 return null;
02369
02370 }
02371
02372
02373
02374
02375 }
02376
02377
02378 class EmptyCanvas extends Canvas {
02379 private int[] snapshot;
02380 public boolean drawSelf = false;
02381 private static final long serialVersionUID = 1L;
02382 public EmptyCanvas(int width, int height, String renderer) {
02383 super();
02384 this.width = width;
02385 this.height = height;
02386 init();
02387 snapshot = new int[width*height];
02388
02389 try{super.size(width, height, P3D);}catch(RendererChangeException e) {};
02390 noLoop();
02391
02392 }
02393
02394
02395 @Override
02396 public void draw() {
02397 if(drawSelf)
02398 for(int i=0;i<width;i++)
02399 for(int j=0;j<height;j++)
02400 set(i, j, snapshot[i*height+j]);
02401 };
02402
02403
02404
02405
02406
02407
02408
02409
02412 @Override
02413 public void runMain() {};
02414 @Override
02415 public void size(int width, int height, String renderer) {};
02416
02417
02418 public void freeze() {
02419 for(int i=0;i<width;i++)
02420 for(int j=0;j<height;j++)
02421 snapshot[i*height+j] = get(i, j);
02422 drawSelf = true;
02423 };
02424
02425 public void unFreeze() {
02426 drawSelf = false;
02427 }
02428 }
02429