Browse Source

Pull request #4916: REPORT-53175【10.0.18】组件背景分离为标题/背景/边框

Merge in DESIGN/design from ~STARRYI/design:feature/10.0 to feature/10.0

* commit '26f2825ccb916aa583153994b5da3df636f7b5cb':
  REPORT-55149【组件背景分离】组件复用-图表块没看到内边距设置项
  REPORT-55150 【组件背景分离】组件复用-标题设置下划线,选择下划线样式,目前web预览,不管选的什么下划线样式都显示的是单横线效果
  REPORT-55121 【组件背景分离】组件复用-点九图填充设置弹窗的关闭按钮和取消按钮,其实还是确认&保存修改的效果
  REPORT-53175 【10.0.18】组件背景分离为标题/背景/边框
  REPORT-53175【10.0.18】组件背景分离为标题/背景/边框
  REPORT-55089 组件背景分离】组件复用-标题图案的图片预览图,和交互文档里定的悬浮时出现删除按钮和不透明遮罩预期效果不同
  REPORT-53175【10.0.18】组件背景分离为标题/背景/边框
  REPORT-55114 【组件背景分离】组件复用-点九图分割线拖动到边缘时,就无法再次选中分割线了
  REPORT-55112 【组件背景分离】组件复用-点九图填充设置弹窗,分割线拖拽到靠近边缘时,像素值就被遮挡看不到了
  REPORT-55108 【组件背景分离】组件复用-边框选择自定义图片,但还没具体选择某张图片时,此时的点九图填充设置按钮应该先灰化
  REPORT-55107 【组件背景分离】组件复用-背景样式 边框选择自定义图片时,下方应出现不透明度设置,目前没有
feature/10.0
starryi 3 years ago
parent
commit
a344ee7674
  1. 2
      designer-base/src/main/java/com/fr/design/gui/frpane/UIPercentDragPane.java
  2. 17
      designer-form/src/main/java/com/fr/design/designer/beans/events/DesignerEditor.java
  3. 9
      designer-form/src/main/java/com/fr/design/designer/creator/XChartEditor.java
  4. 1
      designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java
  5. 3
      designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteLayout.java
  6. 216
      designer-form/src/main/java/com/fr/design/designer/ui/PopupControlPanel.java
  7. 5
      designer-form/src/main/java/com/fr/design/designer/ui/SelectedPopupDialog.java
  8. 76
      designer-form/src/main/java/com/fr/design/gui/xpane/BorderLineAndImagePane.java
  9. 31
      designer-form/src/main/java/com/fr/design/gui/xpane/LayoutStylePane.java
  10. 11
      designer-form/src/main/java/com/fr/design/gui/xpane/TitleInsetImagePane.java
  11. 5
      designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java
  12. 4
      designer-form/src/main/java/com/fr/design/widget/FormWidgetDefinePaneFactoryBase.java
  13. 4
      designer-form/src/main/java/com/fr/design/widget/ui/designer/component/WidgetBoundPane.java
  14. 57
      designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/ChartEditorDefinePane.java

2
designer-base/src/main/java/com/fr/design/gui/frpane/UIPercentDragPane.java

@ -25,6 +25,6 @@ public class UIPercentDragPane extends JPanel {
}
public double updateBean() {
return dragPane.updateBean() * 100;
return dragPane.updateBean() / 100.0;
}
}

17
designer-form/src/main/java/com/fr/design/designer/beans/events/DesignerEditor.java

@ -1,5 +1,6 @@
package com.fr.design.designer.beans.events;
import com.fr.form.ui.PaddingMargin;
import com.fr.stable.core.PropertyChangeAdapter;
import com.fr.stable.core.PropertyChangeListener;
import com.fr.design.utils.gui.LayoutUtils;
@ -76,6 +77,22 @@ public class DesignerEditor<T extends JComponent> implements PropertyChangeListe
}
}
public void paintEditor(Graphics g, Dimension size, PaddingMargin margin) {
if (this.comp != null) {
int marginLeft = margin != null ? margin.getLeft() : 0;
int marginTop = margin != null ? margin.getTop() : 0;
int marginRight = margin != null ? margin.getRight() : 0;
int marginBottom = margin != null ? margin.getBottom() : 0;
int horizonMargin = marginLeft + marginRight;
int verticalMargin = marginTop + marginBottom;
comp.setSize(new Dimension(size.width - 2 - horizonMargin, size.height - 2 - verticalMargin));
LayoutUtils.layoutContainer(comp);
Graphics clipg = g.create(1 + marginLeft, 1 + marginTop, size.width, size.height);
this.comp.paint(clipg);
}
}
public T getEditorTarget() {
return comp;
}

9
designer-form/src/main/java/com/fr/design/designer/creator/XChartEditor.java

@ -20,6 +20,7 @@ import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.widget.editors.WLayoutBorderStyleEditor;
import com.fr.design.module.DesignModuleFactory;
import com.fr.form.ui.BaseChartEditor;
import com.fr.form.ui.PaddingMargin;
import com.fr.form.ui.Widget;
import com.fr.stable.Constants;
import com.fr.stable.core.PropertyChangeAdapter;
@ -228,9 +229,13 @@ public class XChartEditor extends XBorderStyleWidgetCreator {
* 渲染Painter
*/
public void paint(Graphics g) {
designerEditor.paintEditor(g, this.getSize());
Dimension size = getSize();
PaddingMargin margin = toData().getMargin();
designerEditor.paintEditor(g, size, margin);
if (coverPanel != null) {
coverPanel.setSize(this.getSize());
int horizonMargin = margin != null ? margin.getLeft() + margin.getRight() : 0;
int verticalMargin = margin != null ? margin.getTop() + margin.getBottom() : 0;
coverPanel.setSize(size.width - horizonMargin, size.height - verticalMargin);
}
super.paint(g);
if (isEditing) {

1
designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java

@ -777,6 +777,7 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
int extraX = (int) ((bounds.x + bounds.width + SelectedPopupDialog.OFFSET_X) * designer.getScale());
int extraY = (int) (bounds.y * designer.getScale());
popup.setLocation(designer.getLocationOnScreen().x + designer.getPaintX() + extraX, designer.getLocationOnScreen().y + designer.getPaintY() + extraY);
popup.updatePane(designer);
popup.setVisible(selected && accept);
popup.setRelativeBounds(bounds);
}

3
designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteLayout.java

@ -204,7 +204,8 @@ public class XWAbsoluteLayout extends XLayoutContainer {
for (int index = 0, n = this.getComponentCount(); index < n; index++) {
XCreator creator = (XCreator) this.getComponent(index);
if (creator.toData().isAspectRatioLocked()) {
double percent = Math.min(percentW, percentH);
// 因为percentW/H是旧尺寸与新尺寸之间的比例,所以实现组件选择宽度和高度中较小的缩放比例的规则,需要使用Math.max
double percent = Math.max(percentW, percentH);
percentW = percentH = percent;
}
BoundsWidget wgt = (BoundsWidget) layout.getBoundsWidget(creator.toData());

216
designer-form/src/main/java/com/fr/design/designer/ui/PopupControlPanel.java

@ -1,35 +1,27 @@
package com.fr.design.designer.ui;
import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.adapters.layout.FRAbsoluteLayoutAdapter;
import com.fr.design.designer.beans.events.DesignerEvent;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.VerticalFlowLayout;
import com.fr.design.mainframe.CoverReportPane;
import com.fr.design.mainframe.EditingMouseListener;
import com.fr.design.mainframe.FormDesigner;
import com.fr.general.IOUtils;
import com.fr.stable.ArrayUtils;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Insets;
import java.awt.LayoutManager;
import java.awt.Rectangle;
import java.awt.RenderingHints;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.AbstractButton;
import javax.swing.Icon;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JToggleButton;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.util.ArrayList;
import java.util.List;
/**
* @author hades
@ -40,25 +32,39 @@ public class PopupControlPanel extends JPanel {
private static final int ARC_VALUE = 4;
private static final Color FILLED_COLOR = new Color(60, 63, 65);
private static final int V_GAP = 10;
private static final int H_GAP = 2;
private static final int BUTTON_SIZE = 16;
private static final int BUTTON_MARGIN = 4;
private static final int PANE_WIDTH = BUTTON_SIZE + BUTTON_MARGIN * 2; // 24
private Dimension defaultDimension = new Dimension(20, 60);
private final Dimension defaultDimension = new Dimension(PANE_WIDTH, 0);
private Rectangle rectangle;
private final List<JComponent> buttons = new ArrayList<>();
private final JButton editButton;
private final JButton settingButton;
private final JToggleButton toggleButton;
private final XCreator creator;
private final UILabel firstLabel;
private final UILabel secondLabel;
public PopupControlPanel(XCreator creator, FormDesigner designer) {
if (creator.isShared()) {
defaultDimension = new Dimension(20, 85);
}
setLayout(getCustomLayout());
setLayout(new VerticalFlowLayout(VerticalFlowLayout.TOP, 0, 0));
setBorder(BorderFactory.createEmptyBorder());
this.creator = creator;
editButton = createNormalButton(IOUtils.readIcon("/com/fr/design/images/control/show_edit.png"), Toolkit.i18nText("Fine-Design_Form_Edit_Widget"));
editButton = createEditButton(designer);
toggleButton = createAspectRatioLockedButton(designer);
settingButton = createSettingButton();
addButton(editButton, 0);
addButton(toggleButton, 1);
addButton(settingButton, 2);
setButtonVisible(editButton, true);
setButtonVisible(toggleButton, false);
setButtonVisible(settingButton, false);
}
private JButton createEditButton(FormDesigner designer) {
JButton editButton = createNormalButton(IOUtils.readIcon("/com/fr/design/images/control/show_edit.png"), Toolkit.i18nText("Fine-Design_Form_Edit_Widget"));
editButton.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
@ -71,102 +77,99 @@ public class PopupControlPanel extends JPanel {
}
}
});
settingButton = createNormalButton(IOUtils.readIcon("/com/fr/design/images/control/show_setting.png"), Toolkit.i18nText("Fine-Design_Share_Help_Settings"));
return editButton;
}
settingButton.addActionListener(new ActionListener() {
private JToggleButton createAspectRatioLockedButton(FormDesigner designer) {
JToggleButton button = new JToggleButton(IOUtils.readIcon("/com/fr/design/images/control/edit_unlock.png"));
initButtonStyle(button);
button.setSelectedIcon(IOUtils.readIcon("com/fr/design/images/control/edit_lock.png"));
button.setToolTipText(Toolkit.i18nText("Fine-Design_Form_UnLock_Widget_Ratio"));
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
CoverReportPane.showShareConfig(creator.toData());
}
});
toggleButton = new JToggleButton(IOUtils.readIcon("/com/fr/design/images/control/edit_lock.png"));
initButtonStyle(toggleButton);
toggleButton.setSelectedIcon(IOUtils.readIcon("com/fr/design/images/control/edit_unlock.png"));
toggleButton.setToolTipText(Toolkit.i18nText("Fine-Design_Form_Lock_Widget_Ratio"));
toggleButton.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
JToggleButton toggleBtn = (JToggleButton) e.getSource();
String toolTipText = toggleBtn.isSelected() ? Toolkit.i18nText("Fine-Design_Form_UnLock_Widget_Ratio") : Toolkit.i18nText("Fine-Design_Form_Lock_Widget_Ratio");
String toolTipText = toggleBtn.isSelected() ? Toolkit.i18nText("Fine-Design_Form_Lock_Widget_Ratio") : Toolkit.i18nText("Fine-Design_Form_UnLock_Widget_Ratio");
toggleBtn.setToolTipText(toolTipText);
creator.toData().setAspectRatioLocked(toggleBtn.isSelected());
designer.getEditListenerTable().fireCreatorModified(creator, DesignerEvent.CREATOR_RESIZED);
}
});
firstLabel = createLabel();
secondLabel = createLabel();
add(editButton);
add(toggleButton);
add(settingButton);
add(firstLabel);
add(secondLabel);
return button;
}
protected LayoutManager getCustomLayout() {
return new LayoutManager() {
private JButton createSettingButton() {
JButton settingButton = createNormalButton(IOUtils.readIcon("/com/fr/design/images/control/show_setting.png"), Toolkit.i18nText("Fine-Design_Share_Help_Settings"));
settingButton.addActionListener(new ActionListener() {
@Override
public void removeLayoutComponent(Component comp) {
public void actionPerformed(ActionEvent e) {
CoverReportPane.showShareConfig(creator.toData());
}
});
return settingButton;
}
@Override
public Dimension preferredLayoutSize(Container parent) {
return defaultDimension;
private void addButton(JComponent component, int index) {
buttons.add(index, component);
if (index > 0) {
this.add(new SeparatorLabel(), index * 2 - 1);
}
this.add(component, index * 2);
}
@Override
public Dimension minimumLayoutSize(Container parent) {
return null;
private void setButtonVisible(JComponent component, boolean visible) {
int index = buttons.indexOf(component);
boolean hasVisibleButtonBeforeCurrent = false;
for (int i = 0; i < index; i++) {
if (buttons.get(i).isVisible()) {
hasVisibleButtonBeforeCurrent = true;
break;
}
}
@Override
public void layoutContainer(Container parent) {
int width = parent.getPreferredSize().width;
int buttonWidth = editButton.getPreferredSize().width;
int buttonHeight = editButton.getPreferredSize().height;
int x = (width - buttonWidth) / 2;
editButton.setBounds(x, V_GAP, buttonWidth, buttonHeight);
firstLabel.setBounds(x, V_GAP + editButton.getHeight() + V_GAP / 2, buttonWidth, buttonHeight);
toggleButton.setBounds(x, V_GAP * 2 + editButton.getHeight(), buttonWidth, buttonHeight);
if (creator.isShared()) {
secondLabel.setBounds(x, V_GAP * 2 + editButton.getHeight() + toggleButton.getHeight() + V_GAP / 2, buttonWidth, buttonHeight);
settingButton.setBounds(x, V_GAP * 3 + editButton.getHeight() + toggleButton.getHeight(), buttonWidth, buttonHeight);
if (hasVisibleButtonBeforeCurrent) {
buttons.get(index).setVisible(visible);
getComponent(2 * index - 1).setVisible(visible);
return;
}
// 在当前按钮之前没有可见的按钮了
if (index > 0) {
getComponent(2 * index - 1).setVisible(false);
}
buttons.get(index).setVisible(true);
@Override
public void addLayoutComponent(String name, Component comp) {
if (!visible) {
// 如果当前按钮设置为不可见,且在当前按钮之前的其他按钮也不可见,则下一个可见按钮前无分割线
for (int i = index + 1; i < buttons.size(); i++) {
if (buttons.get(i).isVisible()) {
if (i > 0) {
getComponent(2 * i - 1).setVisible(false);
}
break;
}
}
}
};
}
private JButton createNormalButton(Icon icon, String toolTipText) {
JButton button = new JButton(icon);
button.setPreferredSize(new Dimension(BUTTON_SIZE + 2 * BUTTON_MARGIN, BUTTON_SIZE + 2 * BUTTON_MARGIN));
button.setBorder(BorderFactory.createEmptyBorder(BUTTON_MARGIN, BUTTON_MARGIN, BUTTON_MARGIN, BUTTON_MARGIN));
initButtonStyle(button);
button.setToolTipText(toolTipText);
return button;
}
private void initButtonStyle(AbstractButton button) {
button.setPreferredSize(new Dimension(BUTTON_SIZE + 2 * BUTTON_MARGIN, BUTTON_SIZE + 2 * BUTTON_MARGIN));
button.setBorder(BorderFactory.createEmptyBorder(BUTTON_MARGIN, BUTTON_MARGIN, BUTTON_MARGIN, BUTTON_MARGIN));
button.setBorderPainted(false);
button.setBorder(null);
button.setMargin(new Insets(0, 0, 0, 0));
button.setContentAreaFilled(false);
}
private UILabel createLabel() {
return new UILabel() {
@Override
public void paint(Graphics g) {
super.paint(g);
Graphics2D g2d = (Graphics2D) g;
g2d.setColor(Color.WHITE);
g2d.drawLine(H_GAP, 0, toggleButton.getWidth() - H_GAP, 0);
}
};
}
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
@ -188,4 +191,41 @@ public class PopupControlPanel extends JPanel {
this.rectangle = rectangle;
}
public void updatePane(FormDesigner designer) {
setButtonVisible(settingButton, creator.isShared());
setButtonVisible(toggleButton, AdapterBus.searchLayoutAdapter(designer, creator) instanceof FRAbsoluteLayoutAdapter);
toggleButton.setSelected(creator.toData().isAspectRatioLocked());
updateDimension();
}
private void updateDimension() {
int height = 0;
for (int i = 0; i < buttons.size(); i++) {
JComponent component = buttons.get(i);
if (component.isVisible()) {
if (i > 0) {
height += 1;
}
height += component.getHeight();
}
}
height += 2;
defaultDimension.height = height;
}
private static class SeparatorLabel extends UILabel {
public SeparatorLabel() {
setPreferredSize(new Dimension(PANE_WIDTH, 1));
}
@Override
public void paint(Graphics g) {
super.paint(g);
Graphics2D g2d = (Graphics2D) g;
g2d.setColor(Color.WHITE);
g2d.drawLine(BUTTON_MARGIN, 0, getWidth() - BUTTON_MARGIN, 0);
}
}
}

5
designer-form/src/main/java/com/fr/design/designer/ui/SelectedPopupDialog.java

@ -29,6 +29,11 @@ public class SelectedPopupDialog extends JDialog {
this.setSize(controlPanel.getDefaultDimension());
}
public void updatePane(FormDesigner designer) {
controlPanel.updatePane(designer);
this.setSize(controlPanel.getDefaultDimension());
}
public void setRelativeBounds(Rectangle rectangle) {
this.controlPanel.setRelativeBounds(rectangle);
}

76
designer-form/src/main/java/com/fr/design/gui/xpane/BorderLineAndImagePane.java

@ -53,6 +53,7 @@ import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Arrays;
/**
* @author Starryi
@ -79,10 +80,7 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
private NinePointImageTweakDialogPane tweakPane;
private ImageFileChooser imageFileChooser;
private int ninePointLeft = -1;
private int ninePointTop = -1;
private int ninePointRight = -1;
private int ninePointBottom = -1;
private int[] ninePoint = new int[] {-1, -1, -1, -1};
public BorderLineAndImagePane() {
this.initComponents();
@ -146,7 +144,7 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
private JPanel createBorderImageComposePane() {
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] rowSize = {p, p, p};
double[] rowSize = {p, p, p, p, p};
double[] columnSize = {SETTING_LABEL_WIDTH, f};
JPanel borderedImagePreviewPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
@ -219,6 +217,7 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
}
if (!borderLineCombo.isSelectedBorderImage()) {
imagePreviewPane.setImageWithSuffix(null);
tweakNinePointButton.setEnabled(false);
}
fireStateChanged();
@ -241,9 +240,13 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
@Override
public void stateChanged(ChangeEvent e) {
Image image = imagePreviewPane.getImage();
ninePointLeft = ninePointRight = (image != null ? image.getWidth(null) / 3 : -1);
ninePointTop = ninePointBottom = (image != null ? image.getHeight(null) / 3 : -1);
ninePoint = new int[4];
ninePoint[0] = ninePoint[2] = (image != null ? image.getWidth(null) / 3 : -1);
ninePoint[1] = ninePoint[3] = (image != null ? image.getHeight(null) / 3 : -1);
borderImageOpacityPane.populateBean(1.0);
if (image != null) {
tweakNinePointButton.setEnabled(true);
}
fireStateChanged();
}
@ -256,10 +259,12 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
initNinePointTweakPaneIfNotExist();
if (imagePreviewPane.getImage() != null) {
tweakPane.previewPane.setNinePoint(ninePoint);
BasicDialog dialog = tweakPane.showWindow(SwingUtilities.getWindowAncestor(BorderLineAndImagePane.this));
dialog.addDialogActionListener(new DialogActionAdapter() {
@Override
public void doOk() {
ninePoint = Arrays.copyOf(tweakPane.previewPane.getNinePoint(), 4);
fireStateChanged();
}
});
@ -285,15 +290,14 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
if (image != null) {
this.borderLineCombo.selectBorderImage();
this.imagePreviewPane.setImageWithSuffix(((ImageBackground) borderImage).getImageWithSuffix());
this.tweakNinePointButton.setEnabled(true);
this.borderImageOpacityPane.populateBean(style.getBorderImageOpacity());
if (ninePoint != null && ninePoint.length == 4 && ninePoint[0] > 0 && ninePoint[1] > 0 && ninePoint[2] > 0 && ninePoint[3] > 0) {
ninePointLeft = ninePoint[0];
ninePointTop = ninePoint[1];
ninePointRight = ninePoint[2];
ninePointBottom = ninePoint[3];
this.ninePoint = Arrays.copyOf(ninePoint, 4);
} else {
ninePointLeft = ninePointRight = image.getWidth(null) / 3;
ninePointTop = ninePointBottom = image.getHeight(null) / 3;
this.ninePoint = new int[4];
this.ninePoint[0] = this.ninePoint[2] = image.getWidth(null) / 3;
this.ninePoint[1] = this.ninePoint[3] = image.getHeight(null) / 3;
}
getComponent(1).setVisible(false);
@ -326,7 +330,7 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
Image image = this.imagePreviewPane.getImage();
if (image != null) {
ImageBackground newImageBackground = new ImageFileBackground(this.imagePreviewPane.getImageWithSuffix(), Constants.IMAGE_EXTEND);
newImageBackground.setNinePoint(new int[] { ninePointLeft, ninePointTop, ninePointRight, ninePointBottom });
newImageBackground.setNinePoint(Arrays.copyOf(ninePoint, 4));
style.setBorderImage(newImageBackground);
style.setBorderImageOpacity((float)borderImageOpacityPane.updateBean());
}
@ -403,7 +407,7 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
}
private class NinePointImageTweakDialogPane extends BasicPane {
private final NinePointLinePreviewPane previewPane = new NinePointLinePreviewPane();
public final NinePointLinePreviewPane previewPane = new NinePointLinePreviewPane();
public NinePointImageTweakDialogPane() {
this.initComponents();
@ -439,6 +443,11 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
public final Color TEXT_COLOR = Color.WHITE;
public final int PADDING = 15;
private int ninePointLeft = -1;
private int ninePointTop = -1;
private int ninePointRight = -1;
private int ninePointBottom = -1;
private int imgWidth;
private int imgHeight;
private int scaleImgWidth;
@ -468,7 +477,7 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
int autoFixAreaX = PADDING;
int autoFixAreaY = PADDING;
if (imgWidth / imgHeight > autoFixAreaWidth / autoFixAreaHeight) {
if ((imgWidth * 1.0F / imgHeight) > (autoFixAreaWidth * 1.0F / autoFixAreaHeight)) {
scaleImgWidth = autoFixAreaWidth;
scaleImgHeight = (int) (1.0F * scaleImgWidth * imgHeight / imgWidth);
scaleImgX = autoFixAreaX;
@ -489,28 +498,33 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
int scaleRight = (int) (ninePointRight * scale);
int scaleBottom = (int) (ninePointBottom * scale);
double topYInPane = scaleImgY + scaleTop;
double bottomYInPane = scaleImgY + scaleImgHeight - scaleBottom;
double leftXInPane = scaleImgX + scaleLeft;
double rightXInPane = scaleImgX + scaleImgWidth - scaleRight;
g2d.setColor(PATCH_COLOR);
// draw horizontal patch
GraphDrawHelper.fillRect(g2d, 0, scaleImgY + scaleTop, getWidth(), scaleImgHeight - scaleTop - scaleBottom);
GraphDrawHelper.fillRect(g2d, 0, topYInPane, getWidth(), scaleImgHeight - scaleTop - scaleBottom);
// draw vertical patch
GraphDrawHelper.fillRect(g2d, scaleImgX + scaleLeft, 0,scaleImgWidth - scaleLeft - scaleRight, getHeight());
g2d.setColor(DIVIDER_COLOR);
// draw top divider
GraphDrawHelper.drawLine(g2d, 0, scaleImgY + scaleTop, getWidth(), scaleImgY + scaleTop);
GraphDrawHelper.drawLine(g2d, 0, topYInPane, getWidth(), topYInPane);
// draw bottom divider
GraphDrawHelper.drawLine(g2d, 0, scaleImgY + scaleImgHeight - scaleBottom, getWidth(), scaleImgY + scaleImgHeight - scaleBottom);
GraphDrawHelper.drawLine(g2d, 0, bottomYInPane, getWidth(), bottomYInPane);
// draw left divider
GraphDrawHelper.drawLine(g2d, scaleImgX + scaleLeft, 0, scaleImgX + scaleLeft, getHeight());
GraphDrawHelper.drawLine(g2d, leftXInPane, 0, leftXInPane, getHeight());
// draw right divider
GraphDrawHelper.drawLine(g2d, scaleImgX + scaleImgWidth - scaleRight, 0, scaleImgX + scaleImgWidth - scaleRight, getHeight());
GraphDrawHelper.drawLine(g2d, rightXInPane, 0, rightXInPane, getHeight());
g2d.setColor(TEXT_COLOR);
// draw nine point info
GraphDrawHelper.drawString(g2d, Integer.toString(ninePointTop), scaleImgX + (scaleImgWidth + scaleLeft - scaleRight) / 2.0, (scaleImgY + scaleTop) / 2.0);
GraphDrawHelper.drawString(g2d, Integer.toString(ninePointBottom), scaleImgX + scaleLeft + (scaleImgWidth - scaleLeft - scaleRight) / 2.0, scaleImgY + scaleImgHeight - (scaleBottom - PADDING) / 2.0);
GraphDrawHelper.drawString(g2d, Integer.toString(ninePointLeft), (scaleImgX + scaleLeft) / 2.0, scaleImgY + (scaleImgHeight + scaleTop - scaleBottom) / 2.0);
GraphDrawHelper.drawString(g2d, Integer.toString(ninePointRight), scaleImgX + scaleImgWidth - (scaleRight - PADDING) / 2.0, scaleImgY + (scaleImgHeight + scaleTop - scaleBottom) / 2.0);
GraphDrawHelper.drawString(g2d, Integer.toString(ninePointTop), (leftXInPane + rightXInPane) / 2.0F, topYInPane / 2.0);
GraphDrawHelper.drawString(g2d, Integer.toString(ninePointBottom), (leftXInPane + rightXInPane) / 2.0F, (bottomYInPane + getHeight()) / 2.0);
GraphDrawHelper.drawString(g2d, Integer.toString(ninePointLeft), leftXInPane / 2.0, (topYInPane + bottomYInPane) / 2.0);
GraphDrawHelper.drawString(g2d, Integer.toString(ninePointRight), (rightXInPane + getWidth()) / 2.0, (topYInPane + bottomYInPane) / 2.0);
}
@Override
@ -619,5 +633,17 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
public void mouseExited(MouseEvent e) {
}
public void setNinePoint(int[] ninePoint) {
ninePointLeft = ninePoint[0];
ninePointTop = ninePoint[1];
ninePointRight = ninePoint[2];
ninePointBottom = ninePoint[3];
}
public int[] getNinePoint() {
return new int[] { ninePointLeft, ninePointTop, ninePointRight, ninePointBottom };
}
}
}

31
designer-form/src/main/java/com/fr/design/gui/xpane/LayoutStylePane.java

@ -81,7 +81,7 @@ public class LayoutStylePane extends BasicBeanPane<LayoutBorderStyle> {
private UIToggleButton titleFontBoldButton;
private UIToggleButton titleFontItalicButton;
private UIToggleButton titleFontUnderlineButton;
private LineComboBox titleFontUnderlineCombo;
// private LineComboBox titleFontUnderlineCombo; // 目前前端仅支持短横线类型的下划线,因此设计器端暂时就不展示线型选择框了,待后续优化
// 标题图文混排
protected TitleInsetImagePane titleInsetImagePane;
//对齐方式
@ -211,8 +211,8 @@ public class LayoutStylePane extends BasicBeanPane<LayoutBorderStyle> {
titleFontUnderlineButton.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Underline"));
titleFontUnderlineButton.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Underline"));
titleFontUnderlineCombo = new LineComboBox(UIConstants.BORDER_LINE_STYLE_ARRAY);
titleFontUnderlineCombo.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Line_Style"));
// titleFontUnderlineCombo = new LineComboBox(UIConstants.BORDER_LINE_STYLE_ARRAY);
// titleFontUnderlineCombo.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Line_Style"));
titleInsetImagePane = new TitleInsetImagePane();
@ -294,15 +294,15 @@ public class LayoutStylePane extends BasicBeanPane<LayoutBorderStyle> {
JPanel containerPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
containerPane.add(buttonPane, BorderLayout.NORTH);
containerPane.add(titleFontUnderlineCombo, BorderLayout.CENTER);
// containerPane.add(titleFontUnderlineCombo, BorderLayout.CENTER);
titleFontUnderlineCombo.setVisible(false);
titleFontUnderlineButton.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
titleFontUnderlineCombo.setVisible(titleFontUnderlineButton.isSelected());
}
});
// titleFontUnderlineCombo.setVisible(false);
// titleFontUnderlineButton.addChangeListener(new ChangeListener() {
// @Override
// public void stateChanged(ChangeEvent e) {
// titleFontUnderlineCombo.setVisible(titleFontUnderlineButton.isSelected());
// }
// });
return containerPane;
}
@ -349,7 +349,8 @@ public class LayoutStylePane extends BasicBeanPane<LayoutBorderStyle> {
frFont = frFont.applyName(titleFontFamilyComboBox.getSelectedItem().toString());
frFont = frFont.applyForeground(titleFontColorSelectPane.getColor());
frFont = updateTitleFontItalicBold(frFont);
int line = titleFontUnderlineButton.isSelected() ? this.titleFontUnderlineCombo.getSelectedLineStyle() : Constants.LINE_NONE;
// int line = titleFontUnderlineButton.isSelected() ? this.titleFontUnderlineCombo.getSelectedLineStyle() : Constants.LINE_NONE;
int line = titleFontUnderlineButton.isSelected() ? Constants.LINE_THIN : Constants.LINE_NONE;
frFont = frFont.applyUnderline(line);
title.setFrFont(frFont);
title.setPosition((Integer) titleAlignPane.getSelectedItem());
@ -425,11 +426,11 @@ public class LayoutStylePane extends BasicBeanPane<LayoutBorderStyle> {
int line = frFont.getUnderline();
if (line == Constants.LINE_NONE) {
titleFontUnderlineButton.setSelected(false);
titleFontUnderlineCombo.setVisible(false);
// titleFontUnderlineCombo.setVisible(false);
} else {
titleFontUnderlineButton.setSelected(true);
titleFontUnderlineCombo.setVisible(true);
this.titleFontUnderlineCombo.setSelectedLineStyle(line);
// titleFontUnderlineCombo.setVisible(true);
// this.titleFontUnderlineCombo.setSelectedLineStyle(line);
}
titleAlignPane.setSelectedItem(widgetTitle.getPosition());

11
designer-form/src/main/java/com/fr/design/gui/xpane/TitleInsetImagePane.java

@ -47,6 +47,7 @@ public class TitleInsetImagePane extends JPanel implements UIObserver {
private final int SETTING_LABEL_WIDTH = LayoutStylePane.SETTING_LABEL_WIDTH;
private final int DELETE_BUTTON_SIZE = 24;
private final int IMAGE_PREVIEW_SIZE = 145;
private final Color IMAGE_PREVIEW_OVERLAY_COLOR = new Color(255, 255, 255, 51);
private final Style DEFAULT_IMAGE_LAYOUT_STYLE = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_DEFAULT);
private final int DEFAULT_INSET_LOCATION_INDEX = 0;
private final int DEFAULT_INSET_PADDING = 10;
@ -88,17 +89,24 @@ public class TitleInsetImagePane extends JPanel implements UIObserver {
deletableImagePreviewPane.setLayout(null);
deletableImagePreviewPane.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, 5));
deletableImagePreviewPane.setPreferredSize(new Dimension(IMAGE_PREVIEW_SIZE, IMAGE_PREVIEW_SIZE));
JPanel overlayPane = new JPanel();
overlayPane.setPreferredSize(new Dimension(IMAGE_PREVIEW_SIZE - 2, IMAGE_PREVIEW_SIZE - 2));
overlayPane.setBackground(IMAGE_PREVIEW_OVERLAY_COLOR);
imagePreviewPane.setBounds(0, 0, IMAGE_PREVIEW_SIZE, IMAGE_PREVIEW_SIZE);
overlayPane.setBounds(1, 1, IMAGE_PREVIEW_SIZE - 2, IMAGE_PREVIEW_SIZE - 2);
imageDeleteButton.setBounds(IMAGE_PREVIEW_SIZE - DELETE_BUTTON_SIZE, 0, DELETE_BUTTON_SIZE, DELETE_BUTTON_SIZE);
deletableImagePreviewPane.add(imageDeleteButton, 0);
deletableImagePreviewPane.add(imagePreviewPane, 1);
deletableImagePreviewPane.add(overlayPane, 1);
deletableImagePreviewPane.add(imagePreviewPane, 2);
overlayPane.setVisible(false);
imageDeleteButton.setVisible(false);
imageDeleteButton.setEnabled(false);
deletableImagePreviewPane.addMouseListener(new MouseAdapter() {
@Override
public void mouseEntered(MouseEvent e) {
super.mouseEntered(e);
overlayPane.setVisible(true);
imageDeleteButton.setVisible(true);
imageDeleteButton.setEnabled(true);
}
@ -109,6 +117,7 @@ public class TitleInsetImagePane extends JPanel implements UIObserver {
int x = e.getX();
int y = e.getY();
if (x <= 0 || getWidth() <= x || y <= 0 || y >= getHeight()) {
overlayPane.setVisible(false);
imageDeleteButton.setVisible(false);
imageDeleteButton.setEnabled(false);
}

5
designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java

@ -110,6 +110,11 @@ public class FormCreatorDropTarget extends DropTarget {
//图表埋点
dealChartBuryingPoint(widget);
if (addingXCreator.isShared()) {
if (container.acceptType(XWAbsoluteLayout.class)) {
// 绝对布局中新添加的共享组件默认锁定尺寸比例
addingXCreator.toData().setAspectRatioLocked(true);
}
String shareId = addingXCreator.getShareId();
SharableEditorProvider sharableEditor = ShareLoader.getLoader().getSharedElCaseEditorById(shareId);
SharableWidgetProvider bindInfo = ShareLoader.getLoader().getElCaseBindInfoById(shareId);

4
designer-form/src/main/java/com/fr/design/widget/FormWidgetDefinePaneFactoryBase.java

@ -24,7 +24,7 @@ import com.fr.design.widget.ui.designer.TreeComboBoxEditorDefinePane;
import com.fr.design.widget.ui.designer.TreeEditorDefinePane;
import com.fr.design.widget.ui.designer.UserEditorDefinePane;
import com.fr.design.widget.ui.designer.WidgetDefinePane;
import com.fr.design.widget.ui.designer.layout.BorderStyleWidgetDefinePane;
import com.fr.design.widget.ui.designer.layout.ChartEditorDefinePane;
import com.fr.design.widget.ui.designer.layout.ElementEditorDefinePane;
import com.fr.design.widget.ui.designer.layout.FRAbsoluteBodyLayoutDefinePane;
import com.fr.design.widget.ui.designer.layout.FRAbsoluteLayoutDefinePane;
@ -107,7 +107,7 @@ public class FormWidgetDefinePaneFactoryBase {
defineMap.put(FormSubmitButton.class, new Appearance(FreeButtonDefinePane.class, WidgetConstants.BUTTON + ""));
defineMap.put(WFitLayout.class, new Appearance(FRFitLayoutDefinePane.class, "wFitLayout"));
if (StableFactory.getMarkedClass(BridgeMark.CHART_EDITOR, AbstractBorderStyleWidget.class) != null) {
defineMap.put(StableFactory.getMarkedClass(BridgeMark.CHART_EDITOR, AbstractBorderStyleWidget.class), new Appearance(BorderStyleWidgetDefinePane.class, "chartEditor"));
defineMap.put(StableFactory.getMarkedClass(BridgeMark.CHART_EDITOR, AbstractBorderStyleWidget.class), new Appearance(ChartEditorDefinePane.class, "chartEditor"));
}
defineMap.put(WAbsoluteLayout.class, new Appearance(FRAbsoluteLayoutDefinePane.class, "wAbsoluteLayout"));

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

@ -251,7 +251,7 @@ public class WidgetBoundPane extends BasicPane {
@Override
public void stateChanged(ChangeEvent e) {
if (isLockEnabled() && isLocked() && width4Backup > 0 && height4Backup > 0) {
mHeightSpinner.setValue(mWidthSpinner.getValue() * width4Backup / height4Backup, false);
mHeightSpinner.setValue(mWidthSpinner.getValue() * height4Backup / width4Backup, false);
}
}
});
@ -259,7 +259,7 @@ public class WidgetBoundPane extends BasicPane {
@Override
public void stateChanged(ChangeEvent e) {
if (isLockEnabled() && isLocked() && width4Backup > 0 && height4Backup > 0) {
mWidthSpinner.setValue(mHeightSpinner.getValue() * height4Backup / width4Backup, false);
mWidthSpinner.setValue(mHeightSpinner.getValue() * width4Backup / height4Backup, false);
}
}
});

57
designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/ChartEditorDefinePane.java

@ -0,0 +1,57 @@
package com.fr.design.widget.ui.designer.layout;
import com.fr.design.designer.IntervalConstants;
import com.fr.design.designer.creator.CRPropertyDescriptor;
import com.fr.design.designer.creator.PropertyGroupPane;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XElementCase;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.widget.accessibles.AccessibleElementCaseToolBarEditor;
import com.fr.design.widget.ui.designer.component.PaddingBoundPane;
import com.fr.form.ui.ChartEditor;
import com.fr.form.ui.ElementCaseEditor;
import com.fr.form.web.FormToolBarManager;
import com.fr.general.ComparatorUtils;
import javax.swing.*;
import java.awt.*;
/**
* Created by ibm on 2017/8/7.
*/
public class ChartEditorDefinePane extends WTitleLayoutDefinePane<ChartEditor> {
private PaddingBoundPane paddingBoundPane;
public ChartEditorDefinePane(XCreator xCreator) {
super(xCreator);
}
protected JPanel createCenterPane() {
JPanel centerPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
paddingBoundPane = new PaddingBoundPane();
Component[][] components = new Component[][]{
new Component[]{paddingBoundPane, null},
};
JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W0, IntervalConstants.INTERVAL_L1);
panel.setBorder(BorderFactory.createEmptyBorder(5, 0, 10, 0));
centerPane.add(panel, BorderLayout.NORTH);
return centerPane;
}
protected ChartEditor updateSubBean() {
ChartEditor chartEditor = (ChartEditor) creator.toData();
if (ComparatorUtils.equals(getGlobalName(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Layout_Padding_Duplicate"))) {
paddingBoundPane.update(chartEditor);
}
return chartEditor;
}
protected void populateSubBean(ChartEditor ob) {
paddingBoundPane.populate(ob);
}
}
Loading…
Cancel
Save