summaryrefslogtreecommitdiff
path: root/src/main/java/cuchaz/enigma/utils/Utils.java
diff options
context:
space:
mode:
authorGravatar asiekierka2016-08-17 18:35:12 +0200
committerGravatar asiekierka2016-08-17 18:35:12 +0200
commit5540c815de36e316d0749ce2163f12c61895b327 (patch)
tree2b30d5ae98735ee7cba7d1c0087c51d68ed3ebf9 /src/main/java/cuchaz/enigma/utils/Utils.java
parentRevert "Removed util" (diff)
downloadenigma-fork-5540c815de36e316d0749ce2163f12c61895b327.tar.gz
enigma-fork-5540c815de36e316d0749ce2163f12c61895b327.tar.xz
enigma-fork-5540c815de36e316d0749ce2163f12c61895b327.zip
Revert "Removed unused methods"
This reverts commit 1742190f784d0d62e7cc869eebafdfe1927e448f.
Diffstat (limited to 'src/main/java/cuchaz/enigma/utils/Utils.java')
-rw-r--r--src/main/java/cuchaz/enigma/utils/Utils.java43
1 files changed, 0 insertions, 43 deletions
diff --git a/src/main/java/cuchaz/enigma/utils/Utils.java b/src/main/java/cuchaz/enigma/utils/Utils.java
index e391b5a..c16c1fb 100644
--- a/src/main/java/cuchaz/enigma/utils/Utils.java
+++ b/src/main/java/cuchaz/enigma/utils/Utils.java
@@ -88,47 +88,4 @@ public class Utils {
88 manager.mouseMoved(new MouseEvent(component, MouseEvent.MOUSE_MOVED, System.currentTimeMillis(), 0, 0, 0, 0, false)); 88 manager.mouseMoved(new MouseEvent(component, MouseEvent.MOUSE_MOVED, System.currentTimeMillis(), 0, 0, 0, 0, false));
89 manager.setInitialDelay(oldDelay); 89 manager.setInitialDelay(oldDelay);
90 } 90 }
91
92 public static void navigateToToken(final JEditorPane editor, final Token token, final Highlighter.HighlightPainter highlightPainter) {
93
94 // set the caret position to the token
95 editor.setCaretPosition(token.start);
96 editor.grabFocus();
97
98 try {
99 // make sure the token is visible in the scroll window
100 Rectangle start = editor.modelToView(token.start);
101 Rectangle end = editor.modelToView(token.end);
102 final Rectangle show = start.union(end);
103 show.grow(start.width * 10, start.height * 6);
104 SwingUtilities.invokeLater(() -> editor.scrollRectToVisible(show));
105 } catch (BadLocationException ex) {
106 throw new Error(ex);
107 }
108
109 // highlight the token momentarily
110 final Timer timer = new Timer(200, new ActionListener() {
111 private int m_counter = 0;
112 private Object m_highlight = null;
113
114 @Override
115 public void actionPerformed(ActionEvent event) {
116 if (m_counter % 2 == 0) {
117 try {
118 m_highlight = editor.getHighlighter().addHighlight(token.start, token.end, highlightPainter);
119 } catch (BadLocationException ex) {
120 // don't care
121 }
122 } else if (m_highlight != null) {
123 editor.getHighlighter().removeHighlight(m_highlight);
124 }
125
126 if (m_counter++ > 6) {
127 Timer timer = (Timer) event.getSource();
128 timer.stop();
129 }
130 }
131 });
132 timer.start();
133 }
134} 91}