mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-06 14:00:55 +03:00
avoid painting text with our rendering hints enabled to avoid antialiased text in some components if text antialiasing is disabled in system (issue #227)
This commit is contained in:
@@ -21,6 +21,7 @@ import static com.formdev.flatlaf.FlatClientProperties.clientPropertyBoolean;
|
||||
import static com.formdev.flatlaf.util.UIScale.scale;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Font;
|
||||
import java.awt.FontMetrics;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
@@ -62,6 +63,8 @@ public class FlatJideTabbedPaneUI
|
||||
protected boolean hasFullBorder;
|
||||
protected boolean tabsOverlapBorder;
|
||||
|
||||
private Object[] oldRenderingHints;
|
||||
|
||||
public static ComponentUI createUI( JComponent c ) {
|
||||
return new FlatJideTabbedPaneUI();
|
||||
}
|
||||
@@ -193,9 +196,12 @@ public class FlatJideTabbedPaneUI
|
||||
|
||||
@Override
|
||||
public void update( Graphics g, JComponent c ) {
|
||||
FlatUIUtils.setRenderingHints( (Graphics2D) g );
|
||||
oldRenderingHints = FlatUIUtils.setRenderingHints( g );
|
||||
|
||||
super.update( g, c );
|
||||
|
||||
FlatUIUtils.resetRenderingHints( g, oldRenderingHints );
|
||||
oldRenderingHints = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -222,6 +228,15 @@ public class FlatJideTabbedPaneUI
|
||||
g.fillRect( x, y, w, h );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintText( Graphics g, int tabPlacement, Font font, FontMetrics metrics,
|
||||
int tabIndex, String title, Rectangle textRect, boolean isSelected )
|
||||
{
|
||||
FlatUIUtils.runWithoutRenderingHints( g, oldRenderingHints, () -> {
|
||||
super.paintText( g, tabPlacement, font, metrics, tabIndex, title, textRect, isSelected );
|
||||
} );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintTabBorder( Graphics g, int tabPlacement, int tabIndex, int x, int y, int w, int h,
|
||||
boolean isSelected )
|
||||
|
||||
@@ -60,6 +60,8 @@ public class FlatRangeSliderUI
|
||||
protected Color disabledThumbColor;
|
||||
protected Color disabledThumbBorderColor;
|
||||
|
||||
private Object[] oldRenderingHints;
|
||||
|
||||
public static ComponentUI createUI( JComponent c ) {
|
||||
return new FlatRangeSliderUI();
|
||||
}
|
||||
@@ -190,7 +192,7 @@ public class FlatRangeSliderUI
|
||||
|
||||
@Override
|
||||
public void paint( Graphics g, JComponent c ) {
|
||||
FlatUIUtils.setRenderingHints( (Graphics2D) g );
|
||||
oldRenderingHints = FlatUIUtils.setRenderingHints( g );
|
||||
|
||||
/*debug
|
||||
g.setColor( Color.gray );
|
||||
@@ -209,6 +211,16 @@ public class FlatRangeSliderUI
|
||||
debug*/
|
||||
|
||||
super.paint( g, c );
|
||||
|
||||
FlatUIUtils.resetRenderingHints( g, oldRenderingHints );
|
||||
oldRenderingHints = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paintLabels( Graphics g ) {
|
||||
FlatUIUtils.runWithoutRenderingHints( g, oldRenderingHints, () -> {
|
||||
super.paintLabels( g );
|
||||
} );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user