diff --git a/designer-base/src/main/java/com/fr/design/constants/UIConstants.java b/designer-base/src/main/java/com/fr/design/constants/UIConstants.java index 1e119d27ed..85c2c30922 100644 --- a/designer-base/src/main/java/com/fr/design/constants/UIConstants.java +++ b/designer-base/src/main/java/com/fr/design/constants/UIConstants.java @@ -143,7 +143,8 @@ public interface UIConstants { public static final Color TAB_BUTTON_PRESS_SELECTED = new Color(236, 236, 238); public static final Color POPUP_TITLE_BACKGROUND = new Color(0xd8f2fd); public static final Color LIST_ITEM_SPLIT_LINE = new Color(0xf0f0f3); - + public static final Color AUTO_FONT_COLOR = new Color(0, 0, 0, 0); + public static final Color TRANSPARENT_FONT_COLOR = new Color(255, 255, 255, 0); public static final BufferedImage DRAG_BAR = IOUtils.readImage("com/fr/design/images/control/bar.png"); @@ -196,6 +197,7 @@ public interface UIConstants { public static final Icon ANA_SMALL_ICON = IOUtils.readIcon("com/fr/design/images/buttonicon/anas.png"); public static final Icon REFRESH_ICON = IOUtils.readIcon("com/fr/design/images/buttonicon/refresh.png"); public static final Icon FONT_ICON = IOUtils.readIcon("/com/fr/design/images/gui/color/foreground.png"); + public static final Icon AUTO_FONT_ICON = IOUtils.readIcon("/com/fr/design/images/gui/color/autoForeground.png"); public static final Icon HISTORY_ICON = IOUtils.readIcon("com/fr/design/images/buttonicon/history.png"); public static final Icon DELETE_ICON = IOUtils.readIcon("com/fr/design/images/m_file/close.png"); public static final Icon EDIT_ICON = IOUtils.readIcon("com/fr/design/images/m_file/edit.png"); diff --git a/designer-base/src/main/java/com/fr/design/gui/ibutton/UIColorButton.java b/designer-base/src/main/java/com/fr/design/gui/ibutton/UIColorButton.java index 86fc564384..f957e8c39f 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ibutton/UIColorButton.java +++ b/designer-base/src/main/java/com/fr/design/gui/ibutton/UIColorButton.java @@ -24,10 +24,10 @@ import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; public class UIColorButton extends UIButton implements PopupHider, UIObserver, GlobalNameObserver { - private static final int SIZE = 16; - private static final int SIZE_2 = 2; - private static final int SIZE_4 = 4; - private static final int SIZE_6 = 6; + public static final int SIZE = 16; + public static final int SIZE_2 = 2; + public static final int SIZE_4 = 4; + public static final int SIZE_6 = 6; private static final int POPUP_MENU_SHIFT = -70; private Color color = Color.BLACK; private ColorControlWindow popupWin; @@ -53,6 +53,14 @@ public class UIColorButton extends UIButton implements PopupHider, UIObserver, G iniListener(); } + public ColorControlWindow getPopupWin() { + return popupWin; + } + + public void setPopupWin(ColorControlWindow popupWin) { + this.popupWin = popupWin; + } + private void iniListener() { if (shouldResponseChangeListener()) { this.addColorChangeListener(new ChangeListener() { @@ -103,12 +111,15 @@ public class UIColorButton extends UIButton implements PopupHider, UIObserver, G if (ComparatorUtils.equals(this.color, color)) { return; } - + checkIcon(this.color, color); this.color = color; hidePopupMenu(); fireColorStateChanged(); } + protected void checkIcon(Color oldColor, Color newColor) { + } + private void showPopupMenu() { if (isEventBanned) { return; @@ -139,7 +150,7 @@ public class UIColorButton extends UIButton implements PopupHider, UIObserver, G repaint(); } - private ColorControlWindow getColorControlWindow() { + protected ColorControlWindow getColorControlWindow() { //find parant. if (this.popupWin == null) { this.popupWin = new ColorControlWindow(UIColorButton.this) { diff --git a/designer-base/src/main/java/com/fr/design/gui/ibutton/UIColorButtonWithAuto.java b/designer-base/src/main/java/com/fr/design/gui/ibutton/UIColorButtonWithAuto.java new file mode 100644 index 0000000000..0f5f0c58c9 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/gui/ibutton/UIColorButtonWithAuto.java @@ -0,0 +1,35 @@ +package com.fr.design.gui.ibutton; + +import com.fr.design.constants.UIConstants; +import com.fr.design.style.color.ColorControlWindow; +import com.fr.design.style.color.ColorControlWindowWithAuto; +import com.fr.general.ComparatorUtils; + +import java.awt.Color; + +public class UIColorButtonWithAuto extends UIColorButton { + + protected void checkIcon(Color oldColor, Color newColor) { + if (ComparatorUtils.equals(oldColor, UIConstants.AUTO_FONT_COLOR) && !ComparatorUtils.equals(newColor, UIConstants.AUTO_FONT_COLOR)) { + setIcon(UIConstants.FONT_ICON); + } + + if (!ComparatorUtils.equals(oldColor, UIConstants.AUTO_FONT_COLOR) && ComparatorUtils.equals(newColor, UIConstants.AUTO_FONT_COLOR)) { + setIcon(UIConstants.AUTO_FONT_ICON); + } + } + + protected ColorControlWindow getColorControlWindow() { + if (getPopupWin() == null) { + ColorControlWindowWithAuto colorControlWindowWithAuto = new ColorControlWindowWithAuto(UIColorButtonWithAuto.this) { + protected void colorChanged() { + UIColorButtonWithAuto.this.setColor(this.getColor()); + } + }; + + setPopupWin(colorControlWindowWithAuto); + } + + return getPopupWin(); + } +} diff --git a/designer-base/src/main/java/com/fr/design/style/color/ColorControlWindow.java b/designer-base/src/main/java/com/fr/design/style/color/ColorControlWindow.java index b5a5e40752..4ee3a119ea 100644 --- a/designer-base/src/main/java/com/fr/design/style/color/ColorControlWindow.java +++ b/designer-base/src/main/java/com/fr/design/style/color/ColorControlWindow.java @@ -38,6 +38,10 @@ public abstract class ColorControlWindow extends JPopupMenu { return selectionPopupPane.getColor(); } + public PopupHider getPopupHider() { + return popupHider; + } + /** * Init components. */ @@ -49,9 +53,13 @@ public abstract class ColorControlWindow extends JPopupMenu { setOpaque(false); setDoubleBuffered(true); setFocusable(false); + initSelectionPopupPane(isSupportTransparent); + this.pack(); + } + + protected void initSelectionPopupPane(boolean isSupportTransparent) { selectionPopupPane = new ColorSelectionPopupPane(isSupportTransparent); this.add(selectionPopupPane, BorderLayout.CENTER); - this.pack(); } class ColorSelectionPopupPane extends NewColorSelectPane { diff --git a/designer-base/src/main/java/com/fr/design/style/color/ColorControlWindowWithAuto.java b/designer-base/src/main/java/com/fr/design/style/color/ColorControlWindowWithAuto.java new file mode 100644 index 0000000000..46d32c7136 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/style/color/ColorControlWindowWithAuto.java @@ -0,0 +1,115 @@ +package com.fr.design.style.color; + +import com.fr.design.border.UIRoundedBorder; +import com.fr.design.constants.UIConstants; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.ipoppane.PopupHider; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; + +import javax.swing.JPanel; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +public abstract class ColorControlWindowWithAuto extends ColorControlWindow { + + private ColorSelectionPopupPaneWithAuto selectionPopupPaneWithAuto; + + public ColorControlWindowWithAuto(PopupHider popupHider) { + this(false, popupHider); + } + + public ColorControlWindowWithAuto(boolean isSupportTransparent, PopupHider popupHider) { + super(isSupportTransparent, popupHider); + } + + public Color getColor() { + if (selectionPopupPaneWithAuto == null) { + return null; + } + return selectionPopupPaneWithAuto.getColor(); + } + + protected void initSelectionPopupPane(boolean isSupportTransparent) { + selectionPopupPaneWithAuto = new ColorSelectionPopupPaneWithAuto(isSupportTransparent); + this.add(selectionPopupPaneWithAuto, BorderLayout.CENTER); + } + + class ColorSelectionPopupPaneWithAuto extends NewColorSelectPane { + private static final long serialVersionUID = 7822856562329146354L; + + public ColorSelectionPopupPaneWithAuto(boolean isSupportTransparent) { + super(isSupportTransparent); + + this.addChangeListener(new ChangeListener() { + + @Override + public void stateChanged(ChangeEvent e) { + colorChanged(); + } + }); + } + + protected void doTransparent() { + getPopupHider().hidePopupMenu(); + setColor(UIConstants.TRANSPARENT_FONT_COLOR); + } + + protected void doAuto() { + getPopupHider().hidePopupMenu(); + setColor(UIConstants.AUTO_FONT_COLOR); + } + + public void customButtonPressed() { + getPopupHider().hidePopupMenu(); + super.customButtonPressed(); + } + + protected void initSelectButton(boolean isSupportTransparent) { + setSupportTransparent(isSupportTransparent); + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + this.setBorder(new UIRoundedBorder(UIConstants.TOOLBAR_BORDER_COLOR, 1, 5)); + + UIButton transparentButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_ChartF_Transparency")); + UIButton autoButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_ChartF_Auto")); + + transparentButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + doTransparent(); + } + }); + + autoButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + doAuto(); + } + }); + + if (isSupportTransparent) { + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double[] columnSize = {f, 0}; + double[] rowSize = {p, p}; + + Component[][] components = new Component[][]{ + new Component[]{autoButton, null}, + new Component[]{transparentButton, null} + }; + + JPanel buttonGroup = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); + this.add(buttonGroup, BorderLayout.NORTH); + } else { + this.add(autoButton, BorderLayout.NORTH); + } + } + + } + +} \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/style/color/NewColorSelectPane.java b/designer-base/src/main/java/com/fr/design/style/color/NewColorSelectPane.java index d532324165..05c99e06cf 100644 --- a/designer-base/src/main/java/com/fr/design/style/color/NewColorSelectPane.java +++ b/designer-base/src/main/java/com/fr/design/style/color/NewColorSelectPane.java @@ -56,20 +56,7 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable { * Constructor. */ NewColorSelectPane(boolean isSupportTransparent) { - this.isSupportTransparent = isSupportTransparent; - this.setLayout(FRGUIPaneFactory.createBorderLayout()); - this.setBorder(new UIRoundedBorder(UIConstants.TOOLBAR_BORDER_COLOR, 1, 5)); - if (isSupportTransparent) { - UIButton transpanrentButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_ChartF_Transparency")); - this.add(transpanrentButton, BorderLayout.NORTH); - transpanrentButton.addActionListener(new ActionListener() { - - @Override - public void actionPerformed(ActionEvent e) { - doTransparent(); - } - }); - } + initSelectButton(isSupportTransparent); // center JPanel centerPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_S_Pane(); @@ -117,6 +104,27 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable { centerPane.add(centerPane1); } + public void setSupportTransparent(boolean supportTransparent) { + isSupportTransparent = supportTransparent; + } + + protected void initSelectButton(boolean isSupportTransparent){ + this.isSupportTransparent = isSupportTransparent; + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + this.setBorder(new UIRoundedBorder(UIConstants.TOOLBAR_BORDER_COLOR, 1, 5)); + if (isSupportTransparent) { + UIButton transparentButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_ChartF_Transparency")); + this.add(transparentButton, BorderLayout.NORTH); + transparentButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + doTransparent(); + } + }); + } + } + /** * 添加监听 diff --git a/designer-base/src/main/resources/com/fr/design/images/gui/color/autoForeground.png b/designer-base/src/main/resources/com/fr/design/images/gui/color/autoForeground.png new file mode 100755 index 0000000000..4186fea2cf Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/gui/color/autoForeground.png differ diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartTextAttrPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartTextAttrPane.java index f3998be974..71ff1c9d0d 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartTextAttrPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartTextAttrPane.java @@ -25,8 +25,8 @@ import java.awt.Font; public class ChartTextAttrPane extends BasicPane { private static final long serialVersionUID = 6731679928019436869L; - private static final int FONT_START = 6; - private static final int FONT_END = 72; + public static final int FONT_START = 6; + public static final int FONT_END = 72; private UIComboBox fontNameComboBox; private UIComboBox fontSizeComboBox; private UIToggleButton bold; @@ -36,7 +36,7 @@ public class ChartTextAttrPane extends BasicPane { static { for (int i = FONT_START; i <= FONT_END; i++) { - Font_Sizes[i - FONT_START] = new Integer(i); + Font_Sizes[i - FONT_START] = i; } } @@ -57,10 +57,6 @@ public class ChartTextAttrPane extends BasicPane { return bold; } - public void setBold(UIToggleButton bold) { - this.bold = bold; - } - public UIToggleButton getItalic() { return italic; } @@ -69,6 +65,10 @@ public class ChartTextAttrPane extends BasicPane { return fontColor; } + public void setFontColor(UIColorButton fontColor) { + this.fontColor = fontColor; + } + /** * 标题 * @@ -181,9 +181,13 @@ public class ChartTextAttrPane extends BasicPane { protected void initState() { fontNameComboBox = new UIComboBox(Utils.getAvailableFontFamilyNames4Report()); fontSizeComboBox = new UIComboBox(getFontSizeComboBoxModel()); - fontColor = new UIColorButton(); bold = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/bold.png")); italic = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/italic.png")); + initFontColorState(); + } + + protected void initFontColorState() { + setFontColor(new UIColorButton()); } protected void initComponents() { diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartTextAttrPaneWithAuto.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartTextAttrPaneWithAuto.java index 35681ab41a..1301b243a2 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartTextAttrPaneWithAuto.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartTextAttrPaneWithAuto.java @@ -1,6 +1,8 @@ package com.fr.design.mainframe.chart.gui.style; import com.fr.base.Utils; +import com.fr.design.gui.ibutton.UIColorButton; +import com.fr.design.gui.ibutton.UIColorButtonWithAuto; import com.fr.design.i18n.Toolkit; import com.fr.general.ComparatorUtils; import com.fr.general.FRFont; @@ -28,14 +30,22 @@ public class ChartTextAttrPaneWithAuto extends ChartTextAttrPane { initComponents(); } + protected void initFontColorState() { + if (isColorAuto) { + setFontColor(new UIColorButtonWithAuto()); + } else { + setFontColor(new UIColorButton()); + } + } + protected Object[] getFontSizeComboBoxModel() { if (isFontSizeAuto) { - String[] fontSizes = new String[Font_Sizes.length + 1]; + String[] fontSizes = new String[FONT_END - FONT_START + 2]; fontSizes[0] = AUTO; - for (int i = 1; i <= Font_Sizes.length; i++) { - fontSizes[i] = i + ""; + for (int i = 1; i < fontSizes.length; i++) { + fontSizes[i] = FONT_START + i + ""; } return fontSizes; diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugeCateOrPercentLabelDetailPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugeCateOrPercentLabelDetailPane.java index 876da9bc69..d367d40834 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugeCateOrPercentLabelDetailPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugeCateOrPercentLabelDetailPane.java @@ -54,6 +54,12 @@ public class VanChartGaugeCateOrPercentLabelDetailPane extends VanChartGaugeLabe return gaugeStyle == GaugeStyle.RING || gaugeStyle == GaugeStyle.SLOT; } + protected boolean getFontColorAuto() { + GaugeStyle gaugeStyle = ((VanChartGaugePlot) getPlot()).getGaugeStyle(); + + return gaugeStyle == GaugeStyle.RING || gaugeStyle == GaugeStyle.SLOT; + } + protected boolean hasLabelPosition(Plot plot) { GaugeStyle gaugeStyle = ((VanChartGaugePlot) plot).getGaugeStyle(); diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugeLabelDetailPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugeLabelDetailPane.java index 9bfa8e82b4..765ac33c91 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugeLabelDetailPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugeLabelDetailPane.java @@ -52,9 +52,13 @@ public class VanChartGaugeLabelDetailPane extends VanChartPlotLabelDetailPane { return false; } + protected boolean getFontColorAuto() { + return false; + } + protected ChartTextAttrPane initTextFontPane() { - return new ChartTextAttrPaneWithAuto(getFontSizeAuto(), false) { + return new ChartTextAttrPaneWithAuto(getFontSizeAuto(), getFontColorAuto()) { protected double[] getRowSize() { double p = TableLayout.PREFERRED; return new double[]{p, p};