plantuml/src/net/sourceforge/plantuml/klimt/drawing/tikz/UGraphicTikz.java

117 lines
4.1 KiB
Java
Raw Normal View History

2015-04-07 18:26:58 +00:00
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
2023-02-22 18:43:48 +00:00
* (C) Copyright 2009-2024, Arnaud Roques
2015-04-07 18:26:58 +00:00
*
2023-02-22 18:43:48 +00:00
* Project Info: https://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:
*
2023-02-22 18:43:48 +00:00
* https://plantuml.com/patreon (only 1$ per month!)
* https://plantuml.com/paypal
2017-03-15 19:13:31 +00:00
*
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
*
*/
2023-02-22 18:43:48 +00:00
package net.sourceforge.plantuml.klimt.drawing.tikz;
2015-04-07 18:26:58 +00:00
import java.io.IOException;
import java.io.OutputStream;
2023-02-22 18:43:48 +00:00
import net.sourceforge.plantuml.klimt.ClipContainer;
2023-02-02 17:59:43 +00:00
import net.sourceforge.plantuml.klimt.UPath;
import net.sourceforge.plantuml.klimt.color.ColorMapper;
import net.sourceforge.plantuml.klimt.color.HColor;
2023-02-22 18:43:48 +00:00
import net.sourceforge.plantuml.klimt.creole.legacy.AtomText;
import net.sourceforge.plantuml.klimt.drawing.AbstractCommonUGraphic;
import net.sourceforge.plantuml.klimt.drawing.AbstractUGraphic;
2023-02-02 17:59:43 +00:00
import net.sourceforge.plantuml.klimt.font.StringBounder;
2023-02-22 18:43:48 +00:00
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.UImageSvg;
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;
2015-04-07 18:26:58 +00:00
import net.sourceforge.plantuml.tikz.TikzGraphics;
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
2023-02-22 18:43:48 +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) {
2023-02-26 18:51:17 +00:00
if ("SPECIALTXT".equalsIgnoreCase(propertyName))
2016-12-01 20:29:25 +00:00
return true;
2023-02-26 18:51:17 +00:00
2016-12-01 20:29:25 +00:00
return false;
2015-04-07 18:26:58 +00:00
}
}