@ -12,13 +12,10 @@ import com.fr.design.utils.ComponentUtils;
import com.fr.general.Background ;
import com.fr.log.FineLoggerFactory ;
import com.fr.plugin.chart.attr.axis.VanChartAxis ;
import com.fr.plugin.chart.attr.plot.VanChartPlot ;
import com.fr.plugin.chart.base.AttrLabel ;
import com.fr.plugin.chart.base.VanChartTools ;
import com.fr.plugin.chart.column.VanChartColumnPlot ;
import com.fr.plugin.chart.line.VanChartLinePlot ;
import com.fr.plugin.chart.vanchart.VanChart ;
import com.fr.stable.Constants ;
import javax.swing.JComponent ;
import javax.swing.JPanel ;
@ -38,14 +35,9 @@ public class PredefinedStylePreviewPane extends StyleSettingPreviewPane implemen
private double scaleX = 1 . 0 ;
private double scaleY = 1 . 0 ;
private ChartPreStylePreView columnChartPane ;
private ChartPreStylePreView lineChartPane ;
private int COLUMN_CHART_WIDTH = 297 ;
private int COLUMN_CHART_HEIGHT = 220 ;
public static final double CHART_SCALE = 0 . 6 ;
private int COLUMN_CHART_WIDTH = 517 ;
private int COLUMN_CHART_HEIGHT = 300 ;
public PredefinedStylePreviewPane ( ) {
this ( 1 . 0 , 1 . 0 ) ;
@ -57,21 +49,17 @@ public class PredefinedStylePreviewPane extends StyleSettingPreviewPane implemen
this . setBackground ( Color . WHITE ) ;
this . elementCasePreview = new ElementCasePreview ( ) ;
this . add ( initChartPreViewPane ( ) ) ;
this . elementCasePreview . setPreferredSize ( new Dimension ( 517 , 25 0) ) ;
this . elementCasePreview . setPreferredSize ( new Dimension ( 517 , 19 0) ) ;
this . add ( this . elementCasePreview ) ;
}
private JPanel initChartPreViewPane ( ) {
columnChartPane = new ChartPreStylePreView ( initVanColumnChart ( ) , CHART_SCALE , CHART_SCALE ) ;
columnChartPane = new ChartPreStylePreView ( initVanColumnChart ( ) ) ;
columnChartPane . setPreferredSize ( new Dimension ( COLUMN_CHART_WIDTH , COLUMN_CHART_HEIGHT ) ) ;
columnChartPane . setCallbackEvent ( this ) ;
lineChartPane = new ChartPreStylePreView ( initVanLineChart ( ) , CHART_SCALE , CHART_SCALE ) ;
lineChartPane . setPreferredSize ( new Dimension ( 220 , 220 ) ) ;
lineChartPane . setCallbackEvent ( this ) ;
JPanel panel = FRGUIPaneFactory . createNormalFlowInnerContainer_S_Pane ( ) ;
panel . add ( columnChartPane ) ;
panel . add ( lineChartPane ) ;
return panel ;
}
@ -79,12 +67,11 @@ public class PredefinedStylePreviewPane extends StyleSettingPreviewPane implemen
private ChartCollection initVanColumnChart ( ) {
try {
VanChart chart = ( VanChart ) ChartTypeManager . getInstance ( ) . getCharts ( VanChartColumnPlot . VAN_CHART_COLUMN_PLOT_ID ) [ 0 ] . clone ( ) ;
chart . getTitle ( ) . setPosition ( Constants . LEFT ) ;
VanChartTools vanChartTools = chart . getVanChartTools ( ) ;
vanChartTools . setSort ( false ) ;
vanChartTools . setExport ( false ) ;
vanChartTools . setFullScreen ( false ) ;
VanChartPlot plot = chart . getPlot ( ) ;
VanChartColumn Plot plot = chart . getPlot ( ) ;
AttrLabel defaultAttrLabel = plot . getDefaultAttrLabel ( ) ;
defaultAttrLabel . setEnable ( true ) ;
defaultAttrLabel . getAttrLabelDetail ( ) . getBorder ( ) . setBorderStyle ( 0 ) ;
@ -92,30 +79,14 @@ public class PredefinedStylePreviewPane extends StyleSettingPreviewPane implemen
plot . getConditionCollection ( ) . getDefaultAttr ( ) . addDataSeriesCondition ( defaultAttrLabel ) ;
plot . getLegend ( ) . setLegendVisible ( false ) ;
plot . getDataSheet ( ) . setVisible ( true ) ;
ChartCollection chartCollection = new ChartCollection ( chart ) ;
return chartCollection ;
} catch ( Exception ex ) {
FineLoggerFactory . getLogger ( ) . error ( ex . getMessage ( ) , ex ) ;
}
return null ;
}
//折线图
private ChartCollection initVanLineChart ( ) {
try {
VanChart chart = ( VanChart ) ChartTypeManager . getInstance ( ) . getCharts ( VanChartLinePlot . VAN_CHART_LINE_PLOT ) [ 0 ] . clone ( ) ;
chart . getTitle ( ) . setPosition ( Constants . LEFT ) ;
VanChartTools vanChartTools = chart . getVanChartTools ( ) ;
vanChartTools . setSort ( false ) ;
vanChartTools . setExport ( false ) ;
vanChartTools . setFullScreen ( false ) ;
VanChartLinePlot plot = chart . getPlot ( ) ;
plot . getLegend ( ) . setPosition ( Constants . TOP ) ;
VanChartAxis defaultXAxis = plot . getDefaultXAxis ( ) ;
VanChartAxis defaultYAxis = plot . getDefaultYAxis ( ) ;
Title title = new Title ( ) ;
title . setTextObject ( Toolkit . i18nText ( "Fine-Design_Chart_Category" ) ) ;
defaultXAxis . setTitle ( title ) ;
defaultXAxis . setShowAxisTitle ( true ) ;
title . setTextObject ( Toolkit . i18nText ( "Fine-Design_Chart_Axis_Title" ) ) ;
title . getTextAttr ( ) . setRotation ( - 90 ) ;
defaultYAxis . setTitle ( title ) ;
defaultYAxis . setShowAxisTitle ( true ) ;
ChartCollection chartCollection = new ChartCollection ( chart ) ;
return chartCollection ;
} catch ( Exception ex ) {
@ -142,11 +113,9 @@ public class PredefinedStylePreviewPane extends StyleSettingPreviewPane implemen
background . paint ( g , new Rectangle2D . Double ( 0 , 0 , 517 , 500 ) ) ;
this . columnChartPane . paintComponent ( g ) ;
g . translate ( COLUMN_CHART_WIDTH , 0 ) ;
this . lineChartPane . paintComponent ( g ) ;
g . translate ( - COLUMN_CHART_WIDTH , COLUMN_CHART_HEIGHT + 10 ) ;
g . translate ( 0 , COLUMN_CHART_HEIGHT ) ;
this . elementCasePreview . paintContent ( g ) ;
g . translate ( 0 , - COLUMN_CHART_HEIGHT - 10 ) ;
g . translate ( 0 , - COLUMN_CHART_HEIGHT ) ;
// 恢复双缓冲
ComponentUtils . resetBuffer ( dbcomponents ) ;
@ -167,7 +136,6 @@ public class PredefinedStylePreviewPane extends StyleSettingPreviewPane implemen
public void refresh ( PredefinedStyle style , boolean displayFormBackground ) {
elementCasePreview . refresh ( style ) ;
columnChartPane . refresh ( style ) ;
lineChartPane . refresh ( style ) ;
background = displayFormBackground ? style . getFormBackground ( ) . getBackground ( ) : style . getReportBackground ( ) ;
this . repaint ( ) ;
}