Browse Source

update

master
MoMeak 8 years ago
parent
commit
1de6733c9b
  1. 2
      designer/src/com/fr/design/cell/editor/RichTextToolBar.java
  2. 16
      designer/src/com/fr/design/expand/ExpandFatherPane.java
  3. 62
      designer/src/com/fr/design/mainframe/CellElementPropertyPane.java
  4. 2
      designer/src/com/fr/design/mainframe/bbs/UserInfoLabel.java
  5. 49
      designer/src/com/fr/design/mainframe/cell/CellElementEditPane.java
  6. 2
      designer/src/com/fr/design/mainframe/cell/QuickEditorRegion.java
  7. 77
      designer/src/com/fr/design/mainframe/cell/settingpane/CellExpandAttrPane.java
  8. 3
      designer/src/com/fr/design/mainframe/cell/settingpane/CellOtherSetPane.java
  9. 21
      designer/src/com/fr/design/mainframe/cell/settingpane/CellPresentPane.java
  10. 18
      designer/src/com/fr/design/mainframe/cell/settingpane/CellStylePane.java
  11. 2
      designer_base/src/com/fr/design/DesignerEnvManager.java
  12. 111
      designer_base/src/com/fr/design/foldablepane/HeaderPane.java
  13. 95
      designer_base/src/com/fr/design/foldablepane/UIExpandablePane.java
  14. 177
      designer_base/src/com/fr/design/gui/icontainer/UIResizableContainer.java
  15. 24
      designer_base/src/com/fr/design/gui/style/BackgroundPane.java
  16. 69
      designer_base/src/com/fr/design/gui/style/BorderPane.java
  17. 88
      designer_base/src/com/fr/design/gui/style/FRFontPane.java
  18. 178
      designer_base/src/com/fr/design/gui/style/FormatPane.java
  19. 12
      designer_base/src/com/fr/design/menu/MenuManager.java
  20. 4
      designer_chart/src/com/fr/design/chart/series/PlotSeries/MapCustomPane.java

2
designer/src/com/fr/design/cell/editor/RichTextToolBar.java

@ -81,7 +81,7 @@ public class RichTextToolBar extends BasicPane{
private void initAllButton(){
fontNameComboBox = new UIComboBox(Utils.getAvailableFontFamilyNames4Report());
fontNameComboBox.setPreferredSize(new Dimension(144, 20));
fontSizeComboBox = new UIComboBox(FRFontPane.FONT_SIZES);
fontSizeComboBox = new UIComboBox(FRFontPane.getFontSizes());
colorSelectPane = new UIToolbarColorButton(BaseUtils.readIcon("/com/fr/design/images/gui/color/foreground.png"));
colorSelectPane.set4Toolbar();

16
designer/src/com/fr/design/expand/ExpandFatherPane.java

@ -22,6 +22,8 @@ import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
public abstract class ExpandFatherPane extends JPanel implements GlobalNameObserver {
@ -33,6 +35,7 @@ public abstract class ExpandFatherPane extends JPanel implements GlobalNameObser
private String expandFatherName = "";
private GlobalNameListener globalNameListener = null;
private boolean isAlreadyAddListener = false;
private final JPanel customPane;
public ExpandFatherPane() {
this.setLayout(new BorderLayout(0, LayoutConstants.VGAP_SMALL));
@ -41,7 +44,7 @@ public abstract class ExpandFatherPane extends JPanel implements GlobalNameObser
Inter.getLocText("Default"),
Inter.getLocText("Custom")});
final CardLayout cardLayout = new CardLayout();
final JPanel customPane = new JPanel(cardLayout);
customPane = new JPanel(cardLayout);
customParentColumnRowPane = new ColumnRowPane() {
@Override
@ -63,13 +66,22 @@ public abstract class ExpandFatherPane extends JPanel implements GlobalNameObser
cc.add(imageButton, BorderLayout.EAST);
customPane.add(cc, "content");
customPane.add(new JPanel(), "none");
customPane.setPreferredSize(new Dimension(0, 0) );
this.add(comboBox, BorderLayout.NORTH);
this.add(customPane, BorderLayout.CENTER);
comboBox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
cardLayout.show(customPane, comboBox.getSelectedIndex() == 2 ? "content" : "none");
if(comboBox.getSelectedIndex() == 2){
customPane.setPreferredSize(new Dimension(100, 20) );
cardLayout.show(customPane,"content");
}else {
cardLayout.show(customPane,"none");
customPane.setPreferredSize(new Dimension(0, 0) );
}
// cardLayout.show(customPane, comboBox.getSelectedIndex() == 2 ? "content" : "none");
if (globalNameListener != null && shouldResponseNameListener()) {
globalNameListener.setGlobalName(expandFatherName);
}

62
designer/src/com/fr/design/mainframe/CellElementPropertyPane.java

@ -3,11 +3,21 @@
*/
package com.fr.design.mainframe;
import java.awt.*;
import javax.swing.*;
import com.fr.base.BaseUtils;
import com.fr.design.fun.CellAttributeProvider;
import com.fr.design.fun.PresentKindProvider;
import com.fr.design.gui.frpane.UITitlePanel;
import com.fr.design.gui.ibutton.UIHeadGroup;
import com.fr.design.gui.ibutton.UISideGroup;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itabpane.TitleChangeListener;
import com.fr.design.mainframe.cell.CellElementEditPane;
import com.fr.design.mainframe.cell.settingpane.AbstractCellAttrPane;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.GeneralContext;
import com.fr.general.Inter;
import com.fr.grid.selection.CellSelection;
@ -22,9 +32,6 @@ import com.fr.report.cell.DefaultTemplateCellElement;
import com.fr.report.cell.Elem;
import com.fr.report.elementcase.TemplateElementCase;
import javax.swing.*;
import java.awt.*;
/**
* 所有组件一次全部加载不存在延迟加载 原因设计器打开第一张模板的时候会初始化许多许多东西这个过程需要很长时间快的3-5s
@ -35,7 +42,7 @@ import java.awt.*;
* @since 2012-5-24下午1:50:21
*/
public class CellElementPropertyPane extends DockingView {
static {
GeneralContext.listenPluginRunningChanged(new PluginEventListener() {
@ -43,7 +50,7 @@ public class CellElementPropertyPane extends DockingView {
public void on(PluginEvent event) {
synchronized (CellElementPropertyPane.class) {
singleton = null;
singleton = new CellElementPropertyPane();
}
}
}, new PluginFilter() {
@ -51,11 +58,13 @@ public class CellElementPropertyPane extends DockingView {
@Override
public boolean accept(PluginContext context) {
return context.contain(PluginModule.ExtraDesign);
return context.contain(PluginModule.ExtraDesign, PresentKindProvider.MARK_STRING) ||
context.contain(PluginModule.ExtraDesign, CellAttributeProvider.MARK_STRING);
}
});
}
public synchronized static CellElementPropertyPane getInstance() {
if (singleton == null) {
singleton = new CellElementPropertyPane();
@ -78,6 +87,43 @@ public class CellElementPropertyPane extends DockingView {
}
};
public static void main(String[] args){
JFrame jf = new JFrame("test");
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
GUICoreUtils.centerWindow(jf);
final JPanel jPanel = (JPanel) jf.getContentPane();
jPanel.setLayout(new BorderLayout());
final CardLayout card = new CardLayout();
final JPanel center = new JPanel();
center.setLayout( new CardLayout());
final JPanel content = new JPanel();
content.setLayout(new BorderLayout());
final CellElementPropertyPane pane = new CellElementPropertyPane();
content.add(new CellElementPropertyPane(), BorderLayout.CENTER);
Icon[] iconArray = new Icon[2];
iconArray[0] = BaseUtils.readIcon("/com/fr/design/images/expand/vertical.png");
center.add(content,content.getUIClassID());
iconArray[1] = BaseUtils.readIcon("/com/fr/design/images/expand/vertical.png");
center.add(new JPanel(),"");
// for (int i = 0; i < 4; i++) {
// iconArray[0] = BaseUtils.readIcon("/com/fr/design/images/expand/vertical.png");
// center.add(content,content.getUIClassID());
// }
final TitleChangeListener titleChangeListener = null;
UISideGroup tabsHeaderIconPane = new UISideGroup(iconArray) {
};
JPanel j1 = new JPanel();
j1.setLayout(new GridLayout(10,1));
j1.add(tabsHeaderIconPane);
tabsHeaderIconPane.setNeedLeftRightOutLine(false);
jPanel.add(j1, BorderLayout.WEST);
jPanel.add(center,BorderLayout.CENTER);
jf.setSize(500, 500);
jf.setVisible(true);
}
private CellElementPropertyPane() {
this.setLayout(new BorderLayout());
@ -97,7 +143,7 @@ public class CellElementPropertyPane extends DockingView {
title.setVerticalAlignment(SwingConstants.CENTER);
titlePane.add(title, BorderLayout.CENTER);
titlePane.setBorder(BorderFactory.createEmptyBorder(0,0,1,0));
this.add(titlePane, BorderLayout.NORTH);
// this.add(titlePane, BorderLayout.NORTH);
this.add(cellElementEditPane, BorderLayout.CENTER);
}
@ -130,7 +176,7 @@ public class CellElementPropertyPane extends DockingView {
public void reInit(ElementCasePane ePane) {
if (titlePane.getParent() == null) { // 如果处于隐藏状态,则让其显示
this.add(titlePane, BorderLayout.NORTH);
// this.add(titlePane, BorderLayout.NORTH);
this.add(cellElementEditPane, BorderLayout.CENTER);
}
cellElementEditPane.populate(ePane);

2
designer/src/com/fr/design/mainframe/bbs/UserInfoLabel.java

@ -265,7 +265,7 @@ public class UserInfoLabel extends UILabel {
UIMenuItem closeOther = new UIMenuItem(Inter.getLocText("FR-Designer-BBSLogin_Switch-Account"));
closeOther.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e) {
BBSPluginLogin.getInstance().logOut();
// BBSPluginLogin.getInstance().logOut();
UserLoginContext.fireLoginContextListener();
}

49
designer/src/com/fr/design/mainframe/cell/CellElementEditPane.java

@ -1,21 +1,24 @@
package com.fr.design.mainframe.cell;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Dimension;
import java.awt.*;
import java.util.*;
import java.util.List;
import javax.swing.Icon;
import javax.swing.JPanel;
import javax.swing.*;
import com.fr.base.BaseUtils;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.fun.CellAttributeProvider;
import com.fr.design.gui.frpane.AttributeChangeListener;
import com.fr.design.gui.ibutton.UIHeadGroup;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itabpane.TitleChangeListener;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.EastTopArrow;
import com.fr.design.mainframe.cell.settingpane.*;
import com.fr.design.dialog.BasicPane;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.ComparatorUtils;
import com.fr.general.Inter;
import com.fr.design.mainframe.ElementCasePane;
@ -44,21 +47,33 @@ public class CellElementEditPane extends BasicPane {
private int PaneListIndex;
private CardLayout card;
private JPanel center;
private JPanel downTitle;
private JPanel title;
private UILabel titlename;
private TitleChangeListener titleChangeListener = null;
private CellAttributeProvider cellAttributeProvider = null;
public static void main(String[] args){
JFrame jf = new JFrame("test");
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel content = (JPanel)jf.getContentPane();
content.setLayout(new BorderLayout());
content.add(new CellElementEditPane(),BorderLayout.CENTER);
GUICoreUtils.centerWindow(jf);
jf.setSize(270, 400);
jf.setVisible(true);
}
public CellElementEditPane() {
setLayout(new BorderLayout());
initPaneList();
Icon[] iconArray = new Icon[paneList.size()];
String[] iconArray = new String[paneList.size()];
card = new CardLayout();
center = new JPanel(card);
for (int i = 0; i < paneList.size(); i++) {
AbstractCellAttrPane pane = paneList.get(i);
iconArray[i] = BaseUtils.readIcon(pane.getIconPath());
iconArray[i] = pane.getIconPath();
center.add(pane, pane.title4PopupWindow());
}
@ -74,8 +89,22 @@ public class CellElementEditPane extends BasicPane {
}
};
tabsHeaderIconPane.setNeedLeftRightOutLine(false);
this.add(tabsHeaderIconPane, BorderLayout.NORTH);
this.add(center, BorderLayout.CENTER);
titlename = new UILabel(Inter.getLocText("Cell-Cell_Attributes"));
titlename.setFont(new Font("Dialog", 1, 14));
titlename.setForeground(new Color(30,190,245));
title = new JPanel();
title.setLayout(new BorderLayout());
title.add(titlename, BorderLayout.NORTH);
downTitle = new JPanel();
downTitle.setLayout(new BorderLayout());
downTitle.add(tabsHeaderIconPane, BorderLayout.NORTH);
downTitle.add(center, BorderLayout.CENTER);
this.add(title, BorderLayout.NORTH);
this.add(downTitle, BorderLayout.CENTER);
}

2
designer/src/com/fr/design/mainframe/cell/QuickEditorRegion.java

@ -35,7 +35,7 @@ public class QuickEditorRegion extends JPanel {
private static QuickEditorRegion singleton = new QuickEditorRegion();
private static JPanel EMPTY;
private QuickEditorRegion() {
public QuickEditorRegion() {
this.setLayout(new BorderLayout());
}

77
designer/src/com/fr/design/mainframe/cell/settingpane/CellExpandAttrPane.java

@ -10,6 +10,8 @@ import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.foldablepane.UIExpandablePane;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.ComparatorUtils;
import com.fr.general.Inter;
import com.fr.report.cell.DefaultTemplateCellElement;
@ -31,6 +33,9 @@ public class CellExpandAttrPane extends AbstractCellAttrPane {
private UICheckBox horizontalExpandableCheckBox;
private UICheckBox verticalExpandableCheckBox;
private SortExpandAttrPane sortAfterExpand;
private JPanel layoutPane;
private JPanel basicPane;
private JPanel seniorPane;
/**
*
@ -56,6 +61,17 @@ public class CellExpandAttrPane extends AbstractCellAttrPane {
}
public static void main(String[] args){
JFrame jf = new JFrame("test");
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel content = (JPanel) jf.getContentPane();
content.setLayout(new BorderLayout());
content.add(new CellExpandAttrPane().layoutPane(), BorderLayout.CENTER);
GUICoreUtils.centerWindow(jf);
jf.setSize(290, 400);
jf.setVisible(true);
}
private void initAllNames() {
expandDirectionButton.setGlobalName(Inter.getLocText("ExpandD-Expand_Direction"));
leftFatherPane.setGlobalName(Inter.getLocText("LeftParent"));
@ -65,24 +81,63 @@ public class CellExpandAttrPane extends AbstractCellAttrPane {
}
private JPanel layoutPane() {
layoutPane = new JPanel(new BorderLayout());
basicPane = new JPanel();
seniorPane = new JPanel();
basicPane = new UIExpandablePane(Inter.getLocText("FR-Designer_Basic"),290,20,basicPane());
seniorPane = new UIExpandablePane(Inter.getLocText("FR-Designer_Advanced"),290,20,seniorPane());
layoutPane.add(basicPane,BorderLayout.NORTH);
layoutPane.add(seniorPane,BorderLayout.CENTER);
return layoutPane;
// double f = TableLayout.FILL;
// double p = TableLayout.PREFERRED;
// Component[][] components = new Component[][]{
// new Component[]{new UILabel(Inter.getLocText("ExpandD-Expand_Direction") + ":", SwingConstants.RIGHT), expandDirectionButton},
// new Component[]{new UILabel(Inter.getLocText("LeftParent") + ":", SwingConstants.RIGHT), leftFatherPane},
// new Component[]{new UILabel(Inter.getLocText("ExpandD-Up_Father_Cell") + ":", SwingConstants.RIGHT), rightFatherPane},
// new Component[]{new JSeparator(), null},
// new Component[]{new UILabel(Inter.getLocText("ExpandD-Expandable") + ":", SwingConstants.RIGHT), horizontalExpandableCheckBox},
// new Component[]{null, verticalExpandableCheckBox},
// new Component[]{new UILabel(Inter.getLocText("ExpandD-Sort_After_Expand") + ":", SwingConstants.RIGHT), sortAfterExpand},
// };
// double[] rowSize = {p, p, p, p, p, p, p, p, p, p, p, p, p};
// double[] columnSize = {p, f};
// int[][] rowCount = {{1, 1}, {1, 3}, {1, 3}, {1, 1}, {1, 1}, {1, 1}, {1, 3}};
// return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_MEDIUM, LayoutConstants.VGAP_MEDIUM);
}
private JPanel basicPane(){
double f = TableLayout.FILL;
double p = TableLayout.PREFERRED;
Component[][] components = new Component[][]{
new Component[]{null,null},
new Component[]{new UILabel(" "+Inter.getLocText("ExpandD-Expand_Direction")+" ", SwingConstants.LEFT), expandDirectionButton},
new Component[]{new UILabel(" "+Inter.getLocText("LeftParent"), SwingConstants.LEFT), leftFatherPane},
new Component[]{new UILabel(" "+Inter.getLocText("ExpandD-Up_Father_Cell"), SwingConstants.LEFT), rightFatherPane},
};
double[] rowSize = {p, p, p, p, p, p};
double[] columnSize = {p, f};
int[][] rowCount = {{1, 1},{1, 1}, {1, 3}, {1, 3}};
return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_MEDIUM, LayoutConstants.VGAP_MEDIUM);
}
private JPanel seniorPane() {
double f = TableLayout.FILL;
double p = TableLayout.PREFERRED;
Component[][] components = new Component[][]{
new Component[]{new UILabel(Inter.getLocText("ExpandD-Expand_Direction") + ":", SwingConstants.RIGHT), expandDirectionButton},
new Component[]{new UILabel(Inter.getLocText("LeftParent") + ":", SwingConstants.RIGHT), leftFatherPane},
new Component[]{new UILabel(Inter.getLocText("ExpandD-Up_Father_Cell") + ":", SwingConstants.RIGHT), rightFatherPane},
new Component[]{new JSeparator(), null},
new Component[]{new UILabel(Inter.getLocText("ExpandD-Expandable") + ":", SwingConstants.RIGHT), horizontalExpandableCheckBox},
new Component[]{null, verticalExpandableCheckBox},
new Component[]{new UILabel(Inter.getLocText("ExpandD-Sort_After_Expand") + ":", SwingConstants.RIGHT), sortAfterExpand},
new Component[]{null,null},
new Component[]{horizontalExpandableCheckBox, null},
new Component[]{verticalExpandableCheckBox, null},
new Component[]{new UILabel(" "+Inter.getLocText("ExpandD-Sort_After_Expand") + Inter.getLocText("FR-Action_Sort"), SwingConstants.RIGHT), sortAfterExpand},
};
double[] rowSize = {p, p, p, p, p, p, p, p, p, p, p, p, p};
double[] rowSize = {p, p, p, p, p, p, p, p};
double[] columnSize = {p, f};
int[][] rowCount = {{1, 1}, {1, 3}, {1, 3}, {1, 1}, {1, 1}, {1, 1}, {1, 3}};
int[][] rowCount = {{1, 1}, {1, 1}, {1, 3}, {1, 3}};
return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_MEDIUM, LayoutConstants.VGAP_MEDIUM);
}
@Override
protected void populateBean() {
this.leftFatherPane.setElementCasePane(elementCasePane);
@ -120,9 +175,11 @@ public class CellExpandAttrPane extends AbstractCellAttrPane {
@Override
public String getIconPath() {
return "com/fr/design/images/expand/cellAttr.gif";
// return "com/fr/design/images/expand/cellAttr.gif";
return Inter.getLocText("Expand");
}
@Override
public void updateBean(TemplateCellElement cellElement) {
CellExpandAttr cellExpandAttr = cellElement.getCellExpandAttr();

3
designer/src/com/fr/design/mainframe/cell/settingpane/CellOtherSetPane.java

@ -214,7 +214,8 @@ public class CellOtherSetPane extends AbstractCellAttrPane {
@Override
public String getIconPath() {
return "com/fr/design/images/m_format/cellstyle/otherset.png";
// return "com/fr/design/images/m_format/cellstyle/otherset.png";
return Inter.getLocText("Other");
}
@Override

21
designer/src/com/fr/design/mainframe/cell/settingpane/CellPresentPane.java

@ -25,21 +25,22 @@ public class CellPresentPane extends AbstractCellAttrPane {
*/
public JPanel createContentPane() {
presentPane = new PresentPane();
JPanel content = new JPanel(new BorderLayout());
content.add(presentPane, BorderLayout.CENTER);
presentPane.addTabChangeListener(new ItemListener() {
JPanel content = new JPanel(new BorderLayout());
content.add(presentPane, BorderLayout.CENTER);
presentPane.addTabChangeListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
adjustValues();
}
});
return content;
@Override
public void itemStateChanged(ItemEvent e) {
adjustValues();
}
});
return content;
}
@Override
public String getIconPath() {
return "com/fr/design/images/data/source/dataDictionary.png";
// return "com/fr/design/images/data/source/dataDictionary.png";
return Inter.getLocText("Present");
}
@Override

18
designer/src/com/fr/design/mainframe/cell/settingpane/CellStylePane.java

@ -2,12 +2,13 @@ package com.fr.design.mainframe.cell.settingpane;
import java.awt.*;
import javax.swing.JPanel;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import com.fr.base.Style;
import com.fr.design.mainframe.cell.settingpane.style.StylePane;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.Inter;
import com.fr.report.cell.DefaultTemplateCellElement;
import com.fr.report.cell.TemplateCellElement;
@ -40,11 +41,24 @@ public class CellStylePane extends AbstractCellAttrPane {
return content;
}
public static void main(String[] args){
JFrame jf = new JFrame("test");
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel content = (JPanel) jf.getContentPane();
content.setLayout(new BorderLayout());
content.add(new CellStylePane().createContentPane(), BorderLayout.CENTER);
GUICoreUtils.centerWindow(jf);
jf.setSize(290, 400);
jf.setVisible(true);
}
@Override
public String getIconPath() {
return "com/fr/design/images/m_format/cell.png";
// return "com/fr/design/images/m_format/cell.png";
return Inter.getLocText("FR-Designer_Style");
}
@Override
public void updateBean(TemplateCellElement cellElement) {
cellElement.setStyle(stylePane.updateBean());

2
designer_base/src/com/fr/design/DesignerEnvManager.java

@ -1802,7 +1802,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
}
writer.startTAG("Env");
writer.classAttr(env.getClass());
// writer.classAttr(env.getClass());
writer.attr("name", name);
env.writeXML(writer);

111
designer_base/src/com/fr/design/foldablepane/HeaderPane.java

@ -0,0 +1,111 @@
package com.fr.design.foldablepane;
import com.fr.design.constants.UIConstants;
import java.awt.*;
import java.awt.image.BufferedImage;
import javax.swing.JPanel;
/**
* Created by MoMeak on 2017/7/5.
*/
public class HeaderPane extends JPanel {
private static final long serialVersionUID = 1L;
private int headWidth = 280;
private int headHeight = 25;
private Color bgColor;
private boolean isShow;
private String title;
private Image image;
private int fontSize = 13;
public void setShow(boolean isShow) {
this.isShow = isShow;
}
public void setTitle(String title)
{
this.title = title;
}
public void setHeadWidth(int headwidth){
this.headWidth = headwidth;
}
public void setheadHeight(int headHeight){
this.headHeight = headHeight;
}
public void setFontSize(int fontSize){
this.fontSize = fontSize;
}
@Override
protected void paintComponent(Graphics g) {
Graphics2D g2d = (Graphics2D) g.create();
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
BufferedImage panelImage = createPanelImage();
g2d.drawImage(panelImage, null, 0, 0);
}
private BufferedImage createPanelImage() {
BufferedImage panelImage = new BufferedImage(getWidth(), headHeight, BufferedImage.TYPE_INT_ARGB);
Graphics2D g2d = panelImage.createGraphics();
g2d.fillRect(0, 0, headWidth, headHeight);
g2d.drawImage(UIConstants.DRAG_BAR, 0, 0, headWidth, headHeight, null);
g2d.setFont(new Font("SimSun", 0, fontSize));
g2d.setPaint(bgColor);
// g2d.drawString(this.title, fontSize/2, headHeight-fontSize/3);
g2d.drawString(this.title, 0, headHeight-fontSize/3);
if(this.isShow)
{
image = UIConstants.DRAG_DOWN_PRESS;
g2d.drawImage(image, title.length() * fontSize, headHeight/2-1, null);
}
else
{
image = UIConstants.DRAG_RIGHT_PRESS;
g2d.drawImage(image, title.length() * fontSize, headHeight/3, null);
}
return panelImage;
}
@Override
public Dimension getPreferredSize() {
return new Dimension(this.getWidth(), headHeight);
}
@Override
public Dimension getSize() {
return new Dimension(this.getWidth(), headHeight);
}
public HeaderPane(Color bgColor) {
this.bgColor = bgColor;
this.isShow = true;
}
public HeaderPane(Color bgColor, String title , int headWidth, int headHeight) {
this(bgColor);
this.title = title;
this.headHeight = headHeight;
this.headWidth = headWidth;
}
public static void main(String[] args)
{
// JFrame mainFrame = new JFrame("UI Demo - Gloomyfish");
// mainFrame.getContentPane().setLayout(new BorderLayout());
// mainFrame.getContentPane().add(new HeaderPane(Color.black, "基本",280,25), BorderLayout.CENTER);
// mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// mainFrame.pack();
// mainFrame.setSize(280, 400);
// mainFrame.setVisible(true);
}
}

95
designer_base/src/com/fr/design/foldablepane/UIExpandablePane.java

@ -0,0 +1,95 @@
package com.fr.design.foldablepane;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.*;
/**
* Created by MoMeak on 2017/7/5.
*/
public class UIExpandablePane extends JPanel {
private static final long serialVersionUID = 1L;
private HeaderPane headerPanel;
private JPanel contentPanel;
private Color color = Color.black;
private String title;
private int headWidth;
private int headHeight;
public UIExpandablePane(String title,int headWidth,int headHeight,JPanel contentPanel)
{
super();
this.title = title;
this.headWidth = headWidth;
this.headHeight = headHeight;
this.contentPanel = contentPanel;
initComponents();
}
private void initComponents() {
this.setLayout(new BorderLayout());
headerPanel = new HeaderPane(color, title,headWidth,headHeight);
headerPanel.addMouseListener(new PanelAction());
this.add(headerPanel, BorderLayout.NORTH);
this.add(contentPanel, BorderLayout.CENTER);
setOpaque(false);
}
class PanelAction extends MouseAdapter
{
public void mousePressed(MouseEvent e)
{
HeaderPane hp = (HeaderPane)e.getSource();
if(contentPanel.isShowing())
{
contentPanel.setVisible(false);
hp.setShow(false);
}
else
{
contentPanel.setVisible(true);
hp.setShow(true);
}
hp.getParent().validate();
hp.getParent().repaint();
}
}
public static void main(String[] args)
{
// JFrame jf = new JFrame("test");
// jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// JPanel content = (JPanel) jf.getContentPane();
// content.setLayout(new BorderLayout());
//
// JPanel myPanel = new JPanel();
// myPanel.setLayout(new BorderLayout());
// JPanel Panel = new JPanel();
// Panel.setBackground(Color.blue);
// myPanel.add(new UIExpandablePane("基本",280,25,Panel),BorderLayout.CENTER);
//// myPanel.setLayout(new GridBagLayout());
//// myPanel.add(new JExpandablePanel());
//// GridBagConstraints gbc = new GridBagConstraints();
//// JPanel[] panels = new JPanel[4]; //
//// gbc.insets = new Insets(1,3,0,3);
//// gbc.weightx = 1.0;
//// gbc.fill = GridBagConstraints.HORIZONTAL;
//// gbc.gridwidth = GridBagConstraints.REMAINDER;
//// for(int j = 0; j < panels.length; j++)
//// {
//// panels[j] = new JExpandablePanel();
//// myPanel.add(panels[j], gbc);
//// }
// content.add(myPanel, BorderLayout.CENTER);
// GUICoreUtils.centerWindow(jf);
// jf.setSize(280, 400);
// jf.setVisible(true);
}
}

177
designer_base/src/com/fr/design/gui/icontainer/UIResizableContainer.java

@ -5,7 +5,6 @@ import com.fr.design.constants.UIConstants;
import com.fr.design.mainframe.DesignerContext;
import com.fr.stable.Constants;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.stable.collections.utils.MathUtils;
import javax.swing.*;
import java.awt.*;
@ -19,7 +18,9 @@ public class UIResizableContainer extends JPanel {
private int containerWidth = 240;
private int preferredWidth = 240;
private int toolPaneY = 300;
private int toolPaneHeightRight = 20;
private int toolPaneHeight = 10;
private int clickToolPaneHeight = 40;
private int bottomHeight = 30;
private JComponent upPane;
@ -28,7 +29,7 @@ public class UIResizableContainer extends JPanel {
private JComponent parameterPane = new JPanel();
private HorizotalToolPane horizontToolPane;
private VerticalToolPane verticalToolPane;
private VerticalToolPaneRight verticalToolPane;
private int direction;
private boolean hasParameterPane;
@ -45,7 +46,7 @@ public class UIResizableContainer extends JPanel {
private boolean isDownPaneVisible = true ;
private int paraHeight;
public UIResizableContainer(int direction) {
public UIResizableContainer(int direction) {
this(new JPanel(), new JPanel(), direction);
}
@ -79,13 +80,12 @@ public class UIResizableContainer extends JPanel {
public UIResizableContainer(JComponent upPane, JComponent downPane, int direction) {
setBackground(UIConstants.NORMAL_BACKGROUND);
this.upPane = upPane;
this.direction = direction;
this.downPane = downPane;
this.horizontToolPane = new HorizotalToolPane();
this.verticalToolPane = new VerticalToolPane();
this.verticalToolPane = new VerticalToolPaneRight();
setLayout(containerLayout);
add(upPane);
@ -94,6 +94,23 @@ public class UIResizableContainer extends JPanel {
add(verticalToolPane);
}
public static void main(String... args) {
JFrame jf = new JFrame("test");
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel content = (JPanel) jf.getContentPane();
content.setLayout(new BorderLayout());
UIResizableContainer bb = new UIResizableContainer(1);
JPanel cc = new JPanel();
cc.setBackground(Color.white);
content.add(bb, BorderLayout.EAST);
content.add(cc, BorderLayout.CENTER);
GUICoreUtils.centerWindow(jf);
jf.setSize(500, 500);
jf.setVisible(true);
}
public UIResizableContainer(JComponent upPane, int direction) {
setBackground(UIConstants.NORMAL_BACKGROUND);
@ -101,17 +118,17 @@ public class UIResizableContainer extends JPanel {
this.direction = direction;
this.horizontToolPane = new HorizotalToolPane();
setLayout(containerLayout);
add(upPane);
add(horizontToolPane);
}
public void setDownPane(JComponent downPane) {
if (this.downPane != null){
return;
}
this.verticalToolPane = new VerticalToolPane();
this.verticalToolPane = new VerticalToolPaneRight();
this.downPane = downPane;
add(downPane);
add(verticalToolPane);
@ -232,6 +249,11 @@ public class UIResizableContainer extends JPanel {
upPane.setBounds(toolPaneHeight, getParameterPaneHeight(), containerWidth - toolPaneHeight, getHeight() - getParameterPaneHeight());
verticalToolPane.setBounds(0, 0, toolPaneHeight, getHeight());
}
}else {
parameterPane.setBounds(20, 0, 230, getParameterPaneHeight());//10,0,230,462
upPane.setBounds(0, toolPaneHeightRight, containerWidth, getHeight() - toolPaneHeightRight);//20,0,230,0
verticalToolPane.setBounds(0, 0, containerWidth, toolPaneHeightRight);//0,0,10,462
}
}
@ -488,6 +510,7 @@ public class UIResizableContainer extends JPanel {
public void paint(Graphics g) {
Image button;
if (direction == Constants.RIGHT) {
// g.drawImage(UIConstants.DRAG_BAR, 0, 0, toolPaneHeight, getHeight(), null);
g.drawImage(UIConstants.DRAG_BAR, 0, 0, toolPaneHeight, getHeight(), null);
if (containerWidth == toolPaneHeight) {
if (model == UIConstants.MODEL_NORMAL) {
@ -526,22 +549,134 @@ public class UIResizableContainer extends JPanel {
}
}
private class VerticalToolPaneRight extends JPanel {
private int model = UIConstants.MODEL_NORMAL;
public VerticalToolPaneRight() {
super();
addMouseMotionListener(new MouseMotionListener() {
@Override
public void mouseMoved(MouseEvent e) {
if (e.getY() <= ARROW_RANGE_VERTICAL) {
setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
model = UIConstants.MODEL_PRESS;
} else if (isLeftRightDragEnabled) {
setCursor(Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR));
}
repaint();
}
@Override
public void mouseDragged(MouseEvent e) {
if (!isLeftRightDragEnabled) {
return;
}
upPane.setVisible(true);
downPane.setVisible(true);
if (direction == Constants.RIGHT) {
containerWidth = e.getXOnScreen() - UIResizableContainer.this.getLocationOnScreen().x;
} else if (direction == Constants.LEFT) {
containerWidth = UIResizableContainer.this.getWidth() + (UIResizableContainer.this.getLocationOnScreen().x - e.getXOnScreen());
}
containerWidth = containerWidth > MAX_WIDTH ? MAX_WIDTH : containerWidth;
containerWidth = containerWidth < MIN_WIDTH ? MIN_WIDTH : containerWidth;
if (containerWidth < MIN_WIDTH) {
upPane.setVisible(false);
downPane.setVisible(false);
containerWidth = toolPaneHeight;
}
refreshContainer();
if (BaseUtils.isAuthorityEditing()) {
DesignerContext.getDesignerFrame().doResize();
}
}
});
addMouseListener(new MouseAdapter() {
@Override
public void mouseEntered(MouseEvent e) {
if (!isLeftRightDragEnabled) {
return;
}
setCursor(Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR));
}
@Override
public void mouseExited(MouseEvent e) {
setCursor(Cursor.getDefaultCursor());
model = UIConstants.MODEL_NORMAL;
repaint();
}
@Override
public void mouseClicked(MouseEvent e) {
if (e.getY() <= ARROW_RANGE_VERTICAL) {
if (containerWidth == clickToolPaneHeight) {
containerWidth = preferredWidth;
} else {
setPreferredWidth(containerWidth);
containerWidth = clickToolPaneHeight;
}
refreshContainer();
if (BaseUtils.isAuthorityEditing()) {
DesignerContext.getDesignerFrame().doResize();
}
}
}
});
}
@Override
public void paint(Graphics g) {
Image button;
if (direction == Constants.RIGHT) {
g.drawImage(UIConstants.DRAG_BAR, 0, 0, toolPaneHeight, getHeight(), null);
if (containerWidth == toolPaneHeight) {
if (model == UIConstants.MODEL_NORMAL) {
button = UIConstants.DRAG_RIGHT_NORMAL;
} else {
button = UIConstants.DRAG_RIGHT_PRESS;
}
} else {
if (model == UIConstants.MODEL_NORMAL) {
button = UIConstants.DRAG_LEFT_NORMAL;
} else {
button = UIConstants.DRAG_LEFT_PRESS;
}
}
g.drawImage(button, 3, ARROW_MARGIN_VERTICAL, 5, toolPaneHeight, null);
if (isLeftRightDragEnabled) {
g.drawImage(UIConstants.DRAG_DOT_VERTICAL, 2, getHeight() / 2, 5, toolPaneHeight, null);
}
} else {
g.drawImage(UIConstants.DRAG_BAR, 0, 0, containerWidth, toolPaneHeightRight, null);
// g.drawImage(UIConstants.DRAG_BAR, 0, 0, toolPaneHeight, getHeight(), null);
if (containerWidth == clickToolPaneHeight) {
if (model == UIConstants.MODEL_NORMAL) {
button = UIConstants.DRAG_LEFT_NORMAL;
} else {
button = UIConstants.DRAG_LEFT_PRESS;
}
} else {
if (model == UIConstants.MODEL_NORMAL) {
button = UIConstants.DRAG_RIGHT_NORMAL;
} else {
button = UIConstants.DRAG_RIGHT_PRESS;
}
}
// g.drawImage(button, 2, ARROW_MARGIN_VERTICAL, 5, toolPaneHeight, null);
g.drawImage(button, 14, 7, 5, 5, null);
}
}
}
/**
* 主函数
* @param args 参数
*/
public static void main(String... args) {
JFrame jf = new JFrame("test");
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel content = (JPanel) jf.getContentPane();
content.setLayout(new BorderLayout());
UIResizableContainer bb = new UIResizableContainer(Constants.RIGHT);
JPanel cc = new JPanel();
cc.setBackground(Color.blue);
content.add(bb, BorderLayout.EAST);
content.add(cc, BorderLayout.CENTER);
GUICoreUtils.centerWindow(jf);
jf.setSize(500, 500);
jf.setVisible(true);
}
}

24
designer_base/src/com/fr/design/gui/style/BackgroundPane.java

@ -1,9 +1,15 @@
package com.fr.design.gui.style;
import com.fr.base.BaseUtils;
import com.fr.base.Style;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.constants.LayoutConstants;
import com.fr.design.fun.BackgroundQuickUIProvider;
import com.fr.design.gui.ibutton.UIToggleButton;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.backgroundpane.*;
import com.fr.general.Background;
import com.fr.general.Inter;
@ -35,7 +41,7 @@ public class BackgroundPane extends AbstractBasicStylePane {
this.setLayout(new BorderLayout(0, 6));
typeComboBox = new UIComboBox();
final CardLayout cardlayout = new CardLayout();
this.add(typeComboBox, BorderLayout.NORTH);
// this.add(typeComboBox, BorderLayout.NORTH);
paneList = supportKindsOfBackgroundUI();
@ -50,7 +56,7 @@ public class BackgroundPane extends AbstractBasicStylePane {
typeComboBox.addItem(pane.title4PopupWindow());
centerPane.add(pane, pane.title4PopupWindow());
}
this.add(centerPane, BorderLayout.CENTER);
// this.add(centerPane, BorderLayout.CENTER);
typeComboBox.addItemListener(new ItemListener() {
@Override
@ -59,6 +65,20 @@ public class BackgroundPane extends AbstractBasicStylePane {
fireStateChanged();
}
});
double f = TableLayout.FILL;
double p = TableLayout.PREFERRED;
Component[][] components = new Component[][]{
new Component[]{null, null},
new Component[]{new UILabel(Inter.getLocText("FR-Chart-Shape_Fill") + " ", SwingConstants.LEFT),typeComboBox},
new Component[]{null, centerPane}
};
double[] rowSize = {p, p, p};
double[] columnSize = {p,f};
int[][] rowCount = {{1, 1},{1, 1},{1, 1}};
JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_SMALL, LayoutConstants.VGAP_MEDIUM);
this.add(panel, BorderLayout.CENTER);
}
protected BackgroundQuickPane[] supportKindsOfBackgroundUI() {

69
designer_base/src/com/fr/design/gui/style/BorderPane.java

@ -9,8 +9,11 @@ import java.awt.Color;
import java.awt.Component;
import java.awt.GridLayout;
import com.fr.design.constants.LayoutConstants;
import com.fr.design.foldablepane.UIExpandablePane;
import com.fr.design.gui.ilable.UILabel;
import javax.swing.JPanel;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
@ -21,6 +24,7 @@ import com.fr.design.gui.ibutton.UIToggleButton;
import com.fr.design.gui.icombobox.LineComboBox;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.Inter;
import com.fr.stable.Constants;
import com.fr.stable.CoreConstants;
@ -45,22 +49,28 @@ public class BorderPane extends AbstractBasicStylePane {
private LineComboBox currentLineCombo;
private NewColorSelectBox currentLineColorPane;
private JPanel panel;
private JPanel borderPanel;
private JPanel backgroundPanel;
private BackgroundPane backgroundPane;
public BorderPane() {
this.initComponents();
}
public static void main(String[] args){
JFrame jf = new JFrame("test");
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel content = (JPanel) jf.getContentPane();
content.setLayout(new BorderLayout());
content.add(new BorderPane(), BorderLayout.CENTER);
GUICoreUtils.centerWindow(jf);
jf.setSize(290, 400);
jf.setVisible(true);
}
protected void initComponents() {
initButtonsWithIcon();
this.setLayout(new BorderLayout(0, 6));
double p = TableLayout.PREFERRED, f = TableLayout.FILL;
double[] columnSize1 = {p, f}, rowSize1 = {p, p};
Component[][] components1 = new Component[][]{
new Component[]{new UILabel(Inter.getLocText("FR-Designer_Style") + ":"), currentLineCombo},
new Component[]{new UILabel(Inter.getLocText("FR-Designer_Color") + ":"), currentLineColorPane},
};
JPanel northPane = TableLayoutHelper.createTableLayoutPane(components1, rowSize1, columnSize1);
double[] columnSize2 = {p, f}, rowSize2 = {p, p};
JPanel externalPane = new JPanel(new GridLayout(0, 4));
externalPane.add(topToggleButton);
externalPane.add(leftToggleButton);
@ -69,14 +79,32 @@ public class BorderPane extends AbstractBasicStylePane {
JPanel insidePane = new JPanel(new GridLayout(0, 2));
insidePane.add(horizontalToggleButton);
insidePane.add(verticalToggleButton);
Component[][] components2 = new Component[][]{
new Component[]{outerToggleButton = new UIToggleButton(BaseUtils.readIcon("com/fr/design/images/m_format/out.png")), innerToggleButton = new UIToggleButton(BaseUtils.readIcon("com/fr/design/images/m_format/in.png"))},
new Component[]{externalPane, insidePane,}
double f = TableLayout.FILL;
double p = TableLayout.PREFERRED;
Component[][] components = new Component[][]{
new Component[]{null,null},
new Component[]{new UILabel(Inter.getLocText("FR-Designer_Style") + " ", SwingConstants.LEFT), currentLineCombo},
new Component[]{null,null},
new Component[]{new UILabel(Inter.getLocText("FR-Designer_Color") + " ", SwingConstants.LEFT), currentLineColorPane},
new Component[]{null,null},
new Component[]{new UILabel("外边框 ", SwingConstants.LEFT),outerToggleButton = new UIToggleButton(BaseUtils.readIcon("com/fr/design/images/m_format/out.png"))},
new Component[]{null,externalPane},
new Component[]{null,null},
new Component[]{new UILabel("内边框 ", SwingConstants.LEFT),innerToggleButton = new UIToggleButton(BaseUtils.readIcon("com/fr/design/images/m_format/in.png"))},
new Component[]{null,insidePane},
new Component[]{null,null}
};
JPanel centerPane = TableLayoutHelper.createTableLayoutPane(components2, rowSize2, columnSize2);
this.setLayout(new BorderLayout(0, 6));
this.add(northPane, BorderLayout.NORTH);
this.add(centerPane, BorderLayout.CENTER);
double[] rowSize = {p, p, p, p, p, p, p, p, p, p, p};
double[] columnSize = {p,f};
int[][] rowCount = {{1, 1},{1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}};
panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_SMALL, LayoutConstants.VGAP_MEDIUM);
borderPanel = new UIExpandablePane(Inter.getLocText("FR-Designer_Border"),280,20,panel);
this.add(borderPanel,BorderLayout.NORTH);
backgroundPane = new BackgroundPane();
backgroundPanel = new UIExpandablePane(Inter.getLocText("FR-Designer_Background"),280,20,backgroundPane);
this.add(backgroundPanel,BorderLayout.CENTER);
outerToggleButton.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
@ -113,7 +141,8 @@ public class BorderPane extends AbstractBasicStylePane {
return Inter.getLocText("FR-Designer_Border");
}
public void populate(Style style) {
@Override
public void populateBean(Style style) {
if (style == null) {
style = Style.DEFAULT_STYLE;
}
@ -127,8 +156,9 @@ public class BorderPane extends AbstractBasicStylePane {
cellBorderStyle.setBottomColor(style.getBorderBottomColor());
cellBorderStyle.setRightStyle(style.getBorderRight());
cellBorderStyle.setRightColor(style.getBorderRightColor());
this.backgroundPane.populateBean(style.getBackground());
this.populateBean(cellBorderStyle, false, style.getBorderTop(), style.getBorderTopColor());
}
public void populateBean(CellBorderStyle cellBorderStyle, boolean insideMode, int currentStyle, Color currentColor) {
@ -151,10 +181,10 @@ public class BorderPane extends AbstractBasicStylePane {
this.innerToggleButton.setEnabled(this.insideMode);
this.horizontalToggleButton.setEnabled(this.insideMode);
this.verticalToggleButton.setEnabled(this.insideMode);
}
public Style update(Style style) {
// style = style.deriveBackground(backgroundPane.update());
if (style == null) {
style = Style.DEFAULT_STYLE;
}
@ -163,7 +193,6 @@ public class BorderPane extends AbstractBasicStylePane {
style = style.deriveBorder(cellBorderStyle.getTopStyle(), cellBorderStyle.getTopColor(), cellBorderStyle.getBottomStyle(), cellBorderStyle.getBottomColor(),
cellBorderStyle.getLeftStyle(), cellBorderStyle.getLeftColor(), cellBorderStyle.getRightStyle(), cellBorderStyle.getRightColor());
return style;
}

88
designer_base/src/com/fr/design/gui/style/FRFontPane.java

@ -7,6 +7,7 @@ package com.fr.design.gui.style;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.Vector;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
@ -37,12 +38,15 @@ import com.fr.design.utils.gui.GUICoreUtils;
* Pane to edit Font.
*/
public class FRFontPane extends AbstractBasicStylePane implements GlobalNameObserver {
private static final int MAX_FONT_SIZE = 100;
public static Integer[] FONT_SIZES = {new Integer(6), new Integer(8), new Integer(9), new Integer(10), new Integer(11), new Integer(12), new Integer(14), new Integer(16),
new Integer(18), new Integer(20), new Integer(22), new Integer(24), new Integer(26), new Integer(28), new Integer(36), new Integer(48), new Integer(72)};
private static final Dimension BUTTON_SIZE = new Dimension(24, 20);
private static final Dimension BUTTON_SIZE = new Dimension(20, 18);
private final String[] fontSizeStyles = {Inter.getLocText("FRFont-plain"), Inter.getLocText("FRFont-bold"), Inter.getLocText("FRFont-italic"), Inter.getLocText("FRFont-bolditalic")};
private JPanel buttonPane;
private JPanel isSuperOrSubPane;
private UIComboBox fontNameComboBox;
private UIComboBox fontSizeStyleComboBox;
private UIComboBox fontSizeComboBox;
private UIToggleButton bold;
private UIToggleButton italic;
@ -58,11 +62,24 @@ public class FRFontPane extends AbstractBasicStylePane implements GlobalNameObse
private UIToggleButton superPane;
private UIToggleButton subPane;
private JPanel linePane;
private int italic_bold;
public FRFontPane() {
this.initComponents();
}
public static void main(String[] args){
JFrame jf = new JFrame("test");
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel content = (JPanel) jf.getContentPane();
content.setLayout(new BorderLayout());
content.add(new FRFontPane(), BorderLayout.CENTER);
GUICoreUtils.centerWindow(jf);
jf.setSize(290, 400);
jf.setVisible(true);
}
@Override
protected String title4PopupWindow() {
return Inter.getLocText("Sytle-FRFont");
@ -73,7 +90,8 @@ public class FRFontPane extends AbstractBasicStylePane implements GlobalNameObse
*/
public void populateBean(FRFont frFont) {
fontNameComboBox.setSelectedItem(frFont.getFamily());
fontSizeComboBox.setSelectedItem(frFont.getSize());
fontSizeStyleComboBox.setSelectedIndex(frFont.getStyle());
fontSizeComboBox.setSelectedItem(Utils.round5(frFont.getSize2D()));
bold.setSelected(frFont.isBold());
italic.setSelected(frFont.isItalic());
@ -115,8 +133,11 @@ public class FRFontPane extends AbstractBasicStylePane implements GlobalNameObse
if (ComparatorUtils.equals(globalNameListener.getGlobalName(), Inter.getLocText("FRFont-Family"))) {
frFont = frFont.applyName((String) fontNameComboBox.getSelectedItem());
}
if (ComparatorUtils.equals(globalNameListener.getGlobalName(), Inter.getLocText("FRFont-Style"))) {
frFont = frFont.applyStyle(fontSizeStyleComboBox.getSelectedIndex());
}
if (ComparatorUtils.equals(globalNameListener.getGlobalName(), Inter.getLocText("FRFont-Size"))) {
frFont = frFont.applySize((Integer) fontSizeComboBox.getSelectedItem());
frFont = frFont.applySize(Float.parseFloat(fontSizeComboBox.getSelectedItem().toString()));
}
if (ComparatorUtils.equals(globalNameListener.getGlobalName(), Inter.getLocText("FRFont-Foreground"))) {
frFont = frFont.applyForeground(this.colorSelectPane.getColor());
@ -147,7 +168,6 @@ public class FRFontPane extends AbstractBasicStylePane implements GlobalNameObse
private FRFont updateOthers(FRFont frFont) {
frFont = updateItalicBold(frFont);
frFont = updateSubSuperscript(frFont);
return frFont;
}
@ -176,29 +196,6 @@ public class FRFontPane extends AbstractBasicStylePane implements GlobalNameObse
return frFont;
}
private FRFont updateItalicBold(FRFont frFont) {
int italic_bold = frFont.getStyle();
boolean isItalic = italic_bold == Font.ITALIC || italic_bold == (Font.BOLD + Font.ITALIC);
boolean isBold = italic_bold == Font.BOLD || italic_bold == (Font.BOLD + Font.ITALIC);
if (ComparatorUtils.equals(globalNameListener.getGlobalName(), Inter.getLocText("FRFont-italic"))) {
if (italic.isSelected() && !isItalic) {
italic_bold += Font.ITALIC;
} else if (!italic.isSelected() && isItalic) {
italic_bold -= Font.ITALIC;
}
frFont = frFont.applyStyle(italic_bold);
}
if (ComparatorUtils.equals(globalNameListener.getGlobalName(), Inter.getLocText("FRFont-bold"))) {
if (bold.isSelected() && !isBold) {
italic_bold += Font.BOLD;
} else if (!bold.isSelected() && isBold) {
italic_bold -= Font.BOLD;
}
frFont = frFont.applyStyle(italic_bold);
}
return frFont;
}
@Override
public void populateBean(Style style) {
this.populateBean(style.getFRFont());
@ -212,10 +209,20 @@ public class FRFontPane extends AbstractBasicStylePane implements GlobalNameObse
return style.deriveFRFont(frFont);
}
public static Vector<Integer> getFontSizes(){
Vector<Integer> FONT_SIZES = new Vector<Integer>();
for (int i = 1; i < MAX_FONT_SIZE; i++) {
FONT_SIZES.add(i);
}
return FONT_SIZES;
}
protected void initComponents() {
fontSizeStyleComboBox = new UIComboBox(fontSizeStyles);
fontNameComboBox = new UIComboBox(Utils.getAvailableFontFamilyNames4Report());
fontNameComboBox.setPreferredSize(new Dimension(144, 20));
fontSizeComboBox = new UIComboBox(FONT_SIZES);
fontSizeComboBox = new UIComboBox(getFontSizes());
fontSizeComboBox.setEditable(true);
this.underlineCombo = new LineComboBox(UIConstants.BORDER_LINE_STYLE_ARRAY);
colorSelectPane = new UIColorButton();
bold = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/bold.png"));
@ -229,26 +236,31 @@ public class FRFontPane extends AbstractBasicStylePane implements GlobalNameObse
isShadowCheckBox = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/shadow.png"));
isShadowCheckBox.setPreferredSize(BUTTON_SIZE);
superPane = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/sup.png"));
superPane.setPreferredSize(new Dimension(22, 18));
superPane.setPreferredSize(BUTTON_SIZE);
subPane = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/sub.png"));
subPane.setPreferredSize(new Dimension(22, 18));
subPane.setPreferredSize(BUTTON_SIZE);
isSuperOrSubPane = new TwoButtonPane(superPane, subPane);
// Component[] components_font = new Component[]{
// colorSelectPane, italic, bold, underline, isStrikethroughCheckBox, isShadowCheckBox
// };
Component[] components_font = new Component[]{
colorSelectPane, italic, bold, underline, isStrikethroughCheckBox, isShadowCheckBox
colorSelectPane, underline, isStrikethroughCheckBox, isShadowCheckBox
};
buttonPane = new JPanel(new BorderLayout());
buttonPane.add(GUICoreUtils.createFlowPane(components_font, FlowLayout.LEFT, LayoutConstants.HGAP_SMALL));
buttonPane.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
// buttonPane.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
linePane = new JPanel(new CardLayout());
initAllNames();
setToolTips();
this.setLayout(new BorderLayout());
this.add(fontNameComboBox, BorderLayout.NORTH);
this.add(createPane(), BorderLayout.CENTER);
DefaultValues defaultValues = FRContext.getDefaultValues();
populateBean(defaultValues.getFRFont());
}
private void initAllNames() {
fontSizeStyleComboBox.setGlobalName(Inter.getLocText("FRFont-Style"));
fontNameComboBox.setGlobalName(Inter.getLocText("FRFont-Family"));
fontSizeComboBox.setGlobalName(Inter.getLocText("FRFont-Size"));
colorSelectPane.setGlobalName(Inter.getLocText("FRFont-Foreground"));
@ -292,10 +304,11 @@ public class FRFontPane extends AbstractBasicStylePane implements GlobalNameObse
private JPanel createLeftPane() {
double p = TableLayout.PREFERRED;
double[] columnSize = {p};
double f = TableLayout.FILL;
double[] columnSize = {f};
double[] rowSize = {p, p, p};
Component[][] components = new Component[][]{
new Component[]{fontNameComboBox},
new Component[]{fontSizeStyleComboBox},
new Component[]{buttonPane},
new Component[]{createLinePane()}
};
@ -317,9 +330,10 @@ public class FRFontPane extends AbstractBasicStylePane implements GlobalNameObse
private JPanel createPane() {
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] columnSize = {p, f};
double[] rowSize = {p};
double[] columnSize = {f, f};
double[] rowSize = {p,p};
Component[][] components = new Component[][]{
new Component[]{null, null},
new Component[]{createLeftPane(), createRightPane()},
};
return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize);
@ -349,7 +363,7 @@ public class FRFontPane extends AbstractBasicStylePane implements GlobalNameObse
public TwoButtonPane(UIToggleButton leftButton, UIToggleButton rightButton) {
this.leftButton = leftButton;
this.rightButton = rightButton;
this.setLayout(new FlowLayout(FlowLayout.RIGHT, 1, 0));
this.setLayout(new FlowLayout(FlowLayout.LEFT, 1, 0));
this.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
initButton(leftButton);
initButton(rightButton);

178
designer_base/src/com/fr/design/gui/style/FormatPane.java

@ -7,27 +7,24 @@ import com.fr.base.TextFormat;
import com.fr.data.core.FormatField;
import com.fr.data.core.FormatField.FormatContents;
import com.fr.design.border.UIRoundedBorder;
import com.fr.design.constants.LayoutConstants;
import com.fr.design.constants.UIConstants;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.icombobox.UIComboBoxRenderer;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.ComparatorUtils;
import com.fr.general.Inter;
import com.fr.stable.ArrayUtils;
import com.fr.stable.StringUtils;
import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.border.TitledBorder;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import java.awt.*;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.*;
import java.text.Format;
import java.text.SimpleDateFormat;
@ -37,7 +34,7 @@ import java.text.SimpleDateFormat;
* @author zhou
* @since 2012-5-24上午10:57:00
*/
public class FormatPane extends AbstractBasicStylePane {
public class FormatPane extends AbstractBasicStylePane{
private static final long serialVersionUID = 724330854437726751L;
private static final int LABLE_X = 4;
@ -54,13 +51,16 @@ public class FormatPane extends AbstractBasicStylePane {
private Format format;
private UIComboBox typeComboBox;
private UIComboBox textField;
private UILabel sampleLabel;
private FormatePaneNumField patternTextField = null;
private JList patternList = null;
private JPanel contentPane;
private JPanel txtCenterPane;
private JPanel centerPane;
private JPanel formatFontPane;
private FRFontPane frFontPane;
private boolean isRightFormate;
private boolean isDate = false;
private boolean isFormat = false;
/**
* Constructor.
*/
@ -68,40 +68,70 @@ public class FormatPane extends AbstractBasicStylePane {
this.initComponents(TYPES);
}
public static void main(String[] args){
JFrame jf = new JFrame("test");
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel content = (JPanel) jf.getContentPane();
content.setLayout(new BorderLayout());
content.add(new FormatPane(), BorderLayout.CENTER);
GUICoreUtils.centerWindow(jf);
jf.setSize(290, 400);
jf.setVisible(true);
}
protected void initComponents(Integer[] types) {
this.setLayout(new BorderLayout(0, 4));
iniSampleLable();
JPanel contentPane = new JPanel(new BorderLayout(0, 4)) {
contentPane = new JPanel(new BorderLayout(0, 4)) {
@Override
public Dimension getPreferredSize() {
return new Dimension(super.getPreferredSize().width, 185);
return new Dimension(super.getPreferredSize().width, 70);
}
};
typeComboBox = new UIComboBox(types);
UIComboBoxRenderer render = createComBoxRender();
typeComboBox.setRenderer(render);
typeComboBox.addItemListener(itemListener);
contentPane.add(sampleLabel, BorderLayout.NORTH);
this.add(typeComboBox, BorderLayout.NORTH);
// this.add(typeComboBox, BorderLayout.NORTH);
centerPane = new JPanel(new CardLayout());
centerPane.add(new JPanel(), "hide");
centerPane.setPreferredSize(new Dimension(0, 0) );
centerPane.add(contentPane, "show");
this.add(centerPane, BorderLayout.CENTER);
formatFontPane = new JPanel(new BorderLayout());
formatFontPane.add(centerPane, BorderLayout.NORTH);
formatFontPane.add(new FRFontPane(), BorderLayout.CENTER);
// this.add(formatFontPane, BorderLayout.CENTER);
// content pane.
JPanel centerPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
contentPane.add(centerPane, BorderLayout.CENTER);
patternTextField = new FormatePaneNumField();
centerPane.add(patternTextField, BorderLayout.NORTH);
patternTextField.getDocument().addDocumentListener(patternTextDocumentListener);
patternList = new JList(new DefaultListModel());
centerPane.add(new UIScrollPane(patternList), BorderLayout.CENTER);
patternList.addListSelectionListener(patternListSelectionListener);
patternList.setSelectionBackground(UIConstants.LIGHT_BLUE);
patternList.setSelectionForeground(Color.black);
// init values.
txtCenterPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
contentPane.add(txtCenterPane, BorderLayout.CENTER);
textField = new UIComboBox(FormatField.getInstance().getFormatArray(getFormatContents()));
textField.addItemListener(textFieldItemListener);
textField.setEditable(true);
txtCenterPane.add(textField, BorderLayout.NORTH);
frFontPane = new FRFontPane();
double f = TableLayout.FILL;
double p = TableLayout.PREFERRED;
Component[][] components = new Component[][]{
new Component[]{null,null},
new Component[]{new UILabel(Inter.getLocText("FR-Base_Format")+" ", SwingConstants.LEFT), typeComboBox },
new Component[]{null,centerPane},
new Component[]{new UILabel(Inter.getLocText("FR-Designer_FRFont"), SwingConstants.LEFT), frFontPane},
new Component[]{null,null}
};
double[] rowSize = {p, p, p, p, p};
double[] columnSize = {p,f};
int[][] rowCount = {{1, 1},{1, 1}, {1, 1}, {1, 3}, {1, 1}};
JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_SMALL, LayoutConstants.VGAP_MEDIUM);
this.add(panel,BorderLayout.CENTER);
}
@ -187,7 +217,6 @@ public class FormatPane extends AbstractBasicStylePane {
} else {
setPatternComboBoxAndList(FormatContents.NUMBER, pattern);
}
patternTextField.setText(pattern);
} else if (format instanceof SimpleDateFormat) { // date and time
String pattern = ((SimpleDateFormat) format).toPattern();
if (!isTimeType(pattern)) {
@ -195,7 +224,6 @@ public class FormatPane extends AbstractBasicStylePane {
} else {
setPatternComboBoxAndList(FormatContents.TIME, pattern);
}
patternTextField.setText(pattern);
} else if (format instanceof TextFormat) { // Text
this.typeComboBox.setSelectedItem(FormatContents.TEXT);
}
@ -224,9 +252,9 @@ public class FormatPane extends AbstractBasicStylePane {
this.typeComboBox.setSelectedItem(formatStyle);
int i = isArrayContainPattern(FormatField.getInstance().getFormatArray(formatStyle), pattern);
if (i == -1) {
this.patternList.setSelectedIndices(ArrayUtils.EMPTY_INT_ARRAY);
this.textField.setSelectedIndex(0);
} else {
this.patternList.setSelectedIndex(i);
this.textField.setSelectedIndex(i);
}
}
@ -238,7 +266,7 @@ public class FormatPane extends AbstractBasicStylePane {
* update
*/
public Format update() {
String patternString = patternTextField.getText();
String patternString = String.valueOf(textField.getSelectedItem());
if (getFormatContents() == FormatContents.TEXT) {
return FormatField.getInstance().getFormat(getFormatContents(), patternString);
}
@ -262,10 +290,10 @@ public class FormatPane extends AbstractBasicStylePane {
this.sampleLabel.setForeground(UIManager.getColor("Label.foreground"));
try {
isRightFormate = true;
if (StringUtils.isEmpty(patternTextField.getText())) {
if (StringUtils.isEmpty(String.valueOf(textField.getSelectedItem()))) {
return;
}
this.sampleLabel.setText(FormatField.getInstance().getFormatValue(getFormatContents(), patternTextField.getText()));
this.sampleLabel.setText(FormatField.getInstance().getFormatValue(getFormatContents(), String.valueOf(textField.getSelectedItem())));
} catch (Exception e) {
this.sampleLabel.setForeground(Color.red);
this.sampleLabel.setText(e.getMessage());
@ -285,55 +313,37 @@ public class FormatPane extends AbstractBasicStylePane {
@Override
public void itemStateChanged(ItemEvent e) {
int contents = getFormatContents();
CardLayout cardLayout = (CardLayout) centerPane.getLayout();
if (isTextOrNull()) {
cardLayout.show(centerPane, "hide");
patternTextField.setText("");
} else {
cardLayout.show(centerPane, "show");
}
String[] patternArray = FormatField.getInstance().getFormatArray(contents, false);
//
DefaultListModel patternModel = (DefaultListModel) patternList.getModel();
patternModel.removeAllElements();
for (int i = 0; i < patternArray.length; i++) {
patternModel.addElement(patternArray[i]);
if(e.getStateChange() == ItemEvent.SELECTED){
int contents = getFormatContents();
String[] items = FormatField.getInstance().getFormatArray(contents);
CardLayout cardLayout = (CardLayout) centerPane.getLayout();
if (isTextOrNull()) {
centerPane.setPreferredSize(new Dimension(0, 0) );
cardLayout.show(centerPane, "hide");
} else {
textField.removeAllItems();
long begin = System.currentTimeMillis();
for (int i = 0; i < items.length; i++) {
textField.addItem(items[i]);
}
long end = System.currentTimeMillis();
System.out.println(end-begin+"ms");
centerPane.setPreferredSize(new Dimension(270, 70) );
cardLayout.show(centerPane, "show");
}
isFormat = true;
}
if (patternModel.size() > 0) {
patternList.setSelectedIndex(0);
}
}
};
/**
* text pattern document listener.
*/
DocumentListener patternTextDocumentListener = new DocumentListener() {
public void insertUpdate(DocumentEvent evt) {
refreshPreviewLabel();
}
public void removeUpdate(DocumentEvent evt) {
refreshPreviewLabel();
}
public void changedUpdate(DocumentEvent evt) {
refreshPreviewLabel();
}
};
/**
* Pattern list selection listener.
*/
ListSelectionListener patternListSelectionListener = new ListSelectionListener() {
public void valueChanged(ListSelectionEvent evt) {
if (!evt.getValueIsAdjusting()) {
patternTextField.setText((String) patternList.getSelectedValue());
ItemListener textFieldItemListener = new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if(e.getStateChange() == ItemEvent.SELECTED){
isFormat = true;
refreshPreviewLabel();
}
}
};
@ -344,6 +354,8 @@ public class FormatPane extends AbstractBasicStylePane {
*/
public void populateBean(Style style) {
this.populateBean(style.getFormat());
isFormat = false;
this.frFontPane.populateBean(style.getFRFont());
}
@Override
@ -351,7 +363,12 @@ public class FormatPane extends AbstractBasicStylePane {
* update
*/
public Style update(Style style) {
return style.deriveFormat(this.update());
if (isFormat){
isFormat = false;
return style.deriveFormat(this.update());
} else {
return style.deriveFRFont(this.frFontPane.update(style.getFRFont()));
}
}
/**
@ -401,4 +418,5 @@ public class FormatPane extends AbstractBasicStylePane {
}
}
}
}

12
designer_base/src/com/fr/design/menu/MenuManager.java

@ -138,12 +138,12 @@ public class MenuManager extends XMLFileManager {
if (name.isEmpty()) {
return;
}
try {
MenuAction action = (MenuAction) reader.getAttrAsClass().newInstance();
menu.addShortCut(action);
} catch (Exception exp) {
FRLogger.getLogger().error(exp.getMessage(), exp);
}
// try {
// MenuAction action = (MenuAction) reader.getAttrAsClass().newInstance();
// menu.addShortCut(action);
// } catch (Exception exp) {
// FRLogger.getLogger().error(exp.getMessage(), exp);
// }
} else if (reader.getTagName().equals("Menu")) {
final MenuDef submenu = new MenuDef();
String tmpVal = StringUtils.EMPTY;

4
designer_chart/src/com/fr/design/chart/series/PlotSeries/MapCustomPane.java

@ -19,7 +19,7 @@ import com.fr.general.GeneralUtils;
import com.fr.general.Inter;
import com.fr.general.data.DataModel;
import com.fr.stable.StringUtils;
import org.apache.batik.swing.svg.SVGFileFilter;
//import org.apache.batik.swing.svg.SVGFileFilter;
import javax.swing.*;
import java.awt.*;
@ -107,7 +107,7 @@ refreshAreaNameBox();
public void actionPerformed(ActionEvent evt) {
JFileChooser svgFileChooser = new JFileChooser();
svgFileChooser.addChoosableFileFilter(new SVGFileFilter());
// svgFileChooser.addChoosableFileFilter(new SVGFileFilter());
if (StringUtils.isNotBlank(lastSelectPath)) {
svgFileChooser.setSelectedFile(new File(lastSelectPath));
}

Loading…
Cancel
Save