@ -2,21 +2,34 @@ package com.fr.design.actions.replace.action.content.formula.chart;
import com.fr.base.Formula ;
import com.fr.base.chart.chartdata.TopDefinitionProvider ;
import com.fr.base.present.DictPresent ;
import com.fr.base.present.FormulaPresent ;
import com.fr.base.present.Present ;
import com.fr.chart.base.AttrChangeConfig ;
import com.fr.chart.chartattr.Axis ;
import com.fr.chart.chartattr.Chart ;
import com.fr.chart.chartattr.ChartCollection ;
import com.fr.chart.chartattr.SwitchTitle ;
import com.fr.chart.chartattr.Title ;
import com.fr.chart.chartdata.NormalReportDataDefinition ;
import com.fr.chart.chartdata.SeriesDefinition ;
import com.fr.design.actions.replace.action.content.formula.highlight.javascript.SearchJSHighlightAction ;
import com.fr.design.actions.replace.action.content.formula.widget.DictionaryType ;
import com.fr.design.actions.replace.info.CellInfo ;
import com.fr.design.actions.replace.info.FormulaInfo ;
import com.fr.design.actions.replace.info.JSInfo ;
import com.fr.design.actions.replace.info.base.ITContent ;
import com.fr.design.i18n.Toolkit ;
import com.fr.js.NameJavaScript ;
import com.fr.js.NameJavaScriptGroup ;
import com.fr.plugin.chart.attr.axis.VanChartAlertValue ;
import com.fr.plugin.chart.attr.axis.VanChartAxis ;
import com.fr.plugin.chart.attr.axis.VanChartValueAxis ;
import com.fr.report.cell.TemplateCellElement ;
import com.fr.stable.StringUtils ;
import java.util.List ;
import java.util.Map ;
@ -44,7 +57,12 @@ public class SearchChartCollectionFormulaAction {
for ( int i = 0 ; i < chartCollection . getChartCount ( ) ; i + + ) {
ITContent chartContent = ITContent . copy ( content ) ;
searchChartPatternFormula ( formulaInfos , chartContent , chartCollection . getChart ( i ) ) ;
if ( isChangeConfigAttrValid ( chartCollection . getChangeConfigAttr ( ) ) ) {
//图表切换属性
dealChangeConfig ( formulaInfos , chartContent , chartCollection . getChart ( i ) ) ;
}
//图表-交互属性-超级链接
dealChartHyperLink ( formulaInfos , chartContent , chartCollection . getChart ( i ) ) ;
//数据-单元格数据-分类名&系列名&值
SearchChartDataFormulaManager searchChartDataFormulaManager = SearchChartDataFormulaManager . getInstance ( ) ;
Map < String , SearchChartDataFormula > type = searchChartDataFormulaManager . getChartDataType ( ) ;
@ -56,9 +74,94 @@ public class SearchChartCollectionFormulaAction {
dataContent . addOtherPos ( chartCollection . getChart ( i ) . getChartName ( ) , Toolkit . i18nText ( "Fine-Design_Basic_Data" ) ) ;
searchChartDataFormula . searchChartDataFormula ( formulaInfos , dataContent , provider ) ;
}
//数据-形态
if ( chartCollection . getChart ( i ) . getFilterDefinition ( ) ! = null ) {
ITContent presentContent = ITContent . copy ( content ) ;
presentContent . addOtherPos ( chartCollection . getChart ( i ) . getChartName ( ) , Toolkit . i18nText ( "Fine-Design_Basic_Data" ) ) ;
searchFormulaFromChartPresent ( formulaInfos , presentContent , chartCollection . getChart ( i ) . getFilterDefinition ( ) ) ;
}
}
}
private void dealChartHyperLink ( List < FormulaInfo > formulaInfos , ITContent content , Chart chart ) {
ITContent conditionContent = ITContent . copy ( content ) ;
if ( StringUtils . isNotEmpty ( chart . getChartName ( ) ) ) {
conditionContent . addOtherPos ( chart . getChartName ( ) ) ;
}
conditionContent . addOtherPos (
Toolkit . i18nText ( "Fine-Design_Chart_Animation_Special" ) ,
Toolkit . i18nText ( "Fine-Design_Chart_Interactive" )
) ;
if ( chart . getPlot ( ) ! = null ) {
NameJavaScriptGroup javaScriptGroup = chart . getPlot ( ) . getHotHyperLink ( ) ;
if ( javaScriptGroup ! = null ) {
for ( int i = 0 ; i < javaScriptGroup . size ( ) ; i + + ) {
NameJavaScript javaScript = javaScriptGroup . getNameHyperlink ( i ) ;
conditionContent . addOtherPos ( javaScript . getName ( ) ) ;
SearchJSHighlightAction action = SearchJSHighlightAction . getInstance ( ) ;
action . searchJSFormulaFromOther ( formulaInfos , conditionContent , javaScript . getJavaScript ( ) ) ;
}
}
}
}
private void searchFormulaFromChartPresent ( List < FormulaInfo > formulaInfos , ITContent content , TopDefinitionProvider provider ) {
searchPresent4Formula ( provider . getCategoryPresent ( ) , content , formulaInfos ) ;
searchPresent4Formula ( provider . getSeriesPresent ( ) , content , formulaInfos ) ;
}
private void searchPresent4Formula ( Present present , ITContent content , List < FormulaInfo > formulaInfos ) {
if ( present instanceof FormulaPresent ) {
ITContent newContent = ITContent . copy ( content ) ;
newContent . setReplaceObject ( present ) ;
newContent . addOtherPos (
Toolkit . i18nText ( "Fine-Design_Chart_Style_Present" ) ,
Toolkit . i18nText ( "Fine-Design_Basic_Present_Formula_Present" ) ) ;
formulaInfos . add ( new FormulaInfo ( newContent ) ) ;
}
if ( present instanceof DictPresent ) {
ITContent dictContent = ITContent . copy ( content ) ;
dictContent . addOtherPos (
Toolkit . i18nText ( "Fine-Design_Chart_Style_Present" ) ,
Toolkit . i18nText ( "Fine-Design_Basic_DS_Dictionary" )
) ;
DictPresent dictPresent = ( DictPresent ) present ;
if ( dictPresent . getDictionary ( ) ! = null ) {
DictionaryType type = DictionaryType . match ( dictPresent . getDictionary ( ) . getClass ( ) . getSimpleName ( ) ) ;
if ( type ! = null ) {
type . searchFormulaFromDictionary ( dictContent , formulaInfos , dictPresent . getDictionary ( ) ) ;
}
}
}
}
private boolean isChangeConfigAttrValid ( AttrChangeConfig attrChangeConfig ) {
return attrChangeConfig ! = null & & attrChangeConfig . isEnable ( ) ;
}
private void dealChangeConfig ( List < FormulaInfo > formulaInfos , ITContent chartContent , Chart chart ) {
ITContent content = ITContent . copy ( chartContent ) ;
if ( StringUtils . isNotEmpty ( chart . getChartName ( ) ) ) {
content . addOtherPos ( chart . getChartName ( ) ) ;
}
content . addOtherPos (
Toolkit . i18nText ( "Fine-Design_Chart_Type" ) ,
Toolkit . i18nText ( "Fine-Design_Chart_Change_Config_Attributes" )
) ;
if ( isSwitchTitleValid ( chart . getSwitchTitle ( ) ) ) {
SwitchTitle title = chart . getSwitchTitle ( ) ;
content . setReplaceObject ( title . getContent ( ) ) ;
formulaInfos . add ( new FormulaInfo ( content ) ) ;
}
}
private boolean isSwitchTitleValid ( SwitchTitle title ) {
return title ! = null & & title . getContent ( ) instanceof Formula ;
}
private boolean isDefinitionValid ( TopDefinitionProvider provider ) {
return provider ! = null & & SearchChartDataFormulaManager . getInstance ( ) . getChartDataType ( ) . containsKey ( provider . getClass ( ) . getSimpleName ( ) ) ;
}
@ -76,7 +179,7 @@ public class SearchChartCollectionFormulaAction {
}
private void searchChartPatternFormulaFromAlertLine ( List < FormulaInfo > formulaInfos , ITContent chartContent , Chart chart ) {
if ( chart . getPlot ( ) ! = null ) {
if ( chart . getPlot ( ) ! = null ) {
Axis xAxis = chart . getPlot ( ) . getxAxis ( ) ;
Axis yAxis = chart . getPlot ( ) . getyAxis ( ) ;
ITContent content = ITContent . copy ( chartContent ) ;
@ -128,7 +231,7 @@ public class SearchChartCollectionFormulaAction {
}
private void searchChartPatternFormulaFromAxisValue ( List < FormulaInfo > formulaInfos , ITContent chartContent , Chart chart ) {
if ( chart . getPlot ( ) ! = null ) {
if ( chart . getPlot ( ) ! = null ) {
Axis xAxis = chart . getPlot ( ) . getxAxis ( ) ;
Axis yAxis = chart . getPlot ( ) . getyAxis ( ) ;
//样式-坐标轴-x轴