Browse Source

Merge branch 'release/10.0' of https://code.fineres.com/scm/~hades/design into release/10.0

zheng-1641779399395
hades 3 years ago
parent
commit
fb32093781
  1. BIN
      designer-base/src/main/resources/com/fr/design/images/control/icon_cursor_drag_e.png
  2. BIN
      designer-base/src/main/resources/com/fr/design/images/control/icon_cursor_drag_n.png
  3. BIN
      designer-base/src/main/resources/com/fr/design/images/control/icon_cursor_drag_ne.png
  4. BIN
      designer-base/src/main/resources/com/fr/design/images/control/icon_cursor_drag_nw.png
  5. BIN
      designer-base/src/main/resources/com/fr/design/images/control/icon_cursor_drag_s.png
  6. BIN
      designer-base/src/main/resources/com/fr/design/images/control/icon_cursor_drag_se.png
  7. BIN
      designer-base/src/main/resources/com/fr/design/images/control/icon_cursor_drag_sw.png
  8. BIN
      designer-base/src/main/resources/com/fr/design/images/control/icon_cursor_drag_w.png
  9. 315
      designer-form/src/main/java/com/fr/design/gui/xpane/BorderLineAndImagePane.java
  10. 15
      designer-form/src/main/java/com/fr/design/parameter/RootDesignDefinePane.java
  11. 6
      designer-realize/src/main/java/com/fr/design/mainframe/form/FormElementCaseDesigner.java

BIN
designer-base/src/main/resources/com/fr/design/images/control/icon_cursor_drag_e.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 503 B

BIN
designer-base/src/main/resources/com/fr/design/images/control/icon_cursor_drag_n.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 522 B

BIN
designer-base/src/main/resources/com/fr/design/images/control/icon_cursor_drag_ne.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 523 B

BIN
designer-base/src/main/resources/com/fr/design/images/control/icon_cursor_drag_nw.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 511 B

BIN
designer-base/src/main/resources/com/fr/design/images/control/icon_cursor_drag_s.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 522 B

BIN
designer-base/src/main/resources/com/fr/design/images/control/icon_cursor_drag_se.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 511 B

BIN
designer-base/src/main/resources/com/fr/design/images/control/icon_cursor_drag_sw.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 523 B

BIN
designer-base/src/main/resources/com/fr/design/images/control/icon_cursor_drag_w.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 503 B

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

@ -20,7 +20,6 @@ import com.fr.design.gui.ibutton.UIButtonUI;
import com.fr.design.gui.ibutton.UIColorButton; import com.fr.design.gui.ibutton.UIColorButton;
import com.fr.design.gui.icombobox.LineComboBox; import com.fr.design.gui.icombobox.LineComboBox;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextfield.UIIntNumberField;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
@ -38,15 +37,28 @@ import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.project.ProjectConstants; import com.fr.stable.project.ProjectConstants;
import javax.swing.*; import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.JFileChooser;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener; import javax.swing.event.ChangeListener;
import javax.swing.plaf.basic.BasicButtonUI; import javax.swing.plaf.basic.BasicButtonUI;
import java.awt.*; import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Desktop;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.Point;
import java.awt.Toolkit;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.awt.event.MouseListener; import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener; import java.awt.event.MouseMotionListener;
@ -434,13 +446,36 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
private class NinePointLinePreviewPane extends JPanel implements MouseMotionListener, MouseListener { private class NinePointLinePreviewPane extends JPanel implements MouseMotionListener, MouseListener {
public final Color BACKGROUND_PANE_COLOR = Color.WHITE; public final Color BACKGROUND_PANE_COLOR = Color.WHITE;
public final Color BACKGROUND_IMG_COLOR = Color.lightGray; public final Color BACKGROUND_IMG_COLOR = Color.lightGray;
public final Color DIVIDER_BACKGROUND_COLOR = Color.WHITE; public final Color DIVIDER_BACKGROUND_COLOR = new Color(235, 29, 31);
public final Color DIVIDER_FOREGROUND_COLOR = Color.BLACK; public final Color DIVIDER_FOREGROUND_COLOR = Color.WHITE;
public final Color HINT_BACKGROUND_COLOR = new Color(255, 255, 255, 100); public final Color HINT_BACKGROUND_COLOR = new Color(0, 215, 215);
public final Color HINT_FOREGROUND_COLOR = Color.RED; public final Color HINT_FOREGROUND_COLOR = Color.WHITE;
public final Color HINT_LINE_BACKGROUND_COLOR = Color.WHITE; public final int HINT_GAP = 5;
public final Color HINT_LINE_FOREGROUND_COLOR = Color.RED;
public final int PADDING = 20; public final int PADDING = 20;
public final Cursor E_DRAG_CURSOR = Toolkit.getDefaultToolkit().createCustomCursor(
IOUtils.readImage("/com/fr/design/images/control/icon_cursor_drag_e.png"),
new Point(8, 8), "E_DRAG_CURSOR");
public final Cursor S_DRAG_CURSOR = Toolkit.getDefaultToolkit().createCustomCursor(
IOUtils.readImage("/com/fr/design/images/control/icon_cursor_drag_s.png"),
new Point(8, 8), "S_DRAG_CURSOR");
public final Cursor W_DRAG_CURSOR = Toolkit.getDefaultToolkit().createCustomCursor(
IOUtils.readImage("/com/fr/design/images/control/icon_cursor_drag_w.png"),
new Point(8, 8), "W_DRAG_CURSOR");
public final Cursor N_DRAG_CURSOR = Toolkit.getDefaultToolkit().createCustomCursor(
IOUtils.readImage("/com/fr/design/images/control/icon_cursor_drag_n.png"),
new Point(8, 8), "N_DRAG_CURSOR");
public final Cursor NE_DRAG_CURSOR = Toolkit.getDefaultToolkit().createCustomCursor(
IOUtils.readImage("/com/fr/design/images/control/icon_cursor_drag_ne.png"),
new Point(8, 8), "NE_DRAG_CURSOR");
public final Cursor NW_DRAG_CURSOR = Toolkit.getDefaultToolkit().createCustomCursor(
IOUtils.readImage("/com/fr/design/images/control/icon_cursor_drag_nw.png"),
new Point(8, 8), "NW_DRAG_CURSOR");
public final Cursor SE_DRAG_CURSOR = Toolkit.getDefaultToolkit().createCustomCursor(
IOUtils.readImage("/com/fr/design/images/control/icon_cursor_drag_se.png"),
new Point(8, 8), "SE_DRAG_CURSOR");
public final Cursor SW_DRAG_CURSOR = Toolkit.getDefaultToolkit().createCustomCursor(
IOUtils.readImage("/com/fr/design/images/control/icon_cursor_drag_sw.png"),
new Point(8, 8), "SW_DRAG_CURSOR");
private int ninePointLeft = -1; private int ninePointLeft = -1;
private int ninePointTop = -1; private int ninePointTop = -1;
@ -455,54 +490,17 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
private int scaleImgHeight; private int scaleImgHeight;
private int scaleImgX; private int scaleImgX;
private int scaleImgY; private int scaleImgY;
private double scale = 1.0; private double imageScale = 1.0;
private final UIIntNumberField topField = createNumberField(); private boolean draggingLeftDivider = false;
private final UIIntNumberField bottomField = createNumberField(); private boolean draggingRightDivider = false;
private final UIIntNumberField leftField = createNumberField(); private boolean draggingTopDivider = false;
private final UIIntNumberField rightField = createNumberField(); private boolean draggingBottomDivider = false;
public NinePointLinePreviewPane() { public NinePointLinePreviewPane() {
this.setLayout(null); this.setLayout(null);
this.addMouseMotionListener(this); this.addMouseMotionListener(this);
this.addMouseListener(this); this.addMouseListener(this);
this.setFocusable(true);
this.add(topField);
this.add(bottomField);
this.add(leftField);
this.add(rightField);
topField.addFocusListener(new FocusAdapter() {
@Override
public void focusLost(FocusEvent e) {
int value = (int) topField.getValue();
onNinePointTopChanged(value);
}
});
bottomField.addFocusListener(new FocusAdapter() {
@Override
public void focusLost(FocusEvent e) {
int value = (int) bottomField.getValue();
onNinePointBottomChanged(value);
}
});
leftField.addFocusListener(new FocusAdapter() {
@Override
public void focusLost(FocusEvent e) {
int value = (int) leftField.getValue();
onNinePointLeftChanged(value);
}
});
rightField.addFocusListener(new FocusAdapter() {
@Override
public void focusLost(FocusEvent e) {
int value = (int) rightField.getValue();
onNinePointRightChanged(value);
}
});
} }
@Override @Override
@ -528,99 +526,140 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
scaleImgHeight = (int) (1.0F * scaleImgWidth * imgHeight / imgWidth); scaleImgHeight = (int) (1.0F * scaleImgWidth * imgHeight / imgWidth);
scaleImgX = autoFixAreaX; scaleImgX = autoFixAreaX;
scaleImgY = (autoFixAreaHeight - scaleImgHeight) / 2 + autoFixAreaY; // 垂直居中 scaleImgY = (autoFixAreaHeight - scaleImgHeight) / 2 + autoFixAreaY; // 垂直居中
scale = 1.0 * scaleImgWidth / imgWidth; imageScale = 1.0 * scaleImgWidth / imgWidth;
} else { } else {
scaleImgHeight = autoFixAreaHeight; scaleImgHeight = autoFixAreaHeight;
scaleImgWidth = (int) (1.0F * scaleImgHeight * imgWidth / imgHeight); scaleImgWidth = (int) (1.0F * scaleImgHeight * imgWidth / imgHeight);
scaleImgX = (autoFixAreaWidth - scaleImgWidth) / 2 + autoFixAreaX; // 水平居中 scaleImgX = (autoFixAreaWidth - scaleImgWidth) / 2 + autoFixAreaX; // 水平居中
scaleImgY = autoFixAreaY; scaleImgY = autoFixAreaY;
scale = 1.0 * scaleImgHeight / imgHeight; imageScale = 1.0 * scaleImgHeight / imgHeight;
} }
g2d.setColor(BACKGROUND_IMG_COLOR); g2d.setColor(BACKGROUND_IMG_COLOR);
g2d.fillRect(scaleImgX, scaleImgY, scaleImgWidth, scaleImgHeight); g2d.fillRect(scaleImgX, scaleImgY, scaleImgWidth, scaleImgHeight);
g2d.drawImage(image, scaleImgX, scaleImgY, scaleImgWidth, scaleImgHeight, null); g2d.drawImage(image, scaleImgX, scaleImgY, scaleImgWidth, scaleImgHeight, null);
int scaleLeft = (int) (ninePointLeft * scale); int scaleLeft = (int) (ninePointLeft * imageScale);
int scaleTop = (int) (ninePointTop * scale); int scaleTop = (int) (ninePointTop * imageScale);
int scaleRight = (int) (ninePointRight * scale); int scaleRight = (int) (ninePointRight * imageScale);
int scaleBottom = (int) (ninePointBottom * scale); int scaleBottom = (int) (ninePointBottom * imageScale);
double topYInPane = scaleImgY + scaleTop; double topYInPane = scaleImgY + scaleTop;
double bottomYInPane = scaleImgY + scaleImgHeight - scaleBottom; double bottomYInPane = scaleImgY + scaleImgHeight - scaleBottom;
double leftXInPane = scaleImgX + scaleLeft; double leftXInPane = scaleImgX + scaleLeft;
double rightXInPane = scaleImgX + scaleImgWidth - scaleRight; double rightXInPane = scaleImgX + scaleImgWidth - scaleRight;
// 绘制分割线 // 顶部分割线
// 顶部 drawDivider(g2d, scaleImgX, topYInPane, scaleImgX + scaleImgWidth, topYInPane, draggingTopDivider);
drawLine(g2d, DIVIDER_BACKGROUND_COLOR, DIVIDER_FOREGROUND_COLOR, scaleImgX, topYInPane, scaleImgX + scaleImgWidth, topYInPane); if (draggingTopDivider) {
// 底部 // 顶部提示
drawLine(g2d, DIVIDER_BACKGROUND_COLOR, DIVIDER_FOREGROUND_COLOR, scaleImgX, bottomYInPane, scaleImgX + scaleImgWidth, bottomYInPane); drawHint(g2d, ninePointTop + "px", leftXInPane, scaleImgY, scaleImgWidth - scaleLeft - scaleRight, scaleTop, false);
// 左侧 }
drawLine(g2d, DIVIDER_BACKGROUND_COLOR, DIVIDER_FOREGROUND_COLOR, leftXInPane, scaleImgY, leftXInPane, scaleImgY + scaleImgHeight); // 底部分割线
// 右侧 drawDivider(g2d, scaleImgX, bottomYInPane, scaleImgX + scaleImgWidth, bottomYInPane, draggingBottomDivider);
drawLine(g2d, DIVIDER_BACKGROUND_COLOR, DIVIDER_FOREGROUND_COLOR, rightXInPane, scaleImgY, rightXInPane, scaleImgY + scaleImgHeight); if (draggingBottomDivider) {
// 底部提示
// 绘制分割线位置提示 drawHint(g2d, ninePointBottom + "px", leftXInPane, bottomYInPane, scaleImgWidth - scaleLeft - scaleRight, scaleBottom, false);
// 顶部 }
drawLine(g2d, HINT_LINE_BACKGROUND_COLOR, HINT_LINE_FOREGROUND_COLOR, (leftXInPane + rightXInPane) / 2.0F, scaleImgY, (leftXInPane + rightXInPane) / 2.0F, topYInPane); // 左侧分割线
drawHint(g2d, Integer.toString(ninePointTop), (leftXInPane + rightXInPane) / 2.0F, (scaleImgY + topYInPane) / 2.0, topField); drawDivider(g2d, leftXInPane, scaleImgY, leftXInPane, scaleImgY + scaleImgHeight, draggingLeftDivider);
// 底部 if (draggingLeftDivider) {
drawLine(g2d, HINT_LINE_BACKGROUND_COLOR, HINT_LINE_FOREGROUND_COLOR, (leftXInPane + rightXInPane) / 2.0F, bottomYInPane, (leftXInPane + rightXInPane) / 2.0F, scaleImgY + scaleImgHeight); // 左侧提示
drawHint(g2d, Integer.toString(ninePointBottom), (leftXInPane + rightXInPane) / 2.0F, (bottomYInPane + scaleImgY + scaleImgHeight) / 2.0, bottomField); drawHint(g2d, ninePointLeft + "px", scaleImgX, topYInPane, scaleLeft, scaleImgHeight - scaleTop - scaleBottom, true);
// 左侧 }
drawLine(g2d, HINT_LINE_BACKGROUND_COLOR, HINT_LINE_FOREGROUND_COLOR, scaleImgX, (topYInPane + bottomYInPane) / 2.0, leftXInPane, (topYInPane + bottomYInPane) / 2.0); // 右侧分割线
drawHint(g2d, Integer.toString(ninePointLeft), (scaleImgX + leftXInPane) / 2.0, (topYInPane + bottomYInPane) / 2.0, leftField); drawDivider(g2d, rightXInPane, scaleImgY, rightXInPane, scaleImgY + scaleImgHeight, draggingRightDivider);
// 右侧 if (draggingRightDivider) {
drawLine(g2d, HINT_LINE_BACKGROUND_COLOR, HINT_LINE_FOREGROUND_COLOR, rightXInPane, (topYInPane + bottomYInPane) / 2.0, scaleImgX + scaleImgWidth, (topYInPane + bottomYInPane) / 2.0); // 右侧提示
drawHint(g2d, Integer.toString(ninePointRight), (rightXInPane + scaleImgX + scaleImgWidth) / 2.0, (topYInPane + bottomYInPane) / 2.0, rightField); drawHint(g2d, ninePointRight + "px", rightXInPane, topYInPane, scaleRight, scaleImgHeight - scaleTop - scaleBottom, true);
} }
}
private void drawHint(Graphics2D g2d, String hint, double centerX, double centerY, UIIntNumberField hintField) {
private void drawHint(Graphics2D g2d, String hint, double x, double y, double width, double height, boolean horizontal) {
FontMetrics metrics = GraphDrawHelper.getFontMetrics(g2d.getFont()); FontMetrics metrics = GraphDrawHelper.getFontMetrics(g2d.getFont());
double height = metrics.getAscent() + metrics.getDescent(); double hintTextHeight = Math.max(metrics.getAscent() + metrics.getDescent(), 16);
double width = Math.max(metrics.stringWidth(" " + hint + " "), metrics.stringWidth(" 123 ")); double hintTextWidth = Math.max(metrics.stringWidth(hint), metrics.stringWidth("123"));
double hintFrameRadius = hintTextHeight / 2;
double hintFrameHeight = hintTextHeight;
double hintFrameWidth = hintTextWidth + 2 * hintFrameRadius;
double centerX = x + width / 2;
double centerY = y + height / 2;
double indent = 1.0;
double shortLine = 4.0;
hintField.setBounds((int) (centerX - width / 2.0), (int) (centerY - height / 2.0), (int) width, (int) height); if (horizontal) {
if (width > hintFrameWidth) {
g2d.setColor(HINT_BACKGROUND_COLOR);
GraphDrawHelper.draw(g2d, new Line2D.Double(x + indent, centerY, x + width - indent, centerY), Constants.LINE_THIN, 1.0F);
GraphDrawHelper.draw(g2d, new Line2D.Double(x + indent, centerY - shortLine, x + indent, centerY + shortLine), Constants.LINE_THIN, 1.0F);
GraphDrawHelper.draw(g2d, new Line2D.Double(x + width - indent, centerY - shortLine, x + width - indent, centerY + shortLine), Constants.LINE_THIN, 1.0F);
} }
private void drawLine(Graphics2D g2d, Color backgroundColor, Color foregroundColor, double x1, double y1, double x2, double y2) { double hintFrameX = centerX - hintFrameWidth / 2;
g2d.setColor(backgroundColor); double hintFrameY = centerY + HINT_GAP;
g2d.setColor(HINT_BACKGROUND_COLOR);
GraphDrawHelper.fill(g2d, new RoundRectangle2D.Double(hintFrameX, hintFrameY, hintFrameWidth, hintFrameHeight, hintFrameRadius * 2, hintFrameRadius * 2));
g2d.setColor(HINT_FOREGROUND_COLOR);
GraphDrawHelper.drawString(g2d, hint, hintFrameX + (hintFrameWidth - hintTextWidth) / 2, hintFrameY + (hintFrameHeight + hintTextHeight) / 2.0 - metrics.getDescent());
} else {
if (height > hintFrameHeight) {
g2d.setColor(HINT_BACKGROUND_COLOR);
GraphDrawHelper.draw(g2d, new Line2D.Double(centerX, y + indent, centerX, y + height - indent), Constants.LINE_THIN, 1.0F);
GraphDrawHelper.draw(g2d, new Line2D.Double(centerX - shortLine, y + indent, centerX + shortLine, y + indent), Constants.LINE_THIN, 1.0F);
GraphDrawHelper.draw(g2d, new Line2D.Double(centerX - shortLine, y + height - indent, centerX + shortLine, y + height - indent), Constants.LINE_THIN, 1.0F);
}
double hintFrameX = centerX + HINT_GAP;
double hintFrameY = centerY - hintFrameHeight / 2;
g2d.setColor(HINT_BACKGROUND_COLOR);
GraphDrawHelper.fill(g2d, new RoundRectangle2D.Double(hintFrameX, hintFrameY, hintFrameWidth, hintFrameHeight, hintFrameRadius * 2, hintFrameRadius * 2));
g2d.setColor(HINT_FOREGROUND_COLOR);
GraphDrawHelper.drawString(g2d, hint, hintFrameX + (hintFrameWidth - hintTextWidth) / 2, hintFrameY + (hintFrameHeight + hintTextHeight) / 2.0 - metrics.getDescent());
}
}
private void drawDivider(Graphics2D g2d, double x1, double y1, double x2, double y2, boolean dragging) {
if (dragging) {
g2d.setColor(DIVIDER_BACKGROUND_COLOR);
GraphDrawHelper.draw(g2d, new Line2D.Double(x1, y1, x2, y2), Constants.LINE_THIN, 2.0F); GraphDrawHelper.draw(g2d, new Line2D.Double(x1, y1, x2, y2), Constants.LINE_THIN, 2.0F);
g2d.setColor(foregroundColor); g2d.setColor(DIVIDER_FOREGROUND_COLOR);
GraphDrawHelper.draw(g2d, new Line2D.Double(x1, y1, x2, y2), Constants.LINE_THIN, 1.0F);
} else {
g2d.setColor(DIVIDER_BACKGROUND_COLOR);
GraphDrawHelper.draw(g2d, new Line2D.Double(x1, y1, x2, y2), Constants.LINE_DASH, 1.0F); GraphDrawHelper.draw(g2d, new Line2D.Double(x1, y1, x2, y2), Constants.LINE_DASH, 1.0F);
} }
}
@Override @Override
public void mouseDragged(MouseEvent e) { public void mouseDragged(MouseEvent e) {
int x = e.getX(); int x = e.getX();
int y = e.getY(); int y = e.getY();
int cursorType = getCursor().getType(); Cursor cursor = getCursor();
switch (cursorType) { if (cursor == W_DRAG_CURSOR || cursor == NW_DRAG_CURSOR || cursor == SW_DRAG_CURSOR) {
case Cursor.W_RESIZE_CURSOR: { int nextLeft = (int) ((x - scaleImgX) / imageScale);
int nextLeft = (int) ((x - scaleImgX) / scale);
this.onNinePointLeftChanged(nextLeft); this.onNinePointLeftChanged(nextLeft);
return; } else if (cursor == E_DRAG_CURSOR || cursor == NE_DRAG_CURSOR || cursor == SE_DRAG_CURSOR) {
} int nextRight = (int) ((scaleImgX + scaleImgWidth - x) / imageScale);
case Cursor.E_RESIZE_CURSOR: {
int nextRight = (int) ((scaleImgX + scaleImgWidth - x) / scale);
this.onNinePointRightChanged(nextRight); this.onNinePointRightChanged(nextRight);
return;
} }
case Cursor.N_RESIZE_CURSOR: {
int nextTop = (int) ((y - scaleImgY) / scale); if (cursor == N_DRAG_CURSOR || cursor == NE_DRAG_CURSOR || cursor == NW_DRAG_CURSOR) {
int nextTop = (int) ((y - scaleImgY) / imageScale);
this.onNinePointTopChanged(nextTop); this.onNinePointTopChanged(nextTop);
return; } else if (cursor == S_DRAG_CURSOR || cursor == SE_DRAG_CURSOR || cursor == SW_DRAG_CURSOR) {
} int nextBottom = (int) ((scaleImgY + scaleImgHeight - y) / imageScale);
case Cursor.S_RESIZE_CURSOR: {
int nextBottom = (int) ((scaleImgY + scaleImgHeight - y) / scale);
this.onNinePointBottomChanged(nextBottom); this.onNinePointBottomChanged(nextBottom);
} }
} }
}
@Override @Override
public void mouseMoved(MouseEvent e) { public void mouseMoved(MouseEvent e) {
@ -629,13 +668,13 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
int x = e.getX(); int x = e.getX();
int y = e.getY(); int y = e.getY();
double scaleLeft = ninePointLeft * scale; double scaleLeft = ninePointLeft * imageScale;
double scaleTop = ninePointTop * scale; double scaleTop = ninePointTop * imageScale;
double scaleRight = ninePointRight * scale; double scaleRight = ninePointRight * imageScale;
double scaleBottom = ninePointBottom * scale; double scaleBottom = ninePointBottom * imageScale;
// determine cursor // determine cursor
int cursorType = Cursor.DEFAULT_CURSOR; Cursor cursor = Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR);
boolean hoveringLeftDivider = false; boolean hoveringLeftDivider = false;
boolean hoveringRightDivider = false; boolean hoveringRightDivider = false;
@ -649,18 +688,31 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
hoveringBottomDivider = Math.abs(y - (scaleImgY + scaleImgHeight - scaleBottom)) < 2; hoveringBottomDivider = Math.abs(y - (scaleImgY + scaleImgHeight - scaleBottom)) < 2;
} }
if (hoveringLeftDivider) { if (hoveringLeftDivider && hoveringTopDivider) {
cursorType = Cursor.W_RESIZE_CURSOR; cursor = NW_DRAG_CURSOR;
} else if (hoveringLeftDivider && hoveringBottomDivider) {
cursor = SW_DRAG_CURSOR;
} else if (hoveringRightDivider && hoveringTopDivider) {
cursor = NE_DRAG_CURSOR;
} else if (hoveringRightDivider && hoveringBottomDivider) {
cursor = SE_DRAG_CURSOR;
} else if (hoveringLeftDivider) {
cursor = W_DRAG_CURSOR;
} else if (hoveringRightDivider) { } else if (hoveringRightDivider) {
cursorType = Cursor.E_RESIZE_CURSOR; cursor = E_DRAG_CURSOR;
} else if (hoveringTopDivider) { } else if (hoveringTopDivider) {
cursorType = Cursor.N_RESIZE_CURSOR; cursor = N_DRAG_CURSOR;
} else if (hoveringBottomDivider) { } else if (hoveringBottomDivider) {
cursorType = Cursor.S_RESIZE_CURSOR; cursor = S_DRAG_CURSOR;
} }
needRepaint = getCursor().getType() != cursorType; draggingLeftDivider = hoveringLeftDivider;
this.setCursor(Cursor.getPredefinedCursor(cursorType)); draggingRightDivider = hoveringRightDivider;
draggingTopDivider = hoveringTopDivider;
draggingBottomDivider = hoveringBottomDivider;
needRepaint = getCursor() != cursor;
this.setCursor(cursor);
if (needRepaint) { if (needRepaint) {
repaint(); repaint();
@ -680,6 +732,10 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
@Override @Override
public void mouseReleased(MouseEvent e) { public void mouseReleased(MouseEvent e) {
this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
this.draggingLeftDivider = false;
this.draggingRightDivider = false;
this.draggingTopDivider = false;
this.draggingBottomDivider = false;
repaint(); repaint();
} }
@ -701,7 +757,6 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
value = imgHeight - ninePointBottom - MIN_NINE_POINT; value = imgHeight - ninePointBottom - MIN_NINE_POINT;
} }
this.ninePointTop = value; this.ninePointTop = value;
topField.setText(Integer.toString(value));
repaint(); repaint();
} }
@ -712,7 +767,6 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
value = imgHeight - ninePointTop - MIN_NINE_POINT; value = imgHeight - ninePointTop - MIN_NINE_POINT;
} }
this.ninePointBottom = value; this.ninePointBottom = value;
bottomField.setText(Integer.toString(value));
repaint(); repaint();
} }
@ -723,7 +777,6 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
value = imgWidth - ninePointRight - MIN_NINE_POINT; value = imgWidth - ninePointRight - MIN_NINE_POINT;
} }
this.ninePointLeft = value; this.ninePointLeft = value;
leftField.setText(Integer.toString(value));
repaint(); repaint();
} }
@ -734,32 +787,14 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
value = imgWidth - ninePointLeft - MIN_NINE_POINT; value = imgWidth - ninePointLeft - MIN_NINE_POINT;
} }
this.ninePointRight = value; this.ninePointRight = value;
rightField.setText(Integer.toString(value));
repaint(); repaint();
} }
private UIIntNumberField createNumberField() {
UIIntNumberField field = new UIIntNumberField();
field.setBorder(BorderFactory.createLineBorder(Color.GRAY, 1));
field.setOpaque(true);
field.setMinValue(MIN_NINE_POINT);
field.setForeground(HINT_FOREGROUND_COLOR);
field.setBackground(HINT_BACKGROUND_COLOR);
field.setHorizontalAlignment(SwingConstants.CENTER);
return field;
}
public void setNinePoint(int[] ninePoint) { public void setNinePoint(int[] ninePoint) {
ninePointLeft = ninePoint[0]; ninePointLeft = ninePoint[0];
ninePointTop = ninePoint[1]; ninePointTop = ninePoint[1];
ninePointRight = ninePoint[2]; ninePointRight = ninePoint[2];
ninePointBottom = ninePoint[3]; ninePointBottom = ninePoint[3];
leftField.setValue(ninePointLeft);
rightField.setValue(ninePointRight);
topField.setValue(ninePointTop);
bottomField.setValue(ninePointBottom);
} }
public int[] getNinePoint() { public int[] getNinePoint() {

15
designer-form/src/main/java/com/fr/design/parameter/RootDesignDefinePane.java

@ -62,13 +62,18 @@ public class RootDesignDefinePane extends AbstractDataModify<WParameterLayout> {
public void initComponent() { public void initComponent() {
this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setLayout(FRGUIPaneFactory.createBorderLayout());
JPanel inbuiltDefineContentPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
this.add(inbuiltDefineContentPane, BorderLayout.NORTH);
designerWidth = new UIBoundSpinner(1, Integer.MAX_VALUE, 1); designerWidth = new UIBoundSpinner(1, Integer.MAX_VALUE, 1);
JPanel advancePane = createAdvancePane();
UIExpandablePane advanceExpandablePane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Advanced"), 280, 20, advancePane);
this.add(advanceExpandablePane, BorderLayout.NORTH);
JPanel layoutPane = createBoundsPane(); JPanel layoutPane = createBoundsPane();
UIExpandablePane layoutExpandablePane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Size"), 280, 20, layoutPane); UIExpandablePane layoutExpandablePane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Size"), 280, 20, layoutPane);
this.add(layoutExpandablePane, BorderLayout.CENTER); inbuiltDefineContentPane.add(layoutExpandablePane, BorderLayout.NORTH);
JPanel advancePane = createAdvancePane();
UIExpandablePane advanceExpandablePane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Advanced"), 280, 20, advancePane);
inbuiltDefineContentPane.add(advanceExpandablePane, BorderLayout.CENTER);
this.addExtraUIExpandablePaneFromPlugin(); this.addExtraUIExpandablePaneFromPlugin();
} }
@ -83,7 +88,7 @@ public class RootDesignDefinePane extends AbstractDataModify<WParameterLayout> {
panel.add(uiExpandablePane); panel.add(uiExpandablePane);
} }
} }
this.add(panel, BorderLayout.SOUTH); this.add(panel, BorderLayout.CENTER);
} }
public JPanel createBoundsPane() { public JPanel createBoundsPane() {

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

@ -30,6 +30,7 @@ import com.fr.design.selection.Selectedable;
import com.fr.design.selection.SelectionListener; import com.fr.design.selection.SelectionListener;
import com.fr.form.FormElementCaseProvider; import com.fr.form.FormElementCaseProvider;
import com.fr.form.main.Form; import com.fr.form.main.Form;
import com.fr.grid.Grid;
import com.fr.grid.selection.CellSelection; import com.fr.grid.selection.CellSelection;
import com.fr.grid.selection.Selection; import com.fr.grid.selection.Selection;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
@ -138,7 +139,10 @@ public class FormElementCaseDesigner
g.fillRect(0, 0, size.width, size.height); g.fillRect(0, 0, size.width, size.height);
g.setColor(oldColor); g.setColor(oldColor);
this.elementCasePane.paintComponents(g); Grid grid = this.elementCasePane != null ? this.elementCasePane.getGrid() : null;
if (grid != null) {
grid.paintAll(g);
}
} catch (Exception e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);

Loading…
Cancel
Save