Source:
void paintLabels(Graphics2D graphics, Rectangle displayArea) { if (!activeLayers.isEmpty()) { throw new IllegalStateException(activeLayers + " are layers that started rendering but have not completed," + " stop() or endLayer() must be called before end() is called"); } LabelIndex glyphs = new LabelIndex(); glyphs.reserveArea( reserved ); boolean painted; int nonPaintedLineLabels = 0; int paintedLineLabels = 0; displayArea = new Rectangle(displayArea); displayArea.width -= 1; displayArea.height -= 1; clipper = new GeometryClipper(new Envelope(displayArea.getMinX(), displayArea.getMaxX(), displayArea.getMinY(), displayArea.getMaxY())); List<LabelCacheItem> items; if (needsOrdering) { items = orderedLabels(); } else { items = getActiveLabels(); } LabelPainter painter = new LabelPainter(graphics, labelRenderingMode); for (LabelCacheItem labelItem : items) { if (stop) return; painter.setLabel(labelItem); try { AffineTransform tempTransform = new AffineTransform(); Geometry geom = labelItem.getGeometry(); if ((geom instanceof Point) || (geom instanceof MultiPoint)) paintPointLabel(painter, tempTransform, displayArea, glyphs); else if (((geom instanceof LineString) && !(geom instanceof LinearRing)) || (geom instanceof MultiLineString)){ if(!DISABLE_LETTER_LEVEL_CONFLICT) painted = paintLineLabelsWithLetterConflict(painter, tempTransform, displayArea, glyphs); else painted = paintLineLabels(painter, tempTransform, displayArea, glyphs); if (!painted){ nonPaintedLineLabels++; } else paintedLineLabels++; } else if (geom instanceof Polygon || geom instanceof MultiPolygon || geom instanceof LinearRing) paintPolygonLabel(painter, tempTransform, displayArea, glyphs); } catch (Exception e) { System.out.println("Issues painting " + labelItem.getLabel()); e.printStackTrace(); } } LOGGER.log(Level.INFO, "TOTAL LINE LABELS : {0}", items.size()); LOGGER.log(Level.INFO, "PAINTED LINE LABELS : {0}", paintedLineLabels); LOGGER.log(Level.INFO, "REMAINING LINE LABELS : {0}", nonPaintedLineLabels); }

Target:
void paintLabels(Graphics2D graphics, Rectangle displayArea) { if (!activeLayers.isEmpty()) { throw new IllegalStateException(activeLayers + " are layers that started rendering but have not completed," + " stop() or endLayer() must be called before end() is called"); } LabelIndex glyphs = new LabelIndex(); glyphs.reserveArea( reserved ); boolean painted; int nonPaintedLineLabels = 0; int paintedLineLabels = 0; displayArea = new Rectangle(displayArea); displayArea.width -= 1; displayArea.height -= 1; clipper = new GeometryClipper(new Envelope(displayArea.getMinX(), displayArea.getMaxX(), displayArea.getMinY(), displayArea.getMaxY())); List<LabelCacheItem> items; if (needsOrdering) { items = orderedLabels(); } else { items = getActiveLabels(); } LabelPainter painter = new LabelPainter(graphics, labelRenderingMode); for (LabelCacheItem labelItem : items) { if (stop) return; painter.setLabel(labelItem); try { AffineTransform tempTransform = new AffineTransform(); Geometry geom = labelItem.getGeometry(); if ((geom instanceof Point) || (geom instanceof MultiPoint)) paintPointLabel(painter, tempTransform, displayArea, glyphs); else if (((geom instanceof LineString) && !(geom instanceof LinearRing)) || (geom instanceof MultiLineString)){ if(!DISABLE_LETTER_LEVEL_CONFLICT) painted = paintLineLabelsWithLetterConflict(painter, tempTransform, displayArea, glyphs); else painted = paintLineLabels(painter, tempTransform, displayArea, glyphs); if (!painted){ nonPaintedLineLabels++; } else paintedLineLabels++; } else if (geom instanceof Polygon || geom instanceof MultiPolygon || geom instanceof LinearRing) paintPolygonLabel(painter, tempTransform, displayArea, glyphs); } catch (Exception e) { System.out.println("Issues painting " + labelItem.getLabel()); e.printStackTrace(); } } LOGGER.log(Level.FINE, "TOTAL LINE LABELS : {0}", items.size()); LOGGER.log(Level.FINE, "PAINTED LINE LABELS : {0}", paintedLineLabels); LOGGER.log(Level.FINE, "REMAINING LINE LABELS : {0}", nonPaintedLineLabels); }