You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.4 KiB
42 lines
1.4 KiB
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 |
|
)); |
|
} |
|
}
|
|
|