am 0725fdb9: am 8f590c77: Use Math.round instead of (int) to convert Key coordinates from float to int

* commit '0725fdb9522dddb6eeab688c60b24cd84786904b':
  Use Math.round instead of (int) to convert Key coordinates from float to int
This commit is contained in:
Tadashi G. Takaoka 2012-05-28 02:52:47 -07:00 committed by Android Git Automerger
commit 1ef0bcc434

View file

@ -217,21 +217,22 @@ public class Key {
final int keyYPos = row.getKeyY(); final int keyYPos = row.getKeyY();
// Horizontal gap is divided equally to both sides of the key. // Horizontal gap is divided equally to both sides of the key.
mX = (int) (keyXPos + horizontalGap / 2); mX = Math.round(keyXPos + horizontalGap / 2);
mY = keyYPos; mY = keyYPos;
mWidth = (int) (keyWidth - horizontalGap); mWidth = Math.round(keyWidth - horizontalGap);
mHorizontalGap = (int) horizontalGap; mHorizontalGap = Math.round(horizontalGap);
mHitBox.set((int)keyXPos, keyYPos, (int)(keyXPos + keyWidth) + 1, keyYPos + keyHeight); mHitBox.set(Math.round(keyXPos), keyYPos, Math.round(keyXPos + keyWidth) + 1,
keyYPos + keyHeight);
// Update row to have current x coordinate. // Update row to have current x coordinate.
row.setXPos(keyXPos + keyWidth); row.setXPos(keyXPos + keyWidth);
mBackgroundType = style.getInt(keyAttr, mBackgroundType = style.getInt(keyAttr,
R.styleable.Keyboard_Key_backgroundType, BACKGROUND_TYPE_NORMAL); R.styleable.Keyboard_Key_backgroundType, BACKGROUND_TYPE_NORMAL);
mVisualInsetsLeft = (int) Keyboard.Builder.getDimensionOrFraction(keyAttr, mVisualInsetsLeft = Math.round(Keyboard.Builder.getDimensionOrFraction(keyAttr,
R.styleable.Keyboard_Key_visualInsetsLeft, params.mBaseWidth, 0); R.styleable.Keyboard_Key_visualInsetsLeft, params.mBaseWidth, 0));
mVisualInsetsRight = (int) Keyboard.Builder.getDimensionOrFraction(keyAttr, mVisualInsetsRight = Math.round(Keyboard.Builder.getDimensionOrFraction(keyAttr,
R.styleable.Keyboard_Key_visualInsetsRight, params.mBaseWidth, 0); R.styleable.Keyboard_Key_visualInsetsRight, params.mBaseWidth, 0));
mIconId = KeySpecParser.getIconId(style.getString(keyAttr, mIconId = KeySpecParser.getIconId(style.getString(keyAttr,
R.styleable.Keyboard_Key_keyIcon)); R.styleable.Keyboard_Key_keyIcon));
mDisabledIconId = KeySpecParser.getIconId(style.getString(keyAttr, mDisabledIconId = KeySpecParser.getIconId(style.getString(keyAttr,