1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-06-03 09:00:48 +00:00
plantuml/src/net/sourceforge/plantuml/ugraphic/tikz/UGraphicTikz.java

114 lines
4.0 KiB
Java
Raw Normal View History

2015-04-07 18:26:58 +00:00
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
2019-01-16 18:34:41 +00:00
* (C) Copyright 2009-2020, Arnaud Roques
2015-04-07 18:26:58 +00:00
*
2016-03-06 16:47:34 +00:00
* Project Info: http://plantuml.com
2015-04-07 18:26:58 +00:00
*
2017-03-15 19:13:31 +00:00
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
2015-04-07 18:26:58 +00:00
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
*
*/
package net.sourceforge.plantuml.ugraphic.tikz;
import java.io.IOException;
import java.io.OutputStream;
import net.sourceforge.plantuml.Url;
2020-05-17 21:15:50 +00:00
import net.sourceforge.plantuml.creole.legacy.AtomText;
2021-10-02 17:31:42 +00:00
import net.sourceforge.plantuml.graphic.StringBounder;
2015-04-07 18:26:58 +00:00
import net.sourceforge.plantuml.posimo.DotPath;
import net.sourceforge.plantuml.tikz.TikzGraphics;
import net.sourceforge.plantuml.ugraphic.AbstractCommonUGraphic;
import net.sourceforge.plantuml.ugraphic.AbstractUGraphic;
import net.sourceforge.plantuml.ugraphic.ClipContainer;
import net.sourceforge.plantuml.ugraphic.UCenteredCharacter;
import net.sourceforge.plantuml.ugraphic.UEllipse;
import net.sourceforge.plantuml.ugraphic.UImage;
import net.sourceforge.plantuml.ugraphic.UImageSvg;
import net.sourceforge.plantuml.ugraphic.ULine;
import net.sourceforge.plantuml.ugraphic.UPath;
import net.sourceforge.plantuml.ugraphic.UPolygon;
import net.sourceforge.plantuml.ugraphic.URectangle;
import net.sourceforge.plantuml.ugraphic.UText;
2020-03-18 10:50:02 +00:00
import net.sourceforge.plantuml.ugraphic.color.ColorMapper;
2021-05-06 21:23:05 +00:00
import net.sourceforge.plantuml.ugraphic.color.HColor;
2015-04-07 18:26:58 +00:00
public class UGraphicTikz extends AbstractUGraphic<TikzGraphics> implements ClipContainer {
2015-04-07 18:26:58 +00:00
public UGraphicTikz(HColor defaultBackground, ColorMapper colorMapper, StringBounder stringBounder, double scale, boolean withPreamble) {
2021-10-02 17:36:02 +00:00
super(defaultBackground, colorMapper, stringBounder, new TikzGraphics(scale, withPreamble));
register();
2015-04-07 18:26:58 +00:00
}
@Override
protected AbstractCommonUGraphic copyUGraphic() {
return new UGraphicTikz(this);
}
private UGraphicTikz(UGraphicTikz other) {
super(other);
register();
}
private void register() {
registerDriver(URectangle.class, new DriverRectangleTikz());
registerDriver(UText.class, new DriverUTextTikz());
registerDriver(AtomText.class, new DriverAtomTextTikz());
registerDriver(ULine.class, new DriverLineTikz());
registerDriver(UPolygon.class, new DriverPolygonTikz());
registerDriver(UEllipse.class, new DriverEllipseTikz());
2018-09-23 12:15:14 +00:00
registerDriver(UImage.class, new DriverImageTikz());
2015-04-07 18:26:58 +00:00
registerDriver(UImageSvg.class, new DriverNoneTikz());
registerDriver(UPath.class, new DriverUPathTikz());
registerDriver(DotPath.class, new DriverDotPathTikz());
2017-10-07 09:46:53 +00:00
// registerDriver(UCenteredCharacter.class, new DriverCenteredCharacterTikz());
registerDriver(UCenteredCharacter.class, new DriverCenteredCharacterTikz2());
2015-04-07 18:26:58 +00:00
}
public void startUrl(Url url) {
2015-07-11 09:32:49 +00:00
getGraphicObject().openLink(url.getUrl(), url.getTooltip());
2015-04-07 18:26:58 +00:00
}
2020-05-17 21:15:50 +00:00
public void closeUrl() {
2015-07-11 09:32:49 +00:00
getGraphicObject().closeLink();
2015-04-07 18:26:58 +00:00
}
@Override
public void writeToStream(OutputStream os, String metadata, int dpi) throws IOException {
2015-04-07 18:26:58 +00:00
getGraphicObject().createData(os);
}
2016-12-01 20:29:25 +00:00
@Override
public boolean matchesProperty(String propertyName) {
if ("SPECIALTXT".equalsIgnoreCase(propertyName)) {
return true;
}
return false;
2015-04-07 18:26:58 +00:00
}
}