Esempio n. 1
0
 private boolean onAltLeft(KeyboardEvent event) {
   if (noContent()) return true;
   final Object item = selected();
   if (item == null) {
     environment.hint(Hints.EMPTY_LINE);
     return true;
   }
   final String line = appearance.getScreenAppearance(item, NONE_APPEARANCE_FLAGS);
   NullCheck.notNull(line, "line");
   if (line.isEmpty()) {
     environment.hint(Hints.EMPTY_LINE);
     return true;
   }
   final int leftBound = appearance.getObservableLeftBound(item);
   final int rightBound = appearance.getObservableRightBound(item);
   if (hotPointX <= leftBound) {
     environment.hint(Hints.BEGIN_OF_LINE);
     return true;
   }
   final String subline = line.substring(leftBound, rightBound);
   final WordIterator it = new WordIterator(subline, hotPointX - leftBound);
   if (!it.stepBackward()) {
     environment.hint(Hints.BEGIN_OF_LINE);
     return true;
   }
   hotPointX = it.pos() + leftBound;
   environment.say(it.announce());
   environment.onAreaNewHotPoint(this);
   return true;
 }
Esempio n. 2
0
 private boolean onAltEnd(KeyboardEvent event) {
   if (noContent()) return true;
   final Object item = selected();
   if (item == null) {
     environment.hint(Hints.EMPTY_LINE);
     return true;
   }
   final String line = appearance.getScreenAppearance(item, NONE_APPEARANCE_FLAGS);
   NullCheck.notNull(line, "line");
   hotPointX = appearance.getObservableRightBound(item);
   environment.hint(Hints.END_OF_LINE);
   environment.onAreaNewHotPoint(this);
   return true;
 }
Esempio n. 3
0
 protected boolean noContent() {
   if (model == null || model.getItemCount() < 1) {
     environment.hint(noContentStr(), Hints.NO_CONTENT);
     return true;
   }
   return false;
 }
Esempio n. 4
0
 private boolean onArrowLeft(KeyboardEvent event) {
   if (noContentCheck()) return true;
   final int count = model.getRowCount();
   if (hotPointY < 0 || hotPointY >= count) {
     environment.hint(Hints.EMPTY_LINE);
     return true;
   }
   if (hotPointX < initialHotPointX) hotPointX = initialHotPointX;
   if (getColUnderPos(hotPointX) < 0) hotPointX = initialHotPointX;
   final int currentCol = getColUnderPos(hotPointX);
   final int currentColWidth = colWidth[currentCol];
   final int colStartPos = getColStartPos(currentCol);
   final TableCell c =
       new TableCell(
           hotPointX - colStartPos,
           cellShift,
           currentColWidth,
           appearance.getCellText(model, currentCol, hotPointY));
   if (!c.movePrev()) {
     if (currentCol <= 0) {
       environment.hint(Hints.TABLE_BEGIN_OF_ROW);
       return true;
     }
     final String prevColText = appearance.getCellText(model, currentCol - 1, hotPointY);
     final int prevColWidth = colWidth[currentCol - 1];
     final int prevColStartPos = getColStartPos(currentCol - 1);
     if (prevColText.length() > prevColWidth) {
       hotPointX = prevColStartPos + prevColWidth;
       cellShift = prevColText.length() - prevColWidth;
     } else {
       cellShift = 0;
       hotPointX = prevColStartPos + prevColText.length();
     }
     environment.hint(Hints.TABLE_END_OF_COL);
     environment.onAreaNewContent(this);
     environment.onAreaNewHotPoint(this);
     return true;
   }
   cellShift = c.shift;
   hotPointX = c.pos + colStartPos;
   if (c.pos == c.width) // Should never happen;
   environment.hint(Hints.TABLE_END_OF_COL);
   else environment.sayLetter(c.line.charAt(c.pos + c.shift));
   environment.onAreaNewContent(this);
   environment.onAreaNewHotPoint(this);
   return true;
 }
Esempio n. 5
0
 private boolean onArrowRight(KeyboardEvent event) {
   if (noContentCheck()) return true;
   final int count = model.getRowCount();
   if (hotPointY < 0 || hotPointY >= count) {
     environment.hint(Hints.EMPTY_LINE);
     return true;
   }
   // Checking that hot point not before proper line begin;
   if (hotPointX < initialHotPointX) hotPointX = initialHotPointX;
   if (getColUnderPos(hotPointX) < 0) hotPointX = initialHotPointX;
   final int currentCol = getColUnderPos(hotPointX);
   final int currentColWidth = colWidth[currentCol];
   final int colStartPos = getColStartPos(currentCol);
   final int nextColStartPos = colStartPos + colWidth[currentCol] + 1;
   final TableCell c =
       new TableCell(
           hotPointX - colStartPos,
           cellShift,
           currentColWidth,
           appearance.getCellText(model, currentCol, hotPointY));
   if (!c.moveNext()) {
     if (currentCol + 1 >= colWidth.length) {
       environment.hint(Hints.TABLE_END_OF_ROW);
       return true;
     }
     cellShift = 0;
     hotPointX = nextColStartPos;
     final String nextColText = appearance.getCellText(model, currentCol + 1, hotPointY);
     if (!nextColText.isEmpty()) environment.sayLetter(nextColText.charAt(0));
     else
       environment.hint(
           currentCol + 2 < colWidth.length ? Hints.TABLE_END_OF_COL : Hints.TABLE_END_OF_ROW);
     environment.onAreaNewContent(this);
     environment.onAreaNewHotPoint(this);
     return true;
   }
   cellShift = c.shift;
   hotPointX = c.pos + colStartPos;
   if (c.pos + c.shift >= c.line.length())
     environment.hint(
         currentCol + 1 < colWidth.length ? Hints.TABLE_END_OF_COL : Hints.TABLE_END_OF_ROW);
   else environment.sayLetter(c.line.charAt(c.pos + c.shift));
   environment.onAreaNewContent(this);
   environment.onAreaNewHotPoint(this);
   return true;
 }
Esempio n. 6
0
 private void onNewHotPointY(boolean briefIntroduction) {
   final int count = model.getRowCount();
   hotPointX = hotPointY < count ? initialHotPointX : 0;
   cellShift = 0;
   environment.onAreaNewHotPoint(this);
   if (hotPointY < count)
     appearance.introduceRow(model, hotPointY, briefIntroduction ? INTRODUCTION_BRIEF : 0);
   else environment.hint(Hints.EMPTY_LINE);
 }
Esempio n. 7
0
 protected boolean onAnnounceLine() {
   if (isEmpty()) return false;
   final Object item = selected();
   if (item == null) {
     environment.hint(Hints.EMPTY_LINE);
     return true;
   }
   appearance.announceItem(item, NONE_APPEARANCE_FLAGS);
   return true;
 }
Esempio n. 8
0
 private boolean onArrowDown(KeyboardEvent event, boolean briefIntroduction) {
   if (noContentCheck()) return true;
   final int count = model.getRowCount();
   if (hotPointY >= count) {
     environment.hint(Hints.TABLE_NO_ROWS_BELOW);
     return true;
   }
   ++hotPointY;
   onNewHotPointY(briefIntroduction);
   return true;
 }
Esempio n. 9
0
 protected void onNewHotPointY(boolean briefAnnouncement) {
   final int index = selectedIndex();
   if (index < 0) {
     environment.hint(Hints.EMPTY_LINE);
     hotPointX = 0;
     environment.onAreaNewHotPoint(this);
     return;
   }
   final Object item = model.getItem(index);
   if (item == null) {
     environment.hint(Hints.EMPTY_LINE);
     hotPointX = 0;
     environment.onAreaNewHotPoint(this);
     return;
   }
   appearance.announceItem(
       item, briefAnnouncement ? BRIEF_ANNOUNCEMENT_ONLY : NONE_APPEARANCE_FLAGS);
   hotPointX = appearance.getObservableLeftBound(item);
   environment.onAreaNewHotPoint(this);
 }
Esempio n. 10
0
 protected boolean onArrowRight(KeyboardEvent event) {
   if (noContent()) return true;
   final Object item = selected();
   NullCheck.notNull(item, "item");
   final String line = appearance.getScreenAppearance(item, NONE_APPEARANCE_FLAGS);
   NullCheck.notNull(line, "line");
   if (line.isEmpty()) {
     environment.hint(Hints.EMPTY_LINE);
     return true;
   }
   final int rightBound = appearance.getObservableRightBound(item);
   if (hotPointX >= rightBound) {
     environment.hint(Hints.END_OF_LINE);
     return true;
   }
   ++hotPointX;
   announceChar(line, hotPointX, rightBound);
   environment.onAreaNewHotPoint(this);
   return true;
 }
Esempio n. 11
0
 private boolean onPageUp(KeyboardEvent event, boolean briefIntroduction) {
   if (noContentCheck()) return true;
   if (hotPointY <= 0) {
     environment.hint(Hints.TABLE_NO_ROWS_ABOVE);
     return true;
   }
   hotPointY -= environment.getAreaVisibleHeight(this);
   if (hotPointY < 0) hotPointY = 0;
   onNewHotPointY(briefIntroduction);
   return true;
 }
Esempio n. 12
0
 private boolean onPageDown(KeyboardEvent event, boolean briefIntroduction) {
   if (noContentCheck()) return true;
   final int count = model.getRowCount();
   if (hotPointY >= count) {
     environment.hint(Hints.TABLE_NO_ROWS_BELOW);
     return true;
   }
   hotPointY += environment.getAreaVisibleHeight(this);
   if (hotPointY >= count) hotPointY = count;
   onNewHotPointY(briefIntroduction);
   return true;
 }
Esempio n. 13
0
 private boolean onArrowUp(KeyboardEvent event, boolean briefIntroduction) {
   if (noContentCheck()) return true;
   final int count = model.getRowCount();
   if (hotPointY <= 0) {
     environment.hint(Hints.TABLE_NO_ROWS_ABOVE);
     return true;
   }
   --hotPointY;
   if (hotPointY >= count) hotPointY = count - 1;
   onNewHotPointY(briefIntroduction);
   return true;
 }
Esempio n. 14
0
 /**
  * Selects the item by its index. Given the non-negative integer value as an index, this method
  * sets the hot point on the item addressed with this index, checking only that index is in
  * appropriate bounds. Index must address the object as a number in the model, ignoring any empty
  * lines.
  *
  * @param index The item index to select
  * @param announce Must be true, if it is necessary to announce the item , once it has been
  *     selected
  * @return True if the index is valid and the item gets hot point on it
  */
 public boolean select(int index, boolean announce) {
   if (index < 0 || index >= model.getItemCount()) return false;
   final int emptyCountAbove = flags.contains(Flags.EMPTY_LINE_TOP) ? 1 : 0;
   hotPointY = index + emptyCountAbove;
   final Object item = model.getItem(index);
   if (item != null) {
     hotPointX = appearance.getObservableLeftBound(item);
     if (announce) appearance.announceItem(item, NONE_APPEARANCE_FLAGS);
   } else {
     hotPointX = 0;
     if (announce) environment.hint(Hints.EMPTY_LINE);
   }
   environment.onAreaNewHotPoint(this);
   return true;
 }
Esempio n. 15
0
 protected boolean onTransition(Transition.Type type, int hint, boolean briefAnnouncement) {
   NullCheck.notNull(type, "type");
   //	NullCheck.notNull(hint, "hint");
   if (noContent()) return true;
   final int index = selectedIndex();
   final int count = model.getItemCount();
   final int emptyCountTop = flags.contains(Flags.EMPTY_LINE_TOP) ? 1 : 0;
   final Transition.State current;
   if (index >= 0) current = new Transition.State(index);
   else if (flags.contains(Flags.EMPTY_LINE_TOP) && hotPointY == 0)
     current = new Transition.State(Transition.State.Type.EMPTY_LINE_TOP);
   else if (flags.contains(Flags.EMPTY_LINE_BOTTOM) && hotPointY == count + emptyCountTop)
     current = new Transition.State(Transition.State.Type.EMPTY_LINE_BOTTOM);
   else return false;
   final Transition.State newState =
       transition.transition(
           type,
           current,
           count,
           flags.contains(Flags.EMPTY_LINE_TOP),
           flags.contains(Flags.EMPTY_LINE_BOTTOM));
   NullCheck.notNull(newState, "newState");
   Log.debug("list", "newState=" + newState.type);
   switch (newState.type) {
     case NO_TRANSITION:
       environment.hint(hint);
       return true;
     case EMPTY_LINE_TOP:
       if (!flags.contains(Flags.EMPTY_LINE_TOP)) return false;
       hotPointY = 0;
       break;
     case EMPTY_LINE_BOTTOM:
       if (!flags.contains(Flags.EMPTY_LINE_BOTTOM)) return false;
       hotPointY = count + emptyCountTop;
       break;
     case ITEM_INDEX:
       if (newState.itemIndex < 0 || newState.itemIndex >= count) return false;
       hotPointY = newState.itemIndex + emptyCountTop;
       break;
     default:
       return false;
   }
   onNewHotPointY(briefAnnouncement);
   return true;
 }
Esempio n. 16
0
 public void resetHotPoint(boolean introduce) {
   hotPointY = 0;
   final int count = model.getItemCount();
   if (count < 1) {
     hotPointX = 0;
     environment.onAreaNewHotPoint(this);
     return;
   }
   final Object item = model.getItem(0);
   if (item != null) {
     hotPointX = item != null ? appearance.getObservableLeftBound(item) : 0;
     if (introduce) appearance.announceItem(item, NONE_APPEARANCE_FLAGS);
   } else {
     hotPointX = 0;
     environment.hint(Hints.EMPTY_LINE);
   }
   environment.onAreaNewHotPoint(this);
 }
Esempio n. 17
0
 private boolean noContentCheck() {
   if (!noProperContent()) return false;
   environment.hint(environment.staticStr(LangStatic.TABLE_NO_CONTENT), Hints.NO_CONTENT);
   return true;
 }
Esempio n. 18
0
 protected void announceChar(String line, int pos, int rightBound) {
   NullCheck.notNull(line, "line");
   if (pos < rightBound) environment.sayLetter(line.charAt(pos));
   else environment.hint(Hints.END_OF_LINE);
 }