本文整理汇总了Java中org.microemu.device.InputMethod类的典型用法代码示例。如果您正苦于以下问题:Java InputMethod类的具体用法?Java InputMethod怎么用?Java InputMethod使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
InputMethod类属于org.microemu.device包,在下文中一共展示了InputMethod类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getChars
import org.microemu.device.InputMethod; //导入依赖的package包/类
public char[] getChars(int inputMode)
{
char[] result = null;
switch (inputMode) {
case InputMethod.INPUT_123 :
result = (char[]) inputToChars.get("123");
break;
case InputMethod.INPUT_ABC_LOWER :
result = (char[]) inputToChars.get("abc");
break;
case InputMethod.INPUT_ABC_UPPER :
result = (char[]) inputToChars.get("ABC");
break;
}
if (result == null) {
result = (char[]) inputToChars.get("common");
}
if (result == null) {
result = new char[0];
}
return result;
}
示例2: getChars
import org.microemu.device.InputMethod; //导入依赖的package包/类
public char[] getChars(int inputMode) {
char[] result = null;
switch (inputMode) {
case InputMethod.INPUT_123:
result = (char[]) inputToChars.get("123");
break;
case InputMethod.INPUT_ABC_LOWER:
result = (char[]) inputToChars.get("abc");
break;
case InputMethod.INPUT_ABC_UPPER:
result = (char[]) inputToChars.get("ABC");
break;
}
if (result == null) {
result = (char[]) inputToChars.get("common");
}
if (result == null) {
result = new char[0];
}
return result;
}
示例3: TextField
import org.microemu.device.InputMethod; //导入依赖的package包/类
public TextField(String label, String text, int maxSize, int constraints) {
super(label);
super.setUI(DeviceFactory.getDevice().getUIFactory().createTextFieldUI(this));
if (maxSize <= 0) {
throw new IllegalArgumentException();
}
setConstraints(constraints);
if (!InputMethod.validate(text, constraints)) {
throw new IllegalArgumentException();
}
if (maxSize <= 0) {
throw new IllegalArgumentException();
}
this.maxSize = maxSize;
stringComponent = new StringComponent();
if (text != null) {
setString(text);
} else {
setString("");
}
stringComponent.setWidthDecreaser(8);
}
示例4: setString
import org.microemu.device.InputMethod; //导入依赖的package包/类
void setString(String text, int caret) {
if (!InputMethod.validate(text, constraints)) {
throw new IllegalArgumentException("text is illegal for the current input constraints");
}
if (text == null) {
field = "";
stringComponent.setText("");
} else {
if (text.length() > maxSize) {
throw new IllegalArgumentException("text exceeds the current maximum capacity");
}
field = text;
if ((constraints & PASSWORD) == 0) {
stringComponent.setText(text);
} else {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < text.length(); i++) {
sb.append('*');
}
stringComponent.setText(sb.toString());
}
}
setCaretPosition(caret);
setCaretVisible(false);
repaint();
}
示例5: insert
import org.microemu.device.InputMethod; //导入依赖的package包/类
public void insert(String src, int position) {
if (!InputMethod.validate(src, constraints)) {
throw new IllegalArgumentException();
}
if (field.length() + src.length() > maxSize) {
throw new IllegalArgumentException();
}
String newtext = "";
if (position > 0) {
newtext = ((AndroidTextFieldUI) ui).getString();
}
newtext += src;
if (position < field.length()) {
newtext += ((AndroidTextFieldUI) ui).getString().substring(position + 1);
}
((AndroidTextFieldUI) ui).setString(newtext);
}
示例6: filterInputMode
import org.microemu.device.InputMethod; //导入依赖的package包/类
protected char[] filterInputMode(char[] chars) {
if (chars == null) {
return new char[0];
}
int inputMode = getInputMode();
char[] result = new char[chars.length];
int i, j;
for (i = 0, j = 0; i < chars.length; i++) {
if (inputMode == InputMethod.INPUT_ABC_UPPER) {
result[j] = Character.toUpperCase(chars[i]);
j++;
} else if (inputMode == InputMethod.INPUT_ABC_LOWER) {
result[j] = Character.toLowerCase(chars[i]);
j++;
} else if (inputMode == InputMethod.INPUT_123) {
if (Character.isDigit(chars[i]) || chars[i] == '-' || chars[i] == '.') {
result[j] = chars[i];
j++;
}
}
}
if (i != j) {
char[] newresult = new char[j];
System.arraycopy(result, 0, newresult, 0, j);
result = newresult;
}
return result;
}
示例7: paintControls
import org.microemu.device.InputMethod; //导入依赖的package包/类
public void paintControls(SwtGraphics g) {
Device device = DeviceFactory.getDevice();
g.setBackground(g.getColor(new RGB(backgroundColor.getRed(), backgroundColor.getGreen(), backgroundColor
.getBlue())));
g.fillRectangle(0, 0, displayRectangle.width, displayPaintable.y);
g.fillRectangle(0, displayPaintable.y, displayPaintable.x, displayPaintable.height);
g.fillRectangle(displayPaintable.x + displayPaintable.width, displayPaintable.y, displayRectangle.width
- displayPaintable.x - displayPaintable.width, displayPaintable.height);
g.fillRectangle(0, displayPaintable.y + displayPaintable.height, displayRectangle.width,
displayRectangle.height - displayPaintable.y - displayPaintable.height);
g.setForeground(g.getColor(new RGB(foregroundColor.getRed(), foregroundColor.getGreen(), foregroundColor
.getBlue())));
for (Enumeration s = device.getSoftButtons().elements(); s.hasMoreElements();) {
((SwtSoftButton) s.nextElement()).paint(g);
}
int inputMode = device.getInputMethod().getInputMode();
if (inputMode == InputMethod.INPUT_123) {
g.drawImage(((SwtImmutableImage) mode123Image.getImage()).getImage(), mode123Image.getRectangle().x,
mode123Image.getRectangle().y);
} else if (inputMode == InputMethod.INPUT_ABC_UPPER) {
g.drawImage(((SwtImmutableImage) modeAbcUpperImage.getImage()).getImage(),
modeAbcUpperImage.getRectangle().x, modeAbcUpperImage.getRectangle().y);
} else if (inputMode == InputMethod.INPUT_ABC_LOWER) {
g.drawImage(((SwtImmutableImage) modeAbcLowerImage.getImage()).getImage(),
modeAbcLowerImage.getRectangle().x, modeAbcLowerImage.getRectangle().y);
}
}
示例8: paintControls
import org.microemu.device.InputMethod; //导入依赖的package包/类
public void paintControls(Graphics g) {
Device device = DeviceFactory.getDevice();
g.setColor(backgroundColor);
g.fillRect(0, 0, displayRectangle.width, displayPaintable.y);
g.fillRect(0, displayPaintable.y, displayPaintable.x, displayPaintable.height);
g.fillRect(displayPaintable.x + displayPaintable.width, displayPaintable.y, displayRectangle.width
- displayPaintable.x - displayPaintable.width, displayPaintable.height);
g.fillRect(0, displayPaintable.y + displayPaintable.height, displayRectangle.width, displayRectangle.height
- displayPaintable.y - displayPaintable.height);
g.setColor(foregroundColor);
for (Enumeration s = device.getSoftButtons().elements(); s.hasMoreElements();) {
((J2SESoftButton) s.nextElement()).paint(g);
}
int inputMode = device.getInputMethod().getInputMode();
if (inputMode == InputMethod.INPUT_123) {
g.drawImage(((J2SEImmutableImage) mode123Image.getImage()).getImage(), mode123Image.getRectangle().x,
mode123Image.getRectangle().y, null);
} else if (inputMode == InputMethod.INPUT_ABC_UPPER) {
g.drawImage(((J2SEImmutableImage) modeAbcUpperImage.getImage()).getImage(), modeAbcUpperImage
.getRectangle().x, modeAbcUpperImage.getRectangle().y, null);
} else if (inputMode == InputMethod.INPUT_ABC_LOWER) {
g.drawImage(((J2SEImmutableImage) modeAbcLowerImage.getImage()).getImage(), modeAbcLowerImage
.getRectangle().x, modeAbcLowerImage.getRectangle().y, null);
}
}
示例9: setChars
import org.microemu.device.InputMethod; //导入依赖的package包/类
public void setChars(char[] data, int offset, int length) {
if (data == null) {
setString("");
} else {
if (length > maxSize) {
throw new IllegalArgumentException();
}
String newtext = new String(data, offset, length);
if (!InputMethod.validate(newtext, constraints)) {
throw new IllegalArgumentException();
}
setString(newtext);
}
repaint();
}
示例10: setConstraints
import org.microemu.device.InputMethod; //导入依赖的package包/类
public final void setConstraints(int constraints) {
if ((constraints & TextField.CONSTRAINT_MASK) < ANY
|| (constraints & TextField.CONSTRAINT_MASK) > DECIMAL) {
throw new IllegalArgumentException("constraints " + constraints + " is an illegal value");
}
this.constraints = constraints;
if (!InputMethod.validate(getString(), constraints)) {
setString("");
}
((TextFieldUI) ui).setConstraints(constraints);
}
示例11: setFocus
import org.microemu.device.InputMethod; //导入依赖的package包/类
@Override
void setFocus(boolean hasFocus) {
super.setFocus(hasFocus);
if (hasFocus) {
// register input listener
InputMethod inputMethod = DeviceFactory.getDevice().getInputMethod();
inputMethod.setInputMethodListener(inputMethodListener);
inputMethod.setMaxSize(getMaxSize());
setCaretVisible(true);
} else {
// unregister input listener
DeviceFactory.getDevice().getInputMethod().removeInputMethodListener(inputMethodListener);
setCaretVisible(false);
}
}
示例12: showNotify
import org.microemu.device.InputMethod; //导入依赖的package包/类
@Override
void showNotify() {
super.showNotify();
InputMethod inputMethod = DeviceFactory.getDevice().getInputMethod();
inputMethod.setInputMethodListener(inputMethodListener);
inputMethod.setMaxSize(getMaxSize());
setCaretPosition(getString().length());
tf.setCaretVisible(true);
}
示例13: onCreate
import org.microemu.device.InputMethod; //导入依赖的package包/类
@Override
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
// Query the activity property android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
TypedArray ta = getTheme().obtainStyledAttributes(new int[] { android.R.attr.windowFullscreen });
windowFullscreen = ta.getBoolean(0, false);
Drawable phoneCallIcon = getResources().getDrawable(android.R.drawable.stat_sys_phone_call);
int statusBarHeight = 0;
if (!windowFullscreen) {
statusBarHeight = phoneCallIcon.getIntrinsicHeight();
}
Display display = getWindowManager().getDefaultDisplay();
final int width = display.getWidth();
final int height = display.getHeight() - statusBarHeight;
emulatorContext = new EmulatorContext() {
private InputMethod inputMethod = new AndroidInputMethod();
private DeviceDisplay deviceDisplay = new AndroidDeviceDisplay(MicroEmulatorActivity.this, this, width, height);
private FontManager fontManager = new AndroidFontManager(getResources().getDisplayMetrics());
public DisplayComponent getDisplayComponent() {
// TODO consider removal of EmulatorContext.getDisplayComponent()
System.out.println("MicroEmulator.emulatorContext::getDisplayComponent()");
return null;
}
public InputMethod getDeviceInputMethod() {
return inputMethod;
}
public DeviceDisplay getDeviceDisplay() {
return deviceDisplay;
}
public FontManager getDeviceFontManager() {
return fontManager;
}
public InputStream getResourceAsStream(Class origClass, String name) {
try {
if (name.startsWith("/")) {
return MicroEmulatorActivity.this.getAssets().open(name.substring(1));
} else {
Package p = origClass.getPackage();
if (p == null) {
return MicroEmulatorActivity.this.getAssets().open(name);
} else {
String folder = origClass.getPackage().getName().replace('.', '/');
return MicroEmulatorActivity.this.getAssets().open(folder + "/" + name);
}
}
} catch (IOException e) {
Logger.debug(e);
return null;
}
}
public boolean platformRequest(String url) throws ConnectionNotFoundException
{
try {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
} catch (ActivityNotFoundException e) {
throw new ConnectionNotFoundException();
}
return true;
}
};
activityThread = Thread.currentThread();
}
示例14: getInputMethod
import org.microemu.device.InputMethod; //导入依赖的package包/类
public InputMethod getInputMethod() {
return emulatorContext.getDeviceInputMethod();
}
示例15: getInputMethod
import org.microemu.device.InputMethod; //导入依赖的package包/类
public InputMethod getInputMethod() {
return context.getDeviceInputMethod();
}