]> rtime.felk.cvut.cz Git - orte.git/blobdiff - orte/contrib/shape_android/src/org/ocera/orte/shape_android/PublisherShape.java
Merge branch 'shape_android_features' of https://github.com/Vajnar/orte
[orte.git] / orte / contrib / shape_android / src / org / ocera / orte / shape_android / PublisherShape.java
index 9d74bc3ec4958aa5dcd38d84663d5f5cefa26ded..9cf0b267e8e96e735f2716b03009dd64f48f8511 100644 (file)
@@ -45,9 +45,8 @@ public class PublisherShape extends ShapeDrawable
        // Prefer at least 48x48 shape size (Full asset), for more
        //  info, please refer to http://developer.android.com/
        
-       private static final int SHAPE_WIDTH = 48;
-       private static final int SHAPE_HEIGHT = 48;
        private boolean manual;
+       private int pointerId;
        private int incX, incY;
        
        private PublProp publisherProperties;
@@ -71,14 +70,14 @@ public class PublisherShape extends ShapeDrawable
                                :((s == 1)
                                        ?new OvalShape()
                                        :((s == 2)
-                                               ?new PathShape(new  Path(), 96, 96)
+                                               ?new PathShape(new  Path(), PublisherActivity.SHAPE_WIDTH, PublisherActivity.SHAPE_HEIGHT)
                                                :new RectShape()
                                        )
                                )
                        );
                
                if (s == 2) { // fix triangle
-                       this.setShape(new PathShape(PublisherShape.returnTrianglePath(), 96, 96));
+                       this.setShape(new PathShape(PublisherShape.returnTrianglePath(), 2*PublisherActivity.SHAPE_WIDTH, 2*PublisherActivity.SHAPE_HEIGHT));
                }
                
                this.manual = false;
@@ -91,12 +90,12 @@ 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);
-               this.setBounds(0, 0, SHAPE_WIDTH, SHAPE_HEIGHT);
+               this.setBounds(0, 0, PublisherActivity.SHAPE_WIDTH, PublisherActivity.SHAPE_HEIGHT);
                
                //Log.d("PublisherShape", "s: "+s+", c: "+c+", left: "+this.getBounds().left+", top: "+this.getBounds().top+", right: "+this.getBounds().right+", bottom: "+this.getBounds().bottom);
        }
@@ -288,6 +287,24 @@ public class PublisherShape extends ShapeDrawable
         */
        public boolean getManual() { return this.manual; }
 
+       /**
+        * Set the touch pointer ID associated with
+        * this shape.
+        *
+        * @param pointerId
+        * @since 1.0
+        */
+       public void setPointerId(int pointerId) { this.pointerId = pointerId; }
+
+       /**
+        * Get the touch pointer ID associated with
+        * this shape.
+        *
+        * @return Pointer ID.
+        * @since 1.0
+        */
+       public int getPointerId() { return this.pointerId; }
+
        /**
         * Make triangle path for new instance.
         * 
@@ -298,10 +315,10 @@ public class PublisherShape extends ShapeDrawable
        {
                Path path = new Path();
                path.setFillType(FillType.EVEN_ODD);
-               path.moveTo(48, 0);
-               path.lineTo(96, 96);
-               path.lineTo(0, 96);
-               path.lineTo(48, 0);
+               path.moveTo(PublisherActivity.SHAPE_WIDTH, 0); // triangle top center
+               path.lineTo(2*PublisherActivity.SHAPE_WIDTH, 2*PublisherActivity.SHAPE_HEIGHT); // triangle right bottom corner
+               path.lineTo(0, 2*PublisherActivity.SHAPE_HEIGHT); // triangle left bottom corner
+               path.lineTo(PublisherActivity.SHAPE_WIDTH, 0); // back to triangle top center
                path.close();
                
                return path;
@@ -314,7 +331,10 @@ public class PublisherShape extends ShapeDrawable
         */
        public void killMe()
        {
-               this.publication.destroy();
+               if (this.publication != null) {
+                       this.publication.destroy();
+                       this.publication = null;
+               }
        }
        
        /**
@@ -327,5 +347,6 @@ public class PublisherShape extends ShapeDrawable
        public void setScale(int currentWidth, int currentHeight)
        {
                this.box.setScale(currentWidth, currentHeight);
+               this.setBounds(this.box.rectangle.top_left_x, this.box.rectangle.top_left_y, this.box.rectangle.top_left_x+PublisherActivity.SHAPE_WIDTH, this.box.rectangle.top_left_y+PublisherActivity.SHAPE_HEIGHT);
        }
 }