@ -8,7 +8,6 @@ import com.fr.chart.fun.ChartTypeProvider;
import com.fr.chartx.attr.ChartProvider ;
import com.fr.common.annotations.Compatible ;
import com.fr.design.beans.BasicBeanPane ;
import com.fr.design.beans.FurtherBasicBeanPane ;
import com.fr.design.chart.fun.ChartTypeUIProvider ;
import com.fr.design.chart.gui.ChartWidgetOption ;
import com.fr.design.condition.ConditionAttributesPane ;
@ -46,7 +45,6 @@ import com.fr.general.GeneralContext;
import com.fr.general.IOUtils ;
import com.fr.invoke.Reflect ;
import com.fr.locale.InterProviderFactory ;
import com.fr.log.FineLoggerFactory ;
import com.fr.plugin.chart.PiePlot4VanChart ;
import com.fr.plugin.chart.area.VanChartAreaPlot ;
import com.fr.plugin.chart.box.VanChartBoxPlot ;
@ -75,7 +73,6 @@ import com.fr.plugin.observer.PluginEvent;
import com.fr.plugin.observer.PluginEventListener ;
import com.fr.plugin.solution.closeable.CloseableContainedMap ;
import com.fr.stable.ArrayUtils ;
import com.fr.stable.AssistUtils ;
import com.fr.stable.StringUtils ;
import com.fr.stable.plugin.ExtraChartDesignClassManagerProvider ;
import com.fr.van.chart.area.AreaIndependentVanChartInterface ;
@ -100,17 +97,7 @@ import com.fr.van.chart.treemap.TreeMapIndependentVanChartInterface;
import com.fr.van.chart.wordcloud.designer.WordCloudIndependentVanChartInterface ;
import javax.swing.Icon ;
import java.util.ArrayList ;
import java.util.HashMap ;
import java.util.Iterator ;
import java.util.LinkedHashMap ;
import java.util.List ;
import java.util.Map ;
import java.awt.event.ActionListener ;
import static com.fr.chart.charttypes.ChartTypeManager.DEFAULT_PRIORITY ;
import static com.fr.chart.charttypes.ChartTypeManager.DEPRECATED_CHART_PRIORITY ;
import static com.fr.chart.charttypes.ChartTypeManager.VAN_CHART_PRIORITY ;
/ * *
* Created by eason on 14 / 12 / 29 .
@ -120,10 +107,7 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr
private static ChartTypeInterfaceManager classManager = new ChartTypeInterfaceManager ( ) ;
private static LinkedHashMap < String , CloseableContainedMap < String , ChartTypeUIProvider , LinkedHashMap > > chartTypeInterfaces =
new LinkedHashMap < String , CloseableContainedMap < String , ChartTypeUIProvider , LinkedHashMap > > ( ) ;
private static Map < String , String > idAndPriorityMap = new HashMap < String , String > ( ) ;
private static CloseableContainedMap < String , ChartTypeUIProvider , HashMap > chartTypeUIs = new CloseableContainedMap < > ( HashMap . class ) ;
public static final String TYPE_PANE_DEFAULT_TITLE = "DEFAULT_NAME" ;
@ -185,127 +169,69 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr
private static void readVanChart ( ) {
addChartTypeInterface ( VAN_CHART_PRIORITY , PiePlot4VanChart . VAN_CHART_PIE_PLOT , new PieIndependentVanChartInterface ( ) ) ;
addChartTypeInterface ( VAN_CHART_PRIORITY , V anChartColumnPlot . VAN_CHART_COLUMN_PLOT_ID , new VanColumnChartTypeUI ( ) ) ;
addChartTypeInterface ( VAN_CHART_PRIORITY , V anChartColumnPlot . VAN_CHART_BAR_PLOT_ID , new BarIndependentVanChartInterface ( ) ) ;
addChartTypeInterface ( VAN_CHART_PRIORITY , V anChartLinePlot . VAN_CHART_LINE_PLOT , new LineIndependentVanChartInterface ( ) ) ;
addChartTypeInterface ( VAN_CHART_PRIORITY , V anChartAreaPlot . VAN_CHART_AREA_PLOT_ID , new AreaIndependentVanChartInterface ( ) ) ;
addChartTypeInterface ( VAN_CHART_PRIORITY , V anChartGaugePlot . VAN_CHART_GAUGE_PLOT , new GaugeIndependentVanChartInterface ( ) ) ;
addChartTypeInterface ( VAN_CHART_PRIORITY , V anChartRadarPlot . VAN_CHART_RADAR_PLOT , new RadarIndependentVanChartInterface ( ) ) ;
addChartTypeInterface ( VAN_CHART_PRIORITY , V anChartScatterPlot . VAN_CHART_SCATTER_PLOT_ID , new ScatterIndependentVanChartInterface ( ) ) ;
addChartTypeInterface ( VAN_CHART_PRIORITY , V anChartBubblePlot . VAN_CHART_BUBBLE_PLOT_ID , new BubbleIndependentVanChartInterface ( ) ) ;
addChartTypeInterface ( VAN_CHART_PRIORITY , V anChartCustomPlot . VAN_CHART_CUSTOM_PLOT_ID , new CustomIndependentVanChartInterface ( ) ) ;
addChartTypeInterface ( VAN_CHART_PRIORITY , V anChartMultiPiePlot . VAN_CHART_MULTILAYER_PLOT_ID , new MultiPieIndependentVanChartInterface ( ) ) ;
addChartTypeInterface ( VAN_CHART_PRIORITY , V anChartMapPlot . VAN_CHART_MAP_ID , new VanMapChartTypeUI ( ) ) ;
addChartTypeInterface ( VAN_CHART_PRIORITY , V anChartDrillMapPlot . VAN_CHART_DRILL_MAP_ID , new VanDrillMapChartTypeUI ( ) ) ;
addChartTypeInterface ( VAN_CHART_PRIORITY , V anChartTreeMapPlot . VAN_CHART_TREE_MAP_PLOT_ID , new TreeMapIndependentVanChartInterface ( ) ) ;
addChartTypeInterface ( VAN_CHART_PRIORITY , V anChartFunnelPlot . VAN_CHART_FUNNEL_PLOT_ID , new FunnelIndependentVanChartInterface ( ) ) ;
addChartTypeInterface ( VAN_CHART_PRIORITY , V anChartHeatMapPlot . VAN_CHART_HEAT_MAP_ID , new VanHeatMapChartTypeUI ( ) ) ;
addChartTypeInterface ( VAN_CHART_PRIORITY , V anChartWordCloudPlot . WORD_CLOUD_PLOT_ID , new WordCloudIndependentVanChartInterface ( ) ) ;
addChartTypeInterface ( VAN_CHART_PRIORITY , V anChartGanttPlot . VAN_CHART_GANTT_PLOT_ID , new GanttIndependentVanChartInterface ( ) ) ;
addChartTypeInterface ( VAN_CHART_PRIORITY , V anChartStructurePlot . STRUCTURE_PLOT_ID , new VanStructureChartTypeUI ( ) ) ;
addChartTypeInterface ( VAN_CHART_PRIORITY , V anChartBoxPlot . VAN_CHART_BOX_PLOT_ID , new BoxIndependentVanChartInterface ( ) ) ;
addChartTypeInterface ( PiePlot4VanChart . VAN_CHART_PIE_PLOT , new PieIndependentVanChartInterface ( ) ) ;
addChartTypeInterface ( VanChartColumnPlot . VAN_CHART_COLUMN_PLOT_ID , new VanColumnChartTypeUI ( ) ) ;
addChartTypeInterface ( VanChartColumnPlot . VAN_CHART_BAR_PLOT_ID , new BarIndependentVanChartInterface ( ) ) ;
addChartTypeInterface ( VanChartLinePlot . VAN_CHART_LINE_PLOT , new LineIndependentVanChartInterface ( ) ) ;
addChartTypeInterface ( VanChartAreaPlot . VAN_CHART_AREA_PLOT_ID , new AreaIndependentVanChartInterface ( ) ) ;
addChartTypeInterface ( VanChartGaugePlot . VAN_CHART_GAUGE_PLOT , new GaugeIndependentVanChartInterface ( ) ) ;
addChartTypeInterface ( VanChartRadarPlot . VAN_CHART_RADAR_PLOT , new RadarIndependentVanChartInterface ( ) ) ;
addChartTypeInterface ( VanChartScatterPlot . VAN_CHART_SCATTER_PLOT_ID , new ScatterIndependentVanChartInterface ( ) ) ;
addChartTypeInterface ( VanChartBubblePlot . VAN_CHART_BUBBLE_PLOT_ID , new BubbleIndependentVanChartInterface ( ) ) ;
addChartTypeInterface ( VanChartCustomPlot . VAN_CHART_CUSTOM_PLOT_ID , new CustomIndependentVanChartInterface ( ) ) ;
addChartTypeInterface ( VanChartMultiPiePlot . VAN_CHART_MULTILAYER_PLOT_ID , new MultiPieIndependentVanChartInterface ( ) ) ;
addChartTypeInterface ( VanChartMapPlot . VAN_CHART_MAP_ID , new VanMapChartTypeUI ( ) ) ;
addChartTypeInterface ( VanChartDrillMapPlot . VAN_CHART_DRILL_MAP_ID , new VanDrillMapChartTypeUI ( ) ) ;
addChartTypeInterface ( VanChartTreeMapPlot . VAN_CHART_TREE_MAP_PLOT_ID , new TreeMapIndependentVanChartInterface ( ) ) ;
addChartTypeInterface ( VanChartFunnelPlot . VAN_CHART_FUNNEL_PLOT_ID , new FunnelIndependentVanChartInterface ( ) ) ;
addChartTypeInterface ( VanChartHeatMapPlot . VAN_CHART_HEAT_MAP_ID , new VanHeatMapChartTypeUI ( ) ) ;
addChartTypeInterface ( VanChartWordCloudPlot . WORD_CLOUD_PLOT_ID , new WordCloudIndependentVanChartInterface ( ) ) ;
addChartTypeInterface ( VanChartGanttPlot . VAN_CHART_GANTT_PLOT_ID , new GanttIndependentVanChartInterface ( ) ) ;
addChartTypeInterface ( VanChartStructurePlot . STRUCTURE_PLOT_ID , new VanStructureChartTypeUI ( ) ) ;
addChartTypeInterface ( VanChartBoxPlot . VAN_CHART_BOX_PLOT_ID , new BoxIndependentVanChartInterface ( ) ) ;
}
private static void readDefault ( ) {
addChartTypeInterface ( DEPRECATED_CHART_PRIORITY , ChartConstants . COLUMN_CHART , new ColumnChartTypeUI ( ) ) ;
addChartTypeInterface ( DEPRECATED_CHART_PRIORITY , ChartConstants . LINE_CHART , new LineChartTypeUI ( ) ) ;
addChartTypeInterface ( DEPRECATED_CHART_PRIORITY , ChartConstants . BAR_CHART , new BarChartTypeUI ( ) ) ;
addChartTypeInterface ( DEPRECATED_CHART_PRIORITY , ChartConstants . PIE_CHART , new PieChartTypeUI ( ) ) ;
addChartTypeInterface ( DEPRECATED_CHART_PRIORITY , ChartConstants . AREA_CHART , new AreaChartTypeUI ( ) ) ;
addChartTypeInterface ( DEPRECATED_CHART_PRIORITY , ChartConstants . SCATTER_CHART , new XYScatterChartTypeUI ( ) ) ;
addChartTypeInterface ( DEPRECATED_CHART_PRIORITY , ChartConstants . BUBBLE_CHART , new BubbleChartTypeUI ( ) ) ;
addChartTypeInterface ( DEPRECATED_CHART_PRIORITY , ChartConstants . RADAR_CHART , new RadarChartTypeUI ( ) ) ;
addChartTypeInterface ( DEPRECATED_CHART_PRIORITY , ChartConstants . STOCK_CHART , new StockChartTypeUI ( ) ) ;
addChartTypeInterface ( DEPRECATED_CHART_PRIORITY , ChartConstants . METER_CHART , new MeterChartTypeUI ( ) ) ;
addChartTypeInterface ( DEPRECATED_CHART_PRIORITY , ChartConstants . RANGE_CHART , new RangeChartTypeUI ( ) ) ;
addChartTypeInterface ( DEPRECATED_CHART_PRIORITY , ChartConstants . CUSTOM_CHART , new CustomChartTypeUI ( ) ) ;
addChartTypeInterface ( DEPRECATED_CHART_PRIORITY , ChartConstants . GANTT_CHART , new GanttChartTypeUI ( ) ) ;
addChartTypeInterface ( DEPRECATED_CHART_PRIORITY , ChartConstants . DONUT_CHART , new DonutChartTypeUI ( ) ) ;
addChartTypeInterface ( DEPRECATED_CHART_PRIORITY , ChartConstants . MAP_CHART , new MapChartTypeUI ( ) ) ;
addChartTypeInterface ( DEPRECATED_CHART_PRIORITY , ChartConstants . GIS_CHAER , new GisMapChartTypeUI ( ) ) ;
addChartTypeInterface ( DEPRECATED_CHART_PRIORITY , ChartConstants . FUNNEL_CHART , new FunnelChartTypeUI ( ) ) ;
}
private static void addChartTypeInterface ( String priority , String plotID , ChartTypeUIProvider provider ) {
if ( chartTypeInterfaces ! = null ) {
if ( ! chartTypeInterfaces . containsKey ( priority ) ) {
//新建一个具体图表列表
CloseableContainedMap < String , ChartTypeUIProvider , LinkedHashMap > chartUIList
= new CloseableContainedMap < String , ChartTypeUIProvider , LinkedHashMap > ( LinkedHashMap . class ) ;
chartUIList . put ( plotID , provider ) ;
chartTypeInterfaces . put ( priority , chartUIList ) ;
} else {
Map < String , ChartTypeUIProvider > chartUIList = chartTypeInterfaces . get ( priority ) ;
if ( ! chartUIList . containsKey ( plotID ) ) {
chartUIList . put ( plotID , provider ) ;
}
}
idAndPriorityMap . put ( plotID , priority ) ;
addChartTypeInterface ( ChartConstants . COLUMN_CHART , new ColumnChartTypeUI ( ) ) ;
addChartTypeInterface ( ChartConstants . LINE_CHART , new LineChartTypeUI ( ) ) ;
addChartTypeInterface ( ChartConstants . BAR_CHART , new BarChartTypeUI ( ) ) ;
addChartTypeInterface ( ChartConstants . PIE_CHART , new PieChartTypeUI ( ) ) ;
addChartTypeInterface ( ChartConstants . AREA_CHART , new AreaChartTypeUI ( ) ) ;
addChartTypeInterface ( ChartConstants . SCATTER_CHART , new XYScatterChartTypeUI ( ) ) ;
addChartTypeInterface ( ChartConstants . BUBBLE_CHART , new BubbleChartTypeUI ( ) ) ;
addChartTypeInterface ( ChartConstants . RADAR_CHART , new RadarChartTypeUI ( ) ) ;
addChartTypeInterface ( ChartConstants . STOCK_CHART , new StockChartTypeUI ( ) ) ;
addChartTypeInterface ( ChartConstants . METER_CHART , new MeterChartTypeUI ( ) ) ;
addChartTypeInterface ( ChartConstants . RANGE_CHART , new RangeChartTypeUI ( ) ) ;
addChartTypeInterface ( ChartConstants . CUSTOM_CHART , new CustomChartTypeUI ( ) ) ;
addChartTypeInterface ( ChartConstants . GANTT_CHART , new GanttChartTypeUI ( ) ) ;
addChartTypeInterface ( ChartConstants . DONUT_CHART , new DonutChartTypeUI ( ) ) ;
addChartTypeInterface ( ChartConstants . MAP_CHART , new MapChartTypeUI ( ) ) ;
addChartTypeInterface ( ChartConstants . GIS_CHAER , new GisMapChartTypeUI ( ) ) ;
addChartTypeInterface ( ChartConstants . FUNNEL_CHART , new FunnelChartTypeUI ( ) ) ;
}
private static void addChartTypeInterface ( String id , ChartTypeUIProvider provider ) {
if ( chartTypeUIs ! = null ) {
chartTypeUIs . put ( id , provider ) ;
}
}
private ChartTypeUIProvider getChartTypeInterface ( String plotID ) {
if ( idAndPriorityMap . containsKey ( plotID ) ) {
String priority = idAndPriorityMap . get ( plotID ) ;
if ( chartTypeInterfaces . containsKey ( priority ) ) {
return chartTypeInterfaces . get ( priority ) . get ( plotID ) ;
}
private ChartTypeUIProvider getChartTypeInterface ( String id ) {
if ( chartTypeUIs . containsKey ( id ) ) {
return chartTypeUIs . get ( id ) ;
}
return null ;
}
/ * *
* 把所有的pane加到list里
*
* @param paneList pane容器
* /
public void addPlotTypePaneList ( List < FurtherBasicBeanPane < ? extends ChartProvider > > paneList ,
Map < String , Map < String , FurtherBasicBeanPane < ? extends ChartProvider > > > allChartTypePane ,
ActionListener autoButtonListener ) {
List < Integer > priorityList = getPriorityInOrder ( ) ;
for ( Integer aPriorityList : priorityList ) {
String priority = String . valueOf ( aPriorityList ) ;
addPlotTypePaneList ( priority , paneList , allChartTypePane , autoButtonListener ) ;
}
}
public void addPlotTypePaneList ( String priority , List < FurtherBasicBeanPane < ? extends ChartProvider > > paneList ,
Map < String , Map < String , FurtherBasicBeanPane < ? extends ChartProvider > > > allChartTypePane ,
ActionListener autoButtonListener ) {
if ( chartTypeInterfaces ! = null & & chartTypeInterfaces . containsKey ( priority ) ) {
Map < String , ChartTypeUIProvider > chartUIList = chartTypeInterfaces . get ( priority ) ;
Iterator < Map . Entry < String , ChartTypeUIProvider > > iterator = chartUIList . entrySet ( ) . iterator ( ) ;
while ( iterator . hasNext ( ) ) {
try {
Map . Entry < String , ChartTypeUIProvider > entry = iterator . next ( ) ;
String plotID = entry . getKey ( ) ;
AbstractChartTypePane pane = entry . getValue ( ) . getPlotTypePane ( ) ;
if ( AssistUtils . equals ( pane . title4PopupWindow ( ) , TYPE_PANE_DEFAULT_TITLE ) ) {
continue ;
}
pane . reLayout ( plotID ) ;
pane . registerButtonListener ( autoButtonListener ) ;
paneList . add ( pane ) ;
if ( allChartTypePane . get ( priority ) = = null ) {
allChartTypePane . put ( priority , new LinkedHashMap < String , FurtherBasicBeanPane < ? extends ChartProvider > > ( ) ) ;
}
allChartTypePane . get ( priority ) . put ( plotID , pane ) ;
} catch ( Throwable e ) {
FineLoggerFactory . getLogger ( ) . error ( e . getMessage ( ) , e ) ;
}
}
public AbstractChartTypePane getPlotTypePane ( String id ) {
if ( chartTypeUIs . containsKey ( id ) ) {
return chartTypeUIs . get ( id ) . getPlotTypePane ( ) ;
}
return null ;
}
@Compatible
@ -313,23 +239,9 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr
return getName ( plotID ) ;
}
private List < Integer > getPriorityInOrder ( ) {
List < Integer > priorityList = new ArrayList < Integer > ( ) ;
if ( chartTypeInterfaces ! = null ) {
Iterator iterator = chartTypeInterfaces . entrySet ( ) . iterator ( ) ;
while ( iterator . hasNext ( ) ) {
Map . Entry entry = ( Map . Entry ) iterator . next ( ) ;
String priority = ( String ) entry . getKey ( ) ;
priorityList . add ( Integer . valueOf ( priority ) ) ;
}
}
return ChartTypeManager . orderInPriority ( priorityList ) ;
}
public String getIconPath ( String plotID ) {
if ( chartTypeInterface s ! = null ) {
if ( chartTypeUIs ! = null ) {
ChartTypeUIProvider provider = getChartTypeInterface ( plotID ) ;
if ( provider ! = null ) {
return provider . getIconPath ( ) ;
@ -340,7 +252,7 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr
public String [ ] getDemoImagePath ( String chartID ) {
if ( chartTypeInterface s ! = null ) {
if ( chartTypeU Is ! = null ) {
ChartTypeUIProvider provider = getChartTypeInterface ( chartID ) ;
if ( provider ! = null ) {
String [ ] result = null ;
@ -396,7 +308,7 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr
}
public String [ ] getSubName ( String chartID ) {
if ( chartTypeInterface s ! = null ) {
if ( chartTypeU Is ! = null ) {
ChartTypeUIProvider provider = getChartTypeInterface ( chartID ) ;
if ( provider ! = null ) {
String [ ] subNames = null ;
@ -429,7 +341,7 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr
}
public String getName ( String chartID ) {
if ( chartTypeInterface s ! = null ) {
if ( chartTypeU Is ! = null ) {
ChartTypeUIProvider provider = getChartTypeInterface ( chartID ) ;
if ( provider ! = null ) {
String name = null ;
@ -574,9 +486,8 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr
if ( StringUtils . isEmpty ( id ) ) {
id = injection . getAttribute ( "plotID" ) ;
}
String priority = injection . getAttribute ( "priority" , DEFAULT_PRIORITY ) ;
ChartTypeUIProvider instance = ( ChartTypeUIProvider ) injection . getObject ( ) ;
addChartTypeInterface ( priority , id , instance ) ;
addChartTypeInterface ( id , instance ) ;
}
}
@ -585,22 +496,18 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr
public void demount ( PluginSingleInjection injection ) {
if ( isChartTypeUIProvider ( injection ) ) {
String priority = injection . getAttribute ( "priority" , DEFAULT_PRIORITY ) ;
String id = injection . getAttribute ( "chartID" ) ;
if ( StringUtils . isEmpty ( id ) ) {
id = injection . getAttribute ( "plotID" ) ;
}
removeChartTypeInterface ( priority , id ) ;
removeChartTypeInterface ( id ) ;
}
}
private void removeChartTypeInterface ( String priority , String plotID ) {
private void removeChartTypeInterface ( String id ) {
if ( chartTypeInterfaces ! = null ) {
if ( chartTypeInterfaces . containsKey ( priority ) ) {
Map < String , ChartTypeUIProvider > chartUIList = chartTypeInterfaces . get ( priority ) ;
chartUIList . remove ( plotID ) ;
}
if ( chartTypeUIs ! = null ) {
chartTypeUIs . remove ( id ) ;
}
}