コード例 #1
0
  private void updateHistogram(final Key key) {
    final int height = key.getHeight() + mVerticalGap;
    final int heightCount = updateHistogramCounter(mHeightHistogram, height);
    if (heightCount > mMaxHeightCount) {
      mMaxHeightCount = heightCount;
      mMostCommonKeyHeight = height;
    }

    final int width = key.getWidth() + mHorizontalGap;
    final int widthCount = updateHistogramCounter(mWidthHistogram, width);
    if (widthCount > mMaxWidthCount) {
      mMaxWidthCount = widthCount;
      mMostCommonKeyWidth = width;
    }
  }
コード例 #2
0
 public void onAddKey(final Key newKey) {
   final Key key = (mKeysCache != null) ? mKeysCache.get(newKey) : newKey;
   final boolean isSpacer = key.isSpacer();
   if (isSpacer && key.getWidth() == 0) {
     // Ignore zero width {@link Spacer}.
     return;
   }
   mKeys.add(key);
   if (isSpacer) {
     return;
   }
   updateHistogram(key);
   if (key.getCode() == KeyboardConstants.CODE_SHIFT) {
     mShiftKeys.add(key);
   }
   if (key.altCodeWhileTyping()) {
     mAltCodeKeysWhileTyping.add(key);
   }
 }