|
|
|
package com.fr.plugin.present.fun;
|
|
|
|
|
|
|
|
import com.fr.base.AbstractPainter;
|
|
|
|
import com.fr.base.Style;
|
|
|
|
import com.fanruan.api.util.IOKit;
|
|
|
|
import com.fanruan.api.util.CellKit;
|
|
|
|
import com.fr.stable.html.Tag;
|
|
|
|
import com.fr.stable.web.Repository;
|
|
|
|
import com.fanruan.api.report.BaseHTMLWriterKit;
|
|
|
|
|
|
|
|
import java.awt.*;
|
|
|
|
import java.awt.image.BufferedImage;
|
|
|
|
|
|
|
|
public class StarPainter extends AbstractPainter {
|
|
|
|
private static final BufferedImage image = IOKit.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(BaseHTMLWriterKit.createImageTag4RepoWithCheckVml(
|
|
|
|
CellKit.value2Image(this, repo.getResolution(), style, width, height), new Dimension(width, height), repo
|
|
|
|
));
|
|
|
|
}
|
|
|
|
}
|