|
|
@ -36,6 +36,7 @@ import javax.swing.*; |
|
|
|
import javax.swing.event.ChangeEvent; |
|
|
|
import javax.swing.event.ChangeEvent; |
|
|
|
import javax.swing.event.ChangeListener; |
|
|
|
import javax.swing.event.ChangeListener; |
|
|
|
import javax.swing.plaf.ComponentUI; |
|
|
|
import javax.swing.plaf.ComponentUI; |
|
|
|
|
|
|
|
import javax.swing.plaf.UIResource; |
|
|
|
import javax.swing.text.*; |
|
|
|
import javax.swing.text.*; |
|
|
|
|
|
|
|
|
|
|
|
import com.github.weisj.darklaf.components.text.IconListener; |
|
|
|
import com.github.weisj.darklaf.components.text.IconListener; |
|
|
@ -190,7 +191,7 @@ public class DarkNumberingPaneUI extends ComponentUI { |
|
|
|
GraphicsContext config = GraphicsUtil.setupAntialiasing(g); |
|
|
|
GraphicsContext config = GraphicsUtil.setupAntialiasing(g); |
|
|
|
g.setColor(numberingPane.getForeground()); |
|
|
|
g.setColor(numberingPane.getForeground()); |
|
|
|
|
|
|
|
|
|
|
|
Font font = getNumberingFont(numberingPane.getTextComponent(), g); |
|
|
|
Font font = getNumberingFont(numberingPane.getTextComponent(), g, numberingPane.getFont()); |
|
|
|
g.setFont(font); |
|
|
|
g.setFont(font); |
|
|
|
FontMetrics fm = numberingPane.getFontMetrics(font); |
|
|
|
FontMetrics fm = numberingPane.getFontMetrics(font); |
|
|
|
|
|
|
|
|
|
|
@ -201,7 +202,7 @@ public class DarkNumberingPaneUI extends ComponentUI { |
|
|
|
String numberStr = String.valueOf(i); |
|
|
|
String numberStr = String.valueOf(i); |
|
|
|
Rectangle lineRect = textComponent.modelToView(off); |
|
|
|
Rectangle lineRect = textComponent.modelToView(off); |
|
|
|
g.setColor(lineRect.y == yCur ? foregroundHighlight : numberingPane.getForeground()); |
|
|
|
g.setColor(lineRect.y == yCur ? foregroundHighlight : numberingPane.getForeground()); |
|
|
|
g.drawString(numberStr, width - OUTER_PAD - fm.stringWidth(numberStr), |
|
|
|
g.drawString(numberStr, width - OUTER_PAD - fm.stringWidth(numberStr) - maxIconWidth, |
|
|
|
lineRect.y + lineRect.height - descent); |
|
|
|
lineRect.y + lineRect.height - descent); |
|
|
|
} catch (final BadLocationException ignored) { |
|
|
|
} catch (final BadLocationException ignored) { |
|
|
|
} |
|
|
|
} |
|
|
@ -209,12 +210,15 @@ public class DarkNumberingPaneUI extends ComponentUI { |
|
|
|
config.restore(); |
|
|
|
config.restore(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private Font getNumberingFont(final JComponent c, final Graphics g) { |
|
|
|
private Font getNumberingFont(final JComponent c, final Graphics g, final Font f) { |
|
|
|
Font font = c.getFont(); |
|
|
|
Font baseFont = c.getFont(); |
|
|
|
if (font != null) { |
|
|
|
Font font = f; |
|
|
|
float newSize = (float) font.getSize() - 1; |
|
|
|
if (font instanceof UIResource) { |
|
|
|
|
|
|
|
int newSize = baseFont.getSize() - 1; |
|
|
|
if (newSize > 0) { |
|
|
|
if (newSize > 0) { |
|
|
|
font = font.deriveFont(newSize); |
|
|
|
font = font.deriveFont((float) newSize); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
font = font.deriveFont(baseFont.getSize2D()); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
font = g.getFont(); |
|
|
|
font = g.getFont(); |
|
|
@ -355,9 +359,6 @@ public class DarkNumberingPaneUI extends ComponentUI { |
|
|
|
((Caret) newCaret).addChangeListener(currentLinePainter); |
|
|
|
((Caret) newCaret).addChangeListener(currentLinePainter); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} else if (PropertyKey.FONT.equals(key)) { |
|
|
|
|
|
|
|
Font font = textComponent.getFont(); |
|
|
|
|
|
|
|
numberingPane.setFont(font.deriveFont(Math.max(font.getSize() - 1, 1.0f))); |
|
|
|
|
|
|
|
} else if (NumberingPane.KEY_EDITOR.equals(key)) { |
|
|
|
} else if (NumberingPane.KEY_EDITOR.equals(key)) { |
|
|
|
Object newPane = evt.getNewValue(); |
|
|
|
Object newPane = evt.getNewValue(); |
|
|
|
if (textComponent != null) { |
|
|
|
if (textComponent != null) { |
|
|
@ -378,8 +379,6 @@ public class DarkNumberingPaneUI extends ComponentUI { |
|
|
|
} |
|
|
|
} |
|
|
|
textComponent.addPropertyChangeListener(getPropertyChangeListener()); |
|
|
|
textComponent.addPropertyChangeListener(getPropertyChangeListener()); |
|
|
|
textComponent.getCaret().addChangeListener(getChangeListener()); |
|
|
|
textComponent.getCaret().addChangeListener(getChangeListener()); |
|
|
|
Font font = textComponent.getFont(); |
|
|
|
|
|
|
|
numberingPane.setFont(font.deriveFont(Math.max(font.getSize() - 1, 1.0f))); |
|
|
|
|
|
|
|
oldBackground = textComponent.getBackground(); |
|
|
|
oldBackground = textComponent.getBackground(); |
|
|
|
textComponent.setBackground(UIManager.getColor("NumberingPane.textBackground")); |
|
|
|
textComponent.setBackground(UIManager.getColor("NumberingPane.textBackground")); |
|
|
|
} |
|
|
|
} |
|
|
|