always reset our graphics rendering hints

(this is usually not necessary because each component gets its own instance of Graphics when painting, but resetting may avoid side effects if our paint methods are invoked directly)
This commit is contained in:
Karl Tauber
2020-12-18 13:25:04 +01:00
parent 956001dbd7
commit 435068515a
10 changed files with 33 additions and 17 deletions

View File

@@ -180,7 +180,7 @@ public class FlatPaintingStringTest
@Override
protected void paintComponent( Graphics g ) {
Graphics2D g2 = (Graphics2D) g;
FlatUIUtils.setRenderingHints( g2 );
Object[] oldRenderingHints = FlatUIUtils.setRenderingHints( g2 );
// simulate component y position at a fraction
if( scaleFactor > 1 && SystemInfo.isJava_9_orLater )
@@ -241,6 +241,8 @@ public class FlatPaintingStringTest
double textY = t.getTranslateY() + (y * t.getScaleY());
setToolTipText( textY + " + " + yCorrection + " = " + (textY + yCorrection) );
}
FlatUIUtils.resetRenderingHints( g2, oldRenderingHints );
}
private int scale( int value ) {

View File

@@ -471,7 +471,7 @@ public class FlatPaintingTest
@Override
protected void paintComponent( Graphics g ) {
Graphics2D g2 = (Graphics2D) g;
FlatUIUtils.setRenderingHints( g2 );
Object[] oldRenderingHints = FlatUIUtils.setRenderingHints( g2 );
g2.scale( scale, scale );
g2.translate( 1, 1 );
@@ -503,6 +503,8 @@ public class FlatPaintingTest
g2d.setColor( Color.magenta );
g2d.drawRect( x2 - gap, y2 - gap, width2 + (gap * 2) - 1, height2 + (gap * 2) - 1 );
} );
FlatUIUtils.resetRenderingHints( g2, oldRenderingHints );
}
}
}