// ------------------// // getAlienPixelsIn // // ------------------// public int getAlienPixelsIn(Rectangle area) { int count = 0; final int posMin = area.y; final int posMax = (area.y + area.height) - 1; final List<GlyphSection> neighbors = glyph.getLag().getSectionsIn(area); for (GlyphSection section : neighbors) { // Keep only non-patch sections that are not part of the stick if (!section.isPatch() && (section.getGlyph() != glyph)) { int pos = section.getFirstPos() - 1; // Ordinate for horizontal, // Abscissa for vertical for (Run run : section.getRuns()) { pos++; if (pos > posMax) { break; } if (pos < posMin) { continue; } int coordMin = Math.max(area.x, run.getStart()); int coordMax = Math.min((area.x + area.width) - 1, run.getStop()); if (coordMax >= coordMin) { count += (coordMax - coordMin + 1); } } } } if (logger.isFineEnabled()) { logger.fine("Stick" + glyph.getId() + " " + area + " getAlienPixelsIn=" + count); } return count; }
// --------------// // getLastStuck // // --------------// public int getLastStuck() { int stuck = 0; for (GlyphSection section : glyph.getMembers()) { Run sectionRun = section.getLastRun(); for (GlyphSection sct : section.getTargets()) { if (!sct.isGlyphMember() || (sct.getGlyph() != glyph)) { stuck += sectionRun.getCommonLength(sct.getFirstRun()); } } } return stuck; }