Browse Source

REPORT-4944 设计器单元格元素、悬浮元素、聚合报表的图表配置接口适配

master
yaoh.wu 7 years ago
parent
commit
9b8ef8b06a
  1. 10
      designer/src/com/fr/design/module/DesignerModule.java
  2. 274
      designer/src/com/fr/poly/creator/ChartBlockCreator.java
  3. 54
      designer/src/com/fr/quickeditor/ChartQuickEditor.java
  4. 56
      designer/src/com/fr/quickeditor/chartquick/BasicChartQuickEditor.java
  5. 34
      designer/src/com/fr/quickeditor/chartquick/FloatChartQuickEditor.java
  6. 31
      designer/src/com/fr/quickeditor/chartquick/PolyChartQuickEditor.java
  7. 6
      designer_base/src/com/fr/design/actions/core/ActionFactory.java

10
designer/src/com/fr/design/module/DesignerModule.java

@ -32,7 +32,8 @@ import com.fr.general.xml.GeneralXMLTools;
import com.fr.io.importer.Excel2007ReportImporter; import com.fr.io.importer.Excel2007ReportImporter;
import com.fr.io.importer.ExcelReportImporter; import com.fr.io.importer.ExcelReportImporter;
import com.fr.main.impl.WorkBook; import com.fr.main.impl.WorkBook;
import com.fr.quickeditor.ChartQuickEditor; import com.fr.quickeditor.chartquick.BasicChartQuickEditor;
import com.fr.quickeditor.chartquick.FloatChartQuickEditor;
import com.fr.quickeditor.cellquick.*; import com.fr.quickeditor.cellquick.*;
import com.fr.quickeditor.floatquick.FloatImageQuickEditor; import com.fr.quickeditor.floatquick.FloatImageQuickEditor;
import com.fr.quickeditor.floatquick.FloatStringQuickEditor; import com.fr.quickeditor.floatquick.FloatStringQuickEditor;
@ -119,7 +120,7 @@ public class DesignerModule extends DesignModule {
ActionFactory.registerCellEditor(BiasTextPainter.class, CellBiasTextPainterEditor.class); ActionFactory.registerCellEditor(BiasTextPainter.class, CellBiasTextPainterEditor.class);
ActionFactory.registerCellEditor(BufferedImage.class, CellImageQuickEditor.class); ActionFactory.registerCellEditor(BufferedImage.class, CellImageQuickEditor.class);
ActionFactory.registerChartCellEditorInEditor(ChartQuickEditor.class); ActionFactory.registerChartCellEditorInEditor(BasicChartQuickEditor.class);
Set<ElementUIProvider> providers = ExtraDesignClassManager.getInstance().getArray(ElementUIProvider.MARK_STRING); Set<ElementUIProvider> providers = ExtraDesignClassManager.getInstance().getArray(ElementUIProvider.MARK_STRING);
for (ElementUIProvider provider : providers) { for (ElementUIProvider provider : providers) {
@ -139,11 +140,10 @@ public class DesignerModule extends DesignModule {
private void registerFloatEditor() { private void registerFloatEditor() {
ActionFactory.registerFloatEditor(String.class, FloatStringQuickEditor.class); ActionFactory.registerFloatEditor(String.class, FloatStringQuickEditor.class);
ActionFactory.registerFloatEditor(Formula.class, FloatStringQuickEditor.class); ActionFactory.registerFloatEditor(Formula.class, FloatStringQuickEditor.class);
FloatImageQuickEditor floatImageQuickEditor = new FloatImageQuickEditor();
ActionFactory.registerFloatEditor(Image.class, FloatImageQuickEditor.class); ActionFactory.registerFloatEditor(Image.class, FloatImageQuickEditor.class);
ActionFactory.registerFloatEditor(BufferedImage.class, FloatImageQuickEditor.class); ActionFactory.registerFloatEditor(BufferedImage.class, FloatImageQuickEditor.class);
ActionFactory.registerChartFloatEditorInEditor(ChartQuickEditor.class);
ActionFactory.registerChartFloatEditorInEditor(FloatChartQuickEditor.class);
} }
/** /**

274
designer/src/com/fr/poly/creator/ChartBlockCreator.java

@ -1,166 +1,156 @@
/*
* Copyright(c) 2001-2010, FineReport Inc, All Rights Reserved.
*/
package com.fr.poly.creator; package com.fr.poly.creator;
import java.awt.*;
import java.awt.image.BufferedImage;
import javax.swing.*;
import com.fr.base.ScreenResolution;
import com.fr.design.DesignState; import com.fr.design.DesignState;
import com.fr.design.designer.TargetComponent; import com.fr.design.designer.TargetComponent;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.gui.chart.MiddleChartComponent; import com.fr.design.gui.chart.MiddleChartComponent;
import com.fr.design.menu.MenuDef; import com.fr.design.menu.MenuDef;
import com.fr.design.menu.ShortCut; import com.fr.design.menu.ShortCut;
import com.fr.design.menu.ToolBarDef; import com.fr.design.menu.ToolBarDef;
import com.fr.design.module.DesignModuleFactory; import com.fr.design.module.DesignModuleFactory;
import com.fr.design.selection.QuickEditor; import com.fr.design.selection.QuickEditor;
import com.fr.quickeditor.ChartQuickEditor; import com.fr.quickeditor.chartquick.PolyChartQuickEditor;
import com.fr.report.poly.PolyChartBlock; import com.fr.report.poly.PolyChartBlock;
import com.fr.stable.unit.FU; import com.fr.stable.unit.FU;
import com.fr.stable.unit.UNIT; import com.fr.stable.unit.UNIT;
import com.fr.stable.unit.UnitRectangle; import com.fr.stable.unit.UnitRectangle;
import javax.swing.*;
import java.awt.*;
/** /**
* @author richer * @author richer
* @since 6.5.4 创建于2011-5-10 * @since 6.5.4 创建于2011-5-10
*/ */
public class ChartBlockCreator extends BlockCreator<PolyChartBlock> { public class ChartBlockCreator extends BlockCreator<PolyChartBlock> {
private MiddleChartComponent cpm; private MiddleChartComponent cpm;
private ChartBlockEditor editor; private ChartBlockEditor editor;
//图表默认宽高330*240 //图表默认宽高330*240
private static final UNIT DEFAULT_WIDTH = FU.getInstance(12573000); private static final UNIT DEFAULT_WIDTH = FU.getInstance(12573000);
private static final UNIT DEFAULT_HEIGHT = FU.getInstance(9144000); private static final UNIT DEFAULT_HEIGHT = FU.getInstance(9144000);
public ChartBlockCreator() { public ChartBlockCreator() {
} }
public ChartBlockCreator(PolyChartBlock block) { public ChartBlockCreator(PolyChartBlock block) {
super(block); super(block);
} }
public void setResolution(int resolution){ public void setResolution(int resolution) {
this.resolution = resolution; this.resolution = resolution;
} }
/** /**
* 初始化 * 初始化
* @return 初始化的控件. *
*/ * @return 初始化的控件.
public JComponent initMonitor() { */
cpm = DesignModuleFactory.getChartComponent(getValue().getChartCollection()); public JComponent initMonitor() {
cpm.setBorder(BorderFactory.createLineBorder(Color.lightGray)); cpm = DesignModuleFactory.getChartComponent(getValue().getChartCollection());
return cpm; cpm.setBorder(BorderFactory.createLineBorder(Color.lightGray));
} return cpm;
}
public UnitRectangle getDefaultBlockBounds() {
return new UnitRectangle(UNIT.ZERO, UNIT.ZERO, DEFAULT_WIDTH, DEFAULT_HEIGHT); public UnitRectangle getDefaultBlockBounds() {
} return new UnitRectangle(UNIT.ZERO, UNIT.ZERO, DEFAULT_WIDTH, DEFAULT_HEIGHT);
}
@Override
public BlockEditor getEditor() { @Override
if (editor == null) { public BlockEditor getEditor() {
editor = new ChartBlockEditor(designer, this); if (editor == null) {
} editor = new ChartBlockEditor(designer, this);
return editor; }
} return editor;
}
@Override
public int getX(float time) { @Override
return (int) (this.getX() * time); public int getX(float time) {
} return (int) (this.getX() * time);
}
@Override
public int getY(float time) { @Override
return (int) (this.getY() * time); public int getY(float time) {
} return (int) (this.getY() * time);
}
/**
* 检测按钮状态 /**
* * 检测按钮状态
* @date 2015-2-5-上午11:33:46 *
* * @date 2015-2-5-上午11:33:46
*/ */
public void checkButtonEnable() { public void checkButtonEnable() {
if (editor == null) { if (editor == null) {
editor = new ChartBlockEditor(designer, this); editor = new ChartBlockEditor(designer, this);
} }
editor.checkChartButtonsEnable(); editor.checkChartButtonsEnable();
} }
@Override @Override
public PolyChartBlock getValue() { public PolyChartBlock getValue() {
return block; return block;
} }
@Override @Override
public void setValue(PolyChartBlock block) { public void setValue(PolyChartBlock block) {
this.block = block; this.block = block;
cpm.populate(this.block.getChartCollection()); cpm.populate(this.block.getChartCollection());
} }
/**
/** * 获取当前工具栏组
* 获取当前工具栏组 *
* * @return 工具栏组
* @return 工具栏组 * @date 2015-2-5-上午11:29:07
* */
* @date 2015-2-5-上午11:29:07 public ToolBarDef[] toolbars4Target() {
* return new ToolBarDef[0];
*/ }
public ToolBarDef[] toolbars4Target() {
return new ToolBarDef[0]; /**
} * 在Form的工具栏组
*
/** * @return 组件数组
* 在Form的工具栏组 * @date 2015-2-5-上午11:31:46
* */
* @return 组件数组 public JComponent[] toolBarButton4Form() {
* return new JComponent[0];
* @date 2015-2-5-上午11:31:46 }
*
*/ /**
public JComponent[] toolBarButton4Form() { * 目标的列表
return new JComponent[0]; *
} * @return 返回列表.
*/
/** public MenuDef[] menus4Target() {
* 目标的列表 return new MenuDef[0];
* @return 返回列表. }
*/
public MenuDef[] menus4Target() { public int getMenuState() {
return new MenuDef[0];
}
public int getMenuState(){
return DesignState.POLY_SHEET; return DesignState.POLY_SHEET;
} }
/** /**
* 模板的Menu * 模板的Menu
* @return 模板的menu *
*/ * @return 模板的menu
public ShortCut[] shortcut4TemplateMenu() { */
return new ShortCut[0]; public ShortCut[] shortcut4TemplateMenu() {
} return new ShortCut[0];
}
@Override
public PolyElementCasePane getEditingElementCasePane() { @Override
return null; public PolyElementCasePane getEditingElementCasePane() {
} return null;
}
@Override
public QuickEditor getQuickEditor(TargetComponent tc) { @Override
ChartQuickEditor quitEditor = new ChartQuickEditor(); public QuickEditor getQuickEditor(TargetComponent tc) {
quitEditor.populate(tc); PolyChartQuickEditor quitEditor = new PolyChartQuickEditor();
return quitEditor; quitEditor.populate(tc);
} return quitEditor;
}
} }

54
designer/src/com/fr/quickeditor/ChartQuickEditor.java

@ -1,54 +0,0 @@
package com.fr.quickeditor;
import com.fr.base.chart.BaseChartCollection;
//import com.fr.chart.chartattr.ChartCollection;
import com.fr.design.designer.TargetComponent;
import com.fr.design.gui.chart.BaseChartPropertyPane;
import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.module.DesignModuleFactory;
import com.fr.design.selection.QuickEditor;
import com.fr.grid.selection.CellSelection;
import com.fr.grid.selection.FloatSelection;
import com.fr.grid.selection.Selection;
import com.fr.poly.PolyDesigner;
import com.fr.poly.creator.ChartBlockEditor;
import com.fr.report.cell.Elem;
import java.awt.*;
public class ChartQuickEditor extends QuickEditor<TargetComponent>{
// kunsnat: editingPropertyPane初始化 避开设计器启动, 在用到的时候再初始化.
//private BaseChartPropertyPane editingPropertyPane = null;
public ChartQuickEditor() {
setLayout(new BorderLayout());
setBorder(null);
}
@Override
protected void refresh() {
BaseChartPropertyPane editingPropertyPane = null;
BaseChartCollection collection = null;
if(tc instanceof PolyDesigner) {
ChartBlockEditor chartBlockEditor = (ChartBlockEditor)((PolyDesigner)tc).getSelection().getEditor();
collection = chartBlockEditor.getValue().getChartCollection();
add(editingPropertyPane = DesignModuleFactory.getChartPropertyPane(), BorderLayout.CENTER);
editingPropertyPane.setSupportCellData(false);
} else {
Selection selection = ((ElementCasePane)tc).getSelection();
Elem element = null;
if(selection instanceof CellSelection) {
CellSelection cs = (CellSelection)selection;
element = ((ElementCasePane)tc).getEditingElementCase().getCellElement(cs.getColumn(), cs.getRow());
} else if(selection instanceof FloatSelection){
FloatSelection fs = (FloatSelection)selection;
element = ((ElementCasePane)tc).getEditingElementCase().getFloatElement(fs.getSelectedFloatName());
}
collection = (BaseChartCollection) element.getValue();
add(editingPropertyPane = DesignModuleFactory.getChartPropertyPane(), BorderLayout.CENTER);
}
editingPropertyPane.populateChartPropertyPane(collection, tc);
}
}

56
designer/src/com/fr/quickeditor/chartquick/BasicChartQuickEditor.java

@ -0,0 +1,56 @@
package com.fr.quickeditor.chartquick;
import com.fr.base.chart.BaseChartCollection;
import com.fr.design.actions.core.ActionFactory;
import com.fr.design.actions.insert.cell.ChartCellAction;
import com.fr.design.gui.chart.BaseChartPropertyPane;
import com.fr.design.module.DesignModuleFactory;
import com.fr.grid.selection.CellSelection;
import com.fr.grid.selection.Selection;
import com.fr.quickeditor.CellQuickEditor;
import com.fr.report.cell.Elem;
import javax.swing.*;
import java.awt.*;
public class BasicChartQuickEditor extends CellQuickEditor {
private JPanel content;
public BasicChartQuickEditor() {
super();
}
@Override
public JComponent createCenterBody() {
content = new JPanel();
content.setLayout(new BorderLayout());
return content;
}
@Override
public boolean isScrollAll() {
return false;
}
@Override
public Object getComboBoxSelected() {
return ActionFactory.createAction(ChartCellAction.class);
}
@Override
protected void refreshDetails() {
BaseChartPropertyPane editingPropertyPane;
BaseChartCollection collection;
Selection selection = tc.getSelection();
Elem element;
CellSelection cs = (CellSelection) selection;
element = tc.getEditingElementCase().getCellElement(cs.getColumn(), cs.getRow());
collection = (BaseChartCollection) element.getValue();
editingPropertyPane = DesignModuleFactory.getChartPropertyPane();
editingPropertyPane.setBorder(BorderFactory.createEmptyBorder());
content.add(editingPropertyPane, BorderLayout.CENTER);
editingPropertyPane.populateChartPropertyPane(collection, tc);
}
}

34
designer/src/com/fr/quickeditor/chartquick/FloatChartQuickEditor.java

@ -0,0 +1,34 @@
package com.fr.quickeditor.chartquick;
import com.fr.base.chart.BaseChartCollection;
import com.fr.design.gui.chart.BaseChartPropertyPane;
import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.module.DesignModuleFactory;
import com.fr.design.selection.QuickEditor;
import com.fr.grid.selection.FloatSelection;
import com.fr.grid.selection.Selection;
import com.fr.report.cell.Elem;
import java.awt.*;
public class FloatChartQuickEditor extends QuickEditor<ElementCasePane> {
public FloatChartQuickEditor() {
setLayout(new BorderLayout());
setBorder(null);
}
@Override
protected void refresh() {
BaseChartPropertyPane editingPropertyPane;
BaseChartCollection collection;
Selection selection = tc.getSelection();
Elem element;
FloatSelection fs = (FloatSelection) selection;
element = tc.getEditingElementCase().getFloatElement(fs.getSelectedFloatName());
collection = (BaseChartCollection) element.getValue();
add(editingPropertyPane = DesignModuleFactory.getChartPropertyPane(), BorderLayout.CENTER);
editingPropertyPane.populateChartPropertyPane(collection, tc);
}
}

31
designer/src/com/fr/quickeditor/chartquick/PolyChartQuickEditor.java

@ -0,0 +1,31 @@
package com.fr.quickeditor.chartquick;
import com.fr.base.chart.BaseChartCollection;
import com.fr.design.designer.TargetComponent;
import com.fr.design.gui.chart.BaseChartPropertyPane;
import com.fr.design.module.DesignModuleFactory;
import com.fr.design.selection.QuickEditor;
import com.fr.poly.PolyDesigner;
import com.fr.poly.creator.ChartBlockEditor;
import java.awt.*;
public class PolyChartQuickEditor extends QuickEditor<TargetComponent> {
public PolyChartQuickEditor() {
setLayout(new BorderLayout());
setBorder(null);
}
@Override
protected void refresh() {
BaseChartPropertyPane editingPropertyPane;
BaseChartCollection collection;
ChartBlockEditor chartBlockEditor = (ChartBlockEditor) ((PolyDesigner) tc).getSelection().getEditor();
collection = chartBlockEditor.getValue().getChartCollection();
add(editingPropertyPane = DesignModuleFactory.getChartPropertyPane(), BorderLayout.CENTER);
editingPropertyPane.setSupportCellData(false);
editingPropertyPane.populateChartPropertyPane(collection, tc);
}
}

6
designer_base/src/com/fr/design/actions/core/ActionFactory.java

@ -24,11 +24,11 @@ public class ActionFactory {
private ActionFactory() { private ActionFactory() {
} }
private static Map<Class, Class<? extends QuickEditor>> floatEditor = new HashMap<Class, Class<? extends QuickEditor>>(); private static Map<Class, Class<? extends QuickEditor>> floatEditor = new HashMap<>();
private static Class chartCollectionClass = null; private static Class chartCollectionClass = null;
private static Map<Class, Class<? extends QuickEditor>> cellEditor = new HashMap<Class, Class<? extends QuickEditor>>(); private static Map<Class, Class<? extends QuickEditor>> cellEditor = new HashMap<>();
private static UpdateAction chartPreStyleAction = null; private static UpdateAction chartPreStyleAction = null;
@ -98,7 +98,7 @@ public class ActionFactory {
} }
/** /**
* kunsnat: 图表注册 悬浮元素编辑器 , 因为ChartCollecion和ChartQuickEditor一个在Chart,一个在Designer, 所以分开注册. * kunsnat: 图表注册 悬浮元素编辑器 , 因为ChartCollection和ChartQuickEditor一个在Chart,一个在Designer, 所以分开注册.
* *
* @param editor 待说明 * @param editor 待说明
*/ */

Loading…
Cancel
Save