forked from fanruan/design
Bruce.Deng
5 years ago
33 changed files with 673 additions and 354 deletions
@ -0,0 +1,116 @@
|
||||
package com.fr.design.chart; |
||||
|
||||
import com.fr.base.GraphHelper; |
||||
import com.fr.general.IOUtils; |
||||
import com.fr.stable.Constants; |
||||
import com.fr.stable.xml.XMLPrintWriter; |
||||
import com.fr.stable.xml.XMLable; |
||||
import com.fr.stable.xml.XMLableReader; |
||||
|
||||
import javax.swing.Icon; |
||||
import java.awt.Color; |
||||
import java.awt.Component; |
||||
import java.awt.Graphics; |
||||
import java.awt.Graphics2D; |
||||
import java.awt.Paint; |
||||
import java.awt.image.BufferedImage; |
||||
|
||||
/** |
||||
* 图表的缩略图Icon, 在选择图表类型界面 用到. |
||||
*/ |
||||
public class ChartIcon implements Icon, XMLable { |
||||
private static final int WIDTH = 400; |
||||
private static final int HEIGHT = 225; |
||||
/** |
||||
* 缩略图中的图片路径 |
||||
*/ |
||||
private String imagePath; |
||||
|
||||
private String chartName; |
||||
|
||||
/** |
||||
* 构造Chart的缩略图Icon |
||||
*/ |
||||
public ChartIcon(String imagePath, String chartName) { |
||||
this.imagePath = imagePath; |
||||
this.chartName = chartName; |
||||
} |
||||
|
||||
/** |
||||
* 画出缩略图Icon |
||||
* |
||||
* @param g 图形的上下文 |
||||
* @param c 所在的Component |
||||
* @param x 缩略图的起始坐标x |
||||
* @param y 缩略图的起始坐标y |
||||
*/ |
||||
public void paintIcon(Component c, Graphics g, int x, int y) { |
||||
|
||||
Graphics2D g2d = (Graphics2D) g; |
||||
|
||||
Paint oldPaint = g2d.getPaint(); |
||||
|
||||
g.translate(x, y); |
||||
g2d.setPaint(Color.white); |
||||
|
||||
g2d.fillRect(0, 0, getIconWidth(), getIconHeight()); |
||||
BufferedImage demoImage = IOUtils.readImageWithCache(imagePath); |
||||
GraphHelper.paintImage(g, getIconWidth(), getIconHeight(), demoImage, Constants.IMAGE_ADJUST, Constants.NULL, Constants.NULL, -1, -1); |
||||
|
||||
g.translate(-x, -y); |
||||
g2d.setPaint(oldPaint); |
||||
} |
||||
|
||||
/** |
||||
* 返回缩略图的宽度 |
||||
* |
||||
* @return int 缩略图宽度 |
||||
*/ |
||||
public int getIconWidth() { |
||||
return WIDTH; |
||||
} |
||||
|
||||
/** |
||||
* 返回缩略图的高度 |
||||
* |
||||
* @return int 缩略图高度 |
||||
*/ |
||||
public int getIconHeight() { |
||||
return HEIGHT; |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 返回缩略图中的图片路径 |
||||
* |
||||
* @return 缩略图中的图片路径 |
||||
*/ |
||||
public String getImagePath() { |
||||
return imagePath; |
||||
} |
||||
|
||||
public String getChartName() { |
||||
return chartName; |
||||
} |
||||
|
||||
|
||||
public void readXML(XMLableReader reader) { |
||||
|
||||
} |
||||
|
||||
public void writeXML(XMLPrintWriter writer) { |
||||
|
||||
} |
||||
|
||||
/** |
||||
* @return 克隆后的对象 |
||||
* @throws CloneNotSupportedException 如果克隆失败则抛出此异常 |
||||
*/ |
||||
public Object clone() throws CloneNotSupportedException { |
||||
ChartIcon cloned = (ChartIcon) super.clone(); |
||||
cloned.imagePath = this.imagePath; |
||||
cloned.chartName = this.chartName; |
||||
return cloned; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,92 @@
|
||||
package com.fr.design.widget.ui.designer.mobile.component; |
||||
|
||||
import com.fr.design.designer.IntervalConstants; |
||||
import com.fr.design.designer.creator.XCreator; |
||||
import com.fr.design.dialog.BasicPane; |
||||
import com.fr.design.gui.icombocheckbox.UIComboCheckBox; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.design.layout.TableLayoutHelper; |
||||
import com.fr.design.mainframe.FormDesigner; |
||||
import com.fr.design.mainframe.WidgetPropertyPane; |
||||
import com.fr.design.utils.gui.UIComponentUtils; |
||||
import com.fr.design.widget.FRWidgetFactory; |
||||
import com.fr.form.ui.Widget; |
||||
import com.fr.form.ui.container.WSortLayout; |
||||
import com.fr.stable.ArrayUtils; |
||||
|
||||
import javax.swing.BorderFactory; |
||||
import javax.swing.JPanel; |
||||
import java.awt.BorderLayout; |
||||
import java.awt.Component; |
||||
import java.util.ArrayList; |
||||
import java.util.LinkedHashMap; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @author Hades |
||||
* @date 2019/8/14 |
||||
*/ |
||||
public class MobileComponentFrozenPane extends BasicPane { |
||||
|
||||
private UIComboCheckBox uiComboCheckBox; |
||||
|
||||
public MobileComponentFrozenPane() { |
||||
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||
UILabel frozenLabel = FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Component_Frozen")); |
||||
uiComboCheckBox = new UIComboCheckBox(initData()); |
||||
JPanel wrapJPanel = UIComponentUtils.wrapWithBorderLayoutPane(uiComboCheckBox); |
||||
Component[][] components = new Component[][]{ |
||||
new Component[]{frozenLabel, wrapJPanel} |
||||
}; |
||||
JPanel centerPane = TableLayoutHelper.createGapTableLayoutPane(components, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1); |
||||
centerPane.setBorder(BorderFactory.createEmptyBorder(IntervalConstants.INTERVAL_L1, IntervalConstants.INTERVAL_L5, 10, 0)); |
||||
JPanel holder = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||
holder.add(centerPane, BorderLayout.NORTH); |
||||
this.add(holder, BorderLayout.NORTH); |
||||
} |
||||
|
||||
private String[] initData() { |
||||
FormDesigner designer = WidgetPropertyPane.getInstance().getEditingFormDesigner(); |
||||
XCreator selectedCreator = designer.getSelectionModel().getSelection().getSelectedCreator(); |
||||
Widget selectedModel = selectedCreator != null ? selectedCreator.toData() : null; |
||||
|
||||
if (selectedModel == null || !selectedModel.acceptType(WSortLayout.class)) { |
||||
return ArrayUtils.EMPTY_STRING_ARRAY; |
||||
} |
||||
|
||||
List<String> widgetList = ((WSortLayout) selectedModel).getNonContainerWidgetList(); |
||||
return widgetList.toArray(new String[0]); |
||||
} |
||||
|
||||
public void update(XCreator xCreator) { |
||||
List<String> selected = new ArrayList<>(); |
||||
WSortLayout wSortLayout = ((WSortLayout) xCreator.toData()); |
||||
Object[] values = uiComboCheckBox.getSelectedValues(); |
||||
for (Object widgetName : values) { |
||||
selected.add((String) widgetName); |
||||
} |
||||
wSortLayout.updateFrozenWidgets(selected); |
||||
} |
||||
|
||||
public void populate(XCreator xCreator) { |
||||
WSortLayout wSortLayout = ((WSortLayout) xCreator.toData()); |
||||
List<String> all = wSortLayout.getNonContainerWidgetList(); |
||||
List<String> selected = wSortLayout.getFrozenWidgets(); |
||||
Map<Object, Boolean> map = new LinkedHashMap<>(); |
||||
for (String value : selected) { |
||||
map.put(value, true); |
||||
} |
||||
all.removeAll(selected); |
||||
for (String value : all) { |
||||
map.put(value, false); |
||||
} |
||||
uiComboCheckBox.setSelectedValues(map); |
||||
} |
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return "ComponentFrozenPane"; |
||||
} |
||||
} |
Loading…
Reference in new issue