|
|
@ -2,11 +2,13 @@ package com.fr.van.chart.designer.component.richText; |
|
|
|
|
|
|
|
|
|
|
|
import com.fr.base.BaseUtils; |
|
|
|
import com.fr.base.BaseUtils; |
|
|
|
import com.fr.data.util.function.DataFunction; |
|
|
|
import com.fr.data.util.function.DataFunction; |
|
|
|
import com.fr.data.util.function.NoneFunction; |
|
|
|
|
|
|
|
import com.fr.design.gui.ibutton.UIButton; |
|
|
|
import com.fr.design.gui.ibutton.UIButton; |
|
|
|
|
|
|
|
import com.fr.design.gui.ibutton.UIButtonUI; |
|
|
|
import com.fr.design.gui.ibutton.UIToggleButton; |
|
|
|
import com.fr.design.gui.ibutton.UIToggleButton; |
|
|
|
import com.fr.design.layout.TableLayout; |
|
|
|
import com.fr.design.layout.TableLayout; |
|
|
|
import com.fr.design.layout.TableLayoutHelper; |
|
|
|
import com.fr.design.layout.TableLayoutHelper; |
|
|
|
|
|
|
|
import com.fr.design.utils.gui.GUIPaintUtils; |
|
|
|
|
|
|
|
import com.fr.plugin.chart.base.FirstFunction; |
|
|
|
import com.fr.plugin.chart.base.format.AttrTooltipDurationFormat; |
|
|
|
import com.fr.plugin.chart.base.format.AttrTooltipDurationFormat; |
|
|
|
import com.fr.plugin.chart.base.format.AttrTooltipFormat; |
|
|
|
import com.fr.plugin.chart.base.format.AttrTooltipFormat; |
|
|
|
import com.fr.plugin.chart.base.format.IntervalTimeFormat; |
|
|
|
import com.fr.plugin.chart.base.format.IntervalTimeFormat; |
|
|
@ -15,9 +17,12 @@ import com.fr.van.chart.designer.TableLayout4VanChartHelper; |
|
|
|
|
|
|
|
|
|
|
|
import javax.swing.Icon; |
|
|
|
import javax.swing.Icon; |
|
|
|
import javax.swing.JPanel; |
|
|
|
import javax.swing.JPanel; |
|
|
|
|
|
|
|
import javax.swing.plaf.ButtonUI; |
|
|
|
import java.awt.BorderLayout; |
|
|
|
import java.awt.BorderLayout; |
|
|
|
|
|
|
|
import java.awt.Color; |
|
|
|
import java.awt.Component; |
|
|
|
import java.awt.Component; |
|
|
|
import java.awt.Dimension; |
|
|
|
import java.awt.Dimension; |
|
|
|
|
|
|
|
import java.awt.Graphics2D; |
|
|
|
import java.awt.event.MouseAdapter; |
|
|
|
import java.awt.event.MouseAdapter; |
|
|
|
import java.awt.event.MouseEvent; |
|
|
|
import java.awt.event.MouseEvent; |
|
|
|
import java.awt.event.MouseListener; |
|
|
|
import java.awt.event.MouseListener; |
|
|
@ -26,9 +31,10 @@ import java.text.Format; |
|
|
|
public class VanChartFieldButton extends JPanel { |
|
|
|
public class VanChartFieldButton extends JPanel { |
|
|
|
|
|
|
|
|
|
|
|
private static final Icon ADD_ICON = BaseUtils.readIcon("/com/fr/base/images/cell/control/add.png"); |
|
|
|
private static final Icon ADD_ICON = BaseUtils.readIcon("/com/fr/base/images/cell/control/add.png"); |
|
|
|
|
|
|
|
private static final Color HOVER_COLOR = new Color(232, 232, 232); |
|
|
|
|
|
|
|
|
|
|
|
private static final int W = 200; |
|
|
|
private static final int W = 200; |
|
|
|
private static final int H = 28; |
|
|
|
private static final int H = 24; |
|
|
|
|
|
|
|
|
|
|
|
private final String fieldName; |
|
|
|
private final String fieldName; |
|
|
|
private final String fieldId; |
|
|
|
private final String fieldId; |
|
|
@ -40,7 +46,7 @@ public class VanChartFieldButton extends JPanel { |
|
|
|
private UIToggleButton fieldButton; |
|
|
|
private UIToggleButton fieldButton; |
|
|
|
private UIButton addButton; |
|
|
|
private UIButton addButton; |
|
|
|
|
|
|
|
|
|
|
|
private DataFunction dataFunction = new NoneFunction(); |
|
|
|
private DataFunction dataFunction = new FirstFunction(); |
|
|
|
|
|
|
|
|
|
|
|
public VanChartFieldButton(String fieldName, AttrTooltipFormat format, VanChartFieldListener listener) { |
|
|
|
public VanChartFieldButton(String fieldName, AttrTooltipFormat format, VanChartFieldListener listener) { |
|
|
|
this(fieldName, format, false, false, listener); |
|
|
|
this(fieldName, format, false, false, listener); |
|
|
@ -134,9 +140,17 @@ public class VanChartFieldButton extends JPanel { |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public ButtonUI getUI() { |
|
|
|
|
|
|
|
return new FieldButtonUI(); |
|
|
|
|
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
addButton = new UIButton(ADD_ICON); |
|
|
|
addButton = new UIButton(ADD_ICON) { |
|
|
|
|
|
|
|
public ButtonUI getUI() { |
|
|
|
|
|
|
|
return new FieldButtonUI(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
addButton.addMouseListener(new MouseAdapter() { |
|
|
|
addButton.addMouseListener(new MouseAdapter() { |
|
|
|
|
|
|
|
|
|
|
@ -146,6 +160,9 @@ public class VanChartFieldButton extends JPanel { |
|
|
|
listener.addSelectedField(fieldName, fieldId); |
|
|
|
listener.addSelectedField(fieldName, fieldId); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fieldButton.setBorderPaintedOnlyWhenPressed(true); |
|
|
|
|
|
|
|
addButton.setBorderPaintedOnlyWhenPressed(true); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private JPanel getContentPane() { |
|
|
|
private JPanel getContentPane() { |
|
|
@ -160,7 +177,7 @@ public class VanChartFieldButton extends JPanel { |
|
|
|
double[] rowSize = {p}; |
|
|
|
double[] rowSize = {p}; |
|
|
|
double[] columnSize = {e, d}; |
|
|
|
double[] columnSize = {e, d}; |
|
|
|
|
|
|
|
|
|
|
|
JPanel content = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 5, 0); |
|
|
|
JPanel content = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 3, 0); |
|
|
|
content.setPreferredSize(new Dimension(W, H)); |
|
|
|
content.setPreferredSize(new Dimension(W, H)); |
|
|
|
|
|
|
|
|
|
|
|
return content; |
|
|
|
return content; |
|
|
@ -169,4 +186,17 @@ public class VanChartFieldButton extends JPanel { |
|
|
|
public void setSelectedState(boolean selected) { |
|
|
|
public void setSelectedState(boolean selected) { |
|
|
|
fieldButton.setSelected(selected); |
|
|
|
fieldButton.setSelected(selected); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static class FieldButtonUI extends UIButtonUI { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected void doExtraPainting(UIButton b, Graphics2D g2d, int w, int h, String selectedRoles) { |
|
|
|
|
|
|
|
if (isPressed(b) && b.isPressedPainted()) { |
|
|
|
|
|
|
|
GUIPaintUtils.fillPressed(g2d, 0, 0, w, h, b.isRoundBorder(), b.getRectDirection(), b.isDoneAuthorityEdited(selectedRoles)); |
|
|
|
|
|
|
|
} else if (isRollOver(b)) { |
|
|
|
|
|
|
|
GUIPaintUtils.fillRollOver(g2d, 0, 0, w, h, b.isRoundBorder(), b.getRectDirection(), b.isDoneAuthorityEdited(selectedRoles), b.isPressedPainted(), HOVER_COLOR); |
|
|
|
|
|
|
|
} else if (b.isNormalPainted()) { |
|
|
|
|
|
|
|
GUIPaintUtils.fillNormal(g2d, 0, 0, w, h, b.isRoundBorder(), b.getRectDirection(), b.isDoneAuthorityEdited(selectedRoles), b.isPressedPainted()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|