MCPcopy Create free account
hub / github.com/AstroImageJ/astroimagej / clearSelection

Method clearSelection

ij/src/main/java/ij/text/TextPanel.java:895–946  ·  view source on GitHub ↗

Deletes the selected lines.

()

Source from the content-addressed store, hash-verified

893
894 /** Deletes the selected lines. */
895 public void clearSelection() {
896 if (selStart==-1 || selEnd==-1) {
897 if (getLineCount()>0)
898 IJ.error("Text selection required");
899 return;
900 }
901 if (IJ.recording()) {
902 if (Recorder.scriptMode())
903 Recorder.recordString("IJ.deleteRows("+selStart+", "+selEnd+");\n");
904 else {
905 if ("Results".equals(title))
906 Recorder.record("Table.deleteRows", selStart, selEnd);
907 else
908 Recorder.record("Table.deleteRows", selStart, selEnd, title);
909 }
910 }
911 int first=selStart, last=selEnd, rows=iRowCount;
912 if (selStart==0 && selEnd==(iRowCount-1)) {
913 vData.removeAllElements();
914 iRowCount = 0;
915 if (rt!=null) {
916 if (IJ.isResultsWindow() && IJ.getTextPanel()==this) {
917 Analyzer.setUnsavedMeasurements(false);
918 Analyzer.resetCounter();
919 } else
920 rt.reset();
921 }
922 } else {
923 int rowCount = iRowCount;
924 boolean atEnd = rowCount-selEnd<8;
925 int count = selEnd-selStart+1;
926 for (int i=0; i<count; i++) {
927 vData.removeElementAt(selStart);
928 iRowCount--;
929 }
930 if (rt!=null && rowCount==rt.size()) {
931 for (int i=0; i<count; i++)
932 rt.deleteRow(selStart);
933 rt.show(title);
934 if (!atEnd) {
935 iY = 0;
936 tc.repaint();
937 }
938 }
939 }
940 ImagePlus imp = WindowManager.getCurrentImage();
941 if (imp!=null)
942 Overlay.updateTableOverlay(imp, first, last, rows);
943 selStart=-1; selEnd=-1; selOrigin=-1; selLine=-1;
944 adjustVScroll();
945 tc.repaint();
946 }
947
948 /** Deletes all the lines. */
949 public synchronized void clear() {

Callers 4

keyPressedMethod · 0.95
cutSelectionMethod · 0.95
doClearMethod · 0.95
deselectMethod · 0.45

Calls 15

getLineCountMethod · 0.95
errorMethod · 0.95
recordingMethod · 0.95
scriptModeMethod · 0.95
recordStringMethod · 0.95
recordMethod · 0.95
isResultsWindowMethod · 0.95
getTextPanelMethod · 0.95
resetCounterMethod · 0.95
getCurrentImageMethod · 0.95
updateTableOverlayMethod · 0.95

Tested by

no test coverage detected