diff --git a/cnd.completion/nbproject/project.xml b/cnd.completion/nbproject/project.xml --- a/cnd.completion/nbproject/project.xml +++ b/cnd.completion/nbproject/project.xml @@ -173,6 +173,14 @@ + org.netbeans.swing.plaf + + + + 1.27 + + + org.openide.awt diff --git a/cnd.completion/src/org/netbeans/modules/cnd/completion/cplusplus/ext/CsmResultItem.java b/cnd.completion/src/org/netbeans/modules/cnd/completion/cplusplus/ext/CsmResultItem.java --- a/cnd.completion/src/org/netbeans/modules/cnd/completion/cplusplus/ext/CsmResultItem.java +++ b/cnd.completion/src/org/netbeans/modules/cnd/completion/cplusplus/ext/CsmResultItem.java @@ -103,7 +103,7 @@ import org.netbeans.spi.editor.completion.CompletionItem; import org.netbeans.spi.editor.completion.CompletionTask; import org.openide.util.Lookup; - +import org.netbeans.swing.plaf.LFCustoms; /** * * @author Vladimir Voskresensky @@ -122,8 +122,7 @@ protected int selectionEndOffset = -1; protected int substituteOffset = -1; CsmObject associatedObject; - private static final Color KEYWORD_COLOR = Color.gray; - private static final Color TYPE_COLOR = Color.black; + private static final Color KEYWORD_COLOR = Color.lightGray; private int priority; private SubstitutionHint hint; @@ -147,7 +146,7 @@ } protected static Color getTypeColor(CsmType type) { - return type.isBuiltInBased(false) ? KEYWORD_COLOR : TYPE_COLOR; + return type.isBuiltInBased(false) ? LFCustoms.shiftColor(KEYWORD_COLOR) : LFCustoms.getTextFgColor(); } public void setSubstituteOffset(int substituteOffset) { @@ -981,11 +980,11 @@ if (type == null) { // only var args parameters could have null types assert (((CsmParameter) prm).isVarArgs()) : " non var arg " + prm + " of class " + prm.getClass().getName(); - params.add(new ParamStr("", "", ((CsmParameter) prm).getName().toString(), prm.getText().toString(), true, KEYWORD_COLOR)); //NOI18N + params.add(new ParamStr("", "", ((CsmParameter) prm).getName().toString(), prm.getText().toString(), true, LFCustoms.shiftColor(KEYWORD_COLOR))); //NOI18N varArgIndex = i; } else { String typeName = getTypeName(type, instantiateTypes); - params.add(new ParamStr(typeName, typeName, ((CsmParameter) prm).getName().toString(), prm.getText().toString(), false, TYPE_COLOR /*getTypeColor(type.getClassifier())*/)); + params.add(new ParamStr(typeName, typeName, ((CsmParameter) prm).getName().toString(), prm.getText().toString(), false, LFCustoms.getTextFgColor() /*getTypeColor(type.getClassifier())*/)); } i++; } diff --git a/cnd.modelutil/nbproject/project.xml b/cnd.modelutil/nbproject/project.xml --- a/cnd.modelutil/nbproject/project.xml +++ b/cnd.modelutil/nbproject/project.xml @@ -86,6 +86,14 @@ + org.netbeans.swing.plaf + + + + 1.27 + + + org.openide.awt diff --git a/cnd.modelutil/src/org/netbeans/modules/cnd/modelutil/CsmDisplayUtilities.java b/cnd.modelutil/src/org/netbeans/modules/cnd/modelutil/CsmDisplayUtilities.java --- a/cnd.modelutil/src/org/netbeans/modules/cnd/modelutil/CsmDisplayUtilities.java +++ b/cnd.modelutil/src/org/netbeans/modules/cnd/modelutil/CsmDisplayUtilities.java @@ -89,6 +89,7 @@ import org.openide.text.CloneableEditorSupport; import org.openide.util.Lookup; import org.openide.util.NbBundle; +import org.netbeans.swing.plaf.LFCustoms; /** * @@ -405,7 +406,7 @@ buf.insert(0, ""); // NOI18N buf.append(""); // NOI18N } - buf.insert(0, ""); //NOI18N + buf.insert(0, ""); //NOI18N buf.append(""); //NOI18N return buf.toString(); } diff --git a/cnd.modelutil/src/org/netbeans/modules/cnd/modelutil/CsmPaintComponent.java b/cnd.modelutil/src/org/netbeans/modules/cnd/modelutil/CsmPaintComponent.java --- a/cnd.modelutil/src/org/netbeans/modules/cnd/modelutil/CsmPaintComponent.java +++ b/cnd.modelutil/src/org/netbeans/modules/cnd/modelutil/CsmPaintComponent.java @@ -63,7 +63,7 @@ import javax.swing.BorderFactory; import javax.swing.Icon; import javax.swing.JPanel; - +import org.netbeans.swing.plaf.LFCustoms; /** * @@ -101,9 +101,8 @@ "", " ", "[]", "(", ")", ", ", "String", THROWS // NOI18N }; - private static final Color KEYWORD_COLOR = Color.darkGray; - private static final Color TYPE_COLOR = Color.black; - private static final Color POSTFIX_COLOR = Color.gray; + private final static Color KEYWORD_COLOR = Color.gray; + private final static Color POSTFIX_COLOR = Color.lightGray; private Icon icon; @@ -128,21 +127,22 @@ @Override public void paintComponent(Graphics g) { // clear background + Color postfixColor = LFCustoms.shiftColor(POSTFIX_COLOR); g.setColor(getBackground()); java.awt.Rectangle r = g.getClipBounds(); g.fillRect(r.x, r.y, r.width, r.height); draw(g); if(!postfixes.isEmpty()) { - drawString(g, " (", POSTFIX_COLOR); // NOI18N + drawString(g, " (", postfixColor); // NOI18N Iterator iter = postfixes.iterator(); while(iter.hasNext()) { ((PostfixString) iter.next()).Draw(g); if(iter.hasNext()) { - drawString(g, ", ", POSTFIX_COLOR); // NOI18N + drawString(g, ", ", postfixColor); // NOI18N } } - drawString(g, ")", POSTFIX_COLOR); // NOI18N + drawString(g, ")", postfixColor); // NOI18N } } @@ -372,7 +372,7 @@ } public PostfixString(String text, int fontStyle) { - this(text, CsmPaintComponent.POSTFIX_COLOR, fontStyle); + this(text, LFCustoms.shiftColor(CsmPaintComponent.POSTFIX_COLOR), fontStyle); } void Draw(Graphics g) { @@ -397,7 +397,7 @@ private String pkgName; private boolean displayFullNamespacePath; - private Color NAMESPACE_COLOR = Color.green.darker().darker().darker(); + private Color NAMESPACE_COLOR = LFCustoms.shiftColor(new Color(64,255,64)); public NamespacePaintComponent(){ super(); @@ -436,7 +436,7 @@ public static class NamespaceAliasPaintComponent extends CsmPaintComponent{ private String aliasName; - private Color NAMESPACE_COLOR = Color.green.darker().darker().darker(); + private Color NAMESPACE_COLOR = LFCustoms.shiftColor(new Color(64,255,64)); public NamespaceAliasPaintComponent(){ super(); @@ -467,7 +467,7 @@ public static class EnumPaintComponent extends CsmPaintComponent { String formatEnumName; - private Color ENUM_COLOR = Color.red.darker().darker().darker().darker(); + private Color ENUM_COLOR = LFCustoms.shiftColor(new Color(255,64,64)); private boolean displayFQN; public void EnumPaintComponent(String formatEnumName){ @@ -504,7 +504,7 @@ public static class EnumeratorPaintComponent extends CsmPaintComponent { String formatEnumeratorName; - private Color ENUMERATOR_COLOR = Color.blue.darker().darker().darker().darker(); + private Color ENUMERATOR_COLOR = LFCustoms.shiftColor(new Color(64,64,255)); private boolean displayFQN; public void EnumeratorPaintComponent(String formatEnumeratorName){ @@ -542,7 +542,7 @@ public static class ClassPaintComponent extends CsmPaintComponent{ String formatClassName; - private Color CLASS_COLOR = Color.red.darker().darker().darker(); + private Color CLASS_COLOR = LFCustoms.shiftColor(new Color(255,64,64)); private boolean displayFQN; public void setFormatClassName(String formatClassName){ @@ -576,7 +576,7 @@ public static class TypedefPaintComponent extends CsmPaintComponent{ String formatTypedefName; - private final Color TYPEDEF_COLOR = CsmFontColorManager.instance().getColor(FontColorProvider.Entity.TYPEDEF); //Color.blue.darker().darker().darker(); + private final Color TYPEDEF_COLOR = CsmFontColorManager.instance().getColor(FontColorProvider.Entity.TYPEDEF); //new Color(64,64,255).darker().darker().darker(); //private boolean displayFQN; public void setFormatTypedefName(String formatTypedefName){ @@ -609,7 +609,7 @@ public static class StructPaintComponent extends ClassPaintComponent{ - private Color STRUCT_COLOR = Color.red.darker().darker(); + private Color STRUCT_COLOR = LFCustoms.shiftColor(new Color(255,64,64)); @Override protected Color getColor(){ @@ -623,7 +623,7 @@ public static class UnionPaintComponent extends ClassPaintComponent{ - private Color UNION_COLOR = Color.red.darker(); + private Color UNION_COLOR = LFCustoms.shiftColor(new Color(255,64,64)); @Override protected Color getColor(){ @@ -636,7 +636,7 @@ } public static class FieldPaintComponent extends CsmPaintComponent{ - private Color FIELD_COLOR = CsmFontColorManager.instance().getColor(FontColorProvider.Entity.CLASS_FIELD);//Color.blue.darker(); + private Color FIELD_COLOR = CsmFontColorManager.instance().getColor(FontColorProvider.Entity.CLASS_FIELD);//new Color(64,64,255).darker(); protected String typeName; protected Color typeColor; protected String fldName; @@ -720,7 +720,7 @@ } public static class LocalVariablePaintComponent extends FieldPaintComponent { - private Color VARIABLE_COLOR = Color.red.darker().darker().darker(); + private Color VARIABLE_COLOR = LFCustoms.shiftColor(new Color(255,64,64)); public LocalVariablePaintComponent(){ super(); @@ -739,7 +739,7 @@ } public static class FileLocalVariablePaintComponent extends FieldPaintComponent { - private Color VARIABLE_COLOR = Color.blue.darker().darker().darker(); + private Color VARIABLE_COLOR = LFCustoms.shiftColor(new Color(64,64,255)); public FileLocalVariablePaintComponent(){ super(); @@ -752,7 +752,7 @@ } public static class GlobalVariablePaintComponent extends FieldPaintComponent { - private Color VARIABLE_COLOR = Color.blue.darker().darker().darker(); + private Color VARIABLE_COLOR = LFCustoms.shiftColor(new Color(64,64,255)); public GlobalVariablePaintComponent(){ super(); @@ -765,8 +765,8 @@ } public static class MacroPaintComponent extends CsmPaintComponent{ - private Color MACRO_NAME_COLOR = CsmFontColorManager.instance().getColor(FontColorProvider.Entity.DEFINED_MACRO);//Color.green.darker().darker(); - private Color MACRO_PARAMETER_NAME_COLOR = new Color(163, 102, 10);//Color.magenta.darker(); + private Color MACRO_NAME_COLOR = CsmFontColorManager.instance().getColor(FontColorProvider.Entity.DEFINED_MACRO);//new Color(64,255,64).darker().darker(); + private Color MACRO_PARAMETER_NAME_COLOR = LFCustoms.shiftColor(new Color(227, 166, 74));//Color.magenta.darker(); private List params = null; private String name; @@ -848,7 +848,7 @@ } public static class TemplateParameterPaintComponent extends CsmPaintComponent{ - private Color PARAMETER_NAME_COLOR = Color.BLACK.darker().darker(); + private Color PARAMETER_NAME_COLOR = LFCustoms.getTextFgColor(); private List params = null; private String name; @@ -897,7 +897,7 @@ } public static class LabelPaintComponent extends CsmPaintComponent { - private Color LABEL_NAME_COLOR = Color.BLACK.darker().darker(); + private Color LABEL_NAME_COLOR = LFCustoms.getTextFgColor(); private List params = null; private String name; @@ -947,8 +947,8 @@ public static class ConstructorPaintComponent extends CsmPaintComponent{ - private Color CONSTRUCTOR_COLOR = Color.orange.darker().darker(); - private Color PARAMETER_NAME_COLOR = new Color(163, 102, 10);//Color.magenta.darker(); + private Color CONSTRUCTOR_COLOR = LFCustoms.shiftColor(Color.orange); + private Color PARAMETER_NAME_COLOR = LFCustoms.shiftColor(new Color(227, 166, 74));//Color.magenta.darker(); private List params = new ArrayList(); private List excs = new ArrayList(); private String name; @@ -1028,7 +1028,7 @@ protected void drawExceptions(Graphics g, List exc, boolean strike) { if (exc.size() > 0) { - drawString(g, THROWS, KEYWORD_COLOR, null, strike); + drawString(g, THROWS, LFCustoms.shiftColor(KEYWORD_COLOR), null, strike); for (Iterator it = exc.iterator(); it.hasNext();) { ExceptionStr ex = (ExceptionStr) it.next(); drawString(g, ex.getName(), ex.getTypeColor(), null, strike); @@ -1105,7 +1105,7 @@ public static class MethodPaintComponent extends ConstructorPaintComponent { //private Color PARAMETER_NAME_COLOR = Color.magenta.darker(); - private Color METHOD_COLOR = Color.black;//red.darker().darker(); + private Color METHOD_COLOR = LFCustoms.getTextFgColor(); private String typeName; private Color typeColor; private boolean drawTypeAsPrefix = false; @@ -1190,7 +1190,7 @@ } public static class FileLocalFunctionPaintComponent extends MethodPaintComponent { - private Color FUN_COLOR = Color.black;//red.darker().darker(); + private Color FUN_COLOR = LFCustoms.getTextFgColor(); public FileLocalFunctionPaintComponent(){ super(); @@ -1203,7 +1203,7 @@ } public static class GlobalFunctionPaintComponent extends MethodPaintComponent { - private Color FUN_COLOR = Color.black;//.red.darker().darker(); + private Color FUN_COLOR = LFCustoms.getTextFgColor(); public GlobalFunctionPaintComponent(){ super(); @@ -1277,7 +1277,7 @@ @Override protected void draw(Graphics g){ drawIcon(g, null); - drawString(g, str, TYPE_COLOR); + drawString(g, str, LFCustoms.getTextFgColor()); } @Override diff --git a/core.output2/nbproject/project.xml b/core.output2/nbproject/project.xml --- a/core.output2/nbproject/project.xml +++ b/core.output2/nbproject/project.xml @@ -50,6 +50,14 @@ org.netbeans.core.output2 + org.netbeans.swing.plaf + + + + 1.27 + + + org.openide.actions diff --git a/core.output2/src/org/netbeans/core/output2/AbstractLines.java b/core.output2/src/org/netbeans/core/output2/AbstractLines.java --- a/core.output2/src/org/netbeans/core/output2/AbstractLines.java +++ b/core.output2/src/org/netbeans/core/output2/AbstractLines.java @@ -67,7 +67,7 @@ import org.openide.util.Mutex; import org.openide.windows.IOColors; import org.openide.windows.OutputListener; - +import org.netbeans.swing.plaf.LFCustoms; /** * Abstract Lines implementation with handling for getLine wrap calculations, etc. */ @@ -313,7 +313,7 @@ longestLineLen = 0; listener = null; dirty = false; - curDefColors = DEF_COLORS.clone(); + curDefColors = getDefColors().clone(); } private boolean dirty; @@ -827,12 +827,15 @@ } /** initial default colors */ - static final Color[] DEF_COLORS; + private static Color[] DEF_COLORS = null; /** current default colors */ Color[] curDefColors; - static { + static Color[] getDefColors() { + if (DEF_COLORS != null) { + return DEF_COLORS; + } Color out = UIManager.getColor("nb.output.foreground"); //NOI18N if (out == null) { out = UIManager.getColor("textText"); @@ -843,12 +846,12 @@ Color err = UIManager.getColor("nb.output.err.foreground"); //NOI18N if (err == null) { - err = new Color(164, 0, 0); + err = LFCustoms.shiftColor(Color.red); } Color hyperlink = UIManager.getColor("nb.output.link.foreground"); //NOI18N if (hyperlink == null) { - hyperlink = Color.BLUE.darker(); + hyperlink = LFCustoms.shiftColor(Color.blue); } Color hyperlinkImp = UIManager.getColor("nb.output.link.foreground.important"); //NOI18N @@ -856,7 +859,7 @@ hyperlinkImp = hyperlink; } - DEF_COLORS = new Color[]{out, err, hyperlink, hyperlinkImp}; + return DEF_COLORS = new Color[]{out, err, hyperlink, hyperlinkImp}; } public void setDefColor(IOColors.OutputType type, Color color) { diff --git a/core.output2/src/org/netbeans/core/output2/NbIO.java b/core.output2/src/org/netbeans/core/output2/NbIO.java --- a/core.output2/src/org/netbeans/core/output2/NbIO.java +++ b/core.output2/src/org/netbeans/core/output2/NbIO.java @@ -430,7 +430,7 @@ } Color getColor(IOColors.OutputType type) { - return ioColors != null ? ioColors.getColor(type) : AbstractLines.DEF_COLORS[type.ordinal()]; + return ioColors != null ? ioColors.getColor(type) : AbstractLines.getDefColors()[type.ordinal()]; } private class IOTabImpl extends IOTab { @@ -521,7 +521,7 @@ @Override protected Color getColor(OutputType type) { - return clrs[type.ordinal()] != null ? clrs[type.ordinal()] : AbstractLines.DEF_COLORS[type.ordinal()]; + return clrs[type.ordinal()] != null ? clrs[type.ordinal()] : AbstractLines.getDefColors()[type.ordinal()]; } @Override diff --git a/java.editor/nbproject/project.xml b/java.editor/nbproject/project.xml --- a/java.editor/nbproject/project.xml +++ b/java.editor/nbproject/project.xml @@ -337,6 +337,14 @@ + org.netbeans.swing.plaf + + + + 1.27 + + + org.openide.awt diff --git a/java.editor/src/org/netbeans/modules/editor/java/JavaCompletionItem.java b/java.editor/src/org/netbeans/modules/editor/java/JavaCompletionItem.java --- a/java.editor/src/org/netbeans/modules/editor/java/JavaCompletionItem.java +++ b/java.editor/src/org/netbeans/modules/editor/java/JavaCompletionItem.java @@ -97,6 +97,7 @@ import org.openide.util.ImageUtilities; import org.openide.util.NbBundle; import org.openide.xml.XMLUtil; +import org.netbeans.swing.plaf.LFCustoms; /** * @@ -1070,7 +1071,6 @@ static class TypeParameterItem extends JavaCompletionItem { - private static final String TYPE_PARAMETER_COLOR = ""; //NOI18N private String simpleName; private String leftText; @@ -1094,7 +1094,7 @@ protected String getLeftHtmlText() { if (leftText == null) - leftText = TYPE_PARAMETER_COLOR + simpleName + COLOR_END; + leftText = LFCustoms.getTextFgColorHTML() + simpleName + COLOR_END; return leftText; } @@ -1406,7 +1406,6 @@ private static final String METHOD_ST_PROTECTED = "org/netbeans/modules/editor/resources/completion/method_static_protected_16.png"; //NOI18N private static final String METHOD_ST_PRIVATE = "org/netbeans/modules/editor/resources/completion/method_static_private_16.png"; //NOI18N private static final String METHOD_ST_PACKAGE = "org/netbeans/modules/editor/resources/completion/method_static_package_private_16.png"; //NOI18N - private static final String METHOD_COLOR = ""; //NOI18N private static final String PARAMETER_NAME_COLOR = ""; //NOI18N private static ImageIcon icon[][] = new ImageIcon[2][4]; @@ -1487,7 +1486,7 @@ protected String getLeftHtmlText() { if (leftText == null) { StringBuilder lText = new StringBuilder(); - lText.append(METHOD_COLOR); + lText.append(LFCustoms.getTextFgColorHTML()); if (!isInherited) lText.append(BOLD); if (isDeprecated || isBlackListed()) @@ -1795,7 +1794,7 @@ return sb.toString(); } } - + static class OverrideMethodItem extends MethodItem { private static final String IMPL_BADGE_PATH = "org/netbeans/modules/java/editor/resources/implement_badge.png"; @@ -1916,7 +1915,6 @@ private static final String METHOD_PUBLIC = "org/netbeans/modules/editor/resources/completion/method_16.png"; //NOI18N private static final String GETTER_BADGE_PATH = "org/netbeans/modules/java/editor/resources/getter_badge.png"; //NOI18N private static final String SETTER_BADGE_PATH = "org/netbeans/modules/java/editor/resources/setter_badge.png"; //NOI18N - private static final String METHOD_COLOR = ""; //NOI18N private static final String PARAMETER_NAME_COLOR = ""; //NOI18N private static ImageIcon superIcon; @@ -1967,7 +1965,7 @@ protected String getLeftHtmlText() { if (leftText == null) { StringBuilder lText = new StringBuilder(); - lText.append(METHOD_COLOR); + lText.append(LFCustoms.getTextFgColorHTML()); lText.append(BOLD); lText.append(name); lText.append(BOLD_END); @@ -2541,7 +2539,6 @@ static class ParametersItem extends JavaCompletionItem { private static final String PARAMETERS_COLOR = ""; //NOI18N - private static final String ACTIVE_PARAMETER_COLOR = ""; //NOI18N protected ElementHandle elementHandle; private boolean isDeprecated; @@ -2612,7 +2609,7 @@ for (int i = 0; i < params.size(); i++) { ParamDesc paramDesc = params.get(i); if (i == activeParamsIndex) - lText.append(COLOR_END).append(ACTIVE_PARAMETER_COLOR).append(BOLD); + lText.append(COLOR_END).append(LFCustoms.getTextFgColorHTML()).append(BOLD); lText.append(escape(paramDesc.typeName)); lText.append(' '); lText.append(paramDesc.name); diff --git a/o.n.swing.plaf/apichanges.xml b/o.n.swing.plaf/apichanges.xml --- a/o.n.swing.plaf/apichanges.xml +++ b/o.n.swing.plaf/apichanges.xml @@ -49,6 +49,31 @@ Look And Feel Customization + + + New functions for getting foreground text color and color shifting + + + + + +

+ new functions:
+ + static String getHexString(int color)
+ static String getTextFgColorHTML()
+ static Color getTextFgColor()
+ static Color shiftColor(Color color)
+ static Color getForeground(AttributeSet a)
+
+

+
+ +
It is now possible to customize application-specific UIManager keys and values. diff --git a/o.n.swing.plaf/manifest.mf b/o.n.swing.plaf/manifest.mf --- a/o.n.swing.plaf/manifest.mf +++ b/o.n.swing.plaf/manifest.mf @@ -1,6 +1,6 @@ Manifest-Version: 1.0 OpenIDE-Module-Localizing-Bundle: org/netbeans/swing/plaf/Bundle.properties OpenIDE-Module: org.netbeans.swing.plaf -OpenIDE-Module-Specification-Version: 1.26 +OpenIDE-Module-Specification-Version: 1.27 AutoUpdate-Show-In-Client: false diff --git a/o.n.swing.plaf/src/org/netbeans/swing/plaf/LFCustoms.java b/o.n.swing.plaf/src/org/netbeans/swing/plaf/LFCustoms.java --- a/o.n.swing.plaf/src/org/netbeans/swing/plaf/LFCustoms.java +++ b/o.n.swing.plaf/src/org/netbeans/swing/plaf/LFCustoms.java @@ -44,6 +44,12 @@ package org.netbeans.swing.plaf; +import java.awt.Color; +import java.util.logging.Logger; +import javax.swing.UIManager; +import javax.swing.plaf.ColorUIResource; +import javax.swing.text.AttributeSet; + /** Look and feel customizations interface. * For various look and feels, there is a need to customize colors, * borders etc. to provide 'native-like' UI. @@ -78,6 +84,104 @@ private Object[] guaranteedKeysAndValues = null; protected static final String WORKPLACE_FILL = "nb_workplace_fill"; //NOI18N + /** convert color + * @return hexadecimal value */ + public static String getHexString(int color) { + String result = Integer.toHexString(color).toUpperCase(); + if (result.length() == 1) { + return '0'+result; + } + return result; + } + + /** cached window text foreground color as html code */ + private static String textFgColorHTML = ""; + + /** @return window text foreground color as html code */ + public static String getTextFgColorHTML() { + synchronized(LFCustoms.class) { + if (textFgColorHTML.isEmpty()) { + Object o = UIManager.getLookAndFeel().getDefaults().get("windowText"); + if (o instanceof ColorUIResource) { + ColorUIResource resource = (ColorUIResource)o; + textFgColorHTML = ""; + } else { + textFgColorHTML = ""; + Logger.getLogger(LFCustoms.class.getName()).warning("BUG: getTextFgColorHTML: color isn't available"); + } + } + return textFgColorHTML; + } + } + + /** cached window text foreground color */ + private static Color textFgColor = null; + + /** @return window text foreground color */ + public static Color getTextFgColor() { + synchronized(LFCustoms.class) { + if (textFgColor == null) { + Object o = UIManager.getLookAndFeel().getDefaults().get("windowText"); + if (o instanceof ColorUIResource) { + textFgColor = (Color) o; + } else { + textFgColor = Color.BLACK; + Logger.getLogger(LFCustoms.class.getName()).warning("BUG: getTextFgColor: color isn't available"); + } + } + return textFgColor; + } + } + + /** shift color value */ + private static final int shiftValue = 64; + + /** convert color component + * @return brighter color component */ + private static int brighter (int color) { + int result = color + shiftValue; + if (result > 255) { + return 255; + } else { + return result; + } + } + + /** convert color component + * @return darker color component */ + private static int darker(int color) { + int result = color - shiftValue; + if (result < 0) { + return 0; + } else { + return result; + } + } + + /** convert color to brighter one if window foreground text color is bright color + * or convert color to darker one if window foreground text color is dark color + * @return converted color + */ + public static Color shiftColor(Color color) { + Color textFgColor = getTextFgColor(); + if ((textFgColor.getRed() > 127) || (textFgColor.getGreen() > 127) || (textFgColor.getBlue() > 127)) { + return new Color(brighter(color.getRed()), brighter(color.getGreen()), brighter(color.getBlue())); + } + return new Color(darker(color.getRed()), darker(color.getGreen()), darker(color.getBlue())); + } + + /** get foreground text color from AttributeSet + * or get window foreground text color if AttributeSet doesn't define foreground text color + * @return foreground text color + */ + public static Color getForeground(AttributeSet a) { + Color fg = (Color) a.getAttribute(javax.swing.text.StyleConstants.Foreground); + if (fg == null) { + fg = getTextFgColor(); + } + return fg; + } + //TODO: A nice idea would be to replace these classes with XML files - minor rewrite of NbTheme to do it /** Fetch and cache keys and values */ diff --git a/refactoring.java/nbproject/project.xml b/refactoring.java/nbproject/project.xml --- a/refactoring.java/nbproject/project.xml +++ b/refactoring.java/nbproject/project.xml @@ -214,6 +214,14 @@
+ org.netbeans.swing.plaf + + + + 1.27 + + + org.openide.actions diff --git a/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/UIUtilities.java b/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/UIUtilities.java --- a/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/UIUtilities.java +++ b/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/UIUtilities.java @@ -66,6 +66,7 @@ import org.netbeans.api.lexer.TokenHierarchy; import org.netbeans.api.lexer.TokenSequence; import org.netbeans.modules.refactoring.java.api.MemberInfo; +import org.netbeans.swing.plaf.LFCustoms; import org.openide.util.Lookup; import org.openide.xml.XMLUtil; @@ -279,7 +280,7 @@ buf.insert(0, ""); // NOI18N buf.append(""); // NOI18N } - buf.insert(0, ""); //NOI18N + buf.insert(0, ""); //NOI18N buf.append(""); //NOI18N return buf.toString(); }