|
|
|
@ -6,6 +6,9 @@ import com.fr.base.Style;
|
|
|
|
|
import com.fr.general.IOUtils; |
|
|
|
|
|
|
|
|
|
import javax.swing.JPanel; |
|
|
|
|
import java.awt.AlphaComposite; |
|
|
|
|
import java.awt.Color; |
|
|
|
|
import java.awt.Composite; |
|
|
|
|
import java.awt.Dimension; |
|
|
|
|
import java.awt.Graphics; |
|
|
|
|
import java.awt.Graphics2D; |
|
|
|
@ -40,10 +43,21 @@ public class CellStylePreviewPane extends JPanel {
|
|
|
|
|
@Override |
|
|
|
|
public void paint(Graphics g) { |
|
|
|
|
Graphics2D g2d = (Graphics2D) g; |
|
|
|
|
int resolution = ScreenResolution.getScreenResolution(); |
|
|
|
|
|
|
|
|
|
int width = getWidth(); |
|
|
|
|
int height = getHeight(); |
|
|
|
|
paintTransparentBackground(g2d, style); |
|
|
|
|
|
|
|
|
|
paintCellStyle(g2d, style); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void paintTransparentBackground(Graphics2D g2d, Style style) { |
|
|
|
|
Color fontColor = style.getFRFont().getForeground(); |
|
|
|
|
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 scaleHeight = 1.0F * getHeight() / transparentBackgroundHeight; |
|
|
|
@ -54,7 +68,18 @@ public class CellStylePreviewPane extends JPanel {
|
|
|
|
|
} else { |
|
|
|
|
scaleHeight = scaleWidth = maxScale; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Composite oldComposite = g2d.getComposite(); |
|
|
|
|
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, alpha)); |
|
|
|
|
g2d.drawImage(transparentBackgroundImage, 0, 0, (int) (transparentBackgroundWidth * scaleWidth), (int) (transparentBackgroundHeight * scaleHeight), null); |
|
|
|
|
g2d.setComposite(oldComposite); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void paintCellStyle(Graphics2D g2d, Style style) { |
|
|
|
|
int resolution = ScreenResolution.getScreenResolution(); |
|
|
|
|
|
|
|
|
|
int width = getWidth(); |
|
|
|
|
int height = getHeight(); |
|
|
|
|
|
|
|
|
|
if (style == Style.DEFAULT_STYLE) { |
|
|
|
|
// 如果是默认的style,就只写"Report"上去
|
|
|
|
|