summaryrefslogtreecommitdiff
path: root/src/main/java/cuchaz/enigma/gui/highlight
diff options
context:
space:
mode:
authorGravatar asie2018-12-08 11:21:18 +0100
committerGravatar asie2018-12-08 11:21:18 +0100
commit4bc3afe4ff08b9f0c08952ec7f6e0ac930280cc5 (patch)
tree99e43aa385d7fa1248c7fe474c022db55c364592 /src/main/java/cuchaz/enigma/gui/highlight
parentwork around Procyon weirdness (diff)
downloadenigma-fork-4bc3afe4ff08b9f0c08952ec7f6e0ac930280cc5.tar.gz
enigma-fork-4bc3afe4ff08b9f0c08952ec7f6e0ac930280cc5.tar.xz
enigma-fork-4bc3afe4ff08b9f0c08952ec7f6e0ac930280cc5.zip
add barebones plugin framework, cleanup
Diffstat (limited to 'src/main/java/cuchaz/enigma/gui/highlight')
-rw-r--r--src/main/java/cuchaz/enigma/gui/highlight/BoxHighlightPainter.java13
-rw-r--r--src/main/java/cuchaz/enigma/gui/highlight/DeobfuscatedHighlightPainter.java21
-rw-r--r--src/main/java/cuchaz/enigma/gui/highlight/ObfuscatedHighlightPainter.java21
-rw-r--r--src/main/java/cuchaz/enigma/gui/highlight/OtherHighlightPainter.java21
4 files changed, 7 insertions, 69 deletions
diff --git a/src/main/java/cuchaz/enigma/gui/highlight/BoxHighlightPainter.java b/src/main/java/cuchaz/enigma/gui/highlight/BoxHighlightPainter.java
index 976c215..10366ce 100644
--- a/src/main/java/cuchaz/enigma/gui/highlight/BoxHighlightPainter.java
+++ b/src/main/java/cuchaz/enigma/gui/highlight/BoxHighlightPainter.java
@@ -11,13 +11,14 @@
11 11
12package cuchaz.enigma.gui.highlight; 12package cuchaz.enigma.gui.highlight;
13 13
14import cuchaz.enigma.config.Config;
15
14import javax.swing.text.BadLocationException; 16import javax.swing.text.BadLocationException;
15import javax.swing.text.Highlighter; 17import javax.swing.text.Highlighter;
16import javax.swing.text.JTextComponent; 18import javax.swing.text.JTextComponent;
17import java.awt.*; 19import java.awt.*;
18 20
19public abstract class BoxHighlightPainter implements Highlighter.HighlightPainter { 21public class BoxHighlightPainter implements Highlighter.HighlightPainter {
20
21 private Color fillColor; 22 private Color fillColor;
22 private Color borderColor; 23 private Color borderColor;
23 24
@@ -26,6 +27,10 @@ public abstract class BoxHighlightPainter implements Highlighter.HighlightPainte
26 this.borderColor = borderColor; 27 this.borderColor = borderColor;
27 } 28 }
28 29
30 public static BoxHighlightPainter create(Config.AlphaColorEntry entry, Config.AlphaColorEntry entryOutline) {
31 return new BoxHighlightPainter(entry != null ? entry.get() : null, entryOutline != null ? entryOutline.get() : null);
32 }
33
29 public static Rectangle getBounds(JTextComponent text, int start, int end) { 34 public static Rectangle getBounds(JTextComponent text, int start, int end) {
30 try { 35 try {
31 // determine the bounds of the text 36 // determine the bounds of the text
@@ -59,8 +64,4 @@ public abstract class BoxHighlightPainter implements Highlighter.HighlightPainte
59 g.drawRoundRect(bounds.x, bounds.y, bounds.width, bounds.height, 4, 4); 64 g.drawRoundRect(bounds.x, bounds.y, bounds.width, bounds.height, 4, 4);
60 } 65 }
61 66
62 protected static Color getColor(int rgb, float alpha){
63 Color baseColor = new Color(rgb);
64 return new Color(baseColor.getRed(), baseColor.getGreen(), baseColor.getBlue(), (int)(255 * alpha));
65 }
66} 67}
diff --git a/src/main/java/cuchaz/enigma/gui/highlight/DeobfuscatedHighlightPainter.java b/src/main/java/cuchaz/enigma/gui/highlight/DeobfuscatedHighlightPainter.java
deleted file mode 100644
index 41aa97f..0000000
--- a/src/main/java/cuchaz/enigma/gui/highlight/DeobfuscatedHighlightPainter.java
+++ /dev/null
@@ -1,21 +0,0 @@
1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html
7 * <p>
8 * Contributors:
9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/
11
12package cuchaz.enigma.gui.highlight;
13
14import cuchaz.enigma.config.Config;
15
16public class DeobfuscatedHighlightPainter extends BoxHighlightPainter {
17
18 public DeobfuscatedHighlightPainter() {
19 super(getColor(Config.getInstance().deobfuscatedColor, Config.getInstance().deobfuscatedHiglightAlpha), getColor(Config.getInstance().deobfuscatedColorOutline, Config.getInstance().deobfuscatedOutlineAlpha));
20 }
21}
diff --git a/src/main/java/cuchaz/enigma/gui/highlight/ObfuscatedHighlightPainter.java b/src/main/java/cuchaz/enigma/gui/highlight/ObfuscatedHighlightPainter.java
deleted file mode 100644
index d735874..0000000
--- a/src/main/java/cuchaz/enigma/gui/highlight/ObfuscatedHighlightPainter.java
+++ /dev/null
@@ -1,21 +0,0 @@
1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html
7 * <p>
8 * Contributors:
9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/
11
12package cuchaz.enigma.gui.highlight;
13
14import cuchaz.enigma.config.Config;
15
16public class ObfuscatedHighlightPainter extends BoxHighlightPainter {
17
18 public ObfuscatedHighlightPainter() {
19 super(getColor(Config.getInstance().obfuscatedColor, Config.getInstance().obfuscatedHiglightAlpha), getColor(Config.getInstance().obfuscatedColorOutline, Config.getInstance().obfuscatedOutlineAlpha));
20 }
21}
diff --git a/src/main/java/cuchaz/enigma/gui/highlight/OtherHighlightPainter.java b/src/main/java/cuchaz/enigma/gui/highlight/OtherHighlightPainter.java
deleted file mode 100644
index f4ae235..0000000
--- a/src/main/java/cuchaz/enigma/gui/highlight/OtherHighlightPainter.java
+++ /dev/null
@@ -1,21 +0,0 @@
1/*******************************************************************************
2 * Copyright (c) 2015 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser General Public
5 * License v3.0 which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html
7 * <p>
8 * Contributors:
9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/
11
12package cuchaz.enigma.gui.highlight;
13
14import cuchaz.enigma.config.Config;
15
16public class OtherHighlightPainter extends BoxHighlightPainter {
17
18 public OtherHighlightPainter() {
19 super(null, getColor(Config.getInstance().otherColorOutline, Config.getInstance().otherOutlineAlpha));
20 }
21}