net.sourceforge.plantuml.salt.element.ElementImage Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of plantuml-mit Show documentation
Show all versions of plantuml-mit Show documentation
PlantUML is a component that allows to quickly write diagrams from text.
// THIS FILE HAS BEEN GENERATED BY A PREPROCESSOR.
package net.sourceforge.plantuml.salt.element;
import java.util.List;
import net.sourceforge.plantuml.klimt.UTranslate;
import net.sourceforge.plantuml.klimt.drawing.UGraphic;
import net.sourceforge.plantuml.klimt.font.StringBounder;
import net.sourceforge.plantuml.klimt.geom.XDimension2D;
import net.sourceforge.plantuml.klimt.shape.UPixel;
public class ElementImage extends AbstractElement {
private final List img;
public ElementImage(List img) {
this.img = img;
}
public XDimension2D getPreferredDimension(StringBounder stringBounder, double x, double y) {
return new XDimension2D(img.get(0).length(), img.size());
}
public void drawU(UGraphic ug, int zIndex, XDimension2D dimToUse) {
if (zIndex != 0)
return;
ug = ug.apply(getBlack());
final int w = img.get(0).length();
final int h = img.size();
for (int i = 0; i < w; i++)
for (int j = 0; j < h; j++) {
final char c = img.get(j).charAt(i);
if (c == 'X')
ug.apply(new UTranslate(i, j)).draw(new UPixel());
}
}
}