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.
47 lines
1.5 KiB
47 lines
1.5 KiB
package com.tptj.demo.hg.present.kind.provider; |
|
|
|
import com.fr.base.AbstractPainter; |
|
import com.fr.base.Style; |
|
import com.fr.general.ImageWithSuffix; |
|
import com.fr.report.cell.cellattr.core.CellUtils; |
|
import com.fr.stable.CoreGraphHelper; |
|
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; |
|
|
|
/** |
|
* @author 秃破天际 |
|
* @version 10.0 |
|
* Created by 秃破天际 on 2021-04-29 |
|
**/ |
|
public class DemoPainter extends AbstractPainter { |
|
private Object value; |
|
|
|
public DemoPainter(Object value){ |
|
this.value = value; |
|
} |
|
|
|
@Override |
|
public void paint(Graphics g, int width, int height, int resolution, Style style) { |
|
Graphics2D g2d = (Graphics2D) g; |
|
if (value instanceof ImageWithSuffix) { |
|
value = ((ImageWithSuffix)value).getImage(); |
|
} |
|
BufferedImage img = CoreGraphHelper.createBufferedImage(width, height, 6); |
|
g2d.setPaint(Color.white); |
|
Style.paintContent(g2d, value, style, width, height, resolution); |
|
img.flush(); |
|
g2d.dispose(); |
|
} |
|
|
|
@Override |
|
public void paintTag(Repository repo, int width, int height, Style style, Tag tag) { |
|
tag.cls("imageCellElement"); |
|
tag.sub(BaseHTMLWriterUtils.createImageTag4RepoWithCheckVml( |
|
CellUtils.value2Image(value, repo.getResolution(), style, width, height), new Dimension(width, height), repo |
|
)); |
|
} |
|
}
|
|
|