Browse Source

更新效果图

master
richie 6 years ago
parent
commit
4f68119f6b
  1. 3
      plugin.xml
  2. 2
      pom.xml
  3. 11
      readme.md
  4. BIN
      screenshots/1.png
  5. BIN
      screenshots/2.png
  6. 4
      src/main/java/com/fr/plugin/present/PresentKindBridge.java
  7. 43
      src/main/java/com/fr/plugin/present/fun/StarPainter.java
  8. 61
      src/main/java/com/fr/plugin/present/fun/StarPresent.java
  9. 52
      src/main/java/com/fr/plugin/present/ui/MyPresentPane.java
  10. 73
      src/main/java/com/fr/plugin/present/ui/StarPresentPane.java
  11. BIN
      src/main/resources/com/fr/plugin/present/images/star.png
  12. 2
      src/main/resources/com/fr/plugin/present/locale/present.properties
  13. 2
      src/main/resources/com/fr/plugin/present/locale/present_zh_CN.properties

3
plugin.xml

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<plugin>
<id>com.fr.plugin.present.demo</id>
<id>com.fr.plugin.present.star</id>
<main-package>com.fr.plugin.present</main-package>
<name><![CDATA[自定义形态]]></name>
<active>yes</active>
<version>1.0</version>

2
pom.xml

@ -13,6 +13,6 @@
<artifactId>demo-show-present</artifactId>
<build>
<!---如果要更改调试插件,改这里的配置就可以了-->
<outputDirectory>${project.basedir}/../webroot/WEB-INF/plugins/plugin-com.fr.plugin.function.fib-1.0/classes</outputDirectory>
<outputDirectory>${project.basedir}/../webroot/WEB-INF/plugins/plugin-com.fr.plugin.present.star-1.0/classes</outputDirectory>
</build>
</project>

11
readme.md

@ -0,0 +1,11 @@
# 扩展形态示例
可以将数值转化为用于评分展示的红星。
模板设置如下
![tpl](screenshots/1.png)
预览效果如图所示
![show](screenshots/2.png)

BIN
screenshots/1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

BIN
screenshots/2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

4
src/main/java/com/fr/plugin/present/PresentKindBridge.java

@ -4,7 +4,7 @@ import com.fr.base.present.Present;
import com.fr.design.beans.FurtherBasicBeanPane;
import com.fr.design.fun.impl.AbstractPresentKindProvider;
import com.fr.plugin.present.fun.StarPresent;
import com.fr.plugin.present.ui.MyPresentPane;
import com.fr.plugin.present.ui.StarPresentPane;
/**
* @author richie
@ -15,7 +15,7 @@ public class PresentKindBridge extends AbstractPresentKindProvider {
@Override
public FurtherBasicBeanPane<? extends Present> appearanceForPresent() {
return new MyPresentPane();
return new StarPresentPane();
}
@Override

43
src/main/java/com/fr/plugin/present/fun/StarPainter.java

@ -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
));
}
}

61
src/main/java/com/fr/plugin/present/fun/StarPresent.java

@ -1,11 +1,18 @@
package com.fr.plugin.present.fun;
import com.fr.base.BaseFormula;
import com.fr.base.present.AbstractPresent;
import com.fr.general.GeneralUtils;
import com.fr.intelli.record.Focus;
import com.fr.intelli.record.Original;
import com.fr.log.FineLoggerFactory;
import com.fr.record.analyzer.EnableMetrics;
import com.fr.script.Calculator;
import com.fr.stable.AssistUtils;
import com.fr.stable.ColumnRow;
import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
import com.fr.stable.UtilEvalError;
import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLableReader;
@ -17,19 +24,67 @@ import com.fr.stable.xml.XMLableReader;
@EnableMetrics
public class StarPresent extends AbstractPresent {
private String condition;
public String getCondition() {
return condition;
}
public void setCondition(String condition) {
this.condition = condition;
}
@Override
@Focus(id = "com.fr.plugin.present.demo", text = "", source = Original.PLUGIN)
@Focus(id = "com.fr.plugin.present.star", text = "", source = Original.PLUGIN)
public Object present(Object value, Calculator calculator, ColumnRow cr) {
return "aaa";
Object result = null;
if (StableUtils.canBeFormula(condition)) {
try {
result = calculator.evalValue(BaseFormula.createFormulaBuilder().build(condition));
} catch (UtilEvalError e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
} else {
result = condition;
}
Number num = GeneralUtils.objectToNumber(result, true);
if (num == null) {
return value;
}
return new StarPainter(num.intValue());
}
@Override
public void readXML(XMLableReader reader) {
if (reader.isChildNode()) {
String tag = reader.getTagName();
if ("Condition".equals(tag)) {
condition = reader.getElementValue();
}
}
}
@Override
public void writeXML(XMLPrintWriter writer) {
if (StringUtils.isNotEmpty(condition)) {
writer.startTAG("Condition").textNode(condition).end();
}
}
@Override
public Object clone() throws CloneNotSupportedException {
return super.clone();
}
@Override
public boolean equals(Object o) {
return o instanceof StarPresent
&& super.equals(o)
&& AssistUtils.equals(((StarPresent) o).condition, condition);
}
@Override
public int hashCode() {
return AssistUtils.hashCode(condition);
}
}

52
src/main/java/com/fr/plugin/present/ui/MyPresentPane.java

@ -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();
}
}

73
src/main/java/com/fr/plugin/present/ui/StarPresentPane.java

@ -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;
}
}

BIN
src/main/resources/com/fr/plugin/present/images/star.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

2
src/main/resources/com/fr/plugin/present/locale/present.properties

@ -0,0 +1,2 @@
Plugin-Present_Star=Star
Plugin-Present_Value=Value

2
src/main/resources/com/fr/plugin/present/locale/present_zh_CN.properties

@ -0,0 +1,2 @@
Plugin-Present_Star=\u8BC4\u5206\u5F62\u6001
Plugin-Present_Value=\u8BC4\u5206\u503C
Loading…
Cancel
Save