2010-11-15 20:35:36 +00:00
|
|
|
/* ========================================================================
|
|
|
|
* PlantUML : a free UML diagram generator
|
|
|
|
* ========================================================================
|
|
|
|
*
|
2016-01-09 12:15:40 +00:00
|
|
|
* (C) Copyright 2009-2017, Arnaud Roques
|
2010-11-15 20:35:36 +00:00
|
|
|
*
|
2016-03-06 16:47:34 +00:00
|
|
|
* Project Info: http://plantuml.com
|
2010-11-15 20:35:36 +00:00
|
|
|
*
|
2017-03-15 19:13:31 +00:00
|
|
|
* If you like this project or if you find it useful, you can support us at:
|
|
|
|
*
|
|
|
|
* http://plantuml.com/patreon (only 1$ per month!)
|
|
|
|
* http://plantuml.com/paypal
|
|
|
|
*
|
2010-11-15 20:35:36 +00:00
|
|
|
* This file is part of PlantUML.
|
|
|
|
*
|
|
|
|
* PlantUML is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* PlantUML distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
2013-12-10 19:36:50 +00:00
|
|
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
2010-11-15 20:35:36 +00:00
|
|
|
* 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 java.util.ArrayList;
|
2017-03-15 19:13:31 +00:00
|
|
|
import java.util.Collections;
|
2010-11-15 20:35:36 +00:00
|
|
|
import java.util.List;
|
|
|
|
|
2011-09-07 20:41:58 +00:00
|
|
|
import net.sourceforge.plantuml.acearth.PSystemXearthFactory;
|
2010-11-15 20:35:36 +00:00
|
|
|
import net.sourceforge.plantuml.activitydiagram.ActivityDiagramFactory;
|
2013-12-10 19:36:50 +00:00
|
|
|
import net.sourceforge.plantuml.activitydiagram3.ActivityDiagramFactory3;
|
|
|
|
import net.sourceforge.plantuml.api.PSystemFactory;
|
2017-03-21 21:37:59 +00:00
|
|
|
import net.sourceforge.plantuml.bpm.BpmDiagramFactory;
|
2010-11-15 20:35:36 +00:00
|
|
|
import net.sourceforge.plantuml.classdiagram.ClassDiagramFactory;
|
|
|
|
import net.sourceforge.plantuml.compositediagram.CompositeDiagramFactory;
|
2013-12-10 19:36:50 +00:00
|
|
|
import net.sourceforge.plantuml.core.Diagram;
|
|
|
|
import net.sourceforge.plantuml.core.DiagramType;
|
|
|
|
import net.sourceforge.plantuml.core.UmlSource;
|
|
|
|
import net.sourceforge.plantuml.creole.PSystemCreoleFactory;
|
2015-04-07 18:18:37 +00:00
|
|
|
import net.sourceforge.plantuml.cute.PSystemCuteFactory;
|
2016-04-22 20:36:08 +00:00
|
|
|
import net.sourceforge.plantuml.dedication.PSystemDedicationFactory;
|
2017-04-05 17:37:42 +00:00
|
|
|
import net.sourceforge.plantuml.definition.PSystemDefinitionFactory;
|
2013-12-10 19:36:50 +00:00
|
|
|
import net.sourceforge.plantuml.descdiagram.DescriptionDiagramFactory;
|
2011-04-19 16:50:40 +00:00
|
|
|
import net.sourceforge.plantuml.directdot.PSystemDotFactory;
|
|
|
|
import net.sourceforge.plantuml.ditaa.PSystemDitaaFactory;
|
2013-12-10 19:36:50 +00:00
|
|
|
import net.sourceforge.plantuml.donors.PSystemDonorsFactory;
|
2017-11-20 16:10:36 +00:00
|
|
|
import net.sourceforge.plantuml.donors.PSystemSkinparameterListFactory;
|
2013-12-10 19:36:50 +00:00
|
|
|
import net.sourceforge.plantuml.eggs.PSystemAppleTwoFactory;
|
2015-04-07 18:18:37 +00:00
|
|
|
import net.sourceforge.plantuml.eggs.PSystemCharlieFactory;
|
2017-03-12 17:22:02 +00:00
|
|
|
import net.sourceforge.plantuml.eggs.PSystemColorsFactory;
|
2010-11-15 20:35:36 +00:00
|
|
|
import net.sourceforge.plantuml.eggs.PSystemEggFactory;
|
|
|
|
import net.sourceforge.plantuml.eggs.PSystemLostFactory;
|
|
|
|
import net.sourceforge.plantuml.eggs.PSystemPathFactory;
|
|
|
|
import net.sourceforge.plantuml.eggs.PSystemRIPFactory;
|
2017-03-21 21:37:59 +00:00
|
|
|
import net.sourceforge.plantuml.eggs.PSystemWelcomeFactory;
|
2013-12-10 19:36:50 +00:00
|
|
|
import net.sourceforge.plantuml.flowdiagram.FlowDiagramFactory;
|
|
|
|
import net.sourceforge.plantuml.font.PSystemListFontsFactory;
|
2011-09-07 20:41:58 +00:00
|
|
|
import net.sourceforge.plantuml.jcckit.PSystemJcckitFactory;
|
2015-04-07 18:18:37 +00:00
|
|
|
import net.sourceforge.plantuml.jungle.PSystemTreeFactory;
|
2013-12-10 19:36:50 +00:00
|
|
|
import net.sourceforge.plantuml.logo.PSystemLogoFactory;
|
2016-12-14 21:01:03 +00:00
|
|
|
import net.sourceforge.plantuml.math.PSystemLatexFactory;
|
2016-11-18 21:12:09 +00:00
|
|
|
import net.sourceforge.plantuml.math.PSystemMathFactory;
|
2015-04-07 18:18:37 +00:00
|
|
|
import net.sourceforge.plantuml.openiconic.PSystemListOpenIconicFactory;
|
|
|
|
import net.sourceforge.plantuml.openiconic.PSystemOpenIconicFactory;
|
2010-11-15 20:35:36 +00:00
|
|
|
import net.sourceforge.plantuml.oregon.PSystemOregonFactory;
|
2011-03-20 21:40:07 +00:00
|
|
|
import net.sourceforge.plantuml.postit.PostIdDiagramFactory;
|
2010-11-15 20:35:36 +00:00
|
|
|
import net.sourceforge.plantuml.printskin.PrintSkinFactory;
|
2017-02-01 18:55:51 +00:00
|
|
|
import net.sourceforge.plantuml.project3.GanttDiagramFactory;
|
2011-09-07 20:41:58 +00:00
|
|
|
import net.sourceforge.plantuml.salt.PSystemSaltFactory;
|
2010-11-15 20:35:36 +00:00
|
|
|
import net.sourceforge.plantuml.sequencediagram.SequenceDiagramFactory;
|
|
|
|
import net.sourceforge.plantuml.statediagram.StateDiagramFactory;
|
2016-12-01 20:29:25 +00:00
|
|
|
import net.sourceforge.plantuml.stats.StatsUtilsIncrement;
|
2010-11-15 20:35:36 +00:00
|
|
|
import net.sourceforge.plantuml.sudoku.PSystemSudokuFactory;
|
2017-02-01 18:55:51 +00:00
|
|
|
import net.sourceforge.plantuml.timingdiagram.TimingDiagramFactory;
|
2016-01-30 12:20:07 +00:00
|
|
|
import net.sourceforge.plantuml.ugraphic.sprite.PSystemListInternalSpritesFactory;
|
2013-12-10 19:36:50 +00:00
|
|
|
import net.sourceforge.plantuml.version.License;
|
|
|
|
import net.sourceforge.plantuml.version.PSystemLicenseFactory;
|
2010-11-15 20:35:36 +00:00
|
|
|
import net.sourceforge.plantuml.version.PSystemVersionFactory;
|
|
|
|
|
|
|
|
public class PSystemBuilder {
|
|
|
|
|
2015-04-07 18:18:37 +00:00
|
|
|
public static final long startTime = System.currentTimeMillis();
|
|
|
|
|
2017-06-05 11:27:21 +00:00
|
|
|
final public Diagram createPSystem(final List<CharSequence2> strings2, int startLine) {
|
2010-11-15 20:35:36 +00:00
|
|
|
|
2016-11-18 21:12:09 +00:00
|
|
|
final long now = System.currentTimeMillis();
|
2017-03-15 19:13:31 +00:00
|
|
|
|
2016-11-18 21:12:09 +00:00
|
|
|
Diagram result = null;
|
|
|
|
try {
|
|
|
|
final DiagramType type = DiagramType.getTypeFromArobaseStart(strings2.get(0).toString2());
|
2017-06-05 11:27:21 +00:00
|
|
|
final UmlSource umlSource = new UmlSource(strings2, type == DiagramType.UML, startLine);
|
2017-03-15 19:13:31 +00:00
|
|
|
|
2017-06-05 11:27:21 +00:00
|
|
|
// int cpt = 0;
|
2017-03-15 19:13:31 +00:00
|
|
|
for (CharSequence2 s : strings2) {
|
|
|
|
if (s.getPreprocessorError() != null) {
|
2017-04-19 18:30:16 +00:00
|
|
|
Log.error("Preprocessor Error: " + s.getPreprocessorError());
|
2017-06-05 11:27:21 +00:00
|
|
|
final ErrorUml err = new ErrorUml(ErrorUmlType.SYNTAX_ERROR, s.getPreprocessorError(), /* cpt */
|
|
|
|
s.getLocation());
|
|
|
|
return new PSystemError(umlSource, err, Collections.<String> emptyList());
|
2017-03-15 19:13:31 +00:00
|
|
|
}
|
2017-06-05 11:27:21 +00:00
|
|
|
// cpt++;
|
2017-03-15 19:13:31 +00:00
|
|
|
}
|
|
|
|
|
2016-11-18 21:12:09 +00:00
|
|
|
final DiagramType diagramType = umlSource.getDiagramType();
|
|
|
|
final List<PSystemError> errors = new ArrayList<PSystemError>();
|
2017-03-15 19:13:31 +00:00
|
|
|
final List<PSystemFactory> factories = getAllFactories();
|
2016-11-18 21:12:09 +00:00
|
|
|
for (PSystemFactory systemFactory : factories) {
|
|
|
|
if (diagramType != systemFactory.getDiagramType()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
final Diagram sys = systemFactory.createSystem(umlSource);
|
|
|
|
if (isOk(sys)) {
|
|
|
|
result = sys;
|
|
|
|
return sys;
|
|
|
|
}
|
|
|
|
errors.add((PSystemError) sys);
|
2011-08-08 17:48:29 +00:00
|
|
|
}
|
2016-11-18 21:12:09 +00:00
|
|
|
|
|
|
|
final PSystemError err = PSystemError.merge(errors);
|
|
|
|
result = err;
|
|
|
|
return err;
|
|
|
|
} finally {
|
2016-12-14 21:01:03 +00:00
|
|
|
if (result != null && OptionFlags.getInstance().isEnableStats()) {
|
2016-12-01 20:29:25 +00:00
|
|
|
StatsUtilsIncrement.onceMoreParse(System.currentTimeMillis() - now, result.getClass());
|
2011-08-08 17:48:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
private List<PSystemFactory> getAllFactories() {
|
2010-11-15 20:35:36 +00:00
|
|
|
final List<PSystemFactory> factories = new ArrayList<PSystemFactory>();
|
2017-03-15 19:13:31 +00:00
|
|
|
factories.add(new PSystemWelcomeFactory());
|
2017-03-12 17:22:02 +00:00
|
|
|
factories.add(new PSystemColorsFactory());
|
2010-11-15 20:35:36 +00:00
|
|
|
factories.add(new SequenceDiagramFactory());
|
|
|
|
factories.add(new ClassDiagramFactory());
|
|
|
|
factories.add(new ActivityDiagramFactory());
|
2013-12-10 19:36:50 +00:00
|
|
|
factories.add(new DescriptionDiagramFactory());
|
2010-11-15 20:35:36 +00:00
|
|
|
factories.add(new StateDiagramFactory());
|
2013-12-10 19:36:50 +00:00
|
|
|
factories.add(new ActivityDiagramFactory3());
|
2010-11-15 20:35:36 +00:00
|
|
|
factories.add(new CompositeDiagramFactory());
|
2016-01-09 12:15:40 +00:00
|
|
|
// factories.add(new ObjectDiagramFactory());
|
2017-03-21 21:37:59 +00:00
|
|
|
factories.add(new BpmDiagramFactory(DiagramType.BPM));
|
2011-03-20 21:40:07 +00:00
|
|
|
factories.add(new PostIdDiagramFactory());
|
2010-11-15 20:35:36 +00:00
|
|
|
factories.add(new PrintSkinFactory());
|
2013-12-10 19:36:50 +00:00
|
|
|
factories.add(new PSystemLicenseFactory());
|
2010-11-15 20:35:36 +00:00
|
|
|
factories.add(new PSystemVersionFactory());
|
2013-12-10 19:36:50 +00:00
|
|
|
factories.add(new PSystemDonorsFactory());
|
2017-11-20 16:10:36 +00:00
|
|
|
factories.add(new PSystemSkinparameterListFactory());
|
2013-12-10 19:36:50 +00:00
|
|
|
factories.add(new PSystemListFontsFactory());
|
2015-04-07 18:18:37 +00:00
|
|
|
factories.add(new PSystemOpenIconicFactory());
|
|
|
|
factories.add(new PSystemListOpenIconicFactory());
|
2016-01-30 12:20:07 +00:00
|
|
|
factories.add(new PSystemListInternalSpritesFactory());
|
2011-09-07 20:41:58 +00:00
|
|
|
factories.add(new PSystemSaltFactory(DiagramType.SALT));
|
|
|
|
factories.add(new PSystemSaltFactory(DiagramType.UML));
|
2011-04-19 16:50:40 +00:00
|
|
|
factories.add(new PSystemDotFactory(DiagramType.DOT));
|
|
|
|
factories.add(new PSystemDotFactory(DiagramType.UML));
|
2016-07-04 19:06:50 +00:00
|
|
|
if (License.getCurrent() == License.GPL || License.getCurrent() == License.GPLV2) {
|
2013-12-10 19:36:50 +00:00
|
|
|
factories.add(new PSystemDitaaFactory(DiagramType.DITAA));
|
|
|
|
factories.add(new PSystemDitaaFactory(DiagramType.UML));
|
|
|
|
factories.add(new PSystemJcckitFactory(DiagramType.JCCKIT));
|
|
|
|
factories.add(new PSystemJcckitFactory(DiagramType.UML));
|
|
|
|
factories.add(new PSystemLogoFactory());
|
|
|
|
factories.add(new PSystemSudokuFactory());
|
|
|
|
}
|
2017-04-05 17:37:42 +00:00
|
|
|
factories.add(new PSystemDefinitionFactory());
|
2016-11-18 21:12:09 +00:00
|
|
|
factories.add(new PSystemMathFactory(DiagramType.MATH));
|
2016-12-14 21:01:03 +00:00
|
|
|
factories.add(new PSystemLatexFactory(DiagramType.LATEX));
|
2016-12-01 20:29:25 +00:00
|
|
|
// factories.add(new PSystemStatsFactory());
|
2013-12-10 19:36:50 +00:00
|
|
|
factories.add(new PSystemCreoleFactory());
|
2010-11-15 20:35:36 +00:00
|
|
|
factories.add(new PSystemEggFactory());
|
2013-12-10 19:36:50 +00:00
|
|
|
factories.add(new PSystemAppleTwoFactory());
|
2010-11-15 20:35:36 +00:00
|
|
|
factories.add(new PSystemRIPFactory());
|
|
|
|
factories.add(new PSystemLostFactory());
|
|
|
|
factories.add(new PSystemPathFactory());
|
|
|
|
factories.add(new PSystemOregonFactory());
|
2015-04-07 18:18:37 +00:00
|
|
|
factories.add(new PSystemCharlieFactory());
|
2016-07-04 19:06:50 +00:00
|
|
|
if (License.getCurrent() == License.GPL || License.getCurrent() == License.GPLV2) {
|
2013-12-10 19:36:50 +00:00
|
|
|
factories.add(new PSystemXearthFactory());
|
|
|
|
}
|
2017-11-20 16:10:36 +00:00
|
|
|
factories.add(new GanttDiagramFactory(DiagramType.GANTT));
|
|
|
|
factories.add(new GanttDiagramFactory(DiagramType.UML));
|
2013-12-10 19:36:50 +00:00
|
|
|
factories.add(new FlowDiagramFactory());
|
2015-04-07 18:18:37 +00:00
|
|
|
factories.add(new PSystemTreeFactory(DiagramType.JUNGLE));
|
|
|
|
factories.add(new PSystemCuteFactory(DiagramType.CUTE));
|
2016-04-22 20:36:08 +00:00
|
|
|
factories.add(new PSystemDedicationFactory());
|
2017-02-01 18:55:51 +00:00
|
|
|
factories.add(new TimingDiagramFactory());
|
2011-08-08 17:48:29 +00:00
|
|
|
return factories;
|
2010-11-15 20:35:36 +00:00
|
|
|
}
|
|
|
|
|
2013-12-10 19:36:50 +00:00
|
|
|
private boolean isOk(Diagram ps) {
|
2010-11-15 20:35:36 +00:00
|
|
|
if (ps == null || ps instanceof PSystemError) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|