1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-11-26 14:56:28 +00:00

Extract common functionality to new ImageBuilder methods plainImageBuilder() plainPngBuilder() styledImageBuilder() and to PlainDiagram / PlainStringsDiagram classes.

This commit is contained in:
matthew16550 2021-03-23 20:40:50 +11:00
parent efab37d3ce
commit ac1fa530cf
55 changed files with 513 additions and 981 deletions

View File

@ -50,6 +50,7 @@ import net.sourceforge.plantuml.cucadiagram.DisplayPositionned;
import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.VerticalAlignment; import net.sourceforge.plantuml.graphic.VerticalAlignment;
import net.sourceforge.plantuml.stats.StatsUtilsIncrement; import net.sourceforge.plantuml.stats.StatsUtilsIncrement;
import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft;
import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException;
import net.sourceforge.plantuml.version.License; import net.sourceforge.plantuml.version.License;
import net.sourceforge.plantuml.version.Version; import net.sourceforge.plantuml.version.Version;
@ -162,4 +163,8 @@ public abstract class AbstractPSystem implements Diagram {
protected abstract ImageData exportDiagramNow(OutputStream os, int index, FileFormatOption fileFormatOption, protected abstract ImageData exportDiagramNow(OutputStream os, int index, FileFormatOption fileFormatOption,
long seed) throws IOException; long seed) throws IOException;
public ClockwiseTopRightBottomLeft getDefaultMargins() {
return ClockwiseTopRightBottomLeft.same(0);
}
} }

View File

@ -0,0 +1,68 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* 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
*
* 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;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.graphic.UDrawable;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import java.io.IOException;
import java.io.OutputStream;
import static net.sourceforge.plantuml.ugraphic.ImageBuilder.plainImageBuilder;
// This class doesnt feel like a wonderful idea, just a stepping stone towards something
public abstract class PlainDiagram extends AbstractPSystem {
@Override
protected ImageData exportDiagramNow(OutputStream os, int index, FileFormatOption fileFormatOption, long seed)
throws IOException {
final UDrawable drawable = getRootDrawable(fileFormatOption);
final ImageBuilder builder = plainImageBuilder(drawable, fileFormatOption, seed)
.margin(getDefaultMargins())
.metadata(fileFormatOption.isWithMetadata() ? getMetadata() : null);
return adjustImageBuilder(builder).write(os);
}
// kind of a kludge but good enough for now!
protected ImageBuilder adjustImageBuilder(ImageBuilder builder) {
return builder;
}
protected abstract UDrawable getRootDrawable(FileFormatOption fileFormatOption) throws IOException;
}

View File

@ -0,0 +1,57 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* 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
*
* 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;
import net.sourceforge.plantuml.graphic.GraphicPosition;
import net.sourceforge.plantuml.graphic.UDrawable;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.List;
import static net.sourceforge.plantuml.graphic.GraphicStrings.createBlackOnWhite;
public abstract class PlainStringsDiagram extends PlainDiagram {
protected BufferedImage image = null;
protected GraphicPosition imagePosition = null;
protected final List<String> strings = new ArrayList<String>();
@Override
public UDrawable getRootDrawable(FileFormatOption fileFormatOption) {
return createBlackOnWhite(strings, image, imagePosition);
}
}

View File

@ -48,12 +48,9 @@ import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.graphic.GraphicStrings; import net.sourceforge.plantuml.graphic.GraphicStrings;
import net.sourceforge.plantuml.preproc.Defines; import net.sourceforge.plantuml.preproc.Defines;
import net.sourceforge.plantuml.security.SFile; import net.sourceforge.plantuml.security.SFile;
import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft;
import net.sourceforge.plantuml.svek.TextBlockBackcolored; import net.sourceforge.plantuml.svek.TextBlockBackcolored;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.ImageParameter; import static net.sourceforge.plantuml.ugraphic.ImageBuilder.plainImageBuilder;
import net.sourceforge.plantuml.ugraphic.color.ColorMapperIdentity;
import net.sourceforge.plantuml.ugraphic.color.HColor;
public class SourceStringReader { public class SourceStringReader {
@ -228,12 +225,9 @@ public class SourceStringReader {
public ImageData noStartumlFound(OutputStream os, FileFormatOption fileFormatOption, long seed) throws IOException { public ImageData noStartumlFound(OutputStream os, FileFormatOption fileFormatOption, long seed) throws IOException {
final TextBlockBackcolored error = GraphicStrings.createForError(Arrays.asList("No @startuml/@enduml found"), final TextBlockBackcolored error = GraphicStrings.createForError(Arrays.asList("No @startuml/@enduml found"),
fileFormatOption.isUseRedForError()); fileFormatOption.isUseRedForError());
HColor backcolor = error.getBackcolor();
final ImageParameter imageParameter = new ImageParameter(new ColorMapperIdentity(), false, null, null, return plainImageBuilder(error, fileFormatOption, seed)
null, ClockwiseTopRightBottomLeft.none(), backcolor); .write(os);
final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter);
imageBuilder.setUDrawable(error);
return imageBuilder.writeImageTOBEMOVED(fileFormatOption, seed, os);
} }
public final List<BlockUml> getBlocks() { public final List<BlockUml> getBlocks() {

View File

@ -212,7 +212,7 @@ public abstract class TitledDiagram extends AbstractPSystem implements Diagram,
return useSmetana; return useSmetana;
} }
// This is for backwards compatibility with earlier default margins @Override
public ClockwiseTopRightBottomLeft getDefaultMargins() { public ClockwiseTopRightBottomLeft getDefaultMargins() {
return ClockwiseTopRightBottomLeft.same(10); return ClockwiseTopRightBottomLeft.same(10);
} }

View File

@ -68,23 +68,20 @@ import net.sourceforge.plantuml.pdf.PdfConverter;
import net.sourceforge.plantuml.security.ImageIO; import net.sourceforge.plantuml.security.ImageIO;
import net.sourceforge.plantuml.security.SFile; import net.sourceforge.plantuml.security.SFile;
import net.sourceforge.plantuml.security.SecurityUtils; import net.sourceforge.plantuml.security.SecurityUtils;
import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft;
import net.sourceforge.plantuml.style.NoStyleAvailableException; import net.sourceforge.plantuml.style.NoStyleAvailableException;
import net.sourceforge.plantuml.svek.EmptySvgException; import net.sourceforge.plantuml.svek.EmptySvgException;
import net.sourceforge.plantuml.svek.GraphvizCrash; import net.sourceforge.plantuml.svek.GraphvizCrash;
import net.sourceforge.plantuml.svek.TextBlockBackcolored; import net.sourceforge.plantuml.svek.TextBlockBackcolored;
import net.sourceforge.plantuml.ugraphic.AffineTransformType; import net.sourceforge.plantuml.ugraphic.AffineTransformType;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.ImageParameter;
import net.sourceforge.plantuml.ugraphic.PixelImage; import net.sourceforge.plantuml.ugraphic.PixelImage;
import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UImage; import net.sourceforge.plantuml.ugraphic.UImage;
import net.sourceforge.plantuml.ugraphic.UTranslate; import net.sourceforge.plantuml.ugraphic.UTranslate;
import net.sourceforge.plantuml.ugraphic.color.ColorMapperIdentity;
import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColor;
import net.sourceforge.plantuml.ugraphic.color.HColorUtils;
import net.sourceforge.plantuml.version.Version; import net.sourceforge.plantuml.version.Version;
import static net.sourceforge.plantuml.ugraphic.ImageBuilder.plainImageBuilder;
public abstract class UmlDiagram extends TitledDiagram implements Diagram, Annotated, WithSprite { public abstract class UmlDiagram extends TitledDiagram implements Diagram, Annotated, WithSprite {
private boolean rotation; private boolean rotation;
@ -184,11 +181,6 @@ public abstract class UmlDiagram extends TitledDiagram implements Diagram, Annot
} }
strings.addAll(CommandExecutionResult.getStackTrace(exception)); strings.addAll(CommandExecutionResult.getStackTrace(exception));
HColor backcolor = HColorUtils.WHITE;
final ImageParameter imageParameter = new ImageParameter(new ColorMapperIdentity(), false, null, metadata,
null, ClockwiseTopRightBottomLeft.none(), backcolor);
final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter);
BufferedImage im2 = null; BufferedImage im2 = null;
if (flash != null) { if (flash != null) {
@ -207,19 +199,18 @@ public abstract class UmlDiagram extends TitledDiagram implements Diagram, Annot
final TextBlockBackcolored graphicStrings = GraphicStrings.createBlackOnWhite(strings, IconLoader.getRandom(), final TextBlockBackcolored graphicStrings = GraphicStrings.createBlackOnWhite(strings, IconLoader.getRandom(),
GraphicPosition.BACKGROUND_CORNER_TOP_RIGHT); GraphicPosition.BACKGROUND_CORNER_TOP_RIGHT);
if (im == null) { final UDrawable drawable = (im == null) ? graphicStrings : new UDrawable() {
imageBuilder.setUDrawable(graphicStrings);
} else {
imageBuilder.setUDrawable(new UDrawable() {
public void drawU(UGraphic ug) { public void drawU(UGraphic ug) {
graphicStrings.drawU(ug); graphicStrings.drawU(ug);
final double height = graphicStrings.calculateDimension(ug.getStringBounder()).getHeight(); final double height = graphicStrings.calculateDimension(ug.getStringBounder()).getHeight();
ug = ug.apply(UTranslate.dy(height)); ug = ug.apply(UTranslate.dy(height));
ug.draw(new UImage(new PixelImage(im, AffineTransformType.TYPE_NEAREST_NEIGHBOR)).scale(3)); ug.draw(new UImage(new PixelImage(im, AffineTransformType.TYPE_NEAREST_NEIGHBOR)).scale(3));
} }
}); };
}
imageBuilder.writeImageTOBEMOVED(fileFormat, seed, os); plainImageBuilder(drawable, fileFormat, seed)
.metadata(metadata)
.write(os);
} }
private static void exportDiagramErrorText(OutputStream os, Throwable exception, List<String> strings) { private static void exportDiagramErrorText(OutputStream os, Throwable exception, List<String> strings) {

View File

@ -38,9 +38,7 @@ package net.sourceforge.plantuml.activitydiagram3;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import net.sourceforge.plantuml.AnnotatedWorker;
import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.ISkinSimple; import net.sourceforge.plantuml.ISkinSimple;
import net.sourceforge.plantuml.UmlDiagram; import net.sourceforge.plantuml.UmlDiagram;
import net.sourceforge.plantuml.UmlDiagramType; import net.sourceforge.plantuml.UmlDiagramType;
@ -60,12 +58,12 @@ import net.sourceforge.plantuml.graphic.USymbol;
import net.sourceforge.plantuml.graphic.color.Colors; import net.sourceforge.plantuml.graphic.color.Colors;
import net.sourceforge.plantuml.sequencediagram.NotePosition; import net.sourceforge.plantuml.sequencediagram.NotePosition;
import net.sourceforge.plantuml.sequencediagram.NoteType; import net.sourceforge.plantuml.sequencediagram.NoteType;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.ImageParameter;
import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColor;
import net.sourceforge.plantuml.ugraphic.comp.CompressionMode; import net.sourceforge.plantuml.ugraphic.comp.CompressionMode;
import net.sourceforge.plantuml.ugraphic.comp.CompressionXorYBuilder; import net.sourceforge.plantuml.ugraphic.comp.CompressionXorYBuilder;
import static net.sourceforge.plantuml.ugraphic.ImageBuilder.styledImageBuilder;
public class ActivityDiagram3 extends UmlDiagram { public class ActivityDiagram3 extends UmlDiagram {
enum SwimlaneStrategy { enum SwimlaneStrategy {
@ -207,16 +205,8 @@ public class ActivityDiagram3 extends UmlDiagram {
result = CompressionXorYBuilder.build(CompressionMode.ON_Y, result, stringBounder); result = CompressionXorYBuilder.build(CompressionMode.ON_Y, result, stringBounder);
result = new TextBlockRecentred(result); result = new TextBlockRecentred(result);
final ISkinParam skinParam = getSkinParam(); return styledImageBuilder(this, result, index, fileFormatOption, seed())
result = new AnnotatedWorker(this, skinParam, stringBounder).addAdd(result); .write(os);
final ImageParameter imageParameter = new ImageParameter(this, fileFormatOption);
final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter);
imageBuilder.setUDrawable(result);
return imageBuilder.writeImageTOBEMOVED(seed(), os);
} }
public void fork() { public void fork() {

View File

@ -42,10 +42,8 @@ import java.io.OutputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import net.sourceforge.plantuml.AnnotatedWorker;
import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.Dimension2DDouble;
import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.UmlDiagram; import net.sourceforge.plantuml.UmlDiagram;
import net.sourceforge.plantuml.UmlDiagramType; import net.sourceforge.plantuml.UmlDiagramType;
import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.CommandExecutionResult;
@ -53,10 +51,7 @@ import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.ImageData; import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.graphic.InnerStrategy; import net.sourceforge.plantuml.graphic.InnerStrategy;
import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.svek.TextBlockBackcolored; import net.sourceforge.plantuml.svek.TextBlockBackcolored;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.ImageParameter;
import net.sourceforge.plantuml.ugraphic.MinMax; import net.sourceforge.plantuml.ugraphic.MinMax;
import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.ULine; import net.sourceforge.plantuml.ugraphic.ULine;
@ -65,6 +60,8 @@ import net.sourceforge.plantuml.ugraphic.UTranslate;
import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColor;
import net.sourceforge.plantuml.ugraphic.color.HColorUtils; import net.sourceforge.plantuml.ugraphic.color.HColorUtils;
import static net.sourceforge.plantuml.ugraphic.ImageBuilder.styledImageBuilder;
public class BoardDiagram extends UmlDiagram { public class BoardDiagram extends UmlDiagram {
private final List<Activity> activities = new ArrayList<Activity>(); private final List<Activity> activities = new ArrayList<Activity>();
@ -81,19 +78,8 @@ public class BoardDiagram extends UmlDiagram {
protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption) protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
throws IOException { throws IOException {
final ISkinParam skinParam = getSkinParam(); return styledImageBuilder(this, getTextBlock(), index, fileFormatOption, seed())
.write(os);
final ImageParameter imageParameter = new ImageParameter(this, fileFormatOption);
final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter);
TextBlock result = getTextBlock();
result = new AnnotatedWorker(this, skinParam, fileFormatOption.getDefaultStringBounder(getSkinParam()))
.addAdd(result);
imageBuilder.setUDrawable(result);
return imageBuilder.writeImageTOBEMOVED(seed(), os);
} }
private TextBlockBackcolored getTextBlock() { private TextBlockBackcolored getTextBlock() {

View File

@ -49,8 +49,8 @@ import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.core.DiagramDescription; import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.ImageData; import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.graphic.UDrawable; import net.sourceforge.plantuml.graphic.UDrawable;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.ImageParameter; import static net.sourceforge.plantuml.ugraphic.ImageBuilder.styledImageBuilder;
public class BpmDiagram extends UmlDiagram { public class BpmDiagram extends UmlDiagram {
@ -81,12 +81,10 @@ public class BpmDiagram extends UmlDiagram {
@Override @Override
protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption) protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
throws IOException { throws IOException {
final ImageParameter imageParameter = new ImageParameter(this, fileFormatOption);
final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter);
imageBuilder.setUDrawable(getUDrawable());
return imageBuilder.writeImageTOBEMOVED(seed(), os); return styledImageBuilder(this, getUDrawable(), index, fileFormatOption, seed())
.annotations(false)
.write(os);
} }
private UDrawable getUDrawable() { private UDrawable getUDrawable() {

View File

@ -38,16 +38,12 @@ import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import net.sourceforge.plantuml.FileFormat; import net.sourceforge.plantuml.FileFormat;
import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.TikzFontDistortion; import net.sourceforge.plantuml.TikzFontDistortion;
import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.posimo.DotPath; import net.sourceforge.plantuml.posimo.DotPath;
import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft;
import net.sourceforge.plantuml.ugraphic.AbstractCommonUGraphic; import net.sourceforge.plantuml.ugraphic.AbstractCommonUGraphic;
import net.sourceforge.plantuml.ugraphic.AbstractUGraphic; import net.sourceforge.plantuml.ugraphic.AbstractUGraphic;
import net.sourceforge.plantuml.ugraphic.ClipContainer; import net.sourceforge.plantuml.ugraphic.ClipContainer;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.ImageParameter;
import net.sourceforge.plantuml.ugraphic.UCenteredCharacter; import net.sourceforge.plantuml.ugraphic.UCenteredCharacter;
import net.sourceforge.plantuml.ugraphic.UEllipse; import net.sourceforge.plantuml.ugraphic.UEllipse;
import net.sourceforge.plantuml.ugraphic.UGraphic2; import net.sourceforge.plantuml.ugraphic.UGraphic2;
@ -58,9 +54,8 @@ import net.sourceforge.plantuml.ugraphic.UPolygon;
import net.sourceforge.plantuml.ugraphic.URectangle; import net.sourceforge.plantuml.ugraphic.URectangle;
import net.sourceforge.plantuml.ugraphic.UText; import net.sourceforge.plantuml.ugraphic.UText;
import net.sourceforge.plantuml.ugraphic.color.ColorMapper; import net.sourceforge.plantuml.ugraphic.color.ColorMapper;
import net.sourceforge.plantuml.ugraphic.color.ColorMapperIdentity;
import net.sourceforge.plantuml.ugraphic.color.HColor; import static net.sourceforge.plantuml.ugraphic.ImageBuilder.plainPngBuilder;
import net.sourceforge.plantuml.ugraphic.color.HColorUtils;
// https://www.branah.com/braille-translator // https://www.branah.com/braille-translator
public class UGraphicBraille extends AbstractUGraphic<BrailleGrid> implements ClipContainer, UGraphic2 { public class UGraphicBraille extends AbstractUGraphic<BrailleGrid> implements ClipContainer, UGraphic2 {
@ -127,13 +122,8 @@ public class UGraphicBraille extends AbstractUGraphic<BrailleGrid> implements Cl
} }
public void writeImageTOBEMOVED(OutputStream os, String metadata, int dpi) throws IOException { public void writeImageTOBEMOVED(OutputStream os, String metadata, int dpi) throws IOException {
HColor backcolor = HColorUtils.WHITE; plainPngBuilder(new BrailleDrawer(getGraphicObject()))
final ImageParameter imageParameter = new ImageParameter(new ColorMapperIdentity(), false, null, metadata, .metadata(metadata)
null, ClockwiseTopRightBottomLeft.none(), backcolor); .write(os);
final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter);
imageBuilder.setUDrawable(new BrailleDrawer(getGraphicObject()));
imageBuilder.writeImageTOBEMOVED(new FileFormatOption(FileFormat.PNG), 42, os);
} }
} }

View File

@ -56,8 +56,8 @@ import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.USymbol; import net.sourceforge.plantuml.graphic.USymbol;
import net.sourceforge.plantuml.objectdiagram.AbstractClassOrObjectDiagram; import net.sourceforge.plantuml.objectdiagram.AbstractClassOrObjectDiagram;
import net.sourceforge.plantuml.svek.image.EntityImageClass; import net.sourceforge.plantuml.svek.image.EntityImageClass;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.ImageParameter; import static net.sourceforge.plantuml.ugraphic.ImageBuilder.styledImageBuilder;
public class ClassDiagram extends AbstractClassOrObjectDiagram { public class ClassDiagram extends AbstractClassOrObjectDiagram {
@ -198,10 +198,9 @@ public class ClassDiagram extends AbstractClassOrObjectDiagram {
final RowLayout rawLayout = getRawLayout(i); final RowLayout rawLayout = getRawLayout(i);
fullLayout.addRowLayout(rawLayout); fullLayout.addRowLayout(rawLayout);
} }
final ImageParameter imageParameter = new ImageParameter(this, fileFormatOption); return styledImageBuilder(this, fullLayout, index, fileFormatOption, seed())
final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter); .annotations(false) // Backwards compatibility - this only applies when "layout_new_line" is used
imageBuilder.setUDrawable(fullLayout); .write(os);
return imageBuilder.writeImageTOBEMOVED(seed(), os);
} }
private RowLayout getRawLayout(int raw) { private RowLayout getRawLayout(int raw) {

View File

@ -35,18 +35,15 @@
*/ */
package net.sourceforge.plantuml.creole.legacy; package net.sourceforge.plantuml.creole.legacy;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import net.sourceforge.plantuml.AbstractPSystem;
import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.LineBreakStrategy; import net.sourceforge.plantuml.LineBreakStrategy;
import net.sourceforge.plantuml.PlainDiagram;
import net.sourceforge.plantuml.SkinParam; import net.sourceforge.plantuml.SkinParam;
import net.sourceforge.plantuml.UmlDiagramType; import net.sourceforge.plantuml.UmlDiagramType;
import net.sourceforge.plantuml.core.DiagramDescription; import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.creole.CreoleMode; import net.sourceforge.plantuml.creole.CreoleMode;
import net.sourceforge.plantuml.creole.Parser; import net.sourceforge.plantuml.creole.Parser;
import net.sourceforge.plantuml.creole.Sheet; import net.sourceforge.plantuml.creole.Sheet;
@ -54,13 +51,10 @@ import net.sourceforge.plantuml.creole.SheetBlock1;
import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft; import net.sourceforge.plantuml.graphic.UDrawable;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.ImageParameter;
import net.sourceforge.plantuml.ugraphic.UFont; import net.sourceforge.plantuml.ugraphic.UFont;
import net.sourceforge.plantuml.ugraphic.color.ColorMapperIdentity;
public class PSystemCreole extends AbstractPSystem { public class PSystemCreole extends PlainDiagram {
private final List<String> lines = new ArrayList<String>(); private final List<String> lines = new ArrayList<String>();
@ -76,20 +70,13 @@ public class PSystemCreole extends AbstractPSystem {
} }
@Override @Override
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed) protected UDrawable getRootDrawable(FileFormatOption fileFormatOption) {
throws IOException {
final Display display = Display.create(lines); final Display display = Display.create(lines);
final UFont font = UFont.serif(14); final UFont font = UFont.serif(14);
final FontConfiguration fontConfiguration = FontConfiguration.blackBlueTrue(font); final FontConfiguration fontConfiguration = FontConfiguration.blackBlueTrue(font);
final Sheet sheet = Parser.build(fontConfiguration, HorizontalAlignment.LEFT, final Sheet sheet = Parser.build(fontConfiguration, HorizontalAlignment.LEFT,
SkinParam.create(UmlDiagramType.SEQUENCE), CreoleMode.FULL).createSheet(display); SkinParam.create(UmlDiagramType.SEQUENCE), CreoleMode.FULL).createSheet(display);
final SheetBlock1 sheetBlock = new SheetBlock1(sheet, LineBreakStrategy.NONE, 0); return new SheetBlock1(sheet, LineBreakStrategy.NONE, 0);
final ImageParameter imageParameter = new ImageParameter(new ColorMapperIdentity(), false, null, null,
null, ClockwiseTopRightBottomLeft.none(), null);
final ImageBuilder builder = ImageBuilder.build(imageParameter);
builder.setUDrawable(sheetBlock);
return builder.writeImageTOBEMOVED(fileFormat, seed, os);
// final Dimension2D dim = TextBlockUtils.getDimension(sheetBlock); // final Dimension2D dim = TextBlockUtils.getDimension(sheetBlock);
// final UGraphic2 ug = fileFormat.createUGraphic(new ColorMapperIdentity(), 1, // final UGraphic2 ug = fileFormat.createUGraphic(new ColorMapperIdentity(), 1,

View File

@ -36,26 +36,17 @@
package net.sourceforge.plantuml.dedication; package net.sourceforge.plantuml.dedication;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.OutputStream;
import net.sourceforge.plantuml.AbstractPSystem;
import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.PlainDiagram;
import net.sourceforge.plantuml.core.DiagramDescription; import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.graphic.UDrawable; import net.sourceforge.plantuml.graphic.UDrawable;
import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft;
import net.sourceforge.plantuml.ugraphic.AffineTransformType; import net.sourceforge.plantuml.ugraphic.AffineTransformType;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.ImageParameter;
import net.sourceforge.plantuml.ugraphic.PixelImage; import net.sourceforge.plantuml.ugraphic.PixelImage;
import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UImage; import net.sourceforge.plantuml.ugraphic.UImage;
import net.sourceforge.plantuml.ugraphic.color.ColorMapperIdentity;
import net.sourceforge.plantuml.ugraphic.color.HColor;
import net.sourceforge.plantuml.ugraphic.color.HColorUtils;
public class PSystemDedication extends AbstractPSystem { public class PSystemDedication extends PlainDiagram {
private final Dedication dedication; private final Dedication dedication;
private final String keepLetter; private final String keepLetter;
@ -66,21 +57,15 @@ public class PSystemDedication extends AbstractPSystem {
} }
@Override @Override
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed) protected UDrawable getRootDrawable(FileFormatOption fileFormatOption) {
throws IOException { return new UDrawable() {
HColor backcolor = HColorUtils.WHITE;
final ImageParameter imageParameter = new ImageParameter(new ColorMapperIdentity(), false, null,
getMetadata(), null, ClockwiseTopRightBottomLeft.none(), backcolor);
final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter);
imageBuilder.setUDrawable(new UDrawable() {
public void drawU(UGraphic ug) { public void drawU(UGraphic ug) {
final BufferedImage bufferedImage = dedication.getBufferedImage(keepLetter); final BufferedImage bufferedImage = dedication.getBufferedImage(keepLetter);
if (bufferedImage != null) { if (bufferedImage != null) {
ug.draw(new UImage(new PixelImage(bufferedImage, AffineTransformType.TYPE_BILINEAR))); ug.draw(new UImage(new PixelImage(bufferedImage, AffineTransformType.TYPE_BILINEAR)));
} }
} }
}); };
return imageBuilder.writeImageTOBEMOVED(fileFormat, seed, os);
} }
public DiagramDescription getDescription() { public DiagramDescription getDescription() {

View File

@ -36,28 +36,22 @@
package net.sourceforge.plantuml.definition; package net.sourceforge.plantuml.definition;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import net.sourceforge.plantuml.AbstractPSystem;
import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.PlainDiagram;
import net.sourceforge.plantuml.SpriteContainerEmpty; import net.sourceforge.plantuml.SpriteContainerEmpty;
import net.sourceforge.plantuml.core.DiagramDescription; import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.UDrawable; import net.sourceforge.plantuml.graphic.UDrawable;
import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.ImageParameter;
import net.sourceforge.plantuml.ugraphic.UFont; import net.sourceforge.plantuml.ugraphic.UFont;
import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.color.ColorMapperIdentity;
import net.sourceforge.plantuml.ugraphic.color.HColorUtils; import net.sourceforge.plantuml.ugraphic.color.HColorUtils;
public class PSystemDefinition extends AbstractPSystem implements UDrawable { public class PSystemDefinition extends PlainDiagram implements UDrawable {
private final List<String> lines = new ArrayList<String>(); private final List<String> lines = new ArrayList<String>();
private final String startLine; private final String startLine;
@ -71,14 +65,8 @@ public class PSystemDefinition extends AbstractPSystem implements UDrawable {
} }
@Override @Override
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormatOption, long seed) protected UDrawable getRootDrawable(FileFormatOption fileFormatOption) throws IOException {
throws IOException { return this;
final ImageParameter imageParameter = new ImageParameter(new ColorMapperIdentity(), false, null, "", "",
ClockwiseTopRightBottomLeft.none(), null);
final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter);
imageBuilder.setUDrawable(this);
return imageBuilder.writeImageTOBEMOVED(fileFormatOption, seed, os);
} }
public void drawU(UGraphic ug) { public void drawU(UGraphic ug) {

View File

@ -37,15 +37,14 @@ package net.sourceforge.plantuml.donors;
import java.awt.geom.Dimension2D; import java.awt.geom.Dimension2D;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import net.sourceforge.plantuml.AbstractPSystem;
import net.sourceforge.plantuml.BackSlash; import net.sourceforge.plantuml.BackSlash;
import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.PlainDiagram;
import net.sourceforge.plantuml.code.AsciiEncoder; import net.sourceforge.plantuml.code.AsciiEncoder;
import net.sourceforge.plantuml.code.CompressionBrotli; import net.sourceforge.plantuml.code.CompressionBrotli;
import net.sourceforge.plantuml.code.NoPlantumlCompressionException; import net.sourceforge.plantuml.code.NoPlantumlCompressionException;
@ -53,26 +52,19 @@ import net.sourceforge.plantuml.code.StringCompressorNone;
import net.sourceforge.plantuml.code.Transcoder; import net.sourceforge.plantuml.code.Transcoder;
import net.sourceforge.plantuml.code.TranscoderImpl; import net.sourceforge.plantuml.code.TranscoderImpl;
import net.sourceforge.plantuml.core.DiagramDescription; import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.graphic.GraphicStrings; import net.sourceforge.plantuml.graphic.GraphicStrings;
import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.UDrawable; import net.sourceforge.plantuml.graphic.UDrawable;
import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft;
import net.sourceforge.plantuml.svek.TextBlockBackcolored; import net.sourceforge.plantuml.svek.TextBlockBackcolored;
import net.sourceforge.plantuml.ugraphic.AffineTransformType; import net.sourceforge.plantuml.ugraphic.AffineTransformType;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.ImageParameter;
import net.sourceforge.plantuml.ugraphic.PixelImage; import net.sourceforge.plantuml.ugraphic.PixelImage;
import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UImage; import net.sourceforge.plantuml.ugraphic.UImage;
import net.sourceforge.plantuml.ugraphic.UTranslate; import net.sourceforge.plantuml.ugraphic.UTranslate;
import net.sourceforge.plantuml.ugraphic.color.ColorMapperIdentity;
import net.sourceforge.plantuml.ugraphic.color.HColor;
import net.sourceforge.plantuml.ugraphic.color.HColorUtils;
import net.sourceforge.plantuml.version.PSystemVersion; import net.sourceforge.plantuml.version.PSystemVersion;
public class PSystemDonors extends AbstractPSystem { public class PSystemDonors extends PlainDiagram {
private static final int COLS = 6; private static final int COLS = 6;
private static final int FREE_LINES = 6; private static final int FREE_LINES = 6;
@ -107,18 +99,7 @@ public class PSystemDonors extends AbstractPSystem {
*/ */
@Override @Override
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed) protected UDrawable getRootDrawable(FileFormatOption fileFormatOption) throws IOException {
throws IOException {
final UDrawable result = getGraphicStrings();
HColor backcolor = HColorUtils.WHITE;
final ImageParameter imageParameter = new ImageParameter(new ColorMapperIdentity(), false, null,
getMetadata(), null, ClockwiseTopRightBottomLeft.none(), backcolor);
final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter);
imageBuilder.setUDrawable(result);
return imageBuilder.writeImageTOBEMOVED(fileFormat, seed, os);
}
private UDrawable getGraphicStrings() throws IOException {
final List<TextBlock> cols = getCols(getDonors(), COLS, FREE_LINES); final List<TextBlock> cols = getCols(getDonors(), COLS, FREE_LINES);
return new UDrawable() { return new UDrawable() {
public void drawU(UGraphic ug) { public void drawU(UGraphic ug) {

View File

@ -37,43 +37,24 @@ package net.sourceforge.plantuml.donors;
import java.awt.geom.Dimension2D; import java.awt.geom.Dimension2D;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import net.sourceforge.plantuml.AbstractPSystem;
import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.PlainDiagram;
import net.sourceforge.plantuml.SkinParam; import net.sourceforge.plantuml.SkinParam;
import net.sourceforge.plantuml.core.DiagramDescription; import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.graphic.GraphicStrings; import net.sourceforge.plantuml.graphic.GraphicStrings;
import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.UDrawable; import net.sourceforge.plantuml.graphic.UDrawable;
import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.ImageParameter;
import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UTranslate; import net.sourceforge.plantuml.ugraphic.UTranslate;
import net.sourceforge.plantuml.ugraphic.color.ColorMapperIdentity;
import net.sourceforge.plantuml.ugraphic.color.HColor;
import net.sourceforge.plantuml.ugraphic.color.HColorUtils;
public class PSystemSkinparameterList extends AbstractPSystem { public class PSystemSkinparameterList extends PlainDiagram {
@Override @Override
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed) protected UDrawable getRootDrawable(FileFormatOption fileFormatOption) throws IOException {
throws IOException {
final UDrawable result = getGraphicStrings();
HColor backcolor = HColorUtils.WHITE;
final ImageParameter imageParameter = new ImageParameter(new ColorMapperIdentity(), false, null,
getMetadata(), null, ClockwiseTopRightBottomLeft.none(), backcolor);
final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter);
imageBuilder.setUDrawable(result);
return imageBuilder.writeImageTOBEMOVED(fileFormat, seed, os);
}
private UDrawable getGraphicStrings() throws IOException {
final List<TextBlock> cols = getCols(getDonors(), 5); final List<TextBlock> cols = getCols(getDonors(), 5);
return new UDrawable() { return new UDrawable() {
public void drawU(UGraphic ug) { public void drawU(UGraphic ug) {

View File

@ -35,58 +35,21 @@
*/ */
package net.sourceforge.plantuml.eggs; package net.sourceforge.plantuml.eggs;
import java.awt.image.BufferedImage;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
import net.sourceforge.plantuml.AbstractPSystem; import net.sourceforge.plantuml.PlainStringsDiagram;
import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.core.DiagramDescription; import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.graphic.GraphicPosition; import net.sourceforge.plantuml.graphic.GraphicPosition;
import net.sourceforge.plantuml.graphic.GraphicStrings;
import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft;
import net.sourceforge.plantuml.svek.TextBlockBackcolored;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.ImageParameter;
import net.sourceforge.plantuml.ugraphic.color.ColorMapperIdentity;
import net.sourceforge.plantuml.ugraphic.color.HColor;
import net.sourceforge.plantuml.version.PSystemVersion; import net.sourceforge.plantuml.version.PSystemVersion;
public class PSystemAppleTwo extends AbstractPSystem { public class PSystemAppleTwo extends PlainStringsDiagram {
private final List<String> strings = new ArrayList<String>();
private final BufferedImage image;
public PSystemAppleTwo() throws IOException { public PSystemAppleTwo() throws IOException {
strings.add(" <b><size:18>Apple //e for ever ! "); strings.add(" <b><size:18>Apple //e for ever ! ");
strings.add(" "); strings.add(" ");
image = PSystemVersion.getApple2Image(); image = PSystemVersion.getApple2Image();
} imagePosition = GraphicPosition.BOTTOM;
@Override
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed)
throws IOException {
final TextBlockBackcolored result = getGraphicStrings();
HColor backcolor = result.getBackcolor();
final ImageParameter imageParameter = new ImageParameter(new ColorMapperIdentity(), false, null,
getMetadata(), null, ClockwiseTopRightBottomLeft.none(), backcolor);
final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter);
imageBuilder.setUDrawable(result);
return imageBuilder.writeImageTOBEMOVED(fileFormat, seed, os);
}
private TextBlockBackcolored getGraphicStrings() throws IOException {
// final UFont font = new UFont("SansSerif", Font.PLAIN, 12);
final TextBlockBackcolored result = GraphicStrings.createBlackOnWhite(strings, image, GraphicPosition.BOTTOM);
// final GraphicStrings result = new GraphicStrings(strings, font,
// HtmlColorUtils.BLACK, HtmlColorUtils.WHITE,
// image, GraphicPosition.BOTTOM);
// result.setMinWidth(200);
return result;
} }
public DiagramDescription getDescription() { public DiagramDescription getDescription() {

View File

@ -35,27 +35,19 @@
package net.sourceforge.plantuml.eggs; package net.sourceforge.plantuml.eggs;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.OutputStream;
import net.sourceforge.plantuml.AbstractPSystem;
import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.PlainDiagram;
import net.sourceforge.plantuml.core.DiagramDescription; import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.graphic.UDrawable; import net.sourceforge.plantuml.graphic.UDrawable;
import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft;
import net.sourceforge.plantuml.ugraphic.AffineTransformType; import net.sourceforge.plantuml.ugraphic.AffineTransformType;
import net.sourceforge.plantuml.ugraphic.ImageBuilder; import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.ImageParameter;
import net.sourceforge.plantuml.ugraphic.PixelImage; import net.sourceforge.plantuml.ugraphic.PixelImage;
import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UImage; import net.sourceforge.plantuml.ugraphic.UImage;
import net.sourceforge.plantuml.ugraphic.color.ColorMapperIdentity;
import net.sourceforge.plantuml.ugraphic.color.HColor;
import net.sourceforge.plantuml.ugraphic.color.HColorUtils;
import net.sourceforge.plantuml.version.PSystemVersion; import net.sourceforge.plantuml.version.PSystemVersion;
public class PSystemCharlie extends AbstractPSystem { public class PSystemCharlie extends PlainDiagram {
private BufferedImage image; private BufferedImage image;
@ -64,20 +56,18 @@ public class PSystemCharlie extends AbstractPSystem {
} }
@Override @Override
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed) protected ImageBuilder adjustImageBuilder(ImageBuilder builder) {
throws IOException { return builder.blackBackcolor();
HColor backcolor = HColorUtils.BLACK; }
final ImageParameter imageParameter = new ImageParameter(new ColorMapperIdentity(), false, null,
getMetadata(), null, ClockwiseTopRightBottomLeft.none(), backcolor);
final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter);
imageBuilder.setUDrawable(new UDrawable() {
@Override
public UDrawable getRootDrawable(FileFormatOption fileFormatOption) {
return new UDrawable() {
public void drawU(UGraphic ug) { public void drawU(UGraphic ug) {
final UImage im = new UImage(new PixelImage(image, AffineTransformType.TYPE_BILINEAR)); final UImage im = new UImage(new PixelImage(image, AffineTransformType.TYPE_BILINEAR));
ug.draw(im); ug.draw(im);
} }
}); };
return imageBuilder.writeImageTOBEMOVED(fileFormat, seed, os);
} }
public DiagramDescription getDescription() { public DiagramDescription getDescription() {

View File

@ -37,8 +37,6 @@ package net.sourceforge.plantuml.eggs;
import java.awt.geom.Dimension2D; import java.awt.geom.Dimension2D;
import java.awt.geom.Point2D; import java.awt.geom.Point2D;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
@ -46,34 +44,29 @@ import java.util.Comparator;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import net.sourceforge.plantuml.AbstractPSystem;
import net.sourceforge.plantuml.BackSlash; import net.sourceforge.plantuml.BackSlash;
import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.PlainDiagram;
import net.sourceforge.plantuml.SpriteContainerEmpty; import net.sourceforge.plantuml.SpriteContainerEmpty;
import net.sourceforge.plantuml.core.DiagramDescription; import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.UDrawable; import net.sourceforge.plantuml.graphic.UDrawable;
import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.ImageParameter;
import net.sourceforge.plantuml.ugraphic.UFont; import net.sourceforge.plantuml.ugraphic.UFont;
import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UPolygon; import net.sourceforge.plantuml.ugraphic.UPolygon;
import net.sourceforge.plantuml.ugraphic.URectangle; import net.sourceforge.plantuml.ugraphic.URectangle;
import net.sourceforge.plantuml.ugraphic.UTranslate; import net.sourceforge.plantuml.ugraphic.UTranslate;
import net.sourceforge.plantuml.ugraphic.color.ColorMapperIdentity;
import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColor;
import net.sourceforge.plantuml.ugraphic.color.HColorSet; import net.sourceforge.plantuml.ugraphic.color.HColorSet;
import net.sourceforge.plantuml.ugraphic.color.HColorSimple; import net.sourceforge.plantuml.ugraphic.color.HColorSimple;
import net.sourceforge.plantuml.ugraphic.color.HColorUtils; import net.sourceforge.plantuml.ugraphic.color.HColorUtils;
// http://www.redblobgames.com/grids/hexagons/ // http://www.redblobgames.com/grids/hexagons/
public class PSystemColors extends AbstractPSystem implements UDrawable { public class PSystemColors extends PlainDiagram implements UDrawable {
private final double rectangleHeight = 28; private final double rectangleHeight = 28;
private final double rectangleWidth = 175; private final double rectangleWidth = 175;
@ -90,14 +83,8 @@ public class PSystemColors extends AbstractPSystem implements UDrawable {
} }
@Override @Override
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed) protected UDrawable getRootDrawable(FileFormatOption fileFormatOption) {
throws IOException { return this;
HColor backcolor = HColorUtils.WHITE;
final ImageParameter imageParameter = new ImageParameter(new ColorMapperIdentity(), false, null,
getMetadata(), null, ClockwiseTopRightBottomLeft.none(), backcolor);
final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter);
imageBuilder.setUDrawable(this);
return imageBuilder.writeImageTOBEMOVED(fileFormat, seed, os);
} }
public DiagramDescription getDescription() { public DiagramDescription getDescription() {

View File

@ -5,12 +5,12 @@
* (C) Copyright 2009-2020, Arnaud Roques * (C) Copyright 2009-2020, Arnaud Roques
* *
* Project Info: http://plantuml.com * Project Info: http://plantuml.com
* *
* If you like this project or if you find it useful, you can support us at: * 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/patreon (only 1$ per month!)
* http://plantuml.com/paypal * http://plantuml.com/paypal
* *
* This file is part of PlantUML. * This file is part of PlantUML.
* *
* PlantUML is free software; you can redistribute it and/or modify it * PlantUML is free software; you can redistribute it and/or modify it
@ -30,32 +30,17 @@
* *
* *
* Original Author: Arnaud Roques * Original Author: Arnaud Roques
* *
* *
*/ */
package net.sourceforge.plantuml.eggs; package net.sourceforge.plantuml.eggs;
import java.io.IOException; import net.sourceforge.plantuml.PlainStringsDiagram;
import java.io.OutputStream; import net.sourceforge.plantuml.core.DiagramDescription;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import net.sourceforge.plantuml.AbstractPSystem; public class PSystemEgg extends PlainStringsDiagram {
import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.graphic.GraphicStrings;
import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft;
import net.sourceforge.plantuml.svek.TextBlockBackcolored;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.ImageParameter;
import net.sourceforge.plantuml.ugraphic.color.ColorMapperIdentity;
import net.sourceforge.plantuml.ugraphic.color.HColor;
public class PSystemEgg extends AbstractPSystem {
private final List<String> strings = new ArrayList<String>();
PSystemEgg(String sentence) { PSystemEgg(String sentence) {
final StringTokenizer st = new StringTokenizer(sentence, "|"); final StringTokenizer st = new StringTokenizer(sentence, "|");
@ -64,22 +49,6 @@ public class PSystemEgg extends AbstractPSystem {
} }
} }
@Override
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed)
throws IOException {
final TextBlockBackcolored result = getGraphicStrings();
HColor backcolor = result.getBackcolor();
final ImageParameter imageParameter = new ImageParameter(new ColorMapperIdentity(), false, null,
getMetadata(), null, ClockwiseTopRightBottomLeft.none(), backcolor);
final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter);
imageBuilder.setUDrawable(result);
return imageBuilder.writeImageTOBEMOVED(fileFormat, seed, os);
}
private TextBlockBackcolored getGraphicStrings() throws IOException {
return GraphicStrings.createBlackOnWhite(strings);
}
public DiagramDescription getDescription() { public DiagramDescription getDescription() {
return new DiagramDescription("(Easter Eggs)"); return new DiagramDescription("(Easter Eggs)");
} }

View File

@ -35,47 +35,15 @@
*/ */
package net.sourceforge.plantuml.eggs; package net.sourceforge.plantuml.eggs;
import java.io.IOException; import net.sourceforge.plantuml.PlainStringsDiagram;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
import net.sourceforge.plantuml.AbstractPSystem;
import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.core.DiagramDescription; import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.graphic.GraphicStrings;
import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft;
import net.sourceforge.plantuml.svek.TextBlockBackcolored;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.ImageParameter;
import net.sourceforge.plantuml.ugraphic.color.ColorMapperIdentity;
import net.sourceforge.plantuml.ugraphic.color.HColor;
public class PSystemLost extends AbstractPSystem { public class PSystemLost extends PlainStringsDiagram {
private final List<String> strings = new ArrayList<String>();
public PSystemLost() { public PSystemLost() {
strings.add("Thank you for choosing Oceanic Airlines."); strings.add("Thank you for choosing Oceanic Airlines.");
} }
@Override
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed)
throws IOException {
final TextBlockBackcolored result = getGraphicStrings();
HColor backcolor = result.getBackcolor();
final ImageParameter imageParameter = new ImageParameter(new ColorMapperIdentity(), false, null,
getMetadata(), null, ClockwiseTopRightBottomLeft.none(), backcolor);
final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter);
imageBuilder.setUDrawable(result);
return imageBuilder.writeImageTOBEMOVED(fileFormat, seed, os);
}
private TextBlockBackcolored getGraphicStrings() throws IOException {
return GraphicStrings.createBlackOnWhite(strings);
}
public DiagramDescription getDescription() { public DiagramDescription getDescription() {
return new DiagramDescription("(Lost)"); return new DiagramDescription("(Lost)");
} }

View File

@ -35,32 +35,16 @@
*/ */
package net.sourceforge.plantuml.eggs; package net.sourceforge.plantuml.eggs;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
import net.sourceforge.plantuml.AbstractPSystem; import net.sourceforge.plantuml.PlainStringsDiagram;
import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.core.DiagramDescription; import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.graphic.GraphicPosition; import net.sourceforge.plantuml.graphic.GraphicPosition;
import net.sourceforge.plantuml.graphic.GraphicStrings;
import net.sourceforge.plantuml.security.ImageIO; import net.sourceforge.plantuml.security.ImageIO;
import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft;
import net.sourceforge.plantuml.svek.TextBlockBackcolored;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.ImageParameter;
import net.sourceforge.plantuml.ugraphic.color.ColorMapperIdentity;
import net.sourceforge.plantuml.ugraphic.color.HColor;
public class PSystemRIP extends AbstractPSystem { public class PSystemRIP extends PlainStringsDiagram {
private final List<String> strings = new ArrayList<String>();
private final BufferedImage image;
public PSystemRIP() throws IOException { public PSystemRIP() throws IOException {
strings.add(" To my Grandfather,"); strings.add(" To my Grandfather,");
@ -77,22 +61,8 @@ public class PSystemRIP extends AbstractPSystem {
final InputStream is = new ByteArrayInputStream(imm); final InputStream is = new ByteArrayInputStream(imm);
image = ImageIO.read(is); image = ImageIO.read(is);
is.close(); is.close();
}
@Override imagePosition = GraphicPosition.BOTTOM;
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed)
throws IOException {
final TextBlockBackcolored result = getGraphicStrings();
HColor backcolor = result.getBackcolor();
final ImageParameter imageParameter = new ImageParameter(new ColorMapperIdentity(), false, null,
getMetadata(), null, ClockwiseTopRightBottomLeft.none(), backcolor);
final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter);
imageBuilder.setUDrawable(result);
return imageBuilder.writeImageTOBEMOVED(fileFormat, seed, os);
}
private TextBlockBackcolored getGraphicStrings() throws IOException {
return GraphicStrings.createBlackOnWhite(strings, image, GraphicPosition.BOTTOM);
} }
public DiagramDescription getDescription() { public DiagramDescription getDescription() {

View File

@ -36,25 +36,19 @@
package net.sourceforge.plantuml.eggs; package net.sourceforge.plantuml.eggs;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import net.sourceforge.plantuml.AbstractPSystem;
import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.PlainDiagram;
import net.sourceforge.plantuml.core.DiagramDescription; import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.graphic.GraphicPosition; import net.sourceforge.plantuml.graphic.GraphicPosition;
import net.sourceforge.plantuml.graphic.GraphicStrings; import net.sourceforge.plantuml.graphic.GraphicStrings;
import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft; import net.sourceforge.plantuml.graphic.UDrawable;
import net.sourceforge.plantuml.svek.TextBlockBackcolored; import net.sourceforge.plantuml.svek.TextBlockBackcolored;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.ImageParameter;
import net.sourceforge.plantuml.ugraphic.color.ColorMapperIdentity;
import net.sourceforge.plantuml.ugraphic.color.HColor;
import net.sourceforge.plantuml.version.PSystemVersion; import net.sourceforge.plantuml.version.PSystemVersion;
public class PSystemWelcome extends AbstractPSystem { public class PSystemWelcome extends PlainDiagram {
private final List<String> strings = new ArrayList<String>(); private final List<String> strings = new ArrayList<String>();
private final GraphicPosition position; private final GraphicPosition position;
@ -85,16 +79,8 @@ public class PSystemWelcome extends AbstractPSystem {
} }
@Override @Override
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed) protected UDrawable getRootDrawable(FileFormatOption fileFormatOption) throws IOException {
throws IOException { return getGraphicStrings();
final TextBlockBackcolored result = getGraphicStrings();
HColor backcolor = result.getBackcolor();
final ImageParameter imageParameter = new ImageParameter(new ColorMapperIdentity(), false, null,
getMetadata(), null, ClockwiseTopRightBottomLeft.none(), backcolor);
final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter);
imageBuilder.setUDrawable(result);
// imageBuilder.setUDrawable(TextBlockUtils.withMargin(result, 4, 4));
return imageBuilder.writeImageTOBEMOVED(fileFormat, seed, os);
} }
public TextBlockBackcolored getGraphicStrings() throws IOException { public TextBlockBackcolored getGraphicStrings() throws IOException {

View File

@ -46,7 +46,6 @@ import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import net.sourceforge.plantuml.AbstractPSystem;
import net.sourceforge.plantuml.BackSlash; import net.sourceforge.plantuml.BackSlash;
import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.Dimension2DDouble;
import net.sourceforge.plantuml.ErrorUml; import net.sourceforge.plantuml.ErrorUml;
@ -54,9 +53,9 @@ import net.sourceforge.plantuml.FileFormat;
import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.FileImageData; import net.sourceforge.plantuml.FileImageData;
import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.LineLocation;
import net.sourceforge.plantuml.PlainDiagram;
import net.sourceforge.plantuml.SpriteContainerEmpty; import net.sourceforge.plantuml.SpriteContainerEmpty;
import net.sourceforge.plantuml.StringLocated; import net.sourceforge.plantuml.StringLocated;
import net.sourceforge.plantuml.api.ImageDataAbstract;
import net.sourceforge.plantuml.api.ImageDataSimple; import net.sourceforge.plantuml.api.ImageDataSimple;
import net.sourceforge.plantuml.asciiart.UmlCharArea; import net.sourceforge.plantuml.asciiart.UmlCharArea;
import net.sourceforge.plantuml.core.DiagramDescription; import net.sourceforge.plantuml.core.DiagramDescription;
@ -74,21 +73,19 @@ import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.TextBlockRaw; import net.sourceforge.plantuml.graphic.TextBlockRaw;
import net.sourceforge.plantuml.graphic.TextBlockUtils; import net.sourceforge.plantuml.graphic.TextBlockUtils;
import net.sourceforge.plantuml.graphic.UDrawable;
import net.sourceforge.plantuml.graphic.VerticalAlignment; import net.sourceforge.plantuml.graphic.VerticalAlignment;
import net.sourceforge.plantuml.security.SecurityUtils; import net.sourceforge.plantuml.security.SecurityUtils;
import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft;
import net.sourceforge.plantuml.svek.GraphvizCrash; import net.sourceforge.plantuml.svek.GraphvizCrash;
import net.sourceforge.plantuml.svek.TextBlockBackcolored; import net.sourceforge.plantuml.svek.TextBlockBackcolored;
import net.sourceforge.plantuml.ugraphic.AffineTransformType; import net.sourceforge.plantuml.ugraphic.AffineTransformType;
import net.sourceforge.plantuml.ugraphic.ImageBuilder; import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.ImageParameter;
import net.sourceforge.plantuml.ugraphic.MinMax; import net.sourceforge.plantuml.ugraphic.MinMax;
import net.sourceforge.plantuml.ugraphic.PixelImage; import net.sourceforge.plantuml.ugraphic.PixelImage;
import net.sourceforge.plantuml.ugraphic.UFont; import net.sourceforge.plantuml.ugraphic.UFont;
import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UImage; import net.sourceforge.plantuml.ugraphic.UImage;
import net.sourceforge.plantuml.ugraphic.UTranslate; import net.sourceforge.plantuml.ugraphic.UTranslate;
import net.sourceforge.plantuml.ugraphic.color.ColorMapperIdentity;
import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColor;
import net.sourceforge.plantuml.ugraphic.color.HColorSet; import net.sourceforge.plantuml.ugraphic.color.HColorSet;
import net.sourceforge.plantuml.ugraphic.color.HColorSimple; import net.sourceforge.plantuml.ugraphic.color.HColorSimple;
@ -98,11 +95,19 @@ import net.sourceforge.plantuml.version.LicenseInfo;
import net.sourceforge.plantuml.version.PSystemVersion; import net.sourceforge.plantuml.version.PSystemVersion;
import net.sourceforge.plantuml.version.Version; import net.sourceforge.plantuml.version.Version;
public abstract class PSystemError extends AbstractPSystem { public abstract class PSystemError extends PlainDiagram {
protected List<StringLocated> trace; protected List<StringLocated> trace;
protected ErrorUml singleError; protected ErrorUml singleError;
@Override
protected ImageBuilder adjustImageBuilder(ImageBuilder builder) {
return builder
.blackBackcolor()
.randomPixel()
.status(FileImageData.ERROR);
}
final protected StringLocated getLastLine() { final protected StringLocated getLastLine() {
return trace.get(trace.size() - 1); return trace.get(trace.size() - 1);
} }
@ -227,14 +232,14 @@ public abstract class PSystemError extends AbstractPSystem {
return new ImageDataSimple(1, 1); return new ImageDataSimple(1, 1);
} }
return super.exportDiagramNow(os, num, fileFormat, seed);
}
@Override
protected UDrawable getRootDrawable(FileFormatOption fileFormatOption) throws IOException {
final TextBlockBackcolored result = getGraphicalFormatted(); final TextBlockBackcolored result = getGraphicalFormatted();
TextBlock udrawable; TextBlock udrawable;
HColor backcolor = result.getBackcolor();
final ImageParameter imageParameter = new ImageParameter(new ColorMapperIdentity(), false, null,
getMetadata(), null, ClockwiseTopRightBottomLeft.none(), backcolor);
final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter);
imageBuilder.setRandomPixel(true);
if (getSource().getTotalLineCountLessThan5()) { if (getSource().getTotalLineCountLessThan5()) {
udrawable = addWelcome(result); udrawable = addWelcome(result);
} else { } else {
@ -251,10 +256,7 @@ public abstract class PSystemError extends AbstractPSystem {
} else if (getSource().containsIgnoreCase("arecibo")) { } else if (getSource().containsIgnoreCase("arecibo")) {
udrawable = addMessageArecibo(udrawable); udrawable = addMessageArecibo(udrawable);
} }
imageBuilder.setUDrawable(udrawable); return udrawable;
final ImageData imageData = imageBuilder.writeImageTOBEMOVED(fileFormat, seed(), os);
((ImageDataAbstract) imageData).setStatus(FileImageData.ERROR);
return imageData;
} }
private void append(List<String> result, LineLocation lineLocation) { private void append(List<String> result, LineLocation lineLocation) {

View File

@ -36,26 +36,12 @@
package net.sourceforge.plantuml.font; package net.sourceforge.plantuml.font;
import java.awt.GraphicsEnvironment; import java.awt.GraphicsEnvironment;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
import net.sourceforge.plantuml.AbstractPSystem; import net.sourceforge.plantuml.PlainStringsDiagram;
import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.core.DiagramDescription; import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.graphic.GraphicStrings;
import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft;
import net.sourceforge.plantuml.svek.TextBlockBackcolored;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.ImageParameter;
import net.sourceforge.plantuml.ugraphic.color.ColorMapperIdentity;
import net.sourceforge.plantuml.ugraphic.color.HColor;
public class PSystemListFonts extends AbstractPSystem {
private final List<String> strings = new ArrayList<String>(); public class PSystemListFonts extends PlainStringsDiagram {
public PSystemListFonts(String text) { public PSystemListFonts(String text) {
strings.add(" <b><size:16>Fonts available:"); strings.add(" <b><size:16>Fonts available:");
@ -74,22 +60,6 @@ public class PSystemListFonts extends AbstractPSystem {
} }
@Override
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed)
throws IOException {
final TextBlockBackcolored result = getGraphicStrings();
HColor backcolor = result.getBackcolor();
final ImageParameter imageParameter = new ImageParameter(new ColorMapperIdentity(), false, null,
getMetadata(), null, ClockwiseTopRightBottomLeft.none(), backcolor);
final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter);
imageBuilder.setUDrawable(result);
return imageBuilder.writeImageTOBEMOVED(fileFormat, seed, os);
}
private TextBlockBackcolored getGraphicStrings() throws IOException {
return GraphicStrings.createBlackOnWhite(strings);
}
public DiagramDescription getDescription() { public DiagramDescription getDescription() {
return new DiagramDescription("(List fonts)"); return new DiagramDescription("(List fonts)");
} }

View File

@ -40,23 +40,20 @@ import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.Collection; import java.util.Collection;
import net.sourceforge.plantuml.AnnotatedWorker;
import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.UmlDiagram; import net.sourceforge.plantuml.UmlDiagram;
import net.sourceforge.plantuml.UmlDiagramType; import net.sourceforge.plantuml.UmlDiagramType;
import net.sourceforge.plantuml.core.DiagramDescription; import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.ImageData; import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.graphic.InnerStrategy; import net.sourceforge.plantuml.graphic.InnerStrategy;
import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.svek.TextBlockBackcolored; import net.sourceforge.plantuml.svek.TextBlockBackcolored;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.ImageParameter;
import net.sourceforge.plantuml.ugraphic.MinMax; import net.sourceforge.plantuml.ugraphic.MinMax;
import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColor;
import static net.sourceforge.plantuml.ugraphic.ImageBuilder.styledImageBuilder;
public class GitDiagram extends UmlDiagram { public class GitDiagram extends UmlDiagram {
private final Collection<GNode> gnodes; private final Collection<GNode> gnodes;
@ -76,15 +73,8 @@ public class GitDiagram extends UmlDiagram {
protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption) protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
throws IOException { throws IOException {
final ISkinParam skinParam = getSkinParam(); return styledImageBuilder(this, getTextBlock(), index, fileFormatOption, 0)
final ImageParameter imageParameter = new ImageParameter(this, fileFormatOption); .write(os);
final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter);
TextBlock result = getTextBlock();
result = new AnnotatedWorker(this, skinParam, fileFormatOption.getDefaultStringBounder(getSkinParam()))
.addAdd(result);
imageBuilder.setUDrawable(result);
return imageBuilder.writeImageTOBEMOVED(fileFormatOption, 0, os);
} }
private void drawInternal(UGraphic ug) { private void drawInternal(UGraphic ug) {

View File

@ -53,10 +53,9 @@ import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft; import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.ImageParameter;
import net.sourceforge.plantuml.ugraphic.UFont; import net.sourceforge.plantuml.ugraphic.UFont;
import net.sourceforge.plantuml.ugraphic.color.ColorMapperIdentity;
import static net.sourceforge.plantuml.ugraphic.ImageBuilder.styledImageBuilder;
public class Help extends UmlDiagram { public class Help extends UmlDiagram {
@ -79,16 +78,18 @@ public class Help extends UmlDiagram {
final Sheet sheet = Parser.build(fontConfiguration, HorizontalAlignment.LEFT, getSkinParam(), CreoleMode.FULL) final Sheet sheet = Parser.build(fontConfiguration, HorizontalAlignment.LEFT, getSkinParam(), CreoleMode.FULL)
.createSheet(display); .createSheet(display);
final SheetBlock1 sheetBlock = new SheetBlock1(sheet, LineBreakStrategy.NONE, 0); final SheetBlock1 sheetBlock = new SheetBlock1(sheet, LineBreakStrategy.NONE, 0);
final ImageParameter imageParameter = new ImageParameter(new ColorMapperIdentity(), false, null, null, return styledImageBuilder(this, sheetBlock, 1, fileFormat, 0)
null, ClockwiseTopRightBottomLeft.none(), null); .annotations(false)
.write(os);
final ImageBuilder builder = ImageBuilder.build(imageParameter);
builder.setUDrawable(sheetBlock);
return builder.writeImageTOBEMOVED(fileFormat, 0, os);
} }
public void add(CharSequence line) { public void add(CharSequence line) {
this.lines.add(line); this.lines.add(line);
} }
@Override
public ClockwiseTopRightBottomLeft getDefaultMargins() {
return ClockwiseTopRightBottomLeft.same(0);
}
} }

View File

@ -40,9 +40,7 @@ import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.List; import java.util.List;
import net.sourceforge.plantuml.AnnotatedWorker;
import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.TitledDiagram; import net.sourceforge.plantuml.TitledDiagram;
import net.sourceforge.plantuml.UmlDiagramType; import net.sourceforge.plantuml.UmlDiagramType;
import net.sourceforge.plantuml.core.DiagramDescription; import net.sourceforge.plantuml.core.DiagramDescription;
@ -57,13 +55,13 @@ import net.sourceforge.plantuml.graphic.TextBlockUtils;
import net.sourceforge.plantuml.json.JsonArray; import net.sourceforge.plantuml.json.JsonArray;
import net.sourceforge.plantuml.json.JsonValue; import net.sourceforge.plantuml.json.JsonValue;
import net.sourceforge.plantuml.svek.TextBlockBackcolored; import net.sourceforge.plantuml.svek.TextBlockBackcolored;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.ImageParameter;
import net.sourceforge.plantuml.ugraphic.MinMax; import net.sourceforge.plantuml.ugraphic.MinMax;
import net.sourceforge.plantuml.ugraphic.UFont; import net.sourceforge.plantuml.ugraphic.UFont;
import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColor;
import static net.sourceforge.plantuml.ugraphic.ImageBuilder.styledImageBuilder;
public class JsonDiagram extends TitledDiagram { public class JsonDiagram extends TitledDiagram {
private final JsonValue root; private final JsonValue root;
@ -91,15 +89,8 @@ public class JsonDiagram extends TitledDiagram {
protected ImageData exportDiagramNow(OutputStream os, int index, FileFormatOption fileFormatOption, long seed) protected ImageData exportDiagramNow(OutputStream os, int index, FileFormatOption fileFormatOption, long seed)
throws IOException { throws IOException {
final ISkinParam skinParam = getSkinParam(); return styledImageBuilder(this, getTextBlock(), index, fileFormatOption, 0)
final ImageParameter imageParameter = new ImageParameter(this, fileFormatOption); .write(os);
final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter);
TextBlock result = getTextBlock();
result = new AnnotatedWorker(this, skinParam, fileFormatOption.getDefaultStringBounder(getSkinParam()))
.addAdd(result);
imageBuilder.setUDrawable(result);
return imageBuilder.writeImageTOBEMOVED(0, os);
} }
private void drawInternal(UGraphic ug) { private void drawInternal(UGraphic ug) {

View File

@ -50,16 +50,15 @@ import net.sourceforge.plantuml.api.ImageDataSimple;
import net.sourceforge.plantuml.core.ImageData; import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.eps.EpsGraphics; import net.sourceforge.plantuml.eps.EpsGraphics;
import net.sourceforge.plantuml.graphic.GraphicStrings; import net.sourceforge.plantuml.graphic.GraphicStrings;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.security.ImageIO; import net.sourceforge.plantuml.security.ImageIO;
import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft; import net.sourceforge.plantuml.svek.TextBlockBackcolored;
import net.sourceforge.plantuml.ugraphic.AffineTransformType; import net.sourceforge.plantuml.ugraphic.AffineTransformType;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.ImageParameter;
import net.sourceforge.plantuml.ugraphic.MutableImage; import net.sourceforge.plantuml.ugraphic.MutableImage;
import net.sourceforge.plantuml.ugraphic.PixelImage; import net.sourceforge.plantuml.ugraphic.PixelImage;
import net.sourceforge.plantuml.ugraphic.UImageSvg; import net.sourceforge.plantuml.ugraphic.UImageSvg;
import net.sourceforge.plantuml.ugraphic.color.ColorMapperIdentity;
import static net.sourceforge.plantuml.ugraphic.ImageBuilder.plainImageBuilder;
import static net.sourceforge.plantuml.ugraphic.ImageBuilder.plainPngBuilder;
public class ScientificEquationSafe { public class ScientificEquationSafe {
@ -100,10 +99,10 @@ public class ScientificEquationSafe {
return svg; return svg;
} catch (Exception e) { } catch (Exception e) {
printTrace(e); printTrace(e);
final ImageBuilder imageBuilder = getRollback();
final ByteArrayOutputStream baos = new ByteArrayOutputStream(); final ByteArrayOutputStream baos = new ByteArrayOutputStream();
try { try {
dimSvg = imageBuilder.writeImageTOBEMOVED(new FileFormatOption(FileFormat.SVG), 42, baos); dimSvg = plainImageBuilder(getRollback(), new FileFormatOption(FileFormat.SVG), 42)
.write(baos);
} catch (IOException e1) { } catch (IOException e1) {
return null; return null;
} }
@ -116,11 +115,9 @@ public class ScientificEquationSafe {
return equation.getImage(foregroundColor, backgroundColor); return equation.getImage(foregroundColor, backgroundColor);
} catch (Exception e) { } catch (Exception e) {
printTrace(e); printTrace(e);
final ImageBuilder imageBuilder = getRollback();
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
try { try {
imageBuilder.writeImageTOBEMOVED(new FileFormatOption(FileFormat.PNG), 42, baos); final byte[] bytes = plainPngBuilder(getRollback()).writeByteArray();
return new PixelImage(ImageIO.read(new ByteArrayInputStream(baos.toByteArray())), return new PixelImage(ImageIO.read(new ByteArrayInputStream(bytes)),
AffineTransformType.TYPE_BILINEAR); AffineTransformType.TYPE_BILINEAR);
} catch (IOException e1) { } catch (IOException e1) {
return null; return null;
@ -136,13 +133,8 @@ public class ScientificEquationSafe {
e.printStackTrace(); e.printStackTrace();
} }
private ImageBuilder getRollback() { private TextBlockBackcolored getRollback() {
final TextBlock block = GraphicStrings.createBlackOnWhiteMonospaced(Arrays.asList(formula)); return GraphicStrings.createBlackOnWhiteMonospaced(Arrays.asList(formula));
final ImageParameter imageParameter = new ImageParameter(new ColorMapperIdentity(), false, null, null,
null, ClockwiseTopRightBottomLeft.none(), null);
final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter);
imageBuilder.setUDrawable(block);
return imageBuilder;
} }
public ImageData export(OutputStream os, FileFormatOption fileFormat, float scale, Color foregroundColor, public ImageData export(OutputStream os, FileFormatOption fileFormat, float scale, Color foregroundColor,

View File

@ -40,7 +40,6 @@ import java.awt.geom.Rectangle2D;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import net.sourceforge.plantuml.AnnotatedWorker;
import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.Dimension2DDouble;
import net.sourceforge.plantuml.Direction; import net.sourceforge.plantuml.Direction;
import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.FileFormatOption;
@ -52,17 +51,16 @@ import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.graphic.InnerStrategy; import net.sourceforge.plantuml.graphic.InnerStrategy;
import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.style.NoStyleAvailableException; import net.sourceforge.plantuml.style.NoStyleAvailableException;
import net.sourceforge.plantuml.style.StyleBuilder; import net.sourceforge.plantuml.style.StyleBuilder;
import net.sourceforge.plantuml.svek.TextBlockBackcolored; import net.sourceforge.plantuml.svek.TextBlockBackcolored;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.ImageParameter;
import net.sourceforge.plantuml.ugraphic.MinMax; import net.sourceforge.plantuml.ugraphic.MinMax;
import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UTranslate; import net.sourceforge.plantuml.ugraphic.UTranslate;
import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColor;
import static net.sourceforge.plantuml.ugraphic.ImageBuilder.styledImageBuilder;
public class MindMapDiagram extends UmlDiagram { public class MindMapDiagram extends UmlDiagram {
private Branch left = new Branch(); private Branch left = new Branch();
@ -86,15 +84,8 @@ public class MindMapDiagram extends UmlDiagram {
protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption) protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
throws IOException { throws IOException {
final ImageParameter imageParameter = new ImageParameter(this, fileFormatOption); return styledImageBuilder(this, getTextBlock(), index, fileFormatOption, seed())
final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter); .write(os);
TextBlock result = getTextBlock();
result = new AnnotatedWorker(this, getSkinParam(), fileFormatOption.getDefaultStringBounder(getSkinParam()))
.addAdd(result);
imageBuilder.setUDrawable(result);
return imageBuilder.writeImageTOBEMOVED(seed(), os);
} }
private TextBlockBackcolored getTextBlock() { private TextBlockBackcolored getTextBlock() {

View File

@ -46,10 +46,8 @@ import java.util.Map;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import net.sourceforge.plantuml.AnnotatedWorker;
import net.sourceforge.plantuml.ColorParam; import net.sourceforge.plantuml.ColorParam;
import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.SpriteContainerEmpty; import net.sourceforge.plantuml.SpriteContainerEmpty;
import net.sourceforge.plantuml.UmlDiagram; import net.sourceforge.plantuml.UmlDiagram;
import net.sourceforge.plantuml.UmlDiagramType; import net.sourceforge.plantuml.UmlDiagramType;
@ -66,8 +64,6 @@ import net.sourceforge.plantuml.graphic.TextBlockUtils;
import net.sourceforge.plantuml.graphic.UDrawable; import net.sourceforge.plantuml.graphic.UDrawable;
import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft; import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft;
import net.sourceforge.plantuml.svek.TextBlockBackcolored; import net.sourceforge.plantuml.svek.TextBlockBackcolored;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.ImageParameter;
import net.sourceforge.plantuml.ugraphic.MinMax; import net.sourceforge.plantuml.ugraphic.MinMax;
import net.sourceforge.plantuml.ugraphic.UEmpty; import net.sourceforge.plantuml.ugraphic.UEmpty;
import net.sourceforge.plantuml.ugraphic.UFont; import net.sourceforge.plantuml.ugraphic.UFont;
@ -76,6 +72,8 @@ import net.sourceforge.plantuml.ugraphic.UTranslate;
import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColor;
import net.sourceforge.plantuml.ugraphic.color.HColorUtils; import net.sourceforge.plantuml.ugraphic.color.HColorUtils;
import static net.sourceforge.plantuml.ugraphic.ImageBuilder.styledImageBuilder;
public class NwDiagram extends UmlDiagram { public class NwDiagram extends UmlDiagram {
private boolean initDone; private boolean initDone;
@ -217,15 +215,8 @@ public class NwDiagram extends UmlDiagram {
protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption) protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
throws IOException { throws IOException {
final ISkinParam skinParam = getSkinParam(); return styledImageBuilder(this, getTextBlock(), index, fileFormatOption, 0)
final ImageParameter imageParameter = new ImageParameter(this, fileFormatOption); .write(os);
final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter);
TextBlock result = getTextBlock();
result = new AnnotatedWorker(this, skinParam, fileFormatOption.getDefaultStringBounder(getSkinParam()))
.addAdd(result);
imageBuilder.setUDrawable(result);
return imageBuilder.writeImageTOBEMOVED(0, os);
} }
private TextBlockBackcolored getTextBlock() { private TextBlockBackcolored getTextBlock() {

View File

@ -39,43 +39,23 @@ import java.io.BufferedReader;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.OutputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import net.sourceforge.plantuml.AbstractPSystem;
import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.PlainDiagram;
import net.sourceforge.plantuml.core.DiagramDescription; import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.donors.PSystemDonors; import net.sourceforge.plantuml.donors.PSystemDonors;
import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.TextBlockHorizontal; import net.sourceforge.plantuml.graphic.TextBlockHorizontal;
import net.sourceforge.plantuml.graphic.UDrawable; import net.sourceforge.plantuml.graphic.UDrawable;
import net.sourceforge.plantuml.graphic.VerticalAlignment; import net.sourceforge.plantuml.graphic.VerticalAlignment;
import net.sourceforge.plantuml.openiconic.data.DummyIcon; import net.sourceforge.plantuml.openiconic.data.DummyIcon;
import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.ImageParameter;
import net.sourceforge.plantuml.ugraphic.color.ColorMapperIdentity;
import net.sourceforge.plantuml.ugraphic.color.HColor;
import net.sourceforge.plantuml.ugraphic.color.HColorUtils;
public class PSystemListOpenIconic extends AbstractPSystem { public class PSystemListOpenIconic extends PlainDiagram {
@Override @Override
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed) protected UDrawable getRootDrawable(FileFormatOption fileFormatOption) throws IOException {
throws IOException {
final UDrawable result = getGraphicStrings();
HColor backcolor = HColorUtils.WHITE;
final String metadata = fileFormat.isWithMetadata() ? getMetadata() : null;
final ImageParameter imageParameter = new ImageParameter(new ColorMapperIdentity(), false, null, metadata,
null, ClockwiseTopRightBottomLeft.none(), backcolor);
final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter);
imageBuilder.setUDrawable(result);
return imageBuilder.writeImageTOBEMOVED(fileFormat, seed, os);
}
private UDrawable getGraphicStrings() throws IOException {
final List<String> lines = new ArrayList<String>(); final List<String> lines = new ArrayList<String>();
lines.add("<b>List Open Iconic"); lines.add("<b>List Open Iconic");
lines.add("<i>Credit to"); lines.add("<i>Credit to");

View File

@ -35,22 +35,14 @@
*/ */
package net.sourceforge.plantuml.openiconic; package net.sourceforge.plantuml.openiconic;
import java.io.IOException;
import java.io.OutputStream;
import net.sourceforge.plantuml.AbstractPSystem;
import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.SkinParam; import net.sourceforge.plantuml.PlainDiagram;
import net.sourceforge.plantuml.UseStyle;
import net.sourceforge.plantuml.core.DiagramDescription; import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.ImageData; import net.sourceforge.plantuml.graphic.UDrawable;
import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft; import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.ImageParameter;
import net.sourceforge.plantuml.ugraphic.color.ColorMapperIdentity;
import net.sourceforge.plantuml.ugraphic.color.HColorUtils; import net.sourceforge.plantuml.ugraphic.color.HColorUtils;
public class PSystemOpenIconic extends AbstractPSystem { public class PSystemOpenIconic extends PlainDiagram {
private final String iconName; private final String iconName;
private final double factor; private final double factor;
@ -61,26 +53,11 @@ public class PSystemOpenIconic extends AbstractPSystem {
} }
@Override @Override
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed) protected UDrawable getRootDrawable(FileFormatOption fileFormatOption) {
throws IOException {
final OpenIcon icon = OpenIcon.retrieve(iconName); final OpenIcon icon = OpenIcon.retrieve(iconName);
// final Dimension2D dim = new Dimension2DDouble(100, 100); // final Dimension2D dim = new Dimension2DDouble(100, 100);
final int margin1; return icon.asTextBlock(HColorUtils.BLACK, factor);
final int margin2;
if (UseStyle.useBetaStyle()) {
margin1 = SkinParam.zeroMargin(5);
margin2 = SkinParam.zeroMargin(5);
} else {
margin1 = 5;
margin2 = 5;
}
final ClockwiseTopRightBottomLeft margins = ClockwiseTopRightBottomLeft.margin1margin2(margin1, margin2);
final ImageParameter imageParameter = new ImageParameter(new ColorMapperIdentity(), false, null, null,
null, margins, null);
final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter);
imageBuilder.setUDrawable(icon.asTextBlock(HColorUtils.BLACK, factor));
return imageBuilder.writeImageTOBEMOVED(fileFormat, seed, os);
// UGraphic2 ug = fileFormat.createUGraphic(dim); // UGraphic2 ug = fileFormat.createUGraphic(dim);
// ug = (UGraphic2) ug.apply(new UTranslate(10, 10)); // ug = (UGraphic2) ug.apply(new UTranslate(10, 10));
@ -103,4 +80,9 @@ public class PSystemOpenIconic extends AbstractPSystem {
return new DiagramDescription("(Open iconic)"); return new DiagramDescription("(Open iconic)");
} }
@Override
public ClockwiseTopRightBottomLeft getDefaultMargins() {
return ClockwiseTopRightBottomLeft.same(5);
}
} }

View File

@ -36,24 +36,18 @@
package net.sourceforge.plantuml.oregon; package net.sourceforge.plantuml.oregon;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import net.sourceforge.plantuml.AbstractPSystem;
import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.PlainDiagram;
import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.core.DiagramDescription; import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.ImageData; import net.sourceforge.plantuml.graphic.UDrawable;
import net.sourceforge.plantuml.graphic.GraphicStrings;
import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft;
import net.sourceforge.plantuml.svek.TextBlockBackcolored;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.ImageParameter;
import net.sourceforge.plantuml.ugraphic.color.ColorMapperIdentity;
import net.sourceforge.plantuml.ugraphic.color.HColor;
public class PSystemOregon extends AbstractPSystem { import static net.sourceforge.plantuml.graphic.GraphicStrings.createGreenOnBlackMonospaced;
public class PSystemOregon extends PlainDiagram {
private Screen screen; private Screen screen;
private List<String> inputs; private List<String> inputs;
@ -98,19 +92,8 @@ public class PSystemOregon extends AbstractPSystem {
} }
@Override @Override
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed) protected UDrawable getRootDrawable(FileFormatOption fileFormatOption) throws IOException {
throws IOException { return createGreenOnBlackMonospaced(getScreen().getLines());
final TextBlockBackcolored result = getGraphicStrings();
HColor backcolor = result.getBackcolor();
final ImageParameter imageParameter = new ImageParameter(new ColorMapperIdentity(), false, null,
getMetadata(), null, ClockwiseTopRightBottomLeft.none(), backcolor);
final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter);
imageBuilder.setUDrawable(result);
return imageBuilder.writeImageTOBEMOVED(fileFormat, seed, os);
}
private TextBlockBackcolored getGraphicStrings() throws IOException {
return GraphicStrings.createGreenOnBlackMonospaced(getScreen().getLines());
} }
public DiagramDescription getDescription() { public DiagramDescription getDescription() {

View File

@ -49,7 +49,6 @@ import java.util.Map;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import net.sourceforge.plantuml.AnnotatedWorker;
import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.Dimension2DDouble;
import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.TitledDiagram; import net.sourceforge.plantuml.TitledDiagram;
@ -61,7 +60,6 @@ import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.graphic.InnerStrategy; import net.sourceforge.plantuml.graphic.InnerStrategy;
import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.project.core.Moment; import net.sourceforge.plantuml.project.core.Moment;
import net.sourceforge.plantuml.project.core.MomentImpl; import net.sourceforge.plantuml.project.core.MomentImpl;
import net.sourceforge.plantuml.project.core.PrintScale; import net.sourceforge.plantuml.project.core.PrintScale;
@ -93,8 +91,6 @@ import net.sourceforge.plantuml.style.SName;
import net.sourceforge.plantuml.style.Style; import net.sourceforge.plantuml.style.Style;
import net.sourceforge.plantuml.style.StyleSignature; import net.sourceforge.plantuml.style.StyleSignature;
import net.sourceforge.plantuml.svek.TextBlockBackcolored; import net.sourceforge.plantuml.svek.TextBlockBackcolored;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.ImageParameter;
import net.sourceforge.plantuml.ugraphic.MinMax; import net.sourceforge.plantuml.ugraphic.MinMax;
import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UTranslate; import net.sourceforge.plantuml.ugraphic.UTranslate;
@ -102,6 +98,8 @@ import net.sourceforge.plantuml.ugraphic.color.HColor;
import net.sourceforge.plantuml.ugraphic.color.HColorSet; import net.sourceforge.plantuml.ugraphic.color.HColorSet;
import net.sourceforge.plantuml.ugraphic.color.HColorUtils; import net.sourceforge.plantuml.ugraphic.color.HColorUtils;
import static net.sourceforge.plantuml.ugraphic.ImageBuilder.styledImageBuilder;
public class GanttDiagram extends TitledDiagram implements ToTaskDraw, WithSprite { public class GanttDiagram extends TitledDiagram implements ToTaskDraw, WithSprite {
private final Map<Task, TaskDraw> draws = new LinkedHashMap<Task, TaskDraw>(); private final Map<Task, TaskDraw> draws = new LinkedHashMap<Task, TaskDraw>();
@ -167,15 +165,9 @@ public class GanttDiagram extends TitledDiagram implements ToTaskDraw, WithSprit
@Override @Override
protected ImageData exportDiagramNow(OutputStream os, int index, FileFormatOption fileFormatOption, long seed) protected ImageData exportDiagramNow(OutputStream os, int index, FileFormatOption fileFormatOption, long seed)
throws IOException { throws IOException {
final ImageParameter imageParameter = new ImageParameter(this, fileFormatOption);
final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter);
final StringBounder stringBounder = fileFormatOption.getDefaultStringBounder(getSkinParam()); final StringBounder stringBounder = fileFormatOption.getDefaultStringBounder(getSkinParam());
TextBlock result = getTextBlock(stringBounder); return styledImageBuilder(this, getTextBlock(stringBounder), index, fileFormatOption, seed())
result = new AnnotatedWorker(this, getSkinParam(), stringBounder).addAdd(result); .write(os);
imageBuilder.setUDrawable(result);
return imageBuilder.writeImageTOBEMOVED(seed, os);
} }
public void setPrintScale(PrintScale printScale) { public void setPrintScale(PrintScale printScale) {

View File

@ -44,10 +44,8 @@ import java.util.Collection;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import net.sourceforge.plantuml.AnnotatedWorker;
import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.Dimension2DDouble;
import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.Log; import net.sourceforge.plantuml.Log;
import net.sourceforge.plantuml.ScaleSimple; import net.sourceforge.plantuml.ScaleSimple;
import net.sourceforge.plantuml.TitledDiagram; import net.sourceforge.plantuml.TitledDiagram;
@ -63,7 +61,6 @@ import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.ImageData; import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.graphic.InnerStrategy; import net.sourceforge.plantuml.graphic.InnerStrategy;
import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.salt.element.Element; import net.sourceforge.plantuml.salt.element.Element;
import net.sourceforge.plantuml.salt.factory.AbstractElementFactoryComplex; import net.sourceforge.plantuml.salt.factory.AbstractElementFactoryComplex;
import net.sourceforge.plantuml.salt.factory.ElementFactory; import net.sourceforge.plantuml.salt.factory.ElementFactory;
@ -87,14 +84,14 @@ import net.sourceforge.plantuml.salt.factory.ElementFactoryTree;
import net.sourceforge.plantuml.sprite.Sprite; import net.sourceforge.plantuml.sprite.Sprite;
import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft; import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft;
import net.sourceforge.plantuml.svek.TextBlockBackcolored; import net.sourceforge.plantuml.svek.TextBlockBackcolored;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.ImageParameter;
import net.sourceforge.plantuml.ugraphic.MinMax; import net.sourceforge.plantuml.ugraphic.MinMax;
import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColor;
import net.sourceforge.plantuml.ugraphic.color.HColorUtils; import net.sourceforge.plantuml.ugraphic.color.HColorUtils;
import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException;
import static net.sourceforge.plantuml.ugraphic.ImageBuilder.styledImageBuilder;
public class PSystemSalt extends TitledDiagram implements WithSprite { public class PSystemSalt extends TitledDiagram implements WithSprite {
private final List<String> data; private final List<String> data;
@ -115,25 +112,14 @@ public class PSystemSalt extends TitledDiagram implements WithSprite {
} }
@Override @Override
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormatOption, long seed) final protected ImageData exportDiagramNow(OutputStream os, int index, FileFormatOption fileFormatOption, long seed)
throws IOException { throws IOException {
try { try {
final Element salt = createElement(manageSprite()); final Element salt = createElement(manageSprite());
final StringBounder stringBounder = fileFormatOption.getDefaultStringBounder(getSkinParam()); final StringBounder stringBounder = fileFormatOption.getDefaultStringBounder(getSkinParam());
final Dimension2D size = salt.getPreferredDimension(stringBounder, 0, 0); final Dimension2D size = salt.getPreferredDimension(stringBounder, 0, 0);
return styledImageBuilder(this, getTextBlock(salt, size), index, fileFormatOption, seed())
final ISkinParam skinParam = getSkinParam(); .write(os);
final ImageParameter imageParameter = new ImageParameter(this, fileFormatOption);
final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter);
TextBlock result = getTextBlock(salt, size);
result = new AnnotatedWorker(this, skinParam, stringBounder).addAdd(result);
imageBuilder.setUDrawable(result);
return imageBuilder.writeImageTOBEMOVED(seed(), os);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
UmlDiagram.exportDiagramError(os, e, fileFormatOption, seed, getMetadata(), "none", UmlDiagram.exportDiagramError(os, e, fileFormatOption, seed, getMetadata(), "none",

View File

@ -42,6 +42,7 @@ import static gen.lib.cgraph.node__c.agnode;
import static gen.lib.cgraph.subg__c.agsubg; import static gen.lib.cgraph.subg__c.agsubg;
import static gen.lib.gvc.gvc__c.gvContext; import static gen.lib.gvc.gvc__c.gvContext;
import static gen.lib.gvc.gvlayout__c.gvLayoutJobs; import static gen.lib.gvc.gvlayout__c.gvLayoutJobs;
import static net.sourceforge.plantuml.ugraphic.ImageBuilder.styledImageBuilder;
import java.awt.geom.Dimension2D; import java.awt.geom.Dimension2D;
import java.awt.geom.Point2D; import java.awt.geom.Point2D;
@ -63,7 +64,6 @@ import h.ST_Agraphinfo_t;
import h.ST_Agrec_s; import h.ST_Agrec_s;
import h.ST_GVC_s; import h.ST_GVC_s;
import h.ST_boxf; import h.ST_boxf;
import net.sourceforge.plantuml.AnnotatedWorker;
import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.FontParam;
import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.ISkinParam;
@ -100,8 +100,6 @@ import net.sourceforge.plantuml.svek.GraphvizCrash;
import net.sourceforge.plantuml.svek.IEntityImage; import net.sourceforge.plantuml.svek.IEntityImage;
import net.sourceforge.plantuml.svek.SvekNode; import net.sourceforge.plantuml.svek.SvekNode;
import net.sourceforge.plantuml.svek.TextBlockBackcolored; import net.sourceforge.plantuml.svek.TextBlockBackcolored;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.ImageParameter;
import net.sourceforge.plantuml.ugraphic.MinMax; import net.sourceforge.plantuml.ugraphic.MinMax;
import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UStroke; import net.sourceforge.plantuml.ugraphic.UStroke;
@ -448,19 +446,12 @@ public class CucaDiagramFileMakerSmetana implements CucaDiagramFileMaker {
// DebugUtils.printDebugEdge(e); // DebugUtils.printDebugEdge(e);
// } // }
final ImageParameter imageParameter = new ImageParameter(diagram, fileFormatOption);
final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter);
final MinMax minMax = TextBlockUtils.getMinMax(new Drawing(null, null), stringBounder, false); final MinMax minMax = TextBlockUtils.getMinMax(new Drawing(null, null), stringBounder, false);
final AnnotatedWorker annotatedWorker = new AnnotatedWorker(diagram, diagram.getSkinParam(),
fileFormatOption.getDefaultStringBounder(diagram.getSkinParam()));
// imageBuilder.setUDrawable(new Drawing(new YMirror(dim.getHeight()))); // imageBuilder.setUDrawable(new Drawing(new YMirror(dim.getHeight())));
imageBuilder.setUDrawable(annotatedWorker.addAdd(new Drawing(new YMirror(minMax.getMaxY()), minMax))); final TextBlock drawable = new Drawing(new YMirror(minMax.getMaxY()), minMax);
return styledImageBuilder(diagram, drawable, 1, fileFormatOption, diagram.seed())
return imageBuilder.writeImageTOBEMOVED(diagram.seed(), os); .write(os);
} catch (Throwable e) { } catch (Throwable e) {
SmetanaDebug.printMe(); SmetanaDebug.printMe();
UmlDiagram.exportDiagramError(os, e, fileFormatOption, diagram.seed(), diagram.getMetadata(), UmlDiagram.exportDiagramError(os, e, fileFormatOption, diagram.seed(), diagram.getMetadata(),

View File

@ -67,12 +67,12 @@ import net.sourceforge.plantuml.skin.rose.Rose;
import net.sourceforge.plantuml.style.SName; import net.sourceforge.plantuml.style.SName;
import net.sourceforge.plantuml.style.Style; import net.sourceforge.plantuml.style.Style;
import net.sourceforge.plantuml.style.StyleSignature; import net.sourceforge.plantuml.style.StyleSignature;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.ImageParameter;
import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UTranslate; import net.sourceforge.plantuml.ugraphic.UTranslate;
import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColor;
import static net.sourceforge.plantuml.ugraphic.ImageBuilder.styledImageBuilder;
public class SequenceDiagramFileMakerPuma2 implements FileMaker { public class SequenceDiagramFileMakerPuma2 implements FileMaker {
private final SequenceDiagram diagram; private final SequenceDiagram diagram;
@ -186,10 +186,7 @@ public class SequenceDiagramFileMakerPuma2 implements FileMaker {
final Dimension2D dimLegend = legendBlock.calculateDimension(stringBounder); final Dimension2D dimLegend = legendBlock.calculateDimension(stringBounder);
area.setLegend(dimLegend, isLegendTop(), diagram.getLegend().getHorizontalAlignment()); area.setLegend(dimLegend, isLegendTop(), diagram.getLegend().getHorizontalAlignment());
final ImageParameter imageParameter = new ImageParameter(diagram, fileFormatOption); final UDrawable drawable = new UDrawable() {
final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter);
imageBuilder.setUDrawable(new UDrawable() {
public void drawU(UGraphic ug) { public void drawU(UGraphic ug) {
double delta = 0; double delta = 0;
@ -222,8 +219,10 @@ public class SequenceDiagramFileMakerPuma2 implements FileMaker {
} }
} }
}); };
return imageBuilder.writeImageTOBEMOVED(diagram.seed(), os); return styledImageBuilder(diagram, drawable, index, fileFormatOption, diagram.seed())
.annotations(false) // they are managed above
.write(os);
} }
private void drawFooter(SequenceDiagramArea area, UGraphic ug, int page) { private void drawFooter(SequenceDiagramArea area, UGraphic ug, int page) {

View File

@ -68,13 +68,13 @@ import net.sourceforge.plantuml.skin.rose.Rose;
import net.sourceforge.plantuml.style.SName; import net.sourceforge.plantuml.style.SName;
import net.sourceforge.plantuml.style.Style; import net.sourceforge.plantuml.style.Style;
import net.sourceforge.plantuml.style.StyleSignature; import net.sourceforge.plantuml.style.StyleSignature;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.ImageParameter;
import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UTranslate; import net.sourceforge.plantuml.ugraphic.UTranslate;
import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColor;
import net.sourceforge.plantuml.utils.MathUtils; import net.sourceforge.plantuml.utils.MathUtils;
import static net.sourceforge.plantuml.ugraphic.ImageBuilder.styledImageBuilder;
public class SequenceDiagramFileMakerTeoz implements FileMaker { public class SequenceDiagramFileMakerTeoz implements FileMaker {
private final SequenceDiagram diagram; private final SequenceDiagram diagram;
@ -139,13 +139,9 @@ public class SequenceDiagramFileMakerTeoz implements FileMaker {
if (this.index != index) { if (this.index != index) {
throw new IllegalStateException(); throw new IllegalStateException();
} }
final ImageParameter imageParameter = new ImageParameter(diagram, fileFormatOption); return styledImageBuilder(diagram, new Foo(index), index, fileFormatOption, diagram.seed())
.annotations(false) // they are managed in drawInternal()
final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter); .write(os);
imageBuilder.setUDrawable(new Foo(index));
return imageBuilder.writeImageTOBEMOVED(diagram.seed(), os);
} }
class Foo implements UDrawable { class Foo implements UDrawable {

View File

@ -53,13 +53,13 @@ import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.TextBlockUtils; import net.sourceforge.plantuml.graphic.TextBlockUtils;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.ImageParameter;
import net.sourceforge.plantuml.ugraphic.UFont; import net.sourceforge.plantuml.ugraphic.UFont;
import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UTranslate; import net.sourceforge.plantuml.ugraphic.UTranslate;
import net.sourceforge.plantuml.ugraphic.color.HColorUtils; import net.sourceforge.plantuml.ugraphic.color.HColorUtils;
import static net.sourceforge.plantuml.ugraphic.ImageBuilder.styledImageBuilder;
public class ListSpriteDiagram extends UmlDiagram { public class ListSpriteDiagram extends UmlDiagram {
public ListSpriteDiagram(ISkinSimple skinParam) { public ListSpriteDiagram(ISkinSimple skinParam) {
@ -74,12 +74,9 @@ public class ListSpriteDiagram extends UmlDiagram {
protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption) protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
throws IOException { throws IOException {
final TextBlock result = getTable(); return styledImageBuilder(this, getTable(), index, fileFormatOption, seed())
final ImageParameter imageParameter = new ImageParameter(this, fileFormatOption); .annotations(false)
final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter); .write(os);
imageBuilder.setUDrawable(result);
return imageBuilder.writeImageTOBEMOVED(seed(), os);
} }
private TextBlock getTable() { private TextBlock getTable() {

View File

@ -36,41 +36,22 @@
package net.sourceforge.plantuml.sprite; package net.sourceforge.plantuml.sprite;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import net.sourceforge.plantuml.AbstractPSystem;
import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.PlainDiagram;
import net.sourceforge.plantuml.core.DiagramDescription; import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.donors.PSystemDonors; import net.sourceforge.plantuml.donors.PSystemDonors;
import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.TextBlockHorizontal; import net.sourceforge.plantuml.graphic.TextBlockHorizontal;
import net.sourceforge.plantuml.graphic.UDrawable; import net.sourceforge.plantuml.graphic.UDrawable;
import net.sourceforge.plantuml.graphic.VerticalAlignment; import net.sourceforge.plantuml.graphic.VerticalAlignment;
import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.ImageParameter;
import net.sourceforge.plantuml.ugraphic.color.ColorMapperIdentity;
import net.sourceforge.plantuml.ugraphic.color.HColor;
import net.sourceforge.plantuml.ugraphic.color.HColorUtils;
public class PSystemListInternalSprites extends AbstractPSystem { public class PSystemListInternalSprites extends PlainDiagram {
@Override @Override
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed) protected UDrawable getRootDrawable(FileFormatOption fileFormatOption) throws IOException {
throws IOException {
final UDrawable result = getGraphicStrings();
HColor backcolor = HColorUtils.WHITE;
final ImageParameter imageParameter = new ImageParameter(new ColorMapperIdentity(), false, null,
getMetadata(), null, ClockwiseTopRightBottomLeft.none(), backcolor);
final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter);
imageBuilder.setUDrawable(result);
return imageBuilder.writeImageTOBEMOVED(fileFormat, seed, os);
}
private UDrawable getGraphicStrings() throws IOException {
final List<String> lines = new ArrayList<String>(); final List<String> lines = new ArrayList<String>();
lines.add("<b>List Current Sprites"); lines.add("<b>List Current Sprites");
lines.add("<i>Credit to"); lines.add("<i>Credit to");

View File

@ -59,14 +59,14 @@ import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.TextBlockUtils; import net.sourceforge.plantuml.graphic.TextBlockUtils;
import net.sourceforge.plantuml.preproc.Stdlib; import net.sourceforge.plantuml.preproc.Stdlib;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.ImageParameter;
import net.sourceforge.plantuml.ugraphic.UFont; import net.sourceforge.plantuml.ugraphic.UFont;
import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UTranslate; import net.sourceforge.plantuml.ugraphic.UTranslate;
import net.sourceforge.plantuml.ugraphic.color.HColorUtils; import net.sourceforge.plantuml.ugraphic.color.HColorUtils;
import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException; import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException;
import static net.sourceforge.plantuml.ugraphic.ImageBuilder.styledImageBuilder;
public class StdlibDiagram extends UmlDiagram { public class StdlibDiagram extends UmlDiagram {
private static final int WIDTH = 1800; private static final int WIDTH = 1800;
@ -84,13 +84,9 @@ public class StdlibDiagram extends UmlDiagram {
protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption) protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
throws IOException { throws IOException {
final TextBlock result = getTable(); return styledImageBuilder(this, getTable(), index, fileFormatOption, seed())
.annotations(false)
final ImageParameter imageParameter = new ImageParameter(this, fileFormatOption); .write(os);
final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter);
imageBuilder.setUDrawable(result);
return imageBuilder.writeImageTOBEMOVED(seed(), os);
} }
private TextBlock getTable() { private TextBlock getTable() {

View File

@ -34,52 +34,22 @@
*/ */
package net.sourceforge.plantuml.stats; package net.sourceforge.plantuml.stats;
import java.io.IOException; import net.sourceforge.plantuml.PlainStringsDiagram;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
import net.sourceforge.plantuml.AbstractPSystem;
import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.core.DiagramDescription; import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.graphic.GraphicStrings;
import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft;
import net.sourceforge.plantuml.svek.TextBlockBackcolored;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.ImageParameter;
import net.sourceforge.plantuml.ugraphic.color.ColorMapperIdentity;
import net.sourceforge.plantuml.ugraphic.color.HColor;
public class PSystemStats extends AbstractPSystem { import java.io.IOException;
private final List<String> strings = new ArrayList<String>(); public class PSystemStats extends PlainStringsDiagram {
PSystemStats() throws IOException { PSystemStats() {
final StatsImpl stats = (StatsImpl) StatsUtils.getStats(); final StatsImpl stats = (StatsImpl) StatsUtils.getStats();
strings.addAll(new CreoleConverter(stats).toCreole()); strings.addAll(new CreoleConverter(stats).toCreole());
} }
@Override
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed)
throws IOException {
final TextBlockBackcolored result = getGraphicStrings();
HColor backcolor = result.getBackcolor();
final ImageParameter imageParameter = new ImageParameter(new ColorMapperIdentity(), false, null,
getMetadata(), null, ClockwiseTopRightBottomLeft.none(), backcolor);
final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter);
imageBuilder.setUDrawable(result);
return imageBuilder.writeImageTOBEMOVED(fileFormat, seed, os);
}
public static PSystemStats create() throws IOException { public static PSystemStats create() throws IOException {
return new PSystemStats(); return new PSystemStats();
} }
private TextBlockBackcolored getGraphicStrings() throws IOException {
return GraphicStrings.createBlackOnWhite(strings);
}
public DiagramDescription getDescription() { public DiagramDescription getDescription() {
return new DiagramDescription("(Stats)"); return new DiagramDescription("(Stats)");
} }

View File

@ -35,7 +35,6 @@
*/ */
package net.sourceforge.plantuml.svek; package net.sourceforge.plantuml.svek;
import java.awt.geom.Dimension2D;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.ArrayList; import java.util.ArrayList;
@ -46,7 +45,6 @@ import net.sourceforge.plantuml.BaseFile;
import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.NamedOutputStream; import net.sourceforge.plantuml.NamedOutputStream;
import net.sourceforge.plantuml.UmlDiagramType; import net.sourceforge.plantuml.UmlDiagramType;
import net.sourceforge.plantuml.api.ImageDataAbstract;
import net.sourceforge.plantuml.core.ImageData; import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.cucadiagram.CucaDiagram; import net.sourceforge.plantuml.cucadiagram.CucaDiagram;
import net.sourceforge.plantuml.cucadiagram.Link; import net.sourceforge.plantuml.cucadiagram.Link;
@ -54,9 +52,8 @@ import net.sourceforge.plantuml.cucadiagram.dot.CucaDiagramSimplifierActivity;
import net.sourceforge.plantuml.cucadiagram.dot.CucaDiagramSimplifierState; import net.sourceforge.plantuml.cucadiagram.dot.CucaDiagramSimplifierState;
import net.sourceforge.plantuml.cucadiagram.dot.DotData; import net.sourceforge.plantuml.cucadiagram.dot.DotData;
import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.ImageParameter; import static net.sourceforge.plantuml.ugraphic.ImageBuilder.styledImageBuilder;
import net.sourceforge.plantuml.ugraphic.color.HColor;
public final class CucaDiagramFileMakerSvek implements CucaDiagramFileMaker { public final class CucaDiagramFileMakerSvek implements CucaDiagramFileMaker {
@ -109,9 +106,11 @@ public final class CucaDiagramFileMakerSvek implements CucaDiagramFileMaker {
svek2 = createDotDataImageBuilder(DotMode.NO_LEFT_RIGHT_AND_XLABEL, stringBounder); svek2 = createDotDataImageBuilder(DotMode.NO_LEFT_RIGHT_AND_XLABEL, stringBounder);
result = svek2.buildImage(basefile, diagram.getDotStringSkek()); result = svek2.buildImage(basefile, diagram.getDotStringSkek());
} }
final boolean isGraphvizCrash = result instanceof GraphvizCrash; // TODO There is something strange with the left margin of mainframe, I think because AnnotatedWorker is used here
// It can be looked at in another PR
result = new AnnotatedWorker(diagram, diagram.getSkinParam(), stringBounder).addAdd(result); result = new AnnotatedWorker(diagram, diagram.getSkinParam(), stringBounder).addAdd(result);
// TODO UmlDiagram.getWarningOrError() looks similar so this might be simplified? - will leave for a separate PR
final String widthwarning = diagram.getSkinParam().getValue("widthwarning"); final String widthwarning = diagram.getSkinParam().getValue("widthwarning");
String warningOrError = null; String warningOrError = null;
if (widthwarning != null && widthwarning.matches("\\d+")) { if (widthwarning != null && widthwarning.matches("\\d+")) {
@ -121,19 +120,11 @@ public final class CucaDiagramFileMakerSvek implements CucaDiagramFileMaker {
// Sorry about this hack. There is a side effect in SvekResult::calculateDimension() // Sorry about this hack. There is a side effect in SvekResult::calculateDimension()
result.calculateDimension(stringBounder); // Ensure text near the margins is not cut off result.calculateDimension(stringBounder); // Ensure text near the margins is not cut off
final HColor backcolor = result.getBackcolor(); return styledImageBuilder(diagram, result, 1, fileFormatOption, diagram.seed())
final String metadata = fileFormatOption.isWithMetadata() ? diagram.getMetadata() : null; .annotations(false) // backwards compatibility (AnnotatedWorker is used above)
.status(result instanceof GraphvizCrash ? 503 : 0)
final ImageParameter imageParameter = new ImageParameter(diagram, fileFormatOption, metadata, .warningOrError(warningOrError)
warningOrError, backcolor); .write(os);
final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter);
imageBuilder.setUDrawable(result);
final ImageData imageData = imageBuilder.writeImageTOBEMOVED(diagram.seed(), os);
if (isGraphvizCrash) {
((ImageDataAbstract) imageData).setStatus(503);
}
return imageData;
} }
private List<Link> getOrderedLinks() { private List<Link> getOrderedLinks() {

View File

@ -51,7 +51,6 @@ import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent; import java.awt.event.WindowEvent;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.Arrays; import java.util.Arrays;
@ -68,21 +67,16 @@ import javax.swing.ListModel;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import javax.swing.WindowConstants; import javax.swing.WindowConstants;
import net.sourceforge.plantuml.FileFormat;
import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.GeneratedImage; import net.sourceforge.plantuml.GeneratedImage;
import net.sourceforge.plantuml.ImageSelection; import net.sourceforge.plantuml.ImageSelection;
import net.sourceforge.plantuml.graphic.GraphicStrings; import net.sourceforge.plantuml.graphic.GraphicStrings;
import net.sourceforge.plantuml.security.ImageIO; import net.sourceforge.plantuml.security.ImageIO;
import net.sourceforge.plantuml.security.SFile; import net.sourceforge.plantuml.security.SFile;
import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft;
import net.sourceforge.plantuml.svek.TextBlockBackcolored; import net.sourceforge.plantuml.svek.TextBlockBackcolored;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.ImageParameter;
import net.sourceforge.plantuml.ugraphic.color.ColorMapperIdentity;
import net.sourceforge.plantuml.ugraphic.color.HColor;
import net.sourceforge.plantuml.version.PSystemVersion; import net.sourceforge.plantuml.version.PSystemVersion;
import static net.sourceforge.plantuml.ugraphic.ImageBuilder.plainPngBuilder;
class ImageWindow2 extends JFrame { class ImageWindow2 extends JFrame {
private final static Preferences prefs = Preferences.userNodeForPackage(ImageWindow2.class); private final static Preferences prefs = Preferences.userNodeForPackage(ImageWindow2.class);
@ -332,16 +326,9 @@ class ImageWindow2 extends JFrame {
} catch (IOException ex) { } catch (IOException ex) {
final String msg = "Error reading file: " + ex.toString(); final String msg = "Error reading file: " + ex.toString();
final TextBlockBackcolored error = GraphicStrings.createForError(Arrays.asList(msg), false); final TextBlockBackcolored error = GraphicStrings.createForError(Arrays.asList(msg), false);
HColor backcolor = error.getBackcolor();
final ImageParameter imageParameter = new ImageParameter(new ColorMapperIdentity(), false, null, null,
null, ClockwiseTopRightBottomLeft.none(), backcolor);
final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter);
imageBuilder.setUDrawable(error);
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
try { try {
imageBuilder.writeImageTOBEMOVED(new FileFormatOption(FileFormat.PNG), 42, baos); final byte[] bytes = plainPngBuilder(error).writeByteArray();
baos.close(); image = ImageIO.read(new ByteArrayInputStream(bytes));
image = ImageIO.read(new ByteArrayInputStream(baos.toByteArray()));
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }

View File

@ -45,10 +45,8 @@ import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import net.sourceforge.plantuml.AnnotatedWorker;
import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.Dimension2DDouble;
import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.UmlDiagram; import net.sourceforge.plantuml.UmlDiagram;
import net.sourceforge.plantuml.UmlDiagramType; import net.sourceforge.plantuml.UmlDiagramType;
import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.CommandExecutionResult;
@ -62,8 +60,6 @@ import net.sourceforge.plantuml.graphic.color.Colors;
import net.sourceforge.plantuml.svek.TextBlockBackcolored; import net.sourceforge.plantuml.svek.TextBlockBackcolored;
import net.sourceforge.plantuml.timingdiagram.graphic.IntricatedPoint; import net.sourceforge.plantuml.timingdiagram.graphic.IntricatedPoint;
import net.sourceforge.plantuml.timingdiagram.graphic.TimeArrow; import net.sourceforge.plantuml.timingdiagram.graphic.TimeArrow;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.ImageParameter;
import net.sourceforge.plantuml.ugraphic.MinMax; import net.sourceforge.plantuml.ugraphic.MinMax;
import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.ULine; import net.sourceforge.plantuml.ugraphic.ULine;
@ -72,6 +68,8 @@ import net.sourceforge.plantuml.ugraphic.UTranslate;
import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColor;
import net.sourceforge.plantuml.ugraphic.color.HColorUtils; import net.sourceforge.plantuml.ugraphic.color.HColorUtils;
import static net.sourceforge.plantuml.ugraphic.ImageBuilder.styledImageBuilder;
public class TimingDiagram extends UmlDiagram implements Clocks { public class TimingDiagram extends UmlDiagram implements Clocks {
public static final double marginX1 = 5; public static final double marginX1 = 5;
@ -99,16 +97,9 @@ public class TimingDiagram extends UmlDiagram implements Clocks {
@Override @Override
protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption) protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
throws IOException { throws IOException {
final ImageParameter imageParameter = new ImageParameter(this, fileFormatOption);
final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter);
TextBlock result = getTextBlock(); return styledImageBuilder(this, getTextBlock(), index, fileFormatOption, seed())
final ISkinParam skinParam = getSkinParam(); .write(os);
result = new AnnotatedWorker(this, skinParam, fileFormatOption.getDefaultStringBounder(getSkinParam()))
.addAdd(result);
imageBuilder.setUDrawable(result);
return imageBuilder.writeImageTOBEMOVED(seed(), os);
} }
private TextBlockBackcolored getTextBlock() { private TextBlockBackcolored getTextBlock() {

View File

@ -52,19 +52,17 @@ import java.util.Set;
import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerException;
import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.Dimension2DDouble;
import net.sourceforge.plantuml.FileFormat;
import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.TextBlockUtils; import net.sourceforge.plantuml.graphic.TextBlockUtils;
import net.sourceforge.plantuml.graphic.UDrawable; import net.sourceforge.plantuml.graphic.UDrawable;
import net.sourceforge.plantuml.security.ImageIO; import net.sourceforge.plantuml.security.ImageIO;
import net.sourceforge.plantuml.security.SFile; import net.sourceforge.plantuml.security.SFile;
import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft;
import net.sourceforge.plantuml.svg.LengthAdjust; import net.sourceforge.plantuml.svg.LengthAdjust;
import net.sourceforge.plantuml.svg.SvgGraphics; import net.sourceforge.plantuml.svg.SvgGraphics;
import net.sourceforge.plantuml.ugraphic.color.ColorMapperIdentity;
import net.sourceforge.plantuml.ugraphic.color.HColorUtils; import net.sourceforge.plantuml.ugraphic.color.HColorUtils;
import static net.sourceforge.plantuml.ugraphic.ImageBuilder.plainPngBuilder;
public class FontChecker { public class FontChecker {
final private UFont font; final private UFont font;
@ -172,11 +170,9 @@ public class FontChecker {
public BufferedImage getBufferedImage(final char c) throws IOException { public BufferedImage getBufferedImage(final char c) throws IOException {
assert c != '\t'; assert c != '\t';
final ImageParameter imageParameter = new ImageParameter(new ColorMapperIdentity(), false, null, null,
null, ClockwiseTopRightBottomLeft.none(), null);
final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter);
final double dim = 20; final double dim = 20;
imageBuilder.setUDrawable(new UDrawable() { final UDrawable drawable = new UDrawable() {
public void drawU(UGraphic ug) { public void drawU(UGraphic ug) {
ug = ug.apply(HColorUtils.BLACK); ug = ug.apply(HColorUtils.BLACK);
ug.draw(new URectangle(dim - 1, dim - 1)); ug.draw(new URectangle(dim - 1, dim - 1));
@ -186,11 +182,9 @@ public class FontChecker {
ug.draw(text); ug.draw(text);
} }
} }
}); };
final ByteArrayOutputStream os = new ByteArrayOutputStream(); final byte[] bytes = plainPngBuilder(drawable).writeByteArray();
imageBuilder.writeImageTOBEMOVED(new FileFormatOption(FileFormat.PNG), 42, os); return ImageIO.read(new ByteArrayInputStream(bytes));
os.close();
return ImageIO.read(new ByteArrayInputStream(os.toByteArray()));
} }
// public BufferedImage getBufferedImageOld(char c) throws IOException { // public BufferedImage getBufferedImageOld(char c) throws IOException {

View File

@ -51,25 +51,32 @@ import java.util.Set;
import javax.swing.ImageIcon; import javax.swing.ImageIcon;
import net.sourceforge.plantuml.AnimatedGifEncoder; import net.sourceforge.plantuml.AnimatedGifEncoder;
import net.sourceforge.plantuml.AnnotatedWorker;
import net.sourceforge.plantuml.CMapData; import net.sourceforge.plantuml.CMapData;
import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.Dimension2DDouble;
import net.sourceforge.plantuml.EmptyImageBuilder; import net.sourceforge.plantuml.EmptyImageBuilder;
import net.sourceforge.plantuml.FileFormat; import net.sourceforge.plantuml.FileFormat;
import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.FileUtils; import net.sourceforge.plantuml.FileUtils;
import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.TitledDiagram;
import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.anim.AffineTransformation; import net.sourceforge.plantuml.anim.AffineTransformation;
import net.sourceforge.plantuml.anim.Animation; import net.sourceforge.plantuml.anim.Animation;
import net.sourceforge.plantuml.api.ImageDataAbstract;
import net.sourceforge.plantuml.api.ImageDataComplex; import net.sourceforge.plantuml.api.ImageDataComplex;
import net.sourceforge.plantuml.api.ImageDataSimple; import net.sourceforge.plantuml.api.ImageDataSimple;
import net.sourceforge.plantuml.braille.UGraphicBraille; import net.sourceforge.plantuml.braille.UGraphicBraille;
import net.sourceforge.plantuml.core.ImageData; import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.eps.EpsStrategy; import net.sourceforge.plantuml.eps.EpsStrategy;
import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.UDrawable; import net.sourceforge.plantuml.graphic.UDrawable;
import net.sourceforge.plantuml.mjpeg.MJPEGGenerator; import net.sourceforge.plantuml.mjpeg.MJPEGGenerator;
import net.sourceforge.plantuml.security.ImageIO; import net.sourceforge.plantuml.security.ImageIO;
import net.sourceforge.plantuml.security.SFile; import net.sourceforge.plantuml.security.SFile;
import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft;
import net.sourceforge.plantuml.svek.TextBlockBackcolored;
import net.sourceforge.plantuml.svg.LengthAdjust; import net.sourceforge.plantuml.svg.LengthAdjust;
import net.sourceforge.plantuml.ugraphic.color.ColorMapper; import net.sourceforge.plantuml.ugraphic.color.ColorMapper;
import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColor;
@ -87,38 +94,124 @@ import net.sourceforge.plantuml.ugraphic.tikz.UGraphicTikz;
import net.sourceforge.plantuml.ugraphic.txt.UGraphicTxt; import net.sourceforge.plantuml.ugraphic.txt.UGraphicTxt;
import net.sourceforge.plantuml.ugraphic.visio.UGraphicVdx; import net.sourceforge.plantuml.ugraphic.visio.UGraphicVdx;
import static net.sourceforge.plantuml.ugraphic.ImageParameter.calculateDiagramMargin;
import static net.sourceforge.plantuml.ugraphic.ImageParameter.getBackgroundColor;
public class ImageBuilder { public class ImageBuilder {
private final ImageParameter param; private final ImageParameter param;
private final double top; private double top;
private final double right; private double right;
private final double bottom; private double bottom;
private final double left; private double left;
private boolean annotations;
private HColor backcolor = HColorUtils.WHITE;
private final TitledDiagram titledDiagram;
private UDrawable udrawable; private UDrawable udrawable;
private final FileFormatOption fileFormatOption;
private final long seed;
private int status = 0;
private String metadata;
private boolean randomPixel; private boolean randomPixel;
private String warningOrError;
public static ImageBuilder build(ImageParameter imageParameter) { public static ImageBuilder plainImageBuilder(UDrawable drawable, FileFormatOption fileFormatOption, long seed) {
return new ImageBuilder(imageParameter); return new ImageBuilder(drawable, null, fileFormatOption, seed, new ImageParameter());
} }
private ImageBuilder(ImageParameter imageParameter) { public static ImageBuilder plainPngBuilder(UDrawable drawable) {
this.param = imageParameter; return plainImageBuilder(drawable, new FileFormatOption(FileFormat.PNG), 42);
this.top = imageParameter.getMargins().getTop();
this.right = imageParameter.getMargins().getRight();
this.bottom = imageParameter.getMargins().getBottom();
this.left = imageParameter.getMargins().getLeft();
} }
public void setUDrawable(UDrawable udrawable) { // TODO do something with "index"
this.udrawable = udrawable; public static ImageBuilder styledImageBuilder(TitledDiagram diagram, UDrawable drawable, int index,
FileFormatOption fileFormatOption, long seed) {
return new ImageBuilder(drawable, diagram, fileFormatOption, seed, new ImageParameter(diagram))
.annotations(true)
.backcolor(getBackgroundColor(diagram))
.margin(calculateDiagramMargin(diagram))
.metadata(fileFormatOption.isWithMetadata() ? diagram.getMetadata() : null)
.warningOrError(diagram.getWarningOrError());
}
private ImageBuilder(UDrawable drawable, TitledDiagram titledDiagram, FileFormatOption fileFormatOption, long seed, ImageParameter param) {
this.udrawable = drawable;
this.titledDiagram = titledDiagram;
this.fileFormatOption = fileFormatOption;
this.seed = seed;
this.param = param;
if (drawable instanceof TextBlockBackcolored) {
backcolor = ((TextBlockBackcolored) drawable).getBackcolor();
}
}
public ImageBuilder annotations(boolean annotations) {
this.annotations = annotations;
return this;
}
public ImageBuilder backcolor(HColor backcolor) {
this.backcolor = backcolor;
return this;
}
public ImageBuilder blackBackcolor() {
return backcolor(HColorUtils.BLACK);
}
public ImageBuilder margin(ClockwiseTopRightBottomLeft margin) {
this.top = margin.getTop();
this.right = margin.getRight();
this.bottom = margin.getBottom();
this.left = margin.getLeft();
return this;
}
public ImageBuilder metadata(String metadata) {
this.metadata = metadata;
return this;
}
public ImageBuilder randomPixel() {
this.randomPixel = true;
return this;
}
public ImageBuilder status(int status) {
this.status = status;
return this;
}
public ImageBuilder warningOrError(String warningOrError) {
this.warningOrError = warningOrError;
return this;
}
public ImageData write(OutputStream os) throws IOException {
if (annotations && titledDiagram != null) {
if (!(udrawable instanceof TextBlock)) throw new IllegalStateException("udrawable is not a TextBlock");
final ISkinParam skinParam = titledDiagram.getSkinParam();
final StringBounder stringBounder = fileFormatOption.getDefaultStringBounder(skinParam);
final AnnotatedWorker annotatedWorker = new AnnotatedWorker(titledDiagram, skinParam, stringBounder);
udrawable = annotatedWorker.addAdd((TextBlock) udrawable);
}
final ImageData imageData = writeImageTOBEMOVED(fileFormatOption, seed, os);
((ImageDataAbstract) imageData).setStatus(status);
return imageData;
}
public byte[] writeByteArray() throws IOException {
try (final ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
write(baos);
return baos.toByteArray();
}
} }
public ImageData writeImageTOBEMOVED(long seed, OutputStream os) throws IOException { public ImageData writeImageTOBEMOVED(long seed, OutputStream os) throws IOException {
return writeImageTOBEMOVED(param.getFileFormatOption(), seed, os); return writeImageTOBEMOVED(fileFormatOption, seed, os);
} }
public ImageData writeImageTOBEMOVED(FileFormatOption fileFormatOption, long seed, OutputStream os) public ImageData writeImageTOBEMOVED(FileFormatOption fileFormatOption, long seed, OutputStream os)
@ -163,14 +256,14 @@ public class ImageBuilder {
final UGraphic ugDecored = handwritten(ug2); final UGraphic ugDecored = handwritten(ug2);
udrawable.drawU(ugDecored); udrawable.drawU(ugDecored);
ugDecored.flushUg(); ugDecored.flushUg();
ug.writeImageTOBEMOVED(os, param.getMetadata(), 96); ug.writeImageTOBEMOVED(os, metadata, 96);
os.flush(); os.flush();
if (ug instanceof UGraphicG2d) { if (ug instanceof UGraphicG2d) {
final Set<Url> urls = ((UGraphicG2d) ug).getAllUrlsEncountered(); final Set<Url> urls = ((UGraphicG2d) ug).getAllUrlsEncountered();
if (urls.size() > 0) { if (urls.size() > 0) {
final CMapData cmap = CMapData.cmapString(urls, param.getDpi()); final CMapData cmap = CMapData.cmapString(urls, param.getDpi());
return new ImageDataComplex(dim, cmap, param.getWarningOrError()); return new ImageDataComplex(dim, cmap, warningOrError);
} }
} }
return new ImageDataSimple(dim); return new ImageDataSimple(dim);
@ -285,10 +378,10 @@ public class ImageBuilder {
final FileFormat fileFormat = option.getFileFormat(); final FileFormat fileFormat = option.getFileFormat();
switch (fileFormat) { switch (fileFormat) {
case PNG: case PNG:
return createUGraphicPNG(colorMapper, scaleFactor, dim, param.getBackcolor(), animationArg, dx, dy, return createUGraphicPNG(colorMapper, scaleFactor, dim, backcolor, animationArg, dx, dy,
option.getWatermark()); option.getWatermark());
case SVG: case SVG:
return createUGraphicSVG(colorMapper, scaleFactor, dim, param.getBackcolor(), option.getSvgLinkTarget(), return createUGraphicSVG(colorMapper, scaleFactor, dim, backcolor, option.getSvgLinkTarget(),
option.getHoverColor(), seed, option.getPreserveAspectRatio(), param.getlengthAdjust()); option.getHoverColor(), seed, option.getPreserveAspectRatio(), param.getlengthAdjust());
case EPS: case EPS:
return new UGraphicEps(colorMapper, EpsStrategy.getDefault2()); return new UGraphicEps(colorMapper, EpsStrategy.getDefault2());
@ -363,9 +456,4 @@ public class ImageBuilder {
return ug; return ug;
} }
public void setRandomPixel(boolean randomPixel) {
this.randomPixel = randomPixel;
}
} }

View File

@ -37,7 +37,6 @@ package net.sourceforge.plantuml.ugraphic;
import net.sourceforge.plantuml.ColorParam; import net.sourceforge.plantuml.ColorParam;
import net.sourceforge.plantuml.CornerParam; import net.sourceforge.plantuml.CornerParam;
import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.LineParam; import net.sourceforge.plantuml.LineParam;
import net.sourceforge.plantuml.Scale; import net.sourceforge.plantuml.Scale;
@ -53,9 +52,11 @@ import net.sourceforge.plantuml.style.Style;
import net.sourceforge.plantuml.style.StyleSignature; import net.sourceforge.plantuml.style.StyleSignature;
import net.sourceforge.plantuml.svg.LengthAdjust; import net.sourceforge.plantuml.svg.LengthAdjust;
import net.sourceforge.plantuml.ugraphic.color.ColorMapper; import net.sourceforge.plantuml.ugraphic.color.ColorMapper;
import net.sourceforge.plantuml.ugraphic.color.ColorMapperIdentity;
import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColor;
import net.sourceforge.plantuml.ugraphic.color.HColorUtils; import net.sourceforge.plantuml.ugraphic.color.HColorUtils;
// TODO merge these fields into ImageBuilder
public class ImageParameter { public class ImageParameter {
private final ColorMapper colorMapper; private final ColorMapper colorMapper;
@ -63,10 +64,6 @@ public class ImageParameter {
private final Animation animation; private final Animation animation;
private final Scale scale; private final Scale scale;
private int dpi; private int dpi;
private final String metadata;
private final String warningOrError;
private final ClockwiseTopRightBottomLeft margins;
private final HColor backcolor;
private final boolean svgDimensionStyle; private final boolean svgDimensionStyle;
private final SvgCharSizeHack svgCharSizeHack; private final SvgCharSizeHack svgCharSizeHack;
private final LengthAdjust lengthAdjust; private final LengthAdjust lengthAdjust;
@ -74,19 +71,13 @@ public class ImageParameter {
private final UStroke borderStroke; private final UStroke borderStroke;
private final HColor borderColor; private final HColor borderColor;
private final double borderCorner; private final double borderCorner;
private final FileFormatOption fileFormatOption;
public ImageParameter(ColorMapper colorMapper, boolean useHandwritten, Animation animation, public ImageParameter() {
String metadata, String warningOrError, ClockwiseTopRightBottomLeft margins, HColor backcolor) { this.colorMapper = new ColorMapperIdentity();
this.colorMapper = colorMapper; this.useHandwritten = false;
this.useHandwritten = useHandwritten; this.animation = null;
this.animation = animation;
this.scale = null; this.scale = null;
this.dpi = 96; this.dpi = 96;
this.metadata = metadata;
this.warningOrError = warningOrError;
this.margins = margins;
this.backcolor = backcolor;
this.svgDimensionStyle = true; this.svgDimensionStyle = true;
this.borderColor = null; this.borderColor = null;
@ -94,20 +85,9 @@ public class ImageParameter {
this.borderStroke = null; this.borderStroke = null;
this.svgCharSizeHack = SvgCharSizeHack.NO_HACK; this.svgCharSizeHack = SvgCharSizeHack.NO_HACK;
this.lengthAdjust = LengthAdjust.defaultValue(); this.lengthAdjust = LengthAdjust.defaultValue();
this.fileFormatOption = null;
} }
public ImageParameter(TitledDiagram diagram, FileFormatOption fileFormatOption) { public static HColor getBackgroundColor(TitledDiagram diagram) {
this(
diagram,
fileFormatOption,
fileFormatOption.isWithMetadata() ? diagram.getMetadata() : null,
diagram.getWarningOrError(),
getBackgroundColor(diagram)
);
}
private static HColor getBackgroundColor(TitledDiagram diagram) {
if (UseStyle.useBetaStyle()) { if (UseStyle.useBetaStyle()) {
final Style style = StyleSignature final Style style = StyleSignature
.of(SName.root, SName.document, diagram.getUmlDiagramType().getStyleName()) .of(SName.root, SName.document, diagram.getUmlDiagramType().getStyleName())
@ -124,19 +104,13 @@ public class ImageParameter {
return diagram.getSkinParam().getBackgroundColor(false); return diagram.getSkinParam().getBackgroundColor(false);
} }
public ImageParameter(TitledDiagram diagram, FileFormatOption fileFormatOption, String metadata, public ImageParameter(TitledDiagram diagram) {
String warningOrError, HColor backcolor) {
final ISkinParam skinParam = diagram.getSkinParam(); final ISkinParam skinParam = diagram.getSkinParam();
this.fileFormatOption = fileFormatOption;
this.colorMapper = skinParam.getColorMapper(); this.colorMapper = skinParam.getColorMapper();
this.useHandwritten = skinParam.handwritten(); this.useHandwritten = skinParam.handwritten();
this.animation = diagram.getAnimation(); this.animation = diagram.getAnimation();
this.scale = diagram.getScale(); this.scale = diagram.getScale();
this.dpi = skinParam.getDpi(); this.dpi = skinParam.getDpi();
this.metadata = metadata;
this.warningOrError = warningOrError;
this.margins = calculateDiagramMargin(diagram);
this.backcolor = backcolor;
this.svgDimensionStyle = skinParam.svgDimensionStyle(); this.svgDimensionStyle = skinParam.svgDimensionStyle();
final Rose rose = new Rose(); final Rose rose = new Rose();
@ -174,22 +148,6 @@ public class ImageParameter {
return dpi; return dpi;
} }
public final String getMetadata() {
return metadata;
}
public final String getWarningOrError() {
return warningOrError;
}
public final ClockwiseTopRightBottomLeft getMargins() {
return margins;
}
public final HColor getBackcolor() {
return backcolor;
}
public final boolean isSvgDimensionStyle() { public final boolean isSvgDimensionStyle() {
return svgDimensionStyle; return svgDimensionStyle;
} }
@ -214,11 +172,7 @@ public class ImageParameter {
return lengthAdjust; return lengthAdjust;
} }
public FileFormatOption getFileFormatOption() { public static ClockwiseTopRightBottomLeft calculateDiagramMargin(TitledDiagram diagram) {
return fileFormatOption;
}
private static ClockwiseTopRightBottomLeft calculateDiagramMargin(TitledDiagram diagram) {
if (UseStyle.useBetaStyle()) { if (UseStyle.useBetaStyle()) {
final Style style = StyleSignature.of(SName.root, SName.document) final Style style = StyleSignature.of(SName.root, SName.document)
.getMergedStyle(diagram.getSkinParam().getCurrentStyleBuilder()); .getMergedStyle(diagram.getSkinParam().getCurrentStyleBuilder());

View File

@ -37,35 +37,27 @@ package net.sourceforge.plantuml.version;
import java.awt.Color; import java.awt.Color;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
import java.security.spec.InvalidKeySpecException; import java.security.spec.InvalidKeySpecException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import net.sourceforge.plantuml.AbstractPSystem;
import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.PlainDiagram;
import net.sourceforge.plantuml.SignatureUtils; import net.sourceforge.plantuml.SignatureUtils;
import net.sourceforge.plantuml.core.DiagramDescription; import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.flashcode.FlashCodeFactory; import net.sourceforge.plantuml.flashcode.FlashCodeFactory;
import net.sourceforge.plantuml.flashcode.FlashCodeUtils; import net.sourceforge.plantuml.flashcode.FlashCodeUtils;
import net.sourceforge.plantuml.graphic.GraphicStrings; import net.sourceforge.plantuml.graphic.GraphicStrings;
import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.UDrawable; import net.sourceforge.plantuml.graphic.UDrawable;
import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft;
import net.sourceforge.plantuml.ugraphic.AffineTransformType; import net.sourceforge.plantuml.ugraphic.AffineTransformType;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.ImageParameter;
import net.sourceforge.plantuml.ugraphic.PixelImage; import net.sourceforge.plantuml.ugraphic.PixelImage;
import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UImage; import net.sourceforge.plantuml.ugraphic.UImage;
import net.sourceforge.plantuml.ugraphic.UTranslate; import net.sourceforge.plantuml.ugraphic.UTranslate;
import net.sourceforge.plantuml.ugraphic.color.ColorMapperIdentity;
import net.sourceforge.plantuml.ugraphic.color.HColor;
import net.sourceforge.plantuml.ugraphic.color.HColorUtils;
public class PSystemKeycheck extends AbstractPSystem { public class PSystemKeycheck extends PlainDiagram {
final private String key; final private String key;
final private String sig; final private String sig;
@ -76,14 +68,8 @@ public class PSystemKeycheck extends AbstractPSystem {
} }
@Override @Override
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed) protected UDrawable getRootDrawable(FileFormatOption fileFormatOption) {
throws IOException { return new UDrawable() {
HColor backcolor = HColorUtils.WHITE;
final ImageParameter imageParameter = new ImageParameter(new ColorMapperIdentity(), false, null,
getMetadata(), null, ClockwiseTopRightBottomLeft.none(), backcolor);
final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter);
imageBuilder.setUDrawable(new UDrawable() {
public void drawU(UGraphic ug) { public void drawU(UGraphic ug) {
try { try {
drawInternal(ug); drawInternal(ug);
@ -91,8 +77,7 @@ public class PSystemKeycheck extends AbstractPSystem {
e.printStackTrace(); e.printStackTrace();
} }
} }
}); };
return imageBuilder.writeImageTOBEMOVED(fileFormat, seed, os);
} }
public DiagramDescription getDescription() { public DiagramDescription getDescription() {

View File

@ -37,35 +37,27 @@ package net.sourceforge.plantuml.version;
import java.awt.Color; import java.awt.Color;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.prefs.BackingStoreException; import java.util.prefs.BackingStoreException;
import net.sourceforge.plantuml.AbstractPSystem;
import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.PlainDiagram;
import net.sourceforge.plantuml.SignatureUtils; import net.sourceforge.plantuml.SignatureUtils;
import net.sourceforge.plantuml.core.DiagramDescription; import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.flashcode.FlashCodeFactory; import net.sourceforge.plantuml.flashcode.FlashCodeFactory;
import net.sourceforge.plantuml.flashcode.FlashCodeUtils; import net.sourceforge.plantuml.flashcode.FlashCodeUtils;
import net.sourceforge.plantuml.graphic.GraphicStrings; import net.sourceforge.plantuml.graphic.GraphicStrings;
import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.UDrawable; import net.sourceforge.plantuml.graphic.UDrawable;
import net.sourceforge.plantuml.security.SFile; import net.sourceforge.plantuml.security.SFile;
import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft;
import net.sourceforge.plantuml.ugraphic.AffineTransformType; import net.sourceforge.plantuml.ugraphic.AffineTransformType;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.ImageParameter;
import net.sourceforge.plantuml.ugraphic.PixelImage; import net.sourceforge.plantuml.ugraphic.PixelImage;
import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UImage; import net.sourceforge.plantuml.ugraphic.UImage;
import net.sourceforge.plantuml.ugraphic.UTranslate; import net.sourceforge.plantuml.ugraphic.UTranslate;
import net.sourceforge.plantuml.ugraphic.color.ColorMapperIdentity;
import net.sourceforge.plantuml.ugraphic.color.HColor;
import net.sourceforge.plantuml.ugraphic.color.HColorUtils;
public class PSystemKeygen extends AbstractPSystem { public class PSystemKeygen extends PlainDiagram {
final private String key; final private String key;
@ -74,14 +66,8 @@ public class PSystemKeygen extends AbstractPSystem {
} }
@Override @Override
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed) protected UDrawable getRootDrawable(FileFormatOption fileFormatOption) {
throws IOException { return new UDrawable() {
HColor backcolor = HColorUtils.WHITE;
final ImageParameter imageParameter = new ImageParameter(new ColorMapperIdentity(), false, null,
getMetadata(), null, ClockwiseTopRightBottomLeft.none(), backcolor);
final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter);
imageBuilder.setUDrawable(new UDrawable() {
public void drawU(UGraphic ug) { public void drawU(UGraphic ug) {
try { try {
drawInternal(ug); drawInternal(ug);
@ -89,8 +75,7 @@ public class PSystemKeygen extends AbstractPSystem {
e.printStackTrace(); e.printStackTrace();
} }
} }
}); };
return imageBuilder.writeImageTOBEMOVED(fileFormat, seed, os);
} }
public DiagramDescription getDescription() { public DiagramDescription getDescription() {

View File

@ -36,37 +36,26 @@ package net.sourceforge.plantuml.version;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import net.sourceforge.plantuml.AbstractPSystem;
import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.PlainDiagram;
import net.sourceforge.plantuml.core.DiagramDescription; import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.graphic.GraphicStrings; import net.sourceforge.plantuml.graphic.GraphicStrings;
import net.sourceforge.plantuml.graphic.UDrawable; import net.sourceforge.plantuml.graphic.UDrawable;
import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft;
import net.sourceforge.plantuml.svek.TextBlockBackcolored; import net.sourceforge.plantuml.svek.TextBlockBackcolored;
import net.sourceforge.plantuml.ugraphic.AffineTransformType; import net.sourceforge.plantuml.ugraphic.AffineTransformType;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.ImageParameter;
import net.sourceforge.plantuml.ugraphic.PixelImage; import net.sourceforge.plantuml.ugraphic.PixelImage;
import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UImage; import net.sourceforge.plantuml.ugraphic.UImage;
import net.sourceforge.plantuml.ugraphic.UTranslate; import net.sourceforge.plantuml.ugraphic.UTranslate;
import net.sourceforge.plantuml.ugraphic.color.ColorMapperIdentity;
public class PSystemLicense extends AbstractPSystem implements UDrawable { public class PSystemLicense extends PlainDiagram implements UDrawable {
@Override @Override
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed) protected UDrawable getRootDrawable(FileFormatOption fileFormatOption) {
throws IOException { return this;
final ImageParameter imageParameter = new ImageParameter(new ColorMapperIdentity(), false, null,
getMetadata(), null, ClockwiseTopRightBottomLeft.none(), null);
final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter);
imageBuilder.setUDrawable(this);
return imageBuilder.writeImageTOBEMOVED(fileFormat, seed, os);
} }
public static PSystemLicense create() throws IOException { public static PSystemLicense create() throws IOException {

View File

@ -37,22 +37,17 @@ package net.sourceforge.plantuml.version;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import net.sourceforge.plantuml.AbstractPSystem;
import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.OptionFlags; import net.sourceforge.plantuml.OptionFlags;
import net.sourceforge.plantuml.OptionPrint; import net.sourceforge.plantuml.OptionPrint;
import net.sourceforge.plantuml.PlainStringsDiagram;
import net.sourceforge.plantuml.Run; import net.sourceforge.plantuml.Run;
import net.sourceforge.plantuml.core.DiagramDescription; import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.cucadiagram.dot.GraphvizUtils; import net.sourceforge.plantuml.cucadiagram.dot.GraphvizUtils;
import net.sourceforge.plantuml.dedication.Dedication; import net.sourceforge.plantuml.dedication.Dedication;
import net.sourceforge.plantuml.graphic.GraphicPosition;
import net.sourceforge.plantuml.graphic.GraphicStrings;
import net.sourceforge.plantuml.preproc.ImportedFiles; import net.sourceforge.plantuml.preproc.ImportedFiles;
import net.sourceforge.plantuml.preproc.Stdlib; import net.sourceforge.plantuml.preproc.Stdlib;
import net.sourceforge.plantuml.preproc2.PreprocessorUtils; import net.sourceforge.plantuml.preproc2.PreprocessorUtils;
@ -60,29 +55,24 @@ import net.sourceforge.plantuml.security.ImageIO;
import net.sourceforge.plantuml.security.SFile; import net.sourceforge.plantuml.security.SFile;
import net.sourceforge.plantuml.security.SecurityProfile; import net.sourceforge.plantuml.security.SecurityProfile;
import net.sourceforge.plantuml.security.SecurityUtils; import net.sourceforge.plantuml.security.SecurityUtils;
import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft;
import net.sourceforge.plantuml.svek.GraphvizCrash; import net.sourceforge.plantuml.svek.GraphvizCrash;
import net.sourceforge.plantuml.svek.TextBlockBackcolored;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.ImageParameter;
import net.sourceforge.plantuml.ugraphic.color.ColorMapperIdentity;
import net.sourceforge.plantuml.ugraphic.color.HColor;
public class PSystemVersion extends AbstractPSystem { import static net.sourceforge.plantuml.graphic.GraphicPosition.BACKGROUND_CORNER_BOTTOM_RIGHT;
private final List<String> strings = new ArrayList<String>(); public class PSystemVersion extends PlainStringsDiagram {
private BufferedImage image;
PSystemVersion(boolean withImage, List<String> args) { PSystemVersion(boolean withImage, List<String> args) {
this.strings.addAll(args); this.strings.addAll(args);
if (withImage) { if (withImage) {
this.image = getPlantumlImage(); this.image = getPlantumlImage();
this.imagePosition = BACKGROUND_CORNER_BOTTOM_RIGHT;
} }
} }
private PSystemVersion(List<String> args, BufferedImage image) { private PSystemVersion(List<String> args, BufferedImage image) {
this.strings.addAll(args); this.strings.addAll(args);
this.image = image; this.image = image;
this.imagePosition = BACKGROUND_CORNER_BOTTOM_RIGHT;
} }
public static BufferedImage getPlantumlImage() { public static BufferedImage getPlantumlImage() {
@ -167,19 +157,6 @@ public class PSystemVersion extends AbstractPSystem {
return transparentIcon; return transparentIcon;
} }
@Override
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed)
throws IOException {
final TextBlockBackcolored result = GraphicStrings.createBlackOnWhite(strings, image,
GraphicPosition.BACKGROUND_CORNER_BOTTOM_RIGHT);
HColor backcolor = result.getBackcolor();
final ImageParameter imageParameter = new ImageParameter(new ColorMapperIdentity(), false, null,
getMetadata(), null, ClockwiseTopRightBottomLeft.none(), backcolor);
final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter);
imageBuilder.setUDrawable(result);
return imageBuilder.writeImageTOBEMOVED(fileFormat, seed, os);
}
public static PSystemVersion createShowVersion() { public static PSystemVersion createShowVersion() {
final List<String> strings = new ArrayList<String>(); final List<String> strings = new ArrayList<String>();
strings.add("<b>PlantUML version " + Version.versionString() + "</b> (" + Version.compileTimeString() + ")"); strings.add("<b>PlantUML version " + Version.versionString() + "</b> (" + Version.compileTimeString() + ")");

View File

@ -40,10 +40,8 @@ import java.awt.geom.Rectangle2D;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import net.sourceforge.plantuml.AnnotatedWorker;
import net.sourceforge.plantuml.Direction; import net.sourceforge.plantuml.Direction;
import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.UmlDiagram; import net.sourceforge.plantuml.UmlDiagram;
import net.sourceforge.plantuml.UmlDiagramType; import net.sourceforge.plantuml.UmlDiagramType;
import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.CommandExecutionResult;
@ -59,12 +57,12 @@ import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.mindmap.IdeaShape; import net.sourceforge.plantuml.mindmap.IdeaShape;
import net.sourceforge.plantuml.style.NoStyleAvailableException; import net.sourceforge.plantuml.style.NoStyleAvailableException;
import net.sourceforge.plantuml.svek.TextBlockBackcolored; import net.sourceforge.plantuml.svek.TextBlockBackcolored;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.ImageParameter;
import net.sourceforge.plantuml.ugraphic.MinMax; import net.sourceforge.plantuml.ugraphic.MinMax;
import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColor;
import static net.sourceforge.plantuml.ugraphic.ImageBuilder.styledImageBuilder;
public class WBSDiagram extends UmlDiagram { public class WBSDiagram extends UmlDiagram {
public DiagramDescription getDescription() { public DiagramDescription getDescription() {
@ -79,17 +77,8 @@ public class WBSDiagram extends UmlDiagram {
protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption) protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
throws IOException { throws IOException {
final ISkinParam skinParam = getSkinParam(); return styledImageBuilder(this, getTextBlock(), index, fileFormatOption, seed())
final ImageParameter imageParameter = new ImageParameter(this, fileFormatOption); .write(os);
final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter);
TextBlock result = getTextBlock();
result = new AnnotatedWorker(this, skinParam, fileFormatOption.getDefaultStringBounder(getSkinParam()))
.addAdd(result);
imageBuilder.setUDrawable(result);
return imageBuilder.writeImageTOBEMOVED(seed(), os);
} }
private TextBlockBackcolored getTextBlock() { private TextBlockBackcolored getTextBlock() {

View File

@ -42,10 +42,8 @@ import java.io.OutputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import net.sourceforge.plantuml.AnnotatedWorker;
import net.sourceforge.plantuml.FileFormat; import net.sourceforge.plantuml.FileFormat;
import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.TikzFontDistortion; import net.sourceforge.plantuml.TikzFontDistortion;
import net.sourceforge.plantuml.UmlDiagram; import net.sourceforge.plantuml.UmlDiagram;
import net.sourceforge.plantuml.UmlDiagramType; import net.sourceforge.plantuml.UmlDiagramType;
@ -55,15 +53,14 @@ import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.graphic.InnerStrategy; import net.sourceforge.plantuml.graphic.InnerStrategy;
import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.svek.TextBlockBackcolored; import net.sourceforge.plantuml.svek.TextBlockBackcolored;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.ImageParameter;
import net.sourceforge.plantuml.ugraphic.MinMax; import net.sourceforge.plantuml.ugraphic.MinMax;
import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UTranslate; import net.sourceforge.plantuml.ugraphic.UTranslate;
import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColor;
import static net.sourceforge.plantuml.ugraphic.ImageBuilder.styledImageBuilder;
public class WireDiagram extends UmlDiagram { public class WireDiagram extends UmlDiagram {
private final WBlock root = new WBlock("", new UTranslate(), 0, 0, null); private final WBlock root = new WBlock("", new UTranslate(), 0, 0, null);
@ -83,17 +80,8 @@ public class WireDiagram extends UmlDiagram {
protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption) protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
throws IOException { throws IOException {
final ISkinParam skinParam = getSkinParam(); return styledImageBuilder(this, getTextBlock(), index, fileFormatOption, seed())
final ImageParameter imageParameter = new ImageParameter(this, fileFormatOption); .write(os);
final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter);
TextBlock result = getTextBlock();
result = new AnnotatedWorker(this, skinParam, fileFormatOption.getDefaultStringBounder(getSkinParam()))
.addAdd(result);
imageBuilder.setUDrawable(result);
return imageBuilder.writeImageTOBEMOVED(seed(), os);
} }
private TextBlockBackcolored getTextBlock() { private TextBlockBackcolored getTextBlock() {