@Override public RegionContent getWholeRegion() { if (model == null || model.getItemCount() < 0) return null; final LinkedList<String> res = new LinkedList<String>(); final int count = model.getItemCount(); for (int i = 0; i < count; ++i) { final String line = appearance.getScreenAppearance(model.getItem(i), NONE_APPEARANCE_FLAGS); res.add(line != null ? line : ""); } res.add(""); return new RegionContent(res.toArray(new String[res.size()])); }
@Override public RegionContent getRegion(int fromX, int fromY, int toX, int toY) { if (model == null || model.getItemCount() < 0) return null; if (fromY >= model.getItemCount() || toY > model.getItemCount()) return null; if (fromY == toY) { final String line = appearance.getScreenAppearance(model.getItem(fromY), NONE_APPEARANCE_FLAGS); if (line == null || line.isEmpty()) return null; final int fromPos = fromX < line.length() ? fromX : line.length(); final int toPos = toX < line.length() ? toX : line.length(); if (fromPos >= toPos) return null; return new RegionContent(new String[] {line.substring(fromPos, toPos)}); } final LinkedList<String> res = new LinkedList<String>(); for (int i = fromY; i < toY; ++i) { final String line = appearance.getScreenAppearance(model.getItem(i), NONE_APPEARANCE_FLAGS); res.add(line != null ? line : ""); } res.add(""); return new RegionContent(res.toArray(new String[res.size()])); }