@Test public void testAddOffsetTrackingIcon_2Arg_Valid() throws Exception { RTextArea textArea = new RTextArea(PLAIN_TEXT); Gutter gutter = new Gutter(textArea); Icon icon = new TestIcon(); GutterIconInfo gii = gutter.addOffsetTrackingIcon(17, icon); Assert.assertTrue(gii.getIcon() == icon); Assert.assertEquals(17, gii.getMarkedOffset()); Assert.assertNull(gii.getToolTip()); textArea.insert("a", 3); Assert.assertEquals(18, gii.getMarkedOffset()); }
for (int i=trackingIcons.size()-1; i>=0; i--) { // Last to first GutterIconInfo ti = getTrackingIcon(i); Icon icon = ti.getIcon(); if (icon!=null) { int iconH = icon.getIconHeight(); int offs = ti.getMarkedOffset(); if (offs>=0 && offs<=doc.getLength()) { int line = root.getElementIndex(offs); if (lineY<=bottomY && (lineY+iconH>=topY)) { int y2 = lineY + (cellHeight-iconH)/2; ti.getIcon().paintIcon(this, g, 0, y2); lastLine = line-1; // Paint only 1 icon per line
@Override public int compareTo(GutterIconInfo other) { if (other!=null) { return pos.getOffset() - other.getMarkedOffset(); } return -1; }
/** * Overridden to display the tool tip of any icons on this line. * * @param e The location the mouse is hovering over. */ @Override public String getToolTipText(MouseEvent e) { try { int line = viewToModelLine(e.getPoint()); if (line>-1) { GutterIconInfo[] infos = getTrackingIcons(line); if (infos.length>0) { // TODO: Display all messages? return infos[infos.length-1].getToolTip(); } } } catch (BadLocationException ble) { ble.printStackTrace(); // Never happens } return null; }
if (icons[i].getIcon()==bookmarkIcon) { removeTrackingIcon(icons[i]); found = true;
for (int i=trackingIcons.size()-1; i>=0; i--) { // Last to first GutterIconInfo ti = getTrackingIcon(i); int offs = ti.getMarkedOffset(); if (offs>=0 && offs<=doc.getLength()) { int line = root.getElementIndex(offs); if (line<=lastLine && line>=topLine) { Icon icon = ti.getIcon(); if (icon!=null) { int y2 = y + (line-topLine)*cellHeight; y2 += (cellHeight-icon.getIconHeight())/2; ti.getIcon().paintIcon(this, g, 0, y2); lastLine = line-1; // Paint only 1 icon per line
for (int i=0; i<bookmarks.length; i++) { GutterIconInfo bookmark = bookmarks[i]; int offs = bookmark.getMarkedOffset(); int line = textArea.getLineOfOffset(offs); if (line>curLine) { for (int i=bookmarks.length-1; i>=0; i--) { GutterIconInfo bookmark = bookmarks[i]; int offs = bookmark.getMarkedOffset(); int line = textArea.getLineOfOffset(offs); if (line<curLine) { int offs = moveTo.getMarkedOffset(); if (textArea instanceof RSyntaxTextArea) { RSyntaxTextArea rsta = (RSyntaxTextArea)textArea;
/** * Overridden to display the tool tip of any icons on this line. * * @param e The location the mouse is hovering over. */ @Override public String getToolTipText(MouseEvent e) { try { int line = viewToModelLine(e.getPoint()); if (line>-1) { GutterIconInfo[] infos = getTrackingIcons(line); if (infos.length>0) { // TODO: Display all messages? return infos[infos.length-1].getToolTip(); } } } catch (BadLocationException ble) { ble.printStackTrace(); // Never happens } return null; }
if (icons[i].getIcon()==bookmarkIcon) { removeTrackingIcon(icons[i]); found = true;
@Test public void testAddLineTrackingIcon_3Arg_Valid() throws Exception { RTextArea textArea = new RTextArea(PLAIN_TEXT); Gutter gutter = new Gutter(textArea); Icon icon = new TestIcon(); String tip = "tip text"; GutterIconInfo gii = gutter.addLineTrackingIcon(1, icon, tip); int line1Start = textArea.getText().indexOf('\n') + 1; Assert.assertTrue(gii.getIcon() == icon); Assert.assertEquals(line1Start, gii.getMarkedOffset()); Assert.assertEquals(tip, gii.getToolTip()); textArea.insert("a", 0); line1Start = textArea.getText().indexOf('\n') + 1; // Should have advanced 1 Assert.assertEquals(line1Start, gii.getMarkedOffset()); }
for (int i=trackingIcons.size()-1; i>=0; i--) { // Last to first GutterIconInfo ti = getTrackingIcon(i); int offs = ti.getMarkedOffset(); if (offs>=0 && offs<=doc.getLength()) { int line = root.getElementIndex(offs); if (line<=lastLine && line>=topLine) { try { Icon icon = ti.getIcon(); if (icon!=null) { int lineY = rsta.yForLine(line);
boolean markerOffsetMudou() { return gutterInfo.getMarkedOffset() != offsetOriginal; }
@Test public void testAddOffsetTrackingIcon_3Arg_Valid() throws Exception { RTextArea textArea = new RTextArea(PLAIN_TEXT); Gutter gutter = new Gutter(textArea); Icon icon = new TestIcon(); String tip = "tip text"; GutterIconInfo gii = gutter.addOffsetTrackingIcon(17, icon, tip); Assert.assertTrue(gii.getIcon() == icon); Assert.assertEquals(17, gii.getMarkedOffset()); Assert.assertEquals(tip, gii.getToolTip()); textArea.insert("a", 3); Assert.assertEquals(18, gii.getMarkedOffset()); }
for (int i=trackingIcons.size()-1; i>=0; i--) { // Last to first GutterIconInfo ti = getTrackingIcon(i); Icon icon = ti.getIcon(); if (icon!=null) { int iconH = icon.getIconHeight(); int offs = ti.getMarkedOffset(); if (offs>=0 && offs<=doc.getLength()) { int line = root.getElementIndex(offs); if (lineY<=bottomY && (lineY+iconH>=topY)) { int y2 = lineY + (cellHeight-iconH)/2; ti.getIcon().paintIcon(this, g, 0, y2); lastLine = line-1; // Paint only 1 icon per line
public IconePontoDeParada(GutterIconInfo gutterInfo, boolean estaAtivado) { this.gutterInfo = gutterInfo; this.ativado = estaAtivado; this.offsetOriginal = gutterInfo.getMarkedOffset(); }
@Test public void testAddLineTrackingIcon_2Arg_Valid() throws Exception { RTextArea textArea = new RTextArea(PLAIN_TEXT); Gutter gutter = new Gutter(textArea); Icon icon = new TestIcon(); GutterIconInfo gii = gutter.addLineTrackingIcon(1, icon); int line1Start = textArea.getText().indexOf('\n') + 1; Assert.assertTrue(gii.getIcon() == icon); Assert.assertEquals(line1Start, gii.getMarkedOffset()); Assert.assertNull(gii.getToolTip()); textArea.insert("a", 0); line1Start = textArea.getText().indexOf('\n') + 1; // Should have advanced 1 Assert.assertEquals(line1Start, gii.getMarkedOffset()); }
for (int i=trackingIcons.size()-1; i>=0; i--) { // Last to first GutterIconInfo ti = getTrackingIcon(i); int offs = ti.getMarkedOffset(); if (offs>=0 && offs<=doc.getLength()) { int line = root.getElementIndex(offs); if (line<=lastLine && line>=topLine) { Icon icon = ti.getIcon(); if (icon!=null) { int y2 = y + (line-topLine)*cellHeight; y2 += (cellHeight-icon.getIconHeight())/2; ti.getIcon().paintIcon(this, g, 0, y2); lastLine = line-1; // Paint only 1 icon per line
@Override public int compareTo(GutterIconInfo other) { if (other!=null) { return pos.getOffset() - other.getMarkedOffset(); } return -1; }
for (int i=trackingIcons.size()-1; i>=0; i--) { // Last to first GutterIconInfo ti = getTrackingIcon(i); int offs = ti.getMarkedOffset(); if (offs>=0 && offs<=doc.getLength()) { int line = root.getElementIndex(offs); if (line<=lastLine && line>=topLine) { try { Icon icon = ti.getIcon(); if (icon!=null) { int lineY = rsta.yForLine(line);
boolean linhaMudou() { try { return getLineOfOffset(gutterInfo.getMarkedOffset()) != getLineOfOffset(offsetOriginal); } catch (BadLocationException ex) { return true; } }