net.sourceforge.plantuml.braille.UGraphicBraille 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.braille;
import java.io.IOException;
import java.io.OutputStream;
import net.atmp.ImageBuilder;
import net.sourceforge.plantuml.klimt.ClipContainer;
import net.sourceforge.plantuml.klimt.UPath;
import net.sourceforge.plantuml.klimt.color.ColorMapper;
import net.sourceforge.plantuml.klimt.color.HColor;
import net.sourceforge.plantuml.klimt.drawing.AbstractCommonUGraphic;
import net.sourceforge.plantuml.klimt.drawing.AbstractUGraphic;
import net.sourceforge.plantuml.klimt.font.StringBounder;
import net.sourceforge.plantuml.klimt.shape.DotPath;
import net.sourceforge.plantuml.klimt.shape.UCenteredCharacter;
import net.sourceforge.plantuml.klimt.shape.UEllipse;
import net.sourceforge.plantuml.klimt.shape.UImage;
import net.sourceforge.plantuml.klimt.shape.ULine;
import net.sourceforge.plantuml.klimt.shape.UPolygon;
import net.sourceforge.plantuml.klimt.shape.URectangle;
import net.sourceforge.plantuml.klimt.shape.UText;
// https://www.branah.com/braille-translator
public class UGraphicBraille extends AbstractUGraphic implements ClipContainer {
public static final int QUANTA = 4;
@Override
protected AbstractCommonUGraphic copyUGraphic() {
final UGraphicBraille result = new UGraphicBraille(this);
return result;
}
public UGraphicBraille(HColor defaultBackground, ColorMapper colorMapper, StringBounder stringBounder) {
super(stringBounder);
copy(defaultBackground, colorMapper, new BrailleGrid(QUANTA));
register();
}
private UGraphicBraille(UGraphicBraille other) {
super(other.getStringBounder());
copy(other);
register();
}
// public UGraphicBraille(ColorMapper colorMapper, String backcolor, boolean
// textAsPath, double scale, String
// linkTarget) {
// this(colorMapper, new SvgGraphics(backcolor, scale), textAsPath, linkTarget);
// }
//
// public UGraphicBraille(ColorMapper colorMapper, boolean textAsPath, double
// scale, String linkTarget) {
// this(colorMapper, new SvgGraphics(scale), textAsPath, linkTarget);
// }
//
// public UGraphicBraille(ColorMapper mapper, HtmlColorGradient gr, boolean
// textAsPath, double scale, String
// linkTarget) {
// this(mapper, new SvgGraphics(scale), textAsPath, linkTarget);
//
// final SvgGraphics svg = getGraphicObject();
// svg.paintBackcolorGradient(mapper, gr);
// }
private void register() {
ignoreShape(URectangle.class);
registerDriver(URectangle.class, new DriverRectangleBraille(this));
registerDriver(UText.class, new DriverTextBraille());
registerDriver(ULine.class, new DriverLineBraille(this));
registerDriver(UPolygon.class, new DriverPolygonBraille(this));
ignoreShape(UEllipse.class);
ignoreShape(UImage.class);
ignoreShape(UPath.class);
registerDriver(DotPath.class, new DriverDotPathBraille());
registerDriver(UCenteredCharacter.class, new DriverCenteredCharacterBraille());
}
@Override
public void writeToStream(OutputStream os, String metadata, int dpi) throws IOException {
ImageBuilder.plainPngBuilder(new BrailleDrawer(getGraphicObject())).metadata(metadata).write(os);
}
}