@ -12,7 +12,6 @@ import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory ;
import com.fr.design.mainframe.theme.TemplateThemePreviewPane ;
import com.fr.design.mainframe.theme.preview.ecpreview.ECComponentPreviewPane ;
import com.fr.design.utils.ComponentUtils ;
import com.fr.general.Background ;
import com.fr.log.FineLoggerFactory ;
import com.fr.plugin.chart.PiePlot4VanChart ;
@ -24,10 +23,10 @@ import com.fr.plugin.chart.type.RadiusType;
import com.fr.plugin.chart.vanchart.VanChart ;
import com.fr.stable.Constants ;
import com.fr.stable.StringUtils ;
import javax.swing.JComponent ;
import javax.swing.JPanel ;
import java.util.ArrayList ;
import java.awt.AlphaComposite ;
import java.awt.Composite ;
import java.awt.Graphics2D ;
import java.awt.BorderLayout ;
import java.awt.Color ;
import java.awt.Dimension ;
@ -44,6 +43,7 @@ public class FormThemePreviewPane extends TemplateThemePreviewPane<FormTheme> {
private Background background ;
private ChartComponentPreviewPane columnChartPreviewPane ;
private ChartComponentPreviewPane pieChartPreviewPane ;
private float alpha = 1 . 0F ;
public FormThemePreviewPane ( ) {
setLayout ( FRGUIPaneFactory . createBorderLayout ( ) ) ;
@ -72,9 +72,9 @@ public class FormThemePreviewPane extends TemplateThemePreviewPane<FormTheme> {
}
} ;
pieChartPanel . setLayout ( new BorderLayout ( ) ) ;
pieChartPreviewPane = createChartPreviewPane ( initPieChart ( ) , 300 , 368 ) ;
pieChartPreviewPane = createChartPreviewPane ( initPieChart ( ) , 217 , 368 ) ;
pieChartPanel . add ( pieChartPreviewPane , BorderLayout . CENTER ) ;
chartContent . add ( columnChartPanel , BorderLayout . WEST ) ;
chartContent . add ( columnChartPanel , BorderLayout . CENTER ) ;
chartContent . add ( pieChartPanel , BorderLayout . EAST ) ;
return chartContent ;
}
@ -89,6 +89,7 @@ public class FormThemePreviewPane extends TemplateThemePreviewPane<FormTheme> {
@Override
public void refresh ( FormTheme theme ) {
background = theme . getBodyStyle ( ) . getStyle ( ) . getBackground ( ) ;
alpha = theme . getBodyStyle ( ) . getStyle ( ) . getAlpha ( ) ;
elementCasePane . refresh ( theme ) ;
columnChartPreviewPane . refresh ( theme ) ;
pieChartPreviewPane . refresh ( theme ) ;
@ -96,18 +97,19 @@ public class FormThemePreviewPane extends TemplateThemePreviewPane<FormTheme> {
}
public void paint ( Graphics g ) {
// 禁止双缓冲
ArrayList < JComponent > dbcomponents = new ArrayList < JComponent > ( ) ;
@Override
public void paintComponent ( Graphics g ) {
paintBackground ( ( Graphics2D ) g ) ;
}
private void paintBackground ( Graphics2D g2d ) {
if ( background = = null ) {
background = ColorBackground . getInstance ( Color . WHITE ) ;
}
background . paint ( g , new Rectangle2D . Double ( 0 , 0 , 517 , 532 ) ) ;
paintChildren ( g ) ;
// 恢复双缓冲
ComponentUtils . resetBuffer ( dbcomponents ) ;
Composite oldComposite = g2d . getComposite ( ) ;
g2d . setComposite ( AlphaComposite . getInstance ( AlphaComposite . SRC_ATOP , alpha ) ) ;
background . paint ( g2d , new Rectangle2D . Double ( 0 , 0 , 517 , 532 ) ) ;
g2d . setComposite ( oldComposite ) ;
}
//柱形图