!752 !include #1004828 // Java Analysis static new JTextArea infoArea; p { loadConceptsFrom("#1004820"); SSnippet snippet = conceptOfType(SSnippet.class); L substrings = sortedByField(findBackRefs(snippet, Substring.class), "startIndex"); print("substrings: " + l(substrings)); new StringBuilder buf; int i = 0, iCol = 0; for (Substring s : substrings) { //print("s/e= " + s.startIndex + "/" + s.endIndex); buf.append(htmlencode(substring(snippet.text, i, s.startIndex))); S col = odd(iCol++) //? "#b8d1f3" : "#dae5f4"; ? "#CC0000" : "#0000CC"; // Coder Colors! buf.append(span(b(href(str(s.id), htmlencode(s.text()))), "style", "color: " + col)); i = s.endIndex; } buf.append(htmlencode(substring(snippet.text, i))); S html = hhtml(pre(buf)); JEditorPane editorPane = new JEditorPane("text/html", html); editorPane.setEditable(false); editorPane.addHyperlinkListener(new HyperlinkListener { public void hyperlinkUpdate(HyperlinkEvent e) { S link = e.getDescription(); HyperlinkEvent.EventType type = e.getEventType(); //print("Event! " + e.getEventType() + " " + link); if (type == HyperlinkEvent.EventType.ENTERED) showInfo(link); else if (type == HyperlinkEvent.EventType.EXITED) showInfo(null); } }); showFrame(vgrid(editorPane, infoArea)); } static void showInfo(S id) { new StringBuilder buf; Concept c = getConcept(id); if (c != null) { buf.append(shortClassName(c)); if (c instanceof Substring) buf.append(" " + quote(((Substring) c).text())); } infoArea.setText(str(buf)); infoArea.setCaretPosition(0); }