@ -2,6 +2,7 @@ package com.fr.design.actions.replace.utils;
import com.fr.chart.base.DataSeriesCondition ;
import com.fr.chart.chartattr.ChartCollection ;
import com.fr.chart.chartattr.Plot ;
import com.fr.chart.chartglyph.ConditionAttr ;
import com.fr.chart.chartglyph.ConditionCollection ;
import com.fr.chart.web.ChartHyperPoplink ;
@ -22,9 +23,13 @@ import com.fr.plugin.chart.attr.plot.VanChartPlot;
import com.fr.plugin.chart.base.AttrLabel ;
import com.fr.plugin.chart.base.AttrTooltip ;
import com.fr.plugin.chart.base.VanChartHtmlLabel ;
import com.fr.plugin.chart.custom.CustomPlotFactory ;
import com.fr.plugin.chart.custom.VanChartCustomPlot ;
import com.fr.plugin.chart.custom.type.CustomPlotType ;
import com.fr.plugin.chart.map.VanChartMapPlot ;
import com.fr.plugin.chart.map.attr.AttrMapLabel ;
import com.fr.plugin.chart.map.attr.AttrMapTooltip ;
import com.fr.plugin.chart.type.MapType ;
import com.fr.plugin.chart.vanchart.VanChart ;
import com.fr.report.cell.Elem ;
import com.fr.stable.StringUtils ;
@ -119,14 +124,58 @@ public class SearchJSUtils {
for ( int i = 0 ; i < collection . getChartCount ( ) ; i + + ) {
if ( collection . getChart ( i ) instanceof VanChart ) {
VanChart chart = ( ( VanChart ) collection . getChart ( i ) ) ;
int size = chart . getPlot ( ) . getConditionCollection ( ) . getConditionAttrSize ( ) ;
ConditionCollection conditionCollection = chart . getPlot ( ) . getConditionCollection ( ) ;
//如果是组合图
if ( chart . getPlot ( ) instanceof VanChartCustomPlot ) {
VanChartCustomPlot plot = chart . getPlot ( ) ;
for ( VanChartPlot vanChartPlot : plot . getCustomPlotList ( ) ) {
dealPlotHtmlLabel ( arrayList , vanChartPlot ) ;
}
} else if ( chart . getPlot ( ) instanceof VanChartPlot ) {
dealPlotHtmlLabel ( arrayList , chart . getPlot ( ) ) ;
}
addAttrLabelHtmlLabel ( chart , arrayList ) ;
for ( int j = 0 ; j < size ; j + + ) {
searchConditionCollection ( arrayList , conditionCollection . getConditionAttr ( j ) ) ;
}
}
}
private static void dealPlotHtmlLabel ( List < Pair < VanChartHtmlLabel , String > > arrayList , VanChartPlot plot ) {
//如果是组合地图
if ( plot instanceof VanChartMapPlot ) {
dealMapPlotHtmlLabel ( arrayList , ( VanChartMapPlot ) plot ) ;
} else {
dealCommonPlotHtmlLabel ( arrayList , plot ) ;
}
}
private static void dealMapPlotHtmlLabel ( List < Pair < VanChartHtmlLabel , String > > arrayList , VanChartMapPlot plot ) {
ConditionCollection area = plot . getConditionCollection ( ) ;
ConditionCollection line = plot . getLineConditionCollection ( ) ;
ConditionCollection point = plot . getPointConditionCollection ( ) ;
dealMapCollectionHtmlLabel ( arrayList , area , Toolkit . i18nText ( "Fine-Design_Chart_Region_Map" ) ) ;
dealMapCollectionHtmlLabel ( arrayList , line , Toolkit . i18nText ( "Fine-Design_Chart_LineMap" ) ) ;
dealMapCollectionHtmlLabel ( arrayList , point , Toolkit . i18nText ( "Fine-Design_Chart_PointMap" ) ) ;
}
private static void dealMapCollectionHtmlLabel ( List < Pair < VanChartHtmlLabel , String > > arrayList , ConditionCollection collection , String i18nText ) {
for ( int i = 0 , size = collection . getConditionAttrSize ( ) ; i < size ; i + + ) {
searchConditionCollection ( arrayList , collection . getConditionAttr ( i ) , i18nText ) ;
}
}
private static void dealCommonPlotHtmlLabel ( List < Pair < VanChartHtmlLabel , String > > arrayList , VanChartPlot plot ) {
int size = plot . getConditionCollection ( ) . getConditionAttrSize ( ) ;
CustomPlotType plotType = CustomPlotFactory . getCustomType ( plot ) ;
ConditionCollection conditionCollection = plot . getConditionCollection ( ) ;
for ( int j = 0 ; j < size ; j + + ) {
if ( plotType ! = null ) {
searchConditionCollection ( arrayList , conditionCollection . getConditionAttr ( j ) , CustomPlotFactory . getTitle ( plotType ) ) ;
} else {
searchConditionCollection ( arrayList , conditionCollection . getConditionAttr ( j ) , StringUtils . EMPTY ) ;
}
}
}
/ * *
@ -140,15 +189,26 @@ public class SearchJSUtils {
//如果是地图类型要特殊处理
if ( plot instanceof VanChartMapPlot ) {
addMapJS2Array ( ( VanChartMapPlot ) plot , arrayList ) ;
} else if ( plot instanceof VanChartCustomPlot ) {
for ( VanChartPlot vanChartPlot : ( ( VanChartCustomPlot ) plot ) . getCustomPlotList ( ) ) {
CustomPlotType plotType = CustomPlotFactory . getCustomType ( vanChartPlot ) ;
dealAttrLabelHtml4VanChartPlot ( vanChartPlot , arrayList , CustomPlotFactory . getTitle ( plotType ) ) ;
}
} else {
addAttrToolTipCondition2Array ( plot , arrayList ) ;
if ( isAttrLabelExist ( plot ) ) {
addAttrLabelDetail2Array ( plot , arrayList ) ;
addAttrSecondLabelDetail2Array ( plot , arrayList ) ;
dealAttrLabelHtml4VanChartPlot ( plot , arrayList , StringUtils . EMPTY ) ;
}
}
private static void dealAttrLabelHtml4VanChartPlot ( VanChartPlot plot , List < Pair < VanChartHtmlLabel , String > > arrayList , String str ) {
addAttrToolTipCondition2Array ( plot , arrayList , str ) ;
if ( isAttrLabelExist ( plot ) ) {
addAttrLabelDetail2Array ( plot , arrayList , str ) ;
addAttrSecondLabelDetail2Array ( plot , arrayList , str ) ;
}
}
/ * *
* 用于处理地图类型图表中的样式中的JS ( AttrMapTooltip 与 AttrMapLabel )
*
@ -195,9 +255,9 @@ public class SearchJSUtils {
}
}
private static void addAttrToolTipCondition2Array ( VanChartPlot plot , List < Pair < VanChartHtmlLabel , String > > arrayList ) {
private static void addAttrToolTipCondition2Array ( VanChartPlot plot , List < Pair < VanChartHtmlLabel , String > > arrayList , String str ) {
if ( isToolTipValid ( plot . getAttrTooltipFromConditionCollection ( ) ) ) {
arrayList . add ( new Pair < > ( ( ( AttrTooltip ) plot . getAttrTooltipFromConditionCollection ( ) ) . getContent ( ) . getHtmlLabel ( ) , STYLE_TOOLTIP_CUSTOM ) ) ;
arrayList . add ( new Pair < > ( ( ( AttrTooltip ) plot . getAttrTooltipFromConditionCollection ( ) ) . getContent ( ) . getHtmlLabel ( ) , ShowValueUtils . getChartOtherPos ( S TYLE_TOOLTIP_CUSTOM , str ) ) ) ;
}
}
@ -205,9 +265,9 @@ public class SearchJSUtils {
return tooltip instanceof AttrTooltip & & ( ( AttrTooltip ) tooltip ) . isEnable ( ) & & ( ( AttrTooltip ) tooltip ) . getContent ( ) ! = null & & ( ( AttrTooltip ) tooltip ) . getContent ( ) . getHtmlLabel ( ) ! = null ;
}
private static void addAttrLabelDetail2Array ( VanChartPlot plot , List < Pair < VanChartHtmlLabel , String > > arrayList ) {
private static void addAttrLabelDetail2Array ( VanChartPlot plot , List < Pair < VanChartHtmlLabel , String > > arrayList , String str ) {
if ( isLabelDetailValid ( plot ) ) {
arrayList . add ( new Pair < > ( plot . getAttrLabelFromConditionCollection ( ) . getAttrLabelDetail ( ) . getContent ( ) . getHtmlLabel ( ) , STYLE_LABEL ) ) ;
arrayList . add ( new Pair < > ( plot . getAttrLabelFromConditionCollection ( ) . getAttrLabelDetail ( ) . getContent ( ) . getHtmlLabel ( ) , ShowValueUtils . getChartOtherPos ( S TYLE_LABEL , str ) ) ) ;
}
}
@ -217,9 +277,9 @@ public class SearchJSUtils {
& & plot . getAttrLabelFromConditionCollection ( ) . getAttrLabelDetail ( ) . getContent ( ) . getHtmlLabel ( ) ! = null ;
}
private static void addAttrSecondLabelDetail2Array ( VanChartPlot plot , List < Pair < VanChartHtmlLabel , String > > arrayList ) {
private static void addAttrSecondLabelDetail2Array ( VanChartPlot plot , List < Pair < VanChartHtmlLabel , String > > arrayList , String str ) {
if ( isSecondLabelDetailValid ( plot ) ) {
arrayList . add ( new Pair < > ( plot . getAttrLabelFromConditionCollection ( ) . getSecondLabelDetail ( ) . getContent ( ) . getHtmlLabel ( ) , CATEGORY_LABEL ) ) ;
arrayList . add ( new Pair < > ( plot . getAttrLabelFromConditionCollection ( ) . getSecondLabelDetail ( ) . getContent ( ) . getHtmlLabel ( ) , ShowValueUtils . getChartOtherPos ( CATEGORY_LABEL , str ) ) ) ;
}
}
@ -239,21 +299,22 @@ public class SearchJSUtils {
* @param arrayList
* @param conditionAttr
* /
private static void searchConditionCollection ( List < Pair < VanChartHtmlLabel , String > > arrayList , ConditionAttr conditionAttr ) {
private static void searchConditionCollection ( List < Pair < VanChartHtmlLabel , String > > arrayList , ConditionAttr conditionAttr , String name ) {
int conditionSize = conditionAttr . getDataSeriesConditionCount ( ) ;
for ( int t = 0 ; t < conditionSize ; t + + ) {
DataSeriesCondition condition = conditionAttr . getDataSeriesCondition ( t ) ;
String str = Toolkit . i18nText ( "Fine-Design_Chart_Animation_Special" ) + "-" + Toolkit . i18nText ( "Fine-Design_Chart_Condition_Display" ) ;
String str = ShowValueUtils . joinStr4Position ( Toolkit . i18nText ( "Fine-Design_Chart_Animation_Special" ) , Toolkit . i18nText ( "Fine-Design_Chart_Condition_Display" ) ) ;
if ( StringUtils . isNotEmpty ( conditionAttr . getName ( ) ) ) {
str + = "-" + conditionAttr . getName ( ) ;
str = ShowValueUtils . joinStr4Position ( str , conditionAttr . getName ( ) ) ;
}
str = ShowValueUtils . joinStr4Position ( str , name ) ;
if ( condition instanceof AttrTooltip ) {
arrayList . add ( new Pair < > ( ( ( AttrTooltip ) condition ) . getContent ( ) . getHtmlLabel ( ) , str + "-" + Toolkit . i18nText ( "Fine-Design_Chart_Data_Point_Tooltip" ) ) ) ;
arrayList . add ( new Pair < > ( ( ( AttrTooltip ) condition ) . getContent ( ) . getHtmlLabel ( ) , ShowValueUtils . joinStr4Position ( str , Toolkit . i18nText ( "Fine-Design_Chart_Data_Point_Tooltip" ) ) ) ) ;
}
if ( condition instanceof AttrLabel ) {
AttrLabel label = ( AttrLabel ) condition ;
if ( isAttrLabelValid ( label ) ) {
arrayList . add ( new Pair < > ( label . getContent ( ) . getHtmlLabel ( ) , str + "-" + Toolkit . i18nText ( "Fine-Design_Chart_Label" ) ) ) ;
arrayList . add ( new Pair < > ( label . getContent ( ) . getHtmlLabel ( ) , ShowValueUtils . joinStr4Position ( str , Toolkit . i18nText ( "Fine-Design_Chart_Label" ) ) ) ) ;
}
}
@ -270,18 +331,51 @@ public class SearchJSUtils {
* @param chartCollection
* @return
* /
public static List < NameJavaScript > getNameJavaScript ( ChartCollection chartCollection ) {
public static List < NameJavaScript > getNameJavaScript ( ChartCollection chartCollection , ITContent content , List < JSInfo > jsInfos ) {
ArrayList < NameJavaScript > nameJavaScriptArrayList = new ArrayList < > ( ) ;
for ( int i = 0 ; i < chartCollection . getChartCount ( ) ; i + + ) {
if ( chartCollection . getChart ( i ) instanceof VanChart ) {
VanChart chart = ( ( VanChart ) chartCollection . getChart ( i ) ) ;
if ( isCustomMapPlot ( chart . getPlot ( ) ) ) {
dealMapNameJavaScript ( content , chart . getPlot ( ) , jsInfos ) ;
} else {
NameJavaScriptGroup nameJavaScriptGroup = chart . getPlot ( ) . getHotHyperLink ( ) ;
addNameJavaScript2Array ( nameJavaScriptArrayList , nameJavaScriptGroup ) ;
}
}
}
return nameJavaScriptArrayList ;
}
/ * *
* 是否是组合地图
* @param plot 图表的plot
* @return 是则返回true
* /
public static boolean isCustomMapPlot ( Plot plot ) {
return plot instanceof VanChartMapPlot & & ( ( VanChartMapPlot ) plot ) . getMapType ( ) = = MapType . CUSTOM ;
}
/ * *
* 处理图表的交互属性 ( 可能存在多种地图 )
* @param content 存储信息的数据结构
* @param plot 图表的VanChartMapPlot
* /
private static void dealMapNameJavaScript ( ITContent content , VanChartMapPlot plot , List < JSInfo > jsInfos ) {
List < NameJavaScript > areaJavaScriptList = new ArrayList < > ( ) ;
List < NameJavaScript > lineJavaScriptList = new ArrayList < > ( ) ;
List < NameJavaScript > pointJavaScriptList = new ArrayList < > ( ) ;
addNameJavaScript2Array ( areaJavaScriptList , plot . getAreaHotHyperLink ( ) ) ;
addNameJavaScript2Array ( lineJavaScriptList , plot . getLineHotHyperLink ( ) ) ;
addNameJavaScript2Array ( pointJavaScriptList , plot . getPointHotHyperLink ( ) ) ;
addJSInfosFromNameJS ( ShowValueUtils . getCustomMapContent ( content , Toolkit . i18nText ( "Fine-Design_Chart_Region_Map" ) ) , areaJavaScriptList , jsInfos ) ;
addJSInfosFromNameJS ( ShowValueUtils . getCustomMapContent ( content , Toolkit . i18nText ( "Fine-Design_Chart_LineMap" ) ) , lineJavaScriptList , jsInfos ) ;
addJSInfosFromNameJS ( ShowValueUtils . getCustomMapContent ( content , Toolkit . i18nText ( "Fine-Design_Chart_PointMap" ) ) , pointJavaScriptList , jsInfos ) ;
}
private static void addNameJavaScript2Array ( List < NameJavaScript > nameJavaScriptArrayList , NameJavaScriptGroup nameJavaScriptGroup ) {
if ( isNameJavaScriptGroupExist ( nameJavaScriptGroup ) ) {
for ( int j = 0 ; j < nameJavaScriptGroup . size ( ) ; j + + ) {