jeo
5 years ago
153 changed files with 4353 additions and 906 deletions
@ -0,0 +1,57 @@
|
||||
package com.fr.design.fun; |
||||
|
||||
import com.fr.design.gui.icombobox.UIComboBox; |
||||
import com.fr.design.gui.icontainer.UIScrollPane; |
||||
import com.fr.design.mainframe.DockingView; |
||||
import com.fr.stable.fun.mark.Immutable; |
||||
|
||||
import javax.swing.JPanel; |
||||
|
||||
/** |
||||
* 组件库面板处理器 |
||||
* |
||||
* created by Harrison on 2020/03/16 |
||||
**/ |
||||
public interface ComponentLibraryPaneProcessor extends Immutable { |
||||
|
||||
String XML_TAG = "ComponentLibraryPaneProcessor"; |
||||
|
||||
int CURRENT_LEVEL = 1; |
||||
|
||||
/** |
||||
* 创建展示面板 |
||||
* |
||||
* @param isEdit 是否可以编辑 |
||||
* @return 展示面板 |
||||
*/ |
||||
UIScrollPane createShowPanel(boolean isEdit); |
||||
|
||||
/** |
||||
* 创建菜单的上部面板 |
||||
* |
||||
* @return 面板 |
||||
*/ |
||||
JPanel createMenuNorthPane(); |
||||
|
||||
/** |
||||
* 创建复选框 |
||||
* |
||||
* @return 复选框 |
||||
*/ |
||||
UIComboBox createMenuComBox(); |
||||
|
||||
void parentView(DockingView dockingView); |
||||
|
||||
/** |
||||
* 父面板 |
||||
* |
||||
* @param panel 面板 |
||||
*/ |
||||
void parentPane(JPanel panel); |
||||
|
||||
/** |
||||
* 创建完成 |
||||
*/ |
||||
void complete(); |
||||
|
||||
} |
@ -0,0 +1,36 @@
|
||||
package com.fr.design.fun; |
||||
|
||||
import com.fr.design.mainframe.JTemplate; |
||||
import com.fr.design.menu.ShortCut; |
||||
import com.fr.stable.fun.mark.Immutable; |
||||
|
||||
import javax.swing.JComponent; |
||||
import java.awt.Dimension; |
||||
import java.awt.image.BufferedImage; |
||||
|
||||
|
||||
/** |
||||
* Created by kerry on 2020-04-09 |
||||
* 临时接口,后续自适应内置后删除 |
||||
*/ |
||||
public interface FormAdaptiveConfigUIProcessor extends Immutable { |
||||
|
||||
String MARK_STRING = "FormAdaptiveConfigUIProcessor"; |
||||
int CURRENT_LEVEL = 1; |
||||
|
||||
/** |
||||
* 获取表单自适应配置菜单 |
||||
* @return 表单自适应配置菜单 |
||||
*/ |
||||
ShortCut getConfigShortCut(JTemplate jTemplate); |
||||
|
||||
/** |
||||
* 绘制自适应下报表块在表单界面中显示图片 |
||||
* @param size 绘制尺寸 |
||||
* @param elementCasePane 报表块内容对象 |
||||
* @return 自适应下报表块在表单界面中显示的图片 |
||||
*/ |
||||
BufferedImage paintFormElementCaseImage(Dimension size, JComponent elementCasePane); |
||||
|
||||
} |
||||
|
@ -0,0 +1,25 @@
|
||||
package com.fr.design.fun; |
||||
|
||||
import com.fr.design.beans.BasicBeanPane; |
||||
import com.fr.general.cardtag.mobile.MobileTemplateStyle; |
||||
import com.fr.stable.fun.mark.Mutable; |
||||
|
||||
/** |
||||
* @author hades |
||||
* @version 10.0 |
||||
* Created by hades on 2020/3/31 |
||||
*/ |
||||
public interface MobileTemplateStyleProvider extends Mutable { |
||||
|
||||
String XML_TAG = "MobileTemplateStyleProvider"; |
||||
|
||||
int CURRENT_LEVEL = 1; |
||||
|
||||
Class<? extends MobileTemplateStyle> classFroMobileTemplateStyle(); |
||||
|
||||
|
||||
Class<? extends BasicBeanPane<MobileTemplateStyle>> classFroMobileTemplateStyleAppearance(); |
||||
|
||||
String displayName(); |
||||
|
||||
} |
@ -0,0 +1,50 @@
|
||||
package com.fr.design.fun; |
||||
|
||||
import com.fr.design.mainframe.PaneHolder; |
||||
import com.fr.design.mainframe.PropertyItemBean; |
||||
import com.fr.stable.fun.mark.Mutable; |
||||
import org.jetbrains.annotations.Nullable; |
||||
|
||||
/** |
||||
* created by Harrison on 2020/03/23 |
||||
**/ |
||||
public interface PropertyItemPaneProvider<T> extends Mutable { |
||||
|
||||
int CURRENT_LEVEL = 1; |
||||
|
||||
String XML_TAG = "PropertyItemPaneProvider"; |
||||
|
||||
int FIRST = 100; |
||||
|
||||
int LAST = -100; |
||||
|
||||
/** |
||||
* 独一无二的标志 |
||||
* |
||||
* @return 标志 |
||||
*/ |
||||
String key(); |
||||
|
||||
/** |
||||
* 配置属性 |
||||
* |
||||
* @return 熟悉 |
||||
*/ |
||||
PropertyItemBean getItem(); |
||||
|
||||
/** |
||||
* 面板持有者 |
||||
* |
||||
* @param clazz 类型 |
||||
* @return 持有者 |
||||
*/ |
||||
@Nullable |
||||
PaneHolder<T> getPaneHolder(Class<?> clazz); |
||||
|
||||
/** |
||||
* 想要替代的类型 |
||||
* |
||||
* @return 替代类型 |
||||
*/ |
||||
String replaceKey(); |
||||
} |
@ -0,0 +1,39 @@
|
||||
package com.fr.design.fun; |
||||
|
||||
import com.fr.stable.fun.mark.Mutable; |
||||
import com.fr.stable.unit.UNIT; |
||||
|
||||
/** |
||||
* Created by kerry on 2020-04-09 |
||||
*/ |
||||
public interface ReportLengthUNITProvider extends Mutable { |
||||
String MARK_STRING = "ReportLengthUNITProvider"; |
||||
|
||||
int CURRENT_LEVEL = 1; |
||||
|
||||
/** |
||||
* 标尺单位显示字符 |
||||
* @return 标尺单位字符 |
||||
*/ |
||||
String unitText(); |
||||
|
||||
/** |
||||
* 标尺单位类型(之前是将int类型的值直接保存在数据库里面的) |
||||
* @return 返回标尺单位类型 |
||||
*/ |
||||
int unitType(); |
||||
|
||||
/** |
||||
* UNIT转标尺单位值 |
||||
* @param value UNIT |
||||
* @return 标尺单位值 |
||||
*/ |
||||
float unit2Value4Scale(UNIT value); |
||||
|
||||
/** |
||||
* 标尺单位值转UNIT |
||||
* @param value 标尺单位值 |
||||
* @return UNIT |
||||
*/ |
||||
UNIT float2UNIT(float value); |
||||
} |
@ -0,0 +1,23 @@
|
||||
package com.fr.design.fun.impl; |
||||
|
||||
|
||||
import com.fr.design.fun.FormAdaptiveConfigUIProcessor; |
||||
import com.fr.stable.fun.mark.API; |
||||
|
||||
/** |
||||
* Created by kerry on 2020-04-09 |
||||
*/ |
||||
@API(level = FormAdaptiveConfigUIProcessor.CURRENT_LEVEL) |
||||
public abstract class AbstractFormAdaptiveConfigUIProcessor implements FormAdaptiveConfigUIProcessor { |
||||
|
||||
@Override |
||||
public int currentAPILevel() { |
||||
return CURRENT_LEVEL; |
||||
} |
||||
|
||||
@Override |
||||
public int layerIndex() { |
||||
return DEFAULT_LAYER_INDEX; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,25 @@
|
||||
package com.fr.design.fun.impl; |
||||
|
||||
import com.fr.design.fun.MobileTemplateStyleProvider; |
||||
import com.fr.design.fun.MobileWidgetStyleProvider; |
||||
import com.fr.stable.fun.impl.AbstractProvider; |
||||
import com.fr.stable.fun.mark.API; |
||||
|
||||
/** |
||||
* @author hades |
||||
* @version 10.0 |
||||
* Created by hades on 2020/3/31 |
||||
*/ |
||||
@API(level = MobileWidgetStyleProvider.CURRENT_LEVEL) |
||||
public abstract class AbstractMobileTemplateStyleProvider extends AbstractProvider implements MobileTemplateStyleProvider { |
||||
|
||||
@Override |
||||
public int currentAPILevel() { |
||||
return CURRENT_LEVEL; |
||||
} |
||||
|
||||
@Override |
||||
public String mark4Provider() { |
||||
return getClass().getName(); |
||||
} |
||||
} |
@ -0,0 +1,31 @@
|
||||
package com.fr.design.fun.impl; |
||||
|
||||
import com.fr.design.fun.PropertyItemPaneProvider; |
||||
import com.fr.design.mainframe.PaneHolder; |
||||
import com.fr.stable.fun.impl.AbstractProvider; |
||||
import com.fr.stable.fun.mark.API; |
||||
|
||||
/** |
||||
* created by Harrison on 2020/03/23 |
||||
**/ |
||||
@API(level = PropertyItemPaneProvider.CURRENT_LEVEL) |
||||
public abstract class AbstractPropertyItemPaneProvider<T> extends AbstractProvider implements PropertyItemPaneProvider<T> { |
||||
|
||||
@Override |
||||
public PaneHolder<T> getPaneHolder(Class<?> clazz) { |
||||
|
||||
if (sign().equals(clazz)) { |
||||
return getPathHolder0(); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
protected abstract PaneHolder<T> getPathHolder0(); |
||||
|
||||
protected abstract Class<T> sign(); |
||||
|
||||
@Override |
||||
public int currentAPILevel() { |
||||
return PropertyItemPaneProvider.CURRENT_LEVEL; |
||||
} |
||||
} |
@ -0,0 +1,42 @@
|
||||
package com.fr.design.fun.impl; |
||||
|
||||
|
||||
import com.fr.design.fun.ReportLengthUNITProvider; |
||||
import com.fr.stable.StringUtils; |
||||
import com.fr.stable.fun.impl.AbstractProvider; |
||||
import com.fr.stable.fun.mark.API; |
||||
import com.fr.stable.unit.UNIT; |
||||
|
||||
/** |
||||
* Created by kerry on 2020-04-09 |
||||
*/ |
||||
@API(level = ReportLengthUNITProvider.CURRENT_LEVEL) |
||||
public abstract class AbstractReportLengthUNITProvider extends AbstractProvider implements ReportLengthUNITProvider { |
||||
|
||||
|
||||
@Override |
||||
public int currentAPILevel() { |
||||
return CURRENT_LEVEL; |
||||
} |
||||
|
||||
@Override |
||||
public String unitText() { |
||||
return StringUtils.EMPTY; |
||||
} |
||||
|
||||
@Override |
||||
public int unitType() { |
||||
return 0; |
||||
} |
||||
|
||||
@Override |
||||
public float unit2Value4Scale(UNIT value) { |
||||
return 0; |
||||
} |
||||
|
||||
@Override |
||||
public UNIT float2UNIT(float value) { |
||||
return UNIT.ZERO; |
||||
} |
||||
} |
||||
|
@ -0,0 +1,81 @@
|
||||
package com.fr.design.gui.imenu; |
||||
|
||||
import com.fr.design.constants.UIConstants; |
||||
import com.fr.design.utils.gui.GUIPaintUtils; |
||||
import com.fr.stable.Constants; |
||||
import sun.swing.SwingUtilities2; |
||||
|
||||
import javax.swing.ButtonModel; |
||||
import javax.swing.JMenu; |
||||
import javax.swing.JMenuItem; |
||||
import javax.swing.UIManager; |
||||
import javax.swing.plaf.basic.BasicMenuItemUI; |
||||
import java.awt.Color; |
||||
import java.awt.FontMetrics; |
||||
import java.awt.Graphics; |
||||
import java.awt.Graphics2D; |
||||
import java.awt.Rectangle; |
||||
|
||||
/** |
||||
* created by Harrison on 2020/03/22 |
||||
**/ |
||||
public class UIMenuItemUI extends BasicMenuItemUI { |
||||
|
||||
@Override |
||||
protected void paintBackground(Graphics g, JMenuItem menuItem, Color bgColor) { |
||||
if (menuItem.getIcon() == null) { |
||||
super.paintBackground(g, menuItem, bgColor); |
||||
return; |
||||
} |
||||
ButtonModel model = menuItem.getModel(); |
||||
Color oldColor = g.getColor(); |
||||
int menuWidth = menuItem.getWidth(); |
||||
int menuHeight = menuItem.getHeight(); |
||||
|
||||
g.setColor(UIConstants.NORMAL_BACKGROUND); |
||||
g.fillRect(0, 0, menuWidth, menuHeight); |
||||
if (menuItem.isOpaque()) { |
||||
if (model.isArmed() || (menuItem instanceof JMenu && model.isSelected())) { |
||||
GUIPaintUtils.fillPaint((Graphics2D) g, 30, 0, menuWidth - 30, menuHeight, true, Constants.NULL, UIConstants.FLESH_BLUE, 7); |
||||
} else { |
||||
GUIPaintUtils.fillPaint((Graphics2D) g, 30, 0, menuWidth - 30, menuHeight, true, Constants.NULL, menuItem.getBackground(), 7); |
||||
} |
||||
g.setColor(oldColor); |
||||
} else if (model.isArmed() || (menuItem instanceof JMenu && |
||||
model.isSelected())) { |
||||
GUIPaintUtils.fillPaint((Graphics2D) g, 30, 0, menuWidth - 30, menuHeight, true, Constants.NULL, UIConstants.FLESH_BLUE, 7); |
||||
g.setColor(oldColor); |
||||
} |
||||
} |
||||
|
||||
protected void paintText(Graphics g, JMenuItem menuItem, Rectangle textRect, String text) { |
||||
ButtonModel model = menuItem.getModel(); |
||||
FontMetrics fm = SwingUtilities2.getFontMetrics(menuItem, g); |
||||
int mnemIndex = menuItem.getDisplayedMnemonicIndex(); |
||||
|
||||
if (!model.isEnabled()) { |
||||
// *** paint the text disabled
|
||||
if (UIManager.get("MenuItem.disabledForeground") instanceof Color) { |
||||
g.setColor(UIManager.getColor("MenuItem.disabledForeground")); |
||||
SwingUtilities2.drawStringUnderlineCharAt(menuItem, g, text, |
||||
-1, textRect.x, textRect.y + fm.getAscent()); |
||||
} else { |
||||
g.setColor(menuItem.getBackground().brighter()); |
||||
SwingUtilities2.drawStringUnderlineCharAt(menuItem, g, text, |
||||
-1, textRect.x, textRect.y + fm.getAscent()); |
||||
g.setColor(menuItem.getBackground().darker()); |
||||
SwingUtilities2.drawStringUnderlineCharAt(menuItem, g, text, |
||||
-1, textRect.x - 1, textRect.y + |
||||
fm.getAscent() - 1); |
||||
} |
||||
} else { |
||||
// *** paint the text normally
|
||||
if (model.isArmed() || (menuItem instanceof JMenu && model.isSelected())) { |
||||
g.setColor(Color.WHITE); // Uses protected field.
|
||||
} |
||||
SwingUtilities2.drawStringUnderlineCharAt(menuItem, g, text, |
||||
-1, textRect.x, textRect.y + fm.getAscent()); |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,17 @@
|
||||
package com.fr.design.mainframe; |
||||
|
||||
import javax.swing.JPanel; |
||||
|
||||
/** |
||||
* created by Harrison on 2020/03/23 |
||||
**/ |
||||
public interface PaneHolder<T> { |
||||
|
||||
/** |
||||
* 得到 Pane |
||||
* |
||||
* @param arg 参数 |
||||
* @return 面板 |
||||
*/ |
||||
JPanel getInstance(T arg); |
||||
} |
@ -0,0 +1,78 @@
|
||||
package com.fr.design.mainframe; |
||||
|
||||
import java.awt.event.ActionListener; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* created by Harrison on 2020/03/23 |
||||
**/ |
||||
public class PropertyItemBean { |
||||
|
||||
private String name; |
||||
private String title; |
||||
private String btnIconName; |
||||
private String btnIconBaseDir; |
||||
private EastRegionContainerPane.PropertyMode[] visibleModes; |
||||
private EastRegionContainerPane.PropertyMode[] enableModes; |
||||
private List<ActionListener> buttonListeners; |
||||
|
||||
public PropertyItemBean() { |
||||
} |
||||
|
||||
public String getName() { |
||||
return name; |
||||
} |
||||
|
||||
public void setName(String name) { |
||||
this.name = name; |
||||
} |
||||
|
||||
public String getTitle() { |
||||
return title; |
||||
} |
||||
|
||||
public void setTitle(String title) { |
||||
this.title = title; |
||||
} |
||||
|
||||
public String getBtnIconName() { |
||||
return btnIconName; |
||||
} |
||||
|
||||
public void setBtnIconName(String btnIconName) { |
||||
this.btnIconName = btnIconName; |
||||
} |
||||
|
||||
public String getBtnIconBaseDir() { |
||||
|
||||
return btnIconBaseDir; |
||||
} |
||||
|
||||
public void setBtnIconBaseDir(String btnIconBaseDir) { |
||||
this.btnIconBaseDir = btnIconBaseDir; |
||||
} |
||||
|
||||
public EastRegionContainerPane.PropertyMode[] getVisibleModes() { |
||||
return visibleModes; |
||||
} |
||||
|
||||
public void setVisibleModes(EastRegionContainerPane.PropertyMode[] visibleModes) { |
||||
this.visibleModes = visibleModes; |
||||
} |
||||
|
||||
public EastRegionContainerPane.PropertyMode[] getEnableModes() { |
||||
return enableModes; |
||||
} |
||||
|
||||
public void setEnableModes(EastRegionContainerPane.PropertyMode[] enableModes) { |
||||
this.enableModes = enableModes; |
||||
} |
||||
|
||||
public List<ActionListener> getButtonListeners() { |
||||
return buttonListeners; |
||||
} |
||||
|
||||
public void setButtonListeners(List<ActionListener> buttonListeners) { |
||||
this.buttonListeners = buttonListeners; |
||||
} |
||||
} |
@ -0,0 +1,233 @@
|
||||
package com.fr.design.mainframe.mobile.ui; |
||||
|
||||
import com.fr.design.constants.LayoutConstants; |
||||
import com.fr.design.designer.IntervalConstants; |
||||
import com.fr.design.gui.ibutton.UIColorButton; |
||||
import com.fr.design.gui.icombobox.LineComboBox; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.gui.ispinner.UnsignedIntUISpinner; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.design.layout.TableLayoutHelper; |
||||
import com.fr.design.mainframe.widget.MobileTabFontConfPane; |
||||
import com.fr.design.mainframe.widget.UITitleSplitLine; |
||||
import com.fr.design.mainframe.widget.preview.MobileTemplatePreviewPane; |
||||
import com.fr.design.style.color.ColorSelectBox; |
||||
import com.fr.design.style.color.NewColorSelectBox; |
||||
import com.fr.form.ui.container.cardlayout.WCardTagLayout; |
||||
import com.fr.general.cardtag.mobile.MobileTemplateStyle; |
||||
import com.fr.general.cardtag.mobile.TabFontConfig; |
||||
import com.fr.general.cardtag.mobile.UniteStyle; |
||||
import com.fr.stable.CoreConstants; |
||||
|
||||
import javax.swing.*; |
||||
import java.awt.*; |
||||
|
||||
public class UniteStyleDefinePane extends MobileTemplateStyleDefinePane { |
||||
private static final int SPLIT_LINE_WIDTH = 520; |
||||
private static final int SPLIT_LINE_HEIGHT = 20; |
||||
|
||||
private static final int TOGGLE_BUTTON_WIDTH = 20; |
||||
private static final int LABEL_WIDTH = 75; |
||||
private static final int LINE_COMPONENT_WIDTH = 157; |
||||
private static final int LINE_COMPONENT_HEIGHT = 20; |
||||
|
||||
private UnsignedIntUISpinner paddingLeftSpinner; |
||||
private UnsignedIntUISpinner paddingRightSpinner; |
||||
|
||||
private NewColorSelectBox initialBackgroundColorBox; |
||||
private NewColorSelectBox selectedBackgroundColorBox; |
||||
|
||||
private LineComboBox borderWidthComboBox; |
||||
private ColorSelectBox borderColorBox; |
||||
private UnsignedIntUISpinner borderRadiusSpinner; |
||||
|
||||
private MobileTabFontConfPane tabFontConfPane; |
||||
private UIColorButton selectedFontColorButton; |
||||
|
||||
public UniteStyleDefinePane(WCardTagLayout tagLayout) { |
||||
super(tagLayout); |
||||
} |
||||
|
||||
@Override |
||||
protected void createBuiltinConfPane(JPanel centerPane) { |
||||
// ignore builtin conf pane
|
||||
} |
||||
|
||||
@Override |
||||
protected void createExtraConfPane(JPanel centerPane) { |
||||
UITitleSplitLine paddingSplit = new UITitleSplitLine(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Tab_Button_Padding"), SPLIT_LINE_WIDTH); |
||||
paddingSplit.setPreferredSize(new Dimension(SPLIT_LINE_WIDTH, SPLIT_LINE_HEIGHT)); |
||||
centerPane.add(paddingSplit); |
||||
centerPane.add(this.createPaddingConfPane()); |
||||
|
||||
UITitleSplitLine backgroundSplit = new UITitleSplitLine(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Tab_Button_Background"), SPLIT_LINE_WIDTH); |
||||
backgroundSplit.setPreferredSize(new Dimension(SPLIT_LINE_WIDTH, SPLIT_LINE_HEIGHT)); |
||||
centerPane.add(backgroundSplit); |
||||
centerPane.add(this.createBackgroundColorConfPanel()); |
||||
|
||||
UITitleSplitLine borderSplit = new UITitleSplitLine(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Border"), SPLIT_LINE_WIDTH); |
||||
borderSplit.setPreferredSize(new Dimension(SPLIT_LINE_WIDTH, SPLIT_LINE_HEIGHT)); |
||||
centerPane.add(borderSplit); |
||||
centerPane.add(this.createBorderConfPanel()); |
||||
|
||||
UITitleSplitLine fontSplit = new UITitleSplitLine(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Tab_Char"), SPLIT_LINE_WIDTH); |
||||
fontSplit.setPreferredSize(new Dimension(SPLIT_LINE_WIDTH, SPLIT_LINE_HEIGHT)); |
||||
centerPane.add(fontSplit); |
||||
centerPane.add(this.createFontConfPanel()); |
||||
} |
||||
|
||||
private JPanel createPaddingConfPane() { |
||||
|
||||
this.paddingLeftSpinner = new UnsignedIntUISpinner(0, Integer.MAX_VALUE, 1, UniteStyle.DEFAULT_PADDING_LEFT); |
||||
this.paddingLeftSpinner.setPreferredSize(new Dimension(62, LINE_COMPONENT_HEIGHT)); |
||||
this.paddingRightSpinner = new UnsignedIntUISpinner(0, Integer.MAX_VALUE, 1, UniteStyle.DEFAULT_PADDING_RIGHT); |
||||
this.paddingRightSpinner.setPreferredSize(new Dimension(62, LINE_COMPONENT_HEIGHT)); |
||||
|
||||
UILabel paddingLeftLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Left") + ":", SwingConstants.RIGHT); |
||||
paddingLeftLabel.setPreferredSize(new Dimension(LABEL_WIDTH, LINE_COMPONENT_HEIGHT)); |
||||
UILabel paddingRightLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Right") + ":", SwingConstants.RIGHT); |
||||
paddingLeftLabel.setPreferredSize(new Dimension(LABEL_WIDTH, LINE_COMPONENT_HEIGHT)); |
||||
|
||||
JPanel paddingPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{ |
||||
paddingLeftLabel, paddingLeftSpinner, paddingRightLabel,paddingRightSpinner |
||||
}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_MEDIUM); |
||||
paddingPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 20)); |
||||
|
||||
return paddingPanel; |
||||
} |
||||
|
||||
private JPanel createBackgroundColorConfPanel() { |
||||
this.initialBackgroundColorBox = new NewColorSelectBox(LINE_COMPONENT_WIDTH); |
||||
this.initialBackgroundColorBox.setPreferredSize(new Dimension(LINE_COMPONENT_WIDTH, LINE_COMPONENT_HEIGHT)); |
||||
this.selectedBackgroundColorBox = new NewColorSelectBox(LINE_COMPONENT_WIDTH); |
||||
this.selectedBackgroundColorBox.setPreferredSize(new Dimension(LINE_COMPONENT_WIDTH, LINE_COMPONENT_HEIGHT)); |
||||
|
||||
UILabel initialBackgroundColorLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Init_Fill") + ":", SwingConstants.RIGHT); |
||||
initialBackgroundColorLabel.setPreferredSize(new Dimension(LABEL_WIDTH, LINE_COMPONENT_HEIGHT)); |
||||
UILabel selectedBackgroundColorLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Select_Fill") + ":", SwingConstants.RIGHT); |
||||
selectedBackgroundColorLabel.setPreferredSize(new Dimension(LABEL_WIDTH, LINE_COMPONENT_HEIGHT)); |
||||
|
||||
JPanel backgroundColorPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{ |
||||
new Component[]{ initialBackgroundColorLabel, initialBackgroundColorBox }, |
||||
new Component[]{ selectedBackgroundColorLabel, selectedBackgroundColorBox } |
||||
}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_MEDIUM); |
||||
backgroundColorPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 20)); |
||||
|
||||
return backgroundColorPanel; |
||||
} |
||||
|
||||
private JPanel createBorderConfPanel() { |
||||
this.borderWidthComboBox = new LineComboBox(CoreConstants.UNDERLINE_STYLE_ARRAY); |
||||
this.borderWidthComboBox.setPreferredSize(new Dimension(LINE_COMPONENT_WIDTH, LINE_COMPONENT_HEIGHT)); |
||||
this.borderColorBox = new ColorSelectBox(LINE_COMPONENT_WIDTH); |
||||
this.borderColorBox.setPreferredSize(new Dimension(LINE_COMPONENT_WIDTH, LINE_COMPONENT_HEIGHT)); |
||||
this.borderRadiusSpinner = new UnsignedIntUISpinner(0, Integer.MAX_VALUE, 1, UniteStyle.DEFAULT_BORDER_RADIUS); |
||||
this.borderRadiusSpinner.setPreferredSize(new Dimension(LINE_COMPONENT_WIDTH, LINE_COMPONENT_HEIGHT)); |
||||
|
||||
UILabel borderSizeLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Line_Style") + ":", SwingConstants.RIGHT); |
||||
borderSizeLabel.setPreferredSize(new Dimension(LABEL_WIDTH, LINE_COMPONENT_HEIGHT)); |
||||
UILabel borderColorLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Colors") + ":", SwingConstants.RIGHT); |
||||
borderColorLabel.setPreferredSize(new Dimension(LABEL_WIDTH, LINE_COMPONENT_HEIGHT)); |
||||
UILabel borderRadiusLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Radius") + ":", SwingConstants.RIGHT); |
||||
borderRadiusLabel.setPreferredSize(new Dimension(LABEL_WIDTH, LINE_COMPONENT_HEIGHT)); |
||||
|
||||
JPanel borderPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{ |
||||
new Component[]{ borderSizeLabel, borderWidthComboBox}, |
||||
new Component[]{ borderColorLabel, borderColorBox }, |
||||
new Component[]{ borderRadiusLabel, borderRadiusSpinner } |
||||
}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_MEDIUM); |
||||
borderPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 20)); |
||||
|
||||
return borderPanel; |
||||
} |
||||
|
||||
private JPanel createFontConfPanel() { |
||||
this.tabFontConfPane = new MobileTabFontConfPane(); |
||||
this.selectedFontColorButton = new UIColorButton(); |
||||
this.selectedFontColorButton.setPreferredSize(new Dimension(TOGGLE_BUTTON_WIDTH, LINE_COMPONENT_HEIGHT)); |
||||
JPanel selectedFontColorPanel = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); |
||||
selectedFontColorPanel.add(this.selectedFontColorButton); |
||||
|
||||
UILabel initialFontLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Tab_Init_Char") + ":", SwingConstants.RIGHT); |
||||
initialFontLabel.setPreferredSize(new Dimension(LABEL_WIDTH, LINE_COMPONENT_HEIGHT)); |
||||
UILabel selectedFontLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Tab_Select_Char") + ":", SwingConstants.RIGHT); |
||||
selectedFontLabel.setPreferredSize(new Dimension(LABEL_WIDTH, LINE_COMPONENT_HEIGHT)); |
||||
|
||||
JPanel fontPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{ |
||||
new Component[]{ initialFontLabel, tabFontConfPane }, |
||||
new Component[]{ selectedFontLabel, selectedFontColorPanel } |
||||
}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_MEDIUM); |
||||
fontPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 20)); |
||||
|
||||
return fontPanel; |
||||
} |
||||
|
||||
@Override |
||||
protected void initDefaultConfig() { |
||||
this.paddingLeftSpinner.setValue(UniteStyle.DEFAULT_PADDING_LEFT); |
||||
this.paddingRightSpinner.setValue(UniteStyle.DEFAULT_PADDING_RIGHT); |
||||
|
||||
this.initialBackgroundColorBox.setSelectObject(UniteStyle.DEFAULT_INITIAL_BACKGROUND_COLOR); |
||||
this.selectedBackgroundColorBox.setSelectObject(UniteStyle.DEFAULT_SELECTED_BACKGROUND_COLOR); |
||||
|
||||
this.borderWidthComboBox.setSelectedLineStyle(UniteStyle.DEFAULT_BORDER_LINE.getLineStyle()); |
||||
this.borderColorBox.setSelectObject(UniteStyle.DEFAULT_BORDER_LINE.getColor()); |
||||
this.borderRadiusSpinner.setValue(UniteStyle.DEFAULT_BORDER_RADIUS); |
||||
|
||||
this.tabFontConfPane.populate(UniteStyle.DEFAULT_TAB_FONT.getFont()); |
||||
this.selectedFontColorButton.setColor(UniteStyle.DEFAULT_TAB_FONT.getSelectColor()); |
||||
} |
||||
|
||||
@Override |
||||
protected MobileTemplatePreviewPane createPreviewPane() { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
protected MobileTemplateStyle getDefaultTemplateStyle() { |
||||
return new UniteStyle(); |
||||
} |
||||
|
||||
@Override |
||||
public void populateSubStyle(MobileTemplateStyle ob) { |
||||
UniteStyle style = (UniteStyle) ob; |
||||
this.paddingLeftSpinner.setValue(style.getPaddingLeft()); |
||||
this.paddingRightSpinner.setValue(style.getPaddingRight()); |
||||
|
||||
this.initialBackgroundColorBox.setSelectObject(style.getInitialColor()); |
||||
this.selectedBackgroundColorBox.setSelectObject(style.getSelectColor()); |
||||
|
||||
this.borderWidthComboBox.setSelectedLineStyle(style.getBorderLineStyle()); |
||||
this.borderColorBox.setSelectObject(style.getBorderColor()); |
||||
this.borderRadiusSpinner.setValue(style.getBorderRadius()); |
||||
|
||||
this.tabFontConfPane.populate(style.getTabFontConfig().getFont()); |
||||
this.selectedFontColorButton.setColor(style.getTabFontConfig().getSelectColor()); |
||||
} |
||||
|
||||
@Override |
||||
public MobileTemplateStyle updateSubStyle() { |
||||
UniteStyle style = new UniteStyle(); |
||||
style.setPaddingLeft((int) this.paddingLeftSpinner.getValue()); |
||||
style.setPaddingRight((int) this.paddingRightSpinner.getValue()); |
||||
|
||||
style.setInitialColor(this.initialBackgroundColorBox.getSelectObject()); |
||||
style.setSelectColor(this.selectedBackgroundColorBox.getSelectObject()); |
||||
|
||||
style.setBorderLineStyle(this.borderWidthComboBox.getSelectedLineStyle()); |
||||
style.setBorderColor(this.borderColorBox.getSelectObject()); |
||||
style.setBorderRadius((int) this.borderRadiusSpinner.getValue()); |
||||
|
||||
TabFontConfig config = new TabFontConfig(); |
||||
config.setFont(this.tabFontConfPane.update()); |
||||
config.setSelectColor(this.selectedFontColorButton.getColor()); |
||||
style.setTabFontConfig(config); |
||||
|
||||
return style; |
||||
} |
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return null; |
||||
} |
||||
} |
@ -0,0 +1,200 @@
|
||||
package com.fr.design.menu; |
||||
|
||||
import com.fr.design.gui.imenu.UIMenu; |
||||
import com.fr.design.gui.imenu.UIScrollMenu; |
||||
import com.fr.design.notification.SnapChat; |
||||
import com.fr.design.notification.SnapChatConfig; |
||||
import com.fr.design.notification.SnapChatKey; |
||||
|
||||
import javax.swing.JMenu; |
||||
import javax.swing.event.MenuEvent; |
||||
import javax.swing.event.MenuListener; |
||||
import java.awt.Color; |
||||
import java.awt.Graphics2D; |
||||
import java.awt.Image; |
||||
import java.awt.geom.Ellipse2D; |
||||
import java.awt.image.BufferedImage; |
||||
|
||||
/** |
||||
* created by Harrison on 2020/03/16 |
||||
**/ |
||||
public class SnapChatMenuDef extends MenuDef implements SnapChat { |
||||
|
||||
private SnapChatKey uniqueKey; |
||||
private SnapChatMenuUI menuUI = new SnapChatMenuUI(this); |
||||
|
||||
public SnapChatMenuDef(String name, SnapChatKey uniqueKey) { |
||||
super(name); |
||||
this.uniqueKey = uniqueKey; |
||||
} |
||||
|
||||
public SnapChatMenuDef(Boolean rePaint, SnapChatKey uniqueKey) { |
||||
super(rePaint); |
||||
this.uniqueKey = uniqueKey; |
||||
} |
||||
|
||||
public SnapChatMenuDef(String name, char mnemonic, SnapChatKey uniqueKey) { |
||||
super(name, mnemonic); |
||||
this.uniqueKey = uniqueKey; |
||||
} |
||||
|
||||
@Override |
||||
public boolean hasRead() { |
||||
|
||||
String calcKey = calcKey(); |
||||
Boolean val = SnapChatConfig.getInstance().hasRead(calcKey); |
||||
// 默认读过了。
|
||||
return val == null ? defaultStatus() : val; |
||||
} |
||||
|
||||
@Override |
||||
public void markRead() { |
||||
|
||||
String calcKey = calcKey(); |
||||
SnapChatConfig.getInstance().markRead(calcKey); |
||||
} |
||||
|
||||
@Override |
||||
public boolean defaultStatus() { |
||||
|
||||
return true; |
||||
} |
||||
|
||||
@Override |
||||
public void addShortCut(ShortCut shortCut) { |
||||
|
||||
addSnapChatNotification(shortCut); |
||||
super.addShortCut(shortCut); |
||||
} |
||||
|
||||
@Override |
||||
public void insertShortCut(int index, ShortCut shortCut) { |
||||
|
||||
addSnapChatNotification(shortCut); |
||||
super.insertShortCut(index, shortCut); |
||||
} |
||||
|
||||
|
||||
@Override |
||||
public SnapChatKey key() { |
||||
|
||||
return this.uniqueKey; |
||||
} |
||||
|
||||
@Override |
||||
protected MenuListener createMenuListener() { |
||||
|
||||
return new SnapChatMenuListener(); |
||||
} |
||||
|
||||
/** |
||||
* 添加提醒 |
||||
* |
||||
* @param shortCut 快捷方式 |
||||
*/ |
||||
private void addSnapChatNotification(ShortCut shortCut) { |
||||
|
||||
if (shortCut instanceof SnapChatUpdateAction) { |
||||
SnapChatUpdateAction action = (SnapChatUpdateAction) shortCut; |
||||
if (!action.hasRead()) { |
||||
String calcKey = calcKey(); |
||||
SnapChatConfig.getInstance().resetRead(calcKey); |
||||
} |
||||
} |
||||
} |
||||
|
||||
private String calcKey() { |
||||
|
||||
return key().calc(); |
||||
} |
||||
|
||||
@Override |
||||
protected UIMenu createJMenu0() { |
||||
|
||||
UIMenu createdJMenu; |
||||
if (hasScrollSubMenu) { |
||||
createdJMenu = new SnapChatUIScrollMenu(this.getName()); |
||||
} else if (isHeadMenu){ |
||||
createdJMenu = new SnapChatUIHeadMenu(this.getName()); |
||||
} else { |
||||
createdJMenu = new SnapChatUIMenu(this.getName()); |
||||
} |
||||
return createdJMenu; |
||||
} |
||||
|
||||
private class SnapChatMenuListener implements MenuListener { |
||||
|
||||
@Override |
||||
public void menuSelected(MenuEvent e) { |
||||
|
||||
markRead(); |
||||
Object source = e.getSource(); |
||||
if (!(source instanceof JMenu)) { |
||||
return; |
||||
} |
||||
updateMenu(); |
||||
} |
||||
|
||||
@Override |
||||
public void menuDeselected(MenuEvent e) { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public void menuCanceled(MenuEvent e) { |
||||
|
||||
} |
||||
} |
||||
|
||||
private class SnapChatUIScrollMenu extends UIScrollMenu { |
||||
|
||||
public SnapChatUIScrollMenu(String s) { |
||||
super(s); |
||||
} |
||||
|
||||
@Override |
||||
public void updateUI() { |
||||
setUI(menuUI); |
||||
} |
||||
} |
||||
|
||||
private class SnapChatUIMenu extends UIMenu { |
||||
|
||||
public SnapChatUIMenu(String name) { |
||||
|
||||
super(name); |
||||
} |
||||
|
||||
@Override |
||||
public void updateUI() { |
||||
|
||||
setUI(menuUI); |
||||
} |
||||
} |
||||
|
||||
private class SnapChatUIHeadMenu extends UIMenu { |
||||
|
||||
public SnapChatUIHeadMenu(String name) { |
||||
|
||||
super(name); |
||||
} |
||||
|
||||
@Override |
||||
public void updateUI() { |
||||
|
||||
setUI(menuUI); |
||||
} |
||||
} |
||||
|
||||
public static void main(String[] args) { |
||||
|
||||
BufferedImage image = new BufferedImage(16, 16, Image.SCALE_DEFAULT); |
||||
Graphics2D g2d = image.createGraphics(); |
||||
g2d.setColor(Color.green); |
||||
Ellipse2D.Double shape = |
||||
new Ellipse2D.Double(2, 2, 1, 1); |
||||
g2d.fill(shape); |
||||
g2d.draw(shape); |
||||
System.out.println(); |
||||
} |
||||
} |
@ -0,0 +1,31 @@
|
||||
package com.fr.design.menu; |
||||
|
||||
import com.fr.design.gui.imenu.UIMenuItemUI; |
||||
|
||||
import javax.swing.JMenuItem; |
||||
import java.awt.Graphics; |
||||
import java.awt.Rectangle; |
||||
|
||||
/** |
||||
* created by Harrison on 2020/03/22 |
||||
**/ |
||||
class SnapChatMenuItemUI extends UIMenuItemUI { |
||||
|
||||
private final SnapChatUpdateAction snapChatUpdateAction; |
||||
|
||||
public SnapChatMenuItemUI(SnapChatUpdateAction snapChatUpdateAction) { |
||||
|
||||
this.snapChatUpdateAction = snapChatUpdateAction; |
||||
} |
||||
|
||||
@Override |
||||
protected void paintText(Graphics g, JMenuItem menuItem, Rectangle textRect, String text) { |
||||
|
||||
super.paintText(g, menuItem, textRect, text); |
||||
|
||||
if (!snapChatUpdateAction.hasRead()) { |
||||
SnapChatUtil.paintSnapChat(g, textRect); |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,29 @@
|
||||
package com.fr.design.menu; |
||||
|
||||
import com.fr.design.gui.imenu.UIMenuUI; |
||||
|
||||
import javax.swing.JMenuItem; |
||||
import java.awt.Graphics; |
||||
import java.awt.Rectangle; |
||||
|
||||
/** |
||||
* created by Harrison on 2020/03/22 |
||||
**/ |
||||
public class SnapChatMenuUI extends UIMenuUI { |
||||
|
||||
private SnapChatMenuDef menuDef; |
||||
|
||||
public SnapChatMenuUI(SnapChatMenuDef menuDef) { |
||||
this.menuDef = menuDef; |
||||
} |
||||
|
||||
@Override |
||||
protected void paintText(Graphics g, JMenuItem menuItem, Rectangle textRect, String text) { |
||||
|
||||
super.paintText(g, menuItem, textRect, text); |
||||
|
||||
if (!menuDef.hasRead()) { |
||||
SnapChatUtil.paintSnapChat(g, textRect); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,79 @@
|
||||
package com.fr.design.menu; |
||||
|
||||
import com.fr.design.actions.UpdateAction; |
||||
import com.fr.design.gui.imenu.UIMenuItem; |
||||
import com.fr.design.notification.SnapChat; |
||||
import com.fr.design.notification.SnapChatConfig; |
||||
import com.fr.design.notification.SnapChatKey; |
||||
|
||||
import java.awt.event.ActionEvent; |
||||
|
||||
/** |
||||
* created by Harrison on 2020/03/22 |
||||
**/ |
||||
public abstract class SnapChatUpdateAction extends UpdateAction implements SnapChat { |
||||
|
||||
private SnapChatKey uniqueKey; |
||||
|
||||
public SnapChatUpdateAction(SnapChatKey uniqueKey) { |
||||
this.uniqueKey = uniqueKey; |
||||
} |
||||
|
||||
@Override |
||||
public final void actionPerformed(ActionEvent e) { |
||||
|
||||
markRead(); |
||||
actionPerformed0(e); |
||||
} |
||||
|
||||
protected abstract void actionPerformed0(ActionEvent e); |
||||
|
||||
@Override |
||||
public boolean hasRead() { |
||||
|
||||
String calcKey = calcKey(); |
||||
Boolean val = SnapChatConfig.getInstance().hasRead(calcKey); |
||||
return val == null ? defaultStatus() : val; |
||||
} |
||||
|
||||
@Override |
||||
public void markRead() { |
||||
|
||||
String calcKey = calcKey(); |
||||
SnapChatConfig.getInstance().markRead(calcKey); |
||||
} |
||||
|
||||
@Override |
||||
public boolean defaultStatus() { |
||||
|
||||
return false; |
||||
} |
||||
|
||||
@Override |
||||
public SnapChatKey key() { |
||||
|
||||
return this.uniqueKey; |
||||
} |
||||
|
||||
private String calcKey() { |
||||
|
||||
return key().calc(); |
||||
} |
||||
|
||||
@Override |
||||
public UIMenuItem createMenuItem() { |
||||
|
||||
Object object = this.getValue(UIMenuItem.class.getName()); |
||||
if (object == null && !(object instanceof UIMenuItem)) { |
||||
UIMenuItem menuItem = new UIMenuItem(this); |
||||
// 设置名字用作单元测
|
||||
menuItem.setName(getName()); |
||||
menuItem.setUI(new SnapChatMenuItemUI(this)); |
||||
object = menuItem; |
||||
|
||||
this.putValue(UIMenuItem.class.getName(), object); |
||||
} |
||||
return (UIMenuItem) object; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,33 @@
|
||||
package com.fr.design.menu; |
||||
|
||||
import java.awt.Color; |
||||
import java.awt.Graphics; |
||||
import java.awt.Graphics2D; |
||||
import java.awt.Rectangle; |
||||
import java.awt.geom.Ellipse2D; |
||||
|
||||
/** |
||||
* created by Harrison on 2020/03/22 |
||||
**/ |
||||
public class SnapChatUtil { |
||||
|
||||
public static void paintSnapChat(Graphics g, Rectangle textRect) { |
||||
|
||||
Color oldColor = g.getColor(); |
||||
|
||||
double x = textRect.getWidth(); |
||||
x += textRect.getX(); |
||||
x += 2; |
||||
|
||||
double y = textRect.getY(); |
||||
|
||||
Graphics2D g2d = (Graphics2D) g; |
||||
g2d.setColor(Color.red); |
||||
Ellipse2D.Double shape = |
||||
new Ellipse2D.Double(x, y, 4, 4); |
||||
g2d.fill(shape); |
||||
g2d.draw(shape); |
||||
|
||||
g2d.setColor(oldColor); |
||||
} |
||||
} |
@ -0,0 +1,35 @@
|
||||
package com.fr.design.notification; |
||||
|
||||
/** |
||||
* 阅后即焚的消息提醒 |
||||
* |
||||
* created by Harrison on 2020/03/16 |
||||
**/ |
||||
public interface SnapChat { |
||||
|
||||
/** |
||||
* 默认状态 |
||||
* |
||||
* @return 默认状态 |
||||
*/ |
||||
boolean defaultStatus(); |
||||
|
||||
/** |
||||
* 已读 |
||||
* |
||||
* @return 是否为已读 |
||||
*/ |
||||
boolean hasRead(); |
||||
|
||||
/** |
||||
* 标记为已读 |
||||
*/ |
||||
void markRead(); |
||||
|
||||
/** |
||||
* 独一无二的标志 |
||||
* |
||||
* @return 字符标志 |
||||
*/ |
||||
SnapChatKey key(); |
||||
} |
@ -0,0 +1,38 @@
|
||||
package com.fr.design.notification; |
||||
|
||||
import com.fr.stable.CommonUtils; |
||||
|
||||
/** |
||||
* created by Harrison on 2020/03/16 |
||||
**/ |
||||
public abstract class SnapChatAllTypes { |
||||
|
||||
public enum Menu implements SnapChatKey { |
||||
|
||||
/** |
||||
* 社区按钮 |
||||
*/ |
||||
BBS("BBS"); |
||||
|
||||
private static final String SIGN = "0001"; |
||||
|
||||
private String key; |
||||
|
||||
Menu(String key) { |
||||
this.key = key; |
||||
} |
||||
|
||||
public String getKey() { |
||||
return key; |
||||
} |
||||
|
||||
@Override |
||||
public String calc() { |
||||
|
||||
return CommonUtils.join( |
||||
new String[]{SIGN, getKey()}, "-" |
||||
); |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,93 @@
|
||||
package com.fr.design.notification; |
||||
|
||||
import com.fr.stable.StringUtils; |
||||
import com.fr.stable.xml.XMLPrintWriter; |
||||
import com.fr.stable.xml.XMLReadable; |
||||
import com.fr.stable.xml.XMLable; |
||||
import com.fr.stable.xml.XMLableReader; |
||||
|
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* created by Harrison on 2020/03/16 |
||||
**/ |
||||
@SuppressWarnings("unchecked") |
||||
public class SnapChatConfig implements XMLable { |
||||
|
||||
public static final String XML_TAG = "SnapChatConfig"; |
||||
|
||||
/** |
||||
* 已经阅读过的属性 |
||||
*/ |
||||
private Map<String, Boolean> markReadMap = new HashMap<>(8); |
||||
|
||||
private static final SnapChatConfig INSTANCE = new SnapChatConfig(); |
||||
|
||||
public static SnapChatConfig getInstance() { |
||||
return INSTANCE; |
||||
} |
||||
|
||||
public Boolean hasRead(String key) { |
||||
|
||||
Map<String, Boolean> map = markReadMap; |
||||
return map.get(key); |
||||
} |
||||
|
||||
public void markRead(String key) { |
||||
|
||||
markReadMap.put(key, Boolean.TRUE); |
||||
} |
||||
|
||||
public void resetRead(String key) { |
||||
|
||||
markReadMap.put(key, Boolean.FALSE); |
||||
} |
||||
|
||||
@Override |
||||
public void readXML(XMLableReader reader) { |
||||
|
||||
if (reader.isChildNode()) { |
||||
if ("item".equals(reader.getTagName())) { |
||||
String tmpVal = reader.getElementValue(); |
||||
Boolean markRead = Boolean.valueOf(tmpVal); |
||||
markReadMap.put(reader.getAttrAsString("key", StringUtils.EMPTY), markRead); |
||||
} |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public void writeXML(XMLPrintWriter writer) { |
||||
|
||||
writer.startTAG(XML_TAG); |
||||
writeMarkReadMapXML(writer); |
||||
writer.end(); |
||||
} |
||||
|
||||
private void readMarkReadMapXML(XMLableReader reader) { |
||||
|
||||
reader.readXMLObject(new XMLReadable() { |
||||
@Override |
||||
public void readXML(XMLableReader reader) { |
||||
} |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* 写入map |
||||
*/ |
||||
private void writeMarkReadMapXML(XMLPrintWriter writer) { |
||||
|
||||
writer.startTAG("MarkReadMap"); |
||||
for (Map.Entry<String, Boolean> item : markReadMap.entrySet()) { |
||||
writer.startTAG("item").attr("key", item.getKey()).textNode(item.getValue().toString()).end(); |
||||
} |
||||
writer.end(); |
||||
} |
||||
|
||||
@Override |
||||
public Object clone() throws CloneNotSupportedException { |
||||
|
||||
return super.clone(); |
||||
} |
||||
} |
@ -0,0 +1,9 @@
|
||||
package com.fr.design.notification; |
||||
|
||||
/** |
||||
* created by Harrison on 2020/03/16 |
||||
**/ |
||||
public interface SnapChatKey { |
||||
|
||||
String calc(); |
||||
} |
@ -0,0 +1,73 @@
|
||||
package com.fr.design.unit; |
||||
|
||||
import com.fr.design.ExtraDesignClassManager; |
||||
import com.fr.design.fun.ReportLengthUNITProvider; |
||||
import com.fr.design.unit.impl.CMReportLengthUNIT; |
||||
import com.fr.design.unit.impl.INCHReportLengthUNIT; |
||||
import com.fr.design.unit.impl.MMReportLengthUNIT; |
||||
import com.fr.design.unit.impl.PTReportLengthUNIT; |
||||
import com.fr.general.GeneralContext; |
||||
import com.fr.plugin.context.PluginContext; |
||||
import com.fr.plugin.manage.PluginFilter; |
||||
import com.fr.plugin.observer.PluginEvent; |
||||
import com.fr.plugin.observer.PluginEventListener; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
import java.util.Set; |
||||
|
||||
/** |
||||
* Created by kerry on 2020-04-09 |
||||
*/ |
||||
public class UnitConvertUtil { |
||||
private static List<ReportLengthUNITProvider> lengthUNITList = new ArrayList<ReportLengthUNITProvider>(); |
||||
|
||||
static { |
||||
GeneralContext.listenPluginRunningChanged(new PluginEventListener() { |
||||
@Override |
||||
public void on(PluginEvent pluginEvent) { |
||||
initSupportedReportLengthUNIT(); |
||||
} |
||||
}, new PluginFilter() { |
||||
@Override |
||||
public boolean accept(PluginContext pluginContext) { |
||||
return pluginContext.contain(ReportLengthUNITProvider.MARK_STRING); |
||||
} |
||||
}); |
||||
|
||||
initSupportedReportLengthUNIT(); |
||||
} |
||||
|
||||
private static void initSupportedReportLengthUNIT(){ |
||||
lengthUNITList.clear(); |
||||
lengthUNITList.add(new MMReportLengthUNIT()); |
||||
lengthUNITList.add(new CMReportLengthUNIT()); |
||||
lengthUNITList.add(new INCHReportLengthUNIT()); |
||||
lengthUNITList.add(new PTReportLengthUNIT()); |
||||
Set<ReportLengthUNITProvider> providers = ExtraDesignClassManager.getInstance().getArray(ReportLengthUNITProvider.MARK_STRING); |
||||
for (ReportLengthUNITProvider provider : providers) { |
||||
lengthUNITList.add(provider); |
||||
} |
||||
} |
||||
|
||||
private UnitConvertUtil() { |
||||
|
||||
} |
||||
|
||||
|
||||
public static ReportLengthUNITProvider parseLengthUNIT(int unitType) { |
||||
for (ReportLengthUNITProvider lengthUNIT : lengthUNITList) { |
||||
if (unitType == lengthUNIT.unitType()) { |
||||
return lengthUNIT; |
||||
} |
||||
} |
||||
return new MMReportLengthUNIT(); |
||||
} |
||||
|
||||
public static String[] getUnitItems() { |
||||
String[] unitItems = new String[lengthUNITList.size()]; |
||||
for (int i = 0; i < lengthUNITList.size(); i++) { |
||||
unitItems[i] = lengthUNITList.get(i).unitText(); |
||||
} |
||||
return unitItems; |
||||
} |
||||
} |
@ -0,0 +1,32 @@
|
||||
package com.fr.design.unit.impl; |
||||
|
||||
import com.fr.design.fun.impl.AbstractReportLengthUNITProvider; |
||||
import com.fr.stable.Constants; |
||||
import com.fr.stable.unit.CM; |
||||
import com.fr.stable.unit.UNIT; |
||||
|
||||
/** |
||||
* Created by kerry on 2020-04-09 |
||||
*/ |
||||
public class CMReportLengthUNIT extends AbstractReportLengthUNITProvider { |
||||
@Override |
||||
public String unitText() { |
||||
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Unit_CM"); |
||||
} |
||||
|
||||
@Override |
||||
public int unitType() { |
||||
return Constants.UNIT_CM; |
||||
} |
||||
|
||||
@Override |
||||
public float unit2Value4Scale(UNIT value) { |
||||
return value.toCMValue4Scale2(); |
||||
} |
||||
|
||||
@Override |
||||
public UNIT float2UNIT(float value) { |
||||
return new CM(value); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,31 @@
|
||||
package com.fr.design.unit.impl; |
||||
|
||||
import com.fr.design.fun.impl.AbstractReportLengthUNITProvider; |
||||
import com.fr.stable.Constants; |
||||
import com.fr.stable.unit.INCH; |
||||
import com.fr.stable.unit.UNIT; |
||||
|
||||
/** |
||||
* Created by kerry on 2020-04-09 |
||||
*/ |
||||
public class INCHReportLengthUNIT extends AbstractReportLengthUNITProvider { |
||||
@Override |
||||
public String unitText() { |
||||
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Unit_INCH"); |
||||
} |
||||
|
||||
@Override |
||||
public int unitType() { |
||||
return Constants.UNIT_INCH; |
||||
} |
||||
|
||||
@Override |
||||
public float unit2Value4Scale(UNIT value) { |
||||
return value.toINCHValue4Scale3(); |
||||
} |
||||
|
||||
@Override |
||||
public UNIT float2UNIT(float value) { |
||||
return new INCH(value); |
||||
} |
||||
} |
@ -0,0 +1,31 @@
|
||||
package com.fr.design.unit.impl; |
||||
|
||||
import com.fr.design.fun.impl.AbstractReportLengthUNITProvider; |
||||
import com.fr.stable.Constants; |
||||
import com.fr.stable.unit.MM; |
||||
import com.fr.stable.unit.UNIT; |
||||
|
||||
/** |
||||
* Created by kerry on 2020-04-09 |
||||
*/ |
||||
public class MMReportLengthUNIT extends AbstractReportLengthUNITProvider { |
||||
@Override |
||||
public String unitText() { |
||||
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Unit_MM"); |
||||
} |
||||
|
||||
@Override |
||||
public int unitType() { |
||||
return Constants.UNIT_MM; |
||||
} |
||||
|
||||
@Override |
||||
public float unit2Value4Scale(UNIT value) { |
||||
return value.toMMValue4Scale2(); |
||||
} |
||||
|
||||
@Override |
||||
public UNIT float2UNIT(float value) { |
||||
return new MM(value); |
||||
} |
||||
} |
@ -0,0 +1,31 @@
|
||||
package com.fr.design.unit.impl; |
||||
|
||||
import com.fr.design.fun.impl.AbstractReportLengthUNITProvider; |
||||
import com.fr.stable.Constants; |
||||
import com.fr.stable.unit.PT; |
||||
import com.fr.stable.unit.UNIT; |
||||
|
||||
/** |
||||
* Created by kerry on 2020-04-09 |
||||
*/ |
||||
public class PTReportLengthUNIT extends AbstractReportLengthUNITProvider { |
||||
@Override |
||||
public String unitText() { |
||||
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Unit_PT_Duplicate"); |
||||
} |
||||
|
||||
@Override |
||||
public int unitType() { |
||||
return Constants.UNIT_PT; |
||||
} |
||||
|
||||
@Override |
||||
public float unit2Value4Scale(UNIT value) { |
||||
return value.toPTValue4Scale2(); |
||||
} |
||||
|
||||
@Override |
||||
public UNIT float2UNIT(float value) { |
||||
return new PT(value); |
||||
} |
||||
} |
@ -0,0 +1,106 @@
|
||||
package com.fr.design.menu; |
||||
|
||||
import com.fr.config.dao.DaoContext; |
||||
import com.fr.config.dao.impl.LocalClassHelperDao; |
||||
import com.fr.config.dao.impl.LocalEntityDao; |
||||
import com.fr.config.dao.impl.LocalXmlEntityDao; |
||||
import com.fr.design.actions.UpdateAction; |
||||
import com.fr.design.notification.SnapChatAllTypes; |
||||
import com.fr.design.notification.SnapChatConfig; |
||||
import com.fr.stable.xml.XMLableReader; |
||||
import com.fr.store.StateHubManager; |
||||
import com.fr.store.impl.MemoryLock; |
||||
import com.fr.store.impl.MemoryStore; |
||||
import com.fr.transaction.Configurations; |
||||
import com.fr.transaction.LocalConfigurationHelper; |
||||
import org.easymock.EasyMock; |
||||
import org.junit.Assert; |
||||
import org.junit.Before; |
||||
import org.junit.Test; |
||||
import org.junit.runner.RunWith; |
||||
import org.powermock.api.easymock.PowerMock; |
||||
import org.powermock.api.support.membermodification.MemberMatcher; |
||||
import org.powermock.core.classloader.annotations.PowerMockIgnore; |
||||
import org.powermock.core.classloader.annotations.PrepareForTest; |
||||
import org.powermock.modules.junit4.PowerMockRunner; |
||||
import org.powermock.reflect.Whitebox; |
||||
|
||||
import java.awt.event.ActionEvent; |
||||
import java.util.HashMap; |
||||
|
||||
@RunWith(PowerMockRunner.class) |
||||
@PrepareForTest({SnapChatConfig.class, SnapChatUpdateAction.class}) |
||||
@PowerMockIgnore({"javax.crypto.*","javax.net.ssl.*","sun.security.ssl.*","com.sun.*"}) |
||||
public class SnapChatMenuDefTest { |
||||
|
||||
@Before |
||||
public void before() throws Exception { |
||||
|
||||
DaoContext.setXmlEntityDao(new LocalXmlEntityDao()); |
||||
DaoContext.setClassHelperDao(new LocalClassHelperDao()); |
||||
DaoContext.setEntityDao(new LocalEntityDao()); |
||||
StateHubManager.setLock(new MemoryLock()); |
||||
StateHubManager.setStorage(new MemoryStore()); |
||||
Configurations.setHelper(new LocalConfigurationHelper()); |
||||
} |
||||
|
||||
@Test |
||||
public void testAddShortCut() throws Exception { |
||||
|
||||
PowerMock.suppress(MemberMatcher.constructor(UpdateAction.class)); |
||||
SnapChatConfig snapChatConfig = EasyMock.partialMockBuilder(SnapChatConfig.class) |
||||
.addMockedMethod("readXML") |
||||
.createMock(); |
||||
Whitebox.setInternalState(snapChatConfig, "markReadMap", new HashMap()); |
||||
snapChatConfig.readXML(EasyMock.anyObject(XMLableReader.class)); |
||||
EasyMock.expectLastCall().anyTimes(); |
||||
EasyMock.replay(snapChatConfig); |
||||
|
||||
PowerMock.mockStatic(SnapChatConfig.class); |
||||
EasyMock.expect(SnapChatConfig.getInstance()).andReturn(snapChatConfig).anyTimes(); |
||||
PowerMock.replayAll(); |
||||
|
||||
SnapChatMenuDef menuDef = new SnapChatMenuDef("test", SnapChatAllTypes.Menu.BBS); |
||||
ShortCut action = new SnapChatUpdateAction(SnapChatAllTypes.Menu.BBS) { |
||||
@Override |
||||
protected void actionPerformed0(ActionEvent e) { |
||||
|
||||
} |
||||
}; |
||||
|
||||
Assert.assertTrue(menuDef.hasRead()); |
||||
|
||||
menuDef.addShortCut(action); |
||||
Assert.assertFalse(menuDef.hasRead()); |
||||
} |
||||
|
||||
@Test |
||||
public void testInsertShortCut() throws Exception { |
||||
|
||||
PowerMock.suppress(MemberMatcher.constructor(UpdateAction.class)); |
||||
SnapChatConfig snapChatConfig = EasyMock.partialMockBuilder(SnapChatConfig.class) |
||||
.addMockedMethod("readXML") |
||||
.createMock(); |
||||
Whitebox.setInternalState(snapChatConfig, "markReadMap", new HashMap()); |
||||
snapChatConfig.readXML(EasyMock.anyObject(XMLableReader.class)); |
||||
EasyMock.expectLastCall().anyTimes(); |
||||
EasyMock.replay(snapChatConfig); |
||||
|
||||
PowerMock.mockStatic(SnapChatConfig.class); |
||||
EasyMock.expect(SnapChatConfig.getInstance()).andReturn(snapChatConfig).anyTimes(); |
||||
PowerMock.replayAll(); |
||||
|
||||
SnapChatMenuDef menuDef = new SnapChatMenuDef("test", SnapChatAllTypes.Menu.BBS); |
||||
ShortCut action = new SnapChatUpdateAction(SnapChatAllTypes.Menu.BBS) { |
||||
@Override |
||||
protected void actionPerformed0(ActionEvent e) { |
||||
|
||||
} |
||||
}; |
||||
|
||||
Assert.assertTrue(menuDef.hasRead()); |
||||
|
||||
menuDef.insertShortCut(0, action); |
||||
Assert.assertFalse(menuDef.hasRead()); |
||||
} |
||||
} |
@ -0,0 +1,174 @@
|
||||
package com.fr.design.chartx.component.button; |
||||
|
||||
import com.fr.base.BaseUtils; |
||||
import com.fr.base.background.ColorBackground; |
||||
import com.fr.design.style.AbstractSelectBox; |
||||
import com.fr.design.style.color.ColorSelectPane; |
||||
|
||||
import javax.swing.JPanel; |
||||
import javax.swing.event.ChangeEvent; |
||||
import javax.swing.event.ChangeListener; |
||||
import java.awt.Color; |
||||
import java.awt.Dimension; |
||||
import java.awt.Graphics; |
||||
import java.awt.Graphics2D; |
||||
import java.awt.event.MouseAdapter; |
||||
import java.awt.event.MouseEvent; |
||||
import java.awt.event.MouseListener; |
||||
import java.awt.geom.Rectangle2D; |
||||
import java.awt.image.BufferedImage; |
||||
|
||||
/** |
||||
* @author Bjorn |
||||
* @version 10.0 |
||||
* Created by Bjorn on 2020-03-06 |
||||
*/ |
||||
public class ColorButton extends AbstractSelectBox<Color> { |
||||
|
||||
private static final double DEL_WIDTH = 7; |
||||
|
||||
public static final int WIDTH = 18; |
||||
|
||||
private BufferedImage closeIcon = BaseUtils.readImageWithCache("com/fr/design/images/toolbarbtn/chartChangeClose.png"); |
||||
|
||||
private Color color; |
||||
|
||||
private boolean isMoveOn = false; |
||||
|
||||
private ColorSelectPane colorPane; |
||||
|
||||
private boolean lastButton; |
||||
|
||||
private ChangeListener changeListener; |
||||
|
||||
public ColorButton(Color color) { |
||||
this.color = color; |
||||
addMouseListener(getMouseListener()); |
||||
} |
||||
|
||||
public Dimension getPreferredSize() { |
||||
return new Dimension(WIDTH, WIDTH); |
||||
} |
||||
|
||||
private void paintDeleteButton(Graphics g2d) { |
||||
Rectangle2D bounds = this.getBounds(); |
||||
|
||||
int x = (int) (bounds.getWidth() - DEL_WIDTH); |
||||
int y = 1; |
||||
|
||||
g2d.drawImage(closeIcon, x, y, closeIcon.getWidth(), closeIcon.getHeight(), null); |
||||
} |
||||
|
||||
public void setLastButton(boolean lastButton) { |
||||
this.lastButton = lastButton; |
||||
} |
||||
|
||||
@Override |
||||
public void paint(Graphics g) { |
||||
this.setSize(WIDTH, WIDTH); |
||||
Graphics2D g2d = (Graphics2D) g; |
||||
g2d.setPaint(color); |
||||
Rectangle2D rec = new Rectangle2D.Double(0, 0, WIDTH + 1, WIDTH + 1); |
||||
g2d.fill(rec); |
||||
|
||||
if (isMoveOn && !lastButton) { |
||||
paintDeleteButton(g); |
||||
} |
||||
} |
||||
|
||||
protected void deleteButton() { |
||||
|
||||
} |
||||
|
||||
|
||||
private void checkMoveOn(boolean moveOn) { |
||||
this.isMoveOn = moveOn; |
||||
repaint(); |
||||
} |
||||
|
||||
protected MouseListener getMouseListener() { |
||||
return new MouseAdapter() { |
||||
@Override |
||||
public void mouseClicked(MouseEvent e) { |
||||
mouseClick(e); |
||||
} |
||||
|
||||
public void mouseEntered(MouseEvent e) { |
||||
checkMoveOn(true); |
||||
} |
||||
|
||||
public void mouseExited(MouseEvent e) { |
||||
checkMoveOn(false); |
||||
} |
||||
}; |
||||
} |
||||
|
||||
|
||||
public void mouseClick(MouseEvent e) { |
||||
if (!lastButton) { |
||||
Rectangle2D bounds = this.getBounds(); |
||||
if (bounds == null) { |
||||
return; |
||||
} |
||||
if (e.getX() >= bounds.getWidth() - DEL_WIDTH && e.getY() <= DEL_WIDTH) { |
||||
deleteButton(); |
||||
hidePopupMenu(); |
||||
return; |
||||
} |
||||
} |
||||
//打开颜色选择面板
|
||||
showPopupMenu(); |
||||
} |
||||
|
||||
public JPanel initWindowPane(double preferredWidth) { |
||||
// 下拉的时候重新生成面板,刷新最近使用颜色
|
||||
colorPane = new ColorSelectPane(false) { |
||||
@Override |
||||
public void setVisible(boolean b) { |
||||
super.setVisible(b); |
||||
} |
||||
}; |
||||
colorPane.addChangeListener(new ChangeListener() { |
||||
public void stateChanged(ChangeEvent e) { |
||||
hidePopupMenu(); |
||||
color = ((ColorSelectPane) e.getSource()).getColor(); |
||||
fireDisplayComponent(ColorBackground.getInstance(color)); |
||||
ColorButton.this.stateChanged(); |
||||
} |
||||
}); |
||||
return colorPane; |
||||
} |
||||
|
||||
public void stateChanged() { |
||||
if (changeListener != null) { |
||||
changeListener.stateChanged(null); |
||||
} |
||||
} |
||||
|
||||
public void addChangeListener(ChangeListener changeListener) { |
||||
this.changeListener = changeListener; |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 获取当前选中的颜色 |
||||
* |
||||
* @return 当前选中的颜色 |
||||
*/ |
||||
public Color getSelectObject() { |
||||
return this.color; |
||||
} |
||||
|
||||
/** |
||||
* 设置选中的颜色 |
||||
* |
||||
* @param color 颜色 |
||||
*/ |
||||
public void setSelectObject(Color color) { |
||||
this.color = color; |
||||
colorPane.setColor(color); |
||||
|
||||
fireDisplayComponent(ColorBackground.getInstance(color)); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,253 @@
|
||||
package com.fr.design.chartx.component.combobox; |
||||
|
||||
import com.fr.base.ChartColorMatching; |
||||
import com.fr.base.ChartPreStyleConfig; |
||||
import com.fr.design.gui.icombobox.UIComboBox; |
||||
import com.fr.design.gui.icombobox.UIComboBoxRenderer; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.general.GeneralUtils; |
||||
|
||||
import javax.swing.DefaultComboBoxModel; |
||||
import javax.swing.JLabel; |
||||
import javax.swing.JList; |
||||
import java.util.Iterator; |
||||
import java.util.LinkedHashMap; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
import java.util.Set; |
||||
import java.awt.Color; |
||||
import java.awt.Component; |
||||
import java.awt.Dimension; |
||||
import java.awt.FontMetrics; |
||||
import java.awt.Graphics; |
||||
import java.awt.Graphics2D; |
||||
import java.awt.LinearGradientPaint; |
||||
import java.awt.geom.Rectangle2D; |
||||
|
||||
/** |
||||
* @author Bjorn |
||||
* @version 10.0 |
||||
* Created by Bjorn on 2020-03-05 |
||||
* 一个带颜色展示的配色选择下拉框 |
||||
*/ |
||||
public class ColorSchemeComboBox extends UIComboBox { |
||||
|
||||
private Map<String, ColorInfo> colorSchemes; |
||||
|
||||
public ColorSchemeComboBox() { |
||||
this(null); |
||||
} |
||||
|
||||
public ColorSchemeComboBox(Map<String, ColorInfo> colorSchemes) { |
||||
//通过配色方案的集合初始化下拉控件,如果参数为null,从配置中读取配色方案。
|
||||
if (colorSchemes == null) { |
||||
colorSchemes = getColorSchemesFromConfig(); |
||||
} |
||||
this.colorSchemes = colorSchemes; |
||||
|
||||
this.setModel(new DefaultComboBoxModel(colorSchemes.keySet().toArray())); |
||||
|
||||
this.setRenderer(new ColorSchemeCellRenderer()); |
||||
} |
||||
|
||||
private Map<String, ColorInfo> getColorSchemesFromConfig() { |
||||
Map<String, ColorInfo> colorSchemes = new LinkedHashMap<>(); |
||||
ChartPreStyleConfig config = ChartPreStyleConfig.getInstance(); |
||||
|
||||
//所有的样式名称
|
||||
Iterator names = config.names(); |
||||
|
||||
//添加默认的方案和第一个方案
|
||||
String defaultName = config.getCurrentStyle(); |
||||
ChartColorMatching defaultStyle = (ChartColorMatching) config.getPreStyle(defaultName); |
||||
Object firstName = names.next(); |
||||
ChartColorMatching firstStyle = (ChartColorMatching) config.getPreStyle(firstName); |
||||
if (defaultStyle == null) { |
||||
defaultStyle = firstStyle; |
||||
} |
||||
colorSchemes.put(Toolkit.i18nText("Fine-Design_Report_Default"), colorMatchingToColorInfo(defaultStyle)); |
||||
colorSchemes.put(firstStyle.getId(), colorMatchingToColorInfo(firstStyle)); |
||||
|
||||
//添加其他的配色方案
|
||||
while (names.hasNext()) { |
||||
Object key = names.next(); |
||||
ChartColorMatching colorMatching = (ChartColorMatching) config.getPreStyle(key); |
||||
colorSchemes.put(colorMatching.getId(), colorMatchingToColorInfo(colorMatching)); |
||||
} |
||||
|
||||
//添加自定义组合色和自定义渐变色
|
||||
colorSchemes.put(Toolkit.i18nText("Fine-Design_Chart_Custom_Combination_Color"), null); |
||||
colorSchemes.put(Toolkit.i18nText("Fine-Design_Chart_Custom_Gradient"), null); |
||||
|
||||
return colorSchemes; |
||||
} |
||||
|
||||
public ColorInfo getSelectColorInfo() { |
||||
String selectedItem = (String) getSelectedItem(); |
||||
return colorSchemes.get(selectedItem); |
||||
} |
||||
|
||||
private ColorInfo colorMatchingToColorInfo(ChartColorMatching colorMatching) { |
||||
ColorInfo colorInfo = new ColorInfo(); |
||||
colorInfo.setGradient(colorMatching.getGradient()); |
||||
colorInfo.setColors(colorMatching.getColorList()); |
||||
return colorInfo; |
||||
} |
||||
|
||||
public SelectType getSelectType() { |
||||
int selectedIndex = this.getSelectedIndex(); |
||||
int itemCount = this.getItemCount(); |
||||
if (selectedIndex == itemCount - 1) { |
||||
return SelectType.GRADATION_COLOR; |
||||
} |
||||
if (selectedIndex == itemCount - 2) { |
||||
return SelectType.COMBINATION_COLOR; |
||||
} |
||||
if (selectedIndex == 0) { |
||||
return SelectType.DEFAULT; |
||||
} |
||||
return SelectType.NORMAL; |
||||
} |
||||
|
||||
public void setSelectType(SelectType selectType) { |
||||
int itemCount = this.getItemCount(); |
||||
switch (selectType) { |
||||
case DEFAULT: |
||||
setSelectedIndex(0); |
||||
break; |
||||
case GRADATION_COLOR: |
||||
setSelectedIndex(itemCount - 1); |
||||
break; |
||||
case COMBINATION_COLOR: |
||||
setSelectedIndex(itemCount - 2); |
||||
break; |
||||
} |
||||
} |
||||
|
||||
public enum SelectType { |
||||
DEFAULT, |
||||
COMBINATION_COLOR, |
||||
GRADATION_COLOR, |
||||
NORMAL |
||||
} |
||||
|
||||
public Set<String> getItems() { |
||||
return colorSchemes.keySet(); |
||||
} |
||||
|
||||
public class ColorInfo { |
||||
|
||||
private List<Color> colors; |
||||
|
||||
private boolean gradient; |
||||
|
||||
public List<Color> getColors() { |
||||
return colors; |
||||
} |
||||
|
||||
public void setColors(List<Color> colors) { |
||||
this.colors = colors; |
||||
} |
||||
|
||||
public boolean isGradient() { |
||||
return gradient; |
||||
} |
||||
|
||||
public void setGradient(boolean gradient) { |
||||
this.gradient = gradient; |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* CellRenderer. |
||||
*/ |
||||
class ColorSchemeCellRenderer extends UIComboBoxRenderer { |
||||
|
||||
private String schemeName = Toolkit.i18nText("Fine-Design_Report_Default"); |
||||
|
||||
//左边距
|
||||
private static final double X = 4d; |
||||
|
||||
//上边距
|
||||
private static final double Y = 4d; |
||||
|
||||
private static final String BLANK_SPACE = " "; |
||||
|
||||
private static final int HEIGHT = 20; |
||||
|
||||
private static final int MAX_COUNT = 5; |
||||
|
||||
private static final int BLANK = 1; |
||||
|
||||
@Override |
||||
public Dimension getPreferredSize() { |
||||
Dimension preferredSize = super.getPreferredSize(); |
||||
preferredSize.setSize(super.getPreferredSize().getWidth(), HEIGHT); |
||||
return preferredSize; |
||||
} |
||||
|
||||
@Override |
||||
public Dimension getMinimumSize() { |
||||
return getPreferredSize(); |
||||
} |
||||
|
||||
public Component getListCellRendererComponent( |
||||
JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { |
||||
JLabel comp = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); |
||||
this.schemeName = GeneralUtils.objectToString(value); |
||||
ColorInfo colorInfo = colorSchemes.get(schemeName); |
||||
if (colorInfo == null) { |
||||
comp.setText(BLANK_SPACE + schemeName); |
||||
} else { |
||||
FontMetrics fontMetrics = comp.getFontMetrics(comp.getFont()); |
||||
//宽度是5倍的高加上4倍的留白
|
||||
double width = (HEIGHT - 2 * Y) * MAX_COUNT + BLANK * (MAX_COUNT - 1); |
||||
String fill = BLANK_SPACE; |
||||
//图形和文字之间留的宽度大于3倍的X
|
||||
while (fontMetrics.stringWidth(fill) < width + 3 * X) { |
||||
fill += BLANK_SPACE; |
||||
} |
||||
comp.setText(fill + schemeName); |
||||
} |
||||
comp.setToolTipText(schemeName); |
||||
return comp; |
||||
} |
||||
|
||||
public void paint(Graphics g) { |
||||
super.paint(g); |
||||
|
||||
Graphics2D g2d = (Graphics2D) g; |
||||
|
||||
ColorInfo colorInfo = colorSchemes.get(schemeName); |
||||
if (colorInfo != null) { |
||||
if (colorInfo.isGradient()) { |
||||
drawGradient(g2d, colorInfo.getColors()); |
||||
} else { |
||||
drawCombineColor(g2d, colorInfo.getColors()); |
||||
} |
||||
} |
||||
} |
||||
|
||||
private void drawGradient(Graphics2D g2d, List<Color> colors) { |
||||
//上下留4px,宽度等于5倍高
|
||||
double height = HEIGHT - 2 * Y; |
||||
double width = height * MAX_COUNT + BLANK * (MAX_COUNT - 1); |
||||
LinearGradientPaint linearGradientPaint = new LinearGradientPaint((float) X, (float) Y, (float) (X + width), (float) Y, new float[]{0f, 1f}, colors.toArray(new Color[colors.size()])); |
||||
g2d.setPaint(linearGradientPaint); |
||||
Rectangle2D rec = new Rectangle2D.Double(X, Y, width, height); |
||||
g2d.fill(rec); |
||||
} |
||||
|
||||
private void drawCombineColor(Graphics2D g2d, List<Color> colors) { |
||||
int size = Math.min(colors.size(), MAX_COUNT); |
||||
double height = HEIGHT - 2 * Y; |
||||
//加上1px留白
|
||||
double width = ((height + BLANK) * MAX_COUNT - size) / size; |
||||
for (int i = 0; i < size; i++) { |
||||
g2d.setPaint(colors.get(i)); |
||||
Rectangle2D rec = new Rectangle2D.Double(X + (width + BLANK) * i, Y, width, height); |
||||
g2d.fill(rec); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,235 @@
|
||||
package com.fr.design.mainframe.chart.gui.style; |
||||
|
||||
import com.fr.base.BaseUtils; |
||||
import com.fr.base.background.ColorBackground; |
||||
import com.fr.design.chartx.component.button.ColorButton; |
||||
import com.fr.design.event.UIObserver; |
||||
import com.fr.design.event.UIObserverListener; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.design.layout.VerticalFlowLayout; |
||||
import com.fr.design.style.AbstractSelectBox; |
||||
import com.fr.design.style.color.ColorSelectPane; |
||||
|
||||
import javax.swing.JPanel; |
||||
import javax.swing.event.ChangeEvent; |
||||
import javax.swing.event.ChangeListener; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
import java.awt.Color; |
||||
import java.awt.Dimension; |
||||
import java.awt.Graphics; |
||||
import java.awt.Graphics2D; |
||||
import java.awt.event.MouseAdapter; |
||||
import java.awt.event.MouseEvent; |
||||
import java.awt.event.MouseListener; |
||||
import java.awt.geom.Rectangle2D; |
||||
import java.awt.image.BufferedImage; |
||||
|
||||
/** |
||||
* 配色方案选择组合色之后,可以调整颜色的组件 |
||||
* |
||||
* @author Bjorn |
||||
* @version 10.0 |
||||
* Created by Bjorn on 2020-03-25 |
||||
*/ |
||||
public class ChartColorAdjustPane extends JPanel implements UIObserver { |
||||
|
||||
public static final Color[] DEFAULT_COLORS = { |
||||
new Color(99, 178, 238), |
||||
new Color(118, 218, 145), |
||||
new Color(248, 203, 127), |
||||
new Color(248, 149, 136), |
||||
new Color(124, 214, 207), |
||||
new Color(145, 146, 171), |
||||
new Color(120, 152, 225), |
||||
new Color(239, 166, 102), |
||||
new Color(237, 221, 134), |
||||
new Color(153, 135, 206), |
||||
}; |
||||
|
||||
private static final int COUNT_OF_ROW = 8; |
||||
|
||||
private static final int MAX_BUTTON = 40; |
||||
|
||||
private List<ColorButton> colorButtons = new ArrayList<>(); |
||||
|
||||
private List<UIObserverListener> uiObserverListener; |
||||
|
||||
private ChangeListener changeListener; |
||||
|
||||
|
||||
public ChartColorAdjustPane() { |
||||
this(DEFAULT_COLORS); |
||||
} |
||||
|
||||
public ChartColorAdjustPane(Color[] colors) { |
||||
iniListener(); |
||||
createColorButton(colors); |
||||
createContentPane(); |
||||
} |
||||
|
||||
public void updateColor(Color[] colors) { |
||||
createColorButton(colors); |
||||
relayout(); |
||||
} |
||||
|
||||
public Color[] getColors() { |
||||
int size = colorButtons.size(); |
||||
Color[] colors = new Color[size]; |
||||
for (int i = 0; i < size; i++) { |
||||
colors[i] = colorButtons.get(i).getSelectObject(); |
||||
} |
||||
return colors; |
||||
} |
||||
|
||||
private void relayout() { |
||||
this.removeAll(); |
||||
createContentPane(); |
||||
this.validate(); |
||||
this.repaint(); |
||||
} |
||||
|
||||
private void createContentPane() { |
||||
VerticalFlowLayout layout = new VerticalFlowLayout(0, 0, 0); |
||||
layout.setAlignLeft(true); |
||||
this.setLayout(layout); |
||||
|
||||
for (int i = 0, size = colorButtons.size(); i < size; i += COUNT_OF_ROW) { |
||||
JPanel panel = FRGUIPaneFactory.createLeftFlowZeroGapBorderPane(); |
||||
int count = i + COUNT_OF_ROW > colorButtons.size() ? colorButtons.size() : i + COUNT_OF_ROW; |
||||
for (int j = i; j < count; j++) { |
||||
colorButtons.get(j).setLastButton(false); |
||||
panel.add(colorButtons.get(j)); |
||||
} |
||||
if (i + COUNT_OF_ROW > colorButtons.size()) { |
||||
panel.add(new AddColorButton()); |
||||
this.add(panel); |
||||
} else if (i + COUNT_OF_ROW == colorButtons.size() && colorButtons.size() != MAX_BUTTON) { |
||||
this.add(panel); |
||||
this.add(new AddColorButton()); |
||||
} else { |
||||
this.add(panel); |
||||
} |
||||
} |
||||
if (colorButtons.size() == 1) { |
||||
colorButtons.get(0).setLastButton(true); |
||||
} |
||||
} |
||||
|
||||
private void createColorButton(Color[] colors) { |
||||
colorButtons.clear(); |
||||
int size = Math.min(colors.length, MAX_BUTTON); |
||||
for (int i = 0; i < size; i++) { |
||||
colorButtons.add(createColorButton(colors[i])); |
||||
} |
||||
} |
||||
|
||||
private ColorButton createColorButton(Color color) { |
||||
ColorButton colorButton = new ColorButton(color) { |
||||
@Override |
||||
protected void deleteButton() { |
||||
colorButtons.remove(this); |
||||
stateChanged(); |
||||
relayout(); |
||||
} |
||||
}; |
||||
|
||||
colorButton.addChangeListener(changeListener); |
||||
return colorButton; |
||||
} |
||||
|
||||
private void iniListener() { |
||||
uiObserverListener = new ArrayList<>(); |
||||
if (shouldResponseChangeListener()) { |
||||
this.addChangeListener(new ChangeListener() { |
||||
@Override |
||||
public void stateChanged(ChangeEvent e) { |
||||
for (UIObserverListener observerListener : uiObserverListener) { |
||||
observerListener.doChange(); |
||||
} |
||||
} |
||||
}); |
||||
} |
||||
} |
||||
|
||||
public void stateChanged() { |
||||
if (changeListener != null) { |
||||
changeListener.stateChanged(null); |
||||
} |
||||
} |
||||
|
||||
public void addChangeListener(ChangeListener changeListener) { |
||||
this.changeListener = changeListener; |
||||
} |
||||
|
||||
public void registerChangeListener(UIObserverListener listener) { |
||||
uiObserverListener.add(listener); |
||||
} |
||||
|
||||
public boolean shouldResponseChangeListener() { |
||||
return true; |
||||
} |
||||
|
||||
|
||||
private class AddColorButton extends AbstractSelectBox<Color> { |
||||
|
||||
BufferedImage image = BaseUtils.readImageWithCache("/com/fr/design/images/buttonicon/add.png"); |
||||
|
||||
public AddColorButton() { |
||||
addMouseListener(getMouseListener()); |
||||
} |
||||
|
||||
@Override |
||||
public void paint(Graphics g) { |
||||
this.setSize(ColorButton.WIDTH, ColorButton.WIDTH); |
||||
Graphics2D g2d = (Graphics2D) g; |
||||
g2d.setPaint(Color.WHITE); |
||||
Rectangle2D rec = new Rectangle2D.Double(0, 0, ColorButton.WIDTH + 1, ColorButton.WIDTH + 1); |
||||
g2d.fill(rec); |
||||
g2d.drawImage(image, 0, 0, ColorButton.WIDTH + 1, ColorButton.WIDTH + 1, null); |
||||
} |
||||
|
||||
public Dimension getPreferredSize() { |
||||
return new Dimension(ColorButton.WIDTH, ColorButton.WIDTH); |
||||
} |
||||
|
||||
protected MouseListener getMouseListener() { |
||||
return new MouseAdapter() { |
||||
@Override |
||||
public void mouseClicked(MouseEvent e) { |
||||
showPopupMenu(); |
||||
} |
||||
}; |
||||
} |
||||
|
||||
public JPanel initWindowPane(double preferredWidth) { |
||||
// 下拉的时候重新生成面板,刷新最近使用颜色
|
||||
ColorSelectPane colorPane = new ColorSelectPane(false) { |
||||
public void setVisible(boolean b) { |
||||
super.setVisible(b); |
||||
} |
||||
}; |
||||
colorPane.addChangeListener(new ChangeListener() { |
||||
public void stateChanged(ChangeEvent e) { |
||||
hidePopupMenu(); |
||||
Color color = ((ColorSelectPane) e.getSource()).getColor(); |
||||
fireDisplayComponent(ColorBackground.getInstance(color)); |
||||
if(colorButtons.size() < MAX_BUTTON) { |
||||
colorButtons.add(createColorButton(color)); |
||||
} |
||||
ChartColorAdjustPane.this.stateChanged(); |
||||
relayout(); |
||||
} |
||||
}); |
||||
return colorPane; |
||||
} |
||||
|
||||
public Color getSelectObject() { |
||||
return null; |
||||
} |
||||
|
||||
public void setSelectObject(Color color) { |
||||
|
||||
} |
||||
} |
||||
} |
@ -1,42 +1,237 @@
|
||||
package com.fr.van.chart.designer.component; |
||||
|
||||
import com.fr.base.ChartColorMatching; |
||||
import com.fr.base.ChartPreStyleConfig; |
||||
import com.fr.base.Utils; |
||||
import com.fr.chart.base.AttrFillStyle; |
||||
import com.fr.chart.base.ChartConstants; |
||||
import com.fr.chart.base.ChartUtils; |
||||
import com.fr.design.beans.BasicBeanPane; |
||||
import com.fr.design.chartx.component.combobox.ColorSchemeComboBox; |
||||
import com.fr.design.event.UIObserverListener; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.design.layout.TableLayout; |
||||
import com.fr.design.mainframe.chart.gui.style.ChartFillStylePane; |
||||
|
||||
import com.fr.design.mainframe.chart.gui.style.ChartColorAdjustPane; |
||||
import com.fr.design.style.background.gradient.FixedGradientBar; |
||||
import com.fr.stable.StringUtils; |
||||
import com.fr.van.chart.designer.TableLayout4VanChartHelper; |
||||
|
||||
import javax.swing.BorderFactory; |
||||
import javax.swing.JPanel; |
||||
import java.awt.BorderLayout; |
||||
import java.awt.CardLayout; |
||||
import java.awt.Color; |
||||
import java.awt.Component; |
||||
import java.awt.Dimension; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
|
||||
/** |
||||
* Created by mengao on 2017/8/17. |
||||
*/ |
||||
public class VanChartFillStylePane extends ChartFillStylePane { |
||||
public class VanChartFillStylePane extends BasicBeanPane<AttrFillStyle> { |
||||
|
||||
@Override |
||||
protected JPanel getContentPane () { |
||||
|
||||
protected ColorSchemeComboBox styleSelectBox; |
||||
protected JPanel customPane; |
||||
protected JPanel changeColorSetPane; |
||||
protected FixedGradientBar colorGradient; |
||||
|
||||
protected CardLayout cardLayout; |
||||
|
||||
protected ChartColorAdjustPane colorAdjustPane; |
||||
|
||||
private Color[] gradientColors; |
||||
private Color[] accColors; |
||||
|
||||
private boolean gradientSelect = false; |
||||
|
||||
public VanChartFillStylePane() { |
||||
this.setLayout(new BorderLayout()); |
||||
|
||||
styleSelectBox = new ColorSchemeComboBox(); |
||||
customPane = new JPanel(FRGUIPaneFactory.createBorderLayout()) { |
||||
@Override |
||||
public Dimension getPreferredSize() { |
||||
if (!gradientSelect) { |
||||
return colorAdjustPane.getPreferredSize(); |
||||
} |
||||
return colorGradient.getPreferredSize(); |
||||
} |
||||
}; |
||||
|
||||
changeColorSetPane = new JPanel(cardLayout = new CardLayout()); |
||||
changeColorSetPane.add(colorGradient = new FixedGradientBar(4, 130), "gradient"); |
||||
gradientColors = new Color[]{Color.WHITE, FixedGradientBar.NEW_CHARACTER}; |
||||
changeColorSetPane.add(colorAdjustPane = new ChartColorAdjustPane(), "acc"); |
||||
accColors = ChartColorAdjustPane.DEFAULT_COLORS; |
||||
cardLayout.show(changeColorSetPane, "acc"); |
||||
customPane.add(changeColorSetPane, BorderLayout.CENTER); |
||||
initListener(); |
||||
initLayout(); |
||||
} |
||||
|
||||
private void initListener() { |
||||
colorAdjustPane.registerChangeListener(new UIObserverListener() { |
||||
@Override |
||||
public void doChange() { |
||||
accColors = colorAdjustPane.getColors(); |
||||
if (styleSelectBox.getSelectType() != ColorSchemeComboBox.SelectType.COMBINATION_COLOR) { |
||||
styleSelectBox.setSelectType(ColorSchemeComboBox.SelectType.COMBINATION_COLOR); |
||||
} |
||||
VanChartFillStylePane.this.revalidate(); |
||||
} |
||||
}); |
||||
colorGradient.registerChangeListener(new UIObserverListener() { |
||||
@Override |
||||
public void doChange() { |
||||
gradientColors[0] = colorGradient.getSelectColorPointBtnP1().getColorInner(); |
||||
gradientColors[1] = colorGradient.getSelectColorPointBtnP2().getColorInner(); |
||||
if (styleSelectBox.getSelectType() != ColorSchemeComboBox.SelectType.GRADATION_COLOR) { |
||||
styleSelectBox.setSelectType(ColorSchemeComboBox.SelectType.GRADATION_COLOR); |
||||
} |
||||
} |
||||
}); |
||||
styleSelectBox.addActionListener(new ActionListener() { |
||||
@Override |
||||
public void actionPerformed(ActionEvent e) { |
||||
switch (styleSelectBox.getSelectType()) { |
||||
case COMBINATION_COLOR: |
||||
colorAdjustPane.updateColor(accColors); |
||||
cardLayout.show(changeColorSetPane, "acc"); |
||||
gradientSelect = false; |
||||
break; |
||||
case GRADATION_COLOR: |
||||
colorGradient.updateColor(gradientColors[0], gradientColors[1]); |
||||
cardLayout.show(changeColorSetPane, "gradient"); |
||||
gradientSelect = true; |
||||
break; |
||||
default: |
||||
ColorSchemeComboBox.ColorInfo selectColorInfo = styleSelectBox.getSelectColorInfo(); |
||||
if (selectColorInfo.isGradient()) { |
||||
colorGradient.updateColor(selectColorInfo.getColors().get(0), selectColorInfo.getColors().get(1)); |
||||
cardLayout.show(changeColorSetPane, "gradient"); |
||||
gradientSelect = true; |
||||
} else { |
||||
colorAdjustPane.updateColor(selectColorInfo.getColors().toArray(new Color[]{})); |
||||
cardLayout.show(changeColorSetPane, "acc"); |
||||
gradientSelect = false; |
||||
} |
||||
break; |
||||
} |
||||
VanChartFillStylePane.this.revalidate(); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
protected void initLayout() { |
||||
this.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 0)); |
||||
this.setLayout(new BorderLayout()); |
||||
this.add(getContentPane(), BorderLayout.CENTER); |
||||
} |
||||
|
||||
protected JPanel getContentPane() { |
||||
double p = TableLayout.PREFERRED; |
||||
double f = TableLayout.FILL; |
||||
double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; |
||||
double[] columnSize = {f, e}; |
||||
double[] rowSize = {p, p}; |
||||
Component[][] components = new Component[][]{ |
||||
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Color_Match")),styleSelectBox}, |
||||
new Component[]{null,customPane}, |
||||
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Match_Color_Scheme")), styleSelectBox}, |
||||
new Component[]{null, customPane}, |
||||
|
||||
}; |
||||
JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(components,rowSize,columnSize); |
||||
panel.setBorder(BorderFactory.createEmptyBorder(5,5,0,0)); |
||||
JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(components, rowSize, columnSize); |
||||
panel.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 0)); |
||||
return panel; |
||||
} |
||||
|
||||
@Override |
||||
public Dimension getPreferredSize() { |
||||
if(styleSelectBox.getSelectedIndex() != styleSelectBox.getItemCount() - 1) { |
||||
return new Dimension(styleSelectBox.getPreferredSize().width, 30); |
||||
protected String title4PopupWindow() { |
||||
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Color"); |
||||
} |
||||
|
||||
@Override |
||||
public void populateBean(AttrFillStyle condition) { |
||||
String fillStyleName = condition == null ? "" : condition.getFillStyleName(); |
||||
if (StringUtils.isBlank(fillStyleName) || !styleSelectBox.getItems().contains(fillStyleName)) {//兼容处理
|
||||
if (condition == null || condition.getColorStyle() == ChartConstants.COLOR_DEFAULT) { |
||||
styleSelectBox.setSelectType(ColorSchemeComboBox.SelectType.DEFAULT);//默认
|
||||
} else { |
||||
int colorStyle = condition.getColorStyle(); |
||||
if (colorStyle == ChartConstants.COLOR_GRADIENT) { |
||||
gradientColors[0] = condition.getColorIndex(0); |
||||
gradientColors[1] = condition.getColorIndex(1); |
||||
styleSelectBox.setSelectType(ColorSchemeComboBox.SelectType.GRADATION_COLOR); |
||||
} else { |
||||
int colorSize = condition.getColorSize(); |
||||
accColors = new Color[colorSize]; |
||||
for (int i = 0; i < colorSize; i++) { |
||||
accColors[i] = condition.getColorIndex(i); |
||||
} |
||||
styleSelectBox.setSelectType(ColorSchemeComboBox.SelectType.COMBINATION_COLOR); |
||||
} |
||||
} |
||||
} else { |
||||
styleSelectBox.setSelectedItem(fillStyleName); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public AttrFillStyle updateBean() { |
||||
switch (styleSelectBox.getSelectType()) { |
||||
case COMBINATION_COLOR: |
||||
return updateCombinationColor(); |
||||
case GRADATION_COLOR: |
||||
return updateGradationColor(); |
||||
case DEFAULT: |
||||
return updateDefaultColor(); |
||||
default: |
||||
return updateNormalColor(); |
||||
} |
||||
} |
||||
|
||||
private AttrFillStyle updateCombinationColor() { |
||||
AttrFillStyle condition = new AttrFillStyle(); |
||||
condition.clearColors(); |
||||
condition.setColorStyle(ChartConstants.COLOR_ACC); |
||||
for (int i = 0, length = accColors.length; i < length; i++) { |
||||
condition.addFillColor(accColors[i]); |
||||
} |
||||
condition.setCustomFillStyle(true); |
||||
return condition; |
||||
} |
||||
|
||||
private AttrFillStyle updateGradationColor() { |
||||
AttrFillStyle condition = new AttrFillStyle(); |
||||
condition.clearColors(); |
||||
condition.setColorStyle(ChartConstants.COLOR_GRADIENT); |
||||
Color start = gradientColors[0]; |
||||
Color end = gradientColors[1]; |
||||
condition.addFillColor(start); |
||||
condition.addFillColor(end); |
||||
condition.setCustomFillStyle(true); |
||||
return condition; |
||||
} |
||||
|
||||
private AttrFillStyle updateDefaultColor() { |
||||
AttrFillStyle condition = new AttrFillStyle(); |
||||
condition.clearColors(); |
||||
condition.setColorStyle(ChartConstants.COLOR_DEFAULT); |
||||
return condition; |
||||
} |
||||
|
||||
private AttrFillStyle updateNormalColor() { |
||||
ChartPreStyleConfig manager = ChartPreStyleConfig.getInstance(); |
||||
Object preStyle = manager.getPreStyle(styleSelectBox.getSelectedItem()); |
||||
if (preStyle instanceof ChartColorMatching) { |
||||
AttrFillStyle def = ChartUtils.chartColorMatching2AttrFillStyle((ChartColorMatching) preStyle); |
||||
def.setFillStyleName(Utils.objectToString(styleSelectBox.getSelectedItem())); |
||||
return def; |
||||
} else { |
||||
return updateDefaultColor(); |
||||
} |
||||
return super.getPreferredSize(); |
||||
} |
||||
} |
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue