Browse Source

Removed lambda parameter from PaintUtil.drawString in favour of an additional PaintUtil.drawStringUnderlineCharAt method to reduce painting overhead.

Fixed JTextPane not using correct foreground color and font.
pull/173/head
weisj 5 years ago
parent
commit
66ecb2d299
  1. 3
      change_notes.md
  2. 42
      core/src/main/java/com/github/weisj/darklaf/graphics/PaintUtil.java
  3. 19
      core/src/main/java/com/github/weisj/darklaf/ui/button/DarkButtonUI.java
  4. 48
      core/src/main/java/com/github/weisj/darklaf/ui/label/DarkLabelUI.java
  5. 49
      core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkTabFrameTabLabelUI.java
  6. 13
      core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextPaneUI.java
  7. 2
      core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextUI.java
  8. 3
      core/src/main/java/com/github/weisj/darklaf/ui/text/bridge/DarkEditorPaneUIBridge.java
  9. 8
      core/src/main/java/com/github/weisj/darklaf/ui/text/dummy/DummyEditorPane.java
  10. 14
      core/src/main/java/com/github/weisj/darklaf/ui/text/dummy/DummyEditorPaneUI.java
  11. 65
      core/src/main/java/com/github/weisj/darklaf/ui/text/dummy/DummyTextPaneUI.java
  12. 40
      core/src/main/java/com/github/weisj/darklaf/ui/text/dummy/DummyTextUIMethods.java
  13. 9
      core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/radiobutton/DarkRadioButtonUI.java
  14. 8
      core/src/main/java/com/github/weisj/darklaf/ui/tooltip/DarkToolTipUI.java
  15. 1
      core/src/main/resources/com/github/weisj/darklaf/properties/globals.properties
  16. 1
      core/src/main/resources/com/github/weisj/darklaf/properties/ui/text.properties
  17. 2
      core/src/test/java/defaults/SampleRenderer.java
  18. 1
      core/src/test/java/ui/tabFrame/TabFrameDemo.java

3
change_notes.md

@ -4,10 +4,10 @@
- Support for insert text mode. - Support for insert text mode.
- Text cursor will now show directional hints for bidi text. - Text cursor will now show directional hints for bidi text.
- Added cut/copy/paste context menu for text components. - Added cut/copy/paste context menu for text components.
- On macOS Catalina the default font will now be `Helvetica Neue` due to karning issues with the `San Francisco` font.
- Balloons tooltips are now enabled by default for buttons. - Balloons tooltips are now enabled by default for buttons.
- Improved html style sheet. - Improved html style sheet.
- On Windows (Vista and later) darklaf will now use the system font. - On Windows (Vista and later) darklaf will now use the system font.
- On macOS Catalina the default font will now be `Helvetica Neue` due to karning issues with the `San Francisco` font.
- Better interoperability with custom cell renderers. - Better interoperability with custom cell renderers.
- Improved selection painting. - Improved selection painting.
- Added property to control whether the selection is extended to the end of the text component. - Added property to control whether the selection is extended to the end of the text component.
@ -41,3 +41,4 @@
- Incorrect popup location when using multiple monitors with different resolutions. #162 59e3c8e5f07479a1a717e42d48b82d763cf8f8cc - Incorrect popup location when using multiple monitors with different resolutions. #162 59e3c8e5f07479a1a717e42d48b82d763cf8f8cc
- Poor performance when using bidirectional text with non zero margins. #167 252885df6fa18044c215361cbbe200cdf3358cf5 - Poor performance when using bidirectional text with non zero margins. #167 252885df6fa18044c215361cbbe200cdf3358cf5
- Text isn't painted when using the toggle button slider variant. 0d1f2913dd25d5a684fa2567c37a94b549f030b0 - Text isn't painted when using the toggle button slider variant. 0d1f2913dd25d5a684fa2567c37a94b549f030b0
- Kerning issues on macOS Catalina. #128 d3fd5dedabe11d84685e593a03b1941b8ea56836

42
core/src/main/java/com/github/weisj/darklaf/graphics/PaintUtil.java

@ -33,6 +33,8 @@ import java.awt.geom.RoundRectangle2D;
import javax.swing.*; import javax.swing.*;
import javax.swing.text.View; import javax.swing.text.View;
import sun.swing.SwingUtilities2;
import com.github.weisj.darklaf.ui.html.DarkHTML; import com.github.weisj.darklaf.ui.html.DarkHTML;
import com.github.weisj.darklaf.util.PropertyUtil; import com.github.weisj.darklaf.util.PropertyUtil;
import com.github.weisj.darklaf.util.Scale; import com.github.weisj.darklaf.util.Scale;
@ -248,10 +250,14 @@ public class PaintUtil {
g.fillRect(x, y + height - thickness, width, thickness); g.fillRect(x, y + height - thickness, width, thickness);
} }
public static <T extends JComponent> void drawString(final Graphics g, final T c,
final String text, final Rectangle textRect) {
drawString(g, c, text, textRect, SwingUtilities2.getFontMetrics(c, g));
}
public static <T extends JComponent> void drawString(final Graphics g, final T c, public static <T extends JComponent> void drawString(final Graphics g, final T c,
final String text, final Rectangle textRect, final String text, final Rectangle textRect,
final FontMetrics fm, final FontMetrics fm) {
final PaintMethod<T> paintMethod) {
GraphicsContext context = GraphicsUtil.setupAntialiasing(g); GraphicsContext context = GraphicsUtil.setupAntialiasing(g);
g.clipRect(textRect.x, textRect.y, textRect.width, textRect.height); g.clipRect(textRect.x, textRect.y, textRect.width, textRect.height);
Font font = c.getFont(); Font font = c.getFont();
@ -262,19 +268,41 @@ public class PaintUtil {
v.paint(g, textRect); v.paint(g, textRect);
} else { } else {
textRect.y += fm.getAscent(); textRect.y += fm.getAscent();
paintMethod.paintText(g, c, textRect, text); SwingUtilities2.drawString(c, g, text, textRect.x, textRect.y);
} }
} }
context.restore(); context.restore();
} }
public static void fillRect(final Graphics g, final Rectangle r) { public static <T extends JComponent> void drawStringUnderlineCharAt(final Graphics g, final T c,
g.fillRect(r.x, r.y, r.width, r.height); final String text, final int mnemIndex,
final Rectangle textRect) {
drawStringUnderlineCharAt(g, c, text, mnemIndex, textRect, SwingUtilities2.getFontMetrics(c, g));
} }
public interface PaintMethod<T extends JComponent> { public static <T extends JComponent> void drawStringUnderlineCharAt(final Graphics g, final T c,
final String text, final int mnemIndex,
final Rectangle textRect,
final FontMetrics fm) {
GraphicsContext context = GraphicsUtil.setupAntialiasing(g);
g.clipRect(textRect.x, textRect.y, textRect.width, textRect.height);
Font font = c.getFont();
g.setFont(font);
void paintText(final Graphics g, final T c, final Rectangle rect, final String text); if (text != null && !text.equals("")) {
View v = PropertyUtil.getObject(c, DarkHTML.propertyKey, View.class);
if (v != null) {
v.paint(g, textRect);
} else {
textRect.y += fm.getAscent();
SwingUtilities2.drawStringUnderlineCharAt(c, g, text, mnemIndex, textRect.x, textRect.y);
}
}
context.restore();
}
public static void fillRect(final Graphics g, final Rectangle r) {
g.fillRect(r.x, r.y, r.width, r.height);
} }
public enum Outline { public enum Outline {

19
core/src/main/java/com/github/weisj/darklaf/ui/button/DarkButtonUI.java

@ -273,23 +273,14 @@ public class DarkButtonUI extends BasicButtonUI implements ButtonConstants {
} }
} }
@Override protected void paintText(final Graphics g, final AbstractButton b, final String text) {
protected void paintText(final Graphics g, final JComponent c, ButtonModel model = b.getModel();
final Rectangle textRect, final String text) { g.setColor(getForeground(b));
AbstractButton button = (AbstractButton) c; int mnemonicIndex = b.getDisplayedMnemonicIndex();
ButtonModel model = button.getModel();
g.setColor(getForeground(button));
int mnemonicIndex = button.getDisplayedMnemonicIndex();
if (!model.isEnabled()) { if (!model.isEnabled()) {
mnemonicIndex = -1; mnemonicIndex = -1;
} }
SwingUtilities2.drawStringUnderlineCharAt(c, g, text, mnemonicIndex, PaintUtil.drawStringUnderlineCharAt(g, b, text, mnemonicIndex, textRect);
textRect.x + getTextShiftOffset(),
textRect.y + getTextShiftOffset());
}
protected void paintText(final Graphics g, final AbstractButton b, final String text) {
PaintUtil.drawString(g, b, text, textRect, SwingUtilities2.getFontMetrics(b, g), this::paintText);
} }
protected void paintIcon(final Graphics g, final AbstractButton b, final JComponent c) { protected void paintIcon(final Graphics g, final AbstractButton b, final JComponent c) {

48
core/src/main/java/com/github/weisj/darklaf/ui/label/DarkLabelUI.java

@ -78,6 +78,8 @@ public class DarkLabelUI extends BasicLabelUI implements PropertyChangeListener
String text = label.getText(); String text = label.getText();
Icon icon = getIcon(label); Icon icon = getIcon(label);
paintBackground(g, c);
if ((icon == null) && (text == null)) { if ((icon == null) && (text == null)) {
return; return;
} }
@ -90,34 +92,34 @@ public class DarkLabelUI extends BasicLabelUI implements PropertyChangeListener
config.restoreClip(); config.restoreClip();
} }
PaintUtil.drawString(g, c, clippedText, paintTextR, fm, (g2, c2, rect, t) -> { paintText(g, label, fm, clippedText);
if (label.isEnabled()) {
paintEnabledText(label, g2, t, rect.x, rect.y);
} else {
paintDisabledText(label, g2, t, rect.x, rect.y);
}
});
} }
@Override protected void paintBackground(final Graphics g, final JComponent c) {}
protected void paintEnabledText(final JLabel l, final Graphics g, final String s,
final int textX, final int textY) { public void paintText(final Graphics g, final JLabel label, final FontMetrics fm, final String clippedText) {
int mnemIndex = l.getDisplayedMnemonicIndex(); int mnemIndex = label.isEnabled() ? label.getDisplayedMnemonicIndex() : -1;
g.setColor(l.getForeground()); g.setColor(getForeground(label));
SwingUtilities2.drawStringUnderlineCharAt(l, g, s, mnemIndex, PaintUtil.drawStringUnderlineCharAt(g, label, clippedText, mnemIndex, paintTextR, fm);
textX, textY);
} }
@Override protected Color getForeground(final Component label) {
protected void paintDisabledText(final JLabel l, final Graphics g, final String s, if (label.isEnabled()) {
final int textX, final int textY) { return getEnabledForeground(label);
int accChar = l.getDisplayedMnemonicIndex(); } else {
g.setColor(l.getForeground()); return getDisabledForeground(label);
if (!DarkUIUtil.isInCell(l)) { }
g.setColor(inactiveForeground); }
protected Color getEnabledForeground(final Component label) {
return label.getForeground();
}
protected Color getDisabledForeground(final Component label) {
if (!DarkUIUtil.isInCell(label)) {
return inactiveForeground;
} }
SwingUtilities2.drawStringUnderlineCharAt(l, g, s, accChar, return getEnabledForeground(label);
textX, textY);
} }
protected Icon getIcon(final JLabel label) { protected Icon getIcon(final JLabel label) {

49
core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkTabFrameTabLabelUI.java

@ -36,13 +36,9 @@ import javax.swing.*;
import javax.swing.plaf.ComponentUI; import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.UIResource; import javax.swing.plaf.UIResource;
import sun.swing.SwingUtilities2;
import com.github.weisj.darklaf.components.tabframe.JTabFrame; import com.github.weisj.darklaf.components.tabframe.JTabFrame;
import com.github.weisj.darklaf.components.tabframe.TabFrameTab; import com.github.weisj.darklaf.components.tabframe.TabFrameTab;
import com.github.weisj.darklaf.components.tabframe.TabFrameTabLabel; import com.github.weisj.darklaf.components.tabframe.TabFrameTabLabel;
import com.github.weisj.darklaf.graphics.GraphicsContext;
import com.github.weisj.darklaf.graphics.PaintUtil;
import com.github.weisj.darklaf.icons.RotatableIcon; import com.github.weisj.darklaf.icons.RotatableIcon;
import com.github.weisj.darklaf.listener.HoverListener; import com.github.weisj.darklaf.listener.HoverListener;
import com.github.weisj.darklaf.ui.label.DarkLabelUI; import com.github.weisj.darklaf.ui.label.DarkLabelUI;
@ -79,42 +75,9 @@ public class DarkTabFrameTabLabelUI extends DarkLabelUI implements PropertyChang
} }
@Override @Override
public void paint(final Graphics g, final JComponent c) { protected void paintBackground(final Graphics g, final JComponent c) {
GraphicsContext config = new GraphicsContext(g);
g.setColor(getBackground(tabComponent)); g.setColor(getBackground(tabComponent));
g.fillRect(0, 0, tabComponent.getWidth(), tabComponent.getHeight()); g.fillRect(0, 0, tabComponent.getWidth(), tabComponent.getHeight());
JLabel label = (JLabel) c;
String text = label.getText();
Icon icon = getIcon();
if ((icon == null) && (text == null)) {
return;
}
FontMetrics fm = SwingUtilities2.getFontMetrics(label, g);
String clippedText = layout(label, fm, c.getWidth(), c.getHeight());
if (icon != null) {
icon.paintIcon(c, g, paintIconR.x, paintIconR.y);
config.restoreClip();
}
PaintUtil.drawString(g, c, clippedText, paintTextR, fm, (g2, c2, rect, t) -> {
if (label.isEnabled()) {
paintEnabledText(label, g2, t, rect.x, rect.y);
} else {
paintDisabledText(label, g2, t, rect.x, rect.y);
}
});
}
@Override
protected void paintEnabledText(final JLabel l, final Graphics g, final String s,
final int textX, final int textY) {
int mnemIndex = l.getDisplayedMnemonicIndex();
g.setColor(getForeground(tabComponent));
SwingUtilities2.drawStringUnderlineCharAt(l, g, s, mnemIndex, textX, textY);
} }
@Override @Override
@ -259,7 +222,12 @@ public class DarkTabFrameTabLabelUI extends DarkLabelUI implements PropertyChang
: tab.getBackground(); : tab.getBackground();
} }
public Color getForeground(final TabFrameTabLabel tab) { @Override
protected Color getEnabledForeground(final Component label) {
return getTabForeground((TabFrameTabLabel) label);
}
public Color getTabForeground(final TabFrameTabLabel tab) {
if (printing) return tab.getForeground(); if (printing) return tab.getForeground();
return tab.isSelected() return tab.isSelected()
? selectedFontColor ? selectedFontColor
@ -268,7 +236,8 @@ public class DarkTabFrameTabLabelUI extends DarkLabelUI implements PropertyChang
: tab.getForeground(); : tab.getForeground();
} }
protected Icon getIcon() { @Override
protected Icon getIcon(final JLabel label) {
Icon icon = (tabComponent.isEnabled()) ? tabComponent.getIcon() : tabComponent.getDisabledIcon(); Icon icon = (tabComponent.isEnabled()) ? tabComponent.getIcon() : tabComponent.getDisabledIcon();
rotatableIcon.setIcon(icon); rotatableIcon.setIcon(icon);
if (rotatableIcon.getOrientation() == null) { if (rotatableIcon.getOrientation() == null) {

13
core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextPaneUI.java

@ -24,21 +24,24 @@
*/ */
package com.github.weisj.darklaf.ui.text; package com.github.weisj.darklaf.ui.text;
import java.awt.*;
import javax.swing.*; import javax.swing.*;
import javax.swing.plaf.ComponentUI; import javax.swing.plaf.ComponentUI;
import com.github.weisj.darklaf.ui.text.dummy.DummyTextPaneUI;
/** /**
* @author Jannis Weis * @author Jannis Weis
*/ */
public class DarkTextPaneUI extends DarkEditorPaneUI { public class DarkTextPaneUI extends DarkEditorPaneUI {
public static ComponentUI createUI(final JComponent c) { static {
return new DarkTextPaneUI(); basicEditorPaneUI = new DummyTextPaneUI();
} }
@Override public static ComponentUI createUI(final JComponent c) {
public void installUI(final JComponent c) { return new DarkTextPaneUI();
super.installUI(c);
} }
@Override @Override

2
core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextUI.java

@ -135,7 +135,7 @@ public abstract class DarkTextUI extends BasicTextUI implements PropertyChangeLi
protected void uninstallPopupMenu() { protected void uninstallPopupMenu() {
JPopupMenu popupMenu = editor.getComponentPopupMenu(); JPopupMenu popupMenu = editor.getComponentPopupMenu();
if (popupMenu instanceof UIResource) { if (popupMenu instanceof UIResource) {
editor.setComponentOrientation(null); editor.setComponentPopupMenu(null);
} }
} }

3
core/src/main/java/com/github/weisj/darklaf/ui/text/bridge/DarkEditorPaneUIBridge.java

@ -34,6 +34,7 @@ import javax.swing.text.JTextComponent;
import com.github.weisj.darklaf.ui.text.DarkTextUI; import com.github.weisj.darklaf.ui.text.DarkTextUI;
import com.github.weisj.darklaf.ui.text.dummy.DummyEditorPane; import com.github.weisj.darklaf.ui.text.dummy.DummyEditorPane;
import com.github.weisj.darklaf.ui.text.dummy.DummyEditorPaneUI; import com.github.weisj.darklaf.ui.text.dummy.DummyEditorPaneUI;
import com.github.weisj.darklaf.ui.text.dummy.DummyTextUIMethods;
import com.github.weisj.darklaf.util.PropertyKey; import com.github.weisj.darklaf.util.PropertyKey;
/** /**
@ -42,7 +43,7 @@ import com.github.weisj.darklaf.util.PropertyKey;
public abstract class DarkEditorPaneUIBridge extends DarkTextUI { public abstract class DarkEditorPaneUIBridge extends DarkTextUI {
private static final DummyEditorPane editorPane = new DummyEditorPane(); private static final DummyEditorPane editorPane = new DummyEditorPane();
private static final DummyEditorPaneUI basicEditorPaneUI = new DummyEditorPaneUI(); protected static DummyTextUIMethods basicEditorPaneUI = new DummyEditorPaneUI();
private PropertyChangeListener propertyChangeListener; private PropertyChangeListener propertyChangeListener;

8
core/src/main/java/com/github/weisj/darklaf/ui/text/dummy/DummyEditorPane.java

@ -46,6 +46,14 @@ public class DummyEditorPane extends JEditorPane {
public void setEditorPane(final JEditorPane editorPane) { public void setEditorPane(final JEditorPane editorPane) {
this.editorPane = editorPane; this.editorPane = editorPane;
if (editorPane != null) {
copyProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES);
copyProperty(JEditorPane.W3C_LENGTH_UNITS);
}
}
protected void copyProperty(final String key) {
putClientProperty(key, editorPane.getClientProperty(key));
} }
public PropertyChangeListener getPropertyChangeListener() { public PropertyChangeListener getPropertyChangeListener() {

14
core/src/main/java/com/github/weisj/darklaf/ui/text/dummy/DummyEditorPaneUI.java

@ -27,8 +27,9 @@ package com.github.weisj.darklaf.ui.text.dummy;
import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeEvent;
import javax.swing.plaf.basic.BasicEditorPaneUI; import javax.swing.plaf.basic.BasicEditorPaneUI;
import javax.swing.text.JTextComponent;
public class DummyEditorPaneUI extends BasicEditorPaneUI { public class DummyEditorPaneUI extends BasicEditorPaneUI implements DummyTextUIMethods {
@Override @Override
protected void installDefaults() {} protected void installDefaults() {}
@ -42,12 +43,23 @@ public class DummyEditorPaneUI extends BasicEditorPaneUI {
@Override @Override
protected void installKeyboardActions() {} protected void installKeyboardActions() {}
@Override
public void installKeyBoardActionsReal() { public void installKeyBoardActionsReal() {
super.installKeyboardActions(); super.installKeyboardActions();
} }
@Override
public void installUI(final JTextComponent editor) {
super.installUI(editor);
}
@Override @Override
public void propertyChange(final PropertyChangeEvent evt) { public void propertyChange(final PropertyChangeEvent evt) {
super.propertyChange(evt); super.propertyChange(evt);
} }
@Override
public void uninstallUI(final JTextComponent editor) {
super.uninstallUI(editor);
}
} }

65
core/src/main/java/com/github/weisj/darklaf/ui/text/dummy/DummyTextPaneUI.java

@ -0,0 +1,65 @@
/*
* MIT License
*
* Copyright (c) 2020 Jannis Weis
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.weisj.darklaf.ui.text.dummy;
import java.beans.PropertyChangeEvent;
import javax.swing.plaf.basic.BasicTextPaneUI;
import javax.swing.text.JTextComponent;
public class DummyTextPaneUI extends BasicTextPaneUI implements DummyTextUIMethods {
@Override
protected void installDefaults() {}
@Override
protected void installListeners() {}
@Override
protected void modelChanged() {}
@Override
protected void installKeyboardActions() {}
@Override
public void installKeyBoardActionsReal() {
super.installKeyboardActions();
}
@Override
public void installUI(final JTextComponent editor) {
super.installUI(editor);
}
@Override
public void propertyChange(final PropertyChangeEvent evt) {
super.propertyChange(evt);
}
@Override
public void uninstallUI(final JTextComponent editor) {
super.uninstallUI(editor);
}
}

40
core/src/main/java/com/github/weisj/darklaf/ui/text/dummy/DummyTextUIMethods.java

@ -0,0 +1,40 @@
/*
* MIT License
*
* Copyright (c) 2020 Jannis Weis
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.weisj.darklaf.ui.text.dummy;
import java.beans.PropertyChangeEvent;
import javax.swing.text.JTextComponent;
public interface DummyTextUIMethods {
void installKeyBoardActionsReal();
void installUI(final JTextComponent editor);
void propertyChange(final PropertyChangeEvent event);
void uninstallUI(final JTextComponent editor);
}

9
core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/radiobutton/DarkRadioButtonUI.java

@ -165,13 +165,8 @@ public class DarkRadioButtonUI extends MetalRadioButtonUI implements PropertyCha
final Color disabledTextColor) { final Color disabledTextColor) {
g.setFont(b.getFont()); g.setFont(b.getFont());
g.setColor(b.isEnabled() ? b.getForeground() : disabledTextColor); g.setColor(b.isEnabled() ? b.getForeground() : disabledTextColor);
PaintUtil.drawString(g, b, text, textRect, fm, (g2, c2, rect, t) -> { int mnemIndex = b.isEnabled() ? b.getDisplayedMnemonicIndex() : -1;
int textX = rect.x; PaintUtil.drawStringUnderlineCharAt(g, b, text, mnemIndex, textRect, fm);
int textY = rect.y;
SwingUtilities2.drawStringUnderlineCharAt(b, g2, t,
b.getDisplayedMnemonicIndex(),
textX, textY);
});
} }
protected Icon getStateIcon(final AbstractButton b) { protected Icon getStateIcon(final AbstractButton b) {

8
core/src/main/java/com/github/weisj/darklaf/ui/tooltip/DarkToolTipUI.java

@ -36,8 +36,6 @@ import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicToolTipUI; import javax.swing.plaf.basic.BasicToolTipUI;
import javax.swing.text.View; import javax.swing.text.View;
import sun.swing.SwingUtilities2;
import com.github.weisj.darklaf.components.tooltip.ToolTipStyle; import com.github.weisj.darklaf.components.tooltip.ToolTipStyle;
import com.github.weisj.darklaf.graphics.Animator; import com.github.weisj.darklaf.graphics.Animator;
import com.github.weisj.darklaf.graphics.GraphicsContext; import com.github.weisj.darklaf.graphics.GraphicsContext;
@ -187,8 +185,6 @@ public class DarkToolTipUI extends BasicToolTipUI implements PropertyChangeListe
} }
protected void paintText(final Graphics g, final JComponent c) { protected void paintText(final Graphics g, final JComponent c) {
Font font = c.getFont();
FontMetrics metrics = SwingUtilities2.getFontMetrics(c, g, font);
Dimension size = c.getSize(); Dimension size = c.getSize();
g.setColor(c.getForeground()); g.setColor(c.getForeground());
@ -198,9 +194,7 @@ public class DarkToolTipUI extends BasicToolTipUI implements PropertyChangeListe
Rectangle paintTextR = new Rectangle(insets.left, insets.top, Rectangle paintTextR = new Rectangle(insets.left, insets.top,
size.width - (insets.left + insets.right), size.width - (insets.left + insets.right),
size.height - (insets.top + insets.bottom)); size.height - (insets.top + insets.bottom));
PaintUtil.drawString(g, c, tipText, paintTextR, metrics, (g2, c2, r, t) -> { PaintUtil.drawString(g, c, tipText, paintTextR);
SwingUtilities2.drawString(c, g, t, r.x, r.y);
});
} }
protected String getTipText(final JToolTip c) { protected String getTipText(final JToolTip c) {

1
core/src/main/resources/com/github/weisj/darklaf/properties/globals.properties

@ -52,6 +52,7 @@ ArrowButton.down.icon = navigation/arrowDown.svg[themed]
html.pendingImage = files/pendingImage.svg[themed](32,32) html.pendingImage = files/pendingImage.svg[themed](32,32)
html.missingImage = files/missingImage.svg[themed](32,32) html.missingImage = files/missingImage.svg[themed](32,32)
textInactiveText = %textForegroundInactive
link.foreground = %hyperlink link.foreground = %hyperlink
Hyperlink.linkColor = %hyperlink Hyperlink.linkColor = %hyperlink
swing.boldMetal = false swing.boldMetal = false

1
core/src/main/resources/com/github/weisj/darklaf/properties/ui/text.properties

@ -60,6 +60,7 @@ TextField.insets = 4,4,4,4
TextPane.selectionBackground = %textCompSelectionBackground TextPane.selectionBackground = %textCompSelectionBackground
TextPane.selectionForeground = %textCompSelectionForeground TextPane.selectionForeground = %textCompSelectionForeground
TextPane.background = %textBackground TextPane.background = %textBackground
TextPane.foreground = %textForeground
TextPane.disabledBackground = %textBackgroundInactive TextPane.disabledBackground = %textBackgroundInactive
TextPane.inactiveBackground = %textBackgroundInactive TextPane.inactiveBackground = %textBackgroundInactive
TextPane.border = com.github.weisj.darklaf.ui.text.DarkPlainTextBorder TextPane.border = com.github.weisj.darklaf.ui.text.DarkPlainTextBorder

2
core/src/test/java/defaults/SampleRenderer.java

@ -57,7 +57,7 @@ public class SampleRenderer extends JLabel implements TableCellRenderer {
setText(""); setText("");
if (sample instanceof Color) { if (sample instanceof Color) {
setBackground((Color) sample); setBackground(new Color(((Color) sample).getRGB()));
} else if (sample instanceof Border) { } else if (sample instanceof Border) {
setBorder((Border) sample); setBorder((Border) sample);
} else if (sample instanceof Font) { } else if (sample instanceof Font) {

1
core/src/test/java/ui/tabFrame/TabFrameDemo.java

@ -51,7 +51,6 @@ public class TabFrameDemo implements ComponentDemo {
NumberedTextComponent numberPane = new NumberedTextComponent(new NonWrappingTextPane() { NumberedTextComponent numberPane = new NumberedTextComponent(new NonWrappingTextPane() {
{ {
setText(StringUtil.repeat(DemoResources.LOREM_IPSUM, 10)); setText(StringUtil.repeat(DemoResources.LOREM_IPSUM, 10));
setFont(new Font(Font.MONOSPACED, Font.PLAIN, getFont().getSize()));
} }
}); });
NumberingPane numbering = numberPane.getNumberingPane(); NumberingPane numbering = numberPane.getNumberingPane();

Loading…
Cancel
Save