1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-06-09 03:32:33 +00:00
plantuml/src/net/sourceforge/plantuml/project3/GanttDiagramFactory.java

142 lines
4.5 KiB
Java
Raw Normal View History

2017-02-01 18:55:51 +00:00
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
2019-01-16 18:34:41 +00:00
* (C) Copyright 2009-2020, Arnaud Roques
2017-02-01 18:55:51 +00:00
*
* Project Info: http://plantuml.com
*
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
*
2017-02-01 18:55:51 +00:00
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.project3;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import net.sourceforge.plantuml.command.Command;
import net.sourceforge.plantuml.command.CommandNope;
2018-01-28 22:08:15 +00:00
import net.sourceforge.plantuml.command.CommandScale;
2017-02-01 18:55:51 +00:00
import net.sourceforge.plantuml.command.UmlDiagramFactory;
import net.sourceforge.plantuml.core.DiagramType;
public class GanttDiagramFactory extends UmlDiagramFactory {
2019-03-29 22:14:07 +00:00
static private final List<SubjectPattern> subjects() {
2018-04-06 20:36:30 +00:00
return Arrays.<SubjectPattern> asList(new SubjectTask(), new SubjectProject(), new SubjectDayOfWeek(),
2019-02-09 21:56:24 +00:00
new SubjectDayAsDate(), new SubjectDaysAsDates(), new SubjectResource(), new SubjectToday());
2017-02-01 18:55:51 +00:00
}
2017-11-20 16:10:36 +00:00
public GanttDiagramFactory(DiagramType type) {
super(type);
2017-02-01 18:55:51 +00:00
}
@Override
protected List<Command> createCommands() {
final List<Command> cmds = new ArrayList<Command>();
2019-04-21 20:40:01 +00:00
addTitleCommands(cmds);
2018-04-06 20:36:30 +00:00
// addCommonCommands(cmds);
2017-02-01 18:55:51 +00:00
cmds.add(new CommandNope());
2018-04-06 20:36:30 +00:00
// cmds.add(new CommandComment());
// cmds.add(new CommandMultilinesComment());
2019-07-14 20:09:26 +00:00
cmds.addAll(getLanguageCommands());
2017-11-20 16:10:36 +00:00
cmds.add(new CommandGanttArrow());
2018-04-06 20:36:30 +00:00
cmds.add(new CommandGanttArrow2());
cmds.add(new CommandSeparator());
2018-01-28 22:08:15 +00:00
cmds.add(new CommandScale());
2018-04-06 20:36:30 +00:00
cmds.add(new CommandPage());
// cmds.add(new CommandScaleWidthAndHeight());
// cmds.add(new CommandScaleWidthOrHeight());
// cmds.add(new CommandScaleMaxWidth());
// cmds.add(new CommandScaleMaxHeight());
// cmds.add(new CommandScaleMaxWidthAndHeight());
2018-01-28 22:08:15 +00:00
2017-02-01 18:55:51 +00:00
return cmds;
}
2019-07-14 20:09:26 +00:00
static private final Collection<Command> cache = new ArrayList<Command>();
2019-03-29 22:14:07 +00:00
private static Collection<Command> getLanguageCommands() {
2019-07-14 20:09:26 +00:00
synchronized (cache) {
if (cache.size() == 0) {
for (SubjectPattern subject : subjects()) {
for (VerbPattern verb : subject.getVerbs()) {
for (ComplementPattern complement : verb.getComplements()) {
cache.add(NaturalCommand.create(subject, verb, complement));
2017-02-01 18:55:51 +00:00
}
}
}
2019-07-14 20:09:26 +00:00
for (SubjectPattern subject : subjects()) {
final Collection<VerbPattern> verbs = subject.getVerbs();
for (VerbPattern verb1 : verbs) {
for (VerbPattern verb2 : verbs) {
if (verb1 == verb2) {
continue;
}
for (ComplementPattern complement1 : verb1.getComplements()) {
for (ComplementPattern complement2 : verb2.getComplements()) {
cache.add(NaturalCommandAnd.create(subject, verb1, complement1, verb2, complement2));
}
}
2017-02-01 18:55:51 +00:00
}
2019-07-14 20:09:26 +00:00
}
}
for (SubjectPattern subject : subjects()) {
final Collection<VerbPattern> verbs = subject.getVerbs();
for (VerbPattern verb1 : verbs) {
for (VerbPattern verb2 : verbs) {
for (VerbPattern verb3 : verbs) {
if (verb1 == verb2 || verb1 == verb3 || verb2 == verb3) {
continue;
}
for (ComplementPattern complement1 : verb1.getComplements()) {
for (ComplementPattern complement2 : verb2.getComplements()) {
for (ComplementPattern complement3 : verb3.getComplements()) {
cache.add(NaturalCommandAndAnd.create(subject, verb1, complement1, verb2,
complement2, verb3, complement3));
}
}
2017-02-01 18:55:51 +00:00
}
}
}
}
}
}
}
2019-07-14 20:09:26 +00:00
return cache;
2017-02-01 18:55:51 +00:00
}
@Override
public GanttDiagram createEmptyDiagram() {
return new GanttDiagram();
}
}