*/
package org.ocera.orte.shape_android;
-import java.util.regex.Pattern;
-
import org.ocera.orte.DomainApp;
import org.ocera.orte.Manager;
import org.ocera.orte.types.NtpTime;
private static final int MINSEPARATION_MAX = 5;
private static final int RESULT_SETTINGS = 1;
+ public static int SHAPE_WIDTH = 0;
+ public static int SHAPE_HEIGHT = 0;
+
private WifiManager wifiManager;
private WifiLock wifiLock;
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_publisher);
+ // count default shape size
+ SHAPE_WIDTH = (int) (this.getWindowManager().getDefaultDisplay().getWidth() * 25 / BoxType.DESTINATION_WIDTH);
+ SHAPE_HEIGHT = (int) (this.getWindowManager().getDefaultDisplay().getHeight() * 45 / BoxType.DESTINATION_HEIGHT);
+
// From Robot_Demo project.
wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
wifiLock = (WifiLock) wifiManager.createWifiLock((
{
super.onConfigurationChanged(newConfig);
+ // count default shape size
+ SHAPE_WIDTH = (int) (this.getWindowManager().getDefaultDisplay().getWidth() * 25 / BoxType.DESTINATION_WIDTH);
+ SHAPE_HEIGHT = (int) (this.getWindowManager().getDefaultDisplay().getHeight() * 45 / BoxType.DESTINATION_HEIGHT);
+
for (PublisherShape s : this.publisherView.shapes) {
s.setScale(this.getWindowManager().getDefaultDisplay().getWidth(), this.getWindowManager().getDefaultDisplay().getHeight());
}
// 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 incX, incY;
:((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;
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);
}
{
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;
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);
}
}
this.shape.setShape(new OvalShape());
break;
case 2:
- this.shape.setShape(new PathShape(PublisherShape.returnTrianglePath(), 96, 96));
+ this.shape.setShape(new PathShape(PublisherShape.returnTrianglePath(), 2*PublisherActivity.SHAPE_WIDTH, 2*PublisherActivity.SHAPE_HEIGHT));
break;
default:
this.shape.setShape(new RectShape());
public void setScale(int currentWidth, int currentHeight)
{
this.box.setScale(currentWidth, currentHeight);
+ this.setShape();
}
}