PacketDiagramFactory.java
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2026, Arnaud Roques
*
* Project Info: https://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* https://plantuml.com/patreon (only 1$ per month!)
* https://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: kolulu23
*
*
*/
package net.sourceforge.plantuml.packetdiag;
import java.util.List;
import net.sourceforge.plantuml.Previous;
import net.sourceforge.plantuml.command.Command;
import net.sourceforge.plantuml.command.CommonCommands;
import net.sourceforge.plantuml.command.PSystemCommandFactory;
import net.sourceforge.plantuml.core.DiagramType;
import net.sourceforge.plantuml.core.UmlSource;
import net.sourceforge.plantuml.nio.PathSystem;
import net.sourceforge.plantuml.packetdiag.command.CommandColWidth;
import net.sourceforge.plantuml.packetdiag.command.CommandNodeHeight;
import net.sourceforge.plantuml.packetdiag.command.CommandNumRange;
import net.sourceforge.plantuml.packetdiag.command.CommandPacketDiagEnd;
import net.sourceforge.plantuml.packetdiag.command.CommandPacketDiagStart;
import net.sourceforge.plantuml.packetdiag.command.CommandSameHeight;
import net.sourceforge.plantuml.packetdiag.command.CommandScaleDirection;
import net.sourceforge.plantuml.packetdiag.command.CommandScaleInterval;
import net.sourceforge.plantuml.preproc.PreprocessingArtifact;
/**
* Factory responsible for creating {@link PacketDiagram} instances and registering all commands
* supported by the {@code packetdiag} diagram type.
* <p>
* This hooks the {@code packetdiag} parser into PlantUML by:
* </p>
* <ul>
* <li>adding common PlantUML commands (title, skinparam, etc.),</li>
* <li>registering packetdiag-specific directives (colwidth, node_height, scale_direction, ...),</li>
* <li>creating the diagram model ({@link PacketDiagram}) for each parsed source.</li>
* </ul>
*/
public class PacketDiagramFactory extends PSystemCommandFactory {
public PacketDiagramFactory() {
super(DiagramType.PACKET);
}
@Override
protected void initCommandsList(List<Command> cmds) {
CommonCommands.addCommonCommands1(cmds);
cmds.add(new CommandPacketDiagStart());
cmds.add(new CommandColWidth());
cmds.add(new CommandNodeHeight());
cmds.add(new CommandScaleDirection());
cmds.add(new CommandScaleInterval());
cmds.add(new CommandSameHeight());
cmds.add(new CommandNumRange());
cmds.add(new CommandPacketDiagEnd());
}
@Override
public PacketDiagram createEmptyDiagram(PathSystem pathSystem, UmlSource source, Previous previous,
PreprocessingArtifact preprocessing) {
return new PacketDiagram(source, preprocessing);
}
}