mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 10:49:34 +02:00
GP-1981 Review fixes
This commit is contained in:
parent
9679752523
commit
a92a27e9f1
90 changed files with 375 additions and 381 deletions
|
@ -10,3 +10,4 @@ MODULE FILE LICENSE: lib/gson-2.9.0.jar Apache License 2.0
|
|||
MODULE FILE LICENSE: lib/bcpkix-jdk15on-1.69.jar Bouncy Castle License
|
||||
MODULE FILE LICENSE: lib/bcprov-jdk15on-1.69.jar Bouncy Castle License
|
||||
MODULE FILE LICENSE: lib/bcutil-jdk15on-1.69.jar Bouncy Castle License
|
||||
MODULE FILE LICENSE: lib/flatlaf-2.6.jar Apache License 2.0
|
||||
|
|
|
@ -38,7 +38,7 @@ dependencies {
|
|||
api 'org.bouncycastle:bcpkix-jdk15on:1.69' // requires bcutil and bcprov
|
||||
api 'org.bouncycastle:bcprov-jdk15on:1.69'
|
||||
api 'org.bouncycastle:bcutil-jdk15on:1.69'
|
||||
api 'com.formdev:flatlaf:2.2'
|
||||
api 'com.formdev:flatlaf:2.6'
|
||||
|
||||
|
||||
compileOnly "junit:junit:4.12"
|
||||
|
|
|
@ -291,7 +291,7 @@ public abstract class AbstractThemeReader {
|
|||
error(lineNumber, "Missing key for propery line: \"" + line + "\"");
|
||||
return;
|
||||
}
|
||||
if (key.isBlank()) {
|
||||
if (value.isBlank()) {
|
||||
error(lineNumber, "Missing value for propery line: \"" + line + "\"");
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -104,7 +104,8 @@ public class ColorValue extends ThemeValue<Color> {
|
|||
|
||||
Msg.error(this,
|
||||
"Could not resolve indirect color path for \"" + unresolvedId +
|
||||
"\" for primary id \"" + id + "\", using last resort default");
|
||||
"\" for primary id \"" + id + "\", using last resort default",
|
||||
t);
|
||||
return LAST_RESORT_DEFAULT;
|
||||
}
|
||||
|
||||
|
@ -149,7 +150,7 @@ public class ColorValue extends ThemeValue<Color> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void makeCurrentValue() {
|
||||
public void installValue() {
|
||||
Gui.setColor(this);
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@ package generic.theme;
|
|||
import java.awt.Font;
|
||||
import java.text.ParseException;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* Class that can transform one font into another. For example if want a font that is the same
|
||||
|
@ -26,8 +25,6 @@ import java.util.regex.Pattern;
|
|||
* FontModifier
|
||||
*/
|
||||
public class FontModifier {
|
||||
|
||||
private static final Pattern MODIFIER_PATTERN = Pattern.compile("(\\[([a-zA-Z]+|[0-9]+)\\])*");
|
||||
private String family;
|
||||
private Integer style;
|
||||
private Integer size;
|
||||
|
|
|
@ -121,6 +121,11 @@ public class FontValue extends ThemeValue<Font> {
|
|||
return font == null ? null : new FontValue(id, font);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Font style int for the given style string
|
||||
* @param styleString the string to convert to a Font style int
|
||||
* @return the Font style int for the given style string
|
||||
*/
|
||||
public static int getStyle(String styleString) {
|
||||
if ("plain".equalsIgnoreCase(styleString)) {
|
||||
return Font.PLAIN;
|
||||
|
@ -227,7 +232,7 @@ public class FontValue extends ThemeValue<Font> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void makeCurrentValue() {
|
||||
public void installValue() {
|
||||
Gui.setFont(this);
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ import ghidra.util.datastruct.WeakStore;
|
|||
* color table that is determined by the active {@link GTheme}.
|
||||
* <P>The idea is for developers to
|
||||
* not use specific colors in their code, but to instead use a GColor with an id that hints at
|
||||
* its use. For example, instead of harding code a component's background color to white by coding
|
||||
* its use. For example, instead of hard coding a component's background color to white by coding
|
||||
* "component.setBackground(Color.white)", you would do something like
|
||||
* "component.setBackground(new GColor("color.mywidget.bg"). Then in a
|
||||
* "[module name].theme.properties" file (located in the module's data directory), you would
|
||||
|
@ -127,6 +127,11 @@ public class GColor extends Color {
|
|||
return delegate.darker();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this GColor could not find a value for its color id in the current theme
|
||||
* and is using the default color as its delegate
|
||||
* @return true if this GColor could not find a value for its color id in the current theme
|
||||
*/
|
||||
public boolean isUnresolved() {
|
||||
return delegate == ColorValue.LAST_RESORT_DEFAULT;
|
||||
}
|
||||
|
@ -144,20 +149,17 @@ public class GColor extends Color {
|
|||
return WebColors.toString(this, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a more verbose toString()
|
||||
* @return a more verbose toString()
|
||||
*/
|
||||
public String toDebugString() {
|
||||
Color c = delegate;
|
||||
String rgb =
|
||||
"(" + c.getRed() + "," + c.getGreen() + "," + c.getBlue() + "," + c.getAlpha() + ")";
|
||||
String hexrgb = "(" + WebColors.toString(c, true) + ")";
|
||||
return getClass().getSimpleName() + " [id = " + id + ", color = " +
|
||||
c.getClass().getSimpleName() + rgb + "]";
|
||||
}
|
||||
|
||||
public String toDebugHexString() {
|
||||
Color c = delegate;
|
||||
String rgb =
|
||||
"(" + WebColors.toString(c, true) + ")";
|
||||
return getClass().getSimpleName() + " [id = " + id + ", color = " +
|
||||
c.getClass().getSimpleName() + rgb + "]";
|
||||
c.getClass().getSimpleName() + rgb + hexrgb + "]";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -31,8 +31,8 @@ import resources.icons.*;
|
|||
* icon table that is determined by the active {@link GTheme}.
|
||||
* <P> The idea is for developers to
|
||||
* not use specific icons in their code, but to instead use a GIcon with an id that hints at
|
||||
* its use. For example, instead of harding code a label's icon by coding
|
||||
* "lable.setIcon(ResourceManager.loadImage("images/refresh.png", you would do something like
|
||||
* its use. For example, instead of hard coding a label's icon by coding
|
||||
* "label.setIcon(ResourceManager.loadImage("images/refresh.png", you would do something like
|
||||
* label.setIcon(new GIcon("icon.refresh"). Then in a "[module name].theme.properties" file
|
||||
* (located in the module's data directory), you would set the default value by adding this
|
||||
* line "icon.refresh = images/refresh.png".
|
||||
|
|
|
@ -41,7 +41,7 @@ public class GTheme extends GThemeValueMap {
|
|||
private final File file;
|
||||
|
||||
/**
|
||||
* Creates an new GTheme with the given name, the default {@link LookAndFeel} for the the
|
||||
* Creates a new GTheme with the given name, the default {@link LookAndFeel} for the the
|
||||
* platform and not using dark defaults. This theme will be using all the standard defaults
|
||||
* from the theme.property files and the defaults from the default LookAndFeel.
|
||||
* @param name the name for this GTheme
|
||||
|
|
|
@ -32,6 +32,14 @@ public class GThemeDefaults {
|
|||
public static class Java {
|
||||
public static final String BORDER = "system.color.border"; // TODO
|
||||
}
|
||||
|
||||
public static class Fonts {
|
||||
public static final String STANDARD = "font.standard";
|
||||
public static final String BOLD = "font.bold";
|
||||
public static final String ITALIC = "font.italic";
|
||||
public static final String BOLD_ITALIC = "font.bold.italic";
|
||||
public static final String MONOSPACED = "font.monospaced";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -125,12 +133,4 @@ public class GThemeDefaults {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class Fonts {
|
||||
public static final String STANDARD = "font.standard";
|
||||
public static final String BOLD = "font.bold";
|
||||
public static final String ITALIC = "font.italic";
|
||||
public static final String BOLD_ITALIC = "font.bold.italic";
|
||||
public static final String MONOSPACED = "font.monospaced";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,8 @@ import java.util.List;
|
|||
import javax.swing.*;
|
||||
import javax.swing.plaf.ComponentUI;
|
||||
|
||||
import com.formdev.flatlaf.*;
|
||||
import com.formdev.flatlaf.FlatDarkLaf;
|
||||
import com.formdev.flatlaf.FlatLightLaf;
|
||||
|
||||
import generic.theme.builtin.*;
|
||||
import generic.theme.laf.LookAndFeelManager;
|
||||
|
@ -92,7 +93,6 @@ public class Gui {
|
|||
installFlatLookAndFeels();
|
||||
loadThemeDefaults();
|
||||
setTheme(themePreferenceManager.getTheme());
|
||||
// LookAndFeelUtils.installGlobalOverrides();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -489,6 +489,7 @@ public class Gui {
|
|||
return gIcon;
|
||||
}
|
||||
|
||||
// used by
|
||||
public static void setSystemDefaults(GThemeValueMap map) {
|
||||
systemValues = map;
|
||||
}
|
||||
|
@ -730,8 +731,6 @@ public class Gui {
|
|||
private static void installFlatLookAndFeels() {
|
||||
UIManager.installLookAndFeel(LafType.FLAT_LIGHT.getName(), FlatLightLaf.class.getName());
|
||||
UIManager.installLookAndFeel(LafType.FLAT_DARK.getName(), FlatDarkLaf.class.getName());
|
||||
UIManager.installLookAndFeel(LafType.FLAT_DARCULA.getName(),
|
||||
FlatDarculaLaf.class.getName());
|
||||
}
|
||||
|
||||
private static void loadThemeDefaults() {
|
||||
|
|
|
@ -247,7 +247,7 @@ public class IconValue extends ThemeValue<Icon> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void makeCurrentValue() {
|
||||
public void installValue() {
|
||||
Gui.setIcon(this);
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,6 @@ public enum LafType {
|
|||
MOTIF("CDE/Motif"),
|
||||
FLAT_LIGHT("Flat Light"),
|
||||
FLAT_DARK("Flat Dark"),
|
||||
FLAT_DARCULA("Flat Darcula"),
|
||||
WINDOWS("Windows"),
|
||||
WINDOWS_CLASSIC("Windows Classic"),
|
||||
MAC("Mac OS X");
|
||||
|
@ -109,7 +108,6 @@ public enum LafType {
|
|||
return new MotifLookAndFeelManager();
|
||||
case NIMBUS:
|
||||
return new NimbusLookAndFeelManager();
|
||||
case FLAT_DARCULA:
|
||||
case FLAT_DARK:
|
||||
case FLAT_LIGHT:
|
||||
return new FlatLookAndFeelManager(lookAndFeel);
|
||||
|
|
|
@ -52,7 +52,7 @@ public class ThemeFileLoader {
|
|||
}
|
||||
catch (IOException e) {
|
||||
Msg.error(this,
|
||||
"Error reading theme properties file: " + resourceFile.getAbsolutePath());
|
||||
"Error reading theme properties file: " + resourceFile.getAbsolutePath(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ public class ThemePreferenceManager {
|
|||
}
|
||||
catch (Exception e) {
|
||||
Msg.showError(GTheme.class, null, "Can't Load Previous Theme",
|
||||
"Can't find or instantiate class: " + className);
|
||||
"Can't find or instantiate class: " + className, e);
|
||||
}
|
||||
}
|
||||
return Gui.getDefaultTheme();
|
||||
|
|
|
@ -207,8 +207,8 @@ public abstract class ThemeValue<T> implements Comparable<ThemeValue<T>> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Makes this value the current value for the application
|
||||
* Install this value as the current value for the application
|
||||
*/
|
||||
public abstract void makeCurrentValue();
|
||||
public abstract void installValue();
|
||||
|
||||
}
|
||||
|
|
|
@ -24,37 +24,35 @@ public class FlatThemeGrouper extends ThemeGrouper {
|
|||
|
||||
@Override
|
||||
public void group(GThemeValueMap values) {
|
||||
// we made up a source property for a common Flat color. Picked one of them as
|
||||
// an exemplar (menu.foreground)
|
||||
// @formatter:off
|
||||
defineCustomColorGroup(values, "color.flat.menu.hover.bg", "MenuBar.hoverBackground");
|
||||
defineCustomColorGroup(values, "color.flat.button.hover.bg", "Button.hoverBackground");
|
||||
defineCustomColorGroup(values, "color.flat.button.selected.bg","Button.selectedBackground");
|
||||
defineCustomColorGroup(values, "color.flat.button.toolbar.hover.bg","Button.toolbar.hoverBackground");
|
||||
defineCustomColorGroup(values, "color.flat.button.toolbar.pressed.bg","Button.toolbar.pressedBackground");
|
||||
defineCustomColorGroup(values, "color.flat.checkbox.icon.focus.border","CheckBox.icon.focusedBorderColor");
|
||||
defineCustomColorGroup(values, "color.flat.menu.accelerator.fg","Menu.acceleratorForeground");
|
||||
defineCustomColorGroup("color.flat.menu.hover.bg", "MenuBar.hoverBackground", values);
|
||||
defineCustomColorGroup("color.flat.button.hover.bg", "Button.hoverBackground", values);
|
||||
defineCustomColorGroup("color.flat.button.selected.bg", "Button.selectedBackground",values);
|
||||
defineCustomColorGroup("color.flat.button.toolbar.hover.bg", "Button.toolbar.hoverBackground",values);
|
||||
defineCustomColorGroup("color.flat.button.toolbar.pressed.bg", "Button.toolbar.pressedBackground",values);
|
||||
defineCustomColorGroup("color.flat.checkbox.icon.focus.border", "CheckBox.icon.focusedBorderColor",values);
|
||||
defineCustomColorGroup("color.flat.menu.accelerator.fg", "Menu.acceleratorForeground",values);
|
||||
|
||||
|
||||
defineCustomColorGroup(values, "color.flat.focus.border", "Button.focusedBorderColor");
|
||||
defineCustomColorGroup(values, "color.flat.focus", "Component.focusColor");
|
||||
defineCustomColorGroup(values, "color.flat.focus.bg", "Button.focusedBackground");
|
||||
defineCustomColorGroup(values, "color.flat.checkmark", "CheckBox.icon.checkmarkColor");
|
||||
defineCustomColorGroup(values, "color.flat.disabled", "Button.disabledBorderColor");
|
||||
defineCustomColorGroup(values, "color.flat.disabled.selected","Button.disabledSelectedBackground");
|
||||
defineCustomColorGroup(values, "color.flat.arrow","Spinner.buttonArrowColor");
|
||||
defineCustomColorGroup(values, "color.flat.arrow.disabled","Spinner.buttonDisabledArrowColor");
|
||||
defineCustomColorGroup(values, "color.flat.arrow.hover","Spinner.buttonHoverArrowColor");
|
||||
defineCustomColorGroup(values, "color.flat.arrow.pressed","Spinner.buttonPressedArrowColor");
|
||||
defineCustomColorGroup("color.flat.focus.border", "Button.focusedBorderColor", values);
|
||||
defineCustomColorGroup("color.flat.focus", "Component.focusColor", values);
|
||||
defineCustomColorGroup("color.flat.focus.bg", "Button.focusedBackground", values);
|
||||
defineCustomColorGroup("color.flat.checkmark", "CheckBox.icon.checkmarkColor", values);
|
||||
defineCustomColorGroup("color.flat.disabled", "Button.disabledBorderColor", values);
|
||||
defineCustomColorGroup("color.flat.disabled.selected", "Button.disabledSelectedBackground",values);
|
||||
defineCustomColorGroup("color.flat.arrow", "Spinner.buttonArrowColor",values);
|
||||
defineCustomColorGroup("color.flat.arrow.disabled", "Spinner.buttonDisabledArrowColor",values);
|
||||
defineCustomColorGroup("color.flat.arrow.hover", "Spinner.buttonHoverArrowColor",values);
|
||||
defineCustomColorGroup("color.flat.arrow.pressed", "Spinner.buttonPressedArrowColor",values);
|
||||
|
||||
defineCustomColorGroup(values, "color.flat.dropcell.bg","List.dropCellBackground");
|
||||
defineCustomColorGroup(values, "color.flat.dropline","List.dropLineColor");
|
||||
defineCustomColorGroup(values, "color.flat.underline","MenuItem.underlineSelectionColor");
|
||||
defineCustomColorGroup(values, "color.flat.docking.bg","ToolBar.dockingBackground");
|
||||
defineCustomColorGroup(values, "color.flat.progressbar.bg","ProgressBar.background");
|
||||
defineCustomColorGroup(values, "color.flat.progressbar.fg","ProgressBar.foreground");
|
||||
defineCustomColorGroup(values, "color.flat.icon.bg","Tree.icon.openColor");
|
||||
defineCustomColorGroup(values, "color.flat.selection.inactive","Tree.selectionInactiveBackground");
|
||||
defineCustomColorGroup("color.flat.dropcell.bg", "List.dropCellBackground",values);
|
||||
defineCustomColorGroup("color.flat.dropline", "List.dropLineColor",values);
|
||||
defineCustomColorGroup("color.flat.underline", "MenuItem.underlineSelectionColor",values);
|
||||
defineCustomColorGroup("color.flat.docking.bg", "ToolBar.dockingBackground",values);
|
||||
defineCustomColorGroup("color.flat.progressbar.bg", "ProgressBar.background",values);
|
||||
defineCustomColorGroup("color.flat.progressbar.fg", "ProgressBar.foreground",values);
|
||||
defineCustomColorGroup("color.flat.icon.bg", "Tree.icon.openColor",values);
|
||||
defineCustomColorGroup("color.flat.selection.inactive", "Tree.selectionInactiveBackground",values);
|
||||
|
||||
|
||||
// @formatter:on
|
||||
|
|
|
@ -39,7 +39,7 @@ public abstract class LookAndFeelManager {
|
|||
/**
|
||||
* These are color ids (see {@link GColor} used to represent general concepts that
|
||||
* application developers can use to get the color for that concept as defined by
|
||||
* a specific {@link LookAndFeel}. This class will define some standard defaults
|
||||
* a specific {@link LookAndFeel}. This class will define some standard default
|
||||
* mappings in the constructor, but it is expected that each specific LookAndFeelManager
|
||||
* will override these mappings with values appropriate for that LookAndFeel.
|
||||
*/
|
||||
|
|
|
@ -25,12 +25,12 @@ public class MacThemeGrouper extends ThemeGrouper {
|
|||
@Override
|
||||
public void group(GThemeValueMap values) {
|
||||
// @formatter:off
|
||||
defineCustomColorGroup(values, "color.mac.disabled.fg", "Menu.disabledForeground");
|
||||
defineCustomColorGroup(values, "color.mac.button.select", "Button.select");
|
||||
defineCustomColorGroup(values, "color.mac.menu.select","Menu.selectionBackground");
|
||||
defineCustomColorGroup(values, "color.mac.seletion.inactive.bg","List.selectionInactiveBackground");//d4d4d4
|
||||
defineCustomColorGroup("color.mac.disabled.fg", "Menu.disabledForeground", values);
|
||||
defineCustomColorGroup("color.mac.button.select", "Button.select", values);
|
||||
defineCustomColorGroup("color.mac.menu.select", "Menu.selectionBackground",values);
|
||||
defineCustomColorGroup("color.mac.seletion.inactive.bg", "List.selectionInactiveBackground",values);//d4d4d4
|
||||
|
||||
defineCustomFontGroup(values, "font.mac.smallFont", "IconButton.font");
|
||||
defineCustomFontGroup("font.mac.small.font", "IconButton.font", values);
|
||||
// @formatter:on
|
||||
super.group(values);
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ public class MotifThemeGrouper extends ThemeGrouper {
|
|||
|
||||
@Override
|
||||
public void group(GThemeValueMap values) {
|
||||
defineCustomFontGroup(values, "font.monospaced", "Spinner.font");
|
||||
defineCustomFontGroup("font.monospaced", "Spinner.font", values);
|
||||
|
||||
super.group(values);
|
||||
}
|
||||
|
|
|
@ -34,8 +34,8 @@ public class NimbusThemeGrouper extends ThemeGrouper {
|
|||
|
||||
@Override
|
||||
public void group(GThemeValueMap values) {
|
||||
defineCustomColorGroup(values, "color.nimbus.text.alt", "Menu.foreground");
|
||||
defineCustomFontGroup(values, "font.titledborder", "TitledBorder.font");
|
||||
defineCustomColorGroup("color.nimbus.text.alt", "Menu.foreground", values);
|
||||
defineCustomFontGroup("font.titledborder", "TitledBorder.font", values);
|
||||
|
||||
super.group(values);
|
||||
}
|
||||
|
|
|
@ -31,12 +31,17 @@ import generic.theme.*;
|
|||
* organize the properties internally and this class attempts to restore that organization
|
||||
* as much as possible by using the values defined in the {@link BasicLookAndFeel} such as
|
||||
* "control", "window", "controlShadlow", etc. The fonts don't appear to have any such internal
|
||||
* organization, so we created our own groups and used an exemplar property to initialize each
|
||||
* group source value. Then whenever the font matched a group source value, the color is replace
|
||||
* with an indirect reference to the group source property value.
|
||||
* organization, so we created our own groups and used a lookAndFeel property to initialize each
|
||||
* group source value. Then whenever the font matched a group source value, the font is replace
|
||||
* with an indirect reference to the group source font value.
|
||||
* <p>
|
||||
* This class is sometimes sub-classed for a particular {@link LookAndFeel}. The subclass can
|
||||
* create new groups and mappings that are unique to that LookAndFeel.
|
||||
*
|
||||
* Often, many of the various group source ids have the same color value. To try to group
|
||||
* properties as defined in BasicLookAndFeel, the preferred source ids are
|
||||
* defined for each group. These will be tried first, but if a match isn't found among the
|
||||
* preferred sources, then all the sources will be searched for a match
|
||||
*/
|
||||
public class ThemeGrouper {
|
||||
private static String DEFAULT_FONT_GROUP_ID = "font.default";
|
||||
|
@ -141,10 +146,6 @@ public class ThemeGrouper {
|
|||
"ToolTip"
|
||||
};
|
||||
|
||||
// often the many of the various group source ids have the same color value. To try and group
|
||||
// properties as defined in BasicLookAndFeel, the preferred source ids are
|
||||
// defined for each group. These will be tried first, but if a match isn't found among the
|
||||
// preferred sources, then all the sources will be searched for a match
|
||||
private static final String[] BUTTON_PREFERRED_SOURCES = {
|
||||
"control",
|
||||
"controlText",
|
||||
|
@ -225,24 +226,42 @@ public class ThemeGrouper {
|
|||
groupFonts(values, groupMap);
|
||||
}
|
||||
|
||||
protected void defineCustomColorGroup(GThemeValueMap values, String customGroupName,
|
||||
String exemplarComponentId) {
|
||||
/**
|
||||
* Defines a new color id that will be used as the reference value for any specific color ids that
|
||||
* have the same color value. This will allow all those specific colors to be changed at once.
|
||||
* @param customGroupColorName name of a higher level group color id that will be used as the
|
||||
* value for more specific color ids defined by the lookAndFeel.
|
||||
* @param lookAndFeelSourceId the lookAndFeel color id whose value will be used as the value
|
||||
* for the new custom group color id
|
||||
* @param values the map where we store the default theme value mappings
|
||||
*/
|
||||
protected void defineCustomColorGroup(String customGroupColorName, String lookAndFeelSourceId,
|
||||
GThemeValueMap values) {
|
||||
|
||||
colorSourceProperties.add(customGroupName);
|
||||
ColorValue colorValue = values.getColor(exemplarComponentId);
|
||||
colorSourceProperties.add(customGroupColorName);
|
||||
ColorValue colorValue = values.getColor(lookAndFeelSourceId);
|
||||
if (colorValue != null) {
|
||||
Color color = colorValue.get(values);
|
||||
values.addColor(new ColorValue(customGroupName, color));
|
||||
values.addColor(new ColorValue(customGroupColorName, color));
|
||||
}
|
||||
}
|
||||
|
||||
protected void defineCustomFontGroup(GThemeValueMap values, String customGroupName,
|
||||
String exemplarComponentId) {
|
||||
fontSourceProperties.add(customGroupName);
|
||||
FontValue fontValue = values.getFont(exemplarComponentId);
|
||||
/**
|
||||
* Defines a new font id that will be used as the reference value for any specific font ids that
|
||||
* have the same font value. This will allow all those specific fonts to be changed at once.
|
||||
* @param customGroupFontName name of a higher level group font id that will be used as the
|
||||
* value of more specific font ids defined by the lookAndFeel.
|
||||
* @param lookAndFeelSourceId the lookAndFeel font id whose value will be used as the value
|
||||
* for the new custom group font id
|
||||
* @param values the map where we store the default theme value mappings
|
||||
*/
|
||||
protected void defineCustomFontGroup(String customGroupFontName, String lookAndFeelSourceId,
|
||||
GThemeValueMap values) {
|
||||
fontSourceProperties.add(customGroupFontName);
|
||||
FontValue fontValue = values.getFont(lookAndFeelSourceId);
|
||||
if (fontValue != null) {
|
||||
Font font = fontValue.get(values);
|
||||
values.addFont(new FontValue(customGroupName, font));
|
||||
values.addFont(new FontValue(customGroupFontName, font));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -854,6 +854,10 @@ public abstract class AbstractOptions implements Options {
|
|||
}
|
||||
|
||||
private void themeChanged(ThemeEvent e) {
|
||||
// We are only sending out OptionsChangedEvents in response to Font theme changes. We
|
||||
// don't notify options changed for colors because we expect clients are using GColor
|
||||
// which updates automatically, so should need to be notified via options.
|
||||
|
||||
if (!e.hasAnyFontChanged()) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -64,6 +64,13 @@ public enum OptionType {
|
|||
return stringAdapter.objectToString(object);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the give value is of the correct type for this option type. Note that a
|
||||
* value of null is compatible with any class type
|
||||
* since it is an acceptable value for any class type.
|
||||
* @param object the object to see if it is compatible with this option type
|
||||
* @return true if the give value is of the correct type for this option type.
|
||||
*/
|
||||
public boolean isCompatible(Object object) {
|
||||
return object == null || clazz.isAssignableFrom(object.getClass());
|
||||
}
|
||||
|
|
|
@ -185,7 +185,7 @@ public class ColorUtils {
|
|||
private static int blend(int colorValue1, int colorValue2, double ratio) {
|
||||
double value = colorValue1 * ratio + colorValue2 * (1.0 - ratio);
|
||||
int result = (int) (value + 0.5);
|
||||
return Math.max(result, 255);
|
||||
return Math.min(result, 255);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -25,7 +25,6 @@ import java.util.Map;
|
|||
* those strings back to a color.
|
||||
*/
|
||||
public abstract class WebColors {
|
||||
// private static final Pattern HEX_PATTERN = Pattern.compile("(0x|#)[0-9A-Fa-f]{6}");
|
||||
private static final Map<String, Color> nameToColorMap = new HashMap<>();
|
||||
private static final Map<Color, String> colorToNameMap = new HashMap<>();
|
||||
|
||||
|
@ -391,10 +390,13 @@ public abstract class WebColors {
|
|||
}
|
||||
|
||||
private static int parseAlpha(String string) {
|
||||
// alpha strings can either be a float between 0.0 and 1.0 or an integer from 0 to 255.
|
||||
// if it is a float, treat that value as a percentage of the 255 max value
|
||||
// if it is an int, don't allow the value to be bigger than 255.
|
||||
if (string.contains(".")) {
|
||||
float value = Float.parseFloat(string);
|
||||
return (int) (value * 0xff + 0.5) & 0xff;
|
||||
return (int) (value * 0xff + 0.5) & 0xff; // convert to value in range (0-255)
|
||||
}
|
||||
return Integer.parseInt(string) & 0xff;
|
||||
return Integer.parseInt(string) & 0xff; // truncate any bits that would make it bigger than 255
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,11 +20,11 @@ import java.lang.ref.WeakReference;
|
|||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Class for storing weak reference to object instances. Objects of type T can be place in this
|
||||
* store and they will remain there until there are no references to that object remaining. Note
|
||||
* Class for storing a weak reference to object instances. Objects of type T can be placed in this
|
||||
* store and they will remain there until there are no references to that object. Note
|
||||
* that this is not a Set and you can have multiple instances that are "equal" in this store.The
|
||||
* main purpose of this store is to be able to get all objects in the store that are still
|
||||
* referenced. This is useful when you need to visit all remaining items.
|
||||
* referenced. This is useful when you need to visit all in use items.
|
||||
* <p>
|
||||
* This class is thread safe.
|
||||
*
|
||||
|
|
|
@ -53,7 +53,7 @@ public class Icons {
|
|||
|
||||
public static final Icon NOT_ALLOWED_ICON = new GIcon("icon.not.allowed");
|
||||
public static final Icon OPEN_FOLDER_ICON = new GIcon("icon.folder.open");
|
||||
public static final Icon CLOSED_FOLDER_ICON = new GIcon("icon.folder.open");
|
||||
public static final Icon CLOSED_FOLDER_ICON = new GIcon("icon.folder.closed");
|
||||
public static final Icon REFRESH_ICON = new GIcon("icon.refresh");
|
||||
|
||||
public static final Icon SORT_ASCENDING_ICON = new GIcon("icon.sort.ascending");
|
||||
|
|
|
@ -482,7 +482,9 @@ public class ResourceManager {
|
|||
|
||||
/**
|
||||
* Attempts to load an icon from the given path. Returns the icon or null if no icon was
|
||||
* found from the given path.
|
||||
* found from the given path. This differs from {@link #loadImage(String)} in that
|
||||
* loadImage will return the default Icon if one can't be found. Further, loadImage will cache
|
||||
* even the default value, while findIcon only caches resolved icons.
|
||||
* <p>
|
||||
*
|
||||
* @param path the icon to load, e.g., "images/home.gif"
|
||||
|
|
|
@ -57,7 +57,7 @@ public class ColorValueTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void TestIndirectMultiHopValue() {
|
||||
public void testIndirectMultiHopValue() {
|
||||
values.addColor(new ColorValue("color.grandparent", Color.RED));
|
||||
values.addColor(new ColorValue("color.parent", "color.grandparent"));
|
||||
ColorValue value = new ColorValue("color.test", "color.parent");
|
||||
|
@ -69,7 +69,7 @@ public class ColorValueTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void TestUnresolvedIndirectValue() {
|
||||
public void testUnresolvedIndirectValue() {
|
||||
ColorValue value = new ColorValue("color.test", "color.parent");
|
||||
values.addColor(value);
|
||||
|
||||
|
|
|
@ -18,6 +18,8 @@ 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;
|
||||
|
||||
|
@ -126,13 +128,13 @@ public class HTMLUtilitiesTest {
|
|||
|
||||
@Test
|
||||
public void testToRGBString() {
|
||||
String rgb = HTMLUtilities.toRGBString(WebColors.RED);
|
||||
String rgb = HTMLUtilities.toRGBString(Color.RED);
|
||||
assertEquals("255000000", rgb);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testToHexString() {
|
||||
String rgb = HTMLUtilities.toHexString(WebColors.RED);
|
||||
String rgb = HTMLUtilities.toHexString(Color.RED);
|
||||
assertEquals("#FF0000", rgb);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue