BaseShape.java
Go to the documentation of this file.
00001 package org.ros.android.view.visualization.shape;
00002 
00003 import com.google.common.base.Preconditions;
00004 
00005 import org.ros.android.view.visualization.Color;
00006 import org.ros.android.view.visualization.OpenGlTransform;
00007 import org.ros.android.view.visualization.VisualizationView;
00008 import org.ros.rosjava_geometry.Transform;
00009 
00010 import javax.microedition.khronos.opengles.GL10;
00011 
00018 abstract class BaseShape implements Shape {
00019 
00020   private Color color;
00021   private Transform transform;
00022 
00023   public BaseShape() {
00024     setTransform(Transform.identity());
00025   }
00026 
00027   @Override
00028   public void draw(VisualizationView view, GL10 gl) {
00029     gl.glPushMatrix();
00030     OpenGlTransform.apply(gl, getTransform());
00031     scale(view, gl);
00032     drawShape(view, gl);
00033     gl.glPopMatrix();
00034   }
00035 
00040   abstract protected void drawShape(VisualizationView view, GL10 gl);
00041 
00048   protected void scale(VisualizationView view, GL10 gl) {
00049     // The default scale is in metric space.
00050   }
00051 
00052   @Override
00053   public Color getColor() {
00054     Preconditions.checkNotNull(color);
00055     return color;
00056   }
00057 
00058   @Override
00059   public void setColor(Color color) {
00060     this.color = color;
00061   }
00062 
00063   @Override
00064   public Transform getTransform() {
00065     Preconditions.checkNotNull(transform);
00066     return transform;
00067   }
00068 
00069   @Override
00070   public void setTransform(Transform pose) {
00071     this.transform = pose;
00072   }
00073 }


android_core
Author(s): Damon Kohler
autogenerated on Thu Jun 6 2019 21:20:07