@ -51,14 +51,7 @@ public class CellStylePreviewPane extends JPanel {
}
}
private void paintTransparentBackground ( Graphics2D g2d , Style style ) {
private void paintTransparentBackground ( Graphics2D g2d , Style style ) {
Color fontColor = style . getFRFont ( ) . getForeground ( ) ;
float alpha = computeTransparentBackgroundAlpha ( style ) ;
float g = fontColor . getRed ( ) * 0 . 299F + fontColor . getGreen ( ) * 0 . 587F * fontColor . getBlue ( ) * 0 . 114F ;
float alpha = 1 . 0F ;
if ( g < 50 ) {
alpha = 0 . 2F ;
} else if ( g < 160 ) {
alpha = 0 . 5F ;
}
float scaleWidth = 1 . 0F * getWidth ( ) / transparentBackgroundWidth ;
float scaleWidth = 1 . 0F * getWidth ( ) / transparentBackgroundWidth ;
float scaleHeight = 1 . 0F * getHeight ( ) / transparentBackgroundHeight ;
float scaleHeight = 1 . 0F * getHeight ( ) / transparentBackgroundHeight ;
@ -76,6 +69,23 @@ public class CellStylePreviewPane extends JPanel {
g2d . setComposite ( oldComposite ) ;
g2d . setComposite ( oldComposite ) ;
}
}
private float computeTextColorBrightness ( Style style ) {
Color fontColor = style . getFRFont ( ) . getForeground ( ) ;
return fontColor . getRed ( ) * 0 . 299F + fontColor . getGreen ( ) * 0 . 587F + fontColor . getBlue ( ) * 0 . 114F ;
}
private float computeTransparentBackgroundAlpha ( Style style ) {
float textBrightness = computeTextColorBrightness ( style ) ;
float alpha = 1 . 0F ;
if ( textBrightness < 50 ) {
alpha = 0 . 2F ;
} else if ( textBrightness < 160 ) {
alpha = 0 . 5F ;
}
return alpha ;
}
private void paintCellStyle ( Graphics2D g2d , Style style ) {
private void paintCellStyle ( Graphics2D g2d , Style style ) {
int resolution = ScreenResolution . getScreenResolution ( ) ;
int resolution = ScreenResolution . getScreenResolution ( ) ;