summaryrefslogtreecommitdiff
path: root/src/us
diff options
context:
space:
mode:
Diffstat (limited to 'src/us')
-rw-r--r--src/us/minak/IMEGestureOverlayView.java12
-rw-r--r--src/us/minak/IMEModifier.java (renamed from src/us/minak/MetaExpression.java)4
-rw-r--r--src/us/minak/IMEModifierCircle.java (renamed from src/us/minak/MetaCircle.java)10
-rw-r--r--src/us/minak/IMEModifiers.java69
-rw-r--r--src/us/minak/IMEView.java12
5 files changed, 85 insertions, 22 deletions
diff --git a/src/us/minak/IMEGestureOverlayView.java b/src/us/minak/IMEGestureOverlayView.java
index 7e8867d..e27b70a 100644
--- a/src/us/minak/IMEGestureOverlayView.java
+++ b/src/us/minak/IMEGestureOverlayView.java
@@ -22,7 +22,6 @@ import android.gesture.GestureOverlayView;
import android.gesture.GestureOverlayView.OnGesturePerformedListener;
import android.gesture.Prediction;
import android.graphics.Canvas;
-import android.graphics.Paint;
import android.util.AttributeSet;
/**
@@ -32,8 +31,8 @@ public class IMEGestureOverlayView extends GestureOverlayView implements OnGestu
private static final double SCORE_TRESHOLD = 3.0;
private final GestureLibrary mGestureLibrary;
private StringReciever mOnGestureRecognizedListener;
- public List<MetaCircle> circles = new LinkedList<MetaCircle>();
- private final Paint mPaint = new Paint();
+ public List<IMEModifierCircle> circles = new LinkedList<IMEModifierCircle>();
+ private final IMEModifiers modifiers = new IMEModifiers();
public IMEGestureOverlayView(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -62,10 +61,9 @@ public class IMEGestureOverlayView extends GestureOverlayView implements OnGestu
}
}
+ @Override
public void onDraw(Canvas canvas) {
- for (MetaCircle circle : circles) {
- mPaint.setColor(circle.color);
- canvas.drawCircle(circle.x, circle.y, circle.radius, mPaint);
- }
+ float d = Math.min(canvas.getWidth(), canvas.getHeight());
+ modifiers.draw(canvas, d/2, d/2, d*.4F);
}
}
diff --git a/src/us/minak/MetaExpression.java b/src/us/minak/IMEModifier.java
index f9c6cbe..6b5ee67 100644
--- a/src/us/minak/MetaExpression.java
+++ b/src/us/minak/IMEModifier.java
@@ -1,6 +1,6 @@
package us.minak;
-public class MetaExpression {
+public class IMEModifier {
public static enum State {
ON, OFF, LOCK
}
@@ -17,7 +17,7 @@ public class MetaExpression {
this.value = value;
}
- MetaExpression(String value) {
+ IMEModifier(String value) {
this.value = value;
this.state = State.OFF;
}
diff --git a/src/us/minak/MetaCircle.java b/src/us/minak/IMEModifierCircle.java
index 9139dc9..246036f 100644
--- a/src/us/minak/MetaCircle.java
+++ b/src/us/minak/IMEModifierCircle.java
@@ -4,8 +4,8 @@ package us.minak;
* Not sure if this should be drawable or what.
*
*/
-public class MetaCircle {
- private MetaExpression metaExpression;
+public class IMEModifierCircle {
+ private IMEModifier metaExpression;
public float x;
public float y;
public float radius;
@@ -13,7 +13,7 @@ public class MetaCircle {
public boolean expanded;
public int expansion; //the level of expansion (if multiple circles are expanded, this decides precidence)
- MetaCircle(float x, float y, float radius, int color, MetaExpression metaExpr) {
+ IMEModifierCircle(float x, float y, float radius, int color, IMEModifier metaExpr) {
this.setMetaExpression(metaExpr);
this.x = x;
this.y = y;
@@ -27,11 +27,11 @@ public class MetaCircle {
return Math.pow(x - this.x, 2) + Math.pow(y - this.y, 2) < Math.pow(this.radius, 2) ? true : false;
}
- public MetaExpression getMetaExpression() {
+ public IMEModifier getMetaExpression() {
return metaExpression;
}
- public void setMetaExpression(MetaExpression metaExpr) {
+ public void setMetaExpression(IMEModifier metaExpr) {
this.metaExpression = metaExpr;
}
}
diff --git a/src/us/minak/IMEModifiers.java b/src/us/minak/IMEModifiers.java
new file mode 100644
index 0000000..ef49f17
--- /dev/null
+++ b/src/us/minak/IMEModifiers.java
@@ -0,0 +1,69 @@
+package us.minak;
+
+import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.Paint;
+import java.util.List;
+import java.util.ArrayList;
+
+public class IMEModifiers {
+ private final String[] modifiers = { "shift", "ctrl", "alt" };
+ private final Paint colorPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
+ private final Paint textPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
+
+ private float cx = 0;
+ private float cy = 0;
+ private double innerR = 0;
+ private double outerR = 0;
+ private double radEach = 0;
+
+
+ public IMEModifiers() {
+ textPaint.setColor(Color.BLACK);
+ }
+
+ public void draw(Canvas canvas, float cx, float cy, float r) {
+ this.cx = cx;
+ this.cy = cy;
+ innerR = r*(1.0/3.0);
+ outerR = (float)(r*(2.0/3.0));
+ radEach = (Math.PI*2.0)/modifiers.length;
+
+ double rad = 0;
+ float[] hsv = {0F, 1F, .75F};
+
+ for (int i = 0; i < modifiers.length; i++) {
+ rad = radEach * i;
+ hsv[0] = (float)Math.toDegrees(rad);
+ colorPaint.setColor(Color.HSVToColor(0x80, hsv));
+
+ canvas.drawCircle(
+ (float)(cx+innerR*Math.cos(rad)),
+ (float)(cy+innerR*Math.sin(rad)),
+ (float)outerR,
+ colorPaint);
+ canvas.drawText(
+ modifiers[i],
+ (float)(cx+innerR*Math.cos(rad)),
+ (float)(cy+innerR*Math.sin(rad)),
+ textPaint);
+ }
+ }
+
+ public List<String> getModifiersAtPoint(float x, float y) {
+ ArrayList<String> ret = new ArrayList<String>();
+
+ double mx;
+ double my;
+ double rad = 0;
+ for (int i = 0; i < modifiers.length; i++) {
+ rad = radEach * i;
+ mx = cx+innerR*Math.cos(rad);
+ my = cy+innerR*Math.sin(rad);
+
+ if (Math.sqrt(Math.pow(mx-x,2)+Math.pow(my-y, 2)) > outerR)
+ ret.add(modifiers[i]);
+ }
+ return ret;
+ }
+}
diff --git a/src/us/minak/IMEView.java b/src/us/minak/IMEView.java
index 318abd0..a992011 100644
--- a/src/us/minak/IMEView.java
+++ b/src/us/minak/IMEView.java
@@ -16,7 +16,6 @@ import java.util.LinkedList;
import java.util.Queue;
import android.content.Context;
-import android.graphics.Color;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
@@ -56,18 +55,13 @@ public class IMEView extends RelativeLayout {
@Override
protected void onFinishInflate() {
- IMEGestureOverlayView drawingSpaceView = (IMEGestureOverlayView) findViewById(R.id.drawing_space);
- drawingSpaceView.setOnGestureRecognizedListener(new StringReciever() {
+ IMEGestureOverlayView gestureOverlayView = (IMEGestureOverlayView) findViewById(R.id.drawing_space);
+ gestureOverlayView.setOnGestureRecognizedListener(new StringReciever() {
@Override
public void putString(String character) {
enterCharacter(character);
}
});
-
- //dynamic MetaCircle adding stuff here. replace null with Shift or Ctrl or Meta or Alt or Hyper or whatever.
- drawingSpaceView.circles.add(new MetaCircle((float)50.0, (float)50.0, (float)20.0, Color.RED, new MetaExpression(null)));
- drawingSpaceView.circles.add(new MetaCircle((float)70.0, (float)70.0, (float)20.0, Color.RED, new MetaExpression(null)));
- drawingSpaceView.circles.add(new MetaCircle((float)50.0, (float)30.0, (float)20.0, Color.RED, new MetaExpression(null)));
}
public void setOnCharacterEnteredListener(StringReciever onCharacterEnteredListener) {
@@ -92,6 +86,7 @@ public class IMEView extends RelativeLayout {
* The character to enter
*/
private void enterCharacter(String character) {
+ /*
for (MetaCircle circle : ((IMEGestureOverlayView) findViewById(R.id.drawing_space)).circles) {
//go through circles and check if they are applicable
if (circle.containsPoint(this.x, this.y) && circle.getMetaExpression().state != MetaExpression.State.OFF) {
@@ -99,6 +94,7 @@ public class IMEView extends RelativeLayout {
;
}
}
+ */
mOnCharacterEnteredListener.putString(character);
}
}