mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 19:42:36 +02:00
GP-9181 - Theming - Base Module
This commit is contained in:
parent
2dade60b3e
commit
4eb3d8fd86
113 changed files with 1092 additions and 1099 deletions
|
@ -71,10 +71,10 @@ public class GThemeDefaults {
|
|||
*/
|
||||
public static class Messages {
|
||||
//@formatter:off
|
||||
public static final GColor NORMAL = new GColor("color.fg.dialog.status.normal");
|
||||
public static final GColor ERROR = new GColor("color.fg.dialog.status.error");
|
||||
public static final GColor HINT = new GColor("color.fg.hint");
|
||||
|
||||
public static final GColor NORMAL = new GColor("color.fg.messages.normal");
|
||||
public static final GColor ERROR = new GColor("color.fg.messages.error");
|
||||
public static final GColor HINT = new GColor("color.fg.messages.hint");
|
||||
public static final GColor WARNING = new GColor("color.fg.messages.warning");
|
||||
//@formatter:on
|
||||
|
||||
}
|
||||
|
@ -98,10 +98,12 @@ public class GThemeDefaults {
|
|||
public static final GColor LIGHT_GRAY = getColor("lightgray");
|
||||
public static final GColor LIME = getColor("lime");
|
||||
public static final GColor MAGENTA = getColor("magenta");
|
||||
public static final GColor MAROON = getColor("maroon");
|
||||
public static final GColor ORANGE = getColor("orange");
|
||||
public static final GColor PINK = getColor("pink");
|
||||
public static final GColor PURPLE = getColor("purple");
|
||||
public static final GColor RED = getColor("red");
|
||||
public static final GColor SILVER = getColor("silver");
|
||||
public static final GColor WHITE = getColor("white");
|
||||
public static final GColor YELLOW = getColor("yellow");
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ import java.util.Objects;
|
|||
import javax.imageio.ImageIO;
|
||||
import javax.swing.*;
|
||||
|
||||
import generic.theme.GThemeDefaults.Colors;
|
||||
import ghidra.util.MathUtilities;
|
||||
import ghidra.util.Msg;
|
||||
|
||||
|
@ -112,7 +113,7 @@ public class ImageUtils {
|
|||
public static BufferedImage createEmptyImage(int width, int height) {
|
||||
BufferedImage newImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
|
||||
Graphics g = newImage.getGraphics();
|
||||
g.setColor(Color.WHITE);
|
||||
g.setColor(Colors.BACKGROUND);
|
||||
g.fillRect(0, 0, width, height);
|
||||
return newImage;
|
||||
}
|
||||
|
|
|
@ -15,12 +15,13 @@
|
|||
*/
|
||||
package ghidra.framework.options;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.beans.PropertyEditorSupport;
|
||||
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JLabel;
|
||||
|
||||
import generic.theme.GThemeDefaults.Colors.Messages;
|
||||
|
||||
public class ErrorPropertyEditor extends PropertyEditorSupport {
|
||||
private JLabel errorLabel;
|
||||
private Object editorValue;
|
||||
|
@ -34,7 +35,7 @@ public class ErrorPropertyEditor extends PropertyEditorSupport {
|
|||
|
||||
// Use native java JLabel because we can't use docking widgets here
|
||||
errorLabel = new JLabel(message);
|
||||
errorLabel.setForeground(Color.RED);
|
||||
errorLabel.setForeground(Messages.ERROR);
|
||||
errorLabel.putClientProperty("html.disable", true);
|
||||
}
|
||||
|
||||
|
|
|
@ -17,97 +17,77 @@ package ghidra.util;
|
|||
|
||||
import java.awt.Color;
|
||||
|
||||
public class SaveableColor extends PrivateSaveable
|
||||
{
|
||||
public class SaveableColor extends PrivateSaveable {
|
||||
private Color color;
|
||||
private Class<?>[] fields = new Class<?>[] {
|
||||
Integer.class, Integer.class, Integer.class
|
||||
Integer.class, Integer.class, Integer.class
|
||||
};
|
||||
|
||||
|
||||
public SaveableColor(Color color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public SaveableColor() {
|
||||
}
|
||||
/**
|
||||
* @see Saveable#restore(ObjectStorage)
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void save(ObjectStorage objStorage) {
|
||||
objStorage.putInt(color.getRed());
|
||||
objStorage.putInt(color.getBlue());
|
||||
objStorage.putInt(color.getGreen());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class<?>[] getObjectStorageFields() {
|
||||
return fields;
|
||||
return fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Saveable#save(ObjectStorage)
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void restore(ObjectStorage objStorage) {
|
||||
int red = objStorage.getInt();
|
||||
int blue = objStorage.getInt();
|
||||
int green = objStorage.getInt();
|
||||
color = new Color(red,green,blue);
|
||||
color = new Color(red, green, blue);
|
||||
}
|
||||
|
||||
public Color getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.util.Saveable#getSchemaVersion()
|
||||
*/
|
||||
|
||||
@Override
|
||||
public int getSchemaVersion() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.util.Saveable#isUpgradeable(int)
|
||||
*/
|
||||
@Override
|
||||
public boolean isUpgradeable(int oldSchemaVersion) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.util.Saveable#upgrade(ghidra.util.ObjectStorage, int, ghidra.util.ObjectStorage)
|
||||
*/
|
||||
@Override
|
||||
public boolean upgrade(ObjectStorage oldObjStorage, int oldSchemaVersion, ObjectStorage currentObjStorage) {
|
||||
public boolean upgrade(ObjectStorage oldObjStorage, int oldSchemaVersion,
|
||||
ObjectStorage currentObjStorage) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
*/
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null || getClass() != obj.getClass() ) {
|
||||
if (obj == null || getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
return color.equals(((SaveableColor)obj).color);
|
||||
return color.getRGB() == ((SaveableColor) obj).color.getRGB();
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#hashCode()
|
||||
*/
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
public int hashCode() {
|
||||
return color.hashCode();
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
public String toString() {
|
||||
return color.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -144,7 +144,7 @@ public class GGlassPane extends JComponent {
|
|||
// Rectangle bounds = getBounds();
|
||||
// Graphics2D g2 = (Graphics2D) g;
|
||||
// g2.setComposite( AlphaComposite.getInstance( AlphaComposite.SrcOver.getRule(), 0.5f ) );
|
||||
// g2.setColor( Color.BLUE );
|
||||
// g2.setColor( Palette.BLUE );
|
||||
// g2.fill( bounds );
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,8 @@ import java.util.Objects;
|
|||
|
||||
import javax.swing.Icon;
|
||||
|
||||
import generic.theme.TempColorUtils;
|
||||
|
||||
/**
|
||||
* Icon class for for displaying overlapping icons. Icons are drawn in the order they
|
||||
* are added.
|
||||
|
@ -146,7 +148,7 @@ public class MultiIcon implements Icon {
|
|||
if (disabled) {
|
||||
// Alpha blend to background
|
||||
Color bgColor = c.getBackground();
|
||||
g.setColor(new Color(bgColor.getRed(), bgColor.getGreen(), bgColor.getBlue(), 128));
|
||||
g.setColor(TempColorUtils.withAlpha(bgColor, 128));
|
||||
g.fillRect(x, y, width, height);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,8 +15,7 @@
|
|||
*/
|
||||
package generic.constraint;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.io.ByteArrayInputStream;
|
||||
|
@ -29,6 +28,7 @@ import org.junit.Test;
|
|||
|
||||
import generic.constraint.DecisionNode.PropertyValue;
|
||||
import generic.test.AbstractGenericTest;
|
||||
import generic.theme.GThemeDefaults.Colors.Palette;
|
||||
|
||||
public class DecisionTreeTest extends AbstractGenericTest {
|
||||
|
||||
|
@ -89,7 +89,7 @@ public class DecisionTreeTest extends AbstractGenericTest {
|
|||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
decisionTree = new DecisionTree<Color>();
|
||||
decisionTree = new DecisionTree<>();
|
||||
decisionTree.registerConstraintType("BLUE", BlueColorConstraint.class);
|
||||
decisionTree.registerConstraintType("GREEN", GreenColorConstraint.class);
|
||||
decisionTree.registerConstraintType("RED", RedColorConstraint.class);
|
||||
|
@ -134,7 +134,7 @@ public class DecisionTreeTest extends AbstractGenericTest {
|
|||
|
||||
@Test
|
||||
public void testMatchFromFirstXML() {
|
||||
Color c = Color.WHITE;
|
||||
Color c = Palette.WHITE;
|
||||
DecisionSet decisionSet = decisionTree.getDecisionsSet(c, "NAME");
|
||||
List<Decision> decisions = decisionSet.getDecisions();
|
||||
assertEquals(1, decisions.size());
|
||||
|
@ -147,7 +147,7 @@ public class DecisionTreeTest extends AbstractGenericTest {
|
|||
|
||||
@Test
|
||||
public void testMatchFromAdditionalXML() {
|
||||
Color c = new Color(255, 0, 255);
|
||||
Color c = Palette.MAGENTA;
|
||||
DecisionSet decisionSet = decisionTree.getDecisionsSet(c, "NAME");
|
||||
List<Decision> decisions = decisionSet.getDecisions();
|
||||
assertEquals(1, decisions.size());
|
||||
|
@ -160,7 +160,7 @@ public class DecisionTreeTest extends AbstractGenericTest {
|
|||
|
||||
@Test
|
||||
public void testMatchMultiple() {
|
||||
Color c = new Color(255, 255, 0);
|
||||
Color c = Palette.YELLOW;
|
||||
DecisionSet decisionSet = decisionTree.getDecisionsSet(c, "NAME");
|
||||
List<Decision> decisions = decisionSet.getDecisions();
|
||||
assertEquals(2, decisions.size());
|
||||
|
@ -179,7 +179,7 @@ public class DecisionTreeTest extends AbstractGenericTest {
|
|||
|
||||
@Test
|
||||
public void testNoMatchUsingDefault() {
|
||||
Color c = new Color(100, 100, 100);
|
||||
Color c = Palette.GRAY;
|
||||
DecisionSet decisionSet = decisionTree.getDecisionsSet(c, "NAME");
|
||||
List<Decision> decisions = decisionSet.getDecisions();
|
||||
assertEquals(1, decisions.size());
|
||||
|
|
|
@ -18,11 +18,11 @@ package ghidra.util;
|
|||
import static ghidra.util.HTMLUtilities.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import generic.theme.GThemeDefaults.Colors.Palette;
|
||||
|
||||
public class HTMLUtilitiesTest {
|
||||
|
||||
private SpyErrorLogger spyLogger = new SpyErrorLogger();
|
||||
|
@ -128,13 +128,13 @@ public class HTMLUtilitiesTest {
|
|||
|
||||
@Test
|
||||
public void testToRGBString() {
|
||||
String rgb = HTMLUtilities.toRGBString(Color.RED);
|
||||
String rgb = HTMLUtilities.toRGBString(Palette.RED);
|
||||
assertEquals("255000000", rgb);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testToHexString() {
|
||||
String rgb = HTMLUtilities.toHexString(Color.RED);
|
||||
String rgb = HTMLUtilities.toHexString(Palette.RED);
|
||||
assertEquals("#FF0000", rgb);
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ import javax.swing.JOptionPane;
|
|||
|
||||
import org.junit.Test;
|
||||
|
||||
import generic.theme.GThemeDefaults.Colors.Palette;
|
||||
import resources.MultiIconBuilder;
|
||||
import resources.QUADRANT;
|
||||
|
||||
|
@ -62,8 +63,8 @@ public class MultiIconBuilderTest {
|
|||
public void showIconText() {
|
||||
for (QUADRANT quad : QUADRANT.values()) {
|
||||
ImageIcon icon =
|
||||
new MultiIconBuilder(makeQuandrantIcon(32, 32, Color.gray, Color.white))
|
||||
.addText("Abcfg", font, Color.red, quad)
|
||||
new MultiIconBuilder(makeQuandrantIcon(32, 32, Palette.GRAY, Palette.WHITE))
|
||||
.addText("Abcfg", font, Palette.RED, quad)
|
||||
.build();
|
||||
JOptionPane.showMessageDialog(null, "" + quad + " aligned", "Icon text overlay test",
|
||||
JOptionPane.OK_OPTION, icon);
|
||||
|
@ -73,8 +74,8 @@ public class MultiIconBuilderTest {
|
|||
//@Test
|
||||
public void showIconOverlay() {
|
||||
for (QUADRANT quad : QUADRANT.values()) {
|
||||
ImageIcon icon = new MultiIconBuilder(makeEmptyIcon(32, 32, Color.gray))
|
||||
.addIcon(makeEmptyIcon(8, 8, Color.red), 8, 8, quad)
|
||||
ImageIcon icon = new MultiIconBuilder(makeEmptyIcon(32, 32, Palette.GRAY))
|
||||
.addIcon(makeEmptyIcon(8, 8, Palette.RED), 8, 8, quad)
|
||||
.build();
|
||||
JOptionPane.showMessageDialog(null, "" + quad + " aligned", "Icon_icon overlay test",
|
||||
JOptionPane.OK_OPTION, icon);
|
||||
|
@ -84,8 +85,8 @@ public class MultiIconBuilderTest {
|
|||
//@Test
|
||||
public void showScaledIconOverlay() {
|
||||
for (QUADRANT quad : QUADRANT.values()) {
|
||||
ImageIcon icon = new MultiIconBuilder(makeEmptyIcon(32, 32, Color.gray))
|
||||
.addIcon(makeQuandrantIcon(32, 32, Color.red, Color.black), 14, 14, quad)
|
||||
ImageIcon icon = new MultiIconBuilder(makeEmptyIcon(32, 32, Palette.GRAY))
|
||||
.addIcon(makeQuandrantIcon(32, 32, Palette.RED, Palette.BLACK), 14, 14, quad)
|
||||
.build();
|
||||
JOptionPane.showMessageDialog(null, "" + quad + " aligned",
|
||||
"Scaled icon_icon overlay test",
|
||||
|
@ -97,8 +98,8 @@ public class MultiIconBuilderTest {
|
|||
public void testIconOverlay() {
|
||||
// doesn't verify anything other than it doesn't fall down go boom
|
||||
for (QUADRANT quad : QUADRANT.values()) {
|
||||
ImageIcon icon = new MultiIconBuilder(makeEmptyIcon(32, 32, Color.gray))
|
||||
.addIcon(makeQuandrantIcon(32, 32, Color.red, Color.black), 14, 14, quad)
|
||||
ImageIcon icon = new MultiIconBuilder(makeEmptyIcon(32, 32, Palette.GRAY))
|
||||
.addIcon(makeQuandrantIcon(32, 32, Palette.RED, Palette.BLACK), 14, 14, quad)
|
||||
.build();
|
||||
icon.getDescription();
|
||||
}
|
||||
|
@ -109,8 +110,8 @@ public class MultiIconBuilderTest {
|
|||
// doesn't verify anything other than it doesn't fall down go boom
|
||||
for (QUADRANT quad : QUADRANT.values()) {
|
||||
ImageIcon icon =
|
||||
new MultiIconBuilder(makeQuandrantIcon(32, 32, Color.gray, Color.white))
|
||||
.addText("Abcfg", font, Color.red, quad)
|
||||
new MultiIconBuilder(makeQuandrantIcon(32, 32, Palette.GRAY, Palette.WHITE))
|
||||
.addText("Abcfg", font, Palette.RED, quad)
|
||||
.build();
|
||||
icon.getDescription();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue