13 changed files with 194 additions and 59 deletions
@ -0,0 +1,11 @@
|
||||
# 扩展形态示例 |
||||
|
||||
可以将数值转化为用于评分展示的红星。 |
||||
|
||||
模板设置如下 |
||||
|
||||
 |
||||
|
||||
预览效果如图所示 |
||||
|
||||
 |
After Width: | Height: | Size: 50 KiB |
After Width: | Height: | Size: 26 KiB |
@ -0,0 +1,43 @@
|
||||
package com.fr.plugin.present.fun; |
||||
|
||||
import com.fr.base.AbstractPainter; |
||||
import com.fr.base.Style; |
||||
import com.fr.general.IOUtils; |
||||
import com.fr.report.cell.cellattr.core.CellUtils; |
||||
import com.fr.stable.html.Tag; |
||||
import com.fr.stable.web.Repository; |
||||
import com.fr.web.BaseHTMLWriterUtils; |
||||
|
||||
import java.awt.*; |
||||
import java.awt.image.BufferedImage; |
||||
|
||||
public class StarPainter extends AbstractPainter { |
||||
|
||||
private static final BufferedImage image = IOUtils.readImage("/com/fr/plugin/present/images/star.png"); |
||||
|
||||
private int count; |
||||
private int hGap = 4; |
||||
|
||||
public StarPainter(int count) { |
||||
this.count = count; |
||||
} |
||||
|
||||
@Override |
||||
public void paint(Graphics g, int width, int height, int resolution, Style style) { |
||||
Graphics2D g2d = (Graphics2D) g; |
||||
int imageWidth = image.getWidth(); |
||||
int imageHeight = image.getHeight(); |
||||
int y = (height - imageHeight) / 2; |
||||
for (int i = 0; i < count; i++) { |
||||
g2d.drawImage(image, (imageWidth + hGap) * i, y, imageWidth, imageHeight, null); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public void paintTag(Repository repo, int width, int height, Style style, Tag tag) { |
||||
tag.cls("imageCellElement"); |
||||
tag.sub(BaseHTMLWriterUtils.createImageTag4RepoWithCheckVml( |
||||
CellUtils.value2Image(this, repo.getResolution(), style, width, height), new Dimension(width, height), repo |
||||
)); |
||||
} |
||||
} |
@ -1,52 +0,0 @@
|
||||
package com.fr.plugin.present.ui; |
||||
|
||||
import com.fr.design.beans.FurtherBasicBeanPane; |
||||
import com.fr.design.gui.itextfield.UITextField; |
||||
import com.fr.plugin.present.fun.StarPresent; |
||||
|
||||
import java.awt.*; |
||||
|
||||
/** |
||||
* @author richie |
||||
* @date 2015-05-24 |
||||
* @since 8.0 |
||||
*/ |
||||
public class MyPresentPane extends FurtherBasicBeanPane<StarPresent>{ |
||||
private UITextField textField; |
||||
|
||||
public MyPresentPane() { |
||||
initComponents(); |
||||
} |
||||
|
||||
private void initComponents() { |
||||
setLayout(new BorderLayout()); |
||||
textField = new UITextField(); |
||||
add(textField, BorderLayout.NORTH); |
||||
} |
||||
|
||||
|
||||
@Override |
||||
public boolean accept(Object ob) { |
||||
return ob instanceof StarPresent; |
||||
} |
||||
|
||||
@Override |
||||
public String title4PopupWindow() { |
||||
return "我的形态"; |
||||
} |
||||
|
||||
@Override |
||||
public void reset() { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public void populateBean(StarPresent ob) { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public StarPresent updateBean() { |
||||
return new StarPresent(); |
||||
} |
||||
} |
@ -0,0 +1,73 @@
|
||||
package com.fr.plugin.present.ui; |
||||
|
||||
import com.fr.design.beans.FurtherBasicBeanPane; |
||||
import com.fr.design.editor.ValueEditorPane; |
||||
import com.fr.design.editor.ValueEditorPaneFactory; |
||||
import com.fr.design.editor.editor.Editor; |
||||
import com.fr.design.editor.editor.FormulaEditor; |
||||
import com.fr.design.editor.editor.IntegerEditor; |
||||
import com.fr.design.formula.TinyFormulaPane; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.gui.itextfield.UITextField; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.design.utils.gui.GUICoreUtils; |
||||
import com.fr.plugin.present.fun.StarPresent; |
||||
|
||||
import java.awt.*; |
||||
|
||||
/** |
||||
* @author richie |
||||
* @date 2015-05-24 |
||||
* @since 8.0 |
||||
*/ |
||||
public class StarPresentPane extends FurtherBasicBeanPane<StarPresent> { |
||||
|
||||
private TinyFormulaPane formulaPane; |
||||
|
||||
public StarPresentPane() { |
||||
initComponents(); |
||||
} |
||||
|
||||
private void initComponents() { |
||||
setLayout(new BorderLayout()); |
||||
formulaPane = new TinyFormulaPane(); |
||||
add(GUICoreUtils.createBorderLayoutPane( |
||||
new UILabel(Toolkit.i18nText("Plugin-Present_Value") + ":"), |
||||
BorderLayout.WEST, |
||||
formulaPane, |
||||
BorderLayout.CENTER |
||||
), BorderLayout.NORTH); |
||||
|
||||
} |
||||
|
||||
|
||||
@Override |
||||
public boolean accept(Object ob) { |
||||
return ob instanceof StarPresent; |
||||
} |
||||
|
||||
@Override |
||||
public String title4PopupWindow() { |
||||
return Toolkit.i18nText("Plugin-Present_Star"); |
||||
} |
||||
|
||||
@Override |
||||
public void reset() { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public void populateBean(StarPresent ob) { |
||||
if (ob == null) { |
||||
return; |
||||
} |
||||
formulaPane.populateBean(ob.getCondition()); |
||||
} |
||||
|
||||
@Override |
||||
public StarPresent updateBean() { |
||||
StarPresent starPresent = new StarPresent(); |
||||
starPresent.setCondition(formulaPane.updateBean()); |
||||
return starPresent; |
||||
} |
||||
} |
After Width: | Height: | Size: 1.7 KiB |
@ -0,0 +1,2 @@
|
||||
Plugin-Present_Star=Star |
||||
Plugin-Present_Value=Value |
Loading…
Reference in new issue