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