/** * Available if somewhere in table * * @param stopPointsMap stop points of interest map by section or null * * @return next stop point offset or offset after end of table */ public TableCellOffsetInfo nextOffsetStop(final Map<TableSectionType, Integer> stopPointsMap) { int stopOffset = getStopOffset(offset, table, stopPointsMap, true); if (stopOffset != -1) { return table.getCellOffsetInfo(stopOffset); } // go to after the table List<TableRow> allRows = table.getAllSectionRows(); TableRow lastRow = allRows.get(allRows.size() - 1); TableCell lastCell = lastRow.cells.get(lastRow.cells.size() - 1); int offset = lastCell.getEndOffset(); BasedSequence baseSequence = lastCell.text.getBaseSequence(); int eolPos = baseSequence.endOfLineAnyEOL(offset); return table.getCellOffsetInfo(eolPos == -1 ? offset : eolPos + baseSequence.eolLength(eolPos)); }
public int getLineNumber(int offset) { if (lineSegments == EMPTY_LIST) { BasedSequence preText = getChars().baseSubSequence(0, Utils.maxLimit(offset, getChars().length())); if (preText.isEmpty()) return 0; int lineNumber = 0; int nextLineEnd = preText.endOfLineAnyEOL(0); final int length = preText.length(); while (nextLineEnd < length) { lineNumber++; nextLineEnd = preText.endOfLineAnyEOL(nextLineEnd + 1); } return lineNumber; } else { final int iMax = lineSegments.size(); for (int i = 0; i < iMax; i++) { if (offset < lineSegments.get(i).getEndOffset()) { return i; } } return iMax; } }
public int getLineNumber(int offset) { if (lineSegments == EMPTY_LIST) { BasedSequence preText = getChars().baseSubSequence(0, Utils.maxLimit(offset, getChars().length())); if (preText.isEmpty()) return 0; int lineNumber = 0; int nextLineEnd = preText.endOfLineAnyEOL(0); final int length = preText.length(); while (nextLineEnd < length) { lineNumber++; nextLineEnd = preText.endOfLineAnyEOL(nextLineEnd + 1); } return lineNumber; } else { final int iMax = lineSegments.size(); for (int i = 0; i < iMax; i++) { if (offset < lineSegments.get(i).getEndOffset()) { return i; } } return iMax; } }
/** * Available if somewhere in table * * @param stopPointsMap stop points of interest map by section or null * * @return next stop point offset or offset after end of table */ public TableCellOffsetInfo nextOffsetStop(final Map<TableSectionType, Integer> stopPointsMap) { int stopOffset = getStopOffset(offset, table, stopPointsMap, true); if (stopOffset != -1) { return table.getCellOffsetInfo(stopOffset); } // go to after the table List<TableRow> allRows = table.getAllSectionRows(); TableRow lastRow = allRows.get(allRows.size() - 1); TableCell lastCell = lastRow.cells.get(lastRow.cells.size() - 1); int offset = lastCell.getEndOffset(); BasedSequence baseSequence = lastCell.text.getBaseSequence(); int eolPos = baseSequence.endOfLineAnyEOL(offset); return table.getCellOffsetInfo(eolPos == -1 ? offset : eolPos + baseSequence.eolLength(eolPos)); }
/** Compute the number of lines for reaching the given node. * * @param node the node. * @return the line number for the node. */ protected static int computeLineNo(Node node) { final int offset = node.getStartOffset(); final BasedSequence seq = node.getDocument().getChars(); int tmpOffset = seq.endOfLine(0); int lineno = 1; while (tmpOffset < offset) { ++lineno; tmpOffset = seq.endOfLineAnyEOL(tmpOffset + seq.eolLength(tmpOffset)); } return lineno; }