|
|
|
@ -3,7 +3,9 @@
|
|
|
|
|
*/ |
|
|
|
|
package com.fr.design.style; |
|
|
|
|
|
|
|
|
|
import com.fine.theme.utils.FineUIScale; |
|
|
|
|
import com.fine.theme.utils.FineUIUtils; |
|
|
|
|
import com.formdev.flatlaf.ui.FlatUIUtils; |
|
|
|
|
import com.fr.base.BaseUtils; |
|
|
|
|
import com.fr.base.CellBorderStyle; |
|
|
|
|
import com.fr.base.GraphHelper; |
|
|
|
@ -19,8 +21,8 @@ import com.fr.stable.Constants;
|
|
|
|
|
import com.fr.stable.CoreConstants; |
|
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
|
|
|
|
|
|
import javax.swing.AbstractButton; |
|
|
|
|
import javax.swing.BorderFactory; |
|
|
|
|
import javax.swing.ButtonGroup; |
|
|
|
|
import javax.swing.Icon; |
|
|
|
|
import javax.swing.JComponent; |
|
|
|
|
import javax.swing.JPanel; |
|
|
|
@ -35,6 +37,8 @@ import java.awt.Graphics;
|
|
|
|
|
import java.awt.Graphics2D; |
|
|
|
|
import java.awt.event.ActionEvent; |
|
|
|
|
import java.awt.event.ActionListener; |
|
|
|
|
import java.awt.event.ItemEvent; |
|
|
|
|
import java.awt.event.ItemListener; |
|
|
|
|
import java.awt.event.MouseAdapter; |
|
|
|
|
import java.awt.event.MouseEvent; |
|
|
|
|
|
|
|
|
@ -76,7 +80,7 @@ public class BorderPane extends BasicPane {
|
|
|
|
|
private LineComboBox currentLineCombo; |
|
|
|
|
private NewColorSelectBox currentLineColorPane; |
|
|
|
|
|
|
|
|
|
private UIButton insidebutton; |
|
|
|
|
private JToggleButton insidebutton; |
|
|
|
|
|
|
|
|
|
public BorderPane() { |
|
|
|
|
this.initComponents(); |
|
|
|
@ -85,12 +89,13 @@ public class BorderPane extends BasicPane {
|
|
|
|
|
protected void initComponents() { |
|
|
|
|
initBasicComponents(); |
|
|
|
|
JPanel borderAllControlPane = initButtonPanel(); |
|
|
|
|
JPanel borderLeftPane = column(flex(), cell(topToggleButton), cell(horizontalToggleButton), cell(bottomToggleButton), flex()).getComponent(); |
|
|
|
|
JPanel borderBottomPane = row(flex(), cell(leftToggleButton), cell(verticalToggleButton), cell(rightToggleButton), flex()).getComponent(); |
|
|
|
|
JPanel borderLeftPane = column(5, flex(), cell(topToggleButton), cell(horizontalToggleButton), cell(bottomToggleButton), flex()).getComponent(); |
|
|
|
|
JPanel borderBottomPane = row(5, flex(), cell(leftToggleButton), cell(verticalToggleButton), cell(rightToggleButton), flex()).getComponent(); |
|
|
|
|
this.currentLineColorPane.setSelectObject(Color.BLUE); |
|
|
|
|
Component northPane1 = initNorthPanel(); |
|
|
|
|
Component centerPane1 = FineUIUtils.wrapComponentWithTitle(row(5, cell(borderLeftPane), |
|
|
|
|
column(5, row(flex(), cell(borderAllControlPane),flex()), cell(borderComponent).with(it -> it.setPreferredSize(new Dimension(600, 300))), cell(borderBottomPane)) |
|
|
|
|
column(5, row(flex(), cell(borderAllControlPane),flex()), cell(borderComponent) |
|
|
|
|
.with(it -> it.setPreferredSize(FineUIScale.scale(new Dimension(600, 300)))), cell(borderBottomPane)) |
|
|
|
|
).getComponent(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preview")); |
|
|
|
|
this.add(column(10, cell(northPane1), cell(centerPane1)).getComponent()); |
|
|
|
|
} |
|
|
|
@ -115,14 +120,30 @@ public class BorderPane extends BasicPane {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private JPanel initButtonPanel() { |
|
|
|
|
UIButton button1 = createVerButtonPane(NO_BORDERS, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_No")); |
|
|
|
|
UIButton button2 = createVerButtonPane(EXTERNAL_BORDERS, ""); |
|
|
|
|
UIButton button3 = createVerButtonPane(INSIDE_BORDERS, ""); |
|
|
|
|
ButtonGroup buttonGroup = new ButtonGroup(); |
|
|
|
|
buttonGroup.add(button1); |
|
|
|
|
buttonGroup.add(button2); |
|
|
|
|
buttonGroup.add(button3); |
|
|
|
|
return row(cell(button1), cell(button2), cell(button3)).getComponent(); |
|
|
|
|
JToggleButton button1 = createVerButtonPane(NO_BORDERS, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_No")); |
|
|
|
|
JToggleButton button2 = createVerButtonPane(EXTERNAL_BORDERS, ""); |
|
|
|
|
JToggleButton button3 = createVerButtonPane(INSIDE_BORDERS, ""); |
|
|
|
|
ItemListener itemListener = e -> { |
|
|
|
|
AbstractButton button = (AbstractButton) e.getSource(); |
|
|
|
|
if (e.getStateChange() == ItemEvent.SELECTED) { |
|
|
|
|
if (button == button1) { |
|
|
|
|
if (button2.isSelected()) { |
|
|
|
|
button2.setSelected(false); |
|
|
|
|
} |
|
|
|
|
if (button3.isSelected()) { |
|
|
|
|
button3.setSelected(false); |
|
|
|
|
} |
|
|
|
|
} else if (button == button2 || button == button3) { |
|
|
|
|
if (button1.isSelected()) { |
|
|
|
|
button1.setSelected(false); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
button1.addItemListener(itemListener); |
|
|
|
|
button2.addItemListener(itemListener); |
|
|
|
|
button3.addItemListener(itemListener); |
|
|
|
|
return row(5, cell(button1), cell(button2), cell(button3)).getComponent(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private Component initNorthPanel() { |
|
|
|
@ -156,7 +177,7 @@ public class BorderPane extends BasicPane {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private UIButton createVerButtonPane(int display, String text) { |
|
|
|
|
private JToggleButton createVerButtonPane(int display, String text) { |
|
|
|
|
JPanel verPane = new JPanel(); |
|
|
|
|
|
|
|
|
|
BorderButton button = new BorderButton(display); |
|
|
|
@ -253,9 +274,9 @@ public class BorderPane extends BasicPane {
|
|
|
|
|
this.borderType = borderType; |
|
|
|
|
|
|
|
|
|
if (horizontal) { |
|
|
|
|
this.setPreferredSize(new Dimension(40, 24)); |
|
|
|
|
this.setPreferredSize(FineUIScale.scale(new Dimension(40, 24))); |
|
|
|
|
} else { |
|
|
|
|
this.setPreferredSize(new Dimension(24, 40)); |
|
|
|
|
this.setPreferredSize(FineUIScale.scale(new Dimension(24, 40))); |
|
|
|
|
} |
|
|
|
|
this.addActionListener(this); |
|
|
|
|
} |
|
|
|
@ -305,7 +326,7 @@ public class BorderPane extends BasicPane {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Shortcut setting button
|
|
|
|
|
private class BorderButton extends UIButton implements ActionListener { |
|
|
|
|
private class BorderButton extends JToggleButton implements ActionListener { |
|
|
|
|
private int border; |
|
|
|
|
|
|
|
|
|
private BorderButton(int border) { |
|
|
|
@ -315,8 +336,8 @@ public class BorderPane extends BasicPane {
|
|
|
|
|
} else if(border == BorderPane.INSIDE_BORDERS) { |
|
|
|
|
this.setIcon(BaseUtils.readIcon("com/fr/design/images/m_format/in.png")); |
|
|
|
|
} |
|
|
|
|
this.setPreferredSize(FineUIScale.scale(new Dimension(40, 24))); |
|
|
|
|
this.addActionListener(this); |
|
|
|
|
setPreferredSize(new Dimension(36, 24)); |
|
|
|
|
setFocusPainted(false); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -583,16 +604,16 @@ public class BorderPane extends BasicPane {
|
|
|
|
|
int pInset = 4; |
|
|
|
|
int pWidth = this.getWidth() / 2 - 20 - pInset; |
|
|
|
|
int pHeight = this.getHeight() / 2 - 20 - pInset; |
|
|
|
|
g.setColor(Color.lightGray); |
|
|
|
|
g.setColor(FlatUIUtils.getUIColor("fill.hover", new Color(230,233,239))); |
|
|
|
|
g.fillRect(20, 20, pWidth, pHeight); |
|
|
|
|
g.setColor(Color.lightGray); |
|
|
|
|
g.setColor(FlatUIUtils.getUIColor("fill.hover", new Color(230,233,239))); |
|
|
|
|
g.fillRect(this.getWidth() / 2 + pInset + 1, 20, pWidth, pHeight); |
|
|
|
|
g.setColor(Color.lightGray); |
|
|
|
|
g.setColor(FlatUIUtils.getUIColor("fill.hover", new Color(230,233,239))); |
|
|
|
|
g.fillRect(20, this.getHeight() / 2 + pInset + 1, pWidth, pHeight); |
|
|
|
|
g.setColor(Color.lightGray); |
|
|
|
|
g.setColor(FlatUIUtils.getUIColor("fill.hover", new Color(230,233,239))); |
|
|
|
|
g.fillRect(this.getWidth() / 2 + pInset + 1, this.getHeight() / 2 + pInset + 1, pWidth, pHeight); |
|
|
|
|
} else { |
|
|
|
|
g.setColor(Color.lightGray); |
|
|
|
|
g.setColor(FlatUIUtils.getUIColor("fill.hover", new Color(230,233,239))); |
|
|
|
|
g.fillRect(20, 20, this.getWidth() - 40, this.getHeight() - 40); |
|
|
|
|
} |
|
|
|
|
updateBorders(g); |
|
|
|
|