|
|
@ -3,6 +3,8 @@ package com.fr.widgettheme.theme.panel; |
|
|
|
import com.fr.base.BaseUtils; |
|
|
|
import com.fr.base.BaseUtils; |
|
|
|
import com.fr.base.Style; |
|
|
|
import com.fr.base.Style; |
|
|
|
import com.fr.base.theme.TemplateTheme; |
|
|
|
import com.fr.base.theme.TemplateTheme; |
|
|
|
|
|
|
|
import com.fr.widgettheme.ThemePreviewTerminal; |
|
|
|
|
|
|
|
import com.fr.widgettheme.theme.widget.style.ThemeTextStyle; |
|
|
|
import com.fr.widgettheme.theme.widget.style.ThemedWidgetStyle; |
|
|
|
import com.fr.widgettheme.theme.widget.style.ThemedWidgetStyle; |
|
|
|
import com.fr.design.layout.FRGUIPaneFactory; |
|
|
|
import com.fr.design.layout.FRGUIPaneFactory; |
|
|
|
import com.fr.general.FRFont; |
|
|
|
import com.fr.general.FRFont; |
|
|
@ -14,7 +16,6 @@ import javax.swing.ImageIcon; |
|
|
|
import javax.swing.JPanel; |
|
|
|
import javax.swing.JPanel; |
|
|
|
import java.awt.Color; |
|
|
|
import java.awt.Color; |
|
|
|
import java.awt.Dimension; |
|
|
|
import java.awt.Dimension; |
|
|
|
import java.awt.Font; |
|
|
|
|
|
|
|
import java.awt.Graphics; |
|
|
|
import java.awt.Graphics; |
|
|
|
import java.awt.Graphics2D; |
|
|
|
import java.awt.Graphics2D; |
|
|
|
import java.awt.LayoutManager; |
|
|
|
import java.awt.LayoutManager; |
|
|
@ -39,6 +40,11 @@ public class ControlPreviewCell extends JPanel { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
protected String value; |
|
|
|
protected String value; |
|
|
|
protected TemplateTheme reportTheme; |
|
|
|
protected TemplateTheme reportTheme; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 主题预览类型,默认为PC端 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
protected ThemePreviewTerminal themePreviewTerminal = ThemePreviewTerminal.PC; |
|
|
|
/** |
|
|
|
/** |
|
|
|
* 字体的颜色 |
|
|
|
* 字体的颜色 |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -70,9 +76,10 @@ public class ControlPreviewCell extends JPanel { |
|
|
|
/** |
|
|
|
/** |
|
|
|
* 主题样式变化后监听改变 |
|
|
|
* 主题样式变化后监听改变 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void refresh(TemplateTheme reportTheme) { |
|
|
|
public void refresh(TemplateTheme reportTheme, ThemePreviewTerminal type) { |
|
|
|
this.reportTheme = reportTheme; |
|
|
|
this.reportTheme = reportTheme; |
|
|
|
ThemedWidgetStyle widgetStyle = (ThemedWidgetStyle) this.reportTheme.getWidgetStyle(); |
|
|
|
this.themePreviewTerminal = type; |
|
|
|
|
|
|
|
ThemedWidgetStyle widgetStyle = this.themePreviewTerminal.getThemeWidgetStyle(reportTheme); |
|
|
|
//主题色设置为透明或者插件启动前已有的主题启动插件后主题色为null
|
|
|
|
//主题色设置为透明或者插件启动前已有的主题启动插件后主题色为null
|
|
|
|
if (widgetStyle.getThemeColor() == null) { |
|
|
|
if (widgetStyle.getThemeColor() == null) { |
|
|
|
widgetStyle.setThemeColor(DEFAULT_THEME_COLOR); |
|
|
|
widgetStyle.setThemeColor(DEFAULT_THEME_COLOR); |
|
|
@ -87,8 +94,7 @@ public class ControlPreviewCell extends JPanel { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public Color getIconColor() { |
|
|
|
public Color getIconColor() { |
|
|
|
ThemedWidgetStyle widgetStyle = (ThemedWidgetStyle) reportTheme.getWidgetStyle(); |
|
|
|
return this.themePreviewTerminal.getThemeWidgetStyle(reportTheme).getIconColor(); |
|
|
|
return widgetStyle.getIconColor(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected Icon setStyleTwoIcon(Icon icon, Icon defaultIcon) { |
|
|
|
protected Icon setStyleTwoIcon(Icon icon, Icon defaultIcon) { |
|
|
@ -106,13 +112,15 @@ public class ControlPreviewCell extends JPanel { |
|
|
|
* 填充圆角矩形背景色 |
|
|
|
* 填充圆角矩形背景色 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void paintBgColor(Graphics g, ThemedWidgetStyle widgetStyle, int alpha) { |
|
|
|
public void paintBgColor(Graphics g, ThemedWidgetStyle widgetStyle, int alpha) { |
|
|
|
Color themeColor = widgetStyle.getWidgetBackground().getColor(); |
|
|
|
ThemedWidgetStyle themeWidgetStyle = this.themePreviewTerminal.getThemeWidgetStyle(this.reportTheme); |
|
|
|
|
|
|
|
Color themeColor = themeWidgetStyle.getThemeColor(); |
|
|
|
themeColor = themeColor == null ? WidgetThemeDisplayConstants.DEFAULT_TRANSPARENT_COLOR : themeColor; |
|
|
|
themeColor = themeColor == null ? WidgetThemeDisplayConstants.DEFAULT_TRANSPARENT_COLOR : themeColor; |
|
|
|
g.setColor(new Color(themeColor.getRed(), themeColor.getGreen(), themeColor.getBlue(), alpha)); |
|
|
|
g.setColor(new Color(themeColor.getRed(), themeColor.getGreen(), themeColor.getBlue(), alpha)); |
|
|
|
g.fillRoundRect(0, 0, getSize().width - 1, getSize().height - 1, (int) widgetStyle.getBorderStyle().getRadius(), (int) widgetStyle.getBorderStyle().getRadius()); |
|
|
|
g.fillRoundRect(0, 0, getSize().width - 1, getSize().height - 1, (int) widgetStyle.getBorderStyle().getRadius(), (int) widgetStyle.getBorderStyle().getRadius()); |
|
|
|
//需要重新绘制一遍字体,否则会被颜色填充给遮住
|
|
|
|
//需要重新绘制一遍字体,否则会被颜色填充给遮住
|
|
|
|
Graphics2D g2d = (Graphics2D) g.create(); |
|
|
|
Graphics2D g2d = (Graphics2D) g.create(); |
|
|
|
FRFont font = FRFont.getInstance(FRFont.DEFAULT_FONTNAME, Font.PLAIN, widgetStyle.getTextStyle().getFontSize(), textColor); |
|
|
|
ThemeTextStyle textStyle = themeWidgetStyle.getTextStyle(); |
|
|
|
|
|
|
|
FRFont font = FRFont.getInstance(textStyle.getName(), textStyle.getCompositeFontStyle(), textStyle.getFontSize(), textStyle.getFontColor()); |
|
|
|
BaseUtils.drawStringStyleInRotation(g2d, getWidth(), getHeight(), this.value, |
|
|
|
BaseUtils.drawStringStyleInRotation(g2d, getWidth(), getHeight(), this.value, |
|
|
|
Style.getInstance(font).deriveHorizontalAlignment(Constants.LEFT) |
|
|
|
Style.getInstance(font).deriveHorizontalAlignment(Constants.LEFT) |
|
|
|
.deriveTextStyle(Style.TEXTSTYLE_SINGLELINE), NO_SCALE_RESOLUTION); |
|
|
|
.deriveTextStyle(Style.TEXTSTYLE_SINGLELINE), NO_SCALE_RESOLUTION); |
|
|
@ -125,8 +133,8 @@ public class ControlPreviewCell extends JPanel { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
Graphics2D g2d = (Graphics2D) g.create(); |
|
|
|
Graphics2D g2d = (Graphics2D) g.create(); |
|
|
|
ThemedWidgetStyle widgetStyle = (ThemedWidgetStyle) reportTheme.getWidgetStyle(); |
|
|
|
ThemeTextStyle textStyle = this.themePreviewTerminal.getThemeWidgetStyle(reportTheme).getTextStyle(); |
|
|
|
FRFont font = FRFont.getInstance(FRFont.DEFAULT_FONTNAME, Font.PLAIN, widgetStyle.getTextStyle().getFontSize(), textColor); |
|
|
|
FRFont font = FRFont.getInstance(textStyle.getName(), textStyle.getCompositeFontStyle(), textStyle.getFontSize(), textStyle.getFontColor()); |
|
|
|
//每个预览格子通用的字体绘制
|
|
|
|
//每个预览格子通用的字体绘制
|
|
|
|
BaseUtils.drawStringStyleInRotation(g2d, getWidth(), getHeight(), this.value, |
|
|
|
BaseUtils.drawStringStyleInRotation(g2d, getWidth(), getHeight(), this.value, |
|
|
|
Style.getInstance(font).deriveHorizontalAlignment(Constants.LEFT) |
|
|
|
Style.getInstance(font).deriveHorizontalAlignment(Constants.LEFT) |
|
|
|