]> rtime.felk.cvut.cz Git - orte.git/commitdiff
Use proper types, change messages to Little Endian.
authorjiri hubacek <jiri.hubacek@gmail.com>
Sun, 1 Feb 2015 12:23:18 +0000 (13:23 +0100)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Mon, 9 Feb 2015 16:56:15 +0000 (17:56 +0100)
orte/contrib/shape_android/.gitignore
orte/contrib/shape_android/src/org/ocera/orte/shape_android/BoxType.java
orte/contrib/shape_android/src/org/ocera/orte/shape_android/PublisherShape.java

index 8e1904587f645c6952f03b0144c25283843b085a..397d2db5fc1aedb3aaf34f3a160dab5f9d167dde 100644 (file)
@@ -18,6 +18,9 @@ obj/
 .project
 .classpath
 
+# temporary files
+*.swp
+
 # Gradle files
 .gradle/
 build/
index 651536d514b5715a4bdec997d95cf63d54bfdeda..417e4da2e7722c0d8e544eec5c3d511a7c82904f 100644 (file)
@@ -22,8 +22,6 @@ import org.ocera.orte.DomainApp;
 import org.ocera.orte.types.MessageData;
 import org.ocera.orte.types.ORTEConstant;
 
-import android.content.SharedPreferences;
-import android.preference.PreferenceManager;
 import android.util.Log;
 
 /**
@@ -35,12 +33,11 @@ import android.util.Log;
  */
 public class BoxType extends MessageData
 {
-       private static final byte FUZZY = 0;
        private static final double DESTINATION_WIDTH = 367.0; //389.0;
        private static final double DESTINATION_HEIGHT = 261.0; //331.0;
        
-       public byte color;
-       public byte shape;
+       public int color;
+       public int shape;
        public BoxRect rectangle = new BoxRect();
        
        public boolean allowScaling;
@@ -62,6 +59,7 @@ public class BoxType extends MessageData
                }
                
                this.allowScaling = true;
+               this.buffer.order(null); // set buffer to Little endian (Shape uses this)
        }
 
        /* (non-Javadoc)
@@ -73,16 +71,10 @@ public class BoxType extends MessageData
                buffer.rewind();
                
                // get color
-               this.color = buffer.get();
-               
-               // skip fuzzy bytes
-               buffer.get();buffer.get();buffer.get();
+               this.color = buffer.getInt();
                
                // get shape
-               this.shape = buffer.get();
-               
-               // skip fuzzy bytes
-               buffer.get();buffer.get();buffer.get();
+               this.shape = buffer.getInt();
                
                // get rect position (with scaling)
                if (this.allowScaling) {
@@ -97,8 +89,6 @@ public class BoxType extends MessageData
                        this.rectangle.bottom_right_y = buffer.getShort();
                }
                
-               // don't care about last fuzzy byte because of buffer.rewind()
-               
                //Log.d("BoxType", "receiving - color: "+this.color+", shape: "+this.shape+ ", rectangle:{"+this.rectangle.top_left_x+","+this.rectangle.top_left_y+","+this.rectangle.bottom_right_x+","+this.rectangle.bottom_right_y+",}");
        }
 
@@ -111,16 +101,10 @@ public class BoxType extends MessageData
                buffer.rewind();
                
                // put color
-               buffer.put(this.color);
-               
-               // put fuzzy bytes
-               buffer.put(BoxType.FUZZY);buffer.put(BoxType.FUZZY);buffer.put(BoxType.FUZZY);
+               buffer.putInt(this.color);
                
                // put shape
-               buffer.put(this.shape);
-               
-               // put fuzzy bytes
-               buffer.put(BoxType.FUZZY);buffer.put(BoxType.FUZZY);buffer.put(BoxType.FUZZY);
+               buffer.putInt(this.shape);
                
                // put rectange position (with scaling)
                if (this.allowScaling) {
@@ -134,9 +118,6 @@ public class BoxType extends MessageData
                        buffer.putShort(this.rectangle.bottom_right_x);
                        buffer.putShort(this.rectangle.bottom_right_y);
                }
-               
-               // put fuzzy byte
-               buffer.put(BoxType.FUZZY);
        }
 
        /* (non-Javadoc)
@@ -145,7 +126,7 @@ public class BoxType extends MessageData
        @Override
        public int getMaxDataLength()
        {
-               return ORTEConstant.BYTE_FIELD_SIZE + ORTEConstant.LONG_FIELD_SIZE + 4*ORTEConstant.SHORT_FIELD_SIZE;
+               return 2*ORTEConstant.INT_FIELD_SIZE + 4*ORTEConstant.SHORT_FIELD_SIZE;
        }
        
        /**
index 9d74bc3ec4958aa5dcd38d84663d5f5cefa26ded..4387302c0dddbd344b8aeb958ddf69e5bb311c28 100644 (file)
@@ -91,8 +91,8 @@ public class PublisherShape extends ShapeDrawable
                                s+1);
                this.publication = appDomain.createPublication(this.publisherProperties, this.box);
                
-               this.box.shape = (byte) s;
-               this.box.color = (byte) c;
+               this.box.shape = s;
+               this.box.color = c;
 
                this.getPaint().setColor(PublisherShape.getColorConstant(c));
                this.setPadding(0, 0, 0, 0);