Browse Source

REPORT-31758 决策报表设计面板允许进行缩放

feature/big-screen
kerry 4 years ago
parent
commit
707810a4f8
  1. 128
      designer-base/src/main/java/com/fr/design/mainframe/JFormSliderPane.java
  2. 516
      designer-base/src/main/java/com/fr/design/mainframe/JSliderPane.java
  3. 8
      designer-form/src/main/java/com/fr/design/designer/creator/XElementCase.java
  4. 8
      designer-form/src/main/java/com/fr/design/designer/creator/XNumberEditor.java
  5. 6
      designer-form/src/main/java/com/fr/design/designer/creator/XWFitLayout.java
  6. 41
      designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XCardAddButton.java
  7. 10
      designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardTagLayout.java
  8. 29
      designer-form/src/main/java/com/fr/design/form/layout/FRFitLayout.java
  9. 34
      designer-form/src/main/java/com/fr/design/form/layout/FRTitleLayout.java
  10. 36
      designer-form/src/main/java/com/fr/design/mainframe/FormArea.java
  11. 14
      designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java
  12. 33
      designer-form/src/main/java/com/fr/design/widget/ui/designer/component/WidgetBoundPane.java
  13. 28
      designer-realize/src/main/java/com/fr/design/mainframe/ReportComponentComposite.java
  14. 6
      designer-realize/src/main/java/com/fr/design/mainframe/WorkSheetDesigner.java
  15. 27
      designer-realize/src/main/java/com/fr/design/mainframe/form/FormReportComponentComposite.java
  16. 3
      designer-realize/src/main/java/com/fr/grid/GridColumn.java
  17. 5
      designer-realize/src/main/java/com/fr/grid/GridMouseAdapter.java
  18. 8
      designer-realize/src/main/java/com/fr/grid/GridUtils.java
  19. 11
      designer-realize/src/main/java/com/fr/poly/PolyDesigner.java

128
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.base.BaseUtils;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.islider.UISlider; 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 com.fr.design.utils.gui.GUICoreUtils;
import javax.swing.BorderFactory;
import javax.swing.JFrame; import javax.swing.JFrame;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener; import javax.swing.event.ChangeListener;
import javax.swing.text.AttributeSet; import javax.swing.plaf.basic.BasicSliderUI;
import javax.swing.text.BadLocationException;
import javax.swing.text.PlainDocument;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Color; import java.awt.Color;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.EventQueue; import java.awt.EventQueue;
import java.awt.FlowLayout; import java.awt.FlowLayout;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.Point; import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
import java.awt.event.KeyListener; import java.awt.event.KeyListener;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
@ -29,6 +36,7 @@ import java.math.BigDecimal;
* Created by MoMeak on 2017/7/13. * Created by MoMeak on 2017/7/13.
*/ */
public class JFormSliderPane extends JPanel { 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 double ONEPOINTEIGHT = 1.8;
private static final int SIX = 6; 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 HUNDRED = 100;
private static final int TWO_HUNDRED = 200; private static final int TWO_HUNDRED = 200;
private static final int FOUR_HUNDRED = 400; 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 int SHOWVALBUTTON_HEIGHTH = 20;
private static final String SUFFIX = "%"; private static final String SUFFIX = "%";
private static final String REGEX = "[\\d%]*";
private static final int TOOLTIP_Y = 30; private static final int TOOLTIP_Y = 30;
private static final Color BACK_COLOR = new Color(245, 245, 247); private static final Color BACK_COLOR = new Color(245, 245, 247);
public int showValue = 100; public int showValue = 100;
private UITextField showValField; private UINumberField showValField;
private UISlider slider; private UISlider slider;
private int times; private int times;
private int sliderValue; private int sliderValue;
@ -64,6 +71,9 @@ public class JFormSliderPane extends JPanel {
panel.add(slider); panel.add(slider);
panel.add(upButton); panel.add(upButton);
panel.add(showValField); panel.add(showValField);
UILabel uiLabel = new UILabel(SUFFIX);
uiLabel.setBorder(BorderFactory.createEmptyBorder(0, 4, 0, 4));
panel.add(uiLabel);
panel.setBackground(BACK_COLOR); panel.setBackground(BACK_COLOR);
this.add(panel, BorderLayout.NORTH); this.add(panel, BorderLayout.NORTH);
} }
@ -112,8 +122,8 @@ public class JFormSliderPane extends JPanel {
} }
private void initShowValField() { private void initShowValField() {
showValField = new UITextField(showValue + SUFFIX); showValField = new UINumberField();
showValField.setBorderPainted(false); showValField.setValue(showValue);
showValField.setPreferredSize(new Dimension(SHOWVALBUTTON_WIDTH, SHOWVALBUTTON_HEIGHTH)); showValField.setPreferredSize(new Dimension(SHOWVALBUTTON_WIDTH, SHOWVALBUTTON_HEIGHTH));
showValField.addKeyListener(new KeyListener() { showValField.addKeyListener(new KeyListener() {
@Override @Override
@ -131,27 +141,28 @@ public class JFormSliderPane extends JPanel {
int code = evt.getKeyCode(); int code = evt.getKeyCode();
if (code == KeyEvent.VK_ENTER) { if (code == KeyEvent.VK_ENTER) {
showValue = parseInputValue(showValField.getText()); showValFieldChange((int) showValField.getValue());
showValField.setText(showValue + SUFFIX);
showValFieldChange();
} }
} }
}); });
showValField.setDocument(new PlainDocument() { showValField.addFocusListener(new FocusListener() {
@Override @Override
public void insertString(int offset, String s, AttributeSet a) throws BadLocationException { public void focusGained(FocusEvent e) {
if (!s.matches(REGEX)) {
return;
}
super.insertString(offset, s, a);
} }
});
@Override
public void focusLost(FocusEvent e) {
showValFieldChange((int) showValField.getValue());
}
});
} }
private void showValFieldChange() {
private void showValFieldChange(int value) {
isButtonOrIsTxt = true; isButtonOrIsTxt = true;
showValue = getPreferredValue(showValue); showValue = getPreferredValue(value);
refreshShowValueFieldText(); refreshShowValueFieldText();
refreshSlider(); refreshSlider();
} }
@ -167,22 +178,10 @@ public class JFormSliderPane extends JPanel {
} }
private void refreshShowValueFieldText(){ private void refreshShowValueFieldText(){
showValField.setText(showValue + SUFFIX); showValField.setValue(showValue);
} setAdjustButtonStatus();
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;
}
} }
//定义一个监听器,用于监听所有滑动条 //定义一个监听器,用于监听所有滑动条
private ChangeListener listener = new ChangeListener() { private ChangeListener listener = new ChangeListener() {
public void stateChanged(ChangeEvent event) { public void stateChanged(ChangeEvent event) {
@ -207,6 +206,11 @@ public class JFormSliderPane extends JPanel {
slider.setValue(calSliderValue(showValue)); 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) { private int calSliderValue(int value) {
int result; int result;
if (value > HUNDRED) { if (value > HUNDRED) {
@ -245,7 +249,7 @@ public class JFormSliderPane extends JPanel {
if (newUpVal <= FOUR_HUNDRED) { if (newUpVal <= FOUR_HUNDRED) {
showValue = newUpVal; showValue = newUpVal;
} else { } else {
showValue = TEN; showValue = FOUR_HUNDRED;
} }
refreshShowValueFieldText(); refreshShowValueFieldText();
refreshSlider(); refreshSlider();
@ -271,8 +275,7 @@ public class JFormSliderPane extends JPanel {
} }
public void setShowValue(int value) { public void setShowValue(int value) {
showValue = value; showValFieldChange(value);
showValFieldChange();
} }
@ -280,6 +283,55 @@ public class JFormSliderPane extends JPanel {
this.slider.addChangeListener(changeListener); 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) { public static void main(String[] args) {
JFrame jf = new JFrame("test"); JFrame jf = new JFrame("test");

516
designer-base/src/main/java/com/fr/design/mainframe/JSliderPane.java

@ -1,516 +0,0 @@
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);
}
}

8
designer-form/src/main/java/com/fr/design/designer/creator/XElementCase.java

@ -311,6 +311,14 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme
return new Dimension(this.getWidth(), this.getHeight()); return new Dimension(this.getWidth(), this.getHeight());
} }
public void paint(Graphics g) {
BufferedImage image = toData().getECImage();
if (image != null) {
setLabelBackground(image.getScaledInstance(this.getWidth(), this.getHeight(), Image.SCALE_FAST), imageLable);
}
super.paint(g);
}
/** /**
* 响应点击事件 * 响应点击事件
* @param editingMouseListener 事件处理器 * @param editingMouseListener 事件处理器

8
designer-form/src/main/java/com/fr/design/designer/creator/XNumberEditor.java

@ -85,8 +85,10 @@ public class XNumberEditor extends XWrapperedFieldEditor {
NumberEditor editor = (NumberEditor) data; NumberEditor editor = (NumberEditor) data;
if (editor.getWidgetValue() != null) { if (editor.getWidgetValue() != null) {
Graphics2D g2d = (Graphics2D) g.create(); Graphics2D g2d = (Graphics2D) g.create();
FRFont font = FRFont.getInstance();
float fontsize = (float) (font.getSize() * this.getScale());
BaseUtils.drawStringStyleInRotation(g2d, this.getWidth(), this.getHeight(), editor.getWidgetValue() BaseUtils.drawStringStyleInRotation(g2d, this.getWidth(), this.getHeight(), editor.getWidgetValue()
.toString(), Style.getInstance(FRFont.getInstance()).deriveHorizontalAlignment(Constants.LEFT) .toString(), Style.getInstance(FRFont.getInstance().applySize(fontsize)).deriveHorizontalAlignment(Constants.LEFT)
.deriveTextStyle(Style.TEXTSTYLE_SINGLELINE), ScreenResolution.getScreenResolution()); .deriveTextStyle(Style.TEXTSTYLE_SINGLELINE), ScreenResolution.getScreenResolution());
} }
} }
@ -96,10 +98,10 @@ public class XNumberEditor extends XWrapperedFieldEditor {
setBorder(FIELDBORDER); setBorder(FIELDBORDER);
return this; return this;
} }
@Override @Override
protected String getIconName() { protected String getIconName() {
return "number_field_16.png"; return "number_field_16.png";
} }
} }

6
designer-form/src/main/java/com/fr/design/designer/creator/XWFitLayout.java

@ -1375,4 +1375,10 @@ public class XWFitLayout extends XLayoutContainer {
public void adjustCompSize(double percent) { public void adjustCompSize(double percent) {
this.adjustCreatorsWhileSlide(percent); this.adjustCreatorsWhileSlide(percent);
} }
public void setScale(double scale) {
super.setScale(scale);
this.setContainerPercent(scale);
}
} }

41
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; import java.awt.event.MouseEvent;
public class XCardAddButton extends XButton { public class XCardAddButton extends XButton {
private XWCardTagLayout tagLayout; private XWCardTagLayout tagLayout;
private XWCardLayout cardLayout; private XWCardLayout cardLayout;
private static final int DEFAULT_BUTTON_WIDTH = 80; private static final int DEFAULT_BUTTON_WIDTH = 80;
private static final int ICON_OFFSET = 8; private static final int ICON_OFFSET = 8;
private static Icon ADD_ICON = BaseUtils.readIcon("/com/fr/design/form/images/add.png"); private static Icon ADD_ICON = BaseUtils.readIcon("/com/fr/design/form/images/add.png");
private Icon addIcon = ADD_ICON; private Icon addIcon = ADD_ICON;
/** /**
* card布局添加card按钮 * card布局添加card按钮
*/ */
@ -65,7 +65,7 @@ public class XCardAddButton extends XButton {
public XCardAddButton(CardAddButton widget, Dimension initSize) { public XCardAddButton(CardAddButton widget, Dimension initSize) {
super(widget, initSize); super(widget, initSize);
} }
/** /**
* 构造函数 * 构造函数
* @param widget 按钮 * @param widget 按钮
@ -76,18 +76,18 @@ public class XCardAddButton extends XButton {
this.tagLayout = fit; this.tagLayout = fit;
this.cardLayout = cardLayout; this.cardLayout = cardLayout;
} }
/** /**
* 响应点击事件 * 响应点击事件
* @param editingMouseListener 事件处理器 * @param editingMouseListener 事件处理器
* @param e 点击事件 * @param e 点击事件
* *
*/ */
@Override @Override
public void respondClick(EditingMouseListener editingMouseListener, MouseEvent e){ public void respondClick(EditingMouseListener editingMouseListener, MouseEvent e){
FormDesigner designer = editingMouseListener.getDesigner(); FormDesigner designer = editingMouseListener.getDesigner();
designer.fireTargetModified(); designer.fireTargetModified();
// addbutton对应的XWCardLayout和XWCardTagLayout暂未存入到xml中,重新打开之后先根据父子层获取 // addbutton对应的XWCardLayout和XWCardTagLayout暂未存入到xml中,重新打开之后先根据父子层获取
if(cardLayout == null && tagLayout ==null ){ if(cardLayout == null && tagLayout ==null ){
initRelateLayout(); initRelateLayout();
@ -96,17 +96,17 @@ public class XCardAddButton extends XButton {
throw new IllegalArgumentException("cardLayout can not be null"); throw new IllegalArgumentException("cardLayout can not be null");
} }
int index = cardLayout.toData().getWidgetCount(); int index = cardLayout.toData().getWidgetCount();
//添加新的tab,并将原来的设为未选中状态 //添加新的tab,并将原来的设为未选中状态
setTabUnselected(); setTabUnselected();
addTab(index); addTab(index);
this.tagLayout.adjustComponentWidth(); this.tagLayout.adjustComponentWidth();
if (editingMouseListener.stopEditing()) { if (editingMouseListener.stopEditing()) {
ComponentAdapter adapter = AdapterBus.getComponentAdapter(designer, this); ComponentAdapter adapter = AdapterBus.getComponentAdapter(designer, this);
editingMouseListener.startEditing(this, adapter.getDesignerEditor(), adapter); editingMouseListener.startEditing(this, adapter.getDesignerEditor(), adapter);
} }
FormHierarchyTreePane.getInstance().refreshRoot(); FormHierarchyTreePane.getInstance().refreshRoot();
//将焦点切换到新增的tab对应的tabfitLayout上 //将焦点切换到新增的tab对应的tabfitLayout上
showNewTab(editingMouseListener,index); showNewTab(editingMouseListener,index);
@ -118,28 +118,28 @@ public class XCardAddButton extends XButton {
public UIPopupMenu createPopupMenu(FormDesigner formDesigner) { public UIPopupMenu createPopupMenu(FormDesigner formDesigner) {
return UIPopupMenu.EMPTY; // 不要菜单 return UIPopupMenu.EMPTY; // 不要菜单
} }
private void initRelateLayout(){ private void initRelateLayout(){
XWCardTitleLayout titleLayout = (XWCardTitleLayout)this.getBackupParent(); XWCardTitleLayout titleLayout = (XWCardTitleLayout)this.getBackupParent();
this.tagLayout = titleLayout.getTagPart(); this.tagLayout = titleLayout.getTagPart();
XWCardMainBorderLayout borderLayout = (XWCardMainBorderLayout)titleLayout.getBackupParent(); XWCardMainBorderLayout borderLayout = (XWCardMainBorderLayout)titleLayout.getBackupParent();
this.cardLayout = borderLayout.getCardPart(); this.cardLayout = borderLayout.getCardPart();
} }
@Override @Override
public void paintComponent(Graphics g) { public void paintComponent(Graphics g) {
super.paintComponent(g); super.paintComponent(g);
Graphics2D g2d = (Graphics2D) g; Graphics2D g2d = (Graphics2D) g;
drawAddIcon(g2d); drawAddIcon(g2d);
} }
private void drawAddIcon(Graphics2D g2d){ private void drawAddIcon(Graphics2D g2d){
int width = this.getWidth(); int width = this.getWidth();
int height = this.getHeight(); int height = this.getHeight();
addIcon.paintIcon(this, g2d, width / 2 - ICON_OFFSET, height / 2 - ICON_OFFSET); addIcon.paintIcon(this, g2d, width / 2 - ICON_OFFSET, height / 2 - ICON_OFFSET);
} }
//将原来的tab页设置为未选中状态 //将原来的tab页设置为未选中状态
private void setTabUnselected(){ private void setTabUnselected(){
for(int i=0;i<this.tagLayout.getComponentCount();i++){ for(int i=0;i<this.tagLayout.getComponentCount();i++){
@ -148,12 +148,12 @@ public class XCardAddButton extends XButton {
button.setShowButton(false); button.setShowButton(false);
} }
} }
//新增tab //新增tab
private void addTab(int index){ private void addTab(int index){
Dimension dimension = new Dimension(); Dimension dimension = new Dimension();
dimension.width = DEFAULT_BUTTON_WIDTH; dimension.width = DEFAULT_BUTTON_WIDTH;
String cardLayoutName = cardLayout.toData().getWidgetName(); String cardLayoutName = cardLayout.toData().getWidgetName();
CardSwitchButton titleButton = new CardSwitchButton(index,cardLayoutName); CardSwitchButton titleButton = new CardSwitchButton(index,cardLayoutName);
WCardTagLayout layout = (WCardTagLayout) this.tagLayout.toData(); WCardTagLayout layout = (WCardTagLayout) this.tagLayout.toData();
@ -166,11 +166,12 @@ public class XCardAddButton extends XButton {
XCardSwitchButton showButton = new XCardSwitchButton(titleButton, dimension, cardLayout, tagLayout); XCardSwitchButton showButton = new XCardSwitchButton(titleButton, dimension, cardLayout, tagLayout);
titleButton.setShowButton(true); titleButton.setShowButton(true);
showButton.setBackupParent(tagLayout); showButton.setBackupParent(tagLayout);
showButton.setScale(this.getScale());
this.tagLayout.setCurrentCard(titleButton); this.tagLayout.setCurrentCard(titleButton);
this.tagLayout.setTabFitIndex(index); this.tagLayout.setTabFitIndex(index);
this.tagLayout.add(showButton); this.tagLayout.add(showButton);
} }
//切换焦点到新增tab页 //切换焦点到新增tab页
private void showNewTab(EditingMouseListener editingMouseListener, int index){ private void showNewTab(EditingMouseListener editingMouseListener, int index){
SelectionModel selectionModel = editingMouseListener.getSelectionModel(); SelectionModel selectionModel = editingMouseListener.getSelectionModel();
@ -179,7 +180,7 @@ public class XCardAddButton extends XButton {
tabFitLayout.setxCardSwitchButton(xCardSwitchButton); tabFitLayout.setxCardSwitchButton(xCardSwitchButton);
selectionModel.setSelectedCreator(tabFitLayout); selectionModel.setSelectedCreator(tabFitLayout);
} }
//新增时去tabFitLayout名字中最大的Index+1,防止重名 //新增时去tabFitLayout名字中最大的Index+1,防止重名
private String getTabTitleName(WCardTagLayout layout){ private String getTabTitleName(WCardTagLayout layout){
int size = layout.getWidgetCount(); int size = layout.getWidgetCount();

10
designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardTagLayout.java

@ -137,6 +137,7 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout {
WTabFitLayout fitLayout = new WTabFitLayout(widgetName, tabFitIndex, currentCard); WTabFitLayout fitLayout = new WTabFitLayout(widgetName, tabFitIndex, currentCard);
fitLayout.setTabNameIndex(getTabNameIndex()); fitLayout.setTabNameIndex(getTabNameIndex());
XWTabFitLayout tabFitLayout = new XWTabFitLayout(fitLayout, new Dimension()); XWTabFitLayout tabFitLayout = new XWTabFitLayout(fitLayout, new Dimension());
tabFitLayout.setScale(this.getScale());
WCardTagLayout layout = (WCardTagLayout) this.toData(); WCardTagLayout layout = (WCardTagLayout) this.toData();
if(!ComparatorUtils.equals(layout.getTemplateStyle().getStyle(), DefaultTemplateStyle.DEFAULT_TEMPLATE_STYLE)){ if(!ComparatorUtils.equals(layout.getTemplateStyle().getStyle(), DefaultTemplateStyle.DEFAULT_TEMPLATE_STYLE)){
@ -356,6 +357,7 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout {
BorderPacker borderStyle = this.cardLayout.toData().getBorderStyle(); BorderPacker borderStyle = this.cardLayout.toData().getBorderStyle();
FRFont f = borderStyle.getTitle().getFrFont(); FRFont f = borderStyle.getTitle().getFrFont();
FontMetrics fm = GraphHelper.getFontMetrics(f); FontMetrics fm = GraphHelper.getFontMetrics(f);
double scale = this.getScale();
switch (wCardTagLayout.getTextDirection()) { switch (wCardTagLayout.getTextDirection()) {
case TEXT_HORI_DERECTION: case TEXT_HORI_DERECTION:
@ -392,8 +394,8 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout {
int tempX = 0; int tempX = 0;
for (int i = 0; i < tabLength; i++) { for (int i = 0; i < tabLength; i++) {
Rectangle rectangle = this.getComponent(i).getBounds(); Rectangle rectangle = this.getComponent(i).getBounds();
Integer cardWidth = width.get(i) + WIDTH_SIDE_OFFSET; int cardWidth = (int) ((width.get(i) + WIDTH_SIDE_OFFSET) * this.getScale());
Integer cardHeight = tabPaneSize; int cardHeight = tabPaneSize;
rectangle.setBounds(tempX, 0, cardWidth, cardHeight); rectangle.setBounds(tempX, 0, cardWidth, cardHeight);
tempX += cardWidth; tempX += cardWidth;
XCardSwitchButton temp = (XCardSwitchButton) this.getComponent(i); XCardSwitchButton temp = (XCardSwitchButton) this.getComponent(i);
@ -444,4 +446,8 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout {
} }
} }
public void adjustCompSize(double percent){
setTabsAndAdjust();
}
} }

29
designer-form/src/main/java/com/fr/design/form/layout/FRFitLayout.java

@ -8,10 +8,11 @@ import java.awt.LayoutManager;
import java.awt.Point; import java.awt.Point;
import java.awt.Rectangle; import java.awt.Rectangle;
import com.fr.design.designer.creator.XCreator;
import com.fr.form.ui.container.WLayout; import com.fr.form.ui.container.WLayout;
public class FRFitLayout implements FRLayoutManager, LayoutManager{ public class FRFitLayout implements FRLayoutManager, LayoutManager{
private int interval; private int interval;
// 上次的布局内边距 // 上次的布局内边距
private Insets lastInset; private Insets lastInset;
@ -19,11 +20,11 @@ public class FRFitLayout implements FRLayoutManager, LayoutManager{
public FRFitLayout() { public FRFitLayout() {
this(0); this(0);
} }
public FRFitLayout(int interval) { public FRFitLayout(int interval) {
this.interval = interval; this.interval = interval;
} }
public void setInterVal(int val) { public void setInterVal(int val) {
this.interval = val; this.interval = val;
} }
@ -35,7 +36,7 @@ public class FRFitLayout implements FRLayoutManager, LayoutManager{
*/ */
@Override @Override
public void addLayoutComponent(String name, Component comp) { public void addLayoutComponent(String name, Component comp) {
} }
/** /**
@ -44,7 +45,7 @@ public class FRFitLayout implements FRLayoutManager, LayoutManager{
*/ */
@Override @Override
public void removeLayoutComponent(Component comp) { public void removeLayoutComponent(Component comp) {
} }
/** /**
@ -75,6 +76,9 @@ public class FRFitLayout implements FRLayoutManager, LayoutManager{
public void layoutContainer(Container target) { public void layoutContainer(Container target) {
synchronized (target.getTreeLock()) { synchronized (target.getTreeLock()) {
Insets insets = target.getInsets(); Insets insets = target.getInsets();
XCreator creator = (XCreator) target;
double scale = creator.getScale();
processMarginScale(insets, scale);
int width = target.getWidth(); int width = target.getWidth();
int height = target.getHeight(); int height = target.getHeight();
calculateLastInset(target, width, height); calculateLastInset(target, width, height);
@ -104,7 +108,14 @@ public class FRFitLayout implements FRLayoutManager, LayoutManager{
} }
} }
} }
private void processMarginScale(Insets insets, double scale ){
insets.top *= scale;
insets.left *= scale;
insets.right *= scale;
insets.bottom *= scale;
}
private void calculateLastInset(Container target, int width, int height) { private void calculateLastInset(Container target, int width, int height) {
int len = target.getComponentCount(); int len = target.getComponentCount();
if (len ==0) { if (len ==0) {
@ -122,11 +133,11 @@ public class FRFitLayout implements FRLayoutManager, LayoutManager{
lastInset.bottom = Math.min(height-rec.y-rec.height, lastInset.bottom); lastInset.bottom = Math.min(height-rec.y-rec.height, lastInset.bottom);
} }
} }
private boolean insetNotChange(Insets inset, Insets last) { 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 inset.left == last.left && inset.right == last.right && inset.top == last.top && inset.bottom == last.bottom;
} }
/** /**
* 是否重置大小 * 是否重置大小
* @return * @return
@ -136,4 +147,4 @@ public class FRFitLayout implements FRLayoutManager, LayoutManager{
return true; return true;
} }
} }

34
designer-form/src/main/java/com/fr/design/form/layout/FRTitleLayout.java

@ -1,5 +1,5 @@
/** /**
* *
*/ */
package com.fr.design.form.layout; package com.fr.design.form.layout;
@ -8,35 +8,36 @@ import java.awt.Container;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.LayoutManager; import java.awt.LayoutManager;
import com.fr.design.designer.creator.XCreator;
import com.fr.form.ui.container.WLayout; import com.fr.form.ui.container.WLayout;
import com.fr.form.ui.container.WTitleLayout; import com.fr.form.ui.container.WTitleLayout;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
/** /**
* 布局管理器主要为一些需要加标题的组件用如报表块图表块 * 布局管理器主要为一些需要加标题的组件用如报表块图表块
* *
* @author jim * @author jim
* @date 2014-9-25 * @date 2014-9-25
*/ */
public class FRTitleLayout implements FRLayoutManager, LayoutManager{ public class FRTitleLayout implements FRLayoutManager, LayoutManager{
public static final String TITLE = "Title"; public static final String TITLE = "Title";
public static final String BODY = "Body"; public static final String BODY = "Body";
// 标题控件,默认为文本框 // 标题控件,默认为文本框
private Component title; private Component title;
// 主体控件,有表单报表块、图表块 // 主体控件,有表单报表块、图表块
private Component body; private Component body;
private int gap; private int gap;
/** /**
* 构造函数 * 构造函数
*/ */
public FRTitleLayout() { public FRTitleLayout() {
this(0); this(0);
} }
/** /**
* 标题和主体间隙gap的布局 * 标题和主体间隙gap的布局
* @param gap 间隙值 * @param gap 间隙值
@ -44,7 +45,7 @@ public class FRTitleLayout implements FRLayoutManager, LayoutManager{
public FRTitleLayout(int gap) { public FRTitleLayout(int gap) {
this.gap = gap; this.gap = gap;
} }
/** /**
* 返回 * 返回
* Returns the gap between components. * Returns the gap between components.
@ -61,7 +62,7 @@ public class FRTitleLayout implements FRLayoutManager, LayoutManager{
public void setGap(int gap) { public void setGap(int gap) {
this.gap = gap; this.gap = gap;
} }
/** /**
* 增加组件 * 增加组件
* @param name 名字 * @param name 名字
@ -76,7 +77,7 @@ public class FRTitleLayout implements FRLayoutManager, LayoutManager{
body = comp; body = comp;
} else if (ComparatorUtils.equals(name, TITLE)) { } else if (ComparatorUtils.equals(name, TITLE)) {
title = comp; title = comp;
} }
} }
} }
@ -89,7 +90,7 @@ public class FRTitleLayout implements FRLayoutManager, LayoutManager{
synchronized (comp.getTreeLock()) { synchronized (comp.getTreeLock()) {
if (comp == title) { if (comp == title) {
title = null; title = null;
} }
} }
} }
@ -120,15 +121,16 @@ public class FRTitleLayout implements FRLayoutManager, LayoutManager{
*/ */
@Override @Override
public void layoutContainer(Container target) { public void layoutContainer(Container target) {
double scale = ((XCreator)target).getScale();
synchronized (target.getTreeLock()) { synchronized (target.getTreeLock()) {
int width = target.getWidth(); int width = target.getWidth();
int height = target.getHeight(); int height = target.getHeight();
int titleH = title==null ? 0 : WTitleLayout.TITLE_HEIGHT; int titleH = title == null ? 0 : (int) (WTitleLayout.TITLE_HEIGHT * scale);
for (int i=0; i< target.getComponentCount(); i++) { for (int i=0; i< target.getComponentCount(); i++) {
Component comp = target.getComponent(i); Component comp = target.getComponent(i);
if (comp != null) { if (comp != null) {
if (comp == title) { if (comp == title) {
comp.setBounds(0, 0, width, WTitleLayout.TITLE_HEIGHT); comp.setBounds(0, 0, width, titleH);
} else if (comp == body) { } else if (comp == body) {
int y = titleH + gap; int y = titleH + gap;
comp.setBounds(0, y, width, height-y); comp.setBounds(0, y, width, height-y);
@ -137,7 +139,7 @@ public class FRTitleLayout implements FRLayoutManager, LayoutManager{
} }
} }
} }
public Object getConstraints(Component comp) { public Object getConstraints(Component comp) {
if (comp == null){ if (comp == null){
return null; return null;
@ -146,7 +148,7 @@ public class FRTitleLayout implements FRLayoutManager, LayoutManager{
return TITLE; return TITLE;
} else if (comp == body) { } else if (comp == body) {
return BODY; return BODY;
} }
return null; return null;
} }
@ -159,4 +161,4 @@ public class FRTitleLayout implements FRLayoutManager, LayoutManager{
return false; return false;
} }
} }

36
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.base.ScreenResolution;
import com.fr.common.inputevent.InputEventBaseOnOS; 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.beans.events.DesignerEvent;
import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XLayoutContainer; import com.fr.design.designer.creator.XLayoutContainer;
@ -115,7 +116,7 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
this.setFocusTraversalKeysEnabled(false); this.setFocusTraversalKeysEnabled(false);
this.addMouseWheelListener(showValSpinnerMouseWheelListener); this.addMouseWheelListener(showValSpinnerMouseWheelListener);
registerShortCutKey(); registerShortCutKey();
this.designer.addDesignerEditListener(designerEditListener);
} }
/** /**
@ -173,14 +174,14 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
double[] rowSize = {f}; double[] rowSize = {f};
double[] columnSize = {p, f, p, p, p, p, p, f, p}; double[] columnSize = {p, f, p, p, p, p, p, f, p};
UILabel tipsPane = new UILabel("form"); UILabel tipsPane = new UILabel("form");
tipsPane.setPreferredSize(new Dimension(375, 0)); tipsPane.setPreferredSize(new Dimension(265, 0));
widthPane = new UINumberField(); widthPane = new UINumberField();
widthPane.setPreferredSize(new Dimension(60, 0)); widthPane.setPreferredSize(new Dimension(60, 0));
heightPane = new UINumberField(); heightPane = new UINumberField();
heightPane.setPreferredSize(new Dimension(60, 0)); heightPane.setPreferredSize(new Dimension(60, 0));
slidePane = JFormSliderPane.getInstance(); slidePane = JFormSliderPane.getInstance();
slidePane.setPreferredSize(new Dimension(375, 20)); slidePane.setPreferredSize(new Dimension(326, 20));
JPanel resizePane = TableLayoutHelper.createCommonTableLayoutPane( JPanel resizePane = TableLayoutHelper.createCommonTableLayoutPane(
new JComponent[][]{{tipsPane, new UILabel(), widthPane, new JComponent[][]{{tipsPane, new UILabel(), widthPane,
@ -198,6 +199,7 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
slidePane.addValueChangeListener(showValSpinnerChangeListener); slidePane.addValueChangeListener(showValSpinnerChangeListener);
} }
private void setWidgetsConfig() { private void setWidgetsConfig() {
widthPane.setHorizontalAlignment(widthPane.CENTER); widthPane.setHorizontalAlignment(widthPane.CENTER);
heightPane.setHorizontalAlignment(heightPane.CENTER); heightPane.setHorizontalAlignment(heightPane.CENTER);
@ -406,11 +408,10 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
XWFitLayout layout = (XWFitLayout) root; XWFitLayout layout = (XWFitLayout) root;
layout.setContainerPercent(scale); layout.setContainerPercent(scale);
layout.adjustCompSize(percent); layout.adjustCompSize(percent);
traverAndAdjust(layout, percent);
// 拖动滑块,先将内部组件百分比大小计算,再计算容器大小 // 拖动滑块,先将内部组件百分比大小计算,再计算容器大小
Dimension d = new Dimension(layout.getWidth(), layout.getHeight()); Dimension d = new Dimension(layout.getWidth(), layout.getHeight());
XWBorderLayout parent = (XWBorderLayout) layout.getParent(); XWBorderLayout parent = (XWBorderLayout) layout.getParent();
root.setScale(scale); traverAndAdjust(parent, percent);
// 自适应布局的父层是border // 自适应布局的父层是border
if (parent != null) { if (parent != null) {
parent.setScale(scale); parent.setScale(scale);
@ -440,12 +441,13 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
* *
*/ */
private void reCalculateDefaultRoot() { private void reCalculateDefaultRoot() {
Dimension dim = calDesignAreaSize();
XLayoutContainer root = FormArea.this.designer.getRootComponent(); XLayoutContainer root = FormArea.this.designer.getRootComponent();
if (root.acceptType(XWFitLayout.class)) { if (root.acceptType(XWFitLayout.class)) {
XWFitLayout layout = (XWFitLayout) root; XWFitLayout layout = (XWFitLayout) root;
Dimension dimension = layout.getSize(); Dimension dimension = layout.getSize();
double widthScale = 960D / dimension.width; double widthScale = dim.width / (double) dimension.width;
double heightScale = 960D / dimension.height; double heightScale = dim.height / (double) dimension.height;
final double scaleValue = Math.min(widthScale, heightScale); final double scaleValue = Math.min(widthScale, heightScale);
int value = (int) (scaleValue * 100); int value = (int) (scaleValue * 100);
slidePane.setShowValue(value); slidePane.setShowValue(value);
@ -456,6 +458,14 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
} }
} }
private Dimension calDesignAreaSize() {
Dimension cardSize = DesignerContext.getDesignerFrame().getCenterTemplateCardPane().getSize();
if (cardSize.width == 0 || cardSize.height == 0) {
return new Dimension(960, 540);
}
return new Dimension(cardSize.width, cardSize.height - verScrollBar.getPreferredSize().height - 20);
}
//循环遍历布局,按百分比调整子组件大小 //循环遍历布局,按百分比调整子组件大小
private void traverAndAdjust(XCreator creator, double percent) { private void traverAndAdjust(XCreator creator, double percent) {
for (int i = 0; i < creator.getComponentCount(); i++) { for (int i = 0; i < creator.getComponentCount(); i++) {
@ -766,10 +776,20 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
layout.addCompInterval(layout.getAcualInterval()); layout.addCompInterval(layout.getAcualInterval());
} else if (designer.getRootComponent().acceptType(XWFitLayout.class)) { } else if (designer.getRootComponent().acceptType(XWFitLayout.class)) {
reCalculateRoot(slide, true); reCalculateRoot(slide, true);
// slidePane.populateBean(slide);
} }
this.slidePane.setShowValue((int) slide);
} }
private DesignerEditListener designerEditListener = new DesignerEditListener() {
@Override
public void fireCreatorModified(DesignerEvent evt) {
if (evt.getCreatorEventID() == DesignerEvent.CREATOR_ADDED|| evt.getCreatorEventID() == DesignerEvent.CREATOR_DELETED) {
FormArea.this.reCalculateRoot(slidePane.getShowValue(), true);
}
}
};
/** /**
* 计算滚动条的值和max * 计算滚动条的值和max
* *

14
designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java

@ -448,15 +448,21 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
if (paraComponent != null) { if (paraComponent != null) {
return; return;
} }
paraHeight = WBorderLayout.DEFAULT_SIZE;
paraComponent = new XWParameterLayout(); paraComponent = new XWParameterLayout();
paraComponent.toData().setWidgetName("para"); paraComponent.toData().setWidgetName("para");
paraComponent.setSize(paraComponent.initEditorSize()); paraComponent.setSize(paraComponent.initEditorSize());
paraComponent.setScale(rootComponent.getScale());
this.setParaHeight(WBorderLayout.DEFAULT_SIZE);
paraComponent.setPreferredSize(new Dimension(paraComponent.getSize().width, this.getParaHeight()));
XWBorderLayout formLayoutContainer = (XWBorderLayout) rootComponent.getParent(); XWBorderLayout formLayoutContainer = (XWBorderLayout) rootComponent.getParent();
formLayoutContainer.toData().setNorthSize(paraHeight);
formLayoutContainer.add(paraComponent, WBorderLayout.NORTH);
//设下northSize,增加para后,重置border大小,这时候para和root的大小会自适应调整 //设下northSize,增加para后,重置border大小,这时候para和root的大小会自适应调整
formLayoutContainer.setSize(formLayoutContainer.getWidth(), formLayoutContainer.getHeight() + paraHeight);
formLayoutContainer.add(paraComponent, WBorderLayout.NORTH);
selectionModel.reset(); selectionModel.reset();
selectionModel.setSelectedCreator(paraComponent); selectionModel.setSelectedCreator(paraComponent);
invalidateLayout(); invalidateLayout();

33
designer-form/src/main/java/com/fr/design/widget/ui/designer/component/WidgetBoundPane.java

@ -88,9 +88,13 @@ public class WidgetBoundPane extends BasicPane {
height.setValue(bounds.height); height.setValue(bounds.height);
} }
public void fix() { public void fix() {
WLayout wabs = parent.toData(); WLayout wabs = parent.toData();
CRBoundsWidget boundsWidget = wabs.getBoundsWidget(creator.toData()); CRBoundsWidget boundsWidget = wabs.getBoundsWidget(creator.toData());
if (boundsWidget == null){
return;
}
Rectangle bounds = new Rectangle(boundsWidget.getBounds()); Rectangle bounds = new Rectangle(boundsWidget.getBounds());
creator.setBackupBound(creator.getBounds()); creator.setBackupBound(creator.getBounds());
int w = (int) width.getValue(); int w = (int) width.getValue();
@ -106,18 +110,17 @@ public class WidgetBoundPane extends BasicPane {
public void adjustComponents(Rectangle bounds, int difference, int row) { public void adjustComponents(Rectangle bounds, int difference, int row) {
double scale = parent.getScale();
FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner(); FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner();
Rectangle backupBounds = getBound(); Rectangle backupBounds = getBound();
FRFitLayoutAdapter layoutAdapter = (FRFitLayoutAdapter) AdapterBus.searchLayoutAdapter(formDesigner, creator); FRFitLayoutAdapter layoutAdapter = (FRFitLayoutAdapter) AdapterBus.searchLayoutAdapter(formDesigner, creator);
if (layoutAdapter != null) { if (layoutAdapter != null) {
layoutAdapter.setEdit(true); 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) { public void limitWidth(WLayout wabs, int w, Rectangle bounds, Rectangle rec) {
int difference = 0; int scaleDiff = 0;
double scale = parent.getScale(); double scale = parent.getScale();
int minWidth = (int) (MINWIDTH * ((WFitLayout) wabs).getResolutionScaling()); int minWidth = (int) (MINWIDTH * ((WFitLayout) wabs).getResolutionScaling());
PaddingMargin margin = wabs.getMargin(); PaddingMargin margin = wabs.getMargin();
@ -131,16 +134,27 @@ public class WidgetBoundPane extends BasicPane {
width.setValue(bounds.width); width.setValue(bounds.width);
return; return;
} }
difference = bounds.width - w; int difference = bounds.width - w;
scaleDiff = roundValue(difference * scale);
bounds.width = w; bounds.width = w;
} }
Rectangle backupBounds = getBound();
Rectangle newBounds = new Rectangle(backupBounds.x, backupBounds.y, backupBounds.width - scaleDiff, backupBounds.height);
wabs.setBounds(creator.toData(), bounds); wabs.setBounds(creator.toData(), bounds);
adjustComponents(bounds, difference, 0); adjustComponents(newBounds, scaleDiff, 0);
}
private int roundValue(double value) {
if (value < 0) {
return (int) Math.floor(value);
} else {
return (int) Math.ceil(value);
}
} }
public void limitHeight(WLayout wabs, int h, Rectangle bounds, Rectangle rec) { public void limitHeight(WLayout wabs, int h, Rectangle bounds, Rectangle rec) {
double scale = parent.getScale(); double scale = parent.getScale();
int difference = 0; int scaleDiff = 0;
PaddingMargin margin = wabs.getMargin(); PaddingMargin margin = wabs.getMargin();
int minHeight = (int) (MINHEIGHT * ((WFitLayout) wabs).getResolutionScaling()); int minHeight = (int) (MINHEIGHT * ((WFitLayout) wabs).getResolutionScaling());
if (bounds.height != h) { if (bounds.height != h) {
@ -153,11 +167,14 @@ public class WidgetBoundPane extends BasicPane {
height.setValue(bounds.height); height.setValue(bounds.height);
return; return;
} }
difference = bounds.height - h; int difference = bounds.height - h;
scaleDiff = roundValue(difference * scale);
bounds.height = h; bounds.height = h;
} }
Rectangle backupBounds = getBound();
Rectangle newBounds = new Rectangle(backupBounds.x, backupBounds.y, backupBounds.width, backupBounds.height - scaleDiff);
wabs.setBounds(creator.toData(), bounds); wabs.setBounds(creator.toData(), bounds);
adjustComponents(bounds, difference, 1); adjustComponents(newBounds, scaleDiff, 1);
} }

28
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.event.TargetModifiedListener;
import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.gui.icontainer.UIModeControlContainer; import com.fr.design.gui.icontainer.UIModeControlContainer;
import com.fr.design.gui.ispinner.UIBasicSpinner;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.grid.Grid; import com.fr.grid.Grid;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
@ -49,7 +48,7 @@ public class ReportComponentComposite extends JComponent implements RemoveListen
private JPanel hbarContainer; private JPanel hbarContainer;
private JSliderPane jSliderContainer; private JFormSliderPane jSliderContainer;
/** /**
* Constructor with workbook.. * Constructor with workbook..
@ -65,8 +64,7 @@ public class ReportComponentComposite extends JComponent implements RemoveListen
CellElementRegion = FRGUIPaneFactory.createBorderLayout_S_Pane(); CellElementRegion = FRGUIPaneFactory.createBorderLayout_S_Pane();
this.add(CellElementRegion, BorderLayout.NORTH); this.add(CellElementRegion, BorderLayout.NORTH);
this.add(createSouthControlPane(), BorderLayout.SOUTH); this.add(createSouthControlPane(), BorderLayout.SOUTH);
jSliderContainer.getShowVal().addChangeListener(showValSpinnerChangeListener); jSliderContainer.addValueChangeListener(showValSpinnerChangeListener);
jSliderContainer.getSelfAdaptButton().addItemListener(selfAdaptButtonItemListener);
} }
MouseWheelListener showValSpinnerMouseWheelListener = new MouseWheelListener() { MouseWheelListener showValSpinnerMouseWheelListener = new MouseWheelListener() {
@ -74,8 +72,8 @@ public class ReportComponentComposite extends JComponent implements RemoveListen
public void mouseWheelMoved(MouseWheelEvent e) { public void mouseWheelMoved(MouseWheelEvent e) {
if (InputEventBaseOnOS.isControlDown(e)) { if (InputEventBaseOnOS.isControlDown(e)) {
int dir = e.getWheelRotation(); int dir = e.getWheelRotation();
int old_resolution = (int) jSliderContainer.getShowVal().getValue(); int old_resolution = jSliderContainer.getShowValue();
jSliderContainer.getShowVal().setValue(old_resolution - (dir * DIR)); jSliderContainer.setShowValue(old_resolution - (dir * DIR));
} }
} }
}; };
@ -83,7 +81,7 @@ public class ReportComponentComposite extends JComponent implements RemoveListen
ChangeListener showValSpinnerChangeListener = new ChangeListener() { ChangeListener showValSpinnerChangeListener = new ChangeListener() {
@Override @Override
public void stateChanged(ChangeEvent e) { public void stateChanged(ChangeEvent e) {
double value = (int) ((UIBasicSpinner) e.getSource()).getValue(); double value = jSliderContainer.getShowValue();
value = value > MAX ? MAX : value; value = value > MAX ? MAX : value;
value = value < MIN ? MIN : value; value = value < MIN ? MIN : value;
int resolution = (int) (ScreenResolution.getScreenResolution() * value / HUND); 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) { protected void doBeforeChange(int oldIndex) {
if (oldIndex >= 0) { if (oldIndex >= 0) {
@ -130,8 +119,7 @@ public class ReportComponentComposite extends JComponent implements RemoveListen
templateStateList.add(null); templateStateList.add(null);
} }
centerCardPane.editingComponet.setSelection(centerCardPane.editingComponet.getDefaultSelectElement()); centerCardPane.editingComponet.setSelection(centerCardPane.editingComponet.getDefaultSelectElement());
jSliderContainer=JSliderPane.getInstance(); jSliderContainer = JFormSliderPane.getInstance();
jSliderContainer.reset();
} }
if (centerCardPane.editingComponet.elementCasePane == null) { if (centerCardPane.editingComponet.elementCasePane == null) {
@ -173,7 +161,7 @@ public class ReportComponentComposite extends JComponent implements RemoveListen
return sheetNameTab.getSelectedIndex(); return sheetNameTab.getSelectedIndex();
} }
public JSliderPane getjSliderContainer() { public JFormSliderPane getjSliderContainer() {
return this.jSliderContainer; return this.jSliderContainer;
} }
@ -217,7 +205,7 @@ public class ReportComponentComposite extends JComponent implements RemoveListen
hbarContainer = FRGUIPaneFactory.createBorderLayout_S_Pane(); hbarContainer = FRGUIPaneFactory.createBorderLayout_S_Pane();
hbarContainer.add(centerCardPane.editingComponet.getHorizontalScrollBar()); hbarContainer.add(centerCardPane.editingComponet.getHorizontalScrollBar());
JPanel southPane = new JPanel(new BorderLayout()); JPanel southPane = new JPanel(new BorderLayout());
jSliderContainer = JSliderPane.getInstance(); jSliderContainer = JFormSliderPane.getInstance();
southPane.add(hbarContainer, BorderLayout.NORTH); southPane.add(hbarContainer, BorderLayout.NORTH);
southPane.add(sheetNameTab, BorderLayout.CENTER); southPane.add(sheetNameTab, BorderLayout.CENTER);

6
designer-realize/src/main/java/com/fr/design/mainframe/WorkSheetDesigner.java

@ -182,8 +182,8 @@ public class WorkSheetDesigner extends ReportComponent<WorkSheet, ElementCasePan
@Override @Override
public void updateJSliderValue() { public void updateJSliderValue() {
ReportComponentComposite reportComposite = (ReportComponentComposite) HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().getCurrentReportComponentPane(); ReportComponentComposite reportComposite = (ReportComponentComposite) HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().getCurrentReportComponentPane();
JSliderPane jSliderContainer = reportComposite.getjSliderContainer(); JFormSliderPane jSliderContainer = reportComposite.getjSliderContainer();
jSliderContainer.getShowVal().setValue((int) Math.ceil((double) this.elementCasePane.getResolution() * HUND / ScreenResolution.getScreenResolution())); jSliderContainer.setShowValue((int) Math.ceil((double) this.elementCasePane.getResolution() * HUND / ScreenResolution.getScreenResolution()));
} }
@Override @Override
@ -196,4 +196,4 @@ public class WorkSheetDesigner extends ReportComponent<WorkSheet, ElementCasePan
elementCasePane.removeSelectionChangeListener(selectionListener); elementCasePane.removeSelectionChangeListener(selectionListener);
} }
} }

27
designer-realize/src/main/java/com/fr/design/mainframe/form/FormReportComponentComposite.java

@ -11,7 +11,7 @@ import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.BaseJForm; import com.fr.design.mainframe.BaseJForm;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.ElementCasePane; import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.mainframe.JSliderPane; import com.fr.design.mainframe.JFormSliderPane;
import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus; import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus;
import com.fr.form.FormElementCaseContainerProvider; import com.fr.form.FormElementCaseContainerProvider;
import com.fr.form.FormElementCaseProvider; import com.fr.form.FormElementCaseProvider;
@ -42,7 +42,7 @@ public class FormReportComponentComposite extends JComponent implements TargetMo
private FormTabPane sheetNameTab; private FormTabPane sheetNameTab;
private JPanel hbarContainer; private JPanel hbarContainer;
private JSliderPane jSliderContainer; private JFormSliderPane jSliderContainer;
public FormReportComponentComposite(BaseJForm jform, FormElementCaseDesigner elementCaseDesign, FormElementCaseContainerProvider ecContainer) { public FormReportComponentComposite(BaseJForm jform, FormElementCaseDesigner elementCaseDesign, FormElementCaseContainerProvider ecContainer) {
this.jForm = jform; this.jForm = jform;
@ -51,8 +51,7 @@ public class FormReportComponentComposite extends JComponent implements TargetMo
this.add(elementCaseDesigner, BorderLayout.CENTER); this.add(elementCaseDesigner, BorderLayout.CENTER);
sheetNameTab = new FormTabPane(ecContainer, jform); sheetNameTab = new FormTabPane(ecContainer, jform);
this.add(createSouthControlPane(), BorderLayout.SOUTH); this.add(createSouthControlPane(), BorderLayout.SOUTH);
jSliderContainer.getShowVal().addChangeListener(showValSpinnerChangeListener); jSliderContainer.addValueChangeListener(showValSpinnerChangeListener);
jSliderContainer.getSelfAdaptButton().addItemListener(selfAdaptButtonItemListener);
this.elementCaseDesigner.elementCasePane.getGrid().addMouseWheelListener(showValSpinnerMouseWheelListener); this.elementCaseDesigner.elementCasePane.getGrid().addMouseWheelListener(showValSpinnerMouseWheelListener);
elementCaseDesigner.addTargetModifiedListener(this); elementCaseDesigner.addTargetModifiedListener(this);
} }
@ -62,8 +61,8 @@ public class FormReportComponentComposite extends JComponent implements TargetMo
public void mouseWheelMoved(MouseWheelEvent e) { public void mouseWheelMoved(MouseWheelEvent e) {
if (InputEventBaseOnOS.isControlDown(e)) { if (InputEventBaseOnOS.isControlDown(e)) {
int dir = e.getWheelRotation(); int dir = e.getWheelRotation();
int old_resolution = (int) jSliderContainer.getShowVal().getValue(); int old_resolution = jSliderContainer.getShowValue();
jSliderContainer.getShowVal().setValue(old_resolution - (dir * DIR)); jSliderContainer.setShowValue(old_resolution - (dir * DIR));
} }
} }
}; };
@ -72,7 +71,7 @@ public class FormReportComponentComposite extends JComponent implements TargetMo
ChangeListener showValSpinnerChangeListener = new ChangeListener() { ChangeListener showValSpinnerChangeListener = new ChangeListener() {
@Override @Override
public void stateChanged(ChangeEvent e) { public void stateChanged(ChangeEvent e) {
double value = (int) ((UIBasicSpinner) e.getSource()).getValue(); double value = jSliderContainer.getShowValue();
value = value > MAX ? MAX : value; value = value > MAX ? MAX : value;
value = value < MIN ? MIN : value; value = value < MIN ? MIN : value;
int resolution = (int) (ScreenResolution.getScreenResolution() * value / HUND); 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<TargetModifiedListener> targetModifiedList = new java.util.ArrayList<TargetModifiedListener>(); private java.util.List<TargetModifiedListener> targetModifiedList = new java.util.ArrayList<TargetModifiedListener>();
@ -169,7 +160,7 @@ public class FormReportComponentComposite extends JComponent implements TargetMo
JPanel southPane = new JPanel(new BorderLayout()); JPanel southPane = new JPanel(new BorderLayout());
hbarContainer = FRGUIPaneFactory.createBorderLayout_S_Pane(); hbarContainer = FRGUIPaneFactory.createBorderLayout_S_Pane();
hbarContainer.add(elementCaseDesigner.getHorizontalScrollBar()); hbarContainer.add(elementCaseDesigner.getHorizontalScrollBar());
jSliderContainer = JSliderPane.getInstance(); jSliderContainer = JFormSliderPane.getInstance();
southPane.add(hbarContainer, BorderLayout.NORTH); southPane.add(hbarContainer, BorderLayout.NORTH);
southPane.add(sheetNameTab, BorderLayout.CENTER); southPane.add(sheetNameTab, BorderLayout.CENTER);
@ -204,4 +195,4 @@ public class FormReportComponentComposite extends JComponent implements TargetMo
} }
} }

3
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.ExtraDesignClassManager;
import com.fr.design.fun.GridUIProcessor; import com.fr.design.fun.GridUIProcessor;
import com.fr.design.mainframe.ElementCasePane; import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.mainframe.JSliderPane;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import javax.swing.plaf.ComponentUI; import javax.swing.plaf.ComponentUI;
@ -75,4 +74,4 @@ public class GridColumn extends GridHeader<String> {
return new Dimension(super.getPreferredSize().width, (int) (GraphHelper.getFontMetrics(this.getFont()).getHeight() * time + SIZE_ADJUST)); return new Dimension(super.getPreferredSize().width, (int) (GraphHelper.getFontMetrics(this.getFont()).getHeight() * time + SIZE_ADJUST));
} }
} }

5
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.DesignerContext;
import com.fr.design.mainframe.EastRegionContainerPane; import com.fr.design.mainframe.EastRegionContainerPane;
import com.fr.design.mainframe.ElementCasePane; import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.mainframe.JSliderPane;
import com.fr.design.os.impl.PopupDialogSaveAction; import com.fr.design.os.impl.PopupDialogSaveAction;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.grid.selection.CellSelection; import com.fr.grid.selection.CellSelection;
@ -74,7 +73,7 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous
private int ECBlockGap = 40; private int ECBlockGap = 40;
private int resolution = (int) (ScreenResolution.getScreenResolution() * JSliderPane.getInstance().resolutionTimes); private int resolution = ScreenResolution.getScreenResolution();
protected GridMouseAdapter(Grid grid) { protected GridMouseAdapter(Grid grid) {
this.grid = grid; this.grid = grid;
@ -836,4 +835,4 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous
*/ */
public void mouseExited(MouseEvent e) { public void mouseExited(MouseEvent e) {
} }
} }

8
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.ElementsTransferable;
import com.fr.design.cell.clipboard.FloatElementsClip; import com.fr.design.cell.clipboard.FloatElementsClip;
import com.fr.design.mainframe.ElementCasePane; import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.mainframe.JSliderPane;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.grid.selection.CellSelection; import com.fr.grid.selection.CellSelection;
@ -125,8 +124,7 @@ public class GridUtils {
*/ */
public static double[] caculateFloatElementLocations(FloatElement floatElement, DynamicUnitList columnWidthList, DynamicUnitList rowHeightList, public static double[] caculateFloatElementLocations(FloatElement floatElement, DynamicUnitList columnWidthList, DynamicUnitList rowHeightList,
int verticalValue, int horizentalValue) { 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 floatX = columnWidthList.getRangeValue(horizentalValue, 0).toPixD(resolution) + floatElement.getLeftDistance().toPixD(resolution);
double floatY = rowHeightList.getRangeValue(verticalValue, 0).toPixD(resolution) + floatElement.getTopDistance().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) { private static int cc_selected_column_or_row(double mouseEvtPosition, int beginValue, int value, DynamicUnitList sizeList) {
double tmpIntIndex = 0; double tmpIntIndex = 0;
int selectedCellIndex = 0; int selectedCellIndex = 0;
int resolution = (int) (ScreenResolution.getScreenResolution() * JSliderPane.getInstance().resolutionTimes); int resolution = ScreenResolution.getScreenResolution();
if (mouseEvtPosition < 0) { if (mouseEvtPosition < 0) {
selectedCellIndex = value; selectedCellIndex = value;
for (; true; selectedCellIndex--) { for (; true; selectedCellIndex--) {
@ -487,4 +485,4 @@ public class GridUtils {
} }
} }

11
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.ElementCasePane;
import com.fr.design.mainframe.ElementCasePaneAuthorityEditPane; import com.fr.design.mainframe.ElementCasePaneAuthorityEditPane;
import com.fr.design.mainframe.FormScrollBar; 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.JTemplate;
import com.fr.design.mainframe.NoSupportAuthorityEdit; import com.fr.design.mainframe.NoSupportAuthorityEdit;
import com.fr.design.mainframe.ReportComponent; import com.fr.design.mainframe.ReportComponent;
@ -124,8 +124,7 @@ public class PolyDesigner extends ReportComponent<PolyWorkSheet, PolyElementCase
private PolyComponentsBar polyComponentsBar = new PolyComponentsBar(); private PolyComponentsBar polyComponentsBar = new PolyComponentsBar();
private JComponent[] toolBarComponent = null; private JComponent[] toolBarComponent = null;
private JPanel ployareaPane; private JPanel ployareaPane;
private JSliderPane jSliderContainer; private int resolution = ScreenResolution.getScreenResolution() ;
private int resolution = (int) (ScreenResolution.getScreenResolution() * JSliderPane.getInstance().resolutionTimes);
private float time; private float time;
public PolyDesigner(PolyWorkSheet report) { public PolyDesigner(PolyWorkSheet report) {
@ -863,8 +862,8 @@ public class PolyDesigner extends ReportComponent<PolyWorkSheet, PolyElementCase
@Override @Override
public void updateJSliderValue() { public void updateJSliderValue() {
ReportComponentComposite reportComposite = (ReportComponentComposite) HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().getCurrentReportComponentPane(); ReportComponentComposite reportComposite = (ReportComponentComposite) HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().getCurrentReportComponentPane();
JSliderPane jSliderContainer = reportComposite.getjSliderContainer(); JFormSliderPane jSliderContainer = reportComposite.getjSliderContainer();
jSliderContainer.getShowVal().setValue((int) Math.ceil((double) this.resolution * HUND / ScreenResolution.getScreenResolution())); jSliderContainer.setShowValue((int) Math.ceil((double) this.resolution * HUND / ScreenResolution.getScreenResolution()));
} }
@ -1063,4 +1062,4 @@ public class PolyDesigner extends ReportComponent<PolyWorkSheet, PolyElementCase
return false; return false;
} }
} }

Loading…
Cancel
Save