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

116 lines
4.0 KiB
Java
Raw Normal View History

2015-04-07 18:26:58 +00:00
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
2022-03-07 19:33:46 +00:00
* (C) Copyright 2009-2023, 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;
2020-05-17 21:15:50 +00:00
import net.sourceforge.plantuml.creole.legacy.AtomText;
2023-02-02 17:59:43 +00:00
import net.sourceforge.plantuml.klimt.DotPath;
import net.sourceforge.plantuml.klimt.UImage;
import net.sourceforge.plantuml.klimt.ULine;
import net.sourceforge.plantuml.klimt.UPath;
import net.sourceforge.plantuml.klimt.UPolygon;
import net.sourceforge.plantuml.klimt.URectangle;
import net.sourceforge.plantuml.klimt.UText;
import net.sourceforge.plantuml.klimt.color.ColorMapper;
import net.sourceforge.plantuml.klimt.color.HColor;
import net.sourceforge.plantuml.klimt.font.StringBounder;
2015-04-07 18:26:58 +00:00
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.UImageSvg;
2023-02-02 17:59:43 +00:00
import net.sourceforge.plantuml.url.Url;
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) {
2022-03-26 15:11:48 +00:00
super(defaultBackground, colorMapper, stringBounder, new TikzGraphics(scale, withPreamble, colorMapper));
2021-10-02 17:36:02 +00:00
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 DriverTextTikz());
2015-04-07 18:26:58 +00:00
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());
ignoreShape(UImageSvg.class);
registerDriver(UPath.class, new DriverPathTikz());
2015-04-07 18:26:58 +00:00
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
}
2022-01-27 17:08:03 +00:00
@Override
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
}
2022-01-27 17:08:03 +00:00
@Override
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
}
}