Browse Source

增加chart用的基础面板抽象类

master
mengao 7 years ago
parent
commit
0a15c06a90
  1. 26
      designer_base/src/com/fr/design/dialog/BasicScrollPane.java
  2. 2
      designer_base/src/com/fr/design/gui/frpane/AbstractAttrNoScrollPane.java
  3. 13
      designer_base/src/com/fr/design/layout/TableLayoutHelper.java
  4. 9
      designer_chart/src/com/fr/design/mainframe/chart/AbstractChartAttrPane.java
  5. 30
      designer_chart/src/com/fr/plugin/chart/designer/AbstractVanChartTabPane.java
  6. 16
      designer_chart/src/com/fr/plugin/chart/designer/TableLayout4VanChartHelper.java
  7. 4
      designer_chart/src/com/fr/plugin/chart/designer/style/VanChartLegendPane.java
  8. 4
      designer_chart/src/com/fr/plugin/chart/designer/style/VanChartTitlePane.java

26
designer_base/src/com/fr/design/dialog/BasicScrollPane.java

@ -104,7 +104,7 @@ public abstract class BasicScrollPane<T> extends BasicBeanPane<T>{
protected void layoutContentPane() { protected void layoutContentPane() {
leftcontentPane = createContentPane(); leftcontentPane = createContentPane();
leftcontentPane.setBorder(BorderFactory.createMatteBorder(0, 0, 0, 0, original)); leftcontentPane.setBorder(BorderFactory.createMatteBorder(0, 10, 0, 5, original));
this.add(leftcontentPane); this.add(leftcontentPane);
} }
@ -155,26 +155,30 @@ public abstract class BasicScrollPane<T> extends BasicBeanPane<T>{
} else { } else {
int preferheight = leftcontentPane.getPreferredSize().height; int preferheight = leftcontentPane.getPreferredSize().height;
int value = scrollBar.getValue(); int value = scrollBar.getValue();
int baseValue = MAXVALUE - scrollBar.getVisibleAmount(); int baseValue = MAXVALUE - scrollBar.getVisibleAmount();
beginY = baseValue == 0 ? 0 : value * (preferheight - maxheight) / baseValue; beginY = baseValue == 0 ? 0 : value * (preferheight - maxheight) / baseValue;
if(MAXVALUE - scrollBar.getVisibleAmount() != 0) { if(MAXVALUE - scrollBar.getVisibleAmount() != 0) {
beginY = value * (preferheight - maxheight) / (MAXVALUE - scrollBar.getVisibleAmount()); beginY = value * (preferheight - maxheight) / (MAXVALUE - scrollBar.getVisibleAmount());
} }
} }
int width = parent.getWidth(); setLeftContentPaneBouns(parent, scrollBar, beginY, maxheight);
int height = parent.getHeight();
if (leftcontentPane.getPreferredSize().height > maxheight) {
leftcontentPane.setBounds(0, -beginY, width - scrollBar.getWidth(), height + beginY);
scrollBar.setBounds(width - scrollBar.getWidth() - 1, 0, scrollBar.getWidth(), height);
} else {
leftcontentPane.setBounds(0, 0, width, height);
}
leftcontentPane.validate(); leftcontentPane.validate();
} }
} }
protected void setLeftContentPaneBouns (Container parent, UIScrollBar scrollBar, int beginY, int maxheight) {
int width = parent.getWidth();
int height = parent.getHeight();
if (leftcontentPane.getPreferredSize().height > maxheight) {
leftcontentPane.setBounds(0, -beginY, width - scrollBar.getWidth() - DET_WIDTH_OVER_HEIGHT, height + beginY);
scrollBar.setBounds(width - scrollBar.getWidth() - 1, 0, scrollBar.getWidth(), height);
} else {
leftcontentPane.setBounds(0, 0, width - DET_WIDTH, height);
}
}
protected boolean isShowScrollBar() { protected boolean isShowScrollBar() {
return true; return true;
} }
@ -183,7 +187,7 @@ public abstract class BasicScrollPane<T> extends BasicBeanPane<T>{
public T updateBean() { public T updateBean() {
return null; return null;
} }
/** /**
* 用于在调用removeAll以后恢复原来pane的结构放在这边是因为BarLayout是内部类 * 用于在调用removeAll以后恢复原来pane的结构放在这边是因为BarLayout是内部类
* @param pane * @param pane

2
designer_base/src/com/fr/design/gui/frpane/AbstractAttrNoScrollPane.java

@ -45,7 +45,7 @@ public abstract class AbstractAttrNoScrollPane extends BasicPane {
protected void initContentPane() { protected void initContentPane() {
leftContentPane = createContentPane(); leftContentPane = createContentPane();
leftContentPane.setBorder(BorderFactory.createMatteBorder(10, 0, 0, 0, original)); leftContentPane.setBorder(BorderFactory.createMatteBorder(10, 10, 0, 0, original));
this.add(leftContentPane, BorderLayout.CENTER); this.add(leftContentPane, BorderLayout.CENTER);
} }

13
designer_base/src/com/fr/design/layout/TableLayoutHelper.java

@ -2,7 +2,6 @@ package com.fr.design.layout;
import com.fr.design.constants.LayoutConstants; import com.fr.design.constants.LayoutConstants;
import com.fr.design.foldablepane.UIExpandablePane;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
@ -19,8 +18,7 @@ public class TableLayoutHelper {
public static final int FILL_LASTCOL_AND_ROW = 3; public static final int FILL_LASTCOL_AND_ROW = 3;
private static final int FIVE = 5; private static final int FIVE = 5;
private static final int TEN = 10; private static final int TEN = 10;
public static final int EXPANDABLE_PANE_WIDTH =290;
public static final int EXPANDABLE_PANE_HIGHT =24;
private TableLayoutHelper() { private TableLayoutHelper() {
} }
@ -276,15 +274,6 @@ public class TableLayoutHelper {
return createTableLayoutPane(comp, row, column); return createTableLayoutPane(comp, row, column);
} }
public static JPanel createExpandablePaneWithTitle(String title, Component[][] components, double[] rowSize, double[] columnSize){
JPanel jPanel = new JPanel();
JPanel contentPane = createTableLayoutPane4ChartWithoutTitle(components, rowSize, columnSize);
contentPane.setBorder(BorderFactory.createEmptyBorder(10 ,0, 0, 0));
jPanel.add(contentPane);
return new UIExpandablePane(title, EXPANDABLE_PANE_WIDTH, EXPANDABLE_PANE_HIGHT, jPanel);
}
public static void main (String[] args) { public static void main (String[] args) {
JFrame jf = new JFrame("test"); JFrame jf = new JFrame("test");

9
designer_chart/src/com/fr/design/mainframe/chart/AbstractChartAttrPane.java

@ -4,6 +4,9 @@ package com.fr.design.mainframe.chart;
import com.fr.chart.chartattr.ChartCollection; import com.fr.chart.chartattr.ChartCollection;
import com.fr.design.gui.frpane.AbstractAttrNoScrollPane; import com.fr.design.gui.frpane.AbstractAttrNoScrollPane;
import javax.swing.*;
import java.awt.*;
public abstract class AbstractChartAttrPane extends AbstractAttrNoScrollPane { public abstract class AbstractChartAttrPane extends AbstractAttrNoScrollPane {
public abstract void populate(ChartCollection collection); public abstract void populate(ChartCollection collection);
@ -25,6 +28,12 @@ public abstract class AbstractChartAttrPane extends AbstractAttrNoScrollPane {
} }
protected void initContentPane() {
leftContentPane = createContentPane();
leftContentPane.setBorder(BorderFactory.createMatteBorder(10, 0, 0, 0, original));
this.add(leftContentPane, BorderLayout.CENTER);
}
/** /**
* 刷新图表数据界面 * 刷新图表数据界面
* @param collection 图表收集器 * @param collection 图表收集器

30
designer_chart/src/com/fr/plugin/chart/designer/AbstractVanChartTabPane.java

@ -0,0 +1,30 @@
package com.fr.plugin.chart.designer;
import com.fr.design.gui.iscrollbar.UIScrollBar;
import com.fr.design.mainframe.chart.gui.style.AbstractChartTabPane;
import javax.swing.*;
import java.awt.*;
/**
* Created by mengao on 2017/8/11.
*/
public abstract class AbstractVanChartTabPane<T> extends AbstractChartTabPane<T> {
protected void layoutContentPane() {
leftcontentPane = createContentPane();
leftcontentPane.setBorder(BorderFactory.createMatteBorder(0, 0, 0, 0, original));
this.add(leftcontentPane);
}
protected void setLeftContentPaneBouns (Container parent, UIScrollBar scrollBar, int beginY, int maxheight) {
int width = parent.getWidth();
int height = parent.getHeight();
if (leftcontentPane.getPreferredSize().height > maxheight) {
leftcontentPane.setBounds(0, -beginY, width - scrollBar.getWidth(), height + beginY);
scrollBar.setBounds(width - scrollBar.getWidth() - 1, 0, scrollBar.getWidth(), height);
} else {
leftcontentPane.setBounds(0, 0, width, height);
}
}
}

16
designer_chart/src/com/fr/plugin/chart/designer/TableLayout4VanChartHelper.java

@ -15,27 +15,19 @@ import java.awt.*;
*/ */
public class TableLayout4VanChartHelper { public class TableLayout4VanChartHelper {
private static final int DEFAULT_GAP = 0;
private static final int SMALL_GAP = 20; private static final int SMALL_GAP = 20;
public static final int EXPANDABLE_PANE_WIDTH =290;
public static final int EXPANDABLE_PANE_HIGHT =24;
public static JPanel createExpandablePaneWithTitle(String title, JPanel panel) { public static JPanel createExpandablePaneWithTitle(String title, JPanel panel) {
return new UIExpandablePane(title, TableLayoutHelper.EXPANDABLE_PANE_WIDTH, TableLayoutHelper.EXPANDABLE_PANE_HIGHT, panel); return new UIExpandablePane(title, EXPANDABLE_PANE_WIDTH, EXPANDABLE_PANE_HIGHT, panel);
} }
public static JPanel createExpandablePaneWithTitle(String title, Component component) { public static JPanel createExpandablePaneWithTitle(String title, Component component) {
JPanel panel = (JPanel) component; JPanel panel = (JPanel) component;
return new UIExpandablePane(title, TableLayoutHelper.EXPANDABLE_PANE_WIDTH, TableLayoutHelper.EXPANDABLE_PANE_HIGHT, panel); return new UIExpandablePane(title, EXPANDABLE_PANE_WIDTH, EXPANDABLE_PANE_HIGHT, panel);
} }
public static JPanel createGapTableLayoutPane(Component[][] components) {
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] columnSize = {p, f};
double[] rowSize = {p};
return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, SMALL_GAP, LayoutConstants.VGAP_LARGE);
}
public static JPanel createGapTableLayoutPane(String title, Component component) { public static JPanel createGapTableLayoutPane(String title, Component component) {
double p = TableLayout.PREFERRED; double p = TableLayout.PREFERRED;
double f = TableLayout.FILL; double f = TableLayout.FILL;

4
designer_chart/src/com/fr/plugin/chart/designer/style/VanChartLegendPane.java

@ -3,8 +3,8 @@ package com.fr.plugin.chart.designer.style;
import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Chart;
import com.fr.chart.chartattr.Plot; import com.fr.chart.chartattr.Plot;
import com.fr.design.mainframe.chart.PaneTitleConstants; import com.fr.design.mainframe.chart.PaneTitleConstants;
import com.fr.design.dialog.BasicScrollPane;
import com.fr.plugin.chart.attr.VanChartLegend; import com.fr.plugin.chart.attr.VanChartLegend;
import com.fr.plugin.chart.designer.AbstractVanChartTabPane;
import com.fr.plugin.chart.designer.PlotFactory; import com.fr.plugin.chart.designer.PlotFactory;
import com.fr.plugin.chart.vanchart.VanChart; import com.fr.plugin.chart.vanchart.VanChart;
@ -14,7 +14,7 @@ import java.awt.*;
/** /**
* 属性表, 图表样式-图例 界面. * 属性表, 图表样式-图例 界面.
*/ */
public class VanChartLegendPane extends BasicScrollPane<VanChart> { public class VanChartLegendPane extends AbstractVanChartTabPane<VanChart> {
private static final long serialVersionUID = 7553135492053931171L; private static final long serialVersionUID = 7553135492053931171L;
private VanChartPlotLegendPane legendContent; private VanChartPlotLegendPane legendContent;

4
designer_chart/src/com/fr/plugin/chart/designer/style/VanChartTitlePane.java

@ -5,7 +5,6 @@ import com.fr.base.Formula;
import com.fr.base.Style; import com.fr.base.Style;
import com.fr.base.Utils; import com.fr.base.Utils;
import com.fr.chart.base.TextAttr; import com.fr.chart.base.TextAttr;
import com.fr.design.dialog.BasicScrollPane;
import com.fr.design.formula.TinyFormulaPane; import com.fr.design.formula.TinyFormulaPane;
import com.fr.design.gui.frpane.UIBubbleFloatPane; import com.fr.design.gui.frpane.UIBubbleFloatPane;
import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.gui.ibutton.UIButtonGroup;
@ -19,6 +18,7 @@ import com.fr.design.mainframe.chart.PaneTitleConstants;
import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPane; import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPane;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.plugin.chart.attr.VanChartTitle; import com.fr.plugin.chart.attr.VanChartTitle;
import com.fr.plugin.chart.designer.AbstractVanChartTabPane;
import com.fr.plugin.chart.designer.TableLayout4VanChartHelper; import com.fr.plugin.chart.designer.TableLayout4VanChartHelper;
import com.fr.plugin.chart.designer.component.VanChartFloatPositionPane; import com.fr.plugin.chart.designer.component.VanChartFloatPositionPane;
import com.fr.plugin.chart.designer.component.background.VanChartBackgroundWithOutShadowWithRadiusPane; import com.fr.plugin.chart.designer.component.background.VanChartBackgroundWithOutShadowWithRadiusPane;
@ -37,7 +37,7 @@ import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
// 属性表-样式 标题界面 // 属性表-样式 标题界面
public class VanChartTitlePane extends BasicScrollPane<VanChart> { public class VanChartTitlePane extends AbstractVanChartTabPane<VanChart> {
private static final long serialVersionUID = -2438898431228882682L; private static final long serialVersionUID = -2438898431228882682L;
private static final int WIDTH = 165; private static final int WIDTH = 165;

Loading…
Cancel
Save