!7 static L> arrows = synchroList(); p-experiment { S text = lines(sentencesAfterLines_withPeriodOnly(mechList_raw("Simple Wikipedia: Peafowl"))); //jtextpane(text) JTextPane tp = swing(func -> JTextPane { ret new JTextPane { public void paint(Graphics _g) { Graphics2D g = cast _g; super.paint(g); pcall { S text = getText(); for (Pair p : cloneList(arrows)) { Rect r1 = textComponent_substringRect(this, p.a); Rect r2 = textComponent_substringRect(this, p.b); if (r1 != null && r2 != null) { fillRect(g, r1, colorWithAlpha(Color.green, 0.2)); fillRect(g, r2, colorWithAlpha(Color.red, 0.2)); Color arrowColor = colorWithAlpha(Color.red, 0.3); //drawArrowBetweenRects(g, r1, r2, arrowColor); drawArrowBetweenPoints(g, centerOfRect(r1), centerOfRect(r2), arrowColor); } } } } }; }); setTextCaret0(tp, text); showFrame(setFontSize(30, tp)); L tok = javaTok(text); addPair(arrows, tokenToCharRange(tok, indexOfIC(tok, "it")), tokenToCharRange(tok, indexOfIC(tok, "peafowl"))); }