vito
12 months ago
12 changed files with 331 additions and 6 deletions
@ -0,0 +1,37 @@
|
||||
package com.fine.theme.light.ui.laf; |
||||
|
||||
import com.fine.swing.ui.layout.Layouts; |
||||
import com.fine.theme.icon.IconManager; |
||||
import com.fine.theme.light.ui.FineLightIconSet; |
||||
import com.formdev.flatlaf.FlatDarkLaf; |
||||
import com.formdev.flatlaf.util.UIScale; |
||||
import com.fr.stable.StringUtils; |
||||
|
||||
/** |
||||
* FineReport designer new look and feel |
||||
* |
||||
* @author vito |
||||
* @since 11.0 |
||||
* Created on 2023/9/12 |
||||
*/ |
||||
public class FineDarkLaf extends FlatDarkLaf { |
||||
|
||||
private static final String USER_SCALE_FACTOR = "userScaleFactor"; |
||||
|
||||
public static boolean setup() { |
||||
IconManager.addSet(new FineLightIconSet("fine-light")); |
||||
Layouts.setScaleFactor(UIScale.getUserScaleFactor()); |
||||
UIScale.addPropertyChangeListener(evt -> { |
||||
if (StringUtils.equals(evt.getPropertyName(), USER_SCALE_FACTOR)) { |
||||
Layouts.setScaleFactor((float) evt.getNewValue()); |
||||
} |
||||
}); |
||||
return setup(new FineDarkLaf()); |
||||
} |
||||
|
||||
@Override |
||||
public String getName() { |
||||
return "FineDarkLaf"; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,36 @@
|
||||
package com.fr.design.gui.storybook; |
||||
|
||||
import com.fine.theme.icon.LazyIcon; |
||||
import com.fr.design.gui.ibutton.UIButton; |
||||
|
||||
import javax.swing.JButton; |
||||
|
||||
import static com.fine.swing.ui.layout.Layouts.cell; |
||||
import static com.fine.swing.ui.layout.Layouts.flex; |
||||
import static com.fine.swing.ui.layout.Layouts.row; |
||||
|
||||
/** |
||||
* 按钮 |
||||
* |
||||
* @author vito |
||||
* @since 11.0 |
||||
* Created on 2023/11/27 |
||||
*/ |
||||
public class ButtonStoryBoard extends StoryBoard { |
||||
|
||||
public ButtonStoryBoard() { |
||||
super("按钮"); |
||||
add( |
||||
row(10, |
||||
cell(new UIButton("按钮")), |
||||
cell(new UIButton("保存", new LazyIcon("save"))), |
||||
cell(new UIButton(new LazyIcon("multi"))) |
||||
), |
||||
row(10, |
||||
cell(new JButton("按钮")), |
||||
cell(new JButton(new LazyIcon("multi"))) |
||||
), |
||||
flex() |
||||
); |
||||
} |
||||
} |
@ -0,0 +1,30 @@
|
||||
package com.fr.design.gui.storybook; |
||||
|
||||
import com.fine.swing.ui.layout.Column; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
|
||||
import javax.swing.UIManager; |
||||
import java.awt.Font; |
||||
|
||||
import static com.fine.swing.ui.layout.Layouts.cell; |
||||
|
||||
/** |
||||
* UI 故事板,用于demo |
||||
* 展示每个UI组件的能力 |
||||
* |
||||
* @author vito |
||||
* @since 11.0 |
||||
* Created on 2023/11/27 |
||||
*/ |
||||
public class StoryBoard extends Column { |
||||
|
||||
protected static final Font labelFont = UIManager.getFont("Label.font"); |
||||
|
||||
protected String title; |
||||
|
||||
public StoryBoard(String title) { |
||||
this.title = title; |
||||
setSpacing(4); |
||||
add(cell(new UILabel(title)).with(it -> it.setFont(labelFont.deriveFont(16f).deriveFont(Font.BOLD)))); |
||||
} |
||||
} |
@ -0,0 +1,18 @@
|
||||
package com.fr.design.gui.storybook; |
||||
|
||||
import javax.swing.JComponent; |
||||
|
||||
/** |
||||
* @author vito |
||||
* @since 11.0 |
||||
* Created on 2023/11/27 |
||||
*/ |
||||
public class StoryBookComponent { |
||||
public String name; |
||||
public JComponent component; |
||||
|
||||
public StoryBookComponent(String name, JComponent component) { |
||||
this.name = name; |
||||
this.component = component; |
||||
} |
||||
} |
@ -0,0 +1,85 @@
|
||||
package com.fr.design.gui.storybook; |
||||
|
||||
import com.fanruan.gui.UiInspector; |
||||
import com.fine.theme.light.ui.laf.FineLightLaf; |
||||
import com.formdev.flatlaf.util.ScaledEmptyBorder; |
||||
|
||||
import javax.swing.DefaultListCellRenderer; |
||||
import javax.swing.JFrame; |
||||
import javax.swing.JList; |
||||
import javax.swing.JPanel; |
||||
import javax.swing.JScrollPane; |
||||
import javax.swing.SwingUtilities; |
||||
import java.awt.BorderLayout; |
||||
import java.awt.CardLayout; |
||||
import java.awt.Component; |
||||
import java.util.ArrayList; |
||||
|
||||
import static com.fine.swing.ui.layout.Layouts.cell; |
||||
import static com.fine.swing.ui.layout.Layouts.row; |
||||
import static com.fine.theme.utils.FineUIScale.scale; |
||||
|
||||
/** |
||||
* UI 故事书,用于demo |
||||
* 展示每个UI组件的能力 |
||||
* |
||||
* @author vito |
||||
* @since 11.0 |
||||
* Created on 2023/11/27 |
||||
*/ |
||||
public class Storybook { |
||||
|
||||
CardLayout cardLayout; |
||||
JPanel cards; |
||||
|
||||
public void start() { |
||||
FineLightLaf.setup(); |
||||
JFrame jf = new JFrame("Story Book"); |
||||
jf.add(row( |
||||
cell(new JList<>(components())).with(it -> { |
||||
it.setBorder(new ScaledEmptyBorder(10, 10, 10, 10)); |
||||
it.setCellRenderer(new MyListCellRenderer()); |
||||
it.addListSelectionListener(e -> { |
||||
StoryBookComponent[] cs = components(); |
||||
cards.removeAll(); |
||||
cards.add(cs[it.getSelectedIndex()].component); |
||||
cards.revalidate(); |
||||
}); |
||||
}), |
||||
cell(new JScrollPane()).weight(1).with(it -> { |
||||
cards = new JPanel(new BorderLayout()); |
||||
it.setViewportView(cards); |
||||
cards.setBorder(new ScaledEmptyBorder(10, 10, 10, 10)); |
||||
cards.add(components()[0].component); |
||||
}) |
||||
).getComponent()); |
||||
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
||||
jf.setSize(scale(600), scale(400)); |
||||
new UiInspector(); |
||||
jf.setVisible(true); |
||||
} |
||||
|
||||
|
||||
static class MyListCellRenderer extends DefaultListCellRenderer { |
||||
@Override |
||||
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) { |
||||
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); |
||||
setText(((StoryBookComponent) value).name); |
||||
return this; |
||||
} |
||||
} |
||||
|
||||
private StoryBookComponent[] components() { |
||||
ArrayList<StoryBookComponent> components = new ArrayList<>(); |
||||
components.add(new StoryBookComponent("Button", new ButtonStoryBoard())); |
||||
components.add(new StoryBookComponent("HeadGroup", new UIHeadGroupStoryBoard())); |
||||
components.add(new StoryBookComponent("ToggleButton", new ToggleButtonStoryBoard())); |
||||
return components.toArray(new StoryBookComponent[0]); |
||||
} |
||||
|
||||
|
||||
public static void main(String... args) { |
||||
SwingUtilities.invokeLater(() -> new Storybook().start()); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,31 @@
|
||||
package com.fr.design.gui.storybook; |
||||
|
||||
import com.fine.theme.icon.LazyIcon; |
||||
|
||||
import javax.swing.JToggleButton; |
||||
|
||||
import static com.fine.swing.ui.layout.Layouts.cell; |
||||
import static com.fine.swing.ui.layout.Layouts.flex; |
||||
import static com.fine.swing.ui.layout.Layouts.row; |
||||
|
||||
/** |
||||
* 切换状态按钮 |
||||
* |
||||
* @author vito |
||||
* @since 11.0 |
||||
* Created on 2023/11/27 |
||||
*/ |
||||
public class ToggleButtonStoryBoard extends StoryBoard { |
||||
|
||||
public ToggleButtonStoryBoard() { |
||||
super("切换按钮"); |
||||
add( |
||||
row(10, |
||||
cell(new JToggleButton("切换按钮")), |
||||
cell(new JToggleButton("长文字保存保存保存保存", new LazyIcon("save"))), |
||||
cell(new JToggleButton(new LazyIcon("multi"))) |
||||
), |
||||
flex() |
||||
); |
||||
} |
||||
} |
@ -0,0 +1,65 @@
|
||||
package com.fr.design.gui.storybook; |
||||
|
||||
import com.fine.theme.icon.LazyIcon; |
||||
import com.fr.design.gui.ibutton.UIHead; |
||||
import com.fr.design.gui.ibutton.UIHeadGroup; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
import static com.fine.swing.ui.layout.Layouts.cell; |
||||
import static com.fine.swing.ui.layout.Layouts.flex; |
||||
|
||||
/** |
||||
* 属性面板tab |
||||
* |
||||
* @author vito |
||||
* @since 11.0 |
||||
* Created on 2023/11/27 |
||||
*/ |
||||
class UIHeadGroupStoryBoard extends StoryBoard { |
||||
|
||||
public UIHeadGroupStoryBoard() { |
||||
super("属性面板&导入数据集tab"); |
||||
add( |
||||
cell(new UILabel("文字Tab")).with(it -> it.setFont(labelFont.deriveFont(14f))), |
||||
cell(new UIHeadGroup(new String[]{"左按钮", "右按钮"})), |
||||
cell(new UILabel("图标Tab")).with(it -> it.setFont(labelFont.deriveFont(14f))), |
||||
cell(new UIHeadGroup(iconList())), |
||||
cell(new UILabel("文字Tab带禁用")).with(it -> it.setFont(labelFont.deriveFont(14f))), |
||||
cell(new UIHeadGroup(iconList2())), |
||||
cell(new UILabel("文字图标Tab带禁用")).with(it -> it.setFont(labelFont.deriveFont(14f))), |
||||
cell(new UIHeadGroup(iconList3())), |
||||
flex() |
||||
); |
||||
} |
||||
|
||||
public static List<UIHead> iconList() { |
||||
List<UIHead> uiHeads = new ArrayList<>(); |
||||
uiHeads.add(new UIHead(new LazyIcon("cut"))); |
||||
uiHeads.add(new UIHead(new LazyIcon("save"))); |
||||
return uiHeads; |
||||
} |
||||
|
||||
public static List<UIHead> iconList2() { |
||||
List<UIHead> uiHeads = new ArrayList<>(); |
||||
uiHeads.add(new UIHead(new LazyIcon("cut"))); |
||||
uiHeads.add(new UIHead(new LazyIcon("save"), false)); |
||||
return uiHeads; |
||||
} |
||||
|
||||
public static List<UIHead> iconList3() { |
||||
List<UIHead> uiHeads = new ArrayList<>(); |
||||
uiHeads.add(new UIHead("剪切", new LazyIcon("cut"))); |
||||
uiHeads.add(new UIHead("保存", new LazyIcon("save"), false)); |
||||
return uiHeads; |
||||
} |
||||
|
||||
public static List<UIHead> iconList4() { |
||||
List<UIHead> uiHeads = new ArrayList<>(); |
||||
uiHeads.add(new UIHead("剪切剪切剪切剪切剪切剪切剪切剪切剪切", new LazyIcon("cut"))); |
||||
uiHeads.add(new UIHead("保存", new LazyIcon("save"), false)); |
||||
return uiHeads; |
||||
} |
||||
} |
Loading…
Reference in new issue