diff --git a/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java b/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java index ce32e2323..ce495cdb9 100644 --- a/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java +++ b/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java @@ -236,7 +236,7 @@ public class EnvChangeEntrance { //说明版本一致,仅做日志记录 FineLoggerFactory.getLogger().info("Remote Designer version consistency"); } else { - localBranch = formatBranch(localBranch); + localBranch = GeneralUtils.getVersion(); remoteBranch = formatBranch(remoteBranch); Set noExistServiceSet = getNoExistServiceSet(connectionInfo); StringBuilder textBuilder = new StringBuilder(); diff --git a/designer-base/src/main/java/com/fr/design/actions/help/AboutPane.java b/designer-base/src/main/java/com/fr/design/actions/help/AboutPane.java index a7aac0391..57e01f1ac 100644 --- a/designer-base/src/main/java/com/fr/design/actions/help/AboutPane.java +++ b/designer-base/src/main/java/com/fr/design/actions/help/AboutPane.java @@ -11,8 +11,10 @@ import com.fr.design.gui.ilable.BoldFontTextLabel; import com.fr.design.gui.ilable.UILabel; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.general.CloudCenter; +import com.fr.general.ComparatorUtils; import com.fr.general.GeneralContext; import com.fr.general.GeneralUtils; +import com.fr.locale.InterProviderFactory; import com.fr.stable.ProductConstants; import com.fr.stable.StringUtils; import com.fr.stable.bridge.StableFactory; @@ -36,14 +38,16 @@ public class AboutPane extends JPanel { private static final String BUILD_PREFIX = " "; private static final String COMPANY_TELEPHONE = CloudCenter.getInstance().acquireUrlByKind("help.compNo"); private static final String PRESIDENT_PHONE = CloudCenter.getInstance().acquireUrlByKind("help.PNo"); + private static final String LEFT_BRACKET = "("; + private static final String RIGHT_BRACKET = ")"; private int maxWidth; public AboutPane() { this.setLayout(FRGUIPaneFactory.createBorderLayout()); - this.maxWidth = GraphHelper.getWidth(getBuildTitle() + GeneralUtils.readFullBuildNO() + - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Copy_Build_NO") + - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Copy_Build_NO_OK")); + this.maxWidth = GraphHelper.getWidth(getBuildTitle() + getVersionBuildNO() + + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Copy_Build_NO") + + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Copy_Build_NO_OK")); //center panel JPanel centerPane = FRGUIPaneFactory.createBorderLayout_L_Pane(); this.add(centerPane, BorderLayout.CENTER); @@ -53,7 +57,7 @@ public class AboutPane extends JPanel { BoxCenterAlignmentCopyablePane buildCopyPane = new BoxCenterAlignmentCopyablePane( getBuildTitle(), - GeneralUtils.readFullBuildNO(), + getVersionBuildNO(), new String[]{ com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Copy_Build_NO"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Copy_Build_NO_OK") @@ -95,6 +99,15 @@ public class AboutPane extends JPanel { } } + public String getVersionBuildNO() { + String version = GeneralUtils.getVersion(); + String build = GeneralUtils.readFullBuildNO(); + String notInstalledVersion = InterProviderFactory.getProvider().getLocText("Fine-Core_Basic_About_No_Build"); + if (ComparatorUtils.equals(notInstalledVersion, build)) + return notInstalledVersion; + return version + LEFT_BRACKET + build + RIGHT_BRACKET; + } + @Override public Dimension getPreferredSize() { return new Dimension(this.maxWidth, super.getPreferredSize().height); diff --git a/designer-base/src/main/java/com/fr/design/env/RemoteWorkspace.java b/designer-base/src/main/java/com/fr/design/env/RemoteWorkspace.java index c9eb2b621..6d1685e74 100644 --- a/designer-base/src/main/java/com/fr/design/env/RemoteWorkspace.java +++ b/designer-base/src/main/java/com/fr/design/env/RemoteWorkspace.java @@ -24,11 +24,11 @@ public class RemoteWorkspace implements Workspace { private final WorkspaceClient client; private final String address; - + private final WorkspaceConnectionInfo connection; - + private volatile Boolean isRoot = null; - + RemoteWorkspace(WorkspaceClient client, WorkspaceConnectionInfo connection) { this.client = client; @@ -41,13 +41,13 @@ public class RemoteWorkspace implements Workspace { return address; } - + @Override public String getDescription() { - + return Toolkit.i18nText("Fine-Design_Basic_Remote_Env"); } - + @Override public boolean isWarDeploy() { return WorkContext.getCurrent().get(CommonOperator.class, new ExceptionHandler() { @@ -66,7 +66,7 @@ public class RemoteWorkspace implements Workspace { @Override public boolean isRoot() { - + if (isRoot == null) { synchronized (this) { if (isRoot == null) { @@ -89,10 +89,10 @@ public class RemoteWorkspace implements Workspace { @Override public WorkspaceConnection getConnection() { - + return client.getConnection(); } - + @Override public T get(Class type) { @@ -111,22 +111,22 @@ public class RemoteWorkspace implements Workspace { } return client.getPool().get(type); } - + @Override public void close() { - + client.close(); } - + @Override public int hashCode() { - + return connection.hashCode(); } - + @Override public boolean equals(Object obj) { - + return obj instanceof RemoteWorkspace && AssistUtils.equals(((RemoteWorkspace) obj).connection, this.connection); } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/JFormSliderPane.java b/designer-base/src/main/java/com/fr/design/mainframe/JFormSliderPane.java index 0658d6040..adea8d7e4 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/JFormSliderPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/JFormSliderPane.java @@ -2,24 +2,31 @@ package com.fr.design.mainframe; import com.fr.base.BaseUtils; import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.islider.UISlider; -import com.fr.design.gui.itextfield.UITextField; +import com.fr.design.gui.itextfield.UINumberField; import com.fr.design.utils.gui.GUICoreUtils; + +import javax.swing.BorderFactory; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; -import javax.swing.text.AttributeSet; -import javax.swing.text.BadLocationException; -import javax.swing.text.PlainDocument; +import javax.swing.plaf.basic.BasicSliderUI; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; import java.awt.EventQueue; import java.awt.FlowLayout; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Image; import java.awt.Point; +import java.awt.Rectangle; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import java.awt.event.MouseEvent; @@ -29,6 +36,7 @@ import java.math.BigDecimal; * Created by MoMeak on 2017/7/13. */ public class JFormSliderPane extends JPanel { + public static final Image APPFIT_V0 = BaseUtils.readImage("com/fr/design/images/control/icon_thumb_normal.png"); private static final double ONEPOINTEIGHT = 1.8; private static final int SIX = 6; @@ -37,14 +45,13 @@ public class JFormSliderPane extends JPanel { private static final int HUNDRED = 100; private static final int TWO_HUNDRED = 200; private static final int FOUR_HUNDRED = 400; - private static final int SHOWVALBUTTON_WIDTH = 40; + private static final int SHOWVALBUTTON_WIDTH = 35; private static final int SHOWVALBUTTON_HEIGHTH = 20; private static final String SUFFIX = "%"; - private static final String REGEX = "[\\d%]*"; private static final int TOOLTIP_Y = 30; private static final Color BACK_COLOR = new Color(245, 245, 247); public int showValue = 100; - private UITextField showValField; + private UINumberField showValField; private UISlider slider; private int times; private int sliderValue; @@ -64,6 +71,9 @@ public class JFormSliderPane extends JPanel { panel.add(slider); panel.add(upButton); panel.add(showValField); + UILabel uiLabel = new UILabel(SUFFIX); + uiLabel.setBorder(BorderFactory.createEmptyBorder(0, 4, 0, 4)); + panel.add(uiLabel); panel.setBackground(BACK_COLOR); this.add(panel, BorderLayout.NORTH); } @@ -112,8 +122,8 @@ public class JFormSliderPane extends JPanel { } private void initShowValField() { - showValField = new UITextField(showValue + SUFFIX); - showValField.setBorderPainted(false); + showValField = new UINumberField(); + showValField.setValue(showValue); showValField.setPreferredSize(new Dimension(SHOWVALBUTTON_WIDTH, SHOWVALBUTTON_HEIGHTH)); showValField.addKeyListener(new KeyListener() { @Override @@ -131,27 +141,28 @@ public class JFormSliderPane extends JPanel { int code = evt.getKeyCode(); if (code == KeyEvent.VK_ENTER) { - showValue = parseInputValue(showValField.getText()); - showValField.setText(showValue + SUFFIX); - showValFieldChange(); + showValFieldChange((int) showValField.getValue()); } } }); - showValField.setDocument(new PlainDocument() { + showValField.addFocusListener(new FocusListener() { @Override - public void insertString(int offset, String s, AttributeSet a) throws BadLocationException { - if (!s.matches(REGEX)) { - return; - } - super.insertString(offset, s, a); + public void focusGained(FocusEvent e) { + } - }); + @Override + public void focusLost(FocusEvent e) { + showValFieldChange((int) showValField.getValue()); + } + }); } - private void showValFieldChange() { + + + private void showValFieldChange(int value) { isButtonOrIsTxt = true; - showValue = getPreferredValue(showValue); + showValue = getPreferredValue(value); refreshShowValueFieldText(); refreshSlider(); } @@ -167,22 +178,10 @@ public class JFormSliderPane extends JPanel { } private void refreshShowValueFieldText(){ - showValField.setText(showValue + SUFFIX); - } - - private int parseInputValue(String text){ - if (text.endsWith(SUFFIX)){ - text = text.substring(0, text.length() -1); - } - try{ - return Integer.parseInt(text); - }catch (NumberFormatException e){ - return HUNDRED; - } + showValField.setValue(showValue); + setAdjustButtonStatus(); } - - //定义一个监听器,用于监听所有滑动条 private ChangeListener listener = new ChangeListener() { public void stateChanged(ChangeEvent event) { @@ -207,6 +206,11 @@ public class JFormSliderPane extends JPanel { slider.setValue(calSliderValue(showValue)); } + private void setAdjustButtonStatus(){ + this.downButton.setEnabled(this.showValue > TEN); + this.upButton.setEnabled(this.showValue < FOUR_HUNDRED); + } + private int calSliderValue(int value) { int result; if (value > HUNDRED) { @@ -245,7 +249,7 @@ public class JFormSliderPane extends JPanel { if (newUpVal <= FOUR_HUNDRED) { showValue = newUpVal; } else { - showValue = TEN; + showValue = FOUR_HUNDRED; } refreshShowValueFieldText(); refreshSlider(); @@ -271,8 +275,7 @@ public class JFormSliderPane extends JPanel { } public void setShowValue(int value) { - showValue = value; - showValFieldChange(); + showValFieldChange(value); } @@ -280,6 +283,55 @@ public class JFormSliderPane extends JPanel { this.slider.addChangeListener(changeListener); } + class JSliderPaneUI extends BasicSliderUI { + + private static final int THUMB_XOFFSET = 8; + private static final int THUMB_YOFFSET = 3; + private static final int FOUR = 4; + private static final int FIVE = 5; + private static final int SIX = 6; + private static final int MID_X_SHIFT = 2; // 中点标记的水平位置偏移 + + public JSliderPaneUI(UISlider b) { + super(b); + } + + /** + * 绘制指示物 + */ + public void paintThumb(Graphics g) { + Rectangle knobBounds = thumbRect; + Graphics2D g2d = (Graphics2D) g; + g2d.drawImage(APPFIT_V0, knobBounds.x - THUMB_XOFFSET, knobBounds.y + THUMB_YOFFSET, null); + g2d.dispose(); + } + + /** + * 绘制刻度轨迹 + */ + public void paintTrack(Graphics g) { + int cy, cw; + Rectangle trackBounds = trackRect; + if (slider.getOrientation() == UISlider.HORIZONTAL) { + Graphics2D g2 = (Graphics2D) g; + cy = (trackBounds.height / 2); + cw = trackBounds.width; + g2.setPaint(BACK_COLOR); + g2.fillRect(0, -cy, cw + 10, cy * 4); + g.setColor(new Color(216, 216, 216)); + g.drawLine(0, cy, cw + 3, cy); + g.drawLine(MID_X_SHIFT + cw / 2, cy - FOUR, MID_X_SHIFT + cw / 2, cy + FOUR); + } else { + super.paintTrack(g); + } + } + + public void setThumbLocation(int x, int y) { + super.setThumbLocation(x, y); + slider.repaint(); + } + + } public static void main(String[] args) { JFrame jf = new JFrame("test"); diff --git a/designer-base/src/main/java/com/fr/design/mainframe/JSliderPane.java b/designer-base/src/main/java/com/fr/design/mainframe/JSliderPane.java index 4c8f307d6..487d18a56 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/JSliderPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/JSliderPane.java @@ -1,516 +1,516 @@ -package com.fr.design.mainframe; - -import com.fr.base.BaseUtils; -import com.fr.design.constants.LayoutConstants; -import com.fr.design.gui.ibutton.UIButton; -import com.fr.design.gui.ibutton.UIRadioButton; -import com.fr.design.gui.ibutton.UISliderButton; -import com.fr.design.gui.ilable.UILabel; -import com.fr.design.gui.imenu.UIPopupMenu; -import com.fr.design.gui.islider.UISlider; -import com.fr.design.gui.ispinner.UIBasicSpinner; -import com.fr.design.gui.ispinner.UISpinnerUI; -import com.fr.design.gui.itextfield.UITextField; -import com.fr.design.layout.TableLayout; -import com.fr.design.layout.TableLayoutHelper; -import com.fr.design.utils.gui.GUICoreUtils; - - -import javax.swing.BorderFactory; -import javax.swing.ButtonGroup; -import javax.swing.JButton; -import javax.swing.JFormattedTextField; -import javax.swing.JFrame; -import javax.swing.JPanel; -import javax.swing.JRadioButton; -import javax.swing.JSeparator; -import javax.swing.JSpinner; -import javax.swing.SpinnerNumberModel; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; -import javax.swing.plaf.basic.BasicSliderUI; -import javax.swing.text.DefaultFormatterFactory; -import javax.swing.text.NumberFormatter; -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.EventQueue; -import java.awt.FlowLayout; -import java.awt.Font; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.Image; -import java.awt.Insets; -import java.awt.Point; -import java.awt.Rectangle; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; -import java.awt.event.MouseEvent; -import java.math.BigDecimal; - -/** - * Created by MoMeak on 2017/7/13. - */ -public class JSliderPane extends JPanel { - - public static final Image APPFIT_V0 = BaseUtils.readImage("com/fr/design/images/control/icon_thumb_normal.png"); - private static final double ONEPOINTEIGHT = 1.8; - private static final int SIX = 6; - private static final int TEN = 10; - private static final int FONT_SIZE = 12; - private static final int SPINNER_WIDTH = 45; - private static final int SPINNER_HEIGHT = 20; - private static final int HALF_HUNDRED = 50; - private static final int HUNDRED = 100; - private static final int TWO_HUNDRED = 200; - private static final int FOUR_HUNDRED = 400; - private static final int SHOWVALBUTTON_WIDTH = 40; - private static final int SHOWVALBUTTON_HEIGHTH = 20; - private static final int TOOLTIP_Y = 30; - - private static final Color BACK_COLOR = new Color(245, 245, 247); - public int showValue = 100; - public double resolutionTimes = 1.0; - private UITextField showVal; - private JSpinner showValSpinner; - private UISlider slider; - private int times; - private int sliderValue; - private UIButton downButton; - private UIButton upButton; - private UISliderButton 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 PopupPane dialog; - private int upButtonX; - private JPanel dialogContentPanel; - - - public JSliderPane() { - this.setLayout(new BorderLayout()); - initSlider(); - initShowValSpinner(); - //MoMeak:控制只能输入10-400 - JSpinner.NumberEditor editor = new JSpinner.NumberEditor(showValSpinner, "0"); - showValSpinner.setEditor(editor); - JFormattedTextField textField = ((JSpinner.NumberEditor) showValSpinner.getEditor()).getTextField(); - textField.setEditable(true); - DefaultFormatterFactory factory = (DefaultFormatterFactory) textField.getFormatterFactory(); - NumberFormatter formatter = (NumberFormatter) factory.getDefaultFormatter(); - formatter.setAllowsInvalid(false); - - initDownUpButton(); - initShowValButton(); - initUIRadioButton(); - initPane(); - JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 0)); - panel.add(downButton); - panel.add(slider); - panel.add(upButton); - panel.add(showValButton); - panel.setBackground(BACK_COLOR); - this.add(panel, BorderLayout.NORTH); - } - - - public static JSliderPane getInstance() { - return new JSliderPane(); - } - - private void initSlider() { - slider = new UISlider(0, HUNDRED, HALF_HUNDRED) { - public Point getToolTipLocation(MouseEvent event) { - return new Point(event.getX(), event.getY() - TOOLTIP_Y); - } - }; - slider.setUI(new JSliderPaneUI(slider)); - slider.addChangeListener(listener); - slider.setPreferredSize(new Dimension(220, 20)); - //去掉虚线框 - slider.setFocusable(false); - slider.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Scale_Slider")); - } - - private void initShowValSpinner() { - showValSpinner = new UIBasicSpinner(new SpinnerNumberModel(HUNDRED, 0, FOUR_HUNDRED, 1)) { - public Point getToolTipLocation(MouseEvent event) { - return new Point(event.getX(), event.getY() - TOOLTIP_Y); - } - }; - showValSpinner.setUI(new UISpinnerUI()); - showValSpinner.setEnabled(true); - showValSpinner.addChangeListener(showValSpinnerChangeListener); - showValSpinner.setPreferredSize(new Dimension(SPINNER_WIDTH, SPINNER_HEIGHT)); - } - - private void initDownUpButton() { - downButton = new UIButton(BaseUtils.readIcon("com/fr/design/images/data/source/normalDown20.png"), BaseUtils.readIcon("com/fr/design/images/data/source/hoverDown20.png"), BaseUtils.readIcon("com/fr/design/images/data/source/hoverDown20.png")) { - public Point getToolTipLocation(MouseEvent event) { - return new Point(event.getX(), event.getY() - TOOLTIP_Y); - } - }; - downButton.setOpaque(false); - downButton.setBorderPainted(false); - downButton.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Scale_Down")); - upButton = new UIButton(BaseUtils.readIcon("com/fr/design/images/data/source/normalUp20.png"), BaseUtils.readIcon("com/fr/design/images/data/source/hoverUp20.png"), BaseUtils.readIcon("com/fr/design/images/data/source/hoverUp20.png")) { - public Point getToolTipLocation(MouseEvent event) { - return new Point(event.getX(), event.getY() - TOOLTIP_Y); - } - }; - upButton.setOpaque(false); - upButton.setBorderPainted(false); - upButton.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Scale_Up")); - downButton.setActionCommand("less"); - upButton.setActionCommand("more"); - downButton.addActionListener(buttonActionListener); - upButton.addActionListener(buttonActionListener); - } - - private void initShowValButton() { - showValButton = new UISliderButton(showValSpinner.getValue() + "%"); - showValButton.setBackground(BACK_COLOR); - showValButton.setBorderPainted(false); - showValButton.setPreferredSize(new Dimension(SHOWVALBUTTON_WIDTH, SHOWVALBUTTON_HEIGHTH)); - showValButton.addActionListener(showValButtonActionListener); - showValButton.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Scale_Grade")); - } - - 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(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Scale_Self_Adapt_Button")); - selfAdaptButton.setFont(new Font("SimSun", Font.PLAIN, FONT_SIZE)); - customButton = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Scale_Custom_Button")); - customButton.setFont(new Font("SimSun", Font.PLAIN, FONT_SIZE)); - twoHundredButton.addItemListener(radioButtonItemListener); - oneHundredButton.addItemListener(radioButtonItemListener); - sevenFiveButton.addItemListener(radioButtonItemListener); - fiveTenButton.addItemListener(radioButtonItemListener); - twoFiveButton.addItemListener(radioButtonItemListener); - customButton.addItemListener(new ItemListener() { - @Override - public void itemStateChanged(ItemEvent e) { - JRadioButton temp = (JRadioButton) e.getSource(); - if (temp.isSelected()) { - JFormattedTextField textField = ((JSpinner.NumberEditor) showValSpinner.getEditor()).getTextField(); - textField.requestFocus(); - textField.selectAll(); - } - } - }); - - 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); - customButton.setSelected(true); - } - - private void initPane() { - double p = TableLayout.PREFERRED; - double f = TableLayout.FILL; - double[] columnSize = {p, f}; - double[] rowSize = {p, p, p, p, p, p, p, p, p}; - UILabel upLabel = new UILabel(" " + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Scale_EnlargeOrReduce")); - upLabel.setOpaque(false); - JPanel septPane = new JPanel(new BorderLayout()); - JSeparator sept = new JSeparator(); - sept.setBackground(new Color(232, 232, 233)); - septPane.add(sept, BorderLayout.NORTH); - septPane.setBorder(BorderFactory.createEmptyBorder(2, 5, 1, 10)); - septPane.setBackground(BACK_COLOR); - twoHundredButton.setBackground(BACK_COLOR); - oneHundredButton.setBackground(BACK_COLOR); - sevenFiveButton.setBackground(BACK_COLOR); - fiveTenButton.setBackground(BACK_COLOR); - twoFiveButton.setBackground(BACK_COLOR); - selfAdaptButton.setBackground(BACK_COLOR); - customButton.setBackground(BACK_COLOR); - Component[][] components = new Component[][]{ - new Component[]{upLabel, null}, - new Component[]{septPane, null}, - new Component[]{twoHundredButton, null}, - new Component[]{oneHundredButton, null}, - new Component[]{sevenFiveButton, null}, - new Component[]{fiveTenButton, null}, - new Component[]{twoFiveButton, null}, - new Component[]{selfAdaptButton, null}, - new Component[]{customButton, createSpinnerPanel()} - }; - dialogContentPanel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, LayoutConstants.VGAP_MEDIUM, 0); - dialogContentPanel.setBackground(BACK_COLOR); - dialogContentPanel.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0)); - } - - private JPanel createSpinnerPanel() { - JPanel spinnerPanel = new JPanel(new FlowLayout()); - spinnerPanel.add(showValSpinner); - UILabel percent = new UILabel("%"); - percent.setFont(new Font("SimSun", Font.PLAIN, FONT_SIZE)); - spinnerPanel.add(percent); - spinnerPanel.setBackground(BACK_COLOR); - return spinnerPanel; - } - - private ActionListener showValButtonActionListener = new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - popupDialog(); - } - }; - - private ChangeListener showValSpinnerChangeListener = new ChangeListener() { - @Override - public void stateChanged(ChangeEvent e) { - int val = (int) ((UIBasicSpinner) e.getSource()).getValue(); - isButtonOrIsTxt = true; - resolutionTimes = divide(showValue, 100, 2); - if (val > FOUR_HUNDRED) { - showValSpinner.setValue(FOUR_HUNDRED); - val = FOUR_HUNDRED; - } - if (val < TEN) { - showValSpinner.setValue(TEN); - val = TEN; - } - refreshSlider(val); - refreshBottun(val); - JFormattedTextField textField = ((JSpinner.NumberEditor) showValSpinner.getEditor()).getTextField(); - textField.setCaretPosition(showValSpinner.getValue().toString().length()); - } - }; - - - //定义一个监听器,用于监听所有滑动条 - private ChangeListener listener = new ChangeListener() { - public void stateChanged(ChangeEvent event) { - //取出滑动条的值,并在文本中显示出来 - if (!isButtonOrIsTxt) { - customButton.setSelected(true); - EventQueue.invokeLater(new Runnable() { - public void run() { - sliderValue = slider.getValue(); - getTimes(sliderValue); - showValue = times; - showValSpinner.setValue(times); - customButton.setSelected(true); - } - }); - } else { - isButtonOrIsTxt = false; - } - } - }; - - private ItemListener radioButtonItemListener = new ItemListener() { - @Override - public void itemStateChanged(ItemEvent e) { - JRadioButton temp = (JRadioButton) e.getSource(); - if (temp.isSelected()) { - showValSpinner.setValue(Integer.valueOf(temp.getText().substring(0, temp.getText().indexOf("%")))); - } - } - }; - - private void refreshSlider(int val) { - showValue = val; - if (showValue > HUNDRED) { - slider.setValue((int) (showValue + TWO_HUNDRED) / SIX); - } else if (showValue < HUNDRED) { - slider.setValue((int) ((showValue - TEN) / ONEPOINTEIGHT)); - } else { - slider.setValue(HALF_HUNDRED); - } - } - - - private void refreshBottun(int val) { - showValButton.setText(val + "%"); - } - - public double getResolutionTimes() { - return this.resolutionTimes; - } - - public int getshowValue() { - return this.showValue; - } - - public void reset() { - this.showValSpinner.setValue(HUNDRED); - } - - public static double divide(double v1, double v2, int scale) { - BigDecimal b1 = new BigDecimal(Double.toString(v1)); - BigDecimal b2 = new BigDecimal(Double.toString(v2)); - return b1.divide(b2, scale).doubleValue(); - } - - private ActionListener buttonActionListener = new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - showValue = (int) showValSpinner.getValue(); - isButtonOrIsTxt = true; - if ("less".equals(e.getActionCommand())) { - int newDownVal = showValue - TEN; - if (newDownVal >= TEN) { - showValue = newDownVal; - showValSpinner.setValue(newDownVal); - } else { - showValue = newDownVal; - showValSpinner.setValue(TEN); - } - } - if ("more".equals(e.getActionCommand())) { - int newUpVal = showValue + TEN; - if (newUpVal <= FOUR_HUNDRED) { - showValue = newUpVal; - showValSpinner.setValue(newUpVal); - } else { - showValue = newUpVal; - showValSpinner.setValue(FOUR_HUNDRED); - } - } - isButtonOrIsTxt = true; - customButton.setSelected(true); - } - }; - - - private void getTimes(int value) { - if (value == HALF_HUNDRED) { - times = HUNDRED; - } else if (value < HALF_HUNDRED) { - times = (int) Math.round(ONEPOINTEIGHT * value + TEN); - } else { - times = SIX * value - TWO_HUNDRED; - } - } - - - public JSpinner getShowVal() { - return this.showValSpinner; - } - - public UIRadioButton getSelfAdaptButton() { - return this.selfAdaptButton; - } - - private void popupDialog() { - Point btnCoords = upButton.getLocationOnScreen(); - if (dialog == null) { - dialog = new PopupPane(upButton, dialogContentPanel); - if (upButtonX == 0) { - upButtonX = btnCoords.x; - GUICoreUtils.showPopupMenu(dialog, upButton, -dialog.getPreferredSize().width + upButton.getWidth() + SHOWVALBUTTON_WIDTH, -dialog.getPreferredSize().height); - } - } else { - if (upButtonX == 0) { - upButtonX = btnCoords.x; - GUICoreUtils.showPopupMenu(dialog, upButton, -dialog.getPreferredSize().width + upButton.getWidth() + SHOWVALBUTTON_WIDTH, -dialog.getPreferredSize().height); - } else { - GUICoreUtils.showPopupMenu(dialog, upButton, -dialog.getPreferredSize().width + upButton.getWidth() + SHOWVALBUTTON_WIDTH, -dialog.getPreferredSize().height); - } - } - } - - 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(JSliderPane.getInstance(), BorderLayout.CENTER); - GUICoreUtils.centerWindow(jf); - jf.setSize(400, 80); - jf.setVisible(true); - - } -} - -class JSliderPaneUI extends BasicSliderUI { - - private static final Color BACK_COLOR = new Color(245, 245, 247); - private static final int THUMB_XOFFSET = 8; - private static final int THUMB_YOFFSET = 3; - private static final int FOUR = 4; - private static final int FIVE = 5; - private static final int SIX = 6; - private static final int MID_X_SHIFT = 2; // 中点标记的水平位置偏移 - - public JSliderPaneUI(UISlider b) { - super(b); - } - - /** - * 绘制指示物 - */ - public void paintThumb(Graphics g) { - Rectangle knobBounds = thumbRect; - Graphics2D g2d = (Graphics2D) g; - g2d.drawImage(JSliderPane.APPFIT_V0, knobBounds.x - THUMB_XOFFSET, knobBounds.y + THUMB_YOFFSET, null); - g2d.dispose(); - } - - /** - * 绘制刻度轨迹 - */ - public void paintTrack(Graphics g) { - int cy, cw; - Rectangle trackBounds = trackRect; - if (slider.getOrientation() == UISlider.HORIZONTAL) { - Graphics2D g2 = (Graphics2D) g; - cy = (trackBounds.height / 2); - cw = trackBounds.width; - g2.setPaint(BACK_COLOR); - g2.fillRect(0, -cy, cw + 10, cy * 4); - g.setColor(new Color(216, 216, 216)); - g.drawLine(0, cy, cw + 3, cy); - g.drawLine(MID_X_SHIFT + cw / 2, cy - FOUR, MID_X_SHIFT + cw / 2, cy + FOUR); - } else { - super.paintTrack(g); - } - } - - public void setThumbLocation(int x, int y) { - super.setThumbLocation(x, y); - slider.repaint(); - } - -} - -class PopupPane extends UIPopupMenu { - private static final float REC = 8f; - private static final int INSERT_TOPBOTTOM = 10; - private static final int INSERT_LEFTRIGHT = 2; - private static final int DIALOG_WIDTH = 157; - private static final int DIALOG_HEIGHT = 205; - - PopupPane(JButton b, JPanel dialogContentPanel) { - this.add(dialogContentPanel, BorderLayout.CENTER); - this.setPreferredSize(new Dimension(DIALOG_WIDTH, DIALOG_HEIGHT)); - this.setBackground(new Color(245, 245, 247)); - } - - public Insets getInsets() { - return new Insets(INSERT_TOPBOTTOM, INSERT_LEFTRIGHT, INSERT_TOPBOTTOM, INSERT_LEFTRIGHT); - } -} +package com.fr.design.mainframe; + +import com.fr.base.BaseUtils; +import com.fr.design.constants.LayoutConstants; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.ibutton.UIRadioButton; +import com.fr.design.gui.ibutton.UISliderButton; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.imenu.UIPopupMenu; +import com.fr.design.gui.islider.UISlider; +import com.fr.design.gui.ispinner.UIBasicSpinner; +import com.fr.design.gui.ispinner.UISpinnerUI; +import com.fr.design.gui.itextfield.UITextField; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.utils.gui.GUICoreUtils; + + +import javax.swing.BorderFactory; +import javax.swing.ButtonGroup; +import javax.swing.JButton; +import javax.swing.JFormattedTextField; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.JRadioButton; +import javax.swing.JSeparator; +import javax.swing.JSpinner; +import javax.swing.SpinnerNumberModel; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import javax.swing.plaf.basic.BasicSliderUI; +import javax.swing.text.DefaultFormatterFactory; +import javax.swing.text.NumberFormatter; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.FlowLayout; +import java.awt.Font; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Image; +import java.awt.Insets; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.awt.event.MouseEvent; +import java.math.BigDecimal; + +/** + * Created by MoMeak on 2017/7/13. + */ +public class JSliderPane extends JPanel { + + public static final Image APPFIT_V0 = BaseUtils.readImage("com/fr/design/images/control/icon_thumb_normal.png"); + private static final double ONEPOINTEIGHT = 1.8; + private static final int SIX = 6; + private static final int TEN = 10; + private static final int FONT_SIZE = 12; + private static final int SPINNER_WIDTH = 45; + private static final int SPINNER_HEIGHT = 20; + private static final int HALF_HUNDRED = 50; + private static final int HUNDRED = 100; + private static final int TWO_HUNDRED = 200; + private static final int FOUR_HUNDRED = 400; + private static final int SHOWVALBUTTON_WIDTH = 40; + private static final int SHOWVALBUTTON_HEIGHTH = 20; + private static final int TOOLTIP_Y = 30; + + private static final Color BACK_COLOR = new Color(245, 245, 247); + public int showValue = 100; + public double resolutionTimes = 1.0; + private UITextField showVal; + private JSpinner showValSpinner; + private UISlider slider; + private int times; + private int sliderValue; + private UIButton downButton; + private UIButton upButton; + private UISliderButton 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 PopupPane dialog; + private int upButtonX; + private JPanel dialogContentPanel; + + + public JSliderPane() { + this.setLayout(new BorderLayout()); + initSlider(); + initShowValSpinner(); + //MoMeak:控制只能输入10-400 + JSpinner.NumberEditor editor = new JSpinner.NumberEditor(showValSpinner, "0"); + showValSpinner.setEditor(editor); + JFormattedTextField textField = ((JSpinner.NumberEditor) showValSpinner.getEditor()).getTextField(); + textField.setEditable(true); + DefaultFormatterFactory factory = (DefaultFormatterFactory) textField.getFormatterFactory(); + NumberFormatter formatter = (NumberFormatter) factory.getDefaultFormatter(); + formatter.setAllowsInvalid(false); + + initDownUpButton(); + initShowValButton(); + initUIRadioButton(); + initPane(); + JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 0)); + panel.add(downButton); + panel.add(slider); + panel.add(upButton); + panel.add(showValButton); + panel.setBackground(BACK_COLOR); + this.add(panel, BorderLayout.NORTH); + } + + + public static JSliderPane getInstance() { + return new JSliderPane(); + } + + private void initSlider() { + slider = new UISlider(0, HUNDRED, HALF_HUNDRED) { + public Point getToolTipLocation(MouseEvent event) { + return new Point(event.getX(), event.getY() - TOOLTIP_Y); + } + }; + slider.setUI(new JSliderPaneUI(slider)); + slider.addChangeListener(listener); + slider.setPreferredSize(new Dimension(220, 20)); + //去掉虚线框 + slider.setFocusable(false); + slider.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Scale_Slider")); + } + + private void initShowValSpinner() { + showValSpinner = new UIBasicSpinner(new SpinnerNumberModel(HUNDRED, 0, FOUR_HUNDRED, 1)) { + public Point getToolTipLocation(MouseEvent event) { + return new Point(event.getX(), event.getY() - TOOLTIP_Y); + } + }; + showValSpinner.setUI(new UISpinnerUI()); + showValSpinner.setEnabled(true); + showValSpinner.addChangeListener(showValSpinnerChangeListener); + showValSpinner.setPreferredSize(new Dimension(SPINNER_WIDTH, SPINNER_HEIGHT)); + } + + private void initDownUpButton() { + downButton = new UIButton(BaseUtils.readIcon("com/fr/design/images/data/source/normalDown20.png"), BaseUtils.readIcon("com/fr/design/images/data/source/hoverDown20.png"), BaseUtils.readIcon("com/fr/design/images/data/source/hoverDown20.png")) { + public Point getToolTipLocation(MouseEvent event) { + return new Point(event.getX(), event.getY() - TOOLTIP_Y); + } + }; + downButton.setOpaque(false); + downButton.setBorderPainted(false); + downButton.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Scale_Down")); + upButton = new UIButton(BaseUtils.readIcon("com/fr/design/images/data/source/normalUp20.png"), BaseUtils.readIcon("com/fr/design/images/data/source/hoverUp20.png"), BaseUtils.readIcon("com/fr/design/images/data/source/hoverUp20.png")) { + public Point getToolTipLocation(MouseEvent event) { + return new Point(event.getX(), event.getY() - TOOLTIP_Y); + } + }; + upButton.setOpaque(false); + upButton.setBorderPainted(false); + upButton.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Scale_Up")); + downButton.setActionCommand("less"); + upButton.setActionCommand("more"); + downButton.addActionListener(buttonActionListener); + upButton.addActionListener(buttonActionListener); + } + + private void initShowValButton() { + showValButton = new UISliderButton(showValSpinner.getValue() + "%"); + showValButton.setBackground(BACK_COLOR); + showValButton.setBorderPainted(false); + showValButton.setPreferredSize(new Dimension(SHOWVALBUTTON_WIDTH, SHOWVALBUTTON_HEIGHTH)); + showValButton.addActionListener(showValButtonActionListener); + showValButton.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Scale_Grade")); + } + + 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(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Scale_Self_Adapt_Button")); + selfAdaptButton.setFont(new Font("SimSun", Font.PLAIN, FONT_SIZE)); + customButton = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Scale_Custom_Button")); + customButton.setFont(new Font("SimSun", Font.PLAIN, FONT_SIZE)); + twoHundredButton.addItemListener(radioButtonItemListener); + oneHundredButton.addItemListener(radioButtonItemListener); + sevenFiveButton.addItemListener(radioButtonItemListener); + fiveTenButton.addItemListener(radioButtonItemListener); + twoFiveButton.addItemListener(radioButtonItemListener); + customButton.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + JRadioButton temp = (JRadioButton) e.getSource(); + if (temp.isSelected()) { + JFormattedTextField textField = ((JSpinner.NumberEditor) showValSpinner.getEditor()).getTextField(); + textField.requestFocus(); + textField.selectAll(); + } + } + }); + + 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); + customButton.setSelected(true); + } + + private void initPane() { + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double[] columnSize = {p, f}; + double[] rowSize = {p, p, p, p, p, p, p, p, p}; + UILabel upLabel = new UILabel(" " + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Scale_EnlargeOrReduce")); + upLabel.setOpaque(false); + JPanel septPane = new JPanel(new BorderLayout()); + JSeparator sept = new JSeparator(); + sept.setBackground(new Color(232, 232, 233)); + septPane.add(sept, BorderLayout.NORTH); + septPane.setBorder(BorderFactory.createEmptyBorder(2, 5, 1, 10)); + septPane.setBackground(BACK_COLOR); + twoHundredButton.setBackground(BACK_COLOR); + oneHundredButton.setBackground(BACK_COLOR); + sevenFiveButton.setBackground(BACK_COLOR); + fiveTenButton.setBackground(BACK_COLOR); + twoFiveButton.setBackground(BACK_COLOR); + selfAdaptButton.setBackground(BACK_COLOR); + customButton.setBackground(BACK_COLOR); + Component[][] components = new Component[][]{ + new Component[]{upLabel, null}, + new Component[]{septPane, null}, + new Component[]{twoHundredButton, null}, + new Component[]{oneHundredButton, null}, + new Component[]{sevenFiveButton, null}, + new Component[]{fiveTenButton, null}, + new Component[]{twoFiveButton, null}, + new Component[]{selfAdaptButton, null}, + new Component[]{customButton, createSpinnerPanel()} + }; + dialogContentPanel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, LayoutConstants.VGAP_MEDIUM, 0); + dialogContentPanel.setBackground(BACK_COLOR); + dialogContentPanel.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0)); + } + + private JPanel createSpinnerPanel() { + JPanel spinnerPanel = new JPanel(new FlowLayout()); + spinnerPanel.add(showValSpinner); + UILabel percent = new UILabel("%"); + percent.setFont(new Font("SimSun", Font.PLAIN, FONT_SIZE)); + spinnerPanel.add(percent); + spinnerPanel.setBackground(BACK_COLOR); + return spinnerPanel; + } + + private ActionListener showValButtonActionListener = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + popupDialog(); + } + }; + + private ChangeListener showValSpinnerChangeListener = new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + int val = (int) ((UIBasicSpinner) e.getSource()).getValue(); + isButtonOrIsTxt = true; + resolutionTimes = divide(showValue, 100, 2); + if (val > FOUR_HUNDRED) { + showValSpinner.setValue(FOUR_HUNDRED); + val = FOUR_HUNDRED; + } + if (val < TEN) { + showValSpinner.setValue(TEN); + val = TEN; + } + refreshSlider(val); + refreshBottun(val); + JFormattedTextField textField = ((JSpinner.NumberEditor) showValSpinner.getEditor()).getTextField(); + textField.setCaretPosition(showValSpinner.getValue().toString().length()); + } + }; + + + //定义一个监听器,用于监听所有滑动条 + private ChangeListener listener = new ChangeListener() { + public void stateChanged(ChangeEvent event) { + //取出滑动条的值,并在文本中显示出来 + if (!isButtonOrIsTxt) { + customButton.setSelected(true); + EventQueue.invokeLater(new Runnable() { + public void run() { + sliderValue = slider.getValue(); + getTimes(sliderValue); + showValue = times; + showValSpinner.setValue(times); + customButton.setSelected(true); + } + }); + } else { + isButtonOrIsTxt = false; + } + } + }; + + private ItemListener radioButtonItemListener = new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + JRadioButton temp = (JRadioButton) e.getSource(); + if (temp.isSelected()) { + showValSpinner.setValue(Integer.valueOf(temp.getText().substring(0, temp.getText().indexOf("%")))); + } + } + }; + + private void refreshSlider(int val) { + showValue = val; + if (showValue > HUNDRED) { + slider.setValue((int) (showValue + TWO_HUNDRED) / SIX); + } else if (showValue < HUNDRED) { + slider.setValue((int) ((showValue - TEN) / ONEPOINTEIGHT)); + } else { + slider.setValue(HALF_HUNDRED); + } + } + + + private void refreshBottun(int val) { + showValButton.setText(val + "%"); + } + + public double getResolutionTimes() { + return this.resolutionTimes; + } + + public int getshowValue() { + return this.showValue; + } + + public void reset() { + this.showValSpinner.setValue(HUNDRED); + } + + public static double divide(double v1, double v2, int scale) { + BigDecimal b1 = new BigDecimal(Double.toString(v1)); + BigDecimal b2 = new BigDecimal(Double.toString(v2)); + return b1.divide(b2, scale).doubleValue(); + } + + private ActionListener buttonActionListener = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + showValue = (int) showValSpinner.getValue(); + isButtonOrIsTxt = true; + if ("less".equals(e.getActionCommand())) { + int newDownVal = showValue - TEN; + if (newDownVal >= TEN) { + showValue = newDownVal; + showValSpinner.setValue(newDownVal); + } else { + showValue = newDownVal; + showValSpinner.setValue(TEN); + } + } + if ("more".equals(e.getActionCommand())) { + int newUpVal = showValue + TEN; + if (newUpVal <= FOUR_HUNDRED) { + showValue = newUpVal; + showValSpinner.setValue(newUpVal); + } else { + showValue = newUpVal; + showValSpinner.setValue(FOUR_HUNDRED); + } + } + isButtonOrIsTxt = true; + customButton.setSelected(true); + } + }; + + + private void getTimes(int value) { + if (value == HALF_HUNDRED) { + times = HUNDRED; + } else if (value < HALF_HUNDRED) { + times = (int) Math.round(ONEPOINTEIGHT * value + TEN); + } else { + times = SIX * value - TWO_HUNDRED; + } + } + + + public JSpinner getShowVal() { + return this.showValSpinner; + } + + public UIRadioButton getSelfAdaptButton() { + return this.selfAdaptButton; + } + + private void popupDialog() { + Point btnCoords = upButton.getLocationOnScreen(); + if (dialog == null) { + dialog = new PopupPane(upButton, dialogContentPanel); + if (upButtonX == 0) { + upButtonX = btnCoords.x; + GUICoreUtils.showPopupMenu(dialog, upButton, -dialog.getPreferredSize().width + upButton.getWidth() + SHOWVALBUTTON_WIDTH, -dialog.getPreferredSize().height); + } + } else { + if (upButtonX == 0) { + upButtonX = btnCoords.x; + GUICoreUtils.showPopupMenu(dialog, upButton, -dialog.getPreferredSize().width + upButton.getWidth() + SHOWVALBUTTON_WIDTH, -dialog.getPreferredSize().height); + } else { + GUICoreUtils.showPopupMenu(dialog, upButton, -dialog.getPreferredSize().width + upButton.getWidth() + SHOWVALBUTTON_WIDTH, -dialog.getPreferredSize().height); + } + } + } + + 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(JSliderPane.getInstance(), BorderLayout.CENTER); + GUICoreUtils.centerWindow(jf); + jf.setSize(400, 80); + jf.setVisible(true); + + } +} + +class JSliderPaneUI extends BasicSliderUI { + + private static final Color BACK_COLOR = new Color(245, 245, 247); + private static final int THUMB_XOFFSET = 8; + private static final int THUMB_YOFFSET = 3; + private static final int FOUR = 4; + private static final int FIVE = 5; + private static final int SIX = 6; + private static final int MID_X_SHIFT = 2; // 中点标记的水平位置偏移 + + public JSliderPaneUI(UISlider b) { + super(b); + } + + /** + * 绘制指示物 + */ + public void paintThumb(Graphics g) { + Rectangle knobBounds = thumbRect; + Graphics2D g2d = (Graphics2D) g; + g2d.drawImage(JSliderPane.APPFIT_V0, knobBounds.x - THUMB_XOFFSET, knobBounds.y + THUMB_YOFFSET, null); + g2d.dispose(); + } + + /** + * 绘制刻度轨迹 + */ + public void paintTrack(Graphics g) { + int cy, cw; + Rectangle trackBounds = trackRect; + if (slider.getOrientation() == UISlider.HORIZONTAL) { + Graphics2D g2 = (Graphics2D) g; + cy = (trackBounds.height / 2); + cw = trackBounds.width; + g2.setPaint(BACK_COLOR); + g2.fillRect(0, -cy, cw + 10, cy * 4); + g.setColor(new Color(216, 216, 216)); + g.drawLine(0, cy, cw + 3, cy); + g.drawLine(MID_X_SHIFT + cw / 2, cy - FOUR, MID_X_SHIFT + cw / 2, cy + FOUR); + } else { + super.paintTrack(g); + } + } + + public void setThumbLocation(int x, int y) { + super.setThumbLocation(x, y); + slider.repaint(); + } + +} + +class PopupPane extends UIPopupMenu { + private static final float REC = 8f; + private static final int INSERT_TOPBOTTOM = 10; + private static final int INSERT_LEFTRIGHT = 2; + private static final int DIALOG_WIDTH = 157; + private static final int DIALOG_HEIGHT = 205; + + PopupPane(JButton b, JPanel dialogContentPanel) { + this.add(dialogContentPanel, BorderLayout.CENTER); + this.setPreferredSize(new Dimension(DIALOG_WIDTH, DIALOG_HEIGHT)); + this.setBackground(new Color(245, 245, 247)); + } + + public Insets getInsets() { + return new Insets(INSERT_TOPBOTTOM, INSERT_LEFTRIGHT, INSERT_TOPBOTTOM, INSERT_LEFTRIGHT); + } +} diff --git a/designer-base/src/main/java/com/fr/design/update/actions/RecoverForDesigner.java b/designer-base/src/main/java/com/fr/design/update/actions/RecoverForDesigner.java index 827a39fd3..bf874c632 100644 --- a/designer-base/src/main/java/com/fr/design/update/actions/RecoverForDesigner.java +++ b/designer-base/src/main/java/com/fr/design/update/actions/RecoverForDesigner.java @@ -24,6 +24,8 @@ public class RecoverForDesigner implements Recover { private final String installHome = StableUtils.getInstallHome(); + private static final String HYPHEN = "-"; + @Override public boolean recover() { try{ @@ -41,7 +43,8 @@ public class RecoverForDesigner implements Recover { @Override public boolean backup() { //jar包备份文件的目录为"backup/"+jar包当前版本号 - String todayBackupDir = StableUtils.pathJoin(installHome, UpdateConstants.DESIGNER_BACKUP_DIR, (GeneralUtils.readBuildNO())); + String versionBuildNo = GeneralUtils.getVersion() + HYPHEN + GeneralUtils.readBuildNO(); + String todayBackupDir = StableUtils.pathJoin(installHome, UpdateConstants.DESIGNER_BACKUP_DIR, versionBuildNo); String envHome = ProjectLibrary.getInstance().getLibHome(); backupFilesFromInstallEnv(envHome, todayBackupDir); backupFilesFromInstallLib(installHome, todayBackupDir); diff --git a/designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java b/designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java index 78df599c5..3992be6a9 100644 --- a/designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java +++ b/designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java @@ -29,6 +29,7 @@ import com.fr.general.*; import com.fr.general.http.HttpToolbox; import com.fr.json.JSONArray; import com.fr.json.JSONObject; +import com.fr.locale.InterProviderFactory; import com.fr.log.FineLoggerFactory; import com.fr.process.engine.core.FineProcessContext; import com.fr.process.engine.core.FineProcessEngineEvent; @@ -80,6 +81,8 @@ public class UpdateMainDialog extends UIDialog { private static final String UPDATE_CACHE_STATE_FAIL = "fail"; private static final String UPDATE_CACHE_STATE_SUCCESS = "success"; + private static final String HYPHEN = "-"; + private final SimpleDateFormat CHANGELOG_FORMAT = new SimpleDateFormat("M/d/y, h:m:s a", Locale.ENGLISH); private final SimpleDateFormat UPDATE_INFO_TABLE_FORMAT = new SimpleDateFormat("yyyy.MM.dd"); @@ -303,8 +306,9 @@ public class UpdateMainDialog extends UIDialog { new UILabel(UpdateConstants.DEFAULT_APP_NAME + StringUtils.BLANK + ProductConstants.VERSION) ); - - jarCurrentLabel = new UILabel(StringUtils.isEmpty(GeneralUtils.readBuildNO()) ? com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Updater_Not_Install_Version") : GeneralUtils.readBuildNO(), SwingConstants.CENTER); + String notInstallVersion = InterProviderFactory.getProvider().getLocText("Fine-Core_Basic_About_No_Build"); + String versionBuildNo = GeneralUtils.getVersion() + HYPHEN + GeneralUtils.readBuildNO(); + jarCurrentLabel = new UILabel(ComparatorUtils.equals(notInstallVersion, GeneralUtils.readBuildNO()) ? notInstallVersion : versionBuildNo, SwingConstants.CENTER); UILabel noJarPreviousRevision = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Updater_No_Previous_Version")); UpdateActionLabel jarRestorePreviousRevision = new UpdateActionLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Updater_Restore"), false); jarRestorePreviousRevision.setForeground(new Color(RESTORE_LABEL_COLOR)); diff --git a/designer-base/src/main/java/com/fr/env/CheckServiceDialog.java b/designer-base/src/main/java/com/fr/env/CheckServiceDialog.java index 9134d6429..efee9bfdf 100644 --- a/designer-base/src/main/java/com/fr/env/CheckServiceDialog.java +++ b/designer-base/src/main/java/com/fr/env/CheckServiceDialog.java @@ -59,10 +59,13 @@ public class CheckServiceDialog extends JDialog implements ActionListener { label.setPreferredSize(new Dimension(650,30)); String text = Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Local_Designer") + localBranch - + Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Remote_Server") + remoteBranch; + + Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Remote_Server") + + Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Branch_Is_Old") + + localBranch; String delimiter = DisplayUtils.getDisplayLength(text) > 70? "
":"/"; JLabel label2 = new JLabel(""+Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Local_Designer") - + localBranch + delimiter + Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Remote_Server") + remoteBranch+""); + + localBranch + delimiter + Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Remote_Server") + + Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Branch_Is_Old")+ localBranch +""); label2.setPreferredSize(new Dimension(600,30)); JTextPane tipsPane = new JTextPane(); diff --git a/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java b/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java index 3c481ba30..37c4cd41a 100644 --- a/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java +++ b/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java @@ -44,6 +44,7 @@ import java.awt.event.MouseEvent; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.io.File; +import java.util.function.Supplier; import static com.fr.design.layout.TableLayout.FILL; import static com.fr.design.layout.TableLayout.PREFERRED; @@ -439,20 +440,29 @@ public class RemoteEnvPane extends BasicBeanPane { * 设置 app 和 servlet 默认值 */ private void setDefaultAppAndServlet() { - String appName; - String servletName; - try { - appName = FRContext.getCommonOperator().getAppName(); - } catch (Exception ignored) { - appName = RemoteWorkspaceURL.DEFAULT_WEB_APP_NAME; - } - try { - servletName = ServerConfig.getInstance().getServletName(); - } catch (Exception ignored) { - servletName = RemoteWorkspaceURL.DEFAULT_SERVLET_NAME; - } - webAppNameInput.setText(appName); - servletNameInput.setText(servletName); + setWrap(webAppNameInput, () -> FRContext.getCommonOperator().getAppName(), RemoteWorkspaceURL.DEFAULT_WEB_APP_NAME); + setWrap(servletNameInput, () -> ServerConfig.getInstance().getServletName(), RemoteWorkspaceURL.DEFAULT_SERVLET_NAME); + } + + private void setWrap(final UITextField textField, final Supplier supplier, final String defaultName) { + new SwingWorker() { + + @Override + protected String doInBackground() throws Exception { + return supplier.get(); + } + + @Override + protected void done() { + String name = defaultName; + try { + name = get(); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage() , e); + } + textField.setText(name); + } + }.execute(); } diff --git a/designer-base/src/main/java/com/fr/start/BaseDesigner.java b/designer-base/src/main/java/com/fr/start/BaseDesigner.java index 1469dd32e..7808bd7ec 100644 --- a/designer-base/src/main/java/com/fr/start/BaseDesigner.java +++ b/designer-base/src/main/java/com/fr/start/BaseDesigner.java @@ -64,14 +64,11 @@ public abstract class BaseDesigner extends ToolBarMenuDock { @Override public void on(Event event, Null param) { EventDispatcher.stopListen(this); - UIUtil.invokeLaterIfNeeded(new Runnable() { - @Override - public void run() { + UIUtil.invokeLaterIfNeeded(() -> { - // 打开上次的文件 - showDesignerFrame(false); - DesignerLaunchStatus.setStatus(DesignerLaunchStatus.OPEN_LAST_FILE_COMPLETE); - } + // 打开上次的文件 + showDesignerFrame(false); + DesignerLaunchStatus.setStatus(DesignerLaunchStatus.OPEN_LAST_FILE_COMPLETE); }); } }); @@ -90,12 +87,7 @@ public abstract class BaseDesigner extends ToolBarMenuDock { } public void show() { - UIUtil.invokeLaterIfNeeded(new Runnable() { - @Override - public void run() { - refreshTemplateTree(); - } - }); + UIUtil.invokeLaterIfNeeded(this::refreshTemplateTree); } private void refreshTemplateTree() { diff --git a/designer-base/src/test/java/com/fr/design/mainframe/JFormSliderPaneTest.java b/designer-base/src/test/java/com/fr/design/mainframe/JFormSliderPaneTest.java index 59da9fc1f..697bc8938 100644 --- a/designer-base/src/test/java/com/fr/design/mainframe/JFormSliderPaneTest.java +++ b/designer-base/src/test/java/com/fr/design/mainframe/JFormSliderPaneTest.java @@ -9,18 +9,6 @@ import org.junit.Test; */ public class JFormSliderPaneTest { - @Test - public void testParseInputValue() { - JFormSliderPane sliderPane = new JFormSliderPane(); - int result = Reflect.on(sliderPane).call("parseInputValue", "100%").get(); - Assert.assertEquals(100, result); - result = Reflect.on(sliderPane).call("parseInputValue", "50%").get(); - Assert.assertEquals(50, result); - result = Reflect.on(sliderPane).call("parseInputValue", "50").get(); - Assert.assertEquals(50, result); - result = Reflect.on(sliderPane).call("parseInputValue", "50abc").get(); - Assert.assertEquals(100, result); - } @Test public void testGetPreferredValue() { diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/SeriesTypeUseComboxPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/SeriesTypeUseComboxPane.java index 435e4c3e4..cf78e59ff 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/SeriesTypeUseComboxPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/SeriesTypeUseComboxPane.java @@ -100,24 +100,30 @@ public class SeriesTypeUseComboxPane extends BasicBeanPane { protected void initLayout() { this.setLayout(new BorderLayout(4, LayoutConstants.VGAP_MEDIUM)); JPanel northPane = new JPanel(new BorderLayout(4, 0)); - UILabel label1 = new UILabel(Toolkit.i18nText("Fine-Design_Chart_Series_Name_From")); - label1.setPreferredSize(new Dimension(ChartDataPane.LABEL_WIDTH, ChartDataPane.LABEL_HEIGHT)); - JPanel borderLayoutPane = GUICoreUtils.createBorderLayoutPane(new Component[]{content, null, null, label1, null}); + + //使用系列名/系列值选项面板 + UILabel seriesLabel = new UILabel(Toolkit.i18nText("Fine-Design_Chart_Series_Name_From")); + seriesLabel.setPreferredSize(new Dimension(ChartDataPane.LABEL_WIDTH, ChartDataPane.LABEL_HEIGHT)); + JPanel borderLayoutPane = GUICoreUtils.createBorderLayoutPane(new Component[]{content, null, null, seriesLabel, null}); northPane.add(borderLayoutPane); - northPane.setBorder(BorderFactory.createEmptyBorder(10, 24, 0, 15)); - cardPane.setBorder(BorderFactory.createEmptyBorder(0, 24, 0, 15)); + northPane.setBorder(BorderFactory.createEmptyBorder(10, 24, 0, 16)); this.add(northPane, BorderLayout.NORTH); + + //系列名/系列值配置面板 + cardPane.setBorder(BorderFactory.createEmptyBorder(0, 24, 0, 15)); this.add(cardPane, BorderLayout.CENTER); + + //数据筛选 dataScreeningPane = new ChartDataFilterPane(this.initplot, parent); JPanel panel = new UIExpandablePane(Toolkit.i18nText("Fine-Design_Chart_Data_Filter"), 250, 24, dataScreeningPane); - panel.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 15)); + panel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 15)); dataScreeningPane.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); this.add(panel, BorderLayout.SOUTH); } public Dimension getPreferredSize() { Dimension preferredSize = super.getPreferredSize(); - return new Dimension(260, (int) preferredSize.getHeight()); + return new Dimension(246, (int) preferredSize.getHeight()); } /** diff --git a/designer-chart/src/main/java/com/fr/van/chart/box/BoxIndependentVanChartInterface.java b/designer-chart/src/main/java/com/fr/van/chart/box/BoxIndependentVanChartInterface.java index e7981599f..ba7360a79 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/box/BoxIndependentVanChartInterface.java +++ b/designer-chart/src/main/java/com/fr/van/chart/box/BoxIndependentVanChartInterface.java @@ -13,8 +13,11 @@ import com.fr.design.mainframe.chart.gui.ChartStylePane; import com.fr.design.mainframe.chart.gui.data.report.AbstractReportDataContentPane; import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane; import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane; +import com.fr.plugin.chart.attr.plot.VanChartPlot; import com.fr.van.chart.box.data.report.BoxPlotReportDataContentPane; import com.fr.van.chart.box.data.table.BoxPlotTableDataContentPane; +import com.fr.van.chart.designer.other.AutoRefreshPane; +import com.fr.van.chart.designer.other.AutoRefreshPaneWithoutTooltip; import com.fr.van.chart.designer.other.VanChartInteractivePane; import com.fr.van.chart.designer.other.VanChartOtherPane; import com.fr.van.chart.designer.other.zoom.ZoomPane; @@ -79,6 +82,11 @@ public class BoxIndependentVanChartInterface extends AbstractIndependentVanChart }; } + protected AutoRefreshPane getMoreLabelPane(VanChartPlot plot) { + boolean isLargeModel = largeModel(plot); + return new AutoRefreshPaneWithoutTooltip(chart, isLargeModel); + } + protected double[] getToolBarRowSize() { double p = TableLayout.PREFERRED; return new double[]{p, p}; diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/other/VanChartInteractivePane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/other/VanChartInteractivePane.java index f402418d7..49ed07023 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/other/VanChartInteractivePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/other/VanChartInteractivePane.java @@ -22,6 +22,7 @@ import com.fr.plugin.chart.attr.plot.VanChartPlot; import com.fr.plugin.chart.attr.plot.VanChartRectanglePlot; import com.fr.plugin.chart.axis.type.AxisPlotType; import com.fr.plugin.chart.base.AttrEffect; +import com.fr.plugin.chart.base.AttrFloatColor; import com.fr.plugin.chart.base.AttrLabel; import com.fr.plugin.chart.base.RefreshMoreLabel; import com.fr.plugin.chart.base.VanChartAttrMarker; @@ -434,6 +435,7 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane { conditionAttr.remove(ScatterAttrLabel.class); conditionAttr.remove(AttrEffect.class); conditionAttr.remove(AttrLineEffect.class); + conditionAttr.remove(AttrFloatColor.class); VanChartAttrMarker attrMarker = conditionAttr.getExisted(VanChartAttrMarker.class); if (attrMarker != null && !attrMarker.isCommon()) { diff --git a/designer-chart/src/main/java/com/fr/van/chart/heatmap/designer/style/VanChartHeatMapSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/heatmap/designer/style/VanChartHeatMapSeriesPane.java index 6e4309a87..1e06db777 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/heatmap/designer/style/VanChartHeatMapSeriesPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/heatmap/designer/style/VanChartHeatMapSeriesPane.java @@ -111,7 +111,7 @@ public class VanChartHeatMapSeriesPane extends VanChartMapSeriesPane { double[] col = {f}; Component[][] components = new Component[][]{ - new Component[]{getVanChartFillStylePane()}, + new Component[]{getVanChartValueColorPane()}, }; JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(components, row, col); diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/VanChartMapSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/VanChartMapSeriesPane.java index ccc2e012e..925cb96c8 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/VanChartMapSeriesPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/VanChartMapSeriesPane.java @@ -38,6 +38,7 @@ import com.fr.van.chart.map.line.VanChartCurvePane; import com.fr.van.chart.map.line.VanChartLineMapEffectPane; import javax.swing.BorderFactory; +import javax.swing.DefaultComboBoxModel; import javax.swing.JPanel; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; @@ -60,6 +61,9 @@ public class VanChartMapSeriesPane extends VanChartColorValueSeriesPane { private static final String[] MARKER_TYPES = new String[]{MapMarkerType.DEFAULT.toLocalString(), MapMarkerType.COMMON.toLocalString(), MapMarkerType.BUBBLE.toLocalString(), MapMarkerType.IMAGE.toLocalString()}; + private static final String[] LARGE_MARKER_TYPES = new String[]{MapMarkerType.DEFAULT.toLocalString(), + MapMarkerType.COMMON.toLocalString(), MapMarkerType.BUBBLE.toLocalString()}; + //custom private UIButtonGroup areaPointAndLineGroup; @@ -145,8 +149,18 @@ public class VanChartMapSeriesPane extends VanChartColorValueSeriesPane { } private void checkPointCompsEnabledWithLarge(Plot plot) { + boolean largeModel = largeModel(plot); if (pointEffectPane != null) { - GUICoreUtils.setEnabled(pointEffectPane, !largeModel(plot)); + GUICoreUtils.setEnabled(pointEffectPane, !largeModel); + } + if (markerTypeCom != null) { + Object selectedItem = markerTypeCom.getSelectedItem(); + markerTypeCom.setModel(new DefaultComboBoxModel(largeModel ? LARGE_MARKER_TYPES : MARKER_TYPES)); + if (ComparatorUtils.equals(MapMarkerType.IMAGE.toLocalString(), selectedItem) && largeModel) { + markerTypeCom.setSelectedItem(MapMarkerType.COMMON.toLocalString()); + }else{ + markerTypeCom.setSelectedItem(selectedItem); + } } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/other/condition/pane/VanChartBubblePointMapConditionPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/other/condition/pane/VanChartBubblePointMapConditionPane.java index d1e8adfac..3037e1d10 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/designer/other/condition/pane/VanChartBubblePointMapConditionPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/other/condition/pane/VanChartBubblePointMapConditionPane.java @@ -3,8 +3,10 @@ package com.fr.van.chart.map.designer.other.condition.pane; import com.fr.chart.chartattr.Plot; import com.fr.plugin.chart.attr.EffectHelper; import com.fr.plugin.chart.base.AttrEffect; +import com.fr.plugin.chart.base.AttrFloatColor; import com.fr.plugin.chart.bubble.attr.VanChartAttrBubble; import com.fr.van.chart.designer.other.condition.item.VanChartEffectConditionPane; +import com.fr.van.chart.designer.other.condition.item.VanChartFloatColorConditionPane; import com.fr.van.chart.map.designer.other.condition.item.VanChartBubbleMarkerConditionPane; /** @@ -21,6 +23,7 @@ public class VanChartBubblePointMapConditionPane extends VanChartMapConditionPan classPaneMap.put(VanChartAttrBubble.class, new VanChartBubbleMarkerConditionPane(this)); if (addLabelOrEffectAction()) { addLabelAction(); + classPaneMap.put(AttrFloatColor.class, new VanChartFloatColorConditionPane(this)); classPaneMap.put(AttrEffect.class, new VanChartEffectConditionPane(this, EffectHelper.getBubblePlotDefaultEffect())); } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/other/condition/pane/VanChartCommonPointMapConditionPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/other/condition/pane/VanChartCommonPointMapConditionPane.java index 79fc51294..3987e2b5d 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/designer/other/condition/pane/VanChartCommonPointMapConditionPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/other/condition/pane/VanChartCommonPointMapConditionPane.java @@ -3,8 +3,10 @@ package com.fr.van.chart.map.designer.other.condition.pane; import com.fr.chart.chartattr.Plot; import com.fr.plugin.chart.attr.EffectHelper; import com.fr.plugin.chart.base.AttrEffect; +import com.fr.plugin.chart.base.AttrFloatColor; import com.fr.plugin.chart.base.VanChartAttrMarker; import com.fr.van.chart.designer.other.condition.item.VanChartEffectConditionPane; +import com.fr.van.chart.designer.other.condition.item.VanChartFloatColorConditionPane; import com.fr.van.chart.map.designer.other.condition.item.VanChartCommonMarkerConditionPane; /** @@ -21,6 +23,7 @@ public class VanChartCommonPointMapConditionPane extends VanChartMapConditionPan classPaneMap.put(VanChartAttrMarker.class, new VanChartCommonMarkerConditionPane(this)); if(addLabelOrEffectAction()) { addLabelAction(); + classPaneMap.put(AttrFloatColor.class, new VanChartFloatColorConditionPane(this)); classPaneMap.put(AttrEffect.class, new VanChartEffectConditionPane(this, EffectHelper.getScatterPlotDefaultEffect())); } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/other/condition/pane/VanChartDefaultPointMapConditionPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/other/condition/pane/VanChartDefaultPointMapConditionPane.java index d453f9017..511c513cc 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/designer/other/condition/pane/VanChartDefaultPointMapConditionPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/other/condition/pane/VanChartDefaultPointMapConditionPane.java @@ -3,7 +3,9 @@ package com.fr.van.chart.map.designer.other.condition.pane; import com.fr.chart.chartattr.Plot; import com.fr.plugin.chart.attr.EffectHelper; import com.fr.plugin.chart.base.AttrEffect; +import com.fr.plugin.chart.base.AttrFloatColor; import com.fr.van.chart.designer.other.condition.item.VanChartEffectConditionPane; +import com.fr.van.chart.designer.other.condition.item.VanChartFloatColorConditionPane; /** * Created by Mitisky on 16/5/23. @@ -17,6 +19,7 @@ public class VanChartDefaultPointMapConditionPane extends VanChartMapConditionPa protected void addDiffAction() { if(addLabelOrEffectAction()) { addLabelAction(); + classPaneMap.put(AttrFloatColor.class, new VanChartFloatColorConditionPane(this)); classPaneMap.put(AttrEffect.class, new VanChartEffectConditionPane(this, EffectHelper.getPointMapPlotDefaultEffect())); } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/other/condition/pane/VanChartImagePointMapConditionPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/other/condition/pane/VanChartImagePointMapConditionPane.java index b92f340c2..463563dd1 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/designer/other/condition/pane/VanChartImagePointMapConditionPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/other/condition/pane/VanChartImagePointMapConditionPane.java @@ -1,7 +1,9 @@ package com.fr.van.chart.map.designer.other.condition.pane; import com.fr.chart.chartattr.Plot; +import com.fr.plugin.chart.base.AttrFloatColor; import com.fr.plugin.chart.base.VanChartAttrMarker; +import com.fr.van.chart.designer.other.condition.item.VanChartFloatColorConditionPane; import com.fr.van.chart.map.designer.other.condition.item.VanChartImageMarkerConditionPane; /** @@ -18,6 +20,7 @@ public class VanChartImagePointMapConditionPane extends VanChartMapConditionPane classPaneMap.put(VanChartAttrMarker.class, new VanChartImageMarkerConditionPane(this)); if (addLabelOrEffectAction()) { addLabelAction(); + classPaneMap.put(AttrFloatColor.class, new VanChartFloatColorConditionPane(this)); } } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/other/condition/pane/VanChartLineMapConditionPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/other/condition/pane/VanChartLineMapConditionPane.java index 89bc16b7e..a45d9dc82 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/designer/other/condition/pane/VanChartLineMapConditionPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/other/condition/pane/VanChartLineMapConditionPane.java @@ -43,13 +43,13 @@ public class VanChartLineMapConditionPane extends DataSeriesConditionPane { @Override protected void addBasicAction() { classPaneMap.put(AttrBackground.class, new VanChartSeriesColorConditionPane(this)); - classPaneMap.put(AttrFloatColor.class, new VanChartFloatColorConditionPane(this)); classPaneMap.put(AttrCurve.class, new VanChartCurveConditionPane(this)); classPaneMap.put(AttrTooltip.class, new VanChartLineMapTooltipConditionPane(this, plot)); //大数据模式 恢复用注释。下面1行删除。 if (!PlotFactory.lineMapLargeModel(plot)) { //大数据模式 恢复用注释。取消注释。 //if (!PlotFactory.largeDataModel(plot)) { + classPaneMap.put(AttrFloatColor.class, new VanChartFloatColorConditionPane(this)); classPaneMap.put(AttrLineEffect.class, new VanChartLineEffectConditionPane(this, EffectHelper.getLineMapDefaultLineEffect())); } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/other/condition/pane/VanChartMapConditionPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/other/condition/pane/VanChartMapConditionPane.java index c94651173..576b4fba0 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/designer/other/condition/pane/VanChartMapConditionPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/other/condition/pane/VanChartMapConditionPane.java @@ -49,11 +49,11 @@ public class VanChartMapConditionPane extends DataSeriesConditionPane { classPaneMap.put(AttrBackground.class, new VanChartSeriesColorConditionPane(this)); classPaneMap.put(AttrAlpha.class, new LabelAlphaPane(this)); classPaneMap.put(AttrTooltip.class, new VanChartTooltipConditionPane(this, plot)); - classPaneMap.put(AttrFloatColor.class, new VanChartFloatColorConditionPane(this)); addDiffAction(); } protected void addDiffAction() { + classPaneMap.put(AttrFloatColor.class, new VanChartFloatColorConditionPane(this)); classPaneMap.put(AttrBorderWithAlpha.class, new VanChartBorderWithAlphaConditionPane(this)); classPaneMap.put(AttrEffect.class, new VanChartEffectConditionPane(this, EffectHelper.getMapPlotDefaultEffect())); addLabelAction(); diff --git a/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/data/StructurePlotReportDataContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/data/StructurePlotReportDataContentPane.java index dfb1a820b..1e26e2f55 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/data/StructurePlotReportDataContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/data/StructurePlotReportDataContentPane.java @@ -5,10 +5,10 @@ import com.fr.chart.chartattr.ChartCollection; import com.fr.design.formula.TinyFormulaPane; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itextfield.UITextField; +import com.fr.design.i18n.Toolkit; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.chart.gui.data.report.AbstractReportDataContentPane; - import com.fr.plugin.chart.structure.data.StructureReportDefinition; import javax.swing.BorderFactory; @@ -40,11 +40,11 @@ public class StructurePlotReportDataContentPane extends AbstractReportDataConten nodeValue = new TinyFormulaPane(); Component[][] components = new Component[][]{ - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Node_Name")), nodeName}, - new Component[]{new UILabel("id"), nodeID}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Parent_ID")), parentID}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_MultiPie_Series_Name")), seriesName}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Series_Value")), nodeValue}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Node_Name")), nodeName}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Node_Id")), nodeID}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Parent_Node_Id")), parentID}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_MultiPie_Series_Name")), seriesName}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Series_Value")), nodeValue}, }; JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components,rowSize,columnSize,24,6); diff --git a/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/data/StructurePlotTableDataContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/data/StructurePlotTableDataContentPane.java index bc1f7f73b..f91f6641e 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/data/StructurePlotTableDataContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/data/StructurePlotTableDataContentPane.java @@ -6,19 +6,19 @@ import com.fr.data.util.function.AbstractDataFunction; import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itextfield.UITextField; +import com.fr.design.i18n.Toolkit; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.chart.gui.data.CalculateComboBox; import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane; - import com.fr.plugin.chart.structure.data.StructureTableDefinition; import javax.swing.BorderFactory; import javax.swing.JPanel; +import java.util.List; import java.awt.BorderLayout; import java.awt.Component; import java.awt.Dimension; -import java.util.List; /** * Created by shine on 2017/2/15. @@ -45,12 +45,12 @@ public class StructurePlotTableDataContentPane extends AbstractTableDataContentP calculateCombox = new CalculateComboBox(); Component[][] components = new Component[][]{ - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Node_Name")), nodeName}, - new Component[]{new UILabel("id"), nodeId}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Parent_ID")), parenrId}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_MultiPie_Series_Name")), seriesName}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Series_Value")), nodeValue}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Summary_Method")), calculateCombox} + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Node_Name")), nodeName}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Node_Id")), nodeId}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Parent_Node_Id")), parenrId}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_MultiPie_Series_Name")), seriesName}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Series_Value")), nodeValue}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Summary_Method")), calculateCombox} }; JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components,rowSize,columnSize,24,6); diff --git a/designer-chart/src/main/resources/com/fr/design/images/form/toolbar/box.png b/designer-chart/src/main/resources/com/fr/design/images/form/toolbar/box.png old mode 100755 new mode 100644 index ba9101b2d..3b823ea73 Binary files a/designer-chart/src/main/resources/com/fr/design/images/form/toolbar/box.png and b/designer-chart/src/main/resources/com/fr/design/images/form/toolbar/box.png differ diff --git a/designer-chart/src/main/resources/com/fr/van/chart/box.images/box.png b/designer-chart/src/main/resources/com/fr/van/chart/box.images/box.png old mode 100755 new mode 100644 index 743024f72..e67baf4e8 Binary files a/designer-chart/src/main/resources/com/fr/van/chart/box.images/box.png and b/designer-chart/src/main/resources/com/fr/van/chart/box.images/box.png differ diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRBorderLayoutAdapter.java b/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRBorderLayoutAdapter.java index d1a5951cc..cbb8f018f 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRBorderLayoutAdapter.java +++ b/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRBorderLayoutAdapter.java @@ -35,19 +35,18 @@ public class FRBorderLayoutAdapter extends AbstractLayoutAdapter { * @param creator 组件 */ public void fix(XCreator creator) { - FRBorderLayout layout = (FRBorderLayout) container.getFRLayout(); + FRBorderLayout layout = (FRBorderLayout)container.getFRLayout(); Object constraints = layout.getConstraints(creator); - double scale = container.getScale(); if (ComparatorUtils.equals(constraints, BorderLayout.NORTH)) { - ((XWBorderLayout) container).toData().setNorthSize((int) (creator.getHeight() / scale)); + ((XWBorderLayout)container).toData().setNorthSize(creator.getHeight()); } else if (ComparatorUtils.equals(constraints, BorderLayout.SOUTH)) { - ((XWBorderLayout) container).toData().setSouthSize((int) (creator.getHeight() / scale)); + ((XWBorderLayout)container).toData().setSouthSize(creator.getHeight()); } else if (ComparatorUtils.equals(constraints, BorderLayout.EAST)) { - ((XWBorderLayout) container).toData().setEastSize((int) (creator.getWidth() / scale)); + ((XWBorderLayout)container).toData().setEastSize(creator.getWidth()); } else if (ComparatorUtils.equals(constraints, BorderLayout.WEST)) { - ((XWBorderLayout) container).toData().setWestSize((int) (creator.getWidth() / scale)); + ((XWBorderLayout)container).toData().setWestSize(creator.getWidth()); } else { - return; + return; } container.recalculateChildrenPreferredSize(); } @@ -59,7 +58,7 @@ public class FRBorderLayoutAdapter extends AbstractLayoutAdapter { * @param y 纵坐标 */ public void addComp(XCreator child, int x, int y) { - String placement = getPlacement(child, x, y); + String placement = getPlacement(child, x, y); container.add(child, placement); LayoutUtils.layoutRootContainer(container); } @@ -105,7 +104,7 @@ public class FRBorderLayoutAdapter extends AbstractLayoutAdapter { int northSize = wLayout.getNorthSize(); int southSize = wLayout.getSouthSize(); int eastSize = wLayout.getEastSize(); - int westSize = wLayout.getWestSize(); + int westSize = wLayout.getWestSize(); if (y < northSize) { return BorderLayout.NORTH; } else if ((y >= northSize) && (y < (height - southSize))) { diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/models/AddingModel.java b/designer-form/src/main/java/com/fr/design/designer/beans/models/AddingModel.java index fd98adc18..637279bf2 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/models/AddingModel.java +++ b/designer-form/src/main/java/com/fr/design/designer/beans/models/AddingModel.java @@ -17,14 +17,14 @@ import java.awt.Rectangle; * 添加状态下的model */ public class AddingModel { - + // 当前要添加的组件 private XCreator creator; // 记录当前鼠标的位置信息 private int currentX; private int currentY; private boolean added; - + public AddingModel(FormDesigner designer, XCreator xCreator) { this.creator = xCreator; instantiateCreator(designer); @@ -32,14 +32,14 @@ public class AddingModel { currentY = -this.creator.getWidth(); currentX = -this.creator.getHeight(); } - + /** * 待说明 * * @param designer 设计器 */ public void instantiateCreator(FormDesigner designer) { - + ModelUtil.renameWidgetName(designer.getTarget(), creator); ComponentAdapter adapter = new CompositeComponentAdapter(designer, creator); adapter.initialize(); @@ -55,7 +55,7 @@ public class AddingModel { currentX = x - (xCreator.getWidth() / 2); currentY = y - (xCreator.getHeight() / 2); } - + /** * 隐藏当前组件的图标 */ @@ -63,7 +63,7 @@ public class AddingModel { currentX = -this.creator.getWidth(); currentY = -this.creator.getHeight(); } - + public String getXCreatorName(FormDesigner designer, XCreator x) { String def = x.createDefaultName(); if (x.acceptType(XWParameterLayout.class)) { @@ -75,17 +75,17 @@ public class AddingModel { } return def + i; } - - + + public int getCurrentX() { return currentX; } - + public int getCurrentY() { return currentY; } - - + + /** * 移动组件图标到鼠标事件发生的位置 * @@ -101,6 +101,10 @@ public class AddingModel { return this.creator; } + public boolean need2paint(){ + return currentX + this.creator.getWidth() > 0 && currentY + this.creator.getHeight() > 0; + } + /** * 当前组件是否已经添加到某个容器中 * @@ -138,4 +142,4 @@ public class AddingModel { y + designer.getArea().getVerticalValue() - rect.y); return added; } -} \ No newline at end of file +} diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/models/SelectionModel.java b/designer-form/src/main/java/com/fr/design/designer/beans/models/SelectionModel.java index a930deb23..ff89f059b 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/models/SelectionModel.java +++ b/designer-form/src/main/java/com/fr/design/designer/beans/models/SelectionModel.java @@ -452,8 +452,8 @@ public class SelectionModel { } } if (hasSelectionComponent()) { - int x = e.getX() + designer.getArea().getHorizontalValue(); - int y = e.getY() + designer.getArea().getVerticalValue(); + int x = e.getX() + designer.getHorizontalScaleValue(); + int y = e.getY() + designer.getVerticalScaleValue(); dir = getDirection(selection.getRelativeBounds(), x, y); if (selection.size() == 1 && !ArrayUtils.contains(selection.getSelectedCreator().getDirections(), dir .getActual())) { diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XButton.java b/designer-form/src/main/java/com/fr/design/designer/creator/XButton.java index 9dc7b7de9..44996df8c 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XButton.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XButton.java @@ -147,7 +147,7 @@ public class XButton extends XWidgetCreator { public void propertyChange() { FreeButton button = (FreeButton) data; if (button.getFont() != null) { - setContentLabelFont(button.getFont().applyResolutionNP( + contentLabel.setFont(button.getFont().applyResolutionNP( FontTransformUtil.getDesignerFontResolution())); contentLabel.setForeground(button.getFont().getForeground()); } @@ -230,7 +230,7 @@ public class XButton extends XWidgetCreator { if (!button.isCustomStyle()) { l.setBorder(BorderFactory.createLineBorder(new Color(148, 148, 148))); bg = DEFAULTBG; - setContentLabelFont(DEFAULTFT); + contentLabel.setFont(DEFAULTFT); contentLabel.setForeground(DEFAULTFOREGROUNDCOLOR); editor.setLayout(new BorderLayout()); editor.add(l, BorderLayout.CENTER); @@ -239,7 +239,7 @@ public class XButton extends XWidgetCreator { editor.setLayout(new BorderLayout()); editor.add(l,BorderLayout.CENTER); if (button.getFont() != null) { - setContentLabelFont(button.getFont().applyResolutionNP( + contentLabel.setFont(button.getFont().applyResolutionNP( FontTransformUtil.getDesignerFontResolution())); contentLabel.setForeground(button.getFont().getForeground()); } @@ -302,26 +302,11 @@ public class XButton extends XWidgetCreator { setButtonText(button.getText()); checkButonType(); if (button.getFont() != null) { - setContentLabelFont(button.getFont().applyResolutionNP( + contentLabel.setFont(button.getFont().applyResolutionNP( FontTransformUtil.getDesignerFontResolution())); contentLabel.setForeground(button.getFont().getForeground()); } } - private void setContentLabelFont(Font font) { - float size = (float) (font.getSize() * getScale()); - contentLabel.setFont(font.deriveFont(size)); - } - - public void setScale(double scale){ - super.setScale(scale); - FreeButton button = (FreeButton) data; - if (button.getFont() != null) { - setContentLabelFont(button.getFont().applyResolutionNP( - FontTransformUtil.getDesignerFontResolution())); - }else { - setContentLabelFont(DEFAULTFT); - } - } } diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java b/designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java index 0df6abaf1..dcb693883 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java @@ -49,7 +49,6 @@ import java.util.Set; * */ public abstract class XCreator extends JPanel implements XComponent, XCreatorTools { - private double scale = 1.0; protected static final Border DEFALUTBORDER = BorderFactory.createLineBorder(new Color(210, 210, 210), 1); public static final Dimension SMALL_PREFERRED_SIZE = new Dimension(80, 21); @@ -103,14 +102,6 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo } } - public double getScale() { - return scale; - } - - public void setScale(double scale) { - this.scale = scale; - } - /** * 初始化组件大小 */ diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XLabel.java b/designer-form/src/main/java/com/fr/design/designer/creator/XLabel.java index 705ecae5c..df2252c7a 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XLabel.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XLabel.java @@ -17,7 +17,6 @@ import com.fr.design.mainframe.widget.renderer.LabelHorizontalAlignmentRenderer; import com.fr.form.ui.Label; import com.fr.form.ui.container.WParameterLayout; -import com.fr.general.FRFont; import com.fr.stable.ArrayUtils; import com.fr.stable.Constants; import com.fr.stable.core.PropertyChangeAdapter; @@ -95,11 +94,8 @@ public class XLabel extends XWidgetCreator { } if (label.getWidgetValue() != null) { Graphics2D g2d = (Graphics2D) g.create(); - FRFont font = label.getFont(); - float fontsize = (float) (font.getSize() * this.getScale()); BaseUtils.drawStringStyleInRotation(g2d, this.getWidth(), this.getHeight(), label.getWidgetValue() - .toString(), Style.getInstance(font.applySize(fontsize)) - .deriveHorizontalAlignment(label.getTextalign()) + .toString(), Style.getInstance(label.getFont()).deriveHorizontalAlignment(label.getTextalign()) .deriveVerticalAlignment(label.isVerticalCenter() ? SwingConstants.CENTER : SwingConstants.TOP) .deriveTextStyle(label.isWrap() ? Style.TEXTSTYLE_WRAPTEXT : Style.TEXTSTYLE_SINGLELINE), FontTransformUtil.getDesignerFontResolution()); diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XNameWidget.java b/designer-form/src/main/java/com/fr/design/designer/creator/XNameWidget.java index 267101787..0f78c5739 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XNameWidget.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XNameWidget.java @@ -68,9 +68,6 @@ public class XNameWidget extends XWidgetCreator { Widget widget; if (wc != null && (widget= wc.toWidget()) != null) { editor = XCreatorUtils.createXCreator(widget); - Widget currentWidget = toData(); - currentWidget.setVisible(widget.isVisible()); - currentWidget.setEnabled(widget.isEnabled()); this.setBorder(null); } else { this.setBorder(DEFALUTBORDER); diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XNumberEditor.java b/designer-form/src/main/java/com/fr/design/designer/creator/XNumberEditor.java index 7083f087a..15cd30c6f 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XNumberEditor.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XNumberEditor.java @@ -96,10 +96,10 @@ public class XNumberEditor extends XWrapperedFieldEditor { setBorder(FIELDBORDER); return this; } - + @Override protected String getIconName() { return "number_field_16.png"; } - + } diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XTextArea.java b/designer-form/src/main/java/com/fr/design/designer/creator/XTextArea.java index 62dc92a2d..845fe43d9 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XTextArea.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XTextArea.java @@ -59,10 +59,8 @@ public class XTextArea extends XFieldEditor { TextArea area = (TextArea) data; if (area.getWidgetValue() != null) { Graphics2D g2d = (Graphics2D) g.create(); - FRFont font = FRFont.getInstance(); - float fontsize = (float) (font.getSize() * this.getScale()); BaseUtils.drawStringStyleInRotation(g2d, this.getWidth(), this.getHeight(), area.getWidgetValue() - .toString(), Style.getInstance(font.applySize(fontsize)).deriveHorizontalAlignment(Constants.LEFT) + .toString(), Style.getInstance(FRFont.getInstance()).deriveHorizontalAlignment(Constants.LEFT) .deriveVerticalAlignment(SwingConstants.TOP) .deriveTextStyle(Style.TEXTSTYLE_WRAPTEXT), ScreenResolution.getScreenResolution()); } diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XTextEditor.java b/designer-form/src/main/java/com/fr/design/designer/creator/XTextEditor.java index 8106653e2..00daae7c7 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XTextEditor.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XTextEditor.java @@ -67,10 +67,8 @@ public class XTextEditor extends XWrapperedFieldEditor { TextEditor area = (TextEditor) data; if (area.getWidgetValue() != null) { Graphics2D g2d = (Graphics2D) g.create(); - FRFont font = FRFont.getInstance(); - float fontsize = (float) (font.getSize() * this.getScale()); BaseUtils.drawStringStyleInRotation(g2d, this.getWidth(), this.getHeight(), area.getWidgetValue() - .toString(), Style.getInstance(font.applySize(fontsize)).deriveHorizontalAlignment(Constants.LEFT) + .toString(), Style.getInstance(FRFont.getInstance()).deriveHorizontalAlignment(Constants.LEFT) .deriveTextStyle(Style.TEXTSTYLE_SINGLELINE), ScreenResolution.getScreenResolution()); } } diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteLayout.java b/designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteLayout.java index faf544f3b..7c852f282 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteLayout.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteLayout.java @@ -30,8 +30,6 @@ import com.fr.form.ui.Widget; import com.fr.form.ui.container.WAbsoluteLayout; import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget; import com.fr.form.ui.container.WLayout; -import com.fr.form.ui.container.WParameterLayout; -import com.fr.form.ui.widget.CRBoundsWidget; import com.fr.general.FRScreen; import com.fr.general.IOUtils; @@ -399,7 +397,6 @@ public class XWAbsoluteLayout extends XLayoutContainer { return; } XWidgetCreator creator = (XWidgetCreator) e.getChild(); - creator.setScale(this.getScale()); WAbsoluteLayout wabs = this.toData(); if (!creator.acceptType(XWFitLayout.class)) { creator.setDirections(Direction.ALL); @@ -605,17 +602,4 @@ public class XWAbsoluteLayout extends XLayoutContainer { return super.getWidgetPropertyUIProviders(); } } - - public void adjustCompSize(double percent) { - double p = percent + 1; - WAbsoluteLayout absoluteLayout = this.toData(); - for (int i = 0; i < this.getComponentCount(); i++) { - XCreator component = (XCreator) this.getComponent(i); - CRBoundsWidget boundsWidget = absoluteLayout.getBoundsWidget(component.toData()); - Rectangle rec = new Rectangle(boundsWidget.getBounds()); - component.adjustCompSize(percent); - component.setBounds((int) (rec.x * p), (int) (rec.y * p), (int) (rec.width * p), (int) (rec.height * p)); - } - } - } diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XWBorderLayout.java b/designer-form/src/main/java/com/fr/design/designer/creator/XWBorderLayout.java index c65421696..6d2003e21 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XWBorderLayout.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XWBorderLayout.java @@ -126,14 +126,14 @@ public class XWBorderLayout extends XLayoutContainer { WBorderLayout wlayout = this.toData(); Object constraints = wlayout.getConstraints(wgt); Dimension d = new Dimension(); - if (ComparatorUtils.equals(WBorderLayout.NORTH, constraints)) { - d.height = (int) (wlayout.getNorthSize() * getScale()); - } else if (ComparatorUtils.equals(WBorderLayout.SOUTH, constraints)) { - d.height = (int) (wlayout.getSouthSize() * getScale()); - } else if (ComparatorUtils.equals(WBorderLayout.EAST, constraints)) { - d.width = (int) (wlayout.getEastSize() * getScale()); - } else if (ComparatorUtils.equals(WBorderLayout.WEST, constraints)) { - d.width = (int) (wlayout.getWestSize() * getScale()); + if (ComparatorUtils.equals(WBorderLayout.NORTH,constraints)) { + d.height = wlayout.getNorthSize(); + } else if (ComparatorUtils.equals(WBorderLayout.SOUTH,constraints)) { + d.height = wlayout.getSouthSize(); + } else if (ComparatorUtils.equals(WBorderLayout.EAST,constraints)) { + d.width = wlayout.getEastSize(); + } else if (ComparatorUtils.equals(WBorderLayout.WEST,constraints)) { + d.width = wlayout.getWestSize(); } return d; } @@ -203,40 +203,8 @@ public class XWBorderLayout extends XLayoutContainer { } } - @Override - public LayoutAdapter getLayoutAdapter() { - return new FRBorderLayoutAdapter(this); - } - - - /** - * 自适应布局的缩放 - * - * @param percent 百分比 - */ - public void adjustCompSize(double percent) { - for (int i = 0; i < this.getComponentCount(); i++) { - XCreator creator = this.getXCreator(i); - WBorderLayout wlayout = this.toData(); - Object constraints = wlayout.getConstraints(creator.toData()); - if (ComparatorUtils.equals(BorderLayout.NORTH, constraints)) { - int northSize = (int) (this.toData().getNorthSize() * this.getScale()); - Dimension dim = creator.getSize(); - creator.setPreferredSize(new Dimension(dim.width, northSize)); - } else if (ComparatorUtils.equals(BorderLayout.SOUTH, constraints)) { - int southSize = (int) (this.toData().getSouthSize() * this.getScale()); - Dimension dim = creator.getSize(); - creator.setPreferredSize(new Dimension(dim.width, southSize)); - } else if (ComparatorUtils.equals(BorderLayout.EAST, constraints)) { - int eastSize = (int) (this.toData().getEastSize() * this.getScale()); - Dimension dim = creator.getSize(); - creator.setPreferredSize(new Dimension(eastSize, dim.height)); - } else if (ComparatorUtils.equals(BorderLayout.WEST, constraints)) { - int westSize = (int) (this.toData().getWestSize() * this.getScale()); - Dimension dim = creator.getSize(); - creator.setPreferredSize(new Dimension(westSize, dim.height)); - } - } - } + @Override + public LayoutAdapter getLayoutAdapter() { + return new FRBorderLayoutAdapter(this); + } } - diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XWFitLayout.java b/designer-form/src/main/java/com/fr/design/designer/creator/XWFitLayout.java index 3b671c217..06aca3c1b 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XWFitLayout.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XWFitLayout.java @@ -18,7 +18,6 @@ import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget; import com.fr.form.ui.container.WBodyLayoutType; import com.fr.form.ui.container.WFitLayout; import com.fr.form.ui.container.WLayout; -import com.fr.form.ui.widget.CRBoundsWidget; import com.fr.general.ComparatorUtils; import com.fr.general.FRLogger; import com.fr.general.FRScreen; @@ -131,7 +130,6 @@ public class XWFitLayout extends XLayoutContainer { } } - /** * 直接拖动滑条改变整体像素大小时,不用考虑控件的最小高度宽度,内部组件全部一起缩小放大 * 只是界面显示大小改变,不改变对应的BoundsWidget大小 @@ -140,28 +138,32 @@ public class XWFitLayout extends XLayoutContainer { public void adjustCreatorsWhileSlide(double percent) { int count = this.getComponentCount(); if (count == 0) { - Dimension size = new Dimension(this.toData().getContentWidth(), this.toData().getContentHeight()); - size.width += size.width * percent; - size.height += size.height * percent; + Dimension size = new Dimension(this.getSize()); + size.width += size.width*percent; + size.height += size.height*percent; this.setSize(size); return; } + // 初始化时还未加间隔 + if (hasCalGap) { + moveContainerMargin(); + moveCompInterval(backupGap); + LayoutUtils.layoutContainer(this); + } int containerW = 0; int containerH = 0; - int[] hors = getDataHors(); - int[] veris = getDataVeris(); - PaddingMargin margin = new PaddingMargin(); - for (int i = 0; i < count; i++) { + int[] hors = getHors(false); + int[] veris = getVeris(false); + PaddingMargin margin = toData().getMargin(); + for (int i=0; i posX = new ArrayList(); - // 保存实际大小时,组件大小已经去除内边距,此处也判断下 - posX.add(0); - int width = this.toData().getContainerWidth(); - posX.add(width); - for (int i = 0, len = this.toData().getWidgetCount(); i < len; i++) { - CRBoundsWidget widget = (CRBoundsWidget) this.toData().getWidget(i); - Rectangle rec = widget.getBounds(); - if (!posX.contains(rec.x)) { - posX.add(rec.x); - } - } - Collections.sort(posX); - return ArrayUtils.toPrimitive(posX.toArray(new Integer[]{posX.size()})); - } - - - public int[] getDataVeris() { - List posY = new ArrayList(); - // 保存实际大小时,组件大小已经去除内边距,此处也判断下 - posY.add(0); - int height = this.toData().getContainerHeight(); - posY.add(height); - for (int i = 0, len = this.toData().getWidgetCount(); i < len; i++) { - CRBoundsWidget boundsWidget = (CRBoundsWidget) this.toData().getWidget(i); - Rectangle rec = boundsWidget.getBounds(); - if (!posY.contains(rec.y)) { - posY.add(rec.y); - } - } - Collections.sort(posY); - return ArrayUtils.toPrimitive(posY.toArray(new Integer[]{posY.size()})); - } - /** * 获取内部组件纵坐标值 * @param isActualSize 实际大小 @@ -322,7 +291,6 @@ public class XWFitLayout extends XLayoutContainer { return ArrayUtils.toPrimitive(posY.toArray(new Integer[]{posY.size()})); } - /** * 是否能缩小 * @param percent 百分比 @@ -893,14 +861,12 @@ public class XWFitLayout extends XLayoutContainer { } super.add(comp, constraints); XCreator creator = (XCreator) comp; - creator.setScale(this.getScale()); dealDirections(creator, false); } private void add(Component comp, Object constraints, boolean isInit) { super.add(comp, constraints); XCreator creator = (XCreator) comp; - creator.setScale(this.getScale()); dealDirections(creator, isInit); } @@ -1371,14 +1337,4 @@ public class XWFitLayout extends XLayoutContainer { } } } - - /** - * 自适应布局的缩放 - * - * @param percent 百分比 - */ - @Override - public void adjustCompSize(double percent) { - this.adjustCreatorsWhileSlide(percent); - } } diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XCardAddButton.java b/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XCardAddButton.java index 7f43c57df..6909207c3 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XCardAddButton.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XCardAddButton.java @@ -25,18 +25,18 @@ import java.awt.Graphics2D; import java.awt.event.MouseEvent; public class XCardAddButton extends XButton { - + private XWCardTagLayout tagLayout; private XWCardLayout cardLayout; - + private static final int DEFAULT_BUTTON_WIDTH = 80; private static final int ICON_OFFSET = 8; - + private static Icon ADD_ICON = BaseUtils.readIcon("/com/fr/design/form/images/add.png"); private Icon addIcon = ADD_ICON; - + /** * card布局添加card按钮 */ @@ -65,7 +65,7 @@ public class XCardAddButton extends XButton { public XCardAddButton(CardAddButton widget, Dimension initSize) { super(widget, initSize); } - + /** * 构造函数 * @param widget 按钮 @@ -76,18 +76,18 @@ public class XCardAddButton extends XButton { this.tagLayout = fit; this.cardLayout = cardLayout; } - + /** * 响应点击事件 * @param editingMouseListener 事件处理器 * @param e 点击事件 - * + * */ @Override public void respondClick(EditingMouseListener editingMouseListener, MouseEvent e){ FormDesigner designer = editingMouseListener.getDesigner(); designer.fireTargetModified(); - + // addbutton对应的XWCardLayout和XWCardTagLayout暂未存入到xml中,重新打开之后先根据父子层获取 if(cardLayout == null && tagLayout ==null ){ initRelateLayout(); @@ -96,17 +96,17 @@ public class XCardAddButton extends XButton { throw new IllegalArgumentException("cardLayout can not be null"); } int index = cardLayout.toData().getWidgetCount(); - + //添加新的tab,并将原来的设为未选中状态 setTabUnselected(); addTab(index); this.tagLayout.adjustComponentWidth(); - + if (editingMouseListener.stopEditing()) { ComponentAdapter adapter = AdapterBus.getComponentAdapter(designer, this); editingMouseListener.startEditing(this, adapter.getDesignerEditor(), adapter); } - + FormHierarchyTreePane.getInstance().refreshRoot(); //将焦点切换到新增的tab对应的tabfitLayout上 showNewTab(editingMouseListener,index); @@ -118,28 +118,28 @@ public class XCardAddButton extends XButton { public UIPopupMenu createPopupMenu(FormDesigner formDesigner) { return UIPopupMenu.EMPTY; // 不要菜单 } - + private void initRelateLayout(){ XWCardTitleLayout titleLayout = (XWCardTitleLayout)this.getBackupParent(); this.tagLayout = titleLayout.getTagPart(); - + XWCardMainBorderLayout borderLayout = (XWCardMainBorderLayout)titleLayout.getBackupParent(); this.cardLayout = borderLayout.getCardPart(); } - + @Override public void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2d = (Graphics2D) g; drawAddIcon(g2d); } - + private void drawAddIcon(Graphics2D g2d){ int width = this.getWidth(); int height = this.getHeight(); addIcon.paintIcon(this, g2d, width / 2 - ICON_OFFSET, height / 2 - ICON_OFFSET); } - + //将原来的tab页设置为未选中状态 private void setTabUnselected(){ for(int i=0;i width, Map height) { diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWTabFitLayout.java b/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWTabFitLayout.java index e87e30b5f..8d5d232fa 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWTabFitLayout.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWTabFitLayout.java @@ -8,11 +8,15 @@ import com.fr.design.designer.creator.CRPropertyDescriptor; import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XLayoutContainer; import com.fr.design.designer.creator.XWFitLayout; +import com.fr.design.designer.properties.mobile.MobileBooKMarkUsePropertyUI; +import com.fr.design.designer.properties.mobile.MobileBookMarkPropertyUI; +import com.fr.design.form.util.FormDesignerUtils; import com.fr.design.form.util.XCreatorConstants; import com.fr.design.fun.WidgetPropertyUIProvider; import com.fr.design.gui.imenu.UIPopupMenu; import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.FormHierarchyTreePane; +import com.fr.design.mainframe.WidgetPropertyPane; import com.fr.design.mainframe.widget.editors.ButtonTypeEditor; import com.fr.design.mainframe.widget.editors.ImgBackgroundEditor; import com.fr.design.utils.gui.LayoutUtils; @@ -357,7 +361,14 @@ public class XWTabFitLayout extends XWFitLayout { return parent == null ? null : parent.findNearestFit(); } - + /** + * 非顶层自适应布局的缩放 + * @param percent 百分比 + */ + @Override + public void adjustCompSize(double percent) { + this.adjustCreatorsWhileSlide(percent); + } /** * 该布局需要隐藏,无需对边框进行操作 diff --git a/designer-form/src/main/java/com/fr/design/form/layout/FRFitLayout.java b/designer-form/src/main/java/com/fr/design/form/layout/FRFitLayout.java index c3d22d045..1594940b9 100644 --- a/designer-form/src/main/java/com/fr/design/form/layout/FRFitLayout.java +++ b/designer-form/src/main/java/com/fr/design/form/layout/FRFitLayout.java @@ -11,7 +11,7 @@ import java.awt.Rectangle; import com.fr.form.ui.container.WLayout; public class FRFitLayout implements FRLayoutManager, LayoutManager{ - + private int interval; // 上次的布局内边距 private Insets lastInset; @@ -19,11 +19,11 @@ public class FRFitLayout implements FRLayoutManager, LayoutManager{ public FRFitLayout() { this(0); } - + public FRFitLayout(int interval) { this.interval = interval; } - + public void setInterVal(int val) { this.interval = val; } @@ -35,7 +35,7 @@ public class FRFitLayout implements FRLayoutManager, LayoutManager{ */ @Override public void addLayoutComponent(String name, Component comp) { - + } /** @@ -44,7 +44,7 @@ public class FRFitLayout implements FRLayoutManager, LayoutManager{ */ @Override public void removeLayoutComponent(Component comp) { - + } /** @@ -104,7 +104,7 @@ public class FRFitLayout implements FRLayoutManager, LayoutManager{ } } } - + private void calculateLastInset(Container target, int width, int height) { int len = target.getComponentCount(); if (len ==0) { @@ -122,11 +122,11 @@ public class FRFitLayout implements FRLayoutManager, LayoutManager{ lastInset.bottom = Math.min(height-rec.y-rec.height, lastInset.bottom); } } - + private boolean insetNotChange(Insets inset, Insets last) { return inset.left == last.left && inset.right == last.right && inset.top == last.top && inset.bottom == last.bottom; } - + /** * 是否重置大小 * @return 是 @@ -136,4 +136,4 @@ public class FRFitLayout implements FRLayoutManager, LayoutManager{ return true; } -} \ No newline at end of file +} diff --git a/designer-form/src/main/java/com/fr/design/form/layout/FRTitleLayout.java b/designer-form/src/main/java/com/fr/design/form/layout/FRTitleLayout.java index 0ba996258..3f0d2826f 100644 --- a/designer-form/src/main/java/com/fr/design/form/layout/FRTitleLayout.java +++ b/designer-form/src/main/java/com/fr/design/form/layout/FRTitleLayout.java @@ -1,5 +1,5 @@ /** - * + * */ package com.fr.design.form.layout; @@ -14,29 +14,29 @@ import com.fr.general.ComparatorUtils; /** * 布局管理器,主要为一些需要加标题的组件用,如报表块、图表块 - * + * * @author jim * @date 2014-9-25 */ public class FRTitleLayout implements FRLayoutManager, LayoutManager{ - + public static final String TITLE = "Title"; - + public static final String BODY = "Body"; - + // 标题控件,默认为文本框 private Component title; // 主体控件,有表单报表块、图表块 private Component body; private int gap; - + /** * 构造函数 */ public FRTitleLayout() { this(0); } - + /** * 标题和主体间隙gap的布局 * @param gap 间隙值 @@ -44,7 +44,7 @@ public class FRTitleLayout implements FRLayoutManager, LayoutManager{ public FRTitleLayout(int gap) { this.gap = gap; } - + /** * 返回 * Returns the gap between components. @@ -61,7 +61,7 @@ public class FRTitleLayout implements FRLayoutManager, LayoutManager{ public void setGap(int gap) { this.gap = gap; } - + /** * 增加组件 * @param name 名字 @@ -76,7 +76,7 @@ public class FRTitleLayout implements FRLayoutManager, LayoutManager{ body = comp; } else if (ComparatorUtils.equals(name, TITLE)) { title = comp; - } + } } } @@ -89,7 +89,7 @@ public class FRTitleLayout implements FRLayoutManager, LayoutManager{ synchronized (comp.getTreeLock()) { if (comp == title) { title = null; - } + } } } @@ -137,7 +137,7 @@ public class FRTitleLayout implements FRLayoutManager, LayoutManager{ } } } - + public Object getConstraints(Component comp) { if (comp == null){ return null; @@ -146,7 +146,7 @@ public class FRTitleLayout implements FRLayoutManager, LayoutManager{ return TITLE; } else if (comp == body) { return BODY; - } + } return null; } @@ -159,4 +159,4 @@ public class FRTitleLayout implements FRLayoutManager, LayoutManager{ return false; } -} \ No newline at end of file +} diff --git a/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java b/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java index 07cb7f93a..d325e56e4 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java @@ -139,6 +139,9 @@ public class EditingMouseListener extends MouseInputAdapter { * @param e 鼠标事件 */ public void mousePressed(MouseEvent e) { + int oldX = e.getX(); + int oldY = e.getY(); + offsetEventPoint(e); if (!stopEditing()) { return; } @@ -171,6 +174,13 @@ public class EditingMouseListener extends MouseInputAdapter { stateModel.startResizing(e); } } + e.translatePoint(oldX - e.getX(), oldY - e.getY()); + } + + private void offsetEventPoint(MouseEvent e){ + int x = designer.getRelativeX(e.getX()); + int y = designer.getRelativeY(e.getY()); + e.translatePoint(x - e.getX(), y - e.getY()); } /** @@ -179,6 +189,9 @@ public class EditingMouseListener extends MouseInputAdapter { * @param e 鼠标事件 */ public void mouseReleased(MouseEvent e) { + int oldX = e.getX(); + int oldY = e.getY(); + offsetEventPoint(e); if (e.isPopupTrigger()) { if (stateModel.isDragging()) { stateModel.draggingCancel(); @@ -199,6 +212,7 @@ public class EditingMouseListener extends MouseInputAdapter { } lastPressEvent = null; lastXCreator = null; + e.translatePoint(oldX - e.getX(), oldY - e.getY()); } private void mouseDraggingRelease(MouseEvent e) { @@ -261,6 +275,9 @@ public class EditingMouseListener extends MouseInputAdapter { * @param e 鼠标事件 */ public void mouseMoved(MouseEvent e) { + int oldX = e.getX(); + int oldY = e.getY(); + offsetEventPoint(e); XCreator component = designer.getComponentAt(e); setCoverPaneNotDisplay(component, e, false); @@ -299,8 +316,9 @@ public class EditingMouseListener extends MouseInputAdapter { } processChartEditorMouseMove(component, e); - + e.translatePoint(oldX - e.getX(), oldY - e.getY()); designer.repaint(); + } private void elementCaseMouseMoved(MouseEvent e, XCreator component) { @@ -436,6 +454,9 @@ public class EditingMouseListener extends MouseInputAdapter { * @param e 鼠标事件 */ public void mouseDragged(MouseEvent e) { + int oldX = e.getX(); + int oldY = e.getY(); + offsetEventPoint(e); if (DesignerMode.isAuthorityEditing()) { return; } @@ -485,6 +506,7 @@ public class EditingMouseListener extends MouseInputAdapter { lastPressEvent = null; } } + e.translatePoint(oldX - e.getX(), oldY - e.getY()); designer.repaint(); } @@ -556,6 +578,9 @@ public class EditingMouseListener extends MouseInputAdapter { * @param e 鼠标事件 */ public void mouseClicked(MouseEvent e) { + int oldX = e.getX(); + int oldY = e.getY(); + offsetEventPoint(e); XCreator creator = designer.getComponentAt(e); boolean isValidButton = e.getButton() == MouseEvent.BUTTON1 || e.getButton() == MouseEvent.BUTTON3; @@ -575,6 +600,7 @@ public class EditingMouseListener extends MouseInputAdapter { } creator.doLayout(); } + e.translatePoint(oldX - e.getX(), oldY - e.getY()); LayoutUtils.layoutRootContainer(designer.getRootComponent()); } @@ -585,10 +611,14 @@ public class EditingMouseListener extends MouseInputAdapter { * @param e 鼠标事件 */ public void mouseExited(MouseEvent e) { + int oldX = e.getX(); + int oldY = e.getY(); + offsetEventPoint(e); if (designer.getCursor().getType() != Cursor.DEFAULT_CURSOR && !(e.isShiftDown() || InputEventBaseOnOS.isControlDown(e))) { designer.setCursor(Cursor.getDefaultCursor()); } cancelPromptWidgetForbidEnter(); + e.translatePoint(oldX - e.getX(), oldY - e.getY()); } /** diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormArea.java b/designer-form/src/main/java/com/fr/design/mainframe/FormArea.java index 2974f1ae9..05edb3192 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormArea.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormArea.java @@ -2,6 +2,7 @@ package com.fr.design.mainframe; import com.fr.base.ScreenResolution; import com.fr.common.inputevent.InputEventBaseOnOS; +import com.fr.design.designer.beans.events.DesignerEditListener; import com.fr.design.designer.beans.events.DesignerEvent; import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XLayoutContainer; @@ -46,6 +47,7 @@ import java.awt.event.ActionListener; import java.awt.event.FocusAdapter; import java.awt.event.FocusEvent; import java.awt.event.KeyEvent; +import java.awt.event.MouseEvent; import java.awt.event.MouseWheelEvent; import java.awt.event.MouseWheelListener; @@ -75,6 +77,8 @@ public class FormArea extends JComponent implements ScrollRulerComponent { private UINumberField heightPane; private JFormSliderPane slidePane; private boolean isValid = true; + // 初始时滑块值为100,托动后的值设为START_VALUE; + private double START_VALUE = DEFAULT_SLIDER; private int resolution = ScreenResolution.getScreenResolution(); private double screenValue; @@ -115,7 +119,6 @@ public class FormArea extends JComponent implements ScrollRulerComponent { this.setFocusTraversalKeysEnabled(false); this.addMouseWheelListener(showValSpinnerMouseWheelListener); registerShortCutKey(); - } /** @@ -173,14 +176,14 @@ public class FormArea extends JComponent implements ScrollRulerComponent { double[] rowSize = {f}; double[] columnSize = {p, f, p, p, p, p, p, f, p}; UILabel tipsPane = new UILabel("form"); - tipsPane.setPreferredSize(new Dimension(375, 0)); + tipsPane.setPreferredSize(new Dimension(265, 0)); widthPane = new UINumberField(); widthPane.setPreferredSize(new Dimension(60, 0)); heightPane = new UINumberField(); heightPane.setPreferredSize(new Dimension(60, 0)); slidePane = JFormSliderPane.getInstance(); - slidePane.setPreferredSize(new Dimension(375, 20)); + slidePane.setPreferredSize(new Dimension(326, 20)); JPanel resizePane = TableLayoutHelper.createCommonTableLayoutPane( new JComponent[][]{{tipsPane, new UILabel(), widthPane, @@ -198,6 +201,7 @@ public class FormArea extends JComponent implements ScrollRulerComponent { slidePane.addValueChangeListener(showValSpinnerChangeListener); } + private void setWidgetsConfig() { widthPane.setHorizontalAlignment(widthPane.CENTER); heightPane.setHorizontalAlignment(heightPane.CENTER); @@ -218,19 +222,16 @@ public class FormArea extends JComponent implements ScrollRulerComponent { value = value > SHOWVALMAX ? SHOWVALMAX : value; value = value < SHOWVALMIN ? SHOWVALMIN : value; scale((int) value); - JTemplate form = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); - if (form != null) { - form.fireTargetModified(); - } } }; private void scale(int value){ - this.designer.setResolution(value); - this.designer.getArea().resolution = value; - reCalculateRoot(value, true); + this.designer.setScale(value / DEFAULT_SLIDER); + FormArea.this.validate(); + this.designer.repaint(); } + /** * 返回当前的屏幕分辨率对应的百分比值 * @@ -255,6 +256,7 @@ public class FormArea extends JComponent implements ScrollRulerComponent { this.screenValue = FRScreen.getDesignScreenByDimension(scrnsize).getValue(); XLayoutContainer root = FormArea.this.designer.getRootComponent(); // 7.1.1不放缩放滑块,但表单大小仍按屏幕分辨率调整 +// slidePane.populateBean(screenValue); if (root.acceptType(XWFitLayout.class)) { XWFitLayout layout = (XWFitLayout) root; if ( !AssistUtils.equals(screenValue, DEFAULT_SLIDER) ) { @@ -262,7 +264,7 @@ public class FormArea extends JComponent implements ScrollRulerComponent { } else { // 组件间隔啊 // REPORT-2585 原有的逻辑导致嵌套的tab中的间隔加不上去,会在后续拖动的过程中出问题 - reCalculateDefaultRoot(); + reCalculateDefaultRoot(screenValue, true); } } LayoutUtils.layoutContainer(root); @@ -382,14 +384,16 @@ public class FormArea extends JComponent implements ScrollRulerComponent { * 修改大小后,再根据屏幕分辨率调整下 */ private void doReCalculateRoot(int width, int height, XWFitLayout layout) { +// double value = slidePane.updateBean(); //重置滑块的值为默认值100 + START_VALUE = DEFAULT_SLIDER; if ( AssistUtils.equals(screenValue, DEFAULT_SLIDER) ) { layout.getParent().setSize(width, height + designer.getParaHeight()); + FormArea.this.validate(); } else { layout.setBackupGap(screenValue / DEFAULT_SLIDER); + reCalculateRoot(screenValue, false); } - reCalculateRoot(slidePane.getShowValue(), true); - } /** @@ -399,60 +403,71 @@ public class FormArea extends JComponent implements ScrollRulerComponent { * @param value */ private void reCalculateRoot(double value, boolean needCalculateParaHeight) { - double percent = (value - DEFAULT_SLIDER) / DEFAULT_SLIDER; - double scale = value / DEFAULT_SLIDER; + if ( AssistUtils.equals(value, START_VALUE) ) { + return; + } + double percent = (value - START_VALUE) / START_VALUE; XLayoutContainer root = FormArea.this.designer.getRootComponent(); if (root.acceptType(XWFitLayout.class)) { XWFitLayout layout = (XWFitLayout) root; - layout.setContainerPercent(scale); - layout.adjustCompSize(percent); + layout.setContainerPercent(value / DEFAULT_SLIDER); traverAndAdjust(layout, percent); + layout.adjustCreatorsWhileSlide(percent); + // 拖动滑块,先将内部组件百分比大小计算,再计算容器大小 + Dimension d = new Dimension(layout.getWidth(), layout.getHeight()); - XWBorderLayout parent = (XWBorderLayout) layout.getParent(); - root.setScale(scale); // 自适应布局的父层是border - if (parent != null) { - parent.setScale(scale); - int paraHeight = parent.toData().getNorthSize(); - XLayoutContainer paraComponent = designer.getParaComponent(); - if (needCalculateParaHeight && paraComponent != null) { - paraComponent.setScale(scale); - this.designer.setParaHeight(paraHeight); - paraComponent.setPreferredSize(new Dimension(d.width, this.designer.getParaHeight())); - paraComponent.adjustCompSize( percent); + if (layout.getParent() != null) { + int paraHeight = designer.getParaHeight(); + if (needCalculateParaHeight && paraHeight > 0) { + designer.setParaHeight(paraHeight); + XWBorderLayout parent = (XWBorderLayout) layout.getParent(); + parent.toData().setNorthSize(paraHeight); parent.removeAll(); - parent.add(paraComponent, WBorderLayout.NORTH); - parent.add(root, WBorderLayout.CENTER); - root.setBounds(0, this.designer.getParaHeight(), d.width, d.height); + parent.add(designer.getParaComponent(), WBorderLayout.NORTH); + parent.add(designer.getRootComponent(), WBorderLayout.CENTER); } - parent.setSize(d.width, d.height + this.designer.getParaHeight()); - + layout.getParent().setSize(d.width, d.height + paraHeight); // 调整自适应布局大小后,同步调整参数界面和border大小,此时刷新下formArea FormArea.this.validate(); - LayoutUtils.layoutRootContainer(designer.getRootComponent()); } + START_VALUE = value; } } /** * 按照界面大小的百分比值调整root大小 * + * @param needCalculateParaHeight 是否需要调整参数界面高度 + * @param value */ - private void reCalculateDefaultRoot() { + private void reCalculateDefaultRoot(double value, boolean needCalculateParaHeight) { XLayoutContainer root = FormArea.this.designer.getRootComponent(); if (root.acceptType(XWFitLayout.class)) { XWFitLayout layout = (XWFitLayout) root; - Dimension dimension = layout.getSize(); - double widthScale = 960D / dimension.width; - double heightScale = 960D / dimension.height; - final double scaleValue = Math.min(widthScale, heightScale); - int value = (int) (scaleValue * 100); - slidePane.setShowValue(value); - if (value == 100) { - return; + layout.setContainerPercent(1.0); + traverAndAdjust(layout, 0.0); + layout.adjustCreatorsWhileSlide(0.0); + + // 拖动滑块,先将内部组件百分比大小计算,再计算容器大小 + + Dimension d = new Dimension(layout.getWidth(), layout.getHeight()); + // 自适应布局的父层是border + if (layout.getParent() != null) { + int paraHeight = designer.getParaHeight(); + if (needCalculateParaHeight && paraHeight > 0) { + designer.setParaHeight(paraHeight); + XWBorderLayout parent = (XWBorderLayout) layout.getParent(); + parent.toData().setNorthSize(paraHeight); + parent.removeAll(); + parent.add(designer.getParaComponent(), WBorderLayout.NORTH); + parent.add(designer.getRootComponent(), WBorderLayout.CENTER); + } + layout.getParent().setSize(d.width, d.height + paraHeight); + // 调整自适应布局大小后,同步调整参数界面和border大小,此时刷新下formArea + FormArea.this.validate(); } - scale(value); } } @@ -462,7 +477,6 @@ public class FormArea extends JComponent implements ScrollRulerComponent { Object object = creator.getComponent(i); if (object instanceof XCreator) { XCreator temp = (XCreator) object; - temp.setScale(1 + percent); temp.adjustCompSize(percent); traverAndAdjust(temp, percent); } @@ -484,17 +498,17 @@ public class FormArea extends JComponent implements ScrollRulerComponent { * 鼠标滚轮事件 * 由于表单设计界面要求: 容器大小大于界面时,滚动条才可以拖动,所以不支持滚动无限往下滚 */ -// @Override -// protected void processMouseWheelEvent(java.awt.event.MouseWheelEvent evt) { -// int id = evt.getID(); -// switch (id) { -// case MouseEvent.MOUSE_WHEEL: { -// onMouseWheelScroll(evt); -// break; -// } -// default: -// } -// } + @Override + protected void processMouseWheelEvent(java.awt.event.MouseWheelEvent evt) { + int id = evt.getID(); + switch (id) { + case MouseEvent.MOUSE_WHEEL: { + onMouseWheelScroll(evt); + break; + } + default: + } + } private void onMouseWheelScroll(MouseWheelEvent evt) { int value = this.verScrollBar.getValue() + evt.getWheelRotation() * ROTATIONS; @@ -559,9 +573,9 @@ public class FormArea extends JComponent implements ScrollRulerComponent { layout(); if (isValid) { XLayoutContainer root = designer.getRootComponent(); - setScrollBarProperties(root.getWidth() - designer.getWidth(), horScrollBar, horizontalValue); + setScrollBarProperties((int) (root.getWidth()*designer.getScale() - designer.getWidth()), horScrollBar, horizontalValue); //计算滚动条值的时候应该算上参数面板的高度 - setScrollBarProperties(designer.getParaHeight() + root.getHeight() - designer.getHeight(), verScrollBar, verticalValue); + setScrollBarProperties((int) (designer.getParaHeight() + root.getHeight()*designer.getScale() - designer.getHeight()), verScrollBar, verticalValue); } } @@ -765,10 +779,14 @@ public class FormArea extends JComponent implements ScrollRulerComponent { layout.moveContainerMargin(); layout.addCompInterval(layout.getAcualInterval()); } else if (designer.getRootComponent().acceptType(XWFitLayout.class)) { - reCalculateRoot(slide, true); + START_VALUE = DEFAULT_SLIDER; + reCalculateRoot(screenValue, true); // slidePane.populateBean(slide); + } - } + this.slidePane.setShowValue((int) slide); + } + /** * 计算滚动条的值和max @@ -836,10 +854,8 @@ public class FormArea extends JComponent implements ScrollRulerComponent { if (hbarPreferredSize == null) { throw new IllegalArgumentException("hbarPreferredSize can not be null!"); } - int maxHeight = bottom - hbarPreferredSize.height - resize.height - TOPGAP * 2; - int maxWidth = right - vbarPreferredSize.width; - DESIGNERWIDTH = DESIGNERWIDTH > maxWidth ? maxWidth : DESIGNERWIDTH; - DESIGNERHEIGHT = DESIGNERHEIGHT > maxHeight ? maxHeight : DESIGNERHEIGHT; + DESIGNERHEIGHT = bottom - hbarPreferredSize.height - resize.height - TOPGAP * 2; + DESIGNERWIDTH = right - vbarPreferredSize.width; int designerLeft = left + (verScrollBar.getX() - DESIGNERWIDTH) / 2; int designerTop = top + (horScrollBar.getY() - DESIGNERHEIGHT) / 2; rec = new Rectangle(designerLeft, designerTop, DESIGNERWIDTH, DESIGNERHEIGHT); diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java b/designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java index e13748719..e35580b91 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java @@ -240,7 +240,7 @@ public class FormCreatorDropTarget extends DropTarget { @Override public synchronized void dragEnter(DropTargetDragEvent dtde) { Point loc = dtde.getLocation(); - this.entering(loc.x, loc.y); + this.entering(designer.getRelativeX(loc.x), designer.getRelativeY(loc.y)); } /** @@ -251,7 +251,7 @@ public class FormCreatorDropTarget extends DropTarget { @Override public synchronized void dragOver(DropTargetDragEvent dtde) { Point loc = dtde.getLocation(); - hovering(loc.x, loc.y); + hovering(designer.getRelativeX(loc.x), designer.getRelativeY(loc.y)); } /** @@ -282,7 +282,7 @@ public class FormCreatorDropTarget extends DropTarget { @Override public synchronized void drop(DropTargetDropEvent dtde) { Point loc = dtde.getLocation(); - this.adding(loc.x, loc.y); + this.adding(designer.getRelativeX(loc.x), designer.getRelativeY(loc.y)); //针对在表单中拖入一个控件直接ctrl+s无反应 designer.requestFocus(); } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java b/designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java index 851758803..b7d8a9a4c 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java @@ -103,6 +103,9 @@ public class FormDesigner extends TargetComponent
implements TreeSelection protected static final ArrayList NAME_ARRAY_LIST = new ArrayList( Arrays.asList(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_M_Edit_Cut"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_M_Edit_Copy"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_M_Edit_Delete")}) ); + + + private double scale = 1.0D; //底层容器的默认大小 protected static final Dimension LARGE_PREFERRED_SIZE = new Dimension(WBorderLayout.DEFAULT_WIDTH, WBorderLayout.DEFAULT_HEIGHT); private int paraHeight = 0; @@ -167,7 +170,6 @@ public class FormDesigner extends TargetComponent implements TreeSelection setFocusTraversalKeysEnabled(false); this.setOpaque(true); this.setBackground(Color.WHITE); - // 初始化 edit = new CreatorEventListenerTable(); selectionModel = new SelectionModel(this); @@ -185,6 +187,11 @@ public class FormDesigner extends TargetComponent implements TreeSelection populateParameterPropertyPane(); } + + public void paintBorder(Graphics g){ + //不绘制designer的边框 + } + /** * 刷新控件树面板 */ @@ -493,12 +500,12 @@ public class FormDesigner extends TargetComponent implements TreeSelection public void setParaHeight(int height) { XWBorderLayout container = (XWBorderLayout) getTopContainer(); container.toData().setNorthSize(height); - int displayHeight = (int) (height * container.getScale()); - container.setSize(container.getWidth(), container.getHeight() + displayHeight - getParaHeight()); - paraHeight = displayHeight; + container.setSize(container.getWidth(), container.getHeight() + height - getParaHeight()); + paraHeight = height; } + /** * 删除参数界面 */ @@ -986,8 +993,11 @@ public class FormDesigner extends TargetComponent implements TreeSelection @Nullable public XCreator getComponentAt(int x, int y, XCreator[] except) { - XLayoutContainer container = y < paraHeight - formArea.getVerticalValue() ? paraComponent : rootComponent; - XCreator comp = xCreatorAt(x + formArea.getHorizontalValue(), y + formArea.getVerticalValue(), container, + XLayoutContainer container = y + this.getPaintY() < paraHeight - formArea.getVerticalValue() ? paraComponent : rootComponent; + if (container == null) { + container = rootComponent; + } + XCreator comp = xCreatorAt(x + (int)(formArea.getHorizontalValue()/scale), (int)(y + formArea.getVerticalValue()/scale), container, except); return comp == null ? container : comp; } @@ -1550,4 +1560,49 @@ public class FormDesigner extends TargetComponent implements TreeSelection public int getResolution() { return this.resolution; } + + public double getScale() { + return scale; + } + + public void setScale(double scale) { + this.scale = scale; + } + + public int getPaintX() { + if (this.rootComponent == null || this.rootComponent.getParent() == null) { + return 0; + } + int width = this.rootComponent.getParent().getWidth(); + int x = (int) ((this.getWidth() - width * scale) / 2); + return Math.max(x, 0); + } + + public int getPaintY() { + if (this.rootComponent == null || this.rootComponent.getParent() == null) { + return 0; + } + int height = this.rootComponent.getParent().getHeight(); + int y = (int) ((this.getHeight() - height * scale) / 2); + return Math.max(y, 0); + } + + + public int getRelativeX(int x) { + return (int) ((x - this.getPaintX()) / this.getScale()); + } + + public int getRelativeY(int y) { + return (int) ((y - this.getPaintY()) / this.getScale()); + } + + + public int getHorizontalScaleValue() { + return (int) (this.getArea().getHorizontalValue() / this.scale); + } + + public int getVerticalScaleValue() { + return (int) (this.getArea().getVerticalValue() / this.scale); + } + } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java b/designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java index 7c2b67352..404a0fd13 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java @@ -30,6 +30,7 @@ import java.awt.Component; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Rectangle; +import java.awt.geom.AffineTransform; import java.awt.geom.Area; import java.awt.geom.Rectangle2D; import java.util.ArrayList; @@ -66,7 +67,14 @@ public class FormDesignerUI extends ComponentUI { @Override public void paint(final Graphics g, JComponent c) { XCreator rootComponent = designer.getRootComponent(); - this.time = (float)designer.getResolution()/ScreenResolution.getScreenResolution(); + this.time = (float) designer.getResolution() / ScreenResolution.getScreenResolution(); + AffineTransform at = new AffineTransform(); + if (rootComponent.getParent() != null) { + at.translate(designer.getPaintX(), designer.getPaintY()); + at.scale(designer.getScale(), designer.getScale()); + Graphics2D g2 = (Graphics2D) g; + g2.transform(at); + } if (rootComponent != null) { // 设计自适应界面 repaintFit(g, rootComponent, c); @@ -189,9 +197,13 @@ public class FormDesignerUI extends ComponentUI { * 渲染当前正在添加的组件,采用Renderer原理 */ private void paintAddingBean(Graphics g, final AddingModel addingModel) { + if (!addingModel.need2paint()) { + return; + } XCreator bean = addingModel.getXCreator(); int x = addingModel.getCurrentX(); int y = addingModel.getCurrentY(); + int width = bean.getWidth(); int height = bean.getHeight(); Graphics clipg = g.create(x, y, width, height); @@ -254,8 +266,8 @@ public class FormDesignerUI extends ComponentUI { return; } Rectangle bounds = designer.getTopContainer().getBounds(); - bounds.x = -designer.getArea().getHorizontalValue(); - bounds.y = -designer.getArea().getVerticalValue(); + bounds.x = -designer.getHorizontalScaleValue(); + bounds.y = -designer.getVerticalScaleValue(); Graphics clipg = g.create(); clipg.clipRect(bounds.x, bounds.y, bounds.width + 1, bounds.height + 1); paintResizing(clipg); @@ -277,8 +289,8 @@ public class FormDesignerUI extends ComponentUI { designer.getStateModel().paintAbsorptionline(g); } - bounds.x -= designer.getArea().getHorizontalValue(); - bounds.y -= designer.getArea().getVerticalValue(); + bounds.x -= designer.getHorizontalScaleValue(); + bounds.y -= designer.getVerticalScaleValue(); drawResizingThumbs(g, selectionModel.getSelection().getDirections(), bounds.x, bounds.y, bounds.width, bounds.height); //选中时边框颜色 @@ -286,8 +298,8 @@ public class FormDesignerUI extends ComponentUI { for (XCreator creator : selectionModel.getSelection().getSelectedCreators()) { Rectangle creatorBounds = ComponentUtils.getRelativeBounds(creator); - creatorBounds.x -= designer.getArea().getHorizontalValue(); - creatorBounds.y -= designer.getArea().getVerticalValue(); + creatorBounds.x -= designer.getHorizontalScaleValue(); + creatorBounds.y -= designer.getVerticalScaleValue(); if (creator.acceptType(XWFitLayout.class)) { resetFitlayoutBounds(creatorBounds); } else if (designer.getRootComponent().acceptType(XWFitLayout.class)) { @@ -395,17 +407,11 @@ public class FormDesignerUI extends ComponentUI { ComponentUtils.disableBuffer(component, dbcomponents); Graphics clipg; clipg = g.create( - -designer.getArea().getHorizontalValue(), - -designer.getArea().getVerticalValue() + designer.getParaHeight(), + -designer.getHorizontalScaleValue(), + -designer.getVerticalScaleValue() + designer.getParaHeight(), parent.getSize().width + designer.getArea().getHorizontalValue(), parent.getSize().height + designer.getArea().getVerticalValue()); -// BufferedImage img = CoreGraphHelper.createBufferedImage(parent.getSize().width + designer.getArea().getHorizontalValue(), parent.getSize().height + designer.getArea().getVerticalValue(), BufferedImage.TYPE_INT_RGB); -// Graphics2D g2d = img.createGraphics(); -// component.printAll(g2d); -// g2d.dispose(); -// g.drawImage(img,-designer.getArea().getHorizontalValue(),-designer.getArea().getVerticalValue() + designer.getParaHeight(), (int) (parent.getSize().width*time + designer.getArea().getHorizontalValue()), (int) (parent.getSize().height*time + designer.getArea().getVerticalValue()),null); - designer.paintContent(clipg); paintWatermark((Graphics2D) clipg); clipg.dispose(); @@ -427,8 +433,8 @@ public class FormDesignerUI extends ComponentUI { // 禁止双缓冲 ComponentUtils.disableBuffer(component, dbcomponents); Graphics clipg1; - clipg1 = g.create(-designer.getArea().getHorizontalValue(), - -designer.getArea().getVerticalValue() , + clipg1 = g.create(-designer.getHorizontalScaleValue(), + -designer.getVerticalScaleValue(), parent.getSize().width + designer.getArea().getHorizontalValue(), designer.getParaHeight() + designer.getArea().getVerticalValue()); diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormSelection.java b/designer-form/src/main/java/com/fr/design/mainframe/FormSelection.java index 8f95ecaf6..cbebbcba1 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormSelection.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormSelection.java @@ -15,8 +15,6 @@ import com.fr.design.designer.creator.cardlayout.XWTabFitLayout; import com.fr.design.utils.ComponentUtils; import com.fr.design.utils.gui.LayoutUtils; import com.fr.form.ui.Widget; -import com.fr.form.ui.container.WBorderLayout; -import com.fr.form.ui.container.WParameterLayout; import com.fr.log.FineLoggerFactory; import java.awt.LayoutManager; @@ -234,13 +232,12 @@ public class FormSelection { int size = selection.size(); if (size == 1) { XCreator creator = selection.get(0); - if (creator.acceptType(XWCardTagLayout.class)) { - creator = (XCreator) selection.get(0).getParent(); + if(creator.acceptType(XWCardTagLayout.class)){ + creator = (XCreator)selection.get(0).getParent(); } creator.setBounds(rec); if (creator.acceptType(XWParameterLayout.class)) { - double height = rec.getHeight() / creator.getScale(); - designer.setParaHeight((int) height); + designer.setParaHeight((int) rec.getHeight()); designer.getArea().doLayout(); } LayoutUtils.layoutContainer(creator); diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/component/WidgetAbsoluteBoundPane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/component/WidgetAbsoluteBoundPane.java index 80898f592..7ddff022f 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/component/WidgetAbsoluteBoundPane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/component/WidgetAbsoluteBoundPane.java @@ -8,7 +8,6 @@ import com.fr.design.mainframe.WidgetPropertyPane; import com.fr.design.utils.gui.LayoutUtils; import com.fr.design.widget.WidgetBoundsPaneFactory; import com.fr.form.ui.container.WLayout; -import com.fr.form.ui.widget.CRBoundsWidget; import java.awt.Rectangle; @@ -43,13 +42,15 @@ public class WidgetAbsoluteBoundPane extends WidgetBoundPane { FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner(); formDesigner.getSelectionModel().getSelection().backupBounds(); super.update(); - Rectangle bounds = new Rectangle((int) x.getValue(), (int) y.getValue(), (int) width.getValue(), (int) height.getValue()); + Rectangle bounds = new Rectangle(creator.getBounds()); + bounds.x = (int) x.getValue(); + bounds.y = (int) y.getValue(); if (parent == null) { return; } WLayout wabs = parent.toData(); wabs.setBounds(creator.toData(), bounds); - parent.adjustCompSize(parent.getScale() -1); + creator.setBounds(bounds); LayoutUtils.layoutContainer(creator); XWAbsoluteLayout layout = (XWAbsoluteLayout) parent; layout.updateBoundsWidget(creator); @@ -58,13 +59,14 @@ public class WidgetAbsoluteBoundPane extends WidgetBoundPane { @Override public void limitWidth(WLayout wabs, int w, Rectangle bounds, Rectangle rec){ bounds.width = w; + creator.setBounds(bounds); } @Override public void limitHeight(WLayout wabs, int h, Rectangle bounds, Rectangle rec){ bounds.height = h; + creator.setBounds(bounds); } - @Override protected String title4PopupWindow() { return "absoluteBound"; @@ -73,12 +75,7 @@ public class WidgetAbsoluteBoundPane extends WidgetBoundPane { @Override public void populate() { super.populate(); - WLayout wabs = parent.toData(); - CRBoundsWidget boundsWidget = wabs.getBoundsWidget(creator.toData()); - if (boundsWidget == null){ - return; - } - Rectangle bounds = boundsWidget.getBounds(); + Rectangle bounds = new Rectangle(creator.getBounds()); x.setValue(bounds.x); y.setValue(bounds.y); } diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/component/WidgetBoundPane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/component/WidgetBoundPane.java index d76c2f891..ab148f2ae 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/component/WidgetBoundPane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/component/WidgetBoundPane.java @@ -20,8 +20,9 @@ import com.fr.design.widget.WidgetBoundsPaneFactory; import com.fr.form.ui.PaddingMargin; import com.fr.form.ui.container.WFitLayout; import com.fr.form.ui.container.WLayout; -import com.fr.form.ui.widget.CRBoundsWidget; + +import javax.swing.JOptionPane; import java.awt.Rectangle; @@ -45,8 +46,8 @@ public class WidgetBoundPane extends BasicPane { } public XLayoutContainer getParent(XCreator source) { - if (source.acceptType(XWCardTagLayout.class)) { - return (XLayoutContainer) source.getParent(); + if(source.acceptType(XWCardTagLayout.class)){ + return (XLayoutContainer)source.getParent(); } XLayoutContainer container = XCreatorUtils.getParentXLayoutContainer(source); if (source.acceptType(XWFitLayout.class) || source.acceptType(XWParameterLayout.class)) { @@ -78,24 +79,18 @@ public class WidgetBoundPane extends BasicPane { } public void populate() { - WLayout wabs = parent.toData(); - CRBoundsWidget boundsWidget = wabs.getBoundsWidget(creator.toData()); - if (boundsWidget == null){ - return; - } - Rectangle bounds = new Rectangle(boundsWidget.getBounds()); + Rectangle bounds = new Rectangle(creator.getBounds()); width.setValue(bounds.width); height.setValue(bounds.height); } public void fix() { - WLayout wabs = parent.toData(); - CRBoundsWidget boundsWidget = wabs.getBoundsWidget(creator.toData()); - Rectangle bounds = new Rectangle(boundsWidget.getBounds()); + Rectangle bounds = new Rectangle(creator.getBounds()); creator.setBackupBound(creator.getBounds()); int w = (int) width.getValue(); int h = (int) height.getValue(); Rectangle rec = ComponentUtils.getRelativeBounds(parent); + WLayout wabs = parent.toData(); if (bounds.width != w) { limitWidth(wabs, w, bounds, rec); } @@ -106,27 +101,25 @@ public class WidgetBoundPane extends BasicPane { public void adjustComponents(Rectangle bounds, int difference, int row) { - double scale = parent.getScale(); FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner(); Rectangle backupBounds = getBound(); FRFitLayoutAdapter layoutAdapter = (FRFitLayoutAdapter) AdapterBus.searchLayoutAdapter(formDesigner, creator); if (layoutAdapter != null) { layoutAdapter.setEdit(true); - layoutAdapter.calculateBounds(backupBounds, new Rectangle((int) (bounds.x * scale), (int) (bounds.y * scale), (int) (bounds.width * scale), (int) (bounds.height * scale)), creator, row, difference); + layoutAdapter.calculateBounds(backupBounds, bounds, creator, row, difference); } } public void limitWidth(WLayout wabs, int w, Rectangle bounds, Rectangle rec) { int difference = 0; - double scale = parent.getScale(); int minWidth = (int) (MINWIDTH * ((WFitLayout) wabs).getResolutionScaling()); PaddingMargin margin = wabs.getMargin(); if (bounds.width != w) { - if ((int) (bounds.width * scale) == rec.width - margin.getLeft() - margin.getRight()) { + if (bounds.width == rec.width - margin.getLeft() - margin.getRight()) { FineJOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Beyond_Bounds")); width.setValue(bounds.width); return; - } else if (w * scale < minWidth) { + } else if (w < minWidth) { FineJOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Min_Width") + Integer.toString(minWidth)); width.setValue(bounds.width); return; @@ -139,16 +132,15 @@ public class WidgetBoundPane extends BasicPane { } public void limitHeight(WLayout wabs, int h, Rectangle bounds, Rectangle rec) { - double scale = parent.getScale(); int difference = 0; PaddingMargin margin = wabs.getMargin(); int minHeight = (int) (MINHEIGHT * ((WFitLayout) wabs).getResolutionScaling()); if (bounds.height != h) { - if ((int) (bounds.height * scale) == rec.height - margin.getTop() - margin.getBottom()) { + if (bounds.height == rec.height - margin.getTop() - margin.getBottom()) { FineJOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Beyond_Bounds")); height.setValue(bounds.height); return; - } else if (h * scale < minHeight) { + } else if (h < minHeight) { FineJOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Min_Height") + Integer.toString(minHeight)); height.setValue(bounds.height); return; diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/component/WidgetCardTagBoundPane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/component/WidgetCardTagBoundPane.java index e89fe0935..22d544c1a 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/component/WidgetCardTagBoundPane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/component/WidgetCardTagBoundPane.java @@ -10,9 +10,11 @@ import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.WidgetPropertyPane; import com.fr.design.widget.WidgetBoundsPaneFactory; import com.fr.form.ui.container.WTabDisplayPosition; -import com.fr.form.ui.container.cardlayout.WCardMainBorderLayout; import com.fr.form.ui.container.cardlayout.WCardTagLayout; import com.fr.general.ComparatorUtils; + + +import javax.swing.JOptionPane; import java.awt.Rectangle; /** @@ -37,7 +39,6 @@ public class WidgetCardTagBoundPane extends WidgetBoundPane { if (parent == null) { return; } - double scale = parent.getScale(); FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner(); Rectangle parentBounds = new Rectangle(parent.getBounds()); @@ -47,17 +48,17 @@ public class WidgetCardTagBoundPane extends WidgetBoundPane { XLayoutContainer tabLayout = creator.getTopLayout(); Rectangle rectangle = tabLayout.getBounds(); if(ComparatorUtils.equals(displayPosition, WTabDisplayPosition.TOP_POSITION) || ComparatorUtils.equals(displayPosition, WTabDisplayPosition.BOTTOM_POSITION)){ - if(rectangle.height < size* scale){ + if(rectangle.height < size){ FineJOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Beyond_Tablayout_Bounds")); return; } - parentBounds.height = (int) (size * scale); + parentBounds.height = size; }else{ - if(rectangle.width < size*scale){ + if(rectangle.width < size){ FineJOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Beyond_Tablayout_Bounds")); return; } - parentBounds.width = (int) (size * scale); + parentBounds.width = size; } parent.setBounds(parentBounds); @@ -75,8 +76,15 @@ public class WidgetCardTagBoundPane extends WidgetBoundPane { @Override public void populate() { - WCardMainBorderLayout wCardMainBorderLayout = (WCardMainBorderLayout)creator.getTopLayout().toData(); - cardTagWidth.setValue(wCardMainBorderLayout.getTitleSize()); + WCardTagLayout tagLayout = (WCardTagLayout)creator.toData(); + Rectangle bounds = new Rectangle(creator.getBounds()); + WTabDisplayPosition displayPosition = tagLayout.getDisplayPosition(); + if( ComparatorUtils.equals(displayPosition, WTabDisplayPosition.TOP_POSITION) || ComparatorUtils.equals(displayPosition, WTabDisplayPosition.BOTTOM_POSITION)){ + cardTagWidth.setValue(bounds.height); + }else{ + cardTagWidth.setValue(bounds.width); + } + } } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/ReportComponentComposite.java b/designer-realize/src/main/java/com/fr/design/mainframe/ReportComponentComposite.java index 0299899a0..4b74ab4dd 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/ReportComponentComposite.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/ReportComponentComposite.java @@ -7,7 +7,6 @@ import com.fr.design.event.RemoveListener; import com.fr.design.event.TargetModifiedListener; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.gui.icontainer.UIModeControlContainer; -import com.fr.design.gui.ispinner.UIBasicSpinner; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.grid.Grid; import com.fr.log.FineLoggerFactory; @@ -49,7 +48,7 @@ public class ReportComponentComposite extends JComponent implements RemoveListen private JPanel hbarContainer; - private JSliderPane jSliderContainer; + private JFormSliderPane jSliderContainer; /** * Constructor with workbook.. @@ -65,8 +64,7 @@ public class ReportComponentComposite extends JComponent implements RemoveListen CellElementRegion = FRGUIPaneFactory.createBorderLayout_S_Pane(); this.add(CellElementRegion, BorderLayout.NORTH); this.add(createSouthControlPane(), BorderLayout.SOUTH); - jSliderContainer.getShowVal().addChangeListener(showValSpinnerChangeListener); - jSliderContainer.getSelfAdaptButton().addItemListener(selfAdaptButtonItemListener); + jSliderContainer.addValueChangeListener(showValSpinnerChangeListener); } MouseWheelListener showValSpinnerMouseWheelListener = new MouseWheelListener() { @@ -74,8 +72,8 @@ public class ReportComponentComposite extends JComponent implements RemoveListen public void mouseWheelMoved(MouseWheelEvent e) { if (InputEventBaseOnOS.isControlDown(e)) { int dir = e.getWheelRotation(); - int old_resolution = (int) jSliderContainer.getShowVal().getValue(); - jSliderContainer.getShowVal().setValue(old_resolution - (dir * DIR)); + int old_resolution = jSliderContainer.getShowValue(); + jSliderContainer.setShowValue(old_resolution - (dir * DIR)); } } }; @@ -83,7 +81,7 @@ public class ReportComponentComposite extends JComponent implements RemoveListen ChangeListener showValSpinnerChangeListener = new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { - double value = (int) ((UIBasicSpinner) e.getSource()).getValue(); + double value = jSliderContainer.getShowValue(); value = value > MAX ? MAX : value; value = value < MIN ? MIN : value; int resolution = (int) (ScreenResolution.getScreenResolution() * value / HUND); @@ -91,15 +89,6 @@ public class ReportComponentComposite extends JComponent implements RemoveListen } }; - ItemListener selfAdaptButtonItemListener = new ItemListener() { - @Override - public void itemStateChanged(ItemEvent e) { - if (jSliderContainer.getSelfAdaptButton().isSelected()) { - int resolution = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().selfAdaptUpdate(); - jSliderContainer.getShowVal().setValue(resolution * HUND / ScreenResolution.getScreenResolution()); - } - } - }; protected void doBeforeChange(int oldIndex) { if (oldIndex >= 0) { @@ -130,8 +119,7 @@ public class ReportComponentComposite extends JComponent implements RemoveListen templateStateList.add(null); } centerCardPane.editingComponet.setSelection(centerCardPane.editingComponet.getDefaultSelectElement()); - jSliderContainer=JSliderPane.getInstance(); - jSliderContainer.reset(); + jSliderContainer = JFormSliderPane.getInstance(); } if (centerCardPane.editingComponet.elementCasePane == null) { @@ -173,7 +161,7 @@ public class ReportComponentComposite extends JComponent implements RemoveListen return sheetNameTab.getSelectedIndex(); } - public JSliderPane getjSliderContainer() { + public JFormSliderPane getjSliderContainer() { return this.jSliderContainer; } @@ -217,7 +205,7 @@ public class ReportComponentComposite extends JComponent implements RemoveListen hbarContainer = FRGUIPaneFactory.createBorderLayout_S_Pane(); hbarContainer.add(centerCardPane.editingComponet.getHorizontalScrollBar()); JPanel southPane = new JPanel(new BorderLayout()); - jSliderContainer = JSliderPane.getInstance(); + jSliderContainer = JFormSliderPane.getInstance(); southPane.add(hbarContainer, BorderLayout.NORTH); southPane.add(sheetNameTab, BorderLayout.CENTER); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/WorkSheetDesigner.java b/designer-realize/src/main/java/com/fr/design/mainframe/WorkSheetDesigner.java index 707169447..da7548013 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/WorkSheetDesigner.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/WorkSheetDesigner.java @@ -182,8 +182,8 @@ public class WorkSheetDesigner extends ReportComponent MAX ? MAX : value; value = value < MIN ? MIN : value; int resolution = (int) (ScreenResolution.getScreenResolution() * value / HUND); @@ -81,15 +80,7 @@ public class FormReportComponentComposite extends JComponent implements TargetMo } }; - ItemListener selfAdaptButtonItemListener = new ItemListener() { - @Override - public void itemStateChanged(ItemEvent e) { - if (jSliderContainer.getSelfAdaptButton().isSelected()) { - int resolution = selfAdaptUpdate(); - jSliderContainer.getShowVal().setValue(resolution * HUND / ScreenResolution.getScreenResolution()); - } - } - }; + private java.util.List targetModifiedList = new java.util.ArrayList(); @@ -169,7 +160,7 @@ public class FormReportComponentComposite extends JComponent implements TargetMo JPanel southPane = new JPanel(new BorderLayout()); hbarContainer = FRGUIPaneFactory.createBorderLayout_S_Pane(); hbarContainer.add(elementCaseDesigner.getHorizontalScrollBar()); - jSliderContainer = JSliderPane.getInstance(); + jSliderContainer = JFormSliderPane.getInstance(); southPane.add(hbarContainer, BorderLayout.NORTH); southPane.add(sheetNameTab, BorderLayout.CENTER); @@ -204,4 +195,4 @@ public class FormReportComponentComposite extends JComponent implements TargetMo } -} \ No newline at end of file +} diff --git a/designer-realize/src/main/java/com/fr/grid/GridColumn.java b/designer-realize/src/main/java/com/fr/grid/GridColumn.java index 910fac6ec..8ba6484bc 100644 --- a/designer-realize/src/main/java/com/fr/grid/GridColumn.java +++ b/designer-realize/src/main/java/com/fr/grid/GridColumn.java @@ -10,7 +10,6 @@ import com.fr.base.ScreenResolution; import com.fr.design.ExtraDesignClassManager; import com.fr.design.fun.GridUIProcessor; import com.fr.design.mainframe.ElementCasePane; -import com.fr.design.mainframe.JSliderPane; import com.fr.stable.StableUtils; import javax.swing.plaf.ComponentUI; @@ -75,4 +74,4 @@ public class GridColumn extends GridHeader { return new Dimension(super.getPreferredSize().width, (int) (GraphHelper.getFontMetrics(this.getFont()).getHeight() * time + SIZE_ADJUST)); } -} \ No newline at end of file +} diff --git a/designer-realize/src/main/java/com/fr/grid/GridMouseAdapter.java b/designer-realize/src/main/java/com/fr/grid/GridMouseAdapter.java index 86ed09161..b0f91a902 100644 --- a/designer-realize/src/main/java/com/fr/grid/GridMouseAdapter.java +++ b/designer-realize/src/main/java/com/fr/grid/GridMouseAdapter.java @@ -9,7 +9,6 @@ import com.fr.design.constants.UIConstants; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.EastRegionContainerPane; import com.fr.design.mainframe.ElementCasePane; -import com.fr.design.mainframe.JSliderPane; import com.fr.design.os.impl.PopupDialogSaveAction; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.grid.selection.CellSelection; @@ -74,7 +73,7 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous private int ECBlockGap = 40; - private int resolution = (int) (ScreenResolution.getScreenResolution() * JSliderPane.getInstance().resolutionTimes); + private int resolution = ScreenResolution.getScreenResolution(); protected GridMouseAdapter(Grid grid) { this.grid = grid; @@ -836,4 +835,4 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous */ public void mouseExited(MouseEvent e) { } -} \ No newline at end of file +} diff --git a/designer-realize/src/main/java/com/fr/grid/GridUtils.java b/designer-realize/src/main/java/com/fr/grid/GridUtils.java index 11e907fc6..80e6f3ff5 100644 --- a/designer-realize/src/main/java/com/fr/grid/GridUtils.java +++ b/designer-realize/src/main/java/com/fr/grid/GridUtils.java @@ -6,7 +6,6 @@ import com.fr.design.cell.clipboard.CellElementsClip; import com.fr.design.cell.clipboard.ElementsTransferable; import com.fr.design.cell.clipboard.FloatElementsClip; import com.fr.design.mainframe.ElementCasePane; -import com.fr.design.mainframe.JSliderPane; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.ComparatorUtils; import com.fr.grid.selection.CellSelection; @@ -125,8 +124,7 @@ public class GridUtils { */ public static double[] caculateFloatElementLocations(FloatElement floatElement, DynamicUnitList columnWidthList, DynamicUnitList rowHeightList, int verticalValue, int horizentalValue) { - int resolution = (int) (ScreenResolution.getScreenResolution() * JSliderPane.getInstance().resolutionTimes); - + int resolution = ScreenResolution.getScreenResolution(); double floatX = columnWidthList.getRangeValue(horizentalValue, 0).toPixD(resolution) + floatElement.getLeftDistance().toPixD(resolution); double floatY = rowHeightList.getRangeValue(verticalValue, 0).toPixD(resolution) + floatElement.getTopDistance().toPixD(resolution); @@ -179,7 +177,7 @@ public class GridUtils { private static int cc_selected_column_or_row(double mouseEvtPosition, int beginValue, int value, DynamicUnitList sizeList) { double tmpIntIndex = 0; int selectedCellIndex = 0; - int resolution = (int) (ScreenResolution.getScreenResolution() * JSliderPane.getInstance().resolutionTimes); + int resolution = ScreenResolution.getScreenResolution(); if (mouseEvtPosition < 0) { selectedCellIndex = value; for (; true; selectedCellIndex--) { @@ -487,4 +485,4 @@ public class GridUtils { } -} \ No newline at end of file +} diff --git a/designer-realize/src/main/java/com/fr/poly/PolyDesigner.java b/designer-realize/src/main/java/com/fr/poly/PolyDesigner.java index 8397db820..bffb625fe 100644 --- a/designer-realize/src/main/java/com/fr/poly/PolyDesigner.java +++ b/designer-realize/src/main/java/com/fr/poly/PolyDesigner.java @@ -25,7 +25,7 @@ import com.fr.design.mainframe.EastRegionContainerPane; import com.fr.design.mainframe.ElementCasePane; import com.fr.design.mainframe.ElementCasePaneAuthorityEditPane; import com.fr.design.mainframe.FormScrollBar; -import com.fr.design.mainframe.JSliderPane; +import com.fr.design.mainframe.JFormSliderPane; import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.NoSupportAuthorityEdit; import com.fr.design.mainframe.ReportComponent; @@ -124,8 +124,7 @@ public class PolyDesigner extends ReportComponent