From 7d9ff599d603af8aa4a33ccf212219256a1e4650 Mon Sep 17 00:00:00 2001 From: MoMeak Date: Wed, 19 Jul 2017 18:41:26 +0800 Subject: [PATCH 1/2] =?UTF-8?q?REPORT-2897=209.0=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E5=99=A8=E4=BF=AE=E6=94=B9=20PMD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/expand/ExpandFatherPane.java | 6 +- .../mainframe/ReportComponentComposite.java | 34 +- .../cell/settingpane/CellExpandAttrPane.java | 44 +- .../cell/settingpane/CellOtherSetPane.java | 2 +- .../cell/settingpane/CellPresentPane.java | 2 +- .../cell/settingpane/CellStylePane.java | 18 +- designer/src/com/fr/grid/GridRow.java | 3 +- .../com/fr/design/gui/style/BorderPane.java | 44 +- .../com/fr/design/gui/style/FRFontPane.java | 64 +- .../com/fr/design/gui/style/FormatPane.java | 15 - .../com/fr/design/locale/designer.properties | 22 + .../design/locale/designer_en_US.properties | 22 + .../design/locale/designer_ja_JP.properties | 24 +- .../design/locale/designer_ko_KR.properties | 23 +- .../design/locale/designer_zh_CN.properties | 22 + .../design/locale/designer_zh_TW.properties | 21 + .../com/fr/design/mainframe/JSliderPane.java | 280 ++-- .../src/com/fr/design/mainframe/FormArea.java | 1122 +++++++++-------- 18 files changed, 989 insertions(+), 779 deletions(-) diff --git a/designer/src/com/fr/design/expand/ExpandFatherPane.java b/designer/src/com/fr/design/expand/ExpandFatherPane.java index 88aeb44c3..ea863dd81 100644 --- a/designer/src/com/fr/design/expand/ExpandFatherPane.java +++ b/designer/src/com/fr/design/expand/ExpandFatherPane.java @@ -40,9 +40,9 @@ public abstract class ExpandFatherPane extends JPanel implements GlobalNameObser public ExpandFatherPane() { this.setLayout(new BorderLayout(0, LayoutConstants.VGAP_SMALL)); comboBox = new UIComboBox(new String[]{ - Inter.getLocText("None"), - Inter.getLocText("Default"), - Inter.getLocText("Custom")}); + Inter.getLocText("FR-Designer_None"), + Inter.getLocText("FR-Designer_DEFAULT"), + Inter.getLocText("FR-Designer_Custom")}); final CardLayout cardLayout = new CardLayout(); customPane = new JPanel(cardLayout); customParentColumnRowPane = new ColumnRowPane() { diff --git a/designer/src/com/fr/design/mainframe/ReportComponentComposite.java b/designer/src/com/fr/design/mainframe/ReportComponentComposite.java index 0b47214a9..b3ab87a28 100644 --- a/designer/src/com/fr/design/mainframe/ReportComponentComposite.java +++ b/designer/src/com/fr/design/mainframe/ReportComponentComposite.java @@ -6,10 +6,14 @@ import java.util.ArrayList; import javax.swing.JComponent; import javax.swing.JPanel; import javax.swing.JSplitPane; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; import com.fr.base.FRContext; +import com.fr.base.ScreenResolution; import com.fr.design.designer.EditingState; import com.fr.design.event.TargetModifiedListener; +import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.gui.icontainer.UIModeControlContainer; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.general.Inter; @@ -24,6 +28,9 @@ import com.fr.report.report.TemplateReport; * @since 2012-3-27下午12:12:05 */ public class ReportComponentComposite extends JComponent { + + private static final int MAX = 400; + private static final int MIN = 10; private JWorkBook parent; private UIModeControlContainer parentContainer = null; @@ -36,7 +43,7 @@ public class ReportComponentComposite extends JComponent { private JPanel hbarContainer; - private JPanel jSliderContainer; + private JSliderPane jSliderContainer; /** @@ -52,8 +59,28 @@ public class ReportComponentComposite extends JComponent { CellElementRegion = FRGUIPaneFactory.createBorderLayout_S_Pane(); this.add(CellElementRegion, BorderLayout.NORTH); this.add(createSouthControlPane(), BorderLayout.SOUTH); + jSliderContainer.getShowVal().getDocument().addDocumentListener(jSliderContainerListener); } + DocumentListener jSliderContainerListener = new DocumentListener() { + @Override + public void insertUpdate(DocumentEvent e) { + double value = Integer.parseInt(jSliderContainer.getShowVal().getText().substring(0, jSliderContainer.getShowVal().getText().indexOf("%"))); + value = value>MAX ? MAX : value; + value = value= 0) { templateStateList.set(oldIndex, centerCardPane.editingComponet.createEditingState()); @@ -63,7 +90,7 @@ public class ReportComponentComposite extends JComponent { protected void doAfterChange(int newIndex) { WorkBook workbook = getEditingWorkBook(); if (workbook == null) { - FRContext.getLogger().error(Inter.getLocText("Read_failure") + "!"); + FRContext.getLogger().error(Inter.getLocText("FR-Designer_Read_failure") + "!"); //AUGUST:加个报错,不然测试总是SB的认为打不开一个坏的excel文件就是BUG,也不知道去检查下源文件。 return; } @@ -160,7 +187,8 @@ public class ReportComponentComposite extends JComponent { hbarContainer.add(centerCardPane.editingComponet.getHorizontalScrollBar()); // JSplitPane splitpane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, sheetNameTab, hbarContainer); JPanel southPane = new JPanel(new BorderLayout()); - JSplitPane splitpane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, sheetNameTab, JSliderPane.getInstance()); + jSliderContainer = JSliderPane.getInstance(); + JSplitPane splitpane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, sheetNameTab, jSliderContainer); splitpane.setBorder(null); splitpane.setDividerSize(3); splitpane.setResizeWeight(1); diff --git a/designer/src/com/fr/design/mainframe/cell/settingpane/CellExpandAttrPane.java b/designer/src/com/fr/design/mainframe/cell/settingpane/CellExpandAttrPane.java index d6a5a9bef..128c01418 100644 --- a/designer/src/com/fr/design/mainframe/cell/settingpane/CellExpandAttrPane.java +++ b/designer/src/com/fr/design/mainframe/cell/settingpane/CellExpandAttrPane.java @@ -62,22 +62,22 @@ 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); +// 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")); - rightFatherPane.setGlobalName(Inter.getLocText("ExpandD-Up_Father_Cell")); - horizontalExpandableCheckBox.setGlobalName(Inter.getLocText("ExpandD-Expandable")); - verticalExpandableCheckBox.setGlobalName(Inter.getLocText("ExpandD-Expandable")); + expandDirectionButton.setGlobalName(Inter.getLocText("FR-Designer_ExpandD_Expand_Direction")); + leftFatherPane.setGlobalName(Inter.getLocText("FR-Designer_LeftParent")); + rightFatherPane.setGlobalName(Inter.getLocText("FR-Designer_ExpandD_Up_Father_Cell")); + horizontalExpandableCheckBox.setGlobalName(Inter.getLocText("FR-Designer_ExpandD_Expandable")); + verticalExpandableCheckBox.setGlobalName(Inter.getLocText("FR-Designer_ExpandD_Expandable")); } private JPanel layoutPane() { @@ -111,9 +111,9 @@ public class CellExpandAttrPane extends AbstractCellAttrPane { 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}, + new Component[]{new UILabel(" "+Inter.getLocText("FR-Designer_ExpandD_Expand_Direction")+" ", SwingConstants.LEFT), expandDirectionButton}, + new Component[]{new UILabel(" "+Inter.getLocText("FR-Designer_LeftParent"), SwingConstants.LEFT), leftFatherPane}, + new Component[]{new UILabel(" "+Inter.getLocText("FR-Designer_ExpandD_Up_Father_Cell"), SwingConstants.LEFT), rightFatherPane}, }; double[] rowSize = {p, p, p, p, p, p}; double[] columnSize = {p, f}; @@ -128,7 +128,7 @@ public class CellExpandAttrPane extends AbstractCellAttrPane { 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}, + new Component[]{new UILabel(" "+Inter.getLocText("FR-Designer_ExpendSort"), SwingConstants.RIGHT), sortAfterExpand}, }; double[] rowSize = {p, p, p, p, p, p, p, p}; double[] columnSize = {p, f}; @@ -176,7 +176,7 @@ public class CellExpandAttrPane extends AbstractCellAttrPane { @Override public String getIconPath() { // return "com/fr/design/images/expand/cellAttr.gif"; - return Inter.getLocText("Expand"); + return Inter.getLocText("FR-Designer_Expand"); } @@ -187,19 +187,19 @@ public class CellExpandAttrPane extends AbstractCellAttrPane { cellExpandAttr = new CellExpandAttr(); cellElement.setCellExpandAttr(cellExpandAttr); } - if (ComparatorUtils.equals(getGlobalName(), Inter.getLocText("ExpandD-Expand_Direction"))) { + if (ComparatorUtils.equals(getGlobalName(), Inter.getLocText("FR-Designer_ExpandD_Expand_Direction"))) { cellExpandAttr.setDirection(expandDirectionButton.getSelectedItem()); } - if (ComparatorUtils.equals(getGlobalName(), Inter.getLocText("LeftParent"))) { + if (ComparatorUtils.equals(getGlobalName(), Inter.getLocText("FR-Designer_LeftParent"))) { this.leftFatherPane.update(cellExpandAttr); } - if (ComparatorUtils.equals(getGlobalName(), Inter.getLocText("ExpandD-Up_Father_Cell"))) { + if (ComparatorUtils.equals(getGlobalName(), Inter.getLocText("FR-Designer_ExpandD_Up_Father_Cell"))) { this.rightFatherPane.update(cellExpandAttr); } // extendable - if (ComparatorUtils.equals(getGlobalName(), Inter.getLocText("ExpandD-Expandable"))) { + if (ComparatorUtils.equals(getGlobalName(), Inter.getLocText("FR-Designer_ExpandD-Expandable"))) { if (horizontalExpandableCheckBox.isSelected()) { if (verticalExpandableCheckBox.isSelected()) { cellExpandAttr.setExtendable(CellExpandAttr.Both_EXTENDABLE); diff --git a/designer/src/com/fr/design/mainframe/cell/settingpane/CellOtherSetPane.java b/designer/src/com/fr/design/mainframe/cell/settingpane/CellOtherSetPane.java index c5d7af1b1..ee4ecfa4d 100644 --- a/designer/src/com/fr/design/mainframe/cell/settingpane/CellOtherSetPane.java +++ b/designer/src/com/fr/design/mainframe/cell/settingpane/CellOtherSetPane.java @@ -215,7 +215,7 @@ public class CellOtherSetPane extends AbstractCellAttrPane { @Override public String getIconPath() { // return "com/fr/design/images/m_format/cellstyle/otherset.png"; - return Inter.getLocText("Other"); + return Inter.getLocText("FR-Designer_Other"); } @Override diff --git a/designer/src/com/fr/design/mainframe/cell/settingpane/CellPresentPane.java b/designer/src/com/fr/design/mainframe/cell/settingpane/CellPresentPane.java index d0f13c5d2..8d29ff133 100644 --- a/designer/src/com/fr/design/mainframe/cell/settingpane/CellPresentPane.java +++ b/designer/src/com/fr/design/mainframe/cell/settingpane/CellPresentPane.java @@ -40,7 +40,7 @@ public class CellPresentPane extends AbstractCellAttrPane { @Override public String getIconPath() { // return "com/fr/design/images/data/source/dataDictionary.png"; - return Inter.getLocText("Present"); + return Inter.getLocText("FR-Designer_Present"); } @Override diff --git a/designer/src/com/fr/design/mainframe/cell/settingpane/CellStylePane.java b/designer/src/com/fr/design/mainframe/cell/settingpane/CellStylePane.java index 2d508c4f3..ce0351931 100644 --- a/designer/src/com/fr/design/mainframe/cell/settingpane/CellStylePane.java +++ b/designer/src/com/fr/design/mainframe/cell/settingpane/CellStylePane.java @@ -42,14 +42,14 @@ public class CellStylePane 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 CellStylePane().createContentPane(), BorderLayout.CENTER); - GUICoreUtils.centerWindow(jf); - jf.setSize(290, 400); - jf.setVisible(true); +// 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 @@ -120,7 +120,7 @@ public class CellStylePane extends AbstractCellAttrPane { @Override public String title4PopupWindow() { - return Inter.getLocText("Style"); + return Inter.getLocText(Inter.getLocText("FR-Designer_Style")); } public void setSelectedByIds(int level, String... id) { diff --git a/designer/src/com/fr/grid/GridRow.java b/designer/src/com/fr/grid/GridRow.java index c111c7188..4c42ce630 100644 --- a/designer/src/com/fr/grid/GridRow.java +++ b/designer/src/com/fr/grid/GridRow.java @@ -21,6 +21,7 @@ import javax.swing.plaf.ComponentUI; */ public class GridRow extends GridHeader { + private static final int MAX = 5; private int resolution = ScreenResolution.getScreenResolution(); @Override @@ -65,7 +66,7 @@ public class GridRow extends GridHeader { * Calculates max char number. */ private int caculateMaxCharNumber(ElementCasePane reportPane) { - int maxCharNumber = 5; + int maxCharNumber = MAX; maxCharNumber = Math.max(maxCharNumber, ("" + (reportPane.getGrid().getVerticalValue() + reportPane.getGrid().getVerticalExtent())).length() + 1); return maxCharNumber; diff --git a/designer_base/src/com/fr/design/gui/style/BorderPane.java b/designer_base/src/com/fr/design/gui/style/BorderPane.java index d214198a8..585bfe98b 100644 --- a/designer_base/src/com/fr/design/gui/style/BorderPane.java +++ b/designer_base/src/com/fr/design/gui/style/BorderPane.java @@ -87,10 +87,10 @@ public class BorderPane extends AbstractBasicStylePane { 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[]{new UILabel(Inter.getLocText("FR-Designer_outBorder") +" ", 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[]{new UILabel(Inter.getLocText("FR-Designer_inBorder") +" ", SwingConstants.LEFT),innerToggleButton = new UIToggleButton(BaseUtils.readIcon("com/fr/design/images/m_format/in.png"))}, new Component[]{null,insidePane}, new Component[]{null,null} }; @@ -105,26 +105,30 @@ public class BorderPane extends AbstractBasicStylePane { 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) { - boolean value = outerToggleButton.isSelected(); - topToggleButton.setSelected(value); - bottomToggleButton.setSelected(value); - leftToggleButton.setSelected(value); - rightToggleButton.setSelected(value); - } - }); - innerToggleButton.addChangeListener(new ChangeListener() { - @Override - public void stateChanged(ChangeEvent e) { - boolean value = innerToggleButton.isSelected(); - horizontalToggleButton.setSelected(value); - verticalToggleButton.setSelected(value); - } - }); + outerToggleButton.addChangeListener(outerToggleButtonChangeListener); + innerToggleButton.addChangeListener(innerToggleButtonChangeListener); } + ChangeListener outerToggleButtonChangeListener = new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + boolean value = outerToggleButton.isSelected(); + topToggleButton.setSelected(value); + bottomToggleButton.setSelected(value); + leftToggleButton.setSelected(value); + rightToggleButton.setSelected(value); + } + }; + + ChangeListener innerToggleButtonChangeListener = new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + boolean value = innerToggleButton.isSelected(); + horizontalToggleButton.setSelected(value); + verticalToggleButton.setSelected(value); + } + }; + private void initButtonsWithIcon(){ topToggleButton = new UIToggleButton(BaseUtils.readIcon("/com/fr/base/images/dialog/border/top.png")); leftToggleButton = new UIToggleButton(BaseUtils.readIcon("/com/fr/base/images/dialog/border/left.png")); diff --git a/designer_base/src/com/fr/design/gui/style/FRFontPane.java b/designer_base/src/com/fr/design/gui/style/FRFontPane.java index bfe86801f..e7267d683 100644 --- a/designer_base/src/com/fr/design/gui/style/FRFontPane.java +++ b/designer_base/src/com/fr/design/gui/style/FRFontPane.java @@ -42,7 +42,7 @@ public class FRFontPane extends AbstractBasicStylePane implements GlobalNameObse 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(20, 18); - private final String[] fontSizeStyles = {Inter.getLocText("FRFont-plain"), Inter.getLocText("FRFont-bold"), Inter.getLocText("FRFont-italic"), Inter.getLocText("FRFont-bolditalic")}; + private final String[] fontSizeStyles = {Inter.getLocText("FR-Designer_FRFont_plain"), Inter.getLocText("FR-Designer_FRFont_bold"), Inter.getLocText("FR-Designer_FRFont_italic"), Inter.getLocText("FR-Designer_FRFont_bolditalic")}; private JPanel buttonPane; private JPanel isSuperOrSubPane; private UIComboBox fontNameComboBox; @@ -82,7 +82,7 @@ public class FRFontPane extends AbstractBasicStylePane implements GlobalNameObse @Override protected String title4PopupWindow() { - return Inter.getLocText("Sytle-FRFont"); + return Inter.getLocText("FR-Designer_Sytle-FRFont"); } /** @@ -130,34 +130,34 @@ public class FRFontPane extends AbstractBasicStylePane implements GlobalNameObse */ public FRFont update(FRFont frFont) { - if (ComparatorUtils.equals(globalNameListener.getGlobalName(), Inter.getLocText("FRFont-Family"))) { + if (ComparatorUtils.equals(globalNameListener.getGlobalName(), Inter.getLocText("FR-Designer_Name"))) { frFont = frFont.applyName((String) fontNameComboBox.getSelectedItem()); } - if (ComparatorUtils.equals(globalNameListener.getGlobalName(), Inter.getLocText("FRFont-Style"))) { + if (ComparatorUtils.equals(globalNameListener.getGlobalName(), Inter.getLocText("FR-Designer_FRFont_Style"))) { frFont = frFont.applyStyle(fontSizeStyleComboBox.getSelectedIndex()); } - if (ComparatorUtils.equals(globalNameListener.getGlobalName(), Inter.getLocText("FRFont-Size"))) { + if (ComparatorUtils.equals(globalNameListener.getGlobalName(), Inter.getLocText("FR-Designer-FRFont_Size"))) { frFont = frFont.applySize(Float.parseFloat(fontSizeComboBox.getSelectedItem().toString())); } - if (ComparatorUtils.equals(globalNameListener.getGlobalName(), Inter.getLocText("FRFont-Foreground"))) { + if (ComparatorUtils.equals(globalNameListener.getGlobalName(), Inter.getLocText("FR-Designer_FRFont_Foreground"))) { frFont = frFont.applyForeground(this.colorSelectPane.getColor()); } - if (ComparatorUtils.equals(globalNameListener.getGlobalName(), Inter.getLocText("FRFont-Underline"))) { + if (ComparatorUtils.equals(globalNameListener.getGlobalName(), Inter.getLocText("FR-Designer_FRFont_Underline"))) { int line = underline.isSelected() ? this.underlineCombo.getSelectedLineStyle() : Constants.LINE_NONE; frFont = frFont.applyUnderline(line); } - if (ComparatorUtils.equals(globalNameListener.getGlobalName(), Inter.getLocText("Line-Style"))) { + if (ComparatorUtils.equals(globalNameListener.getGlobalName(), Inter.getLocText("FR-Designer-FRFont_Line_Style"))) { frFont = frFont.applyUnderline(this.underlineCombo.getSelectedLineStyle()); } - if (ComparatorUtils.equals(globalNameListener.getGlobalName(), Inter.getLocText("FRFont-Strikethrough"))) { + if (ComparatorUtils.equals(globalNameListener.getGlobalName(), Inter.getLocText("FR-Designer_FRFont_Strikethrough"))) { frFont = frFont.applyStrikethrough(isStrikethroughCheckBox.isSelected()); } - if (ComparatorUtils.equals(globalNameListener.getGlobalName(), Inter.getLocText("FRFont-Shadow"))) { + if (ComparatorUtils.equals(globalNameListener.getGlobalName(), Inter.getLocText("FR-Designer_FRFont_Shadow"))) { frFont = frFont.applyShadow(isShadowCheckBox.isSelected()); } @@ -175,7 +175,7 @@ public class FRFontPane extends AbstractBasicStylePane implements GlobalNameObse private FRFont updateSubSuperscript(FRFont frFont) { boolean isSuper = frFont.isSuperscript(); boolean isSub = frFont.isSubscript(); - if (ComparatorUtils.equals(globalNameListener.getGlobalName(), Inter.getLocText("FRFont-Superscript"))) { + if (ComparatorUtils.equals(globalNameListener.getGlobalName(), Inter.getLocText("FR-Designer_FRFont_Superscript"))) { //如果上标没有选中,点击则选中上标,并且下标一定是不选中状态 //如果上标选中,点击则取消选中上标,字体回复正常 if (superPane.isSelected() && !isSuper) { @@ -185,7 +185,7 @@ public class FRFontPane extends AbstractBasicStylePane implements GlobalNameObse frFont = frFont.applySuperscript(false); } } - if (ComparatorUtils.equals(globalNameListener.getGlobalName(), Inter.getLocText("FRFont-Subscript"))) { + if (ComparatorUtils.equals(globalNameListener.getGlobalName(), Inter.getLocText("FR-Designer_FRFont_Subscript"))) { if (subPane.isSelected() && !isSub) { frFont = frFont.applySubscript(true); frFont = frFont.applySuperscript(false); @@ -260,29 +260,29 @@ public class FRFontPane extends AbstractBasicStylePane implements GlobalNameObse } 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")); - italic.setGlobalName(Inter.getLocText("FRFont-italic")); - bold.setGlobalName(Inter.getLocText("FRFont-bold")); - underline.setGlobalName(Inter.getLocText("FRFont-Underline")); - underlineCombo.setGlobalName(Inter.getLocText("Line-Style")); - isStrikethroughCheckBox.setGlobalName(Inter.getLocText("FRFont-Strikethrough")); - isShadowCheckBox.setGlobalName(Inter.getLocText("FRFont-Shadow")); - superPane.setGlobalName(Inter.getLocText("FRFont-Superscript")); - subPane.setGlobalName(Inter.getLocText("FRFont-Subscript")); + fontSizeStyleComboBox.setGlobalName(Inter.getLocText("FR-Designer_FRFont_Style")); + fontNameComboBox.setGlobalName(Inter.getLocText("FR-Designer_Name")); + fontSizeComboBox.setGlobalName(Inter.getLocText("FR-Designer-FRFont_Size")); + colorSelectPane.setGlobalName(Inter.getLocText("FR-Designer_FRFont_Foreground")); + italic.setGlobalName(Inter.getLocText("FR-Designer_FRFont_italic")); + bold.setGlobalName(Inter.getLocText("FR-Designer_FRFont_bold")); + underline.setGlobalName(Inter.getLocText("FR-Designer_FRFont_Underline")); + underlineCombo.setGlobalName(Inter.getLocText("FR-Designer-FRFont_Line_Style")); + isStrikethroughCheckBox.setGlobalName(Inter.getLocText("FR-Designer_FRFont_Strikethrough")); + isShadowCheckBox.setGlobalName(Inter.getLocText("FR-Designer_FRFont_Shadow")); + superPane.setGlobalName(Inter.getLocText("FR-Designer_FRFont_Superscript")); + subPane.setGlobalName(Inter.getLocText("FR-Designer_FRFont_Subscript")); } private void setToolTips() { - colorSelectPane.setToolTipText(Inter.getLocText("FRFont-Foreground")); - italic.setToolTipText(Inter.getLocText("FRFont-italic")); - bold.setToolTipText(Inter.getLocText("FRFont-bold")); - underline.setToolTipText(Inter.getLocText("FRFont-Underline")); - isStrikethroughCheckBox.setToolTipText(Inter.getLocText("FRFont-Strikethrough")); - isShadowCheckBox.setToolTipText(Inter.getLocText("FRFont-Shadow")); - superPane.setToolTipText(Inter.getLocText("FRFont-Superscript")); - subPane.setToolTipText(Inter.getLocText("FRFont-Subscript")); + colorSelectPane.setToolTipText(Inter.getLocText("FR-Designer_FRFont_Foreground")); + italic.setToolTipText(Inter.getLocText("FR-Designer_FRFont_italic")); + bold.setToolTipText(Inter.getLocText("FR-Designer_FRFont_bold")); + underline.setToolTipText(Inter.getLocText("FR-Designer_FRFont_Underline")); + isStrikethroughCheckBox.setToolTipText(Inter.getLocText("FR-Designer_FRFont_Strikethrough")); + isShadowCheckBox.setToolTipText(Inter.getLocText("FR-Designer_FRFont_Shadow")); + superPane.setToolTipText(Inter.getLocText("FR-Designer_FRFont_Superscript")); + subPane.setToolTipText(Inter.getLocText("FR-Designer_FRFont_Subscript")); } diff --git a/designer_base/src/com/fr/design/gui/style/FormatPane.java b/designer_base/src/com/fr/design/gui/style/FormatPane.java index 7dc5f108f..4d81d0101 100644 --- a/designer_base/src/com/fr/design/gui/style/FormatPane.java +++ b/designer_base/src/com/fr/design/gui/style/FormatPane.java @@ -81,9 +81,7 @@ public class FormatPane extends AbstractBasicStylePane{ protected void initComponents(Integer[] types) { this.setLayout(new BorderLayout(0, 4)); - iniSampleLable(); - contentPane = new JPanel(new BorderLayout(0, 4)) { @Override public Dimension getPreferredSize() { @@ -91,33 +89,24 @@ public class FormatPane extends AbstractBasicStylePane{ } }; typeComboBox = new UIComboBox(types); - UIComboBoxRenderer render = createComBoxRender(); typeComboBox.setRenderer(render); typeComboBox.addItemListener(itemListener); contentPane.add(sampleLabel, 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"); - formatFontPane = new JPanel(new BorderLayout()); formatFontPane.add(centerPane, BorderLayout.NORTH); formatFontPane.add(new FRFontPane(), BorderLayout.CENTER); - -// this.add(formatFontPane, BorderLayout.CENTER); - // content pane. 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[][]{ @@ -132,7 +121,6 @@ public class FormatPane extends AbstractBasicStylePane{ 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); - } protected UIComboBoxRenderer createComBoxRender(){ @@ -323,12 +311,9 @@ public class FormatPane extends AbstractBasicStylePane{ 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"); } diff --git a/designer_base/src/com/fr/design/locale/designer.properties b/designer_base/src/com/fr/design/locale/designer.properties index 0e51b4c21..8cbd876a2 100644 --- a/designer_base/src/com/fr/design/locale/designer.properties +++ b/designer_base/src/com/fr/design/locale/designer.properties @@ -2011,3 +2011,25 @@ FR-Designer_Float_Element=Float Element FR-Designer_Widget_Library=Widget Library FR-Designer_No_Settings_Available=No Settings Available! FR-Designer_Configured_Roles=Configured role +FR-Designer_Scale_EnlargeOrReduce=Scale +FR-Designer_Scale_selfAdaptButton=Fit the selected area exactly +FR-Designer_Scale_customButton=custom +FR-Designer_FRFont_Subscript=Subscript +FR-Designer_FRFont_Superscript=Superscript +FR-Designer_FRFont_Shadow=Shadow +FR-Designer_FRFont_Strikethrough=Strikethrough +FR-Designer_FRFont_Underline=Underline +FR-Designer_FRFont_bold=bold +FR-Designer_FRFont_italic=italic +FR-Designer_FRFont_Foreground=Foreground +FR-Designer_FRFont_Style=Style +FR-Designer_FRFont_plain=plain +FR-Designer_FRFont_bolditalic=bolditalic +FR-Designer_outBorder=outBorder +FR-Designer_inBorder=inBorder +FR-Designer_ExpandD_Up_Father_Cell=Up_Father_Cell +FR-Designer_ExpandD_Expand_Direction=Expand_Direction +FR-Designer_Expand=Expand +FR-Designer_ExpendSort=ExpendSort +FR-Designer_ExpandD_Expandable=Expandable +FR-Designer_Read_failure=Read_failure diff --git a/designer_base/src/com/fr/design/locale/designer_en_US.properties b/designer_base/src/com/fr/design/locale/designer_en_US.properties index 296dcbe7a..9d5a8a9fe 100644 --- a/designer_base/src/com/fr/design/locale/designer_en_US.properties +++ b/designer_base/src/com/fr/design/locale/designer_en_US.properties @@ -2011,3 +2011,25 @@ FR-Designer_Float_Element=Float Element FR-Designer_Widget_Library=Widget Library FR-Designer_No_Settings_Available=No Settings Available! FR-Designer_Configured_Roles=Configured role +FR-Designer_Scale_EnlargeOrReduce=Scale +FR-Designer_Scale_selfAdaptButton=Fit the selected area exactly +FR-Designer_Scale_customButton=custom +FR-Designer_FRFont_Subscript=Subscript +FR-Designer_FRFont_Superscript=\ +FR-Designer_FRFont_Shadow=Shadow +FR-Designer_FRFont_Strikethrough=Strikethrough +FR-Designer_FRFont_Underline=Underline +FR-Designer_FRFont_bold=bold +FR-Designer_FRFont_italic=italic +FR-Designer_FRFont_Foreground=Foreground +FR-Designer_FRFont_Style=Style +FR-Designer_FRFont_plain=plain +FR-Designer_FRFont_bolditalic=bolditalic +FR-Designer_outBorder=outBorder +FR-Designer_inBorder=inBorder +FR-Designer_ExpandD_Up_Father_Cell=Up_Father_Cell +FR-Designer_ExpandD_Expand_Direction=Expand_Direction +FR-Designer_Expand=Expand +FR-Designer_ExpendSort=ExpendSort +FR-Designer_ExpandD_Expandable=Expandable +FR-Designer_Read_failure=Read_failure diff --git a/designer_base/src/com/fr/design/locale/designer_ja_JP.properties b/designer_base/src/com/fr/design/locale/designer_ja_JP.properties index 03514583a..4caf82100 100644 --- a/designer_base/src/com/fr/design/locale/designer_ja_JP.properties +++ b/designer_base/src/com/fr/design/locale/designer_ja_JP.properties @@ -1987,4 +1987,26 @@ FR-Designer_Cell_Attributes=\u30BB\u30EB\u5C5E\u6027 FR-Designer_Float_Element=\u30D5\u30ED\u30FC\u30C8\u8981\u7D20 FR-Designer_Widget_Library= FR-Designer_No_Settings_Available= -FR-Designer_Configured_Roles=\u69CB\u6210\u3055\u308C\u305F\u5F79\u5272 \ No newline at end of file +FR-Designer_Configured_Roles=\u69CB\u6210\u3055\u308C\u305F\u5F79\u5272 +FR-Designer_Scale_EnlargeOrReduce= +FR-Designer_Scale_selfAdaptButton=\ +FR-Designer_Scale_customButton=\ +FR-Designer_FRFont_Subscript=\ +FR-Designer_FRFont_Superscript=\ +FR-Designer_FRFont_Shadow=\ +FR-Designer_FRFont_Strikethrough=\ +FR-Designer_FRFont_Underline=\ +FR-Designer_FRFont_bold=\ +FR-Designer_FRFont_italic=\ +FR-Designer_FRFont_Foreground=\ +FR-Designer_FRFont_Style=\ +FR-Designer_FRFont_plain=\ +FR-Designer_FRFont_bolditalic=\ +FR-Designer_outBorder=\ +FR-Designer_inBorder=\ +FR-Designer_ExpandD_Up_Father_Cell=\ +FR-Designer_ExpandD_Expand_Direction=\ +FR-Designer_Expand=\ +FR-Designer_ExpendSort=\ +FR-Designer_ExpandD_Expandable=\ +FR-Designer_Read_failure=\ \ No newline at end of file diff --git a/designer_base/src/com/fr/design/locale/designer_ko_KR.properties b/designer_base/src/com/fr/design/locale/designer_ko_KR.properties index cafc02022..6cd6849c7 100644 --- a/designer_base/src/com/fr/design/locale/designer_ko_KR.properties +++ b/designer_base/src/com/fr/design/locale/designer_ko_KR.properties @@ -1987,4 +1987,25 @@ FR-Designer_Cell_Attributes=\uC140\uC18D\uC131 FR-Designer_Float_Element=\uD638\uBC84\uC694\uC18C FR-Designer_Widget_Library= FR-Designer_No_Settings_Available= -FR-Designer_Configured_Roles=\uC5ED\uD560\uC774\uAD6C\uC131\uB418\uC5C8\uC2B5\uB2C8\uB2E4. \ No newline at end of file +FR-Designer_Configured_Roles=\uC5ED\uD560\uC774\uAD6C\uC131\uB418\uC5C8\uC2B5\uB2C8\uB2E4. +FR-Designer_Scale_EnlargeOrReduce= +FR-Designer_Scale_selfAdaptButton=\ +FR-Designer_FRFont_Subscript=\ +FR-Designer_FRFont_Superscript=\ +FR-Designer_FRFont_Shadow=\ +FR-Designer_FRFont_Strikethrough=\ +FR-Designer_FRFont_Underline=\ +FR-Designer_FRFont_bold=\ +FR-Designer_FRFont_italic=\ +FR-Designer_FRFont_Foreground=\ +FR-Designer_FRFont_Style=\ +FR-Designer_FRFont_plain=\ +FR-Designer_FRFont_bolditalic=\ +FR-Designer_outBorder=\ +FR-Designer_inBorder=\ +FR-Designer_ExpandD_Up_Father_Cell=\ +FR-Designer_ExpandD_Expand_Direction=\ +FR-Designer_Expand=\ +FR-Designer_ExpendSort=\ +FR-Designer_ExpandD_Expandable=\ +FR-Designer_Read_failure=\ \ No newline at end of file diff --git a/designer_base/src/com/fr/design/locale/designer_zh_CN.properties b/designer_base/src/com/fr/design/locale/designer_zh_CN.properties index 1675df05e..61912d31c 100644 --- a/designer_base/src/com/fr/design/locale/designer_zh_CN.properties +++ b/designer_base/src/com/fr/design/locale/designer_zh_CN.properties @@ -2009,3 +2009,25 @@ FR-Designer_Float_Element=\u60AC\u6D6E\u5143\u7D20 FR-Designer_Widget_Library=\u7EC4\u4EF6\u5E93 FR-Designer_No_Settings_Available=\u65E0\u53EF\u7528\u914D\u7F6E\u9879\uFF01 FR-Designer_Configured_Roles=\u5DF2\u914D\u7F6E\u89D2\u8272 +FR-Designer_Scale_EnlargeOrReduce=\u7F29\u653E +FR-Designer_Scale_selfAdaptButton=\u6070\u597D\u5BB9\u7EB3\u9009\u5B9A\u533A\u57DF +FR-Designer_Scale_customButton=\u81EA\u5B9A\u4E49 +FR-Designer_FRFont_Subscript=\u4E0B\u6807 +FR-Designer_FRFont_Superscript=\u4E0A\u6807 +FR-Designer_FRFont_Shadow=\u9634\u5F71 +FR-Designer_FRFont_Strikethrough=\u5220\u9664\u7EBF +FR-Designer_FRFont_Underline=\u4E0B\u5212\u7EBF +FR-Designer_FRFont_bold=\u52A0\u7C97 +FR-Designer_FRFont_italic=\u659C\u4F53 +FR-Designer_FRFont_Foreground=\u989C\u8272 +FR-Designer_FRFont_Style=\u5B57\u5F62 +FR-Designer_FRFont_plain=\u5E38\u89C4 +FR-Designer_FRFont_bolditalic=\u52A0\u7C97\u503E\u659C +FR-Designer_outBorder=\u5916\u8FB9\u6846 +FR-Designer_inBorder=\u5185\u8FB9\u6846 +FR-Designer_ExpandD_Up_Father_Cell=\u4E0A\u7236\u683C +FR-Designer_ExpandD_Expand_Direction=\u6269\u5C55\u65B9\u5411 +FR-Designer_Expand=\u6269\u5C55 +FR-Designer_ExpendSort=\u6269\u5C55\u540E\u6392\u5E8F +FR-Designer_ExpandD_Expandable=\u53EF\u4F38\u5C55\u6027 +FR-Designer_Read_failure=\u8BFB\u53D6\u5931\u8D25\uFF0C\u53EF\u80FD\u6E90\u6587\u4EF6\u5DF2\u635F\u574F diff --git a/designer_base/src/com/fr/design/locale/designer_zh_TW.properties b/designer_base/src/com/fr/design/locale/designer_zh_TW.properties index 269d4e2e4..6ed80f9d0 100644 --- a/designer_base/src/com/fr/design/locale/designer_zh_TW.properties +++ b/designer_base/src/com/fr/design/locale/designer_zh_TW.properties @@ -2010,3 +2010,24 @@ FR-Designer_Float_Element=\u61F8\u6D6E\u5143\u7D20 FR-Designer_Widget_Library=\u7D44\u4EF6\u5EAB FR-Designer_No_Settings_Available=\u7121\u53EF\u7528\u914D\u5BD8\u9805\uFF01 FR-Designer_Configured_Roles=\u5DF2\u914D\u7F6E\u89D2\u8272 +FR-Designer_Scale_selfAdaptButton=\ +FR-Designer_Scale_customButton=\ +FR-Designer_FRFont_Subscript=\ +FR-Designer_FRFont_Superscript=\ +FR-Designer_FRFont_Shadow=\ +FR-Designer_FRFont_Strikethrough=\ +FR-Designer_FRFont_Underline=\ +FR-Designer_FRFont_bold=\ +FR-Designer_FRFont_italic=\ +FR-Designer_FRFont_Foreground=\ +FR-Designer_FRFont_Style=\ +FR-Designer_FRFont_plain=\ +FR-Designer_FRFont_bolditalic=\ +FR-Designer_outBorder=\ +FR-Designer_inBorder=\ +FR-Designer_ExpandD_Up_Father_Cell=\ +FR-Designer_ExpandD_Expand_Direction=\ +FR-Designer_Expand=\ +FR-Designer_ExpendSort=\ +FR-Designer_ExpandD_Expandable=\ +FR-Designer_Read_failure=\ diff --git a/designer_base/src/com/fr/design/mainframe/JSliderPane.java b/designer_base/src/com/fr/design/mainframe/JSliderPane.java index c2d163643..7125b53b1 100644 --- a/designer_base/src/com/fr/design/mainframe/JSliderPane.java +++ b/designer_base/src/com/fr/design/mainframe/JSliderPane.java @@ -2,6 +2,7 @@ package com.fr.design.mainframe; import com.fr.base.BaseUtils; import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.ibutton.UIRadioButton; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.islider.UISlider; import com.fr.design.gui.itextfield.UITextField; @@ -9,6 +10,7 @@ import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.Inter; import javax.swing.*; +import javax.swing.border.MatteBorder; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.event.DocumentEvent; @@ -17,14 +19,24 @@ import javax.swing.plaf.basic.BasicSliderUI; import java.awt.*; import java.awt.event.*; import java.math.BigDecimal; -import java.util.Observable; /** * Created by MoMeak on 2017/7/13. */ public class JSliderPane extends JPanel { - private final int KERNING = 2; + private static final double ONEPOINTEIGHT = 1.8; + private static final int SIX = 6; + private static final int TEN = 10; + private static final int ONEEIGHT = 18; + private static final int FOURTEN = 40; + private static final int HALFHUNDRED = 50; + private static final int HUNDRED = 100; + private static final int TWOHUNDRED = 200; + private static final int THREEHUNDRED = 300; + private static final int FOURHUNDRED = 400; + private static final int DIALOGWIDTH = 150; + private static final int DIALOGHEIGHT = 200; public int showValue = 100; public double resolutionTimes = 1.0; private static JSliderPane THIS; @@ -34,23 +46,30 @@ public class JSliderPane extends JPanel { private int sliderValue; private UIButton downButton; private UIButton upButton; + private UIButton showValButton; + private UIRadioButton twoHundredButton; + private UIRadioButton oneHundredButton; + private UIRadioButton SevenFiveButton; + private UIRadioButton fiveTenButton; + private UIRadioButton twoFiveButton; + private UIRadioButton selfAdaptButton; + private UIRadioButton customButton; //拖动条处理和button、直接输入不一样 private boolean isButtonOrIsTxt = true; - private boolean isDialogOut = false; // 是否弹出 - private Dialog dialog; + private PopupPane dialog; + private int upButtonX; public JSliderPane() { this.setLayout(new BorderLayout()); - slider = new UISlider(0,100,50); + slider = new UISlider(0,HUNDRED,HALFHUNDRED); slider.setUI(new JSliderPaneUI(slider)); slider.addChangeListener(listener); showVal = new UITextField(); showVal.setText("100%"); - showVal.setPreferredSize(new Dimension(40,18)); + showVal.setPreferredSize(new Dimension(FOURTEN,ONEEIGHT)); showVal.getDocument().addDocumentListener(showValDocumentListener); -// showVal.addMouseListener(showValMouseListener); downButton = new UIButton(BaseUtils.readIcon("com/fr/design/images/data/source/moveDown.png")); upButton = new UIButton(BaseUtils.readIcon("com/fr/design/images/data/source/moveUp.png")); @@ -61,21 +80,23 @@ public class JSliderPane extends JPanel { JPanel panel = new JPanel(new FlowLayout(1,1,0)); + showValButton = new UIButton(showVal.getText()); + showValButton.setBorderPainted(false); + showValButton.setPreferredSize(new Dimension(HALFHUNDRED,ONEEIGHT)); + + showValButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + popupDialog(); + } + }); panel.add(downButton); panel.add(slider); panel.add(upButton); - panel.add(showVal); -// JPanel panel = new JPanel(null); -// panel.add(downButton); -// panel.add(slider); -// panel.add(upButton); -// panel.add(showVal); -// downButton.setBounds(0,0,16,16); -// slider.setBounds(16+KERNING,0,160,16); -// upButton.setBounds(176+KERNING*2,0,16,16); -// showVal.setBounds(192+KERNING*3,0,40,16); + panel.add(showValButton); this.add(panel,BorderLayout.NORTH); - this.setBounds(0,0,300,16); + this.setBounds(0,0,THREEHUNDRED,ONEEIGHT); + } public static final JSliderPane getInstance() { @@ -86,6 +107,24 @@ public class JSliderPane extends JPanel { return THIS; } + private void initUIRadioButton(){ + twoHundredButton = new UIRadioButton("200%"); + oneHundredButton = new UIRadioButton("100%"); + SevenFiveButton = new UIRadioButton("75%"); + fiveTenButton = new UIRadioButton("50%"); + twoFiveButton = new UIRadioButton("25%"); + selfAdaptButton = new UIRadioButton(Inter.getLocText("FR-Designer_Scale_selfAdaptButton")); + customButton = new UIRadioButton(Inter.getLocText("FR-Designer_Scale_customButton")); + + ButtonGroup bg=new ButtonGroup();// 初始化按钮组 + bg.add(twoHundredButton);// 加入按钮组 + bg.add(oneHundredButton); + bg.add(SevenFiveButton); + bg.add(fiveTenButton); + bg.add(twoFiveButton); + bg.add(selfAdaptButton); + bg.add(customButton); + } //定义一个监听器,用于监听所有滑动条 @@ -115,7 +154,7 @@ public class JSliderPane extends JPanel { isButtonOrIsTxt = true; resolutionTimes = divide(showValue,100,2); refreshSlider(); - refreshBody(); + refreshBottun(); } @Override @@ -129,49 +168,20 @@ public class JSliderPane extends JPanel { } }; - MouseListener showValMouseListener = new MouseListener() { - @Override - public void mouseClicked(MouseEvent e) { - popupDialog(); - } - - @Override - public void mousePressed(MouseEvent e) { - - } - - @Override - public void mouseReleased(MouseEvent e) { - - } - - @Override - public void mouseEntered(MouseEvent e) { - - } - - @Override - public void mouseExited(MouseEvent e) { - - } - }; - private void refreshSlider(){ showValue = Integer.parseInt(showVal.getText().substring(0, showVal.getText().indexOf("%"))); - if (showValue >100){ - slider.setValue((int)(showValue+200)/6); - }else if (showValue <100){ - slider.setValue((int)((showValue-10)/1.8)); - }else if (showValue == 100){ - slider.setValue(50); + if (showValue >HUNDRED){ + slider.setValue((int)(showValue+TWOHUNDRED)/SIX); + }else if (showValue = 10 ){ + int newDownVal = showValue - TEN; + if (newDownVal >= TEN ){ showValue = newDownVal; showVal.setText(newDownVal + "%"); }else { showValue = newDownVal; - showVal.setText(10 + "%"); + showVal.setText(TEN + "%"); } } if(e.getActionCommand().equals("more")){ - int newUpVal = showValue + 10; - if (newUpVal <= 400 ){ + int newUpVal = showValue + TEN; + if (newUpVal <= FOURHUNDRED ){ showValue = newUpVal; showVal.setText(newUpVal + "%"); }else { showValue = newUpVal; - showVal.setText(400 + "%"); + showVal.setText(FOURHUNDRED + "%"); } } isButtonOrIsTxt = true; } }; + + private void getTimes(int value){ - if (value == 50){ - times=100; - }else if (value < 50){ - times = (int) Math.round(1.8*value + 10); + if (value == HALFHUNDRED){ + times=HUNDRED; + }else if (value < HALFHUNDRED){ + times = (int) Math.round(ONEPOINTEIGHT*value + TEN); }else { - times = (int) (6*value - 200); + times = (int) (SIX*value - TWOHUNDRED); } } @@ -233,17 +245,20 @@ public class JSliderPane extends JPanel { } private void popupDialog(){ - if (isDialogOut) { - dialog.setVisible(false); - isDialogOut = false; - return; - } - if (dialog == null) { - dialog = new Dialog(showVal); - isDialogOut = true; - } else { - dialog.setVisible(true); - isDialogOut = true; + Point btnCoords = upButton.getLocationOnScreen(); + if (dialog == null){ + dialog = new PopupPane(upButton,showVal); + if (upButtonX == 0) { + upButtonX = btnCoords.x; + GUICoreUtils.showPopupMenu(dialog, upButton, - DIALOGWIDTH + upButton.getWidth() +HALFHUNDRED, -DIALOGHEIGHT); + } + }else { + if (upButtonX == 0) { + upButtonX = btnCoords.x; + GUICoreUtils.showPopupMenu(dialog, upButton, - DIALOGWIDTH + upButton.getWidth() +HALFHUNDRED, -DIALOGHEIGHT); + } else { + GUICoreUtils.showPopupMenu(dialog, upButton, - DIALOGWIDTH + upButton.getWidth() +HALFHUNDRED, -DIALOGHEIGHT); + } } } @@ -263,6 +278,12 @@ public class JSliderPane extends JPanel { class JSliderPaneUI extends BasicSliderUI { + private static final int VERTICAL_WIDTH = 11; + private static final int VERTICAL_HEIGHT = 16; + private static final int FOUR = 4; + private static final int FIVE = 5; + private static final int SIX = 6; + public JSliderPaneUI(UISlider b) { super(b); } @@ -276,12 +297,12 @@ class JSliderPaneUI extends BasicSliderUI { Dimension size = new Dimension(); if ( slider.getOrientation() == JSlider.VERTICAL ) { - size.width = 11; - size.height = 16; + size.width = VERTICAL_WIDTH; + size.height = VERTICAL_HEIGHT; } else { - size.width = 11; - size.height = 16; + size.width = VERTICAL_WIDTH; + size.height = VERTICAL_HEIGHT; } return size; @@ -300,7 +321,7 @@ class JSliderPaneUI extends BasicSliderUI { g.setColor(slider.getBackground().darker()); } g.setColor(Color.darkGray); - g.fillRect(0, 1, w-6, h+1); + g.fillRect(0, 1, w-SIX, h+1); } /** */ @@ -315,43 +336,82 @@ class JSliderPaneUI extends BasicSliderUI { cy = (trackBounds.height / 2); cw = trackBounds.width; g.setColor(Color.lightGray); - g.drawLine(0, cy, cw+5, cy); - g.drawLine(5+cw/2, cy-4, 5+cw/2, cy+4); + g.drawLine(0, cy, cw+FIVE, cy); + g.drawLine(FIVE+cw/2, cy-FOUR, FIVE+cw/2, cy+FOUR); } else { super.paintTrack(g); } } + } class Dialog extends JDialog { - private Container container; - private static final int RESIZE_RANGE = 4; - private Cursor originCursor; - private Cursor southResizeCursor = Cursor.getPredefinedCursor(Cursor.S_RESIZE_CURSOR); - private Point mouseDownCompCoords; - private int minHeight; // 对话框最小高度 +// private Container container; +// private static final int UPLABELHEIGHT = 25; +// private static final int HALFHUNDRED = 50; +// private static final int DIALOGWIDTH = 150; +// private static final int DIALOGHEIGHT = 200; +// private static final int UPLABELWIDTH = 300; +// private int minHeight; // 对话框最小高度 +// private JComponent contentPane; +// private JComponent centerPane; +// private UILabel upLabel; + +// public Dialog(UIButton b,UITextField j) { +// super(DesignerContext.getDesignerFrame()); +// container = getContentPane(); +// setUndecorated(true); +// contentPane = new JPanel(new BorderLayout()); +// centerPane = new JPanel(new BorderLayout()); +// upLabel = new UILabel(Inter.getLocText("FR-Designer_Scale_EnlargeOrReduce")); +// upLabel.setOpaque(true); +// upLabel.setPreferredSize(new Dimension(UPLABELWIDTH,UPLABELHEIGHT)); +// upLabel.setBackground(Color.LIGHT_GRAY); +// upLabel.setBorder(BorderFactory.createLineBorder(Color.gray,1)); +// upLabel.setBorder(new MatteBorder(0,0,1,0,Color.gray)); +// centerPane.add(j,BorderLayout.NORTH); +// contentPane.add(upLabel,BorderLayout.NORTH); +// contentPane.add(centerPane,BorderLayout.CENTER); +//// contentPane.setBorder(BorderFactory.createLineBorder(Color.gray,1)); +// contentPane.setBorder(new MatteBorder(1,1,1,1,Color.darkGray)); +//// contentPane.add(new JPanel()) +// container.add(contentPane, BorderLayout.CENTER); +// minHeight = container.getPreferredSize().height; +// setSize(DIALOGWIDTH, DIALOGHEIGHT); +//// validate(); +// Point btnCoords = b.getLocationOnScreen(); +// +// this.setLocation(btnCoords.x - DIALOGWIDTH + b.getWidth() +HALFHUNDRED, btnCoords.y -DIALOGHEIGHT); +//// initListener(); +// +// this.setVisible(true); +// } +} +class PopupPane extends JPopupMenu { private JComponent contentPane; + private static final int UPLABELHEIGHT = 25; + private static final int HALFHUNDRED = 50; + private static final int DIALOGWIDTH = 150; + private static final int DIALOGHEIGHT = 200; + private static final int UPLABELWIDTH = 300; + private JComponent centerPane; private UILabel upLabel; - - public Dialog(UITextField j) { - super(DesignerContext.getDesignerFrame()); - container = getContentPane(); - setUndecorated(true); + PopupPane(UIButton b,UITextField j) { contentPane = new JPanel(new BorderLayout()); - upLabel = new UILabel(Inter.getLocText("Enlarge_Or_Reduce")); + centerPane = new JPanel(new BorderLayout()); + upLabel = new UILabel(Inter.getLocText("FR-Designer_Scale_EnlargeOrReduce")); upLabel.setOpaque(true); - upLabel.setPreferredSize(new Dimension(300,25)); + upLabel.setPreferredSize(new Dimension(UPLABELWIDTH,UPLABELHEIGHT)); upLabel.setBackground(Color.LIGHT_GRAY); + upLabel.setBorder(new MatteBorder(0,0,1,0,Color.gray)); + centerPane.add(j,BorderLayout.NORTH); contentPane.add(upLabel,BorderLayout.NORTH); -// contentPane.add(new JPanel()) - container.add(contentPane, BorderLayout.CENTER); - minHeight = container.getPreferredSize().height; - setSize(150, 250); -// validate(); - Point btnCoords = j.getLocationOnScreen(); + contentPane.add(centerPane,BorderLayout.CENTER); +// contentPane.setBorder(new MatteBorder(1,1,1,1,Color.darkGray)); + this.add(contentPane, BorderLayout.CENTER); + this.setPreferredSize(new Dimension(DIALOGWIDTH, DIALOGHEIGHT)); + this.setOpaque(false); + } - this.setLocation(btnCoords.x -150+j.getWidth(), btnCoords.y -250); -// initListener(); - this.setVisible(true); - } -} + +} \ No newline at end of file diff --git a/designer_form/src/com/fr/design/mainframe/FormArea.java b/designer_form/src/com/fr/design/mainframe/FormArea.java index 51a18c696..2a321cd32 100644 --- a/designer_form/src/com/fr/design/mainframe/FormArea.java +++ b/designer_form/src/com/fr/design/mainframe/FormArea.java @@ -50,25 +50,27 @@ public class FormArea extends JComponent implements ScrollRulerComponent { private static final double SLIDER_FLOAT = 400.0; private static final double SLIDER_MIN = 10.0; public static final double DEFAULT_SLIDER = 100.0; - private static final int ROTATIONS = 50; - private FormDesigner designer; - private int horizontalValue = 0; - private int verticalValue = 0; - private int verticalMax = 0; - private int horicalMax = 0; - private FormScrollBar verScrollBar; + private static final int ROTATIONS = 50; + private static final int showValMax = 400; + private static final int showValMin = 10; + private FormDesigner designer; + private int horizontalValue = 0; + private int verticalValue = 0; + private int verticalMax = 0; + private int horicalMax = 0; + private FormScrollBar verScrollBar; private FormScrollBar horScrollBar; - //显示和设置表单界面大小的控件 - private UINumberField widthPane; - private UINumberField heightPane; - private JSliderPane slidePane; - private boolean isValid = true; - // 初始时滑块值为100,托动后的值设为START_VALUE; - private double START_VALUE = DEFAULT_SLIDER; - private double screenValue; + //显示和设置表单界面大小的控件 + private UINumberField widthPane; + private UINumberField heightPane; + private JSliderPane slidePane; + private boolean isValid = true; + // 初始时滑块值为100,托动后的值设为START_VALUE; + private double START_VALUE = DEFAULT_SLIDER; + private double screenValue; private JSliderPane sliderPane; - - public FormScrollBar getHorScrollBar() { + + public FormScrollBar getHorScrollBar() { return horScrollBar; } @@ -76,47 +78,47 @@ public class FormArea extends JComponent implements ScrollRulerComponent { this.horScrollBar = horScrollBar; } - public FormArea(FormDesigner designer) { - this(designer, true); - } - - public FormArea(FormDesigner designer, boolean useScrollBar) { - this.designer = designer; - this.designer.setParent(this); - isValid = useScrollBar; - verScrollBar = new FormScrollBar(Adjustable.VERTICAL, this); - horScrollBar = new FormScrollBar(Adjustable.HORIZONTAL, this); - if (useScrollBar) { - this.setLayout(new FormRulerLayout()); - designer.setBorder(new LineBorder(new Color(198,198,198))); - this.add(FormRulerLayout.CENTER, designer); - addFormSize(); - this.add(FormRulerLayout.VERTICAL, verScrollBar); - this.add(FormRulerLayout.HIRIZONTAL, horScrollBar); - enableEvents(AWTEvent.MOUSE_WHEEL_EVENT_MASK); - } else { - // 报表参数界面只要标尺和中心pane - this.setLayout(new RulerLayout()); - this.add(RulerLayout.CENTER, designer); - addFormRuler(); - } - this.setFocusTraversalKeysEnabled(false); - } - - /** - * 增加表单的页面大小控制界面,包括手动修改和滑块拖动 - */ - private void addFormSize() { - double f = TableLayout.FILL; + public FormArea(FormDesigner designer) { + this(designer, true); + } + + public FormArea(FormDesigner designer, boolean useScrollBar) { + this.designer = designer; + this.designer.setParent(this); + isValid = useScrollBar; + verScrollBar = new FormScrollBar(Adjustable.VERTICAL, this); + horScrollBar = new FormScrollBar(Adjustable.HORIZONTAL, this); + if (useScrollBar) { + this.setLayout(new FormRulerLayout()); + designer.setBorder(new LineBorder(new Color(198,198,198))); + this.add(FormRulerLayout.CENTER, designer); + addFormSize(); + this.add(FormRulerLayout.VERTICAL, verScrollBar); + this.add(FormRulerLayout.HIRIZONTAL, horScrollBar); + enableEvents(AWTEvent.MOUSE_WHEEL_EVENT_MASK); + } else { + // 报表参数界面只要标尺和中心pane + this.setLayout(new RulerLayout()); + this.add(RulerLayout.CENTER, designer); + addFormRuler(); + } + this.setFocusTraversalKeysEnabled(false); + } + + /** + * 增加表单的页面大小控制界面,包括手动修改和滑块拖动 + */ + private void addFormSize() { + double f = TableLayout.FILL; double p = TableLayout.PREFERRED; double[] rowSize = {f}; double[] columnSize = { p, f, p, p, p, p, p, f, p}; UILabel tipsPane = new UILabel("form"); tipsPane.setPreferredSize(new Dimension(200, 0)); - widthPane = new UINumberField(); - widthPane.setPreferredSize(new Dimension(60, 0)); - heightPane = new UINumberField(); - heightPane.setPreferredSize(new Dimension(60, 0)); + widthPane = new UINumberField(); + widthPane.setPreferredSize(new Dimension(60, 0)); + heightPane = new UINumberField(); + heightPane.setPreferredSize(new Dimension(60, 0)); // slidePane = new UINumberSlidePane(SLIDER_MIN, SLIDER_FLOAT); // slidePane.setPreferredSize(new Dimension(260,20)); @@ -124,40 +126,40 @@ public class FormArea extends JComponent implements ScrollRulerComponent { slidePane.setPreferredSize(new Dimension(300,20)); - JPanel resizePane =TableLayoutHelper.createCommonTableLayoutPane(new JComponent[][]{ - {tipsPane, new UILabel(), widthPane, new UILabel(Inter.getLocText("FR-Designer_Indent-Pixel")), new UILabel("x"), - heightPane, new UILabel(Inter.getLocText("FR-Designer_Indent-Pixel")), new UILabel(), slidePane}}, - rowSize, columnSize, 8); - this.add(FormRulerLayout.BOTTOM, resizePane); - setWidgetsConfig(); - // 先初始话滑块及对应事件,然后获取分辨率调整容器的显示大小 - slidePane.setEnabled(false); - slidePane.setVisible(true); - initTransparent(); - initCalculateSize(); - } - - private void setWidgetsConfig() { - widthPane.setHorizontalAlignment(widthPane.CENTER); - heightPane.setHorizontalAlignment(heightPane.CENTER); - widthPane.setMaxDecimalLength(0); - heightPane.setMaxDecimalLength(0); - //控件初始值就是根节点组件初始的宽和高 - widthPane.setValue(designer.getRootComponent().getWidth()); - heightPane.setValue(designer.getRootComponent().getHeight()); - addWidthPaneListener(); - addHeightPaneListener(); - } - - private void initTransparent() { - initCalculateSize(); + JPanel resizePane =TableLayoutHelper.createCommonTableLayoutPane(new JComponent[][]{ + {tipsPane, new UILabel(), widthPane, new UILabel(Inter.getLocText("FR-Designer_Indent-Pixel")), new UILabel("x"), + heightPane, new UILabel(Inter.getLocText("FR-Designer_Indent-Pixel")), new UILabel(), slidePane}}, + rowSize, columnSize, 8); + this.add(FormRulerLayout.BOTTOM, resizePane); + setWidgetsConfig(); + // 先初始话滑块及对应事件,然后获取分辨率调整容器的显示大小 + slidePane.setEnabled(false); + slidePane.setVisible(true); + initTransparent(); + initCalculateSize(); + } + + private void setWidgetsConfig() { + widthPane.setHorizontalAlignment(widthPane.CENTER); + heightPane.setHorizontalAlignment(heightPane.CENTER); + widthPane.setMaxDecimalLength(0); + heightPane.setMaxDecimalLength(0); + //控件初始值就是根节点组件初始的宽和高 + widthPane.setValue(designer.getRootComponent().getWidth()); + heightPane.setValue(designer.getRootComponent().getHeight()); + addWidthPaneListener(); + addHeightPaneListener(); + } + + private void initTransparent() { + initCalculateSize(); slidePane.getShowVal().getDocument().addDocumentListener(new DocumentListener() { @Override public void insertUpdate(DocumentEvent e) { // slidePane.getShowVal().getDocument() double value = Integer.parseInt(slidePane.getShowVal().getText().substring(0, slidePane.getShowVal().getText().indexOf("%"))); - value = value>400 ? 400 : value; - value = value<10 ? 10 : value; + value = value>showValMax ? showValMax : value; + value = value= designer.getRootComponent().getWidth(); - } - - /** - * 设置界面内的组件可见以及水平垂直滚动条的值 - * (除了根容器,拖入组件进来时如果大小超过当前界面大小,必须设置滚动条值,否则滚动条默认不显示) - * - * @param creator 控件 - */ - public void scrollPathToVisible(XCreator creator) { - creator.seleteRelatedComponent(creator); - - if (!ComponentUtils.isComponentVisible(creator) && !designer.isRoot(creator) && (creator.toData()).isVisible()) { - designer.makeVisible(creator); - } - - if (shouldSetScrollValue(creator)) { - return; - } - //获取在容器的绝对位置 - Rectangle rec = ComponentUtils.getRelativeBounds(creator); - int dWidth = getDesignerWidth(); - if (rec.width <= dWidth&&rec.x < getHorizontalValue()) { - //在边界内部且x位置小于水平滚动条的值 - horScrollBar.setValue(rec.x); - } else if (rec.x + rec.width > dWidth + horizontalValue) { - //超出边界宽度 - horScrollBar.setValue(rec.x + rec.width - dWidth); - } - int dHeight = getDesignerHeight(); - if (rec.height < dHeight && rec.y < getVerticalValue()) { - //在边界内部且y位置小于竖直滚动条的值 - verScrollBar.setValue(rec.y); - } else if (rec.y + rec.height > dHeight + verticalValue) { - //超出边界高度 - verScrollBar.setValue(rec.y + rec.height - dHeight); - } - } - - - /** - * 容器布局 - */ - public void doLayout() { - layout(); - if (isValid) { - XLayoutContainer root = designer.getRootComponent(); - setScrollBarProperties(root.getWidth()-designer.getWidth(), horScrollBar); - //计算滚动条值的时候应该算上参数面板的高度 - setScrollBarProperties(designer.getParaHeight() + root.getHeight()-designer.getHeight(), verScrollBar); - } - } - - /** - * 设置滚动条的属性 - */ - private void setScrollBarProperties(int value, FormScrollBar bar) { - if (value == 0 && isScrollNotVisible(bar)) { - return; - } - if (value <= 0) { - // 界面有滚动条时,手动缩小容器宽度到界面内,重置滚动条值和max - setScrollBarMax(0, bar); - bar.setMaximum(0); - bar.setValue(0); - bar.setEnabled(false); - } else { - //参数面板拖拽过程中value一直为当前value - int oldValue = verticalValue; - setScrollBarMax(value, bar); - bar.setEnabled(true); - bar.setMaximum(value); - bar.setValue(value); - bar.setValue(oldValue); - } - } - - private boolean isScrollNotVisible(FormScrollBar bar) { - if (bar.getOrientation() == Adjustable.VERTICAL ) { - return verticalMax == 0; - } else { - return horicalMax == 0; - } - } - - private void setScrollBarMax( int max, FormScrollBar bar) { - if (bar.getOrientation() == Adjustable.VERTICAL ) { - verticalMax = max; - } else { - horicalMax = max; - } - } - - /** - *返回designer的最小高度 - * - * @return int - */ - public int getMinHeight() { - return designer.getDesignerMode().getMinDesignHeight(); - } - - /** - *返回designer的最小宽度 - * - * @return int - */ - public int getMinWidth() { - return designer.getDesignerMode().getMinDesignWidth(); - } - - /** - * getRulerLengthUnit - * - * @return short - */ - public short getRulerLengthUnit() { - return -1; - } - - /** - * 返回水平滚动条的value - * - * @return int - */ - public int getHorizontalValue() { - return horizontalValue; - } - - /** - * 设置水平滚动条的value - * - * @param newValue - */ - public void setHorizontalValue(int newValue) { - this.horizontalValue = newValue; - } - - /** - * 返回竖直滚动条的value - * - * @return - */ - public int getVerticalValue() { - return verticalValue; - } - - /** - * 竖直滚动条赋值 - * - * @param newValue - */ - public void setVerticalValue(int newValue) { - this.verticalValue = newValue; - } - - /** - * 返回当前designer的高度 - * - * @return height - */ - public int getDesignerHeight() { - return designer.getHeight(); - } - - /** - * 返回当前designer的宽度 - * - * @return - */ - public int getDesignerWidth() { - return designer.getWidth(); - } - - /** - * 返回宽度控件的value - * - * @return 宽度 - */ - public double getWidthPaneValue() { - return widthPane.getValue(); - } - - /** - * 设置宽度值 - * @param value 值 - */ - public void setWidthPaneValue(int value) { - widthPane.setValue(value); - } - - /** - * 设置高度值 - * @param value 值 - */ - public void setHeightPaneValue(int value) { - heightPane.setValue(value); - } - - /** - * 返回高度控件的value - * - * @return 高度 - */ - public double getHeightPaneValue() { - return heightPane.getValue(); - } - - /** - * 返回界面大小的百分比值 - * - * @return 百分比值 - */ - public double getSlideValue() { + + } + + /** + * 增加刻度条 + */ + public void addFormRuler() { + BaseRuler vRuler = new VerticalRuler(this); + BaseRuler hRuler = new HorizontalRuler(this); + this.add(RulerLayout.VRULER, vRuler); + this.add(RulerLayout.HRULER, hRuler); + } + + /** + * 鼠标滚轮事件 + * 由于表单设计界面要求: 容器大小大于界面时,滚动条才可以拖动,所以不支持滚动无限往下滚 + */ + @Override + protected void processMouseWheelEvent(java.awt.event.MouseWheelEvent evt) { + int id = evt.getID(); + switch (id) { + case MouseEvent.MOUSE_WHEEL: { + int rotations = evt.getWheelRotation(); + int value = this.verScrollBar.getValue() + rotations * ROTATIONS ; + value = Math.min(value, verticalMax); + value = Math.max(0, value); + doLayout(); //加dolayout是因为每次滚动都要重置 Max的大小 + this.verScrollBar.setValue(value); + break; + } + } + } + + /** + * 返回表单容器的中心designer + * getFormEditor. + */ + public FormDesigner getFormEditor() { + return designer; + } + + private boolean shouldSetScrollValue(XCreator creator) { + return !isValid || designer.isRoot(creator) || getDesignerWidth() >= designer.getRootComponent().getWidth(); + } + + /** + * 设置界面内的组件可见以及水平垂直滚动条的值 + * (除了根容器,拖入组件进来时如果大小超过当前界面大小,必须设置滚动条值,否则滚动条默认不显示) + * + * @param creator 控件 + */ + public void scrollPathToVisible(XCreator creator) { + creator.seleteRelatedComponent(creator); + + if (!ComponentUtils.isComponentVisible(creator) && !designer.isRoot(creator) && (creator.toData()).isVisible()) { + designer.makeVisible(creator); + } + + if (shouldSetScrollValue(creator)) { + return; + } + //获取在容器的绝对位置 + Rectangle rec = ComponentUtils.getRelativeBounds(creator); + int dWidth = getDesignerWidth(); + if (rec.width <= dWidth&&rec.x < getHorizontalValue()) { + //在边界内部且x位置小于水平滚动条的值 + horScrollBar.setValue(rec.x); + } else if (rec.x + rec.width > dWidth + horizontalValue) { + //超出边界宽度 + horScrollBar.setValue(rec.x + rec.width - dWidth); + } + int dHeight = getDesignerHeight(); + if (rec.height < dHeight && rec.y < getVerticalValue()) { + //在边界内部且y位置小于竖直滚动条的值 + verScrollBar.setValue(rec.y); + } else if (rec.y + rec.height > dHeight + verticalValue) { + //超出边界高度 + verScrollBar.setValue(rec.y + rec.height - dHeight); + } + } + + + /** + * 容器布局 + */ + public void doLayout() { + layout(); + if (isValid) { + XLayoutContainer root = designer.getRootComponent(); + setScrollBarProperties(root.getWidth()-designer.getWidth(), horScrollBar); + //计算滚动条值的时候应该算上参数面板的高度 + setScrollBarProperties(designer.getParaHeight() + root.getHeight()-designer.getHeight(), verScrollBar); + } + } + + /** + * 设置滚动条的属性 + */ + private void setScrollBarProperties(int value, FormScrollBar bar) { + if (value == 0 && isScrollNotVisible(bar)) { + return; + } + if (value <= 0) { + // 界面有滚动条时,手动缩小容器宽度到界面内,重置滚动条值和max + setScrollBarMax(0, bar); + bar.setMaximum(0); + bar.setValue(0); + bar.setEnabled(false); + } else { + //参数面板拖拽过程中value一直为当前value + int oldValue = verticalValue; + setScrollBarMax(value, bar); + bar.setEnabled(true); + bar.setMaximum(value); + bar.setValue(value); + bar.setValue(oldValue); + } + } + + private boolean isScrollNotVisible(FormScrollBar bar) { + if (bar.getOrientation() == Adjustable.VERTICAL ) { + return verticalMax == 0; + } else { + return horicalMax == 0; + } + } + + private void setScrollBarMax( int max, FormScrollBar bar) { + if (bar.getOrientation() == Adjustable.VERTICAL ) { + verticalMax = max; + } else { + horicalMax = max; + } + } + + /** + *返回designer的最小高度 + * + * @return int + */ + public int getMinHeight() { + return designer.getDesignerMode().getMinDesignHeight(); + } + + /** + *返回designer的最小宽度 + * + * @return int + */ + public int getMinWidth() { + return designer.getDesignerMode().getMinDesignWidth(); + } + + /** + * getRulerLengthUnit + * + * @return short + */ + public short getRulerLengthUnit() { + return -1; + } + + /** + * 返回水平滚动条的value + * + * @return int + */ + public int getHorizontalValue() { + return horizontalValue; + } + + /** + * 设置水平滚动条的value + * + * @param newValue + */ + public void setHorizontalValue(int newValue) { + this.horizontalValue = newValue; + } + + /** + * 返回竖直滚动条的value + * + * @return + */ + public int getVerticalValue() { + return verticalValue; + } + + /** + * 竖直滚动条赋值 + * + * @param newValue + */ + public void setVerticalValue(int newValue) { + this.verticalValue = newValue; + } + + /** + * 返回当前designer的高度 + * + * @return height + */ + public int getDesignerHeight() { + return designer.getHeight(); + } + + /** + * 返回当前designer的宽度 + * + * @return + */ + public int getDesignerWidth() { + return designer.getWidth(); + } + + /** + * 返回宽度控件的value + * + * @return 宽度 + */ + public double getWidthPaneValue() { + return widthPane.getValue(); + } + + /** + * 设置宽度值 + * @param value 值 + */ + public void setWidthPaneValue(int value) { + widthPane.setValue(value); + } + + /** + * 设置高度值 + * @param value 值 + */ + public void setHeightPaneValue(int value) { + heightPane.setValue(value); + } + + /** + * 返回高度控件的value + * + * @return 高度 + */ + public double getHeightPaneValue() { + return heightPane.getValue(); + } + + /** + * 返回界面大小的百分比值 + * + * @return 百分比值 + */ + public double getSlideValue() { // return slidePane.updateBean(); - //7.1.1不加缩放滑块 - return this.screenValue; - } - - /** - * 返回界面区域大小 - * - * @return Dimension - */ - public Dimension getAreaSize() { - return new Dimension(horScrollBar.getMaximum(), verScrollBar.getMaximum()); - } - - /** - * setAreaSize - * - * @param totalSize - * @param horizontalValue - * @param verticalValue - */ - public void setAreaSize(Dimension totalSize, int horizontalValue, int verticalValue, double width, double height, double slide) { - this.verticalMax = (int) totalSize.getHeight(); - this.horicalMax = (int) totalSize.getHeight(); - // 撤销时会refreshRoot,导致layout大小变为默认大小 - // 按照之前设置的宽高和百分比重置下容器size - if (width != widthPane.getValue()) { - widthPane.setValue(width); - reCalculateWidth((int) width); - } - if (height != heightPane.getValue()) { - heightPane.setValue(height); - reCalculateHeight((int) height); - } - if (designer.getRootComponent().acceptType(XWFitLayout.class) && slide == DEFAULT_SLIDER) { - XWFitLayout layout = (XWFitLayout) designer.getRootComponent(); - // 撤销时先refreshRoot了,此处去掉内边距再增加间隔 - layout.moveContainerMargin(); - layout.addCompInterval(layout.getAcualInterval()); - } else if (designer.getRootComponent().acceptType(XWFitLayout.class)){ - START_VALUE = DEFAULT_SLIDER; - reCalculateRoot(slide, true); + //7.1.1不加缩放滑块 + return this.screenValue; + } + + /** + * 返回界面区域大小 + * + * @return Dimension + */ + public Dimension getAreaSize() { + return new Dimension(horScrollBar.getMaximum(), verScrollBar.getMaximum()); + } + + /** + * setAreaSize + * + * @param totalSize + * @param horizontalValue + * @param verticalValue + */ + public void setAreaSize(Dimension totalSize, int horizontalValue, int verticalValue, double width, double height, double slide) { + this.verticalMax = (int) totalSize.getHeight(); + this.horicalMax = (int) totalSize.getHeight(); + // 撤销时会refreshRoot,导致layout大小变为默认大小 + // 按照之前设置的宽高和百分比重置下容器size + if (width != widthPane.getValue()) { + widthPane.setValue(width); + reCalculateWidth((int) width); + } + if (height != heightPane.getValue()) { + heightPane.setValue(height); + reCalculateHeight((int) height); + } + if (designer.getRootComponent().acceptType(XWFitLayout.class) && slide == DEFAULT_SLIDER) { + XWFitLayout layout = (XWFitLayout) designer.getRootComponent(); + // 撤销时先refreshRoot了,此处去掉内边距再增加间隔 + layout.moveContainerMargin(); + layout.addCompInterval(layout.getAcualInterval()); + } else if (designer.getRootComponent().acceptType(XWFitLayout.class)){ + START_VALUE = DEFAULT_SLIDER; + reCalculateRoot(slide, true); // slidePane.populateBean(slide); - } - } - - /** - * 计算滚动条的值和max - * @param oldmax 之前最大值 - * @param max 当前最大值 - * @param newValue 当前value - * @param oldValue 之前value - * @param visi designer的大小 - * @param orientation 滚动条方向 - * @return 计算后的值和max - */ - @Override - public Point calculateScroll(int oldmax, int max, int newValue, int oldValue, int visi, int orientation) { - int scrollMax = orientation==1 ? verticalMax : horicalMax; - //防止滚动条到达低端还可以继续点击移动(滚动条最大范围不变时,newValue要在范围之内) - if ( oldmax == scrollMax+visi && newValue>scrollMax ) { - return new Point(oldValue, oldmax); - } + } + } + + /** + * 计算滚动条的值和max + * @param oldmax 之前最大值 + * @param max 当前最大值 + * @param newValue 当前value + * @param oldValue 之前value + * @param visi designer的大小 + * @param orientation 滚动条方向 + * @return 计算后的值和max + */ + @Override + public Point calculateScroll(int oldmax, int max, int newValue, int oldValue, int visi, int orientation) { + int scrollMax = orientation==1 ? verticalMax : horicalMax; + //防止滚动条到达低端还可以继续点击移动(滚动条最大范围不变时,newValue要在范围之内) + if ( oldmax == scrollMax+visi && newValue>scrollMax ) { + return new Point(oldValue, oldmax); + } return new Point(newValue, max); } private class FormRulerLayout extends RulerLayout{ - private int DESIGNERWIDTH = 960; - private int DESIGNERHEIGHT =540; - private int TOPGAP = 8; - - public FormRulerLayout(){ - super(); - } - - /** - * 表单用的layout,当前不需要标尺 - */ - public void layoutContainer(Container target) { - synchronized (target.getTreeLock()) { - Insets insets = target.getInsets(); - int top = insets.top; - int left = insets.left; - int bottom = target.getHeight() - insets.bottom; - int right = target.getWidth() - insets.right; - Dimension resize = resizePane.getPreferredSize(); - Dimension hbarPreferredSize = null; - Dimension vbarPreferredSize = null; - - resizePane.setBounds(left, bottom - resize.height, right, resize.height); - if(horScrollBar != null) { - hbarPreferredSize = horScrollBar.getPreferredSize(); - vbarPreferredSize = verScrollBar.getPreferredSize(); - horScrollBar.setBounds(left , bottom - hbarPreferredSize.height-resize.height, right - BARSIZE, hbarPreferredSize.height); - verScrollBar.setBounds(right - vbarPreferredSize.width, top, vbarPreferredSize.width, bottom - BARSIZE-resize.height); - } - FormDesigner dg = ((FormDesigner) designer); - XLayoutContainer root = dg.getRootComponent(); - if (root.acceptType(XWFitLayout.class)) { - DESIGNERWIDTH = root.getWidth(); - DESIGNERHEIGHT = dg.hasWAbsoluteLayout() ? root.getHeight()+dg.getParaHeight() : root.getHeight(); - } - Rectangle rec = new Rectangle(left+(right - DESIGNERWIDTH)/2, TOPGAP, right, bottom); - //是否为表单 - if (isValid ){ - int maxHeight = bottom - hbarPreferredSize.height - resize.height -TOPGAP*2; - int maxWidth = right - vbarPreferredSize.width; - DESIGNERWIDTH = DESIGNERWIDTH> maxWidth ? maxWidth : DESIGNERWIDTH; - DESIGNERHEIGHT = DESIGNERHEIGHT > maxHeight ? maxHeight : DESIGNERHEIGHT; - int designerLeft = left+(verScrollBar.getX() - DESIGNERWIDTH)/2; - rec = new Rectangle(designerLeft, TOPGAP, DESIGNERWIDTH, DESIGNERHEIGHT); - } - // designer是整个表单设计界面中的面板部分,目前只放自适应布局和参数界面。 - designer.setBounds(rec); - } - } - - } + private int DESIGNERWIDTH = 960; + private int DESIGNERHEIGHT =540; + private int TOPGAP = 8; + + public FormRulerLayout(){ + super(); + } + + /** + * 表单用的layout,当前不需要标尺 + */ + public void layoutContainer(Container target) { + synchronized (target.getTreeLock()) { + Insets insets = target.getInsets(); + int top = insets.top; + int left = insets.left; + int bottom = target.getHeight() - insets.bottom; + int right = target.getWidth() - insets.right; + Dimension resize = resizePane.getPreferredSize(); + Dimension hbarPreferredSize = null; + Dimension vbarPreferredSize = null; + + resizePane.setBounds(left, bottom - resize.height, right, resize.height); + if(horScrollBar != null) { + hbarPreferredSize = horScrollBar.getPreferredSize(); + vbarPreferredSize = verScrollBar.getPreferredSize(); + horScrollBar.setBounds(left , bottom - hbarPreferredSize.height-resize.height, right - BARSIZE, hbarPreferredSize.height); + verScrollBar.setBounds(right - vbarPreferredSize.width, top, vbarPreferredSize.width, bottom - BARSIZE-resize.height); + } + FormDesigner dg = ((FormDesigner) designer); + XLayoutContainer root = dg.getRootComponent(); + if (root.acceptType(XWFitLayout.class)) { + DESIGNERWIDTH = root.getWidth(); + DESIGNERHEIGHT = dg.hasWAbsoluteLayout() ? root.getHeight()+dg.getParaHeight() : root.getHeight(); + } + Rectangle rec = new Rectangle(left+(right - DESIGNERWIDTH)/2, TOPGAP, right, bottom); + //是否为表单 + if (isValid ){ + int maxHeight = bottom - hbarPreferredSize.height - resize.height -TOPGAP*2; + int maxWidth = right - vbarPreferredSize.width; + DESIGNERWIDTH = DESIGNERWIDTH> maxWidth ? maxWidth : DESIGNERWIDTH; + DESIGNERHEIGHT = DESIGNERHEIGHT > maxHeight ? maxHeight : DESIGNERHEIGHT; + int designerLeft = left+(verScrollBar.getX() - DESIGNERWIDTH)/2; + rec = new Rectangle(designerLeft, TOPGAP, DESIGNERWIDTH, DESIGNERHEIGHT); + } + // designer是整个表单设计界面中的面板部分,目前只放自适应布局和参数界面。 + designer.setBounds(rec); + } + } + + } } \ No newline at end of file From 20c4524cab35dce2761a565d3006d96d2951d40c Mon Sep 17 00:00:00 2001 From: MoMeak Date: Wed, 19 Jul 2017 18:47:53 +0800 Subject: [PATCH 2/2] =?UTF-8?q?REPORT-2897=209.0=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E5=99=A8=E4=BF=AE=E6=94=B9=20PMD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/mainframe/ReportComponentComposite.java | 3 ++- designer_form/src/com/fr/design/mainframe/FormArea.java | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/designer/src/com/fr/design/mainframe/ReportComponentComposite.java b/designer/src/com/fr/design/mainframe/ReportComponentComposite.java index b3ab87a28..d51db1770 100644 --- a/designer/src/com/fr/design/mainframe/ReportComponentComposite.java +++ b/designer/src/com/fr/design/mainframe/ReportComponentComposite.java @@ -30,6 +30,7 @@ import com.fr.report.report.TemplateReport; public class ReportComponentComposite extends JComponent { private static final int MAX = 400; + private static final int HUND = 100; private static final int MIN = 10; private JWorkBook parent; private UIModeControlContainer parentContainer = null; @@ -68,7 +69,7 @@ public class ReportComponentComposite extends JComponent { double value = Integer.parseInt(jSliderContainer.getShowVal().getText().substring(0, jSliderContainer.getShowVal().getText().indexOf("%"))); value = value>MAX ? MAX : value; value = valueshowValMax ? showValMax : value; - value = valueSHOWVALMAX ? SHOWVALMAX : value; + value = value