diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java b/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java index f38e44f751..f2fc29ad52 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java +++ b/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java @@ -24,7 +24,7 @@ import com.fr.form.ui.container.WLayout; import com.fr.form.ui.container.WTabDisplayPosition; import com.fr.form.ui.container.cardlayout.WCardMainBorderLayout; import com.fr.general.ComparatorUtils; -import com.fr.general.TextFetcher; +import com.fr.general.act.BorderPacker; import java.awt.Component; import java.awt.Dimension; @@ -285,7 +285,7 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter { backupBound.x -= rec.x; backupBound.y -= rec.y; XWCardLayout cardLayout = mainLayout.getCardPart(); - TextFetcher style = cardLayout.toData().getBorderStyle(); + BorderPacker style = cardLayout.toData().getBorderStyle(); XWCardTitleLayout xwCardTitleLayout = mainLayout.getTitlePart(); Dimension titleDimension = xwCardTitleLayout.getSize(); diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRTabFitLayoutAdapter.java b/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRTabFitLayoutAdapter.java index b280cb71a4..9b8effd0ad 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRTabFitLayoutAdapter.java +++ b/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRTabFitLayoutAdapter.java @@ -7,19 +7,16 @@ package com.fr.design.designer.beans.adapters.layout; import com.fr.design.beans.GroupModel; import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XLayoutContainer; -import com.fr.design.designer.creator.XWParameterLayout; import com.fr.design.designer.creator.XWidgetCreator; import com.fr.design.designer.creator.cardlayout.XWCardLayout; import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout; import com.fr.design.designer.creator.cardlayout.XWTabFitLayout; import com.fr.design.designer.properties.FRTabFitLayoutPropertiesGroupModel; -import com.fr.design.mainframe.widget.editors.ParameterEditor; import com.fr.design.utils.ComponentUtils; import com.fr.form.ui.LayoutBorderStyle; -import com.fr.form.ui.container.WBorderLayout; import com.fr.form.ui.container.cardlayout.WCardMainBorderLayout; import com.fr.general.ComparatorUtils; -import com.fr.general.TextFetcher; +import com.fr.general.act.BorderPacker; import java.awt.*; @@ -91,7 +88,7 @@ public class FRTabFitLayoutAdapter extends FRFitLayoutAdapter { // TODO 可以直接在这边将x,y都变成相对坐标,这样在后面判断拖进来的新控件放置方式的时候就不用再判断了 private int adjustY(int y, XWTabFitLayout tabLayout) { XWCardLayout cardLayout = (XWCardLayout) tabLayout.getBackupParent(); - TextFetcher style = cardLayout.toData().getBorderStyle(); + BorderPacker style = cardLayout.toData().getBorderStyle(); y = y - this.getParaEditorYOffset(); if (ComparatorUtils.equals(style.getType(), LayoutBorderStyle.TITLE)) { y = y - WCardMainBorderLayout.TAB_HEIGHT; diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XBorderStyleWidgetCreator.java b/designer-form/src/main/java/com/fr/design/designer/creator/XBorderStyleWidgetCreator.java index 05d35c8212..fdefc019ae 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XBorderStyleWidgetCreator.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XBorderStyleWidgetCreator.java @@ -11,7 +11,8 @@ import com.fr.form.ui.WidgetTitle; import com.fr.form.ui.WidgetValue; import com.fr.form.ui.container.WTitleLayout; import com.fr.general.ComparatorUtils; -import com.fr.general.TextFetcher; +import com.fr.general.act.BorderPacker; +import com.fr.general.act.TitlePacker; import com.fr.stable.Constants; import com.fr.stable.StringUtils; @@ -42,7 +43,7 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{ } protected void initStyle() { - TextFetcher style = toData().getBorderStyle(); + BorderPacker style = toData().getBorderStyle(); initBorderStyle(); if (ComparatorUtils.equals(style.getType(), LayoutBorderStyle.TITLE)) { initTitleStyle(style); @@ -53,7 +54,7 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{ // 边框默认值设为NONE,不然像scalelayout这种只用默认边框的会不显示边框 protected void initBorderStyle() { - TextFetcher style = toData().getBorderStyle(); + BorderPacker style = toData().getBorderStyle(); if (style != null && style.getBorder() != Constants.LINE_NONE) { this.setBorder(new UIRoundedBorder(style.getBorder(), style.getColor(), style.getBorderRadius())); } else { @@ -75,8 +76,8 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{ * 设置样式为标题样式时,对应组件加上标题 * @param style 样式 */ - protected void initTitleStyle(TextFetcher style){ - if (style.getTextObject() == null) { + protected void initTitleStyle(BorderPacker style){ + if (style.getTitle() == null || style.getTitle().getTextObject() == null) { return; } XWTitleLayout parent = (XWTitleLayout) this.getParent(); @@ -101,25 +102,25 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{ /** * 更新标题控件所有的样式 */ - private void updateTitleWidgetStyle(Label title, TextFetcher style) { + private void updateTitleWidgetStyle(Label title, BorderPacker style) { //标题的边框样式目前是取对应的控件的边框样式 title.setBorder(style.getBorder()); title.setColor(style.getColor()); // title.setCorner(style.isCorner()); - WidgetTitle wTitle = WidgetTitle.as(style); + TitlePacker wTitle = style.getTitle(); //设置成随机不重复的, 不然都用一个名字的话, 联动只能联动一个 - title.setWidgetName(wTitle.TITLE_NAME_INDEX + this.toData().getWidgetName()); + title.setWidgetName(WidgetTitle.TITLE_NAME_INDEX + this.toData().getWidgetName()); title.setWidgetValue(getTitleValue(wTitle)); title.setFont(wTitle.getFrFont()); title.setTextalign(wTitle.getPosition()); title.setBackground(wTitle.getBackground()); } - private WidgetValue getTitleValue(WidgetTitle wTitle){ + private WidgetValue getTitleValue(TitlePacker wTitle){ String content = String.valueOf(wTitle.getTextObject()); - Object vlaue = content.startsWith("=") ? BaseFormula.createFormulaBuilder().build(content) : content; - return new WidgetValue(vlaue); + Object value = content.startsWith("=") ? BaseFormula.createFormulaBuilder().build(content) : content; + return new WidgetValue(value); } @Override diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java b/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java index 615c328aa1..dc555e5d14 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java @@ -22,14 +22,14 @@ import com.fr.design.mainframe.JForm; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.LayoutUtils; import com.fr.form.ui.CardSwitchButton; -import com.fr.form.ui.WidgetTitle; import com.fr.form.ui.container.WTabTextDirection; import com.fr.form.ui.container.cardlayout.WCardTagLayout; import com.fr.form.ui.container.cardlayout.WTabFitLayout; import com.fr.general.Background; +import com.fr.general.act.BorderPacker; import com.fr.general.ComparatorUtils; import com.fr.general.FRFont; -import com.fr.general.TextFetcher; +import com.fr.general.act.TitlePacker; import com.fr.general.cardtag.TemplateStyle; import com.fr.stable.unit.PT; @@ -297,7 +297,7 @@ public class XCardSwitchButton extends XButton { super.paintComponent(g); Graphics2D g2d = (Graphics2D) g; CardSwitchButton button = (CardSwitchButton) this.toData(); - WidgetTitle widgetTitle = getWidgetTitle(); + TitlePacker widgetTitle = getWidgetTitle(); drawBackground(button, widgetTitle); drawTitle(button, widgetTitle); Dimension panelSize = this.getContentLabel().getSize(); @@ -311,7 +311,7 @@ public class XCardSwitchButton extends XButton { } //画背景 - private void drawBackground(CardSwitchButton button, WidgetTitle widgetTitle){ + private void drawBackground(CardSwitchButton button, TitlePacker widgetTitle){ Background background = widgetTitle.getBackground() == null ? ColorBackground.getInstance(NORMAL_GRAL) : widgetTitle.getBackground(); TemplateStyle templateStyle = ((WCardTagLayout) tagLayout.toData()).getTemplateStyle(); //获取当前tab的index @@ -329,7 +329,7 @@ public class XCardSwitchButton extends XButton { } //画标题 - private void drawTitle(CardSwitchButton button, WidgetTitle widgetTitle) { + private void drawTitle(CardSwitchButton button, TitlePacker widgetTitle) { String titleText = button.getText(); this.setButtonText(titleText); FRFont font = widgetTitle.getFrFont(); @@ -340,12 +340,12 @@ public class XCardSwitchButton extends XButton { } - private WidgetTitle getWidgetTitle() { + private TitlePacker getWidgetTitle() { if (this.cardLayout == null) { initRelateLayout(); } - TextFetcher style = this.cardLayout.toData().getBorderStyle(); - return WidgetTitle.as(style); + BorderPacker style = this.cardLayout.toData().getBorderStyle(); + return style.getTitle(); } //删除tab布局 @@ -452,7 +452,7 @@ public class XCardSwitchButton extends XButton { String titleText = button.getText(); java.util.List verticalTextList = new ArrayList(); StringBuilder titleStringBuf = new StringBuilder(); - WidgetTitle title = getWidgetTitle(); + TitlePacker title = getWidgetTitle(); FRFont font = title.getFrFont(); FRFont newFont = FRFont.getInstance(font.getName(), font.getStyle(), font.getSize() + FONT_SIZE_ADJUST); FontMetrics fm = GraphHelper.getFontMetrics(newFont); diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardLayout.java b/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardLayout.java index 653416e12f..c91d34654c 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardLayout.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardLayout.java @@ -25,7 +25,6 @@ import com.fr.form.ui.CardAddButton; import com.fr.form.ui.CardSwitchButton; import com.fr.form.ui.LayoutBorderStyle; import com.fr.form.ui.Widget; -import com.fr.form.ui.WidgetTitle; import com.fr.form.ui.container.WBorderLayout; import com.fr.form.ui.container.WCardLayout; import com.fr.form.ui.container.WLayout; @@ -33,8 +32,9 @@ import com.fr.form.ui.container.cardlayout.WCardMainBorderLayout; import com.fr.form.ui.container.cardlayout.WCardTagLayout; import com.fr.form.ui.container.cardlayout.WCardTitleLayout; import com.fr.form.ui.container.cardlayout.WTabFitLayout; +import com.fr.general.act.BorderPacker; import com.fr.general.ComparatorUtils; -import com.fr.general.TextFetcher; +import com.fr.general.act.TitlePacker; import com.fr.general.cardtag.DefaultTemplateStyle; import com.fr.general.cardtag.TemplateStyle; import com.fr.stable.ArrayUtils; @@ -166,7 +166,7 @@ public class XWCardLayout extends XLayoutContainer { WCardMainBorderLayout border = new WCardMainBorderLayout(); XWCardMainBorderLayout xMainBorder = new XWCardMainBorderLayout(border, dimension); //将子WCardBorder的style设置到父容器上 - TextFetcher style = (this.toData()).getBorderStyle(); + BorderPacker style = (this.toData()).getBorderStyle(); border.setBorderStyle(style); this.setBackupParent(xMainBorder); XWCardTitleLayout titlePart = this.initTitlePart(widgetName, xMainBorder); @@ -398,13 +398,13 @@ public class XWCardLayout extends XLayoutContainer { //初始化样式 @Override protected void initStyle() { - TextFetcher style = toData().getBorderStyle(); + BorderPacker style = toData().getBorderStyle(); initBorderTitleStyle(style); initBorderStyle(); clearOrShowTitleLayout(ComparatorUtils.equals(style.getType(), LayoutBorderStyle.TITLE)); } - private void initBorderTitleStyle(TextFetcher style) { + private void initBorderTitleStyle(BorderPacker style) { //初始化默认标题样式 if (!initFlag) { return; @@ -412,7 +412,7 @@ public class XWCardLayout extends XLayoutContainer { style.setType(LayoutBorderStyle.TITLE); style.setBorder(Constants.LINE_THIN); - WidgetTitle widgetTitle = WidgetTitle.as(style); + TitlePacker widgetTitle = style.getTitle(); widgetTitle.setBackground(ColorBackground.getInstance(TITLE_COLOR)); initFlag = false; } diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java b/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java index b0731e152b..edbabeadf3 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java @@ -38,7 +38,7 @@ import com.fr.form.ui.container.cardlayout.WCardTitleLayout; import com.fr.general.ComparatorUtils; import com.fr.general.IOUtils; -import com.fr.general.TextFetcher; +import com.fr.general.act.BorderPacker; import com.fr.share.ShareConstants; import com.fr.stable.Constants; @@ -165,7 +165,7 @@ public class XWCardMainBorderLayout extends XWBorderLayout { String tabpaneName = cardLayout.getWidgetName(); if (!wCardTagLayout.isNewTab()) { wCardTagLayout.setWidgetName(tabpaneName); - TextFetcher borderStyle = cardLayout.getBorderStyle(); + BorderPacker borderStyle = cardLayout.getBorderStyle(); if(borderStyle != null){ //新tab默认都有标题 borderStyle.setType(LayoutBorderStyle.TITLE); diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardTagLayout.java b/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardTagLayout.java index cc118001fb..77282f63f9 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardTagLayout.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardTagLayout.java @@ -32,9 +32,9 @@ import com.fr.form.ui.container.WCardLayout; import com.fr.form.ui.container.WTabDisplayPosition; import com.fr.form.ui.container.cardlayout.WCardTagLayout; import com.fr.form.ui.container.cardlayout.WTabFitLayout; +import com.fr.general.act.BorderPacker; import com.fr.general.ComparatorUtils; import com.fr.general.FRFont; -import com.fr.general.TextFetcher; import com.fr.general.cardtag.DefaultTemplateStyle; import javax.swing.border.Border; @@ -360,8 +360,8 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout { if (this.cardLayout == null) { initCardLayout(); } - TextFetcher borderStyle = this.cardLayout.toData().getBorderStyle(); - FRFont f = borderStyle.getFrFont(); + BorderPacker borderStyle = this.cardLayout.toData().getBorderStyle(); + FRFont f = borderStyle.getTitle().getFrFont(); FontMetrics fm = GraphHelper.getFontMetrics(f); switch (wCardTagLayout.getTextDirection()) { diff --git a/designer-form/src/main/java/com/fr/design/gui/xpane/LayoutBorderPane.java b/designer-form/src/main/java/com/fr/design/gui/xpane/LayoutBorderPane.java index a70431700a..cf460f9ceb 100644 --- a/designer-form/src/main/java/com/fr/design/gui/xpane/LayoutBorderPane.java +++ b/designer-form/src/main/java/com/fr/design/gui/xpane/LayoutBorderPane.java @@ -38,32 +38,17 @@ import com.fr.form.ui.LayoutBorderStyle; import com.fr.form.ui.WidgetTitle; import com.fr.general.Background; import com.fr.general.FRFont; - +import com.fr.general.act.TitlePacker; import com.fr.stable.Constants; -import javax.swing.AbstractButton; -import javax.swing.BorderFactory; -import javax.swing.ButtonGroup; -import javax.swing.ButtonModel; -import javax.swing.Icon; -import javax.swing.JComponent; -import javax.swing.JPanel; -import javax.swing.JToggleButton; +import javax.swing.*; import javax.swing.border.Border; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import javax.swing.plaf.basic.BasicToggleButtonUI; -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.Font; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.RenderingHints; +import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.ItemEvent; @@ -546,7 +531,7 @@ public class LayoutBorderPane extends BasicPane { style.setColor(currentLineColorPane.getColor()); style.setBackground(backgroundPane.update()); style.setAlpha((float)(numberDragPane.updateBean()/maxNumber)); - WidgetTitle title = style.getTitle() == null ? new WidgetTitle() : style.getTitle(); + TitlePacker title = style.getTitle() == null ? new WidgetTitle() : style.getTitle(); title.setTextObject(formulaPane.updateBean()); FRFont frFont = title.getFrFont(); frFont = frFont.applySize((Integer)fontSizeComboBox.getSelectedItem()); @@ -644,10 +629,10 @@ public class LayoutBorderPane extends BasicPane { } protected void populateTitle(){ - WidgetTitle widgetTitle = borderStyle == null ? new WidgetTitle() : borderStyle.getTitle(); + TitlePacker widgetTitle = borderStyle == null ? new WidgetTitle() : borderStyle.getTitle(); widgetTitle = widgetTitle == null ? new WidgetTitle() : widgetTitle; - populateFourmula(widgetTitle); + populateFormula(widgetTitle); populateFont(widgetTitle); underline.addMouseListener(new MouseAdapter() { @@ -683,7 +668,7 @@ public class LayoutBorderPane extends BasicPane { paintPreviewPane(); } - protected void populateFont(WidgetTitle widgetTitle){ + protected void populateFont(TitlePacker widgetTitle){ FRFont frFont = widgetTitle.getFrFont(); this.fontSizeComboBox.setSelectedItem(frFont.getSize()); this.fontSizeComboBox.addItemListener(new ItemListener() { @@ -756,7 +741,7 @@ public class LayoutBorderPane extends BasicPane { } - private void populateFourmula(WidgetTitle widgetTitle) { + private void populateFormula(TitlePacker widgetTitle) { this.formulaPane.populateBean(widgetTitle.getTextObject().toString()); this.formulaPane.getUITextField().getDocument() .addDocumentListener(new DocumentListener() { diff --git a/designer-form/src/main/java/com/fr/design/gui/xpane/LayoutBorderPreviewPane.java b/designer-form/src/main/java/com/fr/design/gui/xpane/LayoutBorderPreviewPane.java index 3d649f3b90..33470a33bc 100644 --- a/designer-form/src/main/java/com/fr/design/gui/xpane/LayoutBorderPreviewPane.java +++ b/designer-form/src/main/java/com/fr/design/gui/xpane/LayoutBorderPreviewPane.java @@ -7,10 +7,10 @@ import com.fr.base.background.ColorBackground; import com.fr.design.designer.creator.cardlayout.XCardSwitchButton; import com.fr.design.gui.itextarea.UITextArea; import com.fr.form.ui.LayoutBorderStyle; -import com.fr.form.ui.WidgetTitle; import com.fr.general.Background; import com.fr.general.FRFont; +import com.fr.general.act.TitlePacker; import com.fr.stable.Constants; import javax.swing.JPanel; @@ -126,7 +126,7 @@ public class LayoutBorderPreviewPane extends JPanel{ g2d.setColor(new Color(237, 237, 237)); } g2d.setFont(frFont.applyResolutionNP(resolution)); - WidgetTitle title = borderStyle.getTitle(); + TitlePacker title = borderStyle.getTitle(); String paintText = title.getTextObject().toString(); int startX1 = 0; int startY = 0; @@ -158,7 +158,7 @@ public class LayoutBorderPreviewPane extends JPanel{ GraphHelper.draw(g,double2, borderStyle.getBorder()); } - private void drawTabBack(Graphics2D g2d, Graphics g, WidgetTitle title, FontMetrics fm, int startX1, int startY){ + private void drawTabBack(Graphics2D g2d, Graphics g, TitlePacker title, FontMetrics fm, int startX1, int startY){ Dimension d = getSize(); String paintText = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Title")+TAB_ZERO;