protected void showSelectedGraphicsNode() {
GraphicsNode gn = walker.getCurrentGraphicsNode();
if (!(gn instanceof TextNode)) {
return;
}
TextNode textNode = (TextNode)gn;
// mark the selection of the substring found
String text = textNode.getText();
String pattern = search.getText();
if (!caseSensitive.isSelected()) {
text = text.toLowerCase();
pattern = pattern.toLowerCase();
}
int end = text.indexOf(pattern, currentIndex);
AttributedCharacterIterator aci =
textNode.getAttributedCharacterIterator();
aci.first();
for (int i=0; i < end; ++i) {
aci.next();
}
Mark startMark = textNode.getMarkerForChar(aci.getIndex(), true);
for (int i = 0; i < pattern.length()-1; ++i) {
aci.next();
}
Mark endMark = textNode.getMarkerForChar(aci.getIndex(), false);
svgCanvas.select(startMark, endMark);
// zoom on the TextNode if needed
if (highlightButton.isSelected()) {
return;
}
// get the highlight shape in GVT root (global) coordinate sytem
Shape s = textNode.getHighlightShape();
AffineTransform at;
if (highlightCenterZoomButton.isSelected()) {
at = svgCanvas.getInitialTransform();
} else {
at = svgCanvas.getRenderingTransform();