// SVGRoot root = diagram.getRoot();
// root.setAttribute("width", AnimationElement.AT_XML, Integer.toString(imgWidth));
// root.setAttribute("height", AnimationElement.AT_XML, Integer.toString(imgHeight));
// root.build();
SimpleImage imgMap = new SimpleImage(imgWidth, imgHeight);
Graphics2D g = imgMap.getBufferedImg().createGraphics();
g.scale(resolution_multiplier, resolution_multiplier);
if (pre_antialias != 0) {
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
}
else {
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
}
diagram.render(g);
Pixel pixel = new Pixel();
_points = new ArrayList<Point>();
int xMin = imgMap.getImageWidth() - 1, xMax = 0;
int yMin = imgMap.getImageHeight() - 1, yMax = 0;
for (int i = 0; i < imgMap.getImageHeight(); i++) {
for (int j = 0; j < imgMap.getImageWidth(); j++) {
int argb = imgMap.getARGBValue(j, i);
if (argb != 0) {
if (j < xMin) {
xMin = j;
}
else if (j > xMax) {
xMax = j;
}
if (i < yMin) {
yMin = i;
}
else if (i > yMax) {
yMax = i;
}
}
}
}
int xSize = xMax - xMin;
int ySize = yMax - yMin;
int maxSize = xSize > ySize ? xSize : ySize;
if (maxSize > 0) {
for (int i = 0; i < imgMap.getImageHeight(); i++) {
for (int j = 0; j < imgMap.getImageWidth(); j++) {
int argb = imgMap.getARGBValue(j, i);
if (argb != 0) {
double x = ((j - xMin) - xSize / 2.0) / (double) maxSize;
double y = ((i - yMin) - ySize / 2.0) / (double) maxSize;
pixel.setARGBValue(argb);
_points.add(new Point(x, y, pixel.r, pixel.g, pixel.b));