ItemBase.java
Go to the documentation of this file.
00001 package edu.tum.cs.ias.knowrob.vis.items;
00002 
00003 import java.awt.Color;
00004 
00005 import javax.vecmath.Matrix4d;
00006 
00007 import edu.tum.cs.ias.knowrob.vis.Canvas;
00008 import edu.tum.cs.ias.knowrob.vis.Drawable;
00009 import edu.tum.cs.ias.knowrob.vis.DrawableAnimated;
00010 import edu.tum.cs.ias.knowrob.vis.applets.SemanticMapVisApplet;
00011 import edu.tum.cs.vis.model.util.DrawSettings;
00012 
00018 public abstract class ItemBase implements Drawable, DrawableAnimated {
00019         public String name;
00023         public int defaultColor = SemanticMapVisApplet.convertColor(220, 220, 220, 255);
00024         protected DrawSettings drawSettings = null;
00025         
00026         public void setOverrideColor(Color overrideColor) {
00027                 if (drawSettings == null)
00028                         drawSettings = new DrawSettings();
00029                 drawSettings.setOverrideColor(overrideColor);
00030         }
00031         
00036         protected float[] trafoMatrix = null;
00037         
00038         protected float xdim;
00039         protected float ydim;
00040         protected float zdim;
00041         
00042         protected int color;
00043         
00044         public void draw(Canvas c) {
00045                 draw(c,0);
00046         }
00047         
00048         public int getMaxStep() {
00049                 return -1;
00050         }               
00051         public static int convertColor(int red, int green, int blue, int alpha) {
00052                 return (((((alpha << 8) + red) << 8) + green) << 8) + blue;
00053         }
00054         
00055         public void setColor(int color){
00056                 this.color = color;
00057         }
00058 
00059         public void setColor(int color,int start, int end){
00060                 this.color=color;
00061         }
00062 
00063         public void setPose(Matrix4d pose) {
00064                 if(pose!=null) {
00065                         this.trafoMatrix = new float[] {
00066                                         (float)pose.m00, (float)pose.m01, (float)pose.m02, (float)pose.m03,
00067                                         (float)pose.m10, (float)pose.m11, (float)pose.m12, (float)pose.m13, 
00068                                         (float)pose.m20, (float)pose.m21, (float)pose.m22, (float)pose.m23, 
00069                                         (float)pose.m30, (float)pose.m31, (float)pose.m32, (float)pose.m33      };
00070                 }
00071         }
00072         
00073         public void setPose(double[] pose) {
00074                 this.setPose(new Matrix4d(pose));
00075         }
00076         
00077         public void setPose(float[] pose) {
00078                 this.trafoMatrix = pose;
00079         }
00080         
00081         public void setPose(float m00,float m01,float m02,float m03,
00082                                                 float m10,float m11,float m12,float m13, 
00083                                                 float m20,float m21,float m22,float m23, 
00084                                                 float m30,float m31,float m32,float m33) {
00085                 this.trafoMatrix = new float[] {
00086                                 m00, m01, m02, m03,
00087                                 m10, m11, m12, m13, 
00088                                 m20, m21, m22, m23, 
00089                                 m30, m31, m32, m33      };
00090         }
00091         
00092         public void setPosition(float x, float y, float z) {
00093                 this.trafoMatrix[3]=x;
00094                 this.trafoMatrix[7]=y;
00095                 this.trafoMatrix[11]=z;
00096         }
00097         
00098         public void setDimensions(float xdim, float ydim, float zdim) {
00099                 this.xdim=xdim;
00100                 this.ydim=ydim;
00101                 this.zdim=zdim;
00102         }
00103 }


mod_vis
Author(s): Moritz Tenorth, Jakob Engel
autogenerated on Mon Oct 6 2014 01:30:00