@ -1,5 +1,6 @@
package com.fr.van.chart.designer.type ;
import com.fr.base.BaseUtils ;
import com.fr.chart.base.AttrFillStyle ;
import com.fr.chart.chartattr.Chart ;
import com.fr.chart.chartattr.Legend ;
@ -7,13 +8,16 @@ import com.fr.chart.chartattr.Plot;
import com.fr.chart.chartglyph.ConditionAttr ;
import com.fr.chart.chartglyph.ConditionCollection ;
import com.fr.chart.chartglyph.DataSheet ;
import com.fr.chart.charttypes.ChartTypeManager ;
import com.fr.chartx.data.AbstractDataDefinition ;
import com.fr.chartx.data.ChartDataDefinitionProvider ;
import com.fr.chartx.data.field.AbstractColumnFieldCollection ;
import com.fr.chartx.data.field.diff.MultiCategoryColumnFieldCollection ;
import com.fr.design.ChartTypeInterfaceManager ;
import com.fr.design.gui.ibutton.UIButton ;
import com.fr.design.gui.icheckbox.UICheckBox ;
import com.fr.design.gui.ilable.MultilineLabel ;
import com.fr.design.i18n.Toolkit ;
import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane ;
import com.fr.design.mainframe.chart.gui.type.ChartImagePane ;
import com.fr.design.mainframe.chart.info.ChartInfoCollector ;
@ -25,21 +29,53 @@ import com.fr.plugin.chart.base.VanChartTools;
import com.fr.plugin.chart.base.VanChartZoom ;
import com.fr.plugin.chart.vanchart.VanChart ;
import javax.swing.BorderFactory ;
import javax.swing.JPanel ;
import java.awt.BorderLayout ;
import java.awt.Color ;
import java.awt.Component ;
import java.awt.Dimension ;
import java.awt.event.ActionListener ;
public abstract class AbstractVanChartTypePane extends AbstractChartTypePane < Chart > {
private static final long serialVersionUID = 7743244512351499265L ;
private UICheckBox largeModelCheckBox ;
protected JPanel buttonPane ;
protected UIButton autoButton ;
private boolean samePlot ;
protected boolean isSamePlot ( ) {
return samePlot ;
}
public AbstractVanChartTypePane ( ) {
buttonPane = new JPanel ( ) ;
buttonPane . setLayout ( new BorderLayout ( ) ) ;
if ( ChartTypeManager . AUTO_CHART ) {
autoButton = new UIButton ( Toolkit . i18nText ( "Fine-Design_Chart_Auto_Recommended_Chart" ) ,
BaseUtils . readIcon ( "/com/fr/design/images/m_insert/auto_chart.png" ) ) {
@Override
public Dimension getPreferredSize ( ) {
return new Dimension ( ( int ) super . getPreferredSize ( ) . getWidth ( ) , 25 ) ;
}
} ;
buttonPane . setBorder ( ( BorderFactory . createEmptyBorder ( 5 , 0 , 0 , 0 ) ) ) ;
buttonPane . add ( autoButton ) ;
}
}
@Override
protected Component [ ] [ ] getPaneComponents ( JPanel typePane ) {
return new Component [ ] [ ] {
new Component [ ] { typePane } ,
new Component [ ] { buttonPane } ,
new Component [ ] { stylePane } ,
} ;
}
//新图表暂时还没有平面3d,渐变高光等布局。
@Override
protected String [ ] getTypeLayoutPath ( ) {
@ -66,7 +102,7 @@ public abstract class AbstractVanChartTypePane extends AbstractChartTypePane<Cha
return getPlotID ( ) ;
}
protected Component [ ] [ ] getComponentsWithLargeData ( JPanel typePane ) {
protected Component [ ] [ ] getComponentsWithLargeData ( JPanel typePane ) {
largeModelCheckBox = new UICheckBox ( com . fr . design . i18n . Toolkit . i18nText ( "Fine-Design_Chart_Open_Large_Data_Model" ) ) ;
MultilineLabel prompt = new MultilineLabel ( com . fr . design . i18n . Toolkit . i18nText ( "Fine-Design_Chart_Large_Data_Model_Prompt" ) ) ;
prompt . setForeground ( Color . red ) ;
@ -84,7 +120,7 @@ public abstract class AbstractVanChartTypePane extends AbstractChartTypePane<Cha
* 更新界面内容
* /
public void populateBean ( Chart chart ) {
for ( ChartImagePane imagePane : typeDemo ) {
for ( ChartImagePane imagePane : typeDemo ) {
imagePane . isPressing = false ;
}
Plot plot = chart . getPlot ( ) ;
@ -100,13 +136,13 @@ public abstract class AbstractVanChartTypePane extends AbstractChartTypePane<Cha
VanChartPlot newPlot = getSelectedClonedPlot ( ) ;
checkTypeChange ( oldPlot ) ;
samePlot = accept ( chart ) ;
if ( typeChanged & & samePlot ) {
if ( typeChanged & & samePlot ) {
//同一中图表切换不同类型
cloneOldPlot2New ( oldPlot , newPlot ) ;
chart . setPlot ( newPlot ) ;
resetChartAttr4SamePlot ( chart ) ;
ChartInfoCollector . getInstance ( ) . updateChartMiniType ( chart ) ;
} else if ( ! samePlot ) {
} else if ( ! samePlot ) {
//不同的图表类型切換
resetChartAttr ( chart , newPlot ) ;
//切换图表时,数据配置不变,分类个数也不变
@ -114,55 +150,55 @@ public abstract class AbstractVanChartTypePane extends AbstractChartTypePane<Cha
//切换类型埋点
ChartInfoCollector . getInstance ( ) . updateChartTypeTime ( chart , oldPlot . getPlotID ( ) ) ;
}
if ( chart instanceof VanChart
if ( chart instanceof VanChart
& & ! acceptDefinition ( ( ( VanChart ) chart ) . getChartDataDefinition ( ) , newPlot ) ) {
( ( VanChart ) chart ) . setChartDataDefinition ( null ) ;
}
}
protected boolean acceptDefinition ( ChartDataDefinitionProvider definition , VanChartPlot vanChartPlot ) {
if ( definition instanceof AbstractDataDefinition ) {
if ( definition instanceof AbstractDataDefinition ) {
AbstractColumnFieldCollection columnFieldCollection = ( ( AbstractDataDefinition ) definition ) . getColumnFieldCollection ( ) ;
return columnFieldCollection instanceof MultiCategoryColumnFieldCollection ;
}
return false ;
}
protected void resetChartAttr4SamePlot ( Chart chart ) {
protected void resetChartAttr4SamePlot ( Chart chart ) {
resetRefreshMoreLabelAttr ( ( VanChart ) chart ) ;
}
protected void resetChartAttr ( Chart chart , Plot newPlot ) {
protected void resetChartAttr ( Chart chart , Plot newPlot ) {
chart . setPlot ( newPlot ) ;
if ( newPlot . isSupportZoomDirection ( ) & & ! newPlot . isSupportZoomCategoryAxis ( ) ) {
if ( newPlot . isSupportZoomDirection ( ) & & ! newPlot . isSupportZoomCategoryAxis ( ) ) {
//图表缩放新设计 恢复用注释。下面一行删除。
( ( VanChart ) chart ) . setVanChartZoom ( new VanChartZoom ( ) ) ;
//图表缩放新设计 恢复用注释。下面一行取消注释。
// ((VanChart) chart).setZoomAttribute(new ZoomAttribute());
}
//重置工具栏选项
( ( VanChart ) chart ) . setVanChartTools ( createVanChartTools ( ) ) ;
( ( VanChart ) chart ) . setVanChartTools ( createVanChartTools ( ) ) ;
//重置标题选项
resetTitleAttr ( chart ) ;
//重置监控刷新选项
resetRefreshMoreLabelAttr ( ( VanChart ) chart ) ;
resetRefreshMoreLabelAttr ( ( VanChart ) chart ) ;
resetFilterDefinition ( chart ) ;
}
//默认有标题
protected void resetTitleAttr ( Chart chart ) {
protected void resetTitleAttr ( Chart chart ) {
VanChartPlot vanChartPlot = ( VanChartPlot ) chart . getPlot ( ) ;
chart . setTitle ( vanChartPlot . getDefaultTitle ( ) ) ;
}
//重置数据配置
protected void resetFilterDefinition ( Chart chart ) {
protected void resetFilterDefinition ( Chart chart ) {
}
//重置监控刷新面板
protected void resetRefreshMoreLabelAttr ( VanChart chart ) {
protected void resetRefreshMoreLabelAttr ( VanChart chart ) {
chart . setRefreshMoreLabel ( chart . getDefaultAutoAttrtooltip ( chart ) ) ;
}
@ -170,9 +206,9 @@ public abstract class AbstractVanChartTypePane extends AbstractChartTypePane<Cha
return new VanChartTools ( ) ;
}
protected void checkTypeChange ( Plot oldPlot ) {
for ( int i = 0 ; i < typeDemo . size ( ) ; i + + ) {
if ( typeDemo . get ( i ) . isPressing & & i ! = oldPlot . getDetailType ( ) ) {
protected void checkTypeChange ( Plot oldPlot ) {
for ( int i = 0 ; i < typeDemo . size ( ) ; i + + ) {
if ( typeDemo . get ( i ) . isPressing & & i ! = oldPlot . getDetailType ( ) ) {
typeChanged = true ;
break ;
}
@ -193,15 +229,15 @@ public abstract class AbstractVanChartTypePane extends AbstractChartTypePane<Cha
cloneHotHyperLink ( oldPlot , newPlot ) ;
if ( oldPlot . getPlotFillStyle ( ) ! = null ) {
newPlot . setPlotFillStyle ( ( AttrFillStyle ) oldPlot . getPlotFillStyle ( ) . clone ( ) ) ;
newPlot . setPlotFillStyle ( ( AttrFillStyle ) oldPlot . getPlotFillStyle ( ) . clone ( ) ) ;
}
newPlot . setPlotStyle ( oldPlot . getPlotStyle ( ) ) ;
if ( oldPlot . getDataSheet ( ) ! = null ) {
newPlot . setDataSheet ( ( DataSheet ) oldPlot . getDataSheet ( ) . clone ( ) ) ;
newPlot . setDataSheet ( ( DataSheet ) oldPlot . getDataSheet ( ) . clone ( ) ) ;
}
if ( oldPlot . getBackground ( ) ! = null ) {
newPlot . setBackground ( ( Background ) oldPlot . getBackground ( ) . clone ( ) ) ;
newPlot . setBackground ( ( Background ) oldPlot . getBackground ( ) . clone ( ) ) ;
}
if ( oldPlot . getBorderColor ( ) ! = null ) {
newPlot . setBorderColor ( oldPlot . getBorderColor ( ) ) ;
@ -211,20 +247,20 @@ public abstract class AbstractVanChartTypePane extends AbstractChartTypePane<Cha
newPlot . setAlpha ( oldPlot . getAlpha ( ) ) ;
newPlot . setShadow ( oldPlot . isShadow ( ) ) ;
( ( VanChartPlot ) newPlot ) . setCategoryNum ( ( ( VanChartPlot ) oldPlot ) . getCategoryNum ( ) ) ;
( ( VanChartPlot ) newPlot ) . setCategoryNum ( ( ( VanChartPlot ) oldPlot ) . getCategoryNum ( ) ) ;
} catch ( CloneNotSupportedException e ) {
FineLoggerFactory . getLogger ( ) . error ( "Error in change plot" ) ;
}
}
protected void cloneHotHyperLink ( Plot oldPlot , Plot newPlot ) throws CloneNotSupportedException {
protected void cloneHotHyperLink ( Plot oldPlot , Plot newPlot ) throws CloneNotSupportedException {
if ( oldPlot . getHotHyperLink ( ) ! = null ) {
newPlot . setHotHyperLink ( ( NameJavaScriptGroup ) oldPlot . getHotHyperLink ( ) . clone ( ) ) ;
newPlot . setHotHyperLink ( ( NameJavaScriptGroup ) oldPlot . getHotHyperLink ( ) . clone ( ) ) ;
}
}
protected void cloneOldDefaultAttrConditionCollection ( Plot oldPlot , Plot newPlot ) throws CloneNotSupportedException {
protected void cloneOldDefaultAttrConditionCollection ( Plot oldPlot , Plot newPlot ) throws CloneNotSupportedException {
if ( oldPlot . getConditionCollection ( ) ! = null ) {
ConditionCollection newCondition = new ConditionCollection ( ) ;
newCondition . setDefaultAttr ( ( ConditionAttr ) oldPlot . getConditionCollection ( ) . getDefaultAttr ( ) . clone ( ) ) ;
@ -232,9 +268,16 @@ public abstract class AbstractVanChartTypePane extends AbstractChartTypePane<Cha
}
}
protected void cloneOldConditionCollection ( Plot oldPlot , Plot newPlot ) throws CloneNotSupportedException {
protected void cloneOldConditionCollection ( Plot oldPlot , Plot newPlot ) throws CloneNotSupportedException {
if ( oldPlot . getConditionCollection ( ) ! = null ) {
newPlot . setConditionCollection ( ( ConditionCollection ) oldPlot . getConditionCollection ( ) . clone ( ) ) ;
newPlot . setConditionCollection ( ( ConditionCollection ) oldPlot . getConditionCollection ( ) . clone ( ) ) ;
}
}
@Override
public void registerButtonListener ( ActionListener autoButtonListener ) {
if ( autoButton ! = null ) {
autoButton . addActionListener ( autoButtonListener ) ;
}
}
}