X-Git-Url: https://rtime.felk.cvut.cz/gitweb/orte.git/blobdiff_plain/d12ec5819453e323a7ee14b30d0ed1118fb7ed8e..ab4df9d834af0d7e663796dace242fb9bf303570:/orte/contrib/shape_android/src/org/ocera/orte/shape_android/PublisherShape.java diff --git a/orte/contrib/shape_android/src/org/ocera/orte/shape_android/PublisherShape.java b/orte/contrib/shape_android/src/org/ocera/orte/shape_android/PublisherShape.java index 9d74bc3..9cf0b26 100644 --- a/orte/contrib/shape_android/src/org/ocera/orte/shape_android/PublisherShape.java +++ b/orte/contrib/shape_android/src/org/ocera/orte/shape_android/PublisherShape.java @@ -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); } }