diff options
Diffstat (limited to 'src/net')
266 files changed, 72 insertions, 27908 deletions
diff --git a/src/net/sourceforge/plantuml/DirWatcher.java b/src/net/sourceforge/plantuml/DirWatcher.java index 3b681a6..73934e5 100644 --- a/src/net/sourceforge/plantuml/DirWatcher.java +++ b/src/net/sourceforge/plantuml/DirWatcher.java @@ -37,83 +37,77 @@ package net.sourceforge.plantuml; import java.io.File; import java.io.IOException; -import java.util.ArrayList; import java.util.Collections; -import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.TreeMap; +import java.util.concurrent.Callable; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; +import java.util.concurrent.TimeUnit; -import net.sourceforge.plantuml.preproc.Defines; import net.sourceforge.plantuml.preproc.FileWithSuffix; -@Deprecated public class DirWatcher { - final private File dir; - final private Option option; - final private String pattern; + private final File dir; + private final Option option; + private final String pattern; - final private Map<File, FileWatcher> modifieds = new HashMap<File, FileWatcher>(); + private final Map<File, FileWatcher> modifieds = new ConcurrentHashMap<File, FileWatcher>(); + private final ExecutorService executorService; public DirWatcher(File dir, Option option, String pattern) { this.dir = dir; this.option = option; this.pattern = pattern; - } - - public List<GeneratedImage> buildCreatedFiles() throws IOException, InterruptedException { - boolean error = false; - final List<GeneratedImage> result = new ArrayList<GeneratedImage>(); - for (File f : dir.listFiles()) { - if (error) { - continue; - } - if (f.isFile() == false) { - continue; - } - if (fileToProcess(f.getName()) == false) { - continue; - } - final FileWatcher watcher = modifieds.get(f); + final int nb = Option.defaultNbThreads(); + this.executorService = Executors.newFixedThreadPool(nb); - if (watcher == null || watcher.hasChanged()) { - final SourceFileReader sourceFileReader = new SourceFileReader(Defines.createWithFileName(f), f, - option.getOutputDir(), option.getConfig(), option.getCharset(), option.getFileFormatOption()); - final Set<File> files = FileWithSuffix.convert(sourceFileReader.getIncludedFiles()); - files.add(f); - for (GeneratedImage g : sourceFileReader.getGeneratedImages()) { - result.add(g); - if (option.isFailfastOrFailfast2() && g.lineErrorRaw() != -1) { - error = true; - } - } - modifieds.put(f, new FileWatcher(files)); - } - } - Collections.sort(result); - return Collections.unmodifiableList(result); } - public File getErrorFile() throws IOException, InterruptedException { - for (File f : dir.listFiles()) { - if (f.isFile() == false) { - continue; - } - if (fileToProcess(f.getName()) == false) { - continue; - } - final FileWatcher watcher = modifieds.get(f); + public Map<File, Future<List<GeneratedImage>>> buildCreatedFiles() throws IOException { + final Map<File, Future<List<GeneratedImage>>> result = new TreeMap<File, Future<List<GeneratedImage>>>(); + if (dir.listFiles() != null) { + for (final File f : dir.listFiles()) { + if (!f.isFile()) { + continue; + } + if (!fileToProcess(f.getName())) { + continue; + } + final FileWatcher watcher = modifieds.get(f); - if (watcher == null || watcher.hasChanged()) { - final SourceFileReader sourceFileReader = new SourceFileReader(Defines.createWithFileName(f), f, - option.getOutputDir(), option.getConfig(), option.getCharset(), option.getFileFormatOption()); - if (sourceFileReader.hasError()) { - return f; + if (watcher == null || watcher.hasChanged()) { + final SourceFileReader sourceFileReader = new SourceFileReader(option.getDefaultDefines(f), f, + option.getOutputDir(), option.getConfig(), option.getCharset(), + option.getFileFormatOption()); + modifieds.put(f, new FileWatcher(Collections.singleton(f))); + final Future<List<GeneratedImage>> value = executorService + .submit(new Callable<List<GeneratedImage>>() { + public List<GeneratedImage> call() { + try { + final List<GeneratedImage> generatedImages = sourceFileReader + .getGeneratedImages(); + final Set<File> files = FileWithSuffix.convert(sourceFileReader + .getIncludedFiles()); + files.add(f); + modifieds.put(f, new FileWatcher(files)); + return Collections.unmodifiableList(generatedImages); + } catch (Exception e) { + e.printStackTrace(); + return Collections.emptyList(); + } + } + }); + result.put(f, value); } } } - return null; + return Collections.unmodifiableMap(result); } private boolean fileToProcess(String name) { @@ -124,7 +118,13 @@ public class DirWatcher { return dir; } - // public void setPattern(String pattern) { - // this.pattern = pattern; - // } + public void cancel() { + executorService.shutdownNow(); + } + + public void waitEnd() throws InterruptedException { + executorService.shutdown(); + executorService.awaitTermination(Long.MAX_VALUE, TimeUnit.MILLISECONDS); + } + } diff --git a/src/net/sourceforge/plantuml/DirWatcher2.java b/src/net/sourceforge/plantuml/DirWatcher2.java deleted file mode 100644 index 2e3c6b6..0000000 --- a/src/net/sourceforge/plantuml/DirWatcher2.java +++ /dev/null @@ -1,130 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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 java.io.File; -import java.io.IOException; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.TreeMap; -import java.util.concurrent.Callable; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; -import java.util.concurrent.TimeUnit; - -import net.sourceforge.plantuml.preproc.FileWithSuffix; - -public class DirWatcher2 { - - final private File dir; - final private Option option; - final private String pattern; - - final private Map<File, FileWatcher> modifieds = new ConcurrentHashMap<File, FileWatcher>(); - final private ExecutorService executorService; - - public DirWatcher2(File dir, Option option, String pattern) { - this.dir = dir; - this.option = option; - this.pattern = pattern; - final int nb = Option.defaultNbThreads(); - this.executorService = Executors.newFixedThreadPool(nb); - - } - - public Map<File, Future<List<GeneratedImage>>> buildCreatedFiles() throws IOException, InterruptedException { - final Map<File, Future<List<GeneratedImage>>> result = new TreeMap<File, Future<List<GeneratedImage>>>(); - if (dir.listFiles() != null) { - for (final File f : dir.listFiles()) { - if (f.isFile() == false) { - continue; - } - if (fileToProcess(f.getName()) == false) { - continue; - } - final FileWatcher watcher = modifieds.get(f); - - if (watcher == null || watcher.hasChanged()) { - final SourceFileReader sourceFileReader = new SourceFileReader(option.getDefaultDefines(f), f, - option.getOutputDir(), option.getConfig(), option.getCharset(), - option.getFileFormatOption()); - modifieds.put(f, new FileWatcher(Collections.singleton(f))); - final Future<List<GeneratedImage>> value = executorService - .submit(new Callable<List<GeneratedImage>>() { - public List<GeneratedImage> call() throws Exception { - try { - final List<GeneratedImage> generatedImages = sourceFileReader - .getGeneratedImages(); - final Set<File> files = FileWithSuffix.convert(sourceFileReader - .getIncludedFiles()); - files.add(f); - modifieds.put(f, new FileWatcher(files)); - return Collections.unmodifiableList(generatedImages); - } catch (Exception e) { - e.printStackTrace(); - return Collections.emptyList(); - } - } - }); - result.put(f, value); - } - } - } - return Collections.unmodifiableMap(result); - } - - private boolean fileToProcess(String name) { - return name.matches(pattern); - } - - public final File getDir() { - return dir; - } - - public void cancel() { - executorService.shutdownNow(); - } - - public void waitEnd() throws InterruptedException { - executorService.shutdown(); - executorService.awaitTermination(Long.MAX_VALUE, TimeUnit.MILLISECONDS); - } - -} diff --git a/src/net/sourceforge/plantuml/Option.java b/src/net/sourceforge/plantuml/Option.java index 4bb0e8d..55f150f 100644 --- a/src/net/sourceforge/plantuml/Option.java +++ b/src/net/sourceforge/plantuml/Option.java @@ -77,7 +77,6 @@ public class Option { private boolean splash = false; private boolean textProgressBar = false; private int nbThreads = 0; - private int ftpPort = -1; private boolean hideMetadata = false; private boolean checkMetadata = false; private int imageIndex = 0; @@ -353,13 +352,6 @@ public class Option { if (nb.matches("\\d+")) { this.imageIndex = Integer.parseInt(nb); } - } else if (StringUtils.goLowerCase(s).startsWith("-ftp")) { - final int x = s.indexOf(':'); - if (x == -1) { - this.ftpPort = 4242; - } else { - this.ftpPort = Integer.parseInt(s.substring(x + 1)); - } } else if (s.startsWith("-c")) { s = s.substring(2); config.add(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(s)); @@ -369,10 +361,6 @@ public class Option { } } - public int getFtpPort() { - return ftpPort; - } - private void addInConfig(final FileReader source) throws IOException { BufferedReader br = null; try { diff --git a/src/net/sourceforge/plantuml/PSystemBuilder.java b/src/net/sourceforge/plantuml/PSystemBuilder.java index 41abd02..b0e7545 100644 --- a/src/net/sourceforge/plantuml/PSystemBuilder.java +++ b/src/net/sourceforge/plantuml/PSystemBuilder.java @@ -35,11 +35,6 @@ */ package net.sourceforge.plantuml; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import net.sourceforge.plantuml.acearth.PSystemXearthFactory; import net.sourceforge.plantuml.activitydiagram.ActivityDiagramFactory; import net.sourceforge.plantuml.activitydiagram3.ActivityDiagramFactory3; import net.sourceforge.plantuml.api.PSystemFactory; @@ -58,13 +53,6 @@ import net.sourceforge.plantuml.directdot.PSystemDotFactory; import net.sourceforge.plantuml.ditaa.PSystemDitaaFactory; import net.sourceforge.plantuml.donors.PSystemDonorsFactory; import net.sourceforge.plantuml.donors.PSystemSkinparameterListFactory; -import net.sourceforge.plantuml.eggs.PSystemAppleTwoFactory; -import net.sourceforge.plantuml.eggs.PSystemCharlieFactory; -import net.sourceforge.plantuml.eggs.PSystemColorsFactory; -import net.sourceforge.plantuml.eggs.PSystemEggFactory; -import net.sourceforge.plantuml.eggs.PSystemLostFactory; -import net.sourceforge.plantuml.eggs.PSystemPathFactory; -import net.sourceforge.plantuml.eggs.PSystemRIPFactory; import net.sourceforge.plantuml.eggs.PSystemWelcomeFactory; import net.sourceforge.plantuml.flowdiagram.FlowDiagramFactory; import net.sourceforge.plantuml.font.PSystemListFontsFactory; @@ -76,7 +64,6 @@ import net.sourceforge.plantuml.math.PSystemMathFactory; import net.sourceforge.plantuml.nwdiag.NwDiagramFactory; import net.sourceforge.plantuml.openiconic.PSystemListOpenIconicFactory; import net.sourceforge.plantuml.openiconic.PSystemOpenIconicFactory; -import net.sourceforge.plantuml.oregon.PSystemOregonFactory; import net.sourceforge.plantuml.postit.PostIdDiagramFactory; import net.sourceforge.plantuml.printskin.PrintSkinFactory; import net.sourceforge.plantuml.project3.GanttDiagramFactory; @@ -84,13 +71,16 @@ import net.sourceforge.plantuml.salt.PSystemSaltFactory; import net.sourceforge.plantuml.sequencediagram.SequenceDiagramFactory; import net.sourceforge.plantuml.statediagram.StateDiagramFactory; import net.sourceforge.plantuml.stats.StatsUtilsIncrement; -import net.sourceforge.plantuml.sudoku.PSystemSudokuFactory; import net.sourceforge.plantuml.timingdiagram.TimingDiagramFactory; import net.sourceforge.plantuml.ugraphic.sprite.PSystemListInternalSpritesFactory; import net.sourceforge.plantuml.version.License; import net.sourceforge.plantuml.version.PSystemLicenseFactory; import net.sourceforge.plantuml.version.PSystemVersionFactory; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + public class PSystemBuilder { public static final long startTime = System.currentTimeMillis(); @@ -144,7 +134,6 @@ public class PSystemBuilder { private List<PSystemFactory> getAllFactories() { final List<PSystemFactory> factories = new ArrayList<PSystemFactory>(); factories.add(new PSystemWelcomeFactory()); - factories.add(new PSystemColorsFactory()); factories.add(new SequenceDiagramFactory()); factories.add(new ClassDiagramFactory()); factories.add(new ActivityDiagramFactory()); @@ -175,23 +164,12 @@ public class PSystemBuilder { factories.add(new PSystemJcckitFactory(DiagramType.JCCKIT)); factories.add(new PSystemJcckitFactory(DiagramType.UML)); factories.add(new PSystemLogoFactory()); - factories.add(new PSystemSudokuFactory()); } factories.add(new PSystemDefinitionFactory()); factories.add(new PSystemMathFactory(DiagramType.MATH)); factories.add(new PSystemLatexFactory(DiagramType.LATEX)); // factories.add(new PSystemStatsFactory()); factories.add(new PSystemCreoleFactory()); - factories.add(new PSystemEggFactory()); - factories.add(new PSystemAppleTwoFactory()); - factories.add(new PSystemRIPFactory()); - factories.add(new PSystemLostFactory()); - factories.add(new PSystemPathFactory()); - factories.add(new PSystemOregonFactory()); - factories.add(new PSystemCharlieFactory()); - if (License.getCurrent() == License.GPL || License.getCurrent() == License.GPLV2) { - factories.add(new PSystemXearthFactory()); - } factories.add(new GanttDiagramFactory(DiagramType.GANTT)); factories.add(new GanttDiagramFactory(DiagramType.UML)); factories.add(new FlowDiagramFactory()); diff --git a/src/net/sourceforge/plantuml/QString.java b/src/net/sourceforge/plantuml/QString.java deleted file mode 100644 index caeaea5..0000000 --- a/src/net/sourceforge/plantuml/QString.java +++ /dev/null @@ -1,90 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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; - -public class QString { - - private final String data; - private final long mask; - - public QString(String data) { - this.data = data; - this.mask = getMask(data); - } - - @Override - public String toString() { - return data; - } - - public boolean containsQ(QString other) { - if ((this.mask & other.mask) != other.mask) { - return false; - } - return this.data.contains(other.data); - } - - static long getMask(String s) { - long result = 0; - for (int i = 0; i < s.length(); i++) { - result |= getMask(s.charAt(i)); - } - return result; - } - - static long getMask(char c) { - if (c >= '0' && c <= '9') { - final int n = c - '0'; - return 1L << n; - } - if (c >= 'a' && c <= 'z') { - final int n = c - 'a' + 10; - return 1L << n; - } - if (c >= 'A' && c <= 'Z') { - final int n = c - 'A' + 10 + 26; - return 1L << n; - } - if (c == '_') { - return 1L << (10 + 26 + 26); - } - if (c == '(') { - return 1L << 63; - } - return 0; - } - -} diff --git a/src/net/sourceforge/plantuml/Run.java b/src/net/sourceforge/plantuml/Run.java index e19d033..de2a827 100644 --- a/src/net/sourceforge/plantuml/Run.java +++ b/src/net/sourceforge/plantuml/Run.java @@ -62,7 +62,6 @@ import net.sourceforge.plantuml.code.Transcoder; import net.sourceforge.plantuml.code.TranscoderUtil; import net.sourceforge.plantuml.command.UmlDiagramFactory; import net.sourceforge.plantuml.descdiagram.DescriptionDiagramFactory; -import net.sourceforge.plantuml.ftp.FtpServer; import net.sourceforge.plantuml.objectdiagram.ObjectDiagramFactory; import net.sourceforge.plantuml.png.MetadataTag; import net.sourceforge.plantuml.preproc.Stdlib; @@ -136,11 +135,6 @@ public class Run { return; } - if (option.getFtpPort() != -1) { - goFtp(option); - return; - } - forceOpenJdkResourceLoad(); if (option.getPreprocessorOutputMode() == OptionPreprocOutputMode.CYPHER) { cypher = new LanguageDescriptor().getCypher(); @@ -311,13 +305,6 @@ public class Run { return sb.toString(); } - private static void goFtp(Option option) throws IOException { - final int ftpPort = option.getFtpPort(); - System.err.println("ftpPort=" + ftpPort); - final FtpServer ftpServer = new FtpServer(ftpPort, option.getFileFormatOption().getFileFormat()); - ftpServer.go(); - } - public static void printFonts() { final Font fonts[] = GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts(); for (Font f : fonts) { diff --git a/src/net/sourceforge/plantuml/SingleLine.java b/src/net/sourceforge/plantuml/SingleLine.java deleted file mode 100644 index b11916f..0000000 --- a/src/net/sourceforge/plantuml/SingleLine.java +++ /dev/null @@ -1,43 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.Diagram; - -public interface SingleLine { - - Diagram getSystemFromSingleLine(String singleLine); -} diff --git a/src/net/sourceforge/plantuml/acearth/PSystemXearth.java b/src/net/sourceforge/plantuml/acearth/PSystemXearth.java deleted file mode 100644 index fc3a861..0000000 --- a/src/net/sourceforge/plantuml/acearth/PSystemXearth.java +++ /dev/null @@ -1,133 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.acearth; - -import java.io.IOException; -import java.io.OutputStream; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Arrays; -import java.util.Collection; -import java.util.Date; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.TimeZone; - -import net.sourceforge.plantuml.AbstractPSystem; -import net.sourceforge.plantuml.FileFormatOption; -import net.sourceforge.plantuml.api.ImageDataSimple; -import net.sourceforge.plantuml.core.DiagramDescription; -import net.sourceforge.plantuml.core.ImageData; - -import ext.plantuml.com.ctreber.acearth.ACearth; -import ext.plantuml.com.ctreber.acearth.ConfigurationACearth; -import ext.plantuml.com.ctreber.acearth.plugins.markers.Marker; - -public class PSystemXearth extends AbstractPSystem { - - final private int width; - final private int height; - final private Map<String, String> config; - final private List<Marker> markers; - - final private Collection<String> enums = Arrays.asList("viewPositionType"); - final private Collection<String> doubles = Arrays.asList("sunPosRelLat", "sunPosRelLong", "orbitPeriod", - "orbitInclination", "viewPosLat", "viewPosLong", "starFrequency", "viewMagnification"); - final private Collection<String> integers = Arrays.asList("daySideBrightness", "nightSideBrightness", - "terminatorDiscontinuity", "gridDivision", "gridPixelDivision", "bigStars"); - final private Collection<String> booleans = Arrays.asList("shadeP", "gridP", "starsP"); - - public PSystemXearth(int width, int height, Map<String, String> config, List<Marker> markers) { - this.width = width; - this.height = height; - this.config = config; - this.markers = markers; - } - - @Override - final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed) - throws IOException { - final ACearth earth = new ACearth(markers); - final ConfigurationACearth conf = earth.getConf(); - conf.setInt("imageWidth", width); - conf.setInt("imageHeight", height); - - for (Map.Entry<String, String> ent : config.entrySet()) { - final String key = ent.getKey(); - final String value = ent.getValue(); - if (key.equalsIgnoreCase("GMT")) { - final Date date = extractGmt(value); - conf.setInt("fixedTime", (int) (date.getTime() / 1000L)); - } else if (enums.contains(key)) { - conf.getMOEnum(key).set(value); - } else if (doubles.contains(key)) { - conf.setDouble(key, Double.parseDouble(value)); - } else if (integers.contains(key)) { - conf.setInt(key, Integer.parseInt(value)); - } else if (booleans.contains(key)) { - conf.setBoolean(key, value.equalsIgnoreCase("true")); - } else { - throw new UnsupportedOperationException(key); - } - } - earth.exportPng(os); - return new ImageDataSimple(width, height); - } - - private Date extractGmt(String s) { - final SimpleDateFormat timeFormat; - if (s.matches("\\d{4}/\\d{2}/\\d{2} \\d{2}:\\d{2}:\\d{2}")) { - timeFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss", Locale.US); - } else if (s.matches("\\d{4}/\\d{2}/\\d{2} \\d{2}:\\d{2}")) { - timeFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm", Locale.US); - } else { - throw new UnsupportedOperationException(s); - } - timeFormat.setTimeZone(TimeZone.getTimeZone("GMT")); - try { - return timeFormat.parse(s); - } catch (ParseException e) { - throw new UnsupportedOperationException(s); - } - - } - - public DiagramDescription getDescription() { - return new DiagramDescription("(XEarth)"); - } - -} diff --git a/src/net/sourceforge/plantuml/acearth/PSystemXearthFactory.java b/src/net/sourceforge/plantuml/acearth/PSystemXearthFactory.java deleted file mode 100644 index a4cfd66..0000000 --- a/src/net/sourceforge/plantuml/acearth/PSystemXearthFactory.java +++ /dev/null @@ -1,107 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.acearth; - -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - -import net.sourceforge.plantuml.command.PSystemBasicFactory; -import net.sourceforge.plantuml.command.regex.Matcher2; -import net.sourceforge.plantuml.command.regex.MyPattern; -import net.sourceforge.plantuml.command.regex.Pattern2; - -import ext.plantuml.com.ctreber.acearth.plugins.markers.Marker; - -public class PSystemXearthFactory extends PSystemBasicFactory<PSystemXearth> { - - private final Map<String, String> config = new LinkedHashMap<String, String>(); - private final List<Marker> markers = new ArrayList<Marker>(); - private int width; - private int height; - - public PSystemXearth init(String startLine) { - this.width = 512; - this.height = 512; - this.config.clear(); - this.markers.clear(); - return null; - } - - private void extractDimension(String startLine) { - final Pattern2 p = MyPattern.cmpile("\\((\\d+),(\\d+)\\)"); - final Matcher2 m = p.matcher(startLine); - final boolean ok = m.find(); - if (ok) { - width = Integer.parseInt(m.group(1)); - height = Integer.parseInt(m.group(2)); - } - } - - @Override - public PSystemXearth executeLine(PSystemXearth system, String line) { - if (system == null && line.startsWith("xearth")) { - extractDimension(line); - system = new PSystemXearth(width, height, config, markers); - return system; - } - if (system == null) { - return null; - } - if (line.startsWith("#") || line.startsWith("'")) { - return system; - } - final Pattern2 p = MyPattern.cmpile("(\\w+)[%s]*=[%s]*(.*)"); - final Matcher2 m = p.matcher(line); - if (m.find()) { - config.put(m.group(1), m.group(2)); - return system; - } - try { - final Marker marker = Marker.loadMarkerFile(line); - if (marker != null) { - markers.add(marker); - return system; - } - } catch (Exception e) { - e.printStackTrace(); - return null; - } - return null; - } - -} diff --git a/src/net/sourceforge/plantuml/api/CountRate.java b/src/net/sourceforge/plantuml/api/CountRate.java deleted file mode 100644 index 6f8264d..0000000 --- a/src/net/sourceforge/plantuml/api/CountRate.java +++ /dev/null @@ -1,82 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.api; - -public final class CountRate { - - private final MagicArray lastMinute = new MagicArray(60); - private final MagicArray lastHour = new MagicArray(60); - private final MagicArray lastDay = new MagicArray(140); - - public void increment() { - final long now = System.currentTimeMillis(); - lastMinute.incKey(now / 1000L); - lastHour.incKey(now / (60 * 1000L)); - lastDay.incKey(now / (10 * 60 * 1000L)); - } - - public void increment(int value) { - final long now = System.currentTimeMillis(); - lastMinute.incKey(now / 1000L, value); - lastHour.incKey(now / (60 * 1000L), value); - lastDay.incKey(now / (10 * 60 * 1000L), value); - } - - public long perMinute() { - return lastMinute.getSum(); - } - - public long perHour() { - return lastHour.getSum(); - } - - public long perDay() { - return lastDay.getSum(); - } - - public long perMinuteMax() { - return lastMinute.getMaxSum(); - } - - public long perHourMax() { - return lastHour.getMaxSum(); - } - - public long perDayMax() { - return lastDay.getMaxSum(); - } - -} diff --git a/src/net/sourceforge/plantuml/api/MagicArray.java b/src/net/sourceforge/plantuml/api/MagicArray.java deleted file mode 100644 index 55c3292..0000000 --- a/src/net/sourceforge/plantuml/api/MagicArray.java +++ /dev/null @@ -1,98 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.api; - -public final class MagicArray { - - private final int data[]; - private final int size; - private long lastUpdatedKey = -1; - private int lastUpdatedValue; - private long sum; - private long maxSum; - - public MagicArray(int size) { - this.data = new int[size]; - this.size = size; - } - - synchronized public void incKey(long key) { - incKey(key, 1); - } - - synchronized public void incKey(long key, int delta) { - if (key < lastUpdatedKey) { - return; - } - if (key != lastUpdatedKey) { - if (lastUpdatedKey != -1) { - setValue(lastUpdatedKey, lastUpdatedValue); - for (long i = lastUpdatedKey + 1; i < key; i++) { - setValue(i, 0); - } - } - lastUpdatedValue = 0; - lastUpdatedKey = key; - } - lastUpdatedValue += delta; - } - - private void setValue(long key, int value) { - final int i = (int) (key % size); - sum += value - data[i]; - if (sum > maxSum) { - maxSum = sum; - } - data[i] = value; - } - - synchronized public long getSum() { - return sum; - } - - synchronized public long getMaxSum() { - return maxSum; - } - - private long getSumSlow() { - long tmp = 0; - for (int d : data) { - tmp += d; - } - return tmp; - } - -} diff --git a/src/net/sourceforge/plantuml/api/NiceNumber.java b/src/net/sourceforge/plantuml/api/NiceNumber.java deleted file mode 100644 index dddccb8..0000000 --- a/src/net/sourceforge/plantuml/api/NiceNumber.java +++ /dev/null @@ -1,71 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.api; - -import java.text.DecimalFormat; -import java.text.DecimalFormatSymbols; -import java.util.Locale; - -public class NiceNumber { - - public static int getNicer(final int value) { - if (value <= 18) { - return value; - } - if (value < 93) { - return ((value + 2) / 5) * 5; - } - if (value < 100) { - return ((value + 5) / 10) * 10; - } - int m = 1; - double head = value; - while (head >= 100) { - head = head / 10.0; - m *= 10; - } - return getNicer((int) Math.round(head)) * m; - } - - public static String format(final long v) { - final DecimalFormat df = new DecimalFormat(); - df.setDecimalFormatSymbols(new DecimalFormatSymbols(Locale.US)); - df.setGroupingSize(3); - df.setMaximumFractionDigits(0); - final String t = df.format(v).replace(',', ' '); - return t; - } -} diff --git a/src/net/sourceforge/plantuml/api/NumberAnalyzed2.java b/src/net/sourceforge/plantuml/api/NumberAnalyzed2.java deleted file mode 100644 index c275066..0000000 --- a/src/net/sourceforge/plantuml/api/NumberAnalyzed2.java +++ /dev/null @@ -1,184 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * 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 Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU General Public - * License aint with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - * USA. - */ -package net.sourceforge.plantuml.api; - -import java.util.StringTokenizer; -import java.util.concurrent.atomic.AtomicLong; -import java.util.prefs.Preferences; - -import net.sourceforge.plantuml.Log; - -public class NumberAnalyzed2 implements INumberAnalyzed { - - private static final int SLIDING_WINDOW = 512; - - private final AtomicLong nb = new AtomicLong(); - private final AtomicLong sum = new AtomicLong(); - private final AtomicLong min = new AtomicLong(); - private final AtomicLong max = new AtomicLong(); - private final AtomicLong sumOfSquare = new AtomicLong(); - // See https://fossies.org/linux/haproxy/include/proto/freq_ctr.h - private final AtomicLong sliddingSum = new AtomicLong(); - private final String name; - - public NumberAnalyzed2(String name) { - this.name = name; - } - - public void reset() { - this.nb.set(0); - this.sum.set(0); - this.min.set(0); - this.max.set(0); - this.sumOfSquare.set(0); - this.sliddingSum.set(0); - } - - public NumberAnalyzed2() { - this(""); - } - - public final void save(Preferences prefs) { - if (name.length() == 0) { - throw new UnsupportedOperationException(); - } - prefs.put(name + ".saved", getSavedString()); - } - - protected String getSavedString() { - final String value = longToString(nb) + ";" + longToString(sum) + ";" + longToString(min) + ";" - + longToString(max) + ";" + longToString(sumOfSquare) + ";" + longToString(sliddingSum); - return value; - } - - protected final String longToString(AtomicLong val) { - return Long.toString(val.get(), 36); - } - - public static NumberAnalyzed2 load(String name, Preferences prefs) { - final String value = prefs.get(name + ".saved", ""); - if (value.length() == 0) { - System.err.println("Cannot load " + name); - return null; - } - try { - final StringTokenizer st = new StringTokenizer(value, ";"); - return new NumberAnalyzed2(name, Long.parseLong(st.nextToken(), 36), Long.parseLong(st.nextToken(), 36), - Long.parseLong(st.nextToken(), 36), Long.parseLong(st.nextToken(), 36), Long.parseLong( - st.nextToken(), 36), Long.parseLong(st.nextToken(), 36)); - } catch (Exception e) { - e.printStackTrace(); - Log.info("Error reading " + value); - return null; - } - } - - @Override - public String toString() { - return "sum=" + sum + " nb=" + nb + " min=" + min + " max=" + max + " mean=" + getMean(); - } - - protected NumberAnalyzed2(String name, long nb, long sum, long min, long max, long sumOfSquare, long sliddingSum) { - this(name); - this.nb.set(nb); - this.sum.set(sum); - this.min.set(min); - this.max.set(max); - this.sumOfSquare.set(sumOfSquare); - this.sliddingSum.set(sliddingSum); - } - - public INumberAnalyzed getCopyImmutable() { - final NumberAnalyzed2 copy = new NumberAnalyzed2(name, nb.get(), sum.get(), min.get(), max.get(), - sumOfSquare.get(), sliddingSum.get()); - return copy; - } - - public void addValue(long v) { - nb.incrementAndGet(); - if (nb.get() == 1) { - min.set(v); - max.set(v); - } else if (v > max.get()) { - max.set(v); - } else if (v < min.get()) { - min.set(v); - } - sum.addAndGet(v); - sumOfSquare.addAndGet(v * v); - sliddingSum.set(sliddingSum.get() * (SLIDING_WINDOW - 1) / SLIDING_WINDOW + v); - } - - public void add(NumberAnalyzed2 other) { - this.sum.addAndGet(other.sum.get()); - this.nb.addAndGet(other.nb.get()); - this.min.set(Math.min(this.min.get(), other.min.get())); - this.max.set(Math.max(this.max.get(), other.max.get())); - } - - public final long getNb() { - return nb.get(); - } - - public final long getSum() { - return sum.get(); - } - - public final long getMin() { - return min.get(); - } - - public final long getMax() { - return max.get(); - } - - public final long getMean() { - if (nb.get() == 0) { - return 0; - } - // Bad - return sum.get() / nb.get(); - } - - public final long getSliddingMean() { - if (nb.get() == 0) { - return 0; - } - if (nb.get() < SLIDING_WINDOW) { - return sum.get() / nb.get(); - } - // Bad - return sliddingSum.get() / nb.get(); - } - - final public String getName() { - return name; - } - -} diff --git a/src/net/sourceforge/plantuml/api/PlantumlUtils.java b/src/net/sourceforge/plantuml/api/PlantumlUtils.java deleted file mode 100644 index 5a02064..0000000 --- a/src/net/sourceforge/plantuml/api/PlantumlUtils.java +++ /dev/null @@ -1,60 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.api; - -import java.util.List; - -import net.sourceforge.plantuml.BlockUml; -import net.sourceforge.plantuml.SourceStringReader; -import net.sourceforge.plantuml.core.Diagram; - -public class PlantumlUtils { - - public static boolean hasCMapData(String uml) { - List<BlockUml> blocks = new SourceStringReader(uml).getBlocks(); - if (blocks.size() == 0) { - uml = "@startuml\n" + uml + "\n@enduml"; - blocks = new SourceStringReader(uml).getBlocks(); - if (blocks.size() == 0) { - return false; - } - } - final BlockUml block = blocks.get(0); - final Diagram diagram = block.getDiagram(); - return diagram.hasUrl(); - } - -} diff --git a/src/net/sourceforge/plantuml/api/mda/option2/MDADiagram.java b/src/net/sourceforge/plantuml/api/mda/option2/MDADiagram.java deleted file mode 100644 index 15fde47..0000000 --- a/src/net/sourceforge/plantuml/api/mda/option2/MDADiagram.java +++ /dev/null @@ -1,42 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.api.mda.option2; - -import java.util.Collection; - -public interface MDADiagram { - public Collection<MDAPackage> getPackages(); -} diff --git a/src/net/sourceforge/plantuml/api/mda/option2/MDAEntity.java b/src/net/sourceforge/plantuml/api/mda/option2/MDAEntity.java deleted file mode 100644 index c60f5e4..0000000 --- a/src/net/sourceforge/plantuml/api/mda/option2/MDAEntity.java +++ /dev/null @@ -1,41 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.api.mda.option2; - -public interface MDAEntity { - public String getName(); - -} diff --git a/src/net/sourceforge/plantuml/api/mda/option2/MDAPackage.java b/src/net/sourceforge/plantuml/api/mda/option2/MDAPackage.java deleted file mode 100644 index 0f7c3fb..0000000 --- a/src/net/sourceforge/plantuml/api/mda/option2/MDAPackage.java +++ /dev/null @@ -1,46 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.api.mda.option2; - -import java.util.Collection; - -public interface MDAPackage { - - public String getName(); - - public Collection<MDAEntity> getEntities(); - -} diff --git a/src/net/sourceforge/plantuml/api/mda/option2/MDAUtils.java b/src/net/sourceforge/plantuml/api/mda/option2/MDAUtils.java deleted file mode 100644 index e09f968..0000000 --- a/src/net/sourceforge/plantuml/api/mda/option2/MDAUtils.java +++ /dev/null @@ -1,45 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.api.mda.option2; - -import net.sourceforge.plantuml.mda.MDADiagramImpl; - -public class MDAUtils { - - public static MDADiagram getMDADiagram(String plantumlDiagramSource) { - return MDADiagramImpl.create(plantumlDiagramSource); - } -} diff --git a/src/net/sourceforge/plantuml/api/mda/option3/MDAVisitor.java b/src/net/sourceforge/plantuml/api/mda/option3/MDAVisitor.java deleted file mode 100644 index 5bbbec4..0000000 --- a/src/net/sourceforge/plantuml/api/mda/option3/MDAVisitor.java +++ /dev/null @@ -1,39 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.api.mda.option3; - -public interface MDAVisitor { -} diff --git a/src/net/sourceforge/plantuml/bpm/FootPrint.java b/src/net/sourceforge/plantuml/bpm/FootPrint.java deleted file mode 100644 index 1b8e30d..0000000 --- a/src/net/sourceforge/plantuml/bpm/FootPrint.java +++ /dev/null @@ -1,45 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.bpm; - -import java.util.HashSet; -import java.util.Set; - -public class FootPrint { - - private final Set<Coord> cells = new HashSet<Coord>(); - -} diff --git a/src/net/sourceforge/plantuml/code/Spiral.java b/src/net/sourceforge/plantuml/code/Spiral.java deleted file mode 100644 index 0ba7d43..0000000 --- a/src/net/sourceforge/plantuml/code/Spiral.java +++ /dev/null @@ -1,67 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.code; - -public class Spiral { - - private PairInt current = new PairInt(0, 0); - private PairInt direction = new PairInt(1, 0); - private int step = 0; - private int lim = 1; - private int len = 1; - private int cpt = 0; - - public PairInt nextPoint() { - final PairInt result = current; - oneStep(); - return result; - } - - private void oneStep() { - this.current = this.current.plus(this.direction); - step++; - if (step == lim) { - this.direction = this.direction.rotate(); - cpt++; - if (cpt == 2) { - cpt = 0; - len++; - } - lim += len; - } - } - -} diff --git a/src/net/sourceforge/plantuml/code/SpiralOnRectangle.java b/src/net/sourceforge/plantuml/code/SpiralOnRectangle.java deleted file mode 100644 index 5b3db4f..0000000 --- a/src/net/sourceforge/plantuml/code/SpiralOnRectangle.java +++ /dev/null @@ -1,65 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.code; - -public class SpiralOnRectangle { - - private final Spiral spiral = new Spiral(); - private final int width; - private final int height; - private final PairInt delta; - - public SpiralOnRectangle(int width, int height) { - this.width = width; - this.height = height; - this.delta = new PairInt(width / 2, height / 2); - } - - private boolean inside(PairInt point) { - final int x = point.getX(); - final int y = point.getY(); - return x >= 0 && x < width && y >= 0 && y < height; - } - - public PairInt nextPoint() { - do { - final PairInt result = spiral.nextPoint().plus(delta); - if (inside(result)) { - return result; - } - } while (true); - } -} diff --git a/src/net/sourceforge/plantuml/creole/UCreole.java b/src/net/sourceforge/plantuml/creole/UCreole.java deleted file mode 100644 index 5fab0ec..0000000 --- a/src/net/sourceforge/plantuml/creole/UCreole.java +++ /dev/null @@ -1,42 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.creole; - -import net.sourceforge.plantuml.ugraphic.UShape; - - -public interface UCreole extends UShape { -} diff --git a/src/net/sourceforge/plantuml/eggs/EggUtils.java b/src/net/sourceforge/plantuml/eggs/EggUtils.java deleted file mode 100644 index 780b829..0000000 --- a/src/net/sourceforge/plantuml/eggs/EggUtils.java +++ /dev/null @@ -1,102 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.eggs; - -import java.math.BigInteger; - -import net.sourceforge.plantuml.StringUtils; - -public class EggUtils { - - public static String fromByteArrays(byte data[]) { - final StringBuilder sb = new StringBuilder(); - for (byte b : data) { - final String hex = Integer.toHexString(b & 0xFF); - if (hex.length() == 1) { - sb.append('0'); - } - sb.append(hex); - } - return sb.toString(); - } - - public static byte[] toByteArrays(String s) { - final byte[] result = new byte[s.length() / 2]; - for (int i = 0; i < result.length; i++) { - result[i] = (byte) Integer.parseInt(s.substring(i * 2, i * 2 + 2), 16); - } - return result; - } - - public static BigInteger fromSecretSentence(String s) { - BigInteger result = BigInteger.ZERO; - final BigInteger twentySix = BigInteger.valueOf(26); - s = s.replace('\u00E9', 'e'); - s = s.replace('\u00EA', 'e'); - for (char c : s.toCharArray()) { - final int num = convertChar(c); - if (num != -1) { - result = result.multiply(twentySix); - result = result.add(BigInteger.valueOf(num)); - - } - } - return result; - - } - - private static int convertChar(char c) { - c = StringUtils.goLowerCase(c); - if (c >= 'a' && c <= 'z') { - return c - 'a'; - } - return -1; - } - - public static byte[] xor(byte data[], byte key[]) { - final byte[] result = new byte[data.length]; - int pos = 0; - for (int i = 0; i < result.length; i++) { - result[i] = (byte) (data[i] ^ key[pos++]); - if (pos == key.length) { - pos = 0; - } - - } - return result; - } - -} diff --git a/src/net/sourceforge/plantuml/eggs/GraphicsPath.java b/src/net/sourceforge/plantuml/eggs/GraphicsPath.java deleted file mode 100644 index 4def25a..0000000 --- a/src/net/sourceforge/plantuml/eggs/GraphicsPath.java +++ /dev/null @@ -1,84 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.eggs; - -import java.awt.Color; -import java.awt.Graphics2D; -import java.awt.image.BufferedImage; -import java.io.IOException; -import java.io.OutputStream; - -import net.sourceforge.plantuml.EmptyImageBuilder; -import net.sourceforge.plantuml.api.ImageDataSimple; -import net.sourceforge.plantuml.core.ImageData; -import net.sourceforge.plantuml.graphic.HtmlColorUtils; -import net.sourceforge.plantuml.png.PngIO; -import net.sourceforge.plantuml.ugraphic.ColorMapper; -import net.sourceforge.plantuml.ugraphic.UChangeColor; -import net.sourceforge.plantuml.ugraphic.UMotif; -import net.sourceforge.plantuml.ugraphic.g2d.UGraphicG2d; - -public class GraphicsPath { - - private final String path; - private final ColorMapper colorMapper; - - public GraphicsPath(ColorMapper colorMapper, String path) { - this.path = path; - this.colorMapper = colorMapper; - } - - public ImageData writeImage(OutputStream os) throws IOException { - final BufferedImage im = createImage(); - PngIO.write(im, os, 96); - return new ImageDataSimple(im.getWidth(), im.getHeight()); - } - - private BufferedImage createImage() { - final EmptyImageBuilder builder = new EmptyImageBuilder(50, 50, Color.WHITE); - final BufferedImage im = builder.getBufferedImage(); - final Graphics2D g2d = builder.getGraphics2D(); - - final UGraphicG2d ug = new UGraphicG2d(colorMapper, g2d, 1.0); - ug.setBufferedImage(im); - final UMotif motif = new UMotif(path); - motif.drawHorizontal(ug.apply(new UChangeColor(HtmlColorUtils.BLACK)), 20, 20, 1); - - g2d.dispose(); - return im; - } - -} diff --git a/src/net/sourceforge/plantuml/eggs/PSystemAppleTwo.java b/src/net/sourceforge/plantuml/eggs/PSystemAppleTwo.java deleted file mode 100644 index 436cb6b..0000000 --- a/src/net/sourceforge/plantuml/eggs/PSystemAppleTwo.java +++ /dev/null @@ -1,90 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.eggs; - -import java.awt.image.BufferedImage; -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.FileFormatOption; -import net.sourceforge.plantuml.core.DiagramDescription; -import net.sourceforge.plantuml.core.ImageData; -import net.sourceforge.plantuml.graphic.GraphicPosition; -import net.sourceforge.plantuml.graphic.GraphicStrings; -import net.sourceforge.plantuml.svek.TextBlockBackcolored; -import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity; -import net.sourceforge.plantuml.ugraphic.ImageBuilder; -import net.sourceforge.plantuml.version.PSystemVersion; - -public class PSystemAppleTwo extends AbstractPSystem { - - private final List<String> strings = new ArrayList<String>(); - private final BufferedImage image; - - public PSystemAppleTwo() throws IOException { - strings.add(" <b><size:18>Apple //e for ever ! "); - strings.add(" "); - - image = PSystemVersion.getApple2Image(); - } - - @Override - final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed) - throws IOException { - final TextBlockBackcolored result = getGraphicStrings(); - final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, result.getBackcolor(), - getMetadata(), null, 0, 0, null, false); - 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() { - return new DiagramDescription("(Apple //e)"); - } - -} diff --git a/src/net/sourceforge/plantuml/eggs/PSystemAppleTwoFactory.java b/src/net/sourceforge/plantuml/eggs/PSystemAppleTwoFactory.java deleted file mode 100644 index fda68bd..0000000 --- a/src/net/sourceforge/plantuml/eggs/PSystemAppleTwoFactory.java +++ /dev/null @@ -1,61 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.eggs; - -import java.io.IOException; - -import net.sourceforge.plantuml.AbstractPSystem; -import net.sourceforge.plantuml.Log; -import net.sourceforge.plantuml.command.PSystemSingleLineFactory; - -public class PSystemAppleTwoFactory extends PSystemSingleLineFactory { - - @Override - protected AbstractPSystem executeLine(String line) { - if (line.equalsIgnoreCase("apple //e") || line.equalsIgnoreCase("apple ][") - || line.equalsIgnoreCase("apple II") || line.equalsIgnoreCase("Steve Jobs") - || line.equalsIgnoreCase("Steve Wozniak")) { - try { - return new PSystemAppleTwo(); - } catch (IOException e) { - Log.error("Error " + e); - e.printStackTrace(); - } - } - return null; - } - -} diff --git a/src/net/sourceforge/plantuml/eggs/PSystemCharlie.java b/src/net/sourceforge/plantuml/eggs/PSystemCharlie.java deleted file mode 100644 index 92539d8..0000000 --- a/src/net/sourceforge/plantuml/eggs/PSystemCharlie.java +++ /dev/null @@ -1,80 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.eggs; - -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.core.DiagramDescription; -import net.sourceforge.plantuml.core.ImageData; -import net.sourceforge.plantuml.graphic.HtmlColorUtils; -import net.sourceforge.plantuml.graphic.UDrawable; -import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity; -import net.sourceforge.plantuml.ugraphic.ImageBuilder; -import net.sourceforge.plantuml.ugraphic.UGraphic; -import net.sourceforge.plantuml.ugraphic.UImage; -import net.sourceforge.plantuml.version.PSystemVersion; - -public class PSystemCharlie extends AbstractPSystem { - - private BufferedImage image; - - PSystemCharlie() { - image = PSystemVersion.getCharlieImage(); - } - - @Override - final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed) - throws IOException { - final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, HtmlColorUtils.BLACK, - getMetadata(), null, 0, 0, null, false); - imageBuilder.setUDrawable(new UDrawable() { - - public void drawU(UGraphic ug) { - final UImage im = new UImage(image); - ug.draw(im); - } - }); - return imageBuilder.writeImageTOBEMOVED(fileFormat, seed, os); - } - - public DiagramDescription getDescription() { - return new DiagramDescription("(Je Suis Charlie)"); - } - -} diff --git a/src/net/sourceforge/plantuml/eggs/PSystemCharlieFactory.java b/src/net/sourceforge/plantuml/eggs/PSystemCharlieFactory.java deleted file mode 100644 index e21bcb0..0000000 --- a/src/net/sourceforge/plantuml/eggs/PSystemCharlieFactory.java +++ /dev/null @@ -1,51 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.eggs; - -import net.sourceforge.plantuml.AbstractPSystem; -import net.sourceforge.plantuml.command.PSystemSingleLineFactory; - -public class PSystemCharlieFactory extends PSystemSingleLineFactory { - - @Override - protected AbstractPSystem executeLine(String line) { - if (line.equalsIgnoreCase("charlie") || line.equalsIgnoreCase("jesuischarlie")) { - return new PSystemCharlie(); - } - return null; - } - -} diff --git a/src/net/sourceforge/plantuml/eggs/PSystemColors.java b/src/net/sourceforge/plantuml/eggs/PSystemColors.java deleted file mode 100644 index cd3fca6..0000000 --- a/src/net/sourceforge/plantuml/eggs/PSystemColors.java +++ /dev/null @@ -1,282 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.eggs; - -import java.awt.geom.Dimension2D; -import java.awt.geom.Point2D; -import java.io.IOException; -import java.io.OutputStream; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Comparator; -import java.util.Iterator; -import java.util.List; - -import net.sourceforge.plantuml.AbstractPSystem; -import net.sourceforge.plantuml.BackSlash; -import net.sourceforge.plantuml.FileFormatOption; -import net.sourceforge.plantuml.SpriteContainerEmpty; -import net.sourceforge.plantuml.core.DiagramDescription; -import net.sourceforge.plantuml.core.ImageData; -import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.graphic.FontConfiguration; -import net.sourceforge.plantuml.graphic.HorizontalAlignment; -import net.sourceforge.plantuml.graphic.HtmlColor; -import net.sourceforge.plantuml.graphic.HtmlColorSetSimple; -import net.sourceforge.plantuml.graphic.HtmlColorSimple; -import net.sourceforge.plantuml.graphic.HtmlColorUtils; -import net.sourceforge.plantuml.graphic.StringBounder; -import net.sourceforge.plantuml.graphic.TextBlock; -import net.sourceforge.plantuml.graphic.UDrawable; -import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity; -import net.sourceforge.plantuml.ugraphic.ImageBuilder; -import net.sourceforge.plantuml.ugraphic.UChangeBackColor; -import net.sourceforge.plantuml.ugraphic.UChangeColor; -import net.sourceforge.plantuml.ugraphic.UFont; -import net.sourceforge.plantuml.ugraphic.UGraphic; -import net.sourceforge.plantuml.ugraphic.UPolygon; -import net.sourceforge.plantuml.ugraphic.URectangle; -import net.sourceforge.plantuml.ugraphic.UTranslate; - -// http://www.redblobgames.com/grids/hexagons/ -public class PSystemColors extends AbstractPSystem implements UDrawable { - - private final double rectangleHeight = 28; - private final double rectangleWidth = 175; - private final HtmlColorSetSimple colors = new HtmlColorSetSimple(); - private final String paletteCentralColor; - private final double size = 60; - - public PSystemColors(String option) { - if (option == null) { - this.paletteCentralColor = null; - } else { - this.paletteCentralColor = option.replaceAll("\\#", ""); - } - } - - @Override - final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed) - throws IOException { - final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, HtmlColorUtils.WHITE, - getMetadata(), null, 0, 0, null, false); - imageBuilder.setUDrawable(this); - return imageBuilder.writeImageTOBEMOVED(fileFormat, seed, os); - } - - public DiagramDescription getDescription() { - return new DiagramDescription("(Colors)"); - } - - public void drawU(UGraphic ug) { - if (colors.getColorIfValid(paletteCentralColor) instanceof HtmlColorSimple) { - drawPalette(ug); - } else { - drawFull(ug); - } - } - - private void drawPalette(UGraphic ug) { - double x = (centerHexa(2, 0).getX() + centerHexa(3, 0).getX()) / 2; - double y = centerHexa(0, 2).getY() + corner(1).getY(); - ug = ug.apply(new UTranslate(x, y)); - final UPolygon hexa = getHexa(); - - final List<String> friends = getColorsCloseTo(paletteCentralColor); - int idx = 0; - drawOneHexa(ug, friends.get(idx++), 0, 0, hexa); - - drawOneHexa(ug, friends.get(idx++), 1, 0, hexa); - drawOneHexa(ug, friends.get(idx++), 0, 1, hexa); - drawOneHexa(ug, friends.get(idx++), -1, 1, hexa); - drawOneHexa(ug, friends.get(idx++), -1, 0, hexa); - drawOneHexa(ug, friends.get(idx++), -1, -1, hexa); - drawOneHexa(ug, friends.get(idx++), 0, -1, hexa); - - drawOneHexa(ug, friends.get(idx++), 2, 0, hexa); - drawOneHexa(ug, friends.get(idx++), 1, 1, hexa); - drawOneHexa(ug, friends.get(idx++), 1, 2, hexa); - drawOneHexa(ug, friends.get(idx++), 0, 2, hexa); - drawOneHexa(ug, friends.get(idx++), -1, 2, hexa); - drawOneHexa(ug, friends.get(idx++), -2, 1, hexa); - drawOneHexa(ug, friends.get(idx++), -2, 0, hexa); - drawOneHexa(ug, friends.get(idx++), -2, -1, hexa); - drawOneHexa(ug, friends.get(idx++), -1, -2, hexa); - drawOneHexa(ug, friends.get(idx++), 0, -2, hexa); - drawOneHexa(ug, friends.get(idx++), 1, -2, hexa); - drawOneHexa(ug, friends.get(idx++), 1, -1, hexa); - } - - private Point2D centerHexa(int i, int j) { - final double width = getWidth(); - final double x = width * i + (j % 2 == 0 ? 0 : width / 2); - final double y = size * j * 1.5; - return new Point2D.Double(x, y); - - } - - private double getWidth() { - return Math.sqrt(3) / 2 * 2 * size; - } - - private void drawOneHexa(UGraphic ug, String colorName, int i, int j, UPolygon hexa) { - final HtmlColorSimple color = (HtmlColorSimple) colors.getColorIfValid(colorName); - ug = applyColor(ug, color); - ug = ug.apply(new UTranslate(centerHexa(i, j))); - ug.draw(hexa); - - final UFont font = UFont.sansSerif(14).bold(); - - TextBlock tt = getTextName(font, colorName, color); - Dimension2D dimText = tt.calculateDimension(ug.getStringBounder()); - if (dimText.getWidth() > getWidth()) { - tt = getTextName(font, findShortest(ug.getStringBounder(), font, colorName), color); - dimText = tt.calculateDimension(ug.getStringBounder()); - } - tt.drawU(ug.apply(new UTranslate(-dimText.getWidth() / 2, -dimText.getHeight() / 2))); - } - - private String findShortest(StringBounder stringBounder, UFont font, String colorName) { - String result = null; - double min = Double.MAX_VALUE; - for (int i = 1; i < colorName.length() - 1; i++) { - if (Character.isLowerCase(colorName.charAt(i))) { - continue; - } - final String candidat = colorName.substring(0, i) + BackSlash.BS_BS_N + colorName.substring(i); - final TextBlock tt = getTextName(font, candidat, (HtmlColorSimple) HtmlColorUtils.BLACK); - final double width = tt.calculateDimension(stringBounder).getWidth(); - if (width < min) { - result = candidat; - min = width; - } - } - return result; - } - - private UGraphic applyColor(UGraphic ug, HtmlColor color) { - return ug.apply(new UChangeColor(color)).apply(new UChangeBackColor(color)); - } - - private Point2D corner(int i) { - double angle_deg = 60 * i + 30; - double angle_rad = Math.PI / 180 * angle_deg; - return new Point2D.Double(size * Math.cos(angle_rad), size * Math.sin(angle_rad)); - } - - private UPolygon getHexa() { - final UPolygon result = new UPolygon(); - for (int i = 0; i < 6; i++) { - result.addPoint(corner(i)); - } - return result; - } - - private List<String> getColorsCloseTo(String other) { - final List<String> result = new ArrayList<String>(colors.names()); - for (Iterator<String> it = result.iterator(); it.hasNext();) { - final String candidat = it.next(); - final String similar = candidat.replaceAll("Gray", "Grey"); - if (candidat.equals(similar)) { - continue; - } - if (result.contains(similar)) { - it.remove(); - } - } - if (containsCaseInsensitive(result, other) == false) { - result.add(other); - } - Collections.sort(result, closeComparator(paletteCentralColor)); - return result; - } - - private boolean containsCaseInsensitive(Collection<String> source, String target) { - for (String s : source) { - if (s.equalsIgnoreCase(target)) { - return true; - } - } - return false; - } - - private Comparator<String> closeComparator(String center) { - final HtmlColorSimple centerColor = (HtmlColorSimple) colors.getColorIfValid(center); - return new Comparator<String>() { - public int compare(String col1, String col2) { - final double dist1 = centerColor.distance((HtmlColorSimple) colors.getColorIfValid(col1)); - final double dist2 = centerColor.distance((HtmlColorSimple) colors.getColorIfValid(col2)); - return (int) Math.signum(dist1 - dist2); - } - }; - } - - private void drawFull(UGraphic ug) { - final UFont font = UFont.sansSerif(14).bold(); - - ug = ug.apply(new UChangeColor(HtmlColorUtils.BLACK)); - int i = 0; - int j = 0; - for (String name : colors.names()) { - UGraphic tmp = getPositioned(ug, i, j); - final HtmlColorSimple color = (HtmlColorSimple) colors.getColorIfValid(name); - applyColor(tmp, color).draw(new URectangle(rectangleWidth, rectangleHeight)); - final TextBlock tt = getTextName(font, name, color); - final Dimension2D dimText = tt.calculateDimension(ug.getStringBounder()); - final double dy = (rectangleHeight - dimText.getHeight()) / 2; - final double dx = (rectangleWidth - dimText.getWidth()) / 2; - tt.drawU(tmp.apply(new UTranslate(dx, dy))); - if (j++ == 20) { - j = 0; - i++; - } - } - } - - private TextBlock getTextName(final UFont font, String name, final HtmlColorSimple color) { - final HtmlColorSimple opposite = color.opposite(); - final FontConfiguration fc = new FontConfiguration(font, opposite, HtmlColorUtils.BLUE, true); - final TextBlock tt = Display.getWithNewlines(name).create(fc, HorizontalAlignment.CENTER, - new SpriteContainerEmpty()); - return tt; - } - - private UGraphic getPositioned(UGraphic ug, int i, int j) { - return ug.apply(new UTranslate(rectangleWidth * i, rectangleHeight * j)); - } - -} diff --git a/src/net/sourceforge/plantuml/eggs/PSystemColorsFactory.java b/src/net/sourceforge/plantuml/eggs/PSystemColorsFactory.java deleted file mode 100644 index af056db..0000000 --- a/src/net/sourceforge/plantuml/eggs/PSystemColorsFactory.java +++ /dev/null @@ -1,56 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.eggs; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import net.sourceforge.plantuml.AbstractPSystem; -import net.sourceforge.plantuml.command.PSystemSingleLineFactory; - -public class PSystemColorsFactory extends PSystemSingleLineFactory { - - @Override - protected AbstractPSystem executeLine(String line) { - final Pattern pattern = Pattern.compile("^colors?\\s*(#?\\w+)?\\s*$"); - final Matcher matcher = pattern.matcher(line); - if (matcher.matches()) { - return new PSystemColors(matcher.group(1)); - } - return null; - } - -} diff --git a/src/net/sourceforge/plantuml/eggs/PSystemEgg.java b/src/net/sourceforge/plantuml/eggs/PSystemEgg.java deleted file mode 100644 index 0ef2d90..0000000 --- a/src/net/sourceforge/plantuml/eggs/PSystemEgg.java +++ /dev/null @@ -1,82 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.eggs; - -import java.io.IOException; -import java.io.OutputStream; -import java.util.ArrayList; -import java.util.List; -import java.util.StringTokenizer; - -import net.sourceforge.plantuml.AbstractPSystem; -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.svek.TextBlockBackcolored; -import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity; -import net.sourceforge.plantuml.ugraphic.ImageBuilder; - -public class PSystemEgg extends AbstractPSystem { - - private final List<String> strings = new ArrayList<String>(); - - PSystemEgg(String sentence) { - final StringTokenizer st = new StringTokenizer(sentence, "|"); - while (st.hasMoreTokens()) { - strings.add(st.nextToken()); - } - } - - @Override - final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed) - throws IOException { - final TextBlockBackcolored result = getGraphicStrings(); - final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, result.getBackcolor(), - getMetadata(), null, 0, 0, null, false); - imageBuilder.setUDrawable(result); - return imageBuilder.writeImageTOBEMOVED(fileFormat, seed, os); - } - - private TextBlockBackcolored getGraphicStrings() throws IOException { - return GraphicStrings.createBlackOnWhite(strings); - } - - public DiagramDescription getDescription() { - return new DiagramDescription("(Easter Eggs)"); - } - -} diff --git a/src/net/sourceforge/plantuml/eggs/PSystemEggFactory.java b/src/net/sourceforge/plantuml/eggs/PSystemEggFactory.java deleted file mode 100644 index b65c325..0000000 --- a/src/net/sourceforge/plantuml/eggs/PSystemEggFactory.java +++ /dev/null @@ -1,68 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.eggs; - -import java.io.UnsupportedEncodingException; -import java.util.Arrays; -import java.util.List; - -import net.sourceforge.plantuml.AbstractPSystem; -import net.sourceforge.plantuml.command.PSystemSingleLineFactory; - -public class PSystemEggFactory extends PSystemSingleLineFactory { - - final static private List<byte[]> all = Arrays - .asList(EggUtils - .toByteArrays("56092d35fce86a0dd88047a766c1d6541a7c5fd5ba212fa02db9a32a463422febd71a75a934eb135dec7d6c6325ddd17fd2fa437eba863462b28e3e92514998306a72790d93501335ed6b1262ea46ab79573142c28f8e92508978255a533d9cf7903394f9ab73a33b230a2b273033633adf16044888243b92f9bd8351f3d4f9aa2302fb264afa37546368424fa6a07919152bd2990d935092e49d9a02038b437aeb528"), - EggUtils.toByteArrays("421e5b773c5df733a1194f716f18e8842155196b3b")); - - @Override - protected AbstractPSystem executeLine(String line) { - try { - for (byte[] crypted : all) { - final SentenceDecoder decoder = new SentenceDecoder(line, crypted); - if (decoder.isOk()) { - return new PSystemEgg(decoder.getSecret()); - } - } - } catch (UnsupportedEncodingException e) { - return null; - } - - return null; - } - -} diff --git a/src/net/sourceforge/plantuml/eggs/PSystemLost.java b/src/net/sourceforge/plantuml/eggs/PSystemLost.java deleted file mode 100644 index c5d063e..0000000 --- a/src/net/sourceforge/plantuml/eggs/PSystemLost.java +++ /dev/null @@ -1,78 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.eggs; - -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.FileFormatOption; -import net.sourceforge.plantuml.core.DiagramDescription; -import net.sourceforge.plantuml.core.ImageData; -import net.sourceforge.plantuml.graphic.GraphicStrings; -import net.sourceforge.plantuml.svek.TextBlockBackcolored; -import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity; -import net.sourceforge.plantuml.ugraphic.ImageBuilder; - -public class PSystemLost extends AbstractPSystem { - - private final List<String> strings = new ArrayList<String>(); - - public PSystemLost() { - 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(); - final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, result.getBackcolor(), - getMetadata(), null, 0, 0, null, false); - imageBuilder.setUDrawable(result); - return imageBuilder.writeImageTOBEMOVED(fileFormat, seed, os); - } - - private TextBlockBackcolored getGraphicStrings() throws IOException { - return GraphicStrings.createBlackOnWhite(strings); - } - - public DiagramDescription getDescription() { - return new DiagramDescription("(Lost)"); - } - -} diff --git a/src/net/sourceforge/plantuml/eggs/PSystemLostFactory.java b/src/net/sourceforge/plantuml/eggs/PSystemLostFactory.java deleted file mode 100644 index 6edc532..0000000 --- a/src/net/sourceforge/plantuml/eggs/PSystemLostFactory.java +++ /dev/null @@ -1,51 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.eggs; - -import net.sourceforge.plantuml.AbstractPSystem; -import net.sourceforge.plantuml.command.PSystemSingleLineFactory; - -public class PSystemLostFactory extends PSystemSingleLineFactory { - - @Override - protected AbstractPSystem executeLine(String line) { - if (line.matches("^4\\D+8\\D+15\\D+16\\D+23\\D+42")) { - return new PSystemLost(); - } - return null; - } - -} diff --git a/src/net/sourceforge/plantuml/eggs/PSystemPath.java b/src/net/sourceforge/plantuml/eggs/PSystemPath.java deleted file mode 100644 index f148eed..0000000 --- a/src/net/sourceforge/plantuml/eggs/PSystemPath.java +++ /dev/null @@ -1,65 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.eggs; - -import java.io.IOException; -import java.io.OutputStream; - -import net.sourceforge.plantuml.AbstractPSystem; -import net.sourceforge.plantuml.FileFormatOption; -import net.sourceforge.plantuml.core.DiagramDescription; -import net.sourceforge.plantuml.core.ImageData; -import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity; - -public class PSystemPath extends AbstractPSystem { - - private final GraphicsPath path; - - public PSystemPath(String s) { - this.path = new GraphicsPath(new ColorMapperIdentity(), s); - } - - @Override - final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed) - throws IOException { - return path.writeImage(os); - } - - public DiagramDescription getDescription() { - return new DiagramDescription("(Path)"); - } - -} diff --git a/src/net/sourceforge/plantuml/eggs/PSystemPathFactory.java b/src/net/sourceforge/plantuml/eggs/PSystemPathFactory.java deleted file mode 100644 index f4ba758..0000000 --- a/src/net/sourceforge/plantuml/eggs/PSystemPathFactory.java +++ /dev/null @@ -1,57 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.eggs; - -import net.sourceforge.plantuml.AbstractPSystem; -import net.sourceforge.plantuml.command.PSystemSingleLineFactory; -import net.sourceforge.plantuml.command.regex.Matcher2; -import net.sourceforge.plantuml.command.regex.MyPattern; -import net.sourceforge.plantuml.command.regex.Pattern2; - -public class PSystemPathFactory extends PSystemSingleLineFactory { - - final private static Pattern2 p = MyPattern.cmpile("(?i)^path[%s]+([0-9A-Za-z]+)$"); - - @Override - protected AbstractPSystem executeLine(String line) { - final Matcher2 m = p.matcher(line); - if (m.find() == false) { - return null; - } - return new PSystemPath(m.group(1)); - } - -} diff --git a/src/net/sourceforge/plantuml/eggs/PSystemRIP.java b/src/net/sourceforge/plantuml/eggs/PSystemRIP.java deleted file mode 100644 index d9a5fca..0000000 --- a/src/net/sourceforge/plantuml/eggs/PSystemRIP.java +++ /dev/null @@ -1,464 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.eggs; - -import java.awt.image.BufferedImage; -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.ArrayList; -import java.util.List; - -import javax.imageio.ImageIO; - -import net.sourceforge.plantuml.AbstractPSystem; -import net.sourceforge.plantuml.FileFormatOption; -import net.sourceforge.plantuml.core.DiagramDescription; -import net.sourceforge.plantuml.core.ImageData; -import net.sourceforge.plantuml.graphic.GraphicPosition; -import net.sourceforge.plantuml.graphic.GraphicStrings; -import net.sourceforge.plantuml.svek.TextBlockBackcolored; -import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity; -import net.sourceforge.plantuml.ugraphic.ImageBuilder; - -public class PSystemRIP extends AbstractPSystem { - - private final List<String> strings = new ArrayList<String>(); - private final BufferedImage image; - - public PSystemRIP() throws IOException { - strings.add(" To my Grandfather,"); - strings.add(" A mon grand-pere,"); - strings.add(" "); - strings.add(" <b>Jean CANOUET"); - strings.add(" "); - strings.add(" 31-OCT-1921 <i>(Neuilly-Sur-Seine, France)"); - strings.add(" 15-SEP-2009 <i>(Nanterre, France)"); - strings.add(" "); - strings.add(" <b>Requiescat In Pace"); - strings.add(" "); - - final InputStream is = new ByteArrayInputStream(imm); - image = ImageIO.read(is); - is.close(); - } - - @Override - final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed) - throws IOException { - final TextBlockBackcolored result = getGraphicStrings(); - final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, result.getBackcolor(), - getMetadata(), null, 0, 0, null, false); - imageBuilder.setUDrawable(result); - return imageBuilder.writeImageTOBEMOVED(fileFormat, seed, os); - } - - private TextBlockBackcolored getGraphicStrings() throws IOException { - return GraphicStrings.createBlackOnWhite(strings, image, GraphicPosition.BOTTOM); - } - - public DiagramDescription getDescription() { - return new DiagramDescription("(RIP)"); - } - - private static final byte imm[] = new byte[] { (byte) 255, (byte) 216, (byte) 255, (byte) 224, (byte) 0, (byte) 16, - (byte) 74, (byte) 70, (byte) 73, (byte) 70, (byte) 0, (byte) 1, (byte) 1, (byte) 1, (byte) 2, (byte) 88, - (byte) 2, (byte) 88, (byte) 0, (byte) 0, (byte) 255, (byte) 219, (byte) 0, (byte) 67, (byte) 0, (byte) 13, - (byte) 9, (byte) 10, (byte) 11, (byte) 10, (byte) 8, (byte) 13, (byte) 11, (byte) 10, (byte) 11, (byte) 14, - (byte) 14, (byte) 13, (byte) 15, (byte) 19, (byte) 32, (byte) 21, (byte) 19, (byte) 18, (byte) 18, - (byte) 19, (byte) 39, (byte) 28, (byte) 30, (byte) 23, (byte) 32, (byte) 46, (byte) 41, (byte) 49, - (byte) 48, (byte) 46, (byte) 41, (byte) 45, (byte) 44, (byte) 51, (byte) 58, (byte) 74, (byte) 62, - (byte) 51, (byte) 54, (byte) 70, (byte) 55, (byte) 44, (byte) 45, (byte) 64, (byte) 87, (byte) 65, - (byte) 70, (byte) 76, (byte) 78, (byte) 82, (byte) 83, (byte) 82, (byte) 50, (byte) 62, (byte) 90, - (byte) 97, (byte) 90, (byte) 80, (byte) 96, (byte) 74, (byte) 81, (byte) 82, (byte) 79, (byte) 255, - (byte) 219, (byte) 0, (byte) 67, (byte) 1, (byte) 14, (byte) 14, (byte) 14, (byte) 19, (byte) 17, - (byte) 19, (byte) 38, (byte) 21, (byte) 21, (byte) 38, (byte) 79, (byte) 53, (byte) 45, (byte) 53, - (byte) 79, (byte) 79, (byte) 79, (byte) 79, (byte) 79, (byte) 79, (byte) 79, (byte) 79, (byte) 79, - (byte) 79, (byte) 79, (byte) 79, (byte) 79, (byte) 79, (byte) 79, (byte) 79, (byte) 79, (byte) 79, - (byte) 79, (byte) 79, (byte) 79, (byte) 79, (byte) 79, (byte) 79, (byte) 79, (byte) 79, (byte) 79, - (byte) 79, (byte) 79, (byte) 79, (byte) 79, (byte) 79, (byte) 79, (byte) 79, (byte) 79, (byte) 79, - (byte) 79, (byte) 79, (byte) 79, (byte) 79, (byte) 79, (byte) 79, (byte) 79, (byte) 79, (byte) 79, - (byte) 79, (byte) 79, (byte) 79, (byte) 79, (byte) 79, (byte) 255, (byte) 192, (byte) 0, (byte) 17, - (byte) 8, (byte) 0, (byte) 135, (byte) 0, (byte) 162, (byte) 3, (byte) 1, (byte) 34, (byte) 0, (byte) 2, - (byte) 17, (byte) 1, (byte) 3, (byte) 17, (byte) 1, (byte) 255, (byte) 196, (byte) 0, (byte) 31, (byte) 0, - (byte) 0, (byte) 1, (byte) 5, (byte) 1, (byte) 1, (byte) 1, (byte) 1, (byte) 1, (byte) 1, (byte) 0, - (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 1, (byte) 2, (byte) 3, - (byte) 4, (byte) 5, (byte) 6, (byte) 7, (byte) 8, (byte) 9, (byte) 10, (byte) 11, (byte) 255, (byte) 196, - (byte) 0, (byte) 181, (byte) 16, (byte) 0, (byte) 2, (byte) 1, (byte) 3, (byte) 3, (byte) 2, (byte) 4, - (byte) 3, (byte) 5, (byte) 5, (byte) 4, (byte) 4, (byte) 0, (byte) 0, (byte) 1, (byte) 125, (byte) 1, - (byte) 2, (byte) 3, (byte) 0, (byte) 4, (byte) 17, (byte) 5, (byte) 18, (byte) 33, (byte) 49, (byte) 65, - (byte) 6, (byte) 19, (byte) 81, (byte) 97, (byte) 7, (byte) 34, (byte) 113, (byte) 20, (byte) 50, - (byte) 129, (byte) 145, (byte) 161, (byte) 8, (byte) 35, (byte) 66, (byte) 177, (byte) 193, (byte) 21, - (byte) 82, (byte) 209, (byte) 240, (byte) 36, (byte) 51, (byte) 98, (byte) 114, (byte) 130, (byte) 9, - (byte) 10, (byte) 22, (byte) 23, (byte) 24, (byte) 25, (byte) 26, (byte) 37, (byte) 38, (byte) 39, - (byte) 40, (byte) 41, (byte) 42, (byte) 52, (byte) 53, (byte) 54, (byte) 55, (byte) 56, (byte) 57, - (byte) 58, (byte) 67, (byte) 68, (byte) 69, (byte) 70, (byte) 71, (byte) 72, (byte) 73, (byte) 74, - (byte) 83, (byte) 84, (byte) 85, (byte) 86, (byte) 87, (byte) 88, (byte) 89, (byte) 90, (byte) 99, - (byte) 100, (byte) 101, (byte) 102, (byte) 103, (byte) 104, (byte) 105, (byte) 106, (byte) 115, (byte) 116, - (byte) 117, (byte) 118, (byte) 119, (byte) 120, (byte) 121, (byte) 122, (byte) 131, (byte) 132, (byte) 133, - (byte) 134, (byte) 135, (byte) 136, (byte) 137, (byte) 138, (byte) 146, (byte) 147, (byte) 148, (byte) 149, - (byte) 150, (byte) 151, (byte) 152, (byte) 153, (byte) 154, (byte) 162, (byte) 163, (byte) 164, (byte) 165, - (byte) 166, (byte) 167, (byte) 168, (byte) 169, (byte) 170, (byte) 178, (byte) 179, (byte) 180, (byte) 181, - (byte) 182, (byte) 183, (byte) 184, (byte) 185, (byte) 186, (byte) 194, (byte) 195, (byte) 196, (byte) 197, - (byte) 198, (byte) 199, (byte) 200, (byte) 201, (byte) 202, (byte) 210, (byte) 211, (byte) 212, (byte) 213, - (byte) 214, (byte) 215, (byte) 216, (byte) 217, (byte) 218, (byte) 225, (byte) 226, (byte) 227, (byte) 228, - (byte) 229, (byte) 230, (byte) 231, (byte) 232, (byte) 233, (byte) 234, (byte) 241, (byte) 242, (byte) 243, - (byte) 244, (byte) 245, (byte) 246, (byte) 247, (byte) 248, (byte) 249, (byte) 250, (byte) 255, (byte) 196, - (byte) 0, (byte) 31, (byte) 1, (byte) 0, (byte) 3, (byte) 1, (byte) 1, (byte) 1, (byte) 1, (byte) 1, - (byte) 1, (byte) 1, (byte) 1, (byte) 1, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, - (byte) 1, (byte) 2, (byte) 3, (byte) 4, (byte) 5, (byte) 6, (byte) 7, (byte) 8, (byte) 9, (byte) 10, - (byte) 11, (byte) 255, (byte) 196, (byte) 0, (byte) 181, (byte) 17, (byte) 0, (byte) 2, (byte) 1, (byte) 2, - (byte) 4, (byte) 4, (byte) 3, (byte) 4, (byte) 7, (byte) 5, (byte) 4, (byte) 4, (byte) 0, (byte) 1, - (byte) 2, (byte) 119, (byte) 0, (byte) 1, (byte) 2, (byte) 3, (byte) 17, (byte) 4, (byte) 5, (byte) 33, - (byte) 49, (byte) 6, (byte) 18, (byte) 65, (byte) 81, (byte) 7, (byte) 97, (byte) 113, (byte) 19, - (byte) 34, (byte) 50, (byte) 129, (byte) 8, (byte) 20, (byte) 66, (byte) 145, (byte) 161, (byte) 177, - (byte) 193, (byte) 9, (byte) 35, (byte) 51, (byte) 82, (byte) 240, (byte) 21, (byte) 98, (byte) 114, - (byte) 209, (byte) 10, (byte) 22, (byte) 36, (byte) 52, (byte) 225, (byte) 37, (byte) 241, (byte) 23, - (byte) 24, (byte) 25, (byte) 26, (byte) 38, (byte) 39, (byte) 40, (byte) 41, (byte) 42, (byte) 53, - (byte) 54, (byte) 55, (byte) 56, (byte) 57, (byte) 58, (byte) 67, (byte) 68, (byte) 69, (byte) 70, - (byte) 71, (byte) 72, (byte) 73, (byte) 74, (byte) 83, (byte) 84, (byte) 85, (byte) 86, (byte) 87, - (byte) 88, (byte) 89, (byte) 90, (byte) 99, (byte) 100, (byte) 101, (byte) 102, (byte) 103, (byte) 104, - (byte) 105, (byte) 106, (byte) 115, (byte) 116, (byte) 117, (byte) 118, (byte) 119, (byte) 120, (byte) 121, - (byte) 122, (byte) 130, (byte) 131, (byte) 132, (byte) 133, (byte) 134, (byte) 135, (byte) 136, (byte) 137, - (byte) 138, (byte) 146, (byte) 147, (byte) 148, (byte) 149, (byte) 150, (byte) 151, (byte) 152, (byte) 153, - (byte) 154, (byte) 162, (byte) 163, (byte) 164, (byte) 165, (byte) 166, (byte) 167, (byte) 168, (byte) 169, - (byte) 170, (byte) 178, (byte) 179, (byte) 180, (byte) 181, (byte) 182, (byte) 183, (byte) 184, (byte) 185, - (byte) 186, (byte) 194, (byte) 195, (byte) 196, (byte) 197, (byte) 198, (byte) 199, (byte) 200, (byte) 201, - (byte) 202, (byte) 210, (byte) 211, (byte) 212, (byte) 213, (byte) 214, (byte) 215, (byte) 216, (byte) 217, - (byte) 218, (byte) 226, (byte) 227, (byte) 228, (byte) 229, (byte) 230, (byte) 231, (byte) 232, (byte) 233, - (byte) 234, (byte) 242, (byte) 243, (byte) 244, (byte) 245, (byte) 246, (byte) 247, (byte) 248, (byte) 249, - (byte) 250, (byte) 255, (byte) 218, (byte) 0, (byte) 12, (byte) 3, (byte) 1, (byte) 0, (byte) 2, (byte) 17, - (byte) 3, (byte) 17, (byte) 0, (byte) 63, (byte) 0, (byte) 180, (byte) 48, (byte) 6, (byte) 69, (byte) 84, - (byte) 212, (byte) 135, (byte) 250, (byte) 49, (byte) 235, (byte) 214, (byte) 174, (byte) 116, (byte) 246, - (byte) 170, (byte) 154, (byte) 144, (byte) 205, (byte) 153, (byte) 61, (byte) 121, (byte) 21, (byte) 200, - (byte) 246, (byte) 61, (byte) 8, (byte) 124, (byte) 72, (byte) 202, (byte) 94, (byte) 7, (byte) 29, - (byte) 233, (byte) 24, (byte) 100, (byte) 127, (byte) 58, (byte) 114, (byte) 99, (byte) 181, (byte) 4, - (byte) 113, (byte) 222, (byte) 176, (byte) 59, (byte) 8, (byte) 226, (byte) 228, (byte) 103, (byte) 29, - (byte) 41, (byte) 177, (byte) 227, (byte) 127, (byte) 20, (byte) 228, (byte) 198, (byte) 211, (byte) 206, - (byte) 41, (byte) 163, (byte) 137, (byte) 61, (byte) 168, (byte) 1, (byte) 95, (byte) 168, (byte) 232, - (byte) 42, (byte) 212, (byte) 24, (byte) 242, (byte) 151, (byte) 57, (byte) 224, (byte) 246, (byte) 170, - (byte) 210, (byte) 18, (byte) 112, (byte) 42, (byte) 205, (byte) 191, (byte) 250, (byte) 159, (byte) 188, - (byte) 122, (byte) 211, (byte) 20, (byte) 182, (byte) 36, (byte) 7, (byte) 23, (byte) 72, (byte) 115, - (byte) 220, (byte) 113, (byte) 90, (byte) 135, (byte) 238, (byte) 140, (byte) 117, (byte) 205, (byte) 100, - (byte) 183, (byte) 19, (byte) 171, (byte) 99, (byte) 161, (byte) 28, (byte) 85, (byte) 249, (byte) 174, - (byte) 226, (byte) 133, (byte) 112, (byte) 207, (byte) 207, (byte) 160, (byte) 173, (byte) 32, (byte) 99, - (byte) 81, (byte) 55, (byte) 107, (byte) 22, (byte) 20, (byte) 117, (byte) 233, (byte) 214, (byte) 148, - (byte) 116, (byte) 108, (byte) 250, (byte) 214, (byte) 83, (byte) 106, (byte) 172, (byte) 14, (byte) 35, - (byte) 143, (byte) 143, (byte) 122, (byte) 106, (byte) 106, (byte) 115, (byte) 110, (byte) 249, (byte) 163, - (byte) 4, (byte) 103, (byte) 165, (byte) 105, (byte) 116, (byte) 79, (byte) 179, (byte) 145, (byte) 179, - (byte) 143, (byte) 148, (byte) 99, (byte) 138, (byte) 204, (byte) 214, (byte) 135, (byte) 203, (byte) 23, - (byte) 63, (byte) 197, (byte) 82, (byte) 195, (byte) 168, (byte) 71, (byte) 39, (byte) 13, (byte) 149, - (byte) 57, (byte) 232, (byte) 106, (byte) 13, (byte) 93, (byte) 131, (byte) 197, (byte) 27, (byte) 43, - (byte) 103, (byte) 230, (byte) 235, (byte) 69, (byte) 197, (byte) 20, (byte) 212, (byte) 181, (byte) 28, - (byte) 169, (byte) 38, (byte) 6, (byte) 8, (byte) 198, (byte) 61, (byte) 41, (byte) 205, (byte) 20, - (byte) 196, (byte) 13, (byte) 178, (byte) 1, (byte) 248, (byte) 81, (byte) 24, (byte) 118, (byte) 81, - (byte) 243, (byte) 246, (byte) 167, (byte) 180, (byte) 76, (byte) 64, (byte) 196, (byte) 173, (byte) 159, - (byte) 76, (byte) 212, (byte) 131, (byte) 96, (byte) 177, (byte) 200, (byte) 62, (byte) 83, (byte) 43, - (byte) 123, (byte) 226, (byte) 164, (byte) 17, (byte) 156, (byte) 99, (byte) 123, (byte) 126, (byte) 117, - (byte) 24, (byte) 140, (byte) 175, (byte) 222, (byte) 118, (byte) 231, (byte) 190, (byte) 105, (byte) 193, - (byte) 71, (byte) 77, (byte) 199, (byte) 241, (byte) 52, (byte) 196, (byte) 72, (byte) 34, (byte) 83, - (byte) 213, (byte) 155, (byte) 39, (byte) 142, (byte) 180, (byte) 162, (byte) 36, (byte) 201, (byte) 201, - (byte) 63, (byte) 157, (byte) 51, (byte) 9, (byte) 158, (byte) 88, (byte) 115, (byte) 239, (byte) 78, - (byte) 81, (byte) 24, (byte) 39, (byte) 230, (byte) 20, (byte) 132, (byte) 39, (byte) 151, (byte) 31, - (byte) 181, (byte) 20, (byte) 252, (byte) 197, (byte) 234, (byte) 40, (byte) 160, (byte) 46, (byte) 76, - (byte) 7, (byte) 168, (byte) 170, (byte) 218, (byte) 128, (byte) 255, (byte) 0, (byte) 67, (byte) 127, - (byte) 194, (byte) 174, (byte) 1, (byte) 199, (byte) 61, (byte) 42, (byte) 190, (byte) 160, (byte) 191, - (byte) 232, (byte) 114, (byte) 96, (byte) 83, (byte) 123, (byte) 10, (byte) 59, (byte) 163, (byte) 13, - (byte) 6, (byte) 6, (byte) 41, (byte) 89, (byte) 72, (byte) 247, (byte) 52, (byte) 168, (byte) 164, - (byte) 119, (byte) 193, (byte) 167, (byte) 50, (byte) 156, (byte) 26, (byte) 231, (byte) 108, (byte) 236, - (byte) 34, (byte) 140, (byte) 114, (byte) 221, (byte) 51, (byte) 81, (byte) 168, (byte) 30, (byte) 103, - (byte) 34, (byte) 165, (byte) 139, (byte) 134, (byte) 61, (byte) 233, (byte) 164, (byte) 226, (byte) 83, - (byte) 199, (byte) 90, (byte) 10, (byte) 65, (byte) 42, (byte) 227, (byte) 233, (byte) 86, (byte) 109, - (byte) 128, (byte) 48, (byte) 231, (byte) 112, (byte) 94, (byte) 123, (byte) 213, (byte) 121, (byte) 58, - (byte) 116, (byte) 233, (byte) 79, (byte) 50, (byte) 8, (byte) 236, (byte) 152, (byte) 224, (byte) 18, - (byte) 125, (byte) 104, (byte) 90, (byte) 147, (byte) 45, (byte) 136, (byte) 238, (byte) 231, (byte) 253, - (byte) 246, (byte) 200, (byte) 136, (byte) 220, (byte) 58, (byte) 181, (byte) 49, (byte) 85, (byte) 187, - (byte) 245, (byte) 61, (byte) 205, (byte) 71, (byte) 2, (byte) 28, (byte) 100, (byte) 247, (byte) 171, - (byte) 208, (byte) 71, (byte) 131, (byte) 156, (byte) 113, (byte) 90, (byte) 109, (byte) 161, (byte) 73, - (byte) 13, (byte) 138, (byte) 14, (byte) 121, (byte) 228, (byte) 85, (byte) 143, (byte) 32, (byte) 40, - (byte) 199, (byte) 74, (byte) 181, (byte) 111, (byte) 16, (byte) 61, (byte) 112, (byte) 125, (byte) 51, - (byte) 83, (byte) 203, (byte) 26, (byte) 4, (byte) 31, (byte) 39, (byte) 228, (byte) 105, (byte) 1, - (byte) 143, (byte) 44, (byte) 56, (byte) 233, (byte) 154, (byte) 169, (byte) 59, (byte) 72, (byte) 19, - (byte) 110, (byte) 114, (byte) 1, (byte) 200, (byte) 21, (byte) 181, (byte) 34, (byte) 140, (byte) 30, - (byte) 0, (byte) 250, (byte) 86, (byte) 124, (byte) 241, (byte) 130, (byte) 50, (byte) 71, (byte) 229, - (byte) 66, (byte) 97, (byte) 107, (byte) 133, (byte) 165, (byte) 202, (byte) 200, (byte) 161, (byte) 93, - (byte) 176, (byte) 122, (byte) 114, (byte) 106, (byte) 198, (byte) 3, (byte) 30, (byte) 95, (byte) 233, - (byte) 205, (byte) 99, (byte) 74, (byte) 165, (byte) 36, (byte) 201, (byte) 30, (byte) 226, (byte) 181, - (byte) 45, (byte) 36, (byte) 134, (byte) 120, (byte) 182, (byte) 202, (byte) 16, (byte) 17, (byte) 222, - (byte) 180, (byte) 49, (byte) 156, (byte) 109, (byte) 169, (byte) 58, (byte) 136, (byte) 192, (byte) 193, - (byte) 97, (byte) 249, (byte) 212, (byte) 170, (byte) 177, (byte) 131, (byte) 156, (byte) 138, (byte) 114, - (byte) 8, (byte) 66, (byte) 241, (byte) 183, (byte) 138, (byte) 148, (byte) 24, (byte) 123, (byte) 117, - (byte) 250, (byte) 80, (byte) 101, (byte) 113, (byte) 170, (byte) 98, (byte) 235, (byte) 149, (byte) 247, - (byte) 226, (byte) 156, (byte) 101, (byte) 128, (byte) 1, (byte) 128, (byte) 51, (byte) 158, (byte) 160, - (byte) 82, (byte) 230, (byte) 48, (byte) 49, (byte) 131, (byte) 207, (byte) 160, (byte) 163, (byte) 204, - (byte) 78, (byte) 56, (byte) 63, (byte) 247, (byte) 205, (byte) 50, (byte) 70, (byte) 249, (byte) 145, - (byte) 255, (byte) 0, (byte) 181, (byte) 255, (byte) 0, (byte) 124, (byte) 209, (byte) 78, (byte) 243, - (byte) 71, (byte) 247, (byte) 91, (byte) 242, (byte) 162, (byte) 150, (byte) 131, (byte) 47, (byte) 99, - (byte) 143, (byte) 173, (byte) 87, (byte) 191, (byte) 81, (byte) 246, (byte) 73, (byte) 51, (byte) 233, - (byte) 87, (byte) 48, (byte) 14, (byte) 122, (byte) 213, (byte) 123, (byte) 209, (byte) 254, (byte) 137, - (byte) 39, (byte) 166, (byte) 41, (byte) 189, (byte) 136, (byte) 142, (byte) 232, (byte) 231, (byte) 208, - (byte) 102, (byte) 158, (byte) 220, (byte) 28, (byte) 10, (byte) 106, (byte) 227, (byte) 138, (byte) 151, - (byte) 4, (byte) 142, (byte) 245, (byte) 204, (byte) 118, (byte) 144, (byte) 32, (byte) 204, (byte) 135, - (byte) 53, (byte) 27, (byte) 224, (byte) 75, (byte) 199, (byte) 173, (byte) 74, (byte) 56, (byte) 147, - (byte) 6, (byte) 152, (byte) 227, (byte) 247, (byte) 216, (byte) 52, (byte) 13, (byte) 4, (byte) 131, - (byte) 229, (byte) 206, (byte) 42, (byte) 180, (byte) 161, (byte) 152, (byte) 172, (byte) 125, (byte) 135, - (byte) 38, (byte) 174, (byte) 74, (byte) 0, (byte) 66, (byte) 7, (byte) 165, (byte) 64, (byte) 235, - (byte) 209, (byte) 179, (byte) 205, (byte) 84, (byte) 55, (byte) 6, (byte) 75, (byte) 12, (byte) 125, - (byte) 1, (byte) 206, (byte) 49, (byte) 82, (byte) 77, (byte) 113, (byte) 228, (byte) 97, (byte) 81, - (byte) 55, (byte) 53, (byte) 62, (byte) 220, (byte) 101, (byte) 50, (byte) 8, (byte) 233, (byte) 82, - (byte) 89, (byte) 36, (byte) 127, (byte) 104, (byte) 221, (byte) 112, (byte) 192, (byte) 51, (byte) 30, - (byte) 51, (byte) 218, (byte) 173, (byte) 110, (byte) 13, (byte) 216, (byte) 91, (byte) 75, (byte) 240, - (byte) 236, (byte) 18, (byte) 96, (byte) 87, (byte) 60, (byte) 100, (byte) 138, (byte) 213, (byte) 16, - (byte) 130, (byte) 157, (byte) 141, (byte) 23, (byte) 246, (byte) 118, (byte) 182, (byte) 234, (byte) 140, - (byte) 204, (byte) 24, (byte) 48, (byte) 4, (byte) 48, (byte) 82, (byte) 42, (byte) 72, (byte) 118, - (byte) 199, (byte) 18, (byte) 146, (byte) 202, (byte) 85, (byte) 135, (byte) 20, (byte) 89, (byte) 18, - (byte) 165, (byte) 116, (byte) 103, (byte) 94, (byte) 98, (byte) 221, (byte) 119, (byte) 177, (byte) 206, - (byte) 122, (byte) 10, (byte) 200, (byte) 123, (byte) 208, (byte) 220, (byte) 52, (byte) 100, (byte) 15, - (byte) 90, (byte) 222, (byte) 146, (byte) 15, (byte) 58, (byte) 38, (byte) 157, (byte) 212, (byte) 178, - (byte) 47, (byte) 124, (byte) 116, (byte) 172, (byte) 233, (byte) 252, (byte) 150, (byte) 66, (byte) 172, - (byte) 128, (byte) 46, (byte) 113, (byte) 144, (byte) 59, (byte) 209, (byte) 161, (byte) 92, (byte) 198, - (byte) 93, (byte) 202, (byte) 228, (byte) 43, (byte) 1, (byte) 197, (byte) 45, (byte) 140, (byte) 209, - (byte) 37, (byte) 198, (byte) 37, (byte) 25, (byte) 83, (byte) 198, (byte) 49, (byte) 82, (byte) 204, - (byte) 134, (byte) 37, (byte) 10, (byte) 72, (byte) 62, (byte) 135, (byte) 218, (byte) 170, (byte) 194, - (byte) 234, (byte) 147, (byte) 169, (byte) 35, (byte) 60, (byte) 250, (byte) 85, (byte) 33, (byte) 61, - (byte) 81, (byte) 209, (byte) 164, (byte) 208, (byte) 237, (byte) 218, (byte) 128, (byte) 227, (byte) 217, - (byte) 77, (byte) 60, (byte) 72, (byte) 167, (byte) 162, (byte) 177, (byte) 255, (byte) 0, (byte) 128, - (byte) 154, (byte) 72, (byte) 231, (byte) 27, (byte) 70, (byte) 17, (byte) 200, (byte) 199, (byte) 101, - (byte) 169, (byte) 145, (byte) 201, (byte) 255, (byte) 0, (byte) 150, (byte) 111, (byte) 84, (byte) 114, - (byte) 49, (byte) 155, (byte) 207, (byte) 64, (byte) 173, (byte) 255, (byte) 0, (byte) 124, (byte) 208, - (byte) 95, (byte) 166, (byte) 99, (byte) 111, (byte) 202, (byte) 165, (byte) 220, (byte) 199, (byte) 164, - (byte) 109, (byte) 75, (byte) 185, (byte) 207, (byte) 30, (byte) 89, (byte) 252, (byte) 233, (byte) 8, - (byte) 103, (byte) 154, (byte) 223, (byte) 243, (byte) 204, (byte) 254, (byte) 84, (byte) 83, (byte) 240, - (byte) 255, (byte) 0, (byte) 243, (byte) 207, (byte) 245, (byte) 162, (byte) 139, (byte) 129, (byte) 108, - (byte) 142, (byte) 106, (byte) 43, (byte) 197, (byte) 205, (byte) 164, (byte) 131, (byte) 167, (byte) 202, - (byte) 106, (byte) 206, (byte) 61, (byte) 122, (byte) 212, (byte) 87, (byte) 35, (byte) 54, (byte) 210, - (byte) 103, (byte) 251, (byte) 166, (byte) 155, (byte) 216, (byte) 148, (byte) 245, (byte) 57, (byte) 164, - (byte) 83, (byte) 145, (byte) 215, (byte) 138, (byte) 148, (byte) 1, (byte) 154, (byte) 106, (byte) 14, - (byte) 112, (byte) 106, (byte) 80, (byte) 56, (byte) 237, (byte) 154, (byte) 229, (byte) 103, (byte) 109, - (byte) 202, (byte) 216, (byte) 253, (byte) 233, (byte) 166, (byte) 203, (byte) 254, (byte) 180, (byte) 26, - (byte) 148, (byte) 2, (byte) 37, (byte) 250, (byte) 211, (byte) 102, (byte) 95, (byte) 222, (byte) 140, - (byte) 154, (byte) 16, (byte) 192, (byte) 168, (byte) 96, (byte) 42, (byte) 213, (byte) 212, (byte) 17, - (byte) 164, (byte) 33, (byte) 112, (byte) 8, (byte) 198, (byte) 106, (byte) 187, (byte) 175, (byte) 203, - (byte) 212, (byte) 226, (byte) 172, (byte) 135, (byte) 13, (byte) 102, (byte) 197, (byte) 190, (byte) 241, - (byte) 92, (byte) 125, (byte) 106, (byte) 224, (byte) 50, (byte) 188, (byte) 16, (byte) 70, (byte) 223, - (byte) 42, (byte) 147, (byte) 130, (byte) 123, (byte) 28, (byte) 84, (byte) 255, (byte) 0, (byte) 101, - (byte) 119, (byte) 159, (byte) 129, (byte) 140, (byte) 112, (byte) 42, (byte) 27, (byte) 77, (byte) 194, - (byte) 69, (byte) 29, (byte) 171, (byte) 106, (byte) 37, (byte) 87, (byte) 56, (byte) 12, (byte) 1, - (byte) 199, (byte) 122, (byte) 173, (byte) 68, (byte) 244, (byte) 27, (byte) 112, (byte) 215, (byte) 18, - (byte) 90, (byte) 195, (byte) 28, (byte) 164, (byte) 58, (byte) 196, (byte) 48, (byte) 6, (byte) 59, - (byte) 85, (byte) 41, (byte) 110, (byte) 30, (byte) 17, (byte) 177, (byte) 85, (byte) 126, (byte) 113, - (byte) 223, (byte) 156, (byte) 86, (byte) 156, (byte) 144, (byte) 21, (byte) 66, (byte) 210, (byte) 55, - (byte) 3, (byte) 144, (byte) 23, (byte) 189, (byte) 101, (byte) 198, (byte) 130, (byte) 123, (byte) 163, - (byte) 185, (byte) 130, (byte) 250, (byte) 3, (byte) 218, (byte) 158, (byte) 251, (byte) 132, (byte) 82, - (byte) 38, (byte) 180, (byte) 184, (byte) 157, (byte) 108, (byte) 165, (byte) 137, (byte) 27, (byte) 247, - (byte) 114, (byte) 12, (byte) 50, (byte) 213, (byte) 9, (byte) 163, (byte) 85, (byte) 93, (byte) 170, - (byte) 8, (byte) 238, (byte) 125, (byte) 234, (byte) 218, (byte) 68, (byte) 233, (byte) 118, (byte) 99, - (byte) 71, (byte) 24, (byte) 60, (byte) 143, (byte) 66, (byte) 105, (byte) 243, (byte) 71, (byte) 34, - (byte) 130, (byte) 90, (byte) 62, (byte) 71, (byte) 189, (byte) 14, (byte) 227, (byte) 178, (byte) 76, - (byte) 206, (byte) 146, (byte) 47, (byte) 58, (byte) 84, (byte) 80, (byte) 6, (byte) 91, (byte) 214, - (byte) 179, (byte) 221, (byte) 190, (byte) 207, (byte) 119, (byte) 141, (byte) 155, (byte) 130, (byte) 55, - (byte) 74, (byte) 189, (byte) 44, (byte) 158, (byte) 84, (byte) 193, (byte) 240, (byte) 1, (byte) 0, - (byte) 145, (byte) 143, (byte) 90, (byte) 207, (byte) 11, (byte) 52, (byte) 243, (byte) 240, (byte) 187, - (byte) 153, (byte) 143, (byte) 65, (byte) 84, (byte) 132, (byte) 246, (byte) 58, (byte) 107, (byte) 121, - (byte) 76, (byte) 145, (byte) 171, (byte) 136, (byte) 142, (byte) 8, (byte) 233, (byte) 154, (byte) 156, - (byte) 23, (byte) 255, (byte) 0, (byte) 158, (byte) 120, (byte) 252, (byte) 106, (byte) 59, (byte) 88, - (byte) 231, (byte) 72, (byte) 85, (byte) 10, (byte) 32, (byte) 192, (byte) 171, (byte) 24, (byte) 151, - (byte) 31, (byte) 193, (byte) 154, (byte) 163, (byte) 141, (byte) 140, (byte) 5, (byte) 241, (byte) 247, - (byte) 7, (byte) 231, (byte) 74, (byte) 60, (byte) 206, (byte) 161, (byte) 71, (byte) 231, (byte) 78, - (byte) 219, (byte) 47, (byte) 251, (byte) 20, (byte) 170, (byte) 178, (byte) 231, (byte) 239, (byte) 47, - (byte) 229, (byte) 64, (byte) 134, (byte) 252, (byte) 222, (byte) 139, (byte) 249, (byte) 209, (byte) 82, - (byte) 121, (byte) 114, (byte) 255, (byte) 0, (byte) 121, (byte) 104, (byte) 164, (byte) 23, (byte) 44, - (byte) 149, (byte) 39, (byte) 165, (byte) 71, (byte) 58, (byte) 159, (byte) 33, (byte) 198, (byte) 63, - (byte) 132, (byte) 212, (byte) 248, (byte) 7, (byte) 138, (byte) 108, (byte) 171, (byte) 251, (byte) 166, - (byte) 250, (byte) 98, (byte) 171, (byte) 161, (byte) 11, (byte) 115, (byte) 150, (byte) 140, (byte) 124, - (byte) 220, (byte) 84, (byte) 219, (byte) 121, (byte) 166, (byte) 42, (byte) 146, (byte) 216, (byte) 29, - (byte) 141, (byte) 78, (byte) 163, (byte) 154, (byte) 228, (byte) 123, (byte) 157, (byte) 197, (byte) 82, - (byte) 15, (byte) 152, (byte) 41, (byte) 179, (byte) 175, (byte) 206, (byte) 9, (byte) 169, (byte) 153, - (byte) 79, (byte) 154, (byte) 41, (byte) 147, (byte) 174, (byte) 25, (byte) 73, (byte) 206, (byte) 40, - (byte) 24, (byte) 99, (byte) 9, (byte) 142, (byte) 105, (byte) 208, (byte) 32, (byte) 101, (byte) 37, - (byte) 219, (byte) 104, (byte) 3, (byte) 34, (byte) 159, (byte) 183, (byte) 40, (byte) 112, (byte) 57, - (byte) 237, (byte) 87, (byte) 108, (byte) 236, (byte) 100, (byte) 40, (byte) 124, (byte) 193, (byte) 141, - (byte) 195, (byte) 165, (byte) 105, (byte) 74, (byte) 46, (byte) 79, (byte) 66, (byte) 39, (byte) 53, - (byte) 21, (byte) 118, (byte) 80, (byte) 183, (byte) 31, (byte) 48, (byte) 30, (byte) 245, (byte) 173, - (byte) 110, (byte) 152, (byte) 249, (byte) 143, (byte) 65, (byte) 84, (byte) 163, (byte) 128, (byte) 195, - (byte) 115, (byte) 176, (byte) 245, (byte) 7, (byte) 154, (byte) 211, (byte) 141, (byte) 51, (byte) 149, - (byte) 238, (byte) 106, (byte) 154, (byte) 177, (byte) 92, (byte) 221, (byte) 72, (byte) 46, (byte) 238, - (byte) 55, (byte) 28, (byte) 100, (byte) 243, (byte) 85, (byte) 226, (byte) 183, (byte) 93, (byte) 187, - (byte) 152, (byte) 114, (byte) 122, (byte) 123, (byte) 83, (byte) 117, (byte) 8, (byte) 38, (byte) 102, - (byte) 45, (byte) 19, (byte) 99, (byte) 29, (byte) 133, (byte) 85, (byte) 84, (byte) 185, (byte) 85, - (byte) 206, (byte) 72, (byte) 230, (byte) 132, (byte) 104, (byte) 147, (byte) 104, (byte) 89, (byte) 3, - (byte) 67, (byte) 117, (byte) 149, (byte) 99, (byte) 128, (byte) 106, (byte) 244, (byte) 178, (byte) 9, - (byte) 34, (byte) 221, (byte) 237, (byte) 89, (byte) 66, (byte) 41, (byte) 158, (byte) 113, (byte) 184, - (byte) 182, (byte) 220, (byte) 242, (byte) 107, (byte) 96, (byte) 162, (byte) 139, (byte) 124, (byte) 142, - (byte) 167, (byte) 138, (byte) 24, (byte) 164, (byte) 236, (byte) 97, (byte) 94, (byte) 129, (byte) 146, - (byte) 9, (byte) 193, (byte) 199, (byte) 21, (byte) 14, (byte) 155, (byte) 230, (byte) 11, (byte) 164, - (byte) 219, (byte) 183, (byte) 35, (byte) 212, (byte) 113, (byte) 79, (byte) 212, (byte) 207, (byte) 250, - (byte) 70, (byte) 220, (byte) 227, (byte) 2, (byte) 173, (byte) 104, (byte) 214, (byte) 141, (byte) 33, - (byte) 105, (byte) 3, (byte) 225, (byte) 151, (byte) 167, (byte) 28, (byte) 85, (byte) 35, (byte) 57, - (byte) 187, (byte) 35, (byte) 106, (byte) 53, (byte) 159, (byte) 3, (byte) 123, (byte) 174, (byte) 125, - (byte) 133, (byte) 60, (byte) 71, (byte) 38, (byte) 57, (byte) 113, (byte) 159, (byte) 165, (byte) 34, - (byte) 197, (byte) 40, (byte) 31, (byte) 52, (byte) 205, (byte) 159, (byte) 165, (byte) 56, (byte) 198, - (byte) 248, (byte) 229, (byte) 216, (byte) 211, (byte) 57, (byte) 67, (byte) 99, (byte) 224, (byte) 130, - (byte) 252, (byte) 253, (byte) 41, (byte) 66, (byte) 201, (byte) 221, (byte) 248, (byte) 250, (byte) 81, - (byte) 229, (byte) 147, (byte) 140, (byte) 187, (byte) 82, (byte) 136, (byte) 207, (byte) 247, (byte) 219, - (byte) 31, (byte) 90, (byte) 96, (byte) 46, (byte) 195, (byte) 255, (byte) 0, (byte) 61, (byte) 13, - (byte) 20, (byte) 121, (byte) 63, (byte) 237, (byte) 55, (byte) 231, (byte) 69, (byte) 23, (byte) 21, - (byte) 139, (byte) 152, (byte) 201, (byte) 247, (byte) 164, (byte) 117, (byte) 249, (byte) 79, (byte) 166, - (byte) 41, (byte) 195, (byte) 20, (byte) 132, (byte) 124, (byte) 164, (byte) 85, (byte) 16, (byte) 115, - (byte) 32, (byte) 126, (byte) 240, (byte) 129, (byte) 235, (byte) 82, (byte) 117, (byte) 224, (byte) 83, - (byte) 74, (byte) 226, (byte) 118, (byte) 235, (byte) 212, (byte) 212, (byte) 161, (byte) 79, (byte) 28, - (byte) 243, (byte) 92, (byte) 143, (byte) 115, (byte) 182, (byte) 229, (byte) 121, (byte) 0, (byte) 14, - (byte) 50, (byte) 41, (byte) 207, (byte) 3, (byte) 202, (byte) 192, (byte) 39, (byte) 62, (byte) 167, - (byte) 210, (byte) 174, (byte) 195, (byte) 100, (byte) 101, (byte) 96, (byte) 207, (byte) 144, (byte) 61, - (byte) 43, (byte) 78, (byte) 27, (byte) 116, (byte) 81, (byte) 133, (byte) 0, (byte) 98, (byte) 183, - (byte) 167, (byte) 69, (byte) 189, (byte) 89, (byte) 140, (byte) 235, (byte) 168, (byte) 236, (byte) 83, - (byte) 176, (byte) 177, (byte) 0, (byte) 130, (byte) 252, (byte) 227, (byte) 214, (byte) 180, (byte) 210, - (byte) 60, (byte) 47, (byte) 35, (byte) 156, (byte) 212, (byte) 144, (byte) 198, (byte) 20, (byte) 142, - (byte) 42, (byte) 114, (byte) 163, (byte) 56, (byte) 29, (byte) 235, (byte) 174, (byte) 49, (byte) 81, - (byte) 86, (byte) 71, (byte) 28, (byte) 230, (byte) 228, (byte) 238, (byte) 204, (byte) 125, (byte) 86, - (byte) 216, (byte) 161, (byte) 89, (byte) 194, (byte) 251, (byte) 54, (byte) 59, (byte) 84, (byte) 105, - (byte) 40, (byte) 40, (byte) 174, (byte) 189, (byte) 71, (byte) 167, (byte) 90, (byte) 223, (byte) 186, - (byte) 183, (byte) 89, (byte) 160, (byte) 42, (byte) 195, (byte) 130, (byte) 48, (byte) 107, (byte) 154, - (byte) 8, (byte) 246, (byte) 183, (byte) 13, (byte) 4, (byte) 199, (byte) 31, (byte) 221, (byte) 61, - (byte) 136, (byte) 172, (byte) 106, (byte) 199, (byte) 170, (byte) 58, (byte) 104, (byte) 78, (byte) 234, - (byte) 204, (byte) 149, (byte) 8, (byte) 147, (byte) 118, (byte) 72, (byte) 235, (byte) 154, (byte) 99, - (byte) 40, (byte) 42, (byte) 113, (byte) 131, (byte) 138, (byte) 35, (byte) 27, (byte) 36, (byte) 200, - (byte) 28, (byte) 19, (byte) 79, (byte) 102, (byte) 11, (byte) 209, (byte) 125, (byte) 248, (byte) 172, - (byte) 108, (byte) 117, (byte) 166, (byte) 85, (byte) 224, (byte) 238, (byte) 35, (byte) 29, (byte) 42, - (byte) 1, (byte) 57, (byte) 84, (byte) 62, (byte) 220, (byte) 1, (byte) 235, (byte) 83, (byte) 207, - (byte) 242, (byte) 41, (byte) 218, (byte) 58, (byte) 251, (byte) 209, (byte) 97, (byte) 109, (byte) 188, - (byte) 153, (byte) 88, (byte) 12, (byte) 3, (byte) 133, (byte) 250, (byte) 250, (byte) 213, (byte) 70, - (byte) 23, (byte) 100, (byte) 212, (byte) 154, (byte) 138, (byte) 185, (byte) 3, (byte) 104, (byte) 13, - (byte) 112, (byte) 158, (byte) 107, (byte) 204, (byte) 86, (byte) 86, (byte) 228, (byte) 140, (byte) 112, - (byte) 42, (byte) 75, (byte) 125, (byte) 60, (byte) 89, (byte) 194, (byte) 82, (byte) 89, (byte) 93, - (byte) 73, (byte) 63, (byte) 120, (byte) 30, (byte) 43, (byte) 105, (byte) 27, (byte) 229, (byte) 7, - (byte) 20, (byte) 247, (byte) 69, (byte) 117, (byte) 33, (byte) 128, (byte) 32, (byte) 245, (byte) 205, - (byte) 110, (byte) 233, (byte) 163, (byte) 139, (byte) 219, (byte) 73, (byte) 238, (byte) 103, (byte) 36, - (byte) 42, (byte) 121, (byte) 243, (byte) 73, (byte) 255, (byte) 0, (byte) 129, (byte) 84, (byte) 130, - (byte) 20, (byte) 35, (byte) 33, (byte) 219, (byte) 254, (byte) 250, (byte) 172, (byte) 251, (byte) 203, - (byte) 83, (byte) 167, (byte) 75, (byte) 231, (byte) 196, (byte) 187, (byte) 161, (byte) 39, (byte) 230, - (byte) 83, (byte) 218, (byte) 174, (byte) 91, (byte) 205, (byte) 105, (byte) 60, (byte) 97, (byte) 208, - (byte) 168, (byte) 227, (byte) 167, (byte) 165, (byte) 100, (byte) 213, (byte) 141, (byte) 58, (byte) 93, - (byte) 18, (byte) 249, (byte) 49, (byte) 255, (byte) 0, (byte) 120, (byte) 243, (byte) 254, (byte) 213, - (byte) 30, (byte) 84, (byte) 93, (byte) 50, (byte) 127, (byte) 239, (byte) 170, (byte) 81, (byte) 228, - (byte) 15, (byte) 238, (byte) 81, (byte) 254, (byte) 142, (byte) 23, (byte) 248, (byte) 41, (byte) 8, - (byte) 60, (byte) 168, (byte) 127, (byte) 188, (byte) 127, (byte) 239, (byte) 170, (byte) 41, (byte) 63, - (byte) 209, (byte) 255, (byte) 0, (byte) 216, (byte) 162, (byte) 141, (byte) 7, (byte) 115, (byte) 67, - (byte) 29, (byte) 232, (byte) 199, (byte) 81, (byte) 235, (byte) 79, (byte) 160, (byte) 138, (byte) 163, - (byte) 51, (byte) 152, (byte) 117, (byte) 38, (byte) 233, (byte) 148, (byte) 15, (byte) 226, (byte) 34, - (byte) 180, (byte) 173, (byte) 237, (byte) 48, (byte) 1, (byte) 97, (byte) 255, (byte) 0, (byte) 214, - (byte) 169, (byte) 160, (byte) 176, (byte) 219, (byte) 44, (byte) 147, (byte) 75, (byte) 221, (byte) 142, - (byte) 209, (byte) 87, (byte) 226, (byte) 139, (byte) 208, (byte) 126, (byte) 116, (byte) 233, (byte) 210, - (byte) 183, (byte) 188, (byte) 199, (byte) 86, (byte) 173, (byte) 215, (byte) 42, (byte) 35, (byte) 142, - (byte) 53, (byte) 94, (byte) 49, (byte) 83, (byte) 249, (byte) 67, (byte) 32, (byte) 140, (byte) 84, - (byte) 137, (byte) 22, (byte) 57, (byte) 53, (byte) 32, (byte) 94, (byte) 245, (byte) 185, (byte) 206, - (byte) 49, (byte) 83, (byte) 10, (byte) 24, (byte) 118, (byte) 52, (byte) 253, (byte) 185, (byte) 96, - (byte) 77, (byte) 57, (byte) 70, (byte) 65, (byte) 200, (byte) 169, (byte) 54, (byte) 240, (byte) 41, - (byte) 12, (byte) 16, (byte) 238, (byte) 5, (byte) 79, (byte) 81, (byte) 84, (byte) 53, (byte) 61, - (byte) 60, (byte) 93, (byte) 33, (byte) 3, (byte) 135, (byte) 31, (byte) 116, (byte) 214, (byte) 134, - (byte) 222, (byte) 132, (byte) 83, (byte) 156, (byte) 110, (byte) 92, (byte) 142, (byte) 162, (byte) 144, - (byte) 211, (byte) 105, (byte) 221, (byte) 28, (byte) 121, (byte) 183, (byte) 185, (byte) 137, (byte) 138, - (byte) 156, (byte) 241, (byte) 237, (byte) 71, (byte) 152, (byte) 234, (byte) 62, (byte) 97, (byte) 205, - (byte) 116, (byte) 146, (byte) 91, (byte) 164, (byte) 255, (byte) 0, (byte) 49, (byte) 24, (byte) 35, - (byte) 140, (byte) 138, (byte) 161, (byte) 45, (byte) 178, (byte) 36, (byte) 152, (byte) 35, (byte) 154, - (byte) 194, (byte) 81, (byte) 104, (byte) 236, (byte) 133, (byte) 85, (byte) 35, (byte) 13, (byte) 163, - (byte) 121, (byte) 166, (byte) 85, (byte) 60, (byte) 100, (byte) 214, (byte) 196, (byte) 80, (byte) 4, - (byte) 9, (byte) 26, (byte) 224, (byte) 119, (byte) 168, (byte) 4, (byte) 5, (byte) 175, (byte) 14, - (byte) 209, (byte) 192, (byte) 239, (byte) 90, (byte) 98, (byte) 220, (byte) 44, (byte) 91, (byte) 137, - (byte) 201, (byte) 29, (byte) 42, (byte) 233, (byte) 167, (byte) 185, (byte) 157, (byte) 121, (byte) 105, - (byte) 98, (byte) 154, (byte) 41, (byte) 85, (byte) 83, (byte) 219, (byte) 161, (byte) 169, (byte) 151, - (byte) 142, (byte) 61, (byte) 63, (byte) 149, (byte) 72, (byte) 209, (byte) 0, (byte) 132, (byte) 122, - (byte) 115, (byte) 81, (byte) 99, (byte) 24, (byte) 173, (byte) 142, (byte) 113, (byte) 110, (byte) 33, - (byte) 73, (byte) 237, (byte) 200, (byte) 97, (byte) 199, (byte) 67, (byte) 244, (byte) 174, (byte) 94, - (byte) 214, (byte) 69, (byte) 176, (byte) 212, (byte) 222, (byte) 7, (byte) 251, (byte) 164, (byte) 227, - (byte) 165, (byte) 117, (byte) 145, (byte) 99, (byte) 12, (byte) 167, (byte) 21, (byte) 205, (byte) 248, - (byte) 146, (byte) 31, (byte) 42, (byte) 120, (byte) 231, (byte) 69, (byte) 231, (byte) 161, (byte) 250, - (byte) 138, (byte) 206, (byte) 162, (byte) 208, (byte) 214, (byte) 139, (byte) 215, (byte) 151, (byte) 185, - (byte) 171, (byte) 190, (byte) 35, (byte) 252, (byte) 56, (byte) 252, (byte) 40, (byte) 221, (byte) 22, - (byte) 51, (byte) 183, (byte) 255, (byte) 0, (byte) 29, (byte) 168, (byte) 236, (byte) 174, (byte) 60, - (byte) 251, (byte) 84, (byte) 125, (byte) 135, (byte) 36, (byte) 96, (byte) 212, (byte) 197, (byte) 184, - (byte) 255, (byte) 0, (byte) 86, (byte) 213, (byte) 137, (byte) 67, (byte) 124, (byte) 216, (byte) 191, - (byte) 186, (byte) 127, (byte) 239, (byte) 154, (byte) 41, (byte) 124, (byte) 207, (byte) 250, (byte) 100, - (byte) 223, (byte) 149, (byte) 20, (byte) 12, (byte) 209, (byte) 198, (byte) 120, (byte) 169, (byte) 35, - (byte) 143, (byte) 113, (byte) 246, (byte) 20, (byte) 152, (byte) 61, (byte) 106, (byte) 196, (byte) 73, - (byte) 182, (byte) 44, (byte) 250, (byte) 214, (byte) 145, (byte) 87, (byte) 102, (byte) 82, (byte) 118, - (byte) 34, (byte) 88, (byte) 183, (byte) 201, (byte) 147, (byte) 208, (byte) 118, (byte) 171, (byte) 11, - (byte) 31, (byte) 124, (byte) 83, (byte) 97, (byte) 24, (byte) 82, (byte) 125, (byte) 77, (byte) 90, - (byte) 3, (byte) 3, (byte) 21, (byte) 165, (byte) 204, (byte) 200, (byte) 74, (byte) 99, (byte) 154, - (byte) 66, (byte) 184, (byte) 197, (byte) 78, (byte) 87, (byte) 62, (byte) 244, (byte) 214, (byte) 92, - (byte) 227, (byte) 210, (byte) 139, (byte) 136, (byte) 131, (byte) 163, (byte) 98, (byte) 165, (byte) 2, - (byte) 145, (byte) 151, (byte) 231, (byte) 252, (byte) 42, (byte) 80, (byte) 56, (byte) 161, (byte) 140, - (byte) 140, (byte) 112, (byte) 219, (byte) 79, (byte) 122, (byte) 90, (byte) 71, (byte) 24, (byte) 193, - (byte) 29, (byte) 169, (byte) 123, (byte) 231, (byte) 214, (byte) 129, (byte) 145, (byte) 178, (byte) 158, - (byte) 171, (byte) 138, (byte) 169, (byte) 120, (byte) 141, (byte) 144, (byte) 248, (byte) 233, (byte) 214, - (byte) 175, (byte) 16, (byte) 122, (byte) 83, (byte) 72, (byte) 12, (byte) 118, (byte) 176, (byte) 224, - (byte) 138, (byte) 26, (byte) 186, (byte) 176, (byte) 70, (byte) 78, (byte) 46, (byte) 230, (byte) 84, - (byte) 17, (byte) 147, (byte) 48, (byte) 53, (byte) 121, (byte) 211, (byte) 10, (byte) 5, (byte) 71, - (byte) 111, (byte) 9, (byte) 75, (byte) 135, (byte) 95, (byte) 238, (byte) 244, (byte) 171, (byte) 18, - (byte) 142, (byte) 71, (byte) 214, (byte) 148, (byte) 21, (byte) 145, (byte) 85, (byte) 37, (byte) 205, - (byte) 34, (byte) 177, (byte) 4, (byte) 231, (byte) 138, (byte) 132, (byte) 175, (byte) 31, (byte) 90, - (byte) 182, (byte) 87, (byte) 4, (byte) 212, (byte) 44, (byte) 160, (byte) 49, (byte) 21, (byte) 68, - (byte) 21, (byte) 199, (byte) 202, (byte) 224, (byte) 254, (byte) 117, (byte) 71, (byte) 196, (byte) 16, - (byte) 249, (byte) 154, (byte) 116, (byte) 140, (byte) 163, (byte) 37, (byte) 112, (byte) 195, (byte) 250, - (byte) 214, (byte) 139, (byte) 167, (byte) 28, (byte) 117, (byte) 166, (byte) 74, (byte) 162, (byte) 88, - (byte) 25, (byte) 8, (byte) 206, (byte) 84, (byte) 138, (byte) 77, (byte) 93, (byte) 21, (byte) 23, - (byte) 102, (byte) 153, (byte) 207, (byte) 104, (byte) 55, (byte) 18, (byte) 24, (byte) 90, (byte) 61, - (byte) 160, (byte) 224, (byte) 250, (byte) 214, (byte) 182, (byte) 249, (byte) 127, (byte) 184, (byte) 63, - (byte) 58, (byte) 231, (byte) 52, (byte) 150, (byte) 150, (byte) 45, (byte) 65, (byte) 145, (byte) 72, - (byte) 29, (byte) 143, (byte) 21, (byte) 209, (byte) 126, (byte) 255, (byte) 0, (byte) 213, (byte) 115, - (byte) 88, (byte) 29, (byte) 19, (byte) 90, (byte) 134, (byte) 249, (byte) 255, (byte) 0, (byte) 184, - (byte) 159, (byte) 157, (byte) 20, (byte) 126, (byte) 251, (byte) 213, (byte) 127, (byte) 42, (byte) 40, - (byte) 185, (byte) 54, (byte) 53, (byte) 209, (byte) 114, (byte) 192, (byte) 26, (byte) 179, (byte) 39, - (byte) 220, (byte) 0, (byte) 81, (byte) 69, (byte) 109, (byte) 29, (byte) 140, (byte) 36, (byte) 245, - (byte) 31, (byte) 18, (byte) 141, (byte) 192, (byte) 122, (byte) 10, (byte) 177, (byte) 138, (byte) 40, - (byte) 160, (byte) 66, (byte) 116, (byte) 56, (byte) 161, (byte) 128, (byte) 234, (byte) 40, (byte) 162, - (byte) 129, (byte) 12, (byte) 97, (byte) 215, (byte) 233, (byte) 73, (byte) 25, (byte) 36, (byte) 81, - (byte) 69, (byte) 3, (byte) 7, (byte) 25, (byte) 28, (byte) 83, (byte) 87, (byte) 238, (byte) 224, - (byte) 209, (byte) 69, (byte) 48, (byte) 23, (byte) 60, (byte) 82, (byte) 48, (byte) 252, (byte) 232, - (byte) 162, (byte) 128, (byte) 19, (byte) 0, (byte) 190, (byte) 238, (byte) 132, (byte) 140, (byte) 26, - (byte) 107, (byte) 140, (byte) 156, (byte) 122, (byte) 81, (byte) 69, (byte) 2, (byte) 68, (byte) 108, - (byte) 188, (byte) 212, (byte) 110, (byte) 189, (byte) 40, (byte) 162, (byte) 129, (byte) 145, (byte) 55, - (byte) 99, (byte) 81, (byte) 72, (byte) 187, (byte) 64, (byte) 97, (byte) 235, (byte) 69, (byte) 20, - (byte) 193, (byte) 28, (byte) 124, (byte) 136, (byte) 209, (byte) 235, (byte) 178, (byte) 5, (byte) 114, - (byte) 191, (byte) 188, (byte) 61, (byte) 43, (byte) 162, (byte) 242, (byte) 164, (byte) 219, (byte) 254, - (byte) 185, (byte) 191, (byte) 33, (byte) 69, (byte) 21, (byte) 206, (byte) 247, (byte) 58, (byte) 166, - (byte) 244, (byte) 66, (byte) 249, (byte) 18, (byte) 255, (byte) 0, (byte) 207, (byte) 193, (byte) 255, - (byte) 0, (byte) 190, (byte) 104, (byte) 162, (byte) 138, (byte) 68, (byte) 159, (byte) 255, (byte) 217 - - }; - -} diff --git a/src/net/sourceforge/plantuml/eggs/PSystemRIPFactory.java b/src/net/sourceforge/plantuml/eggs/PSystemRIPFactory.java deleted file mode 100644 index 95fb2f0..0000000 --- a/src/net/sourceforge/plantuml/eggs/PSystemRIPFactory.java +++ /dev/null @@ -1,59 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.eggs; - -import java.io.IOException; - -import net.sourceforge.plantuml.AbstractPSystem; -import net.sourceforge.plantuml.Log; -import net.sourceforge.plantuml.command.PSystemSingleLineFactory; - -public class PSystemRIPFactory extends PSystemSingleLineFactory { - - @Override - protected AbstractPSystem executeLine(String line) { - if (line.equalsIgnoreCase("jean canouet")) { - try { - return new PSystemRIP(); - } catch (IOException e) { - Log.error("Error " + e); - e.printStackTrace(); - } - } - return null; - } - -} diff --git a/src/net/sourceforge/plantuml/eggs/SentenceDecoder.java b/src/net/sourceforge/plantuml/eggs/SentenceDecoder.java deleted file mode 100644 index 37902a2..0000000 --- a/src/net/sourceforge/plantuml/eggs/SentenceDecoder.java +++ /dev/null @@ -1,69 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.eggs; - -import java.io.UnsupportedEncodingException; - -public class SentenceDecoder { - - private final String secret; - - public SentenceDecoder(String sentence1, byte[] crypted) throws UnsupportedEncodingException { - final byte[] key = EggUtils.fromSecretSentence(sentence1).toByteArray(); - final byte[] sen2 = EggUtils.xor(crypted, key); - this.secret = new String(sen2, "UTF-8"); - } - - public boolean isOk() { - for (char c : secret.toCharArray()) { - if ((int) c > 256) { - return false; - } - if (Character.isDefined(c) == false) { - return false; - } - if (Character.isISOControl(c)) { - return false; - } - } - return true; - } - - public String getSecret() { - return secret; - } - -} diff --git a/src/net/sourceforge/plantuml/eggs/SentenceProducer.java b/src/net/sourceforge/plantuml/eggs/SentenceProducer.java deleted file mode 100644 index 88124c0..0000000 --- a/src/net/sourceforge/plantuml/eggs/SentenceProducer.java +++ /dev/null @@ -1,55 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.eggs; - -import java.io.UnsupportedEncodingException; - -public class SentenceProducer { - - private final String secret; - - public SentenceProducer(String sentence1, String sentence2) throws UnsupportedEncodingException { - final byte[] key = EggUtils.fromSecretSentence(sentence1).toByteArray(); - final byte[] sen2 = sentence2.getBytes("UTF-8"); - final byte[] crypted = EggUtils.xor(sen2, key); - this.secret = EggUtils.fromByteArrays(crypted); - } - - public String getSecret() { - return secret; - } - -} diff --git a/src/net/sourceforge/plantuml/flashcode/FlashCodeFactory.java b/src/net/sourceforge/plantuml/flashcode/FlashCodeFactory.java index c0ad1a3..4cf8b7f 100644 --- a/src/net/sourceforge/plantuml/flashcode/FlashCodeFactory.java +++ b/src/net/sourceforge/plantuml/flashcode/FlashCodeFactory.java @@ -38,17 +38,7 @@ package net.sourceforge.plantuml.flashcode; public class FlashCodeFactory { public static FlashCodeUtils getFlashCodeUtils() { - final String name = "net.sourceforge.plantuml.flashcode.FlashCodeUtilsZxing"; - try { - final Class cl = Class.forName(name); - return (FlashCodeUtils) cl.newInstance(); - } catch (ClassNotFoundException e) { - return new FlashCodeUtilsNone(); - } catch (InstantiationException e) { - return new FlashCodeUtilsNone(); - } catch (IllegalAccessException e) { - return new FlashCodeUtilsNone(); - } + return new FlashCodeUtilsZxing(); } } diff --git a/src/net/sourceforge/plantuml/flashcode/FlashCodeUtilsNone.java b/src/net/sourceforge/plantuml/flashcode/FlashCodeUtilsNone.java deleted file mode 100644 index b5d496d..0000000 --- a/src/net/sourceforge/plantuml/flashcode/FlashCodeUtilsNone.java +++ /dev/null @@ -1,47 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.flashcode; - -import java.awt.Color; -import java.awt.image.BufferedImage; - -public class FlashCodeUtilsNone implements FlashCodeUtils { - - public BufferedImage exportFlashcode(String s, Color fore, Color back) { - return null; - } - -} diff --git a/src/net/sourceforge/plantuml/ftp/FtpConnexion.java b/src/net/sourceforge/plantuml/ftp/FtpConnexion.java deleted file mode 100644 index 2ff0369..0000000 --- a/src/net/sourceforge/plantuml/ftp/FtpConnexion.java +++ /dev/null @@ -1,206 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.ftp; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import net.sourceforge.plantuml.BlockUml; -import net.sourceforge.plantuml.FileFormat; -import net.sourceforge.plantuml.FileFormatOption; -import net.sourceforge.plantuml.SourceStringReader; -import net.sourceforge.plantuml.core.DiagramDescription; - -public class FtpConnexion { - - private final String user; - private final Map<String, String> incoming = new HashMap<String, String>(); - private final Map<String, byte[]> outgoing = new HashMap<String, byte[]>(); - private final Set<String> futureOutgoing = new HashSet<String>(); - - private FileFormat fileFormat; - - public FtpConnexion(String user, FileFormat defaultfileFormat) { - this.user = user; - this.fileFormat = defaultfileFormat; - } - - public synchronized void addIncoming(String fileName, String data) { - if (fileName.startsWith("/")) { - throw new IllegalArgumentException(); - } - incoming.put(fileName, data); - } - - public synchronized void futureOutgoing(String fileName) { - outgoing.remove(fileName); - futureOutgoing.add(fileName); - } - - public synchronized Collection<String> getFiles() { - final List<String> result = new ArrayList<String>(incoming.keySet()); - result.addAll(outgoing.keySet()); - result.addAll(futureOutgoing); - return Collections.unmodifiableCollection(result); - } - - public synchronized boolean willExist(String fileName) { - if (incoming.containsKey(fileName)) { - return true; - } - if (outgoing.containsKey(fileName)) { - return true; - } - if (futureOutgoing.contains(fileName)) { - return true; - } - return false; - } - - public synchronized boolean doesExist(String fileName) { - if (incoming.containsKey(fileName)) { - return true; - } - if (outgoing.containsKey(fileName)) { - return true; - } - return false; - } - - public synchronized byte[] getData(String fileName) throws InterruptedException { - if (fileName.startsWith("/")) { - throw new IllegalArgumentException(); - } - final String data = incoming.get(fileName); - if (data != null) { - return data.getBytes(); - } - // do { - // if (willExist(fileName) == false) { - // return null; - // } - final byte data2[] = outgoing.get(fileName); - if (data2 == null) { - return new byte[1]; - } - // if (data2 != null) { - return data2; - // } - // Thread.sleep(200L); - // } while (true); - } - - public synchronized int getSize(String fileName) { - if (fileName.startsWith("/")) { - throw new IllegalArgumentException(); - } - final String data = incoming.get(fileName); - if (data != null) { - return data.length(); - } - final byte data2[] = outgoing.get(fileName); - if (data2 != null) { - return data2.length; - } - return 0; - } - - public void processImage(String fileName) throws IOException { - if (fileName.startsWith("/")) { - throw new IllegalArgumentException(); - } - final String pngFileName = getFutureFileName(fileName); - boolean done = false; - try { - final SourceStringReader sourceStringReader = new SourceStringReader(incoming.get(fileName)); - final ByteArrayOutputStream baos = new ByteArrayOutputStream(); - final FileFormat format = getFileFormat(); - final DiagramDescription desc = sourceStringReader.generateDiagramDescription(new FileFormatOption(format)); - final List<BlockUml> blocks = sourceStringReader.getBlocks(); - if (blocks.size() > 0) { - blocks.get(0).getDiagram().exportDiagram(baos, 0, new FileFormatOption(format)); - } - final String errorFileName = pngFileName.substring(0, pngFileName.length() - 4) + ".err"; - synchronized (this) { - outgoing.remove(pngFileName); - futureOutgoing.remove(pngFileName); - outgoing.remove(errorFileName); - if (desc != null && desc.getDescription() != null) { - outgoing.put(pngFileName, baos.toByteArray()); - done = true; - if (desc.getDescription().startsWith("(Error)")) { - final ByteArrayOutputStream errBaos = new ByteArrayOutputStream(); - sourceStringReader.outputImage(errBaos, new FileFormatOption(FileFormat.ATXT)); - errBaos.close(); - outgoing.put(errorFileName, errBaos.toByteArray()); - } - } - } - } finally { - if (done == false) { - outgoing.put(pngFileName, new byte[0]); - } - } - } - - public String getFutureFileName(String fileName) { - return getFileFormat().changeName(fileName, 0); - } - - private FileFormat getFileFormat() { - return fileFormat; - } - - public synchronized void delete(String fileName) { - incoming.remove(fileName); - outgoing.remove(fileName); - futureOutgoing.add(fileName); - } - - public void setFileFormat(FileFormat fileFormat) { - this.fileFormat = fileFormat; - - } - -} diff --git a/src/net/sourceforge/plantuml/ftp/FtpLoop.java b/src/net/sourceforge/plantuml/ftp/FtpLoop.java deleted file mode 100644 index 06d21c8..0000000 --- a/src/net/sourceforge/plantuml/ftp/FtpLoop.java +++ /dev/null @@ -1,333 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.ftp; - -// server - -// FtpServer.java -import java.io.BufferedReader; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.io.PrintWriter; -import java.net.ServerSocket; -import java.net.Socket; -import java.net.UnknownHostException; -import java.util.Collection; -import java.util.StringTokenizer; - -import net.sourceforge.plantuml.FileFormat; -import net.sourceforge.plantuml.FileUtils; -import net.sourceforge.plantuml.StringUtils; - -class FtpLoop implements Runnable { - enum Mode { - ACTIF, PASSIF - }; - - final private Socket incoming; - final private FtpServer ftpServer; - final private BufferedReader br; - final private PrintWriter pw; - - private FtpConnexion connexion; - private String ipClient = null; - private int port = -1; - private Mode mode; - - public FtpLoop(Socket socket, FtpServer ftpServer) throws IOException { - this.incoming = socket; - this.ftpServer = ftpServer; - this.br = new BufferedReader(new InputStreamReader(incoming.getInputStream(), ftpServer.getCharset())); - this.pw = new PrintWriter(incoming.getOutputStream(), true); - } - - // http://www.ncftp.com/libncftp/doc/ftp_overview.html - // http://www.nsftools.com/tips/RawFTP.htm - // http://www.commentcamarche.net/contents/internet/ftp.php3 - // http://en.wikipedia.org/wiki/List_of_FTP_server_return_codes - // http://www.freefire.org/articles/ftpexample.php - // http://forum.hardware.fr/hfr/Programmation/VB-VBA-VBS/transfert-sujet_59989_1.htm - // http://www.excel-downloads.com/forum/104130-telechargement-ftp-via-vba.html - // http://www.pcreview.co.uk/forums/ftp-vba-macro-t949945.html - private void runInternal() throws IOException, InterruptedException { - localLog("Starting Loop"); - myOut("220 PlantUML"); - while (true) { - final String s = br.readLine(); - localLog("s=" + s); - if (s == null) { - pw.close(); - br.close(); - return; - } - final boolean finish = manage(s); - if (finish) { - return; - } - } - } - - private boolean manage(final String cmd) throws UnknownHostException, IOException, InterruptedException { - final String upper = StringUtils.goUpperCase(cmd); - if (upper.startsWith("USER")) { - myOut("331 Password required"); - final String user = cmd.substring("USER ".length()); - connexion = ftpServer.getFtpConnexion(user); - } else if (upper.startsWith("PASS")) { - myOut("230 Logged in."); - } else if (upper.startsWith("PWD")) { - // myOut("/"); - // myOut("200 OK /"); - myOut("257 \"/\" is current directory."); - } else if (upper.startsWith("CWD")) { - final String dir = cmd.substring("CWD ".length()); - myOut("250 \"" + dir + "\" is new working directory.."); - } else if (upper.startsWith("TYPE")) { - myOut("200 Command okay."); - // localLog("type=" + s); - } else if (upper.startsWith("PORT")) { - mode = Mode.ACTIF; - final StringTokenizer st = new StringTokenizer(cmd, " ,"); - st.nextToken(); - ipClient = st.nextToken() + "." + st.nextToken() + "." + st.nextToken() + "." + st.nextToken(); - port = Integer.parseInt(st.nextToken()) * 256 + Integer.parseInt(st.nextToken()); - // localLog("ipClient=" + ipClient); - // localLog("port=" + port); - - myOut("200 Command okay."); - } else if (upper.startsWith("LIST")) { - if (mode == Mode.ACTIF) { - listActif(); - } else { - listPassif(); - } - } else if (upper.startsWith("STOR")) { - if (mode == Mode.ACTIF) { - storActif(cmd); - } else { - storPassif(cmd); - } - } else if (upper.startsWith("PASV")) { - mode = Mode.PASSIF; - port = ftpServer.getFreePort(); - final int p1 = port / 256; - final int p2 = port % 256; - assert port == p1 * 256 + p2; - localLog("adr=" + incoming.getInetAddress().getHostAddress()); - final String ipServer = ftpServer.getIpServer(); - localLog("server=" + ipServer); - myOut("227 Entering Passive Mode (" + ipServer.replace('.', ',') + "," + p1 + "," + p2 + ")."); - ipClient = ipServer; - } else if (upper.startsWith("RETR")) { - if (mode == Mode.ACTIF) { - retrActif(cmd); - } else { - retrPassif(cmd); - } - } else if (upper.startsWith("DELE")) { - final String file = cmd.substring("DELE ".length()); - connexion.delete(file); - myOut("200 Command okay."); - } else if (upper.startsWith("QUIT")) { - myOut("221 Goodbye."); - return true; - } else if (upper.startsWith("SYST")) { - myOut("215 UNIX Type: L8."); - } else { - myOut("502 Command not implemented."); - } - return false; - } - - private void localLog(String s) { - } - - private void retr(final String fileName, Socket soc) throws UnknownHostException, IOException, InterruptedException { - final OutputStream os = soc.getOutputStream(); - final byte[] data = connexion.getData(fileName); - - if (data != null) { - os.write(data); - } - os.flush(); - os.close(); - soc.close(); - myOut("226 Transfer complete."); - } - - private void retrPassif(final String s) throws UnknownHostException, IOException, InterruptedException { - String fileName = s.substring("STOR ".length()); - fileName = removeStartingsSlash(fileName); - if (connexion.willExist(fileName) == false) { - myOut("550 No such file."); - return; - } - myOut("150 Opening"); - waitForMe(fileName); - final ServerSocket ss = new ServerSocket(port); - final Socket incoming = ss.accept(); - retr(fileName, incoming); - ss.close(); - } - - private void waitForMe(String fileName) throws InterruptedException { - do { - if (connexion.doesExist(fileName)) { - return; - } - Thread.sleep(200L); - } while (true); - } - - private void retrActif(final String s) throws UnknownHostException, IOException, InterruptedException { - String fileName = s.substring("STOR ".length()); - fileName = removeStartingsSlash(fileName); - if (connexion.willExist(fileName) == false) { - myOut("550 No such file."); - return; - } - myOut("150 Opening"); - waitForMe(fileName); - final Socket soc = new Socket(ipClient, port); - retr(fileName, soc); - } - - private void storActif(final String s) throws IOException { - final String fileName = removeStartingsSlash(s.substring("STOR ".length())); - myOut("150 FILE: " + fileName); - final Socket soc = new Socket(ipClient, port); - stor(fileName, soc); - } - - private void storPassif(final String s) throws IOException { - final String fileName = removeStartingsSlash(s.substring("STOR ".length())); - myOut("150 FILE: " + fileName); - final ServerSocket ss = new ServerSocket(port); - final Socket incoming = ss.accept(); - stor(fileName, incoming); - ss.close(); - } - - private String removeStartingsSlash(String fileName) { - while (fileName.startsWith("/")) { - fileName = fileName.substring(1); - } - return fileName; - } - - private void stor(String fileName, Socket socket) throws UnknownHostException, IOException { - final InputStream is = socket.getInputStream(); - final ByteArrayOutputStream baos = new ByteArrayOutputStream(); - FileUtils.copyToStream(is, baos); - - myOut("226 Transfer complete."); - - if ("png".equalsIgnoreCase(fileName)) { - connexion.setFileFormat(FileFormat.PNG); - } else if ("svg".equalsIgnoreCase(fileName)) { - connexion.setFileFormat(FileFormat.SVG); - } else if ("eps".equalsIgnoreCase(fileName)) { - connexion.setFileFormat(FileFormat.EPS); - } - - if (fileName.length() > 3) { - final String data = new String(baos.toByteArray(), ftpServer.getCharset()); - final String pngFileName = connexion.getFutureFileName(fileName); - connexion.futureOutgoing(pngFileName); - connexion.addIncoming(fileName, data); - - ftpServer.processImage(connexion, fileName); - } - } - - private void listActif() throws UnknownHostException, IOException { - myOut("150 Opening ASCII mode data"); - final Socket soc = new Socket(ipClient, port); - list(soc); - } - - private void listPassif() throws UnknownHostException, IOException { - myOut("150 Opening ASCII mode data"); - final ServerSocket ss = new ServerSocket(port); - final Socket incoming = ss.accept(); - list(incoming); - ss.close(); - } - - private void list(final Socket soc) throws IOException { - final PrintWriter listing = new PrintWriter(soc.getOutputStream(), true); - final Collection<String> files = connexion.getFiles(); - if (files.size() > 0) { - int total = 0; - for (String n : files) { - total += (connexion.getSize(n) + 511) / 512; - } - listing.println("total " + total); - // localLog(total); - for (String n : files) { - final String ls = String.format("%10s %4d %-8s %-8s %8d %3s %2s %5s %s", "-rw-rw-r--", 1, "plantuml", - "plantuml", connexion.getSize(n), "Sep", 28, 2006, n); - listing.println(ls); - // localLog(ls); - } - } - listing.flush(); - listing.close(); - soc.close(); - myOut("226 Listing completed."); - } - - private void myOut(String s) { - if (s.indexOf('\t') != -1) { - throw new IllegalArgumentException(); - } - pw.println(s); - pw.flush(); - } - - public void run() { - try { - runInternal(); - } catch (Throwable t) { - t.printStackTrace(); - } - - } - -} diff --git a/src/net/sourceforge/plantuml/ftp/FtpServer.java b/src/net/sourceforge/plantuml/ftp/FtpServer.java deleted file mode 100644 index b6f0a7a..0000000 --- a/src/net/sourceforge/plantuml/ftp/FtpServer.java +++ /dev/null @@ -1,128 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.ftp; - -// server - -// FtpServer.java -import java.io.IOException; -import java.net.ServerSocket; -import java.net.Socket; -import java.util.Map; -import java.util.TreeMap; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; - -import net.sourceforge.plantuml.FileFormat; - -public class FtpServer { - - private final Map<String, FtpConnexion> datas = new TreeMap<String, FtpConnexion>(); - private final ExecutorService exeImage = Executors.newFixedThreadPool(2); - private final String charset = "UTF-8"; - - private final int listenPort; - - private int portFree = 10042; - private String ip; - private final FileFormat defaultfileFormat; - - public FtpServer(int listenPort, FileFormat defaultfileFormat) { - this.listenPort = listenPort; - this.defaultfileFormat = defaultfileFormat == null ? FileFormat.PNG : defaultfileFormat; - } - - public synchronized int getFreePort() { - portFree++; - // Log.println("port=" + portFree); - return portFree; - } - - public void go() throws IOException { - final ServerSocket s = new ServerSocket(listenPort); - final ExecutorService exe = Executors.newCachedThreadPool(); - while (true) { - final Socket incoming = s.accept(); - ip = incoming.getLocalAddress().getHostAddress(); - System.out.println("New Client Connected from " + incoming.getInetAddress().getHostName() + "... "); - exe.submit(new FtpLoop(incoming, this)); - } - } - - public String getIpServer() { - return ip; - } - - public synchronized FtpConnexion getFtpConnexion(String user) { - if (user == null) { - throw new IllegalArgumentException(); - } - FtpConnexion data = datas.get(user); - if (data == null) { - data = new FtpConnexion(user, defaultfileFormat); - datas.put(user, data); - } - return data; - } - - public static void main(String[] args) throws IOException { - System.out.println("****************************** ************************************************** "); - System.out.println("****************************** FTP SERVER***********************************"); - - System.out.println("****************************** ************************************************** "); - System.out.println("Server Started..."); - System.out.println("Waiting for connections..."); - System.out.println(" "); - new FtpServer(4242, FileFormat.PNG).go(); - } - - public void processImage(final FtpConnexion connexion, final String name) { - exeImage.submit(new Runnable() { - public void run() { - try { - connexion.processImage(name); - } catch (IOException e) { - e.printStackTrace(); - } - } - }); - } - - public final String getCharset() { - return charset; - } - -} diff --git a/src/net/sourceforge/plantuml/geom/AbstractFigure.java b/src/net/sourceforge/plantuml/geom/AbstractFigure.java deleted file mode 100644 index a49223c..0000000 --- a/src/net/sourceforge/plantuml/geom/AbstractFigure.java +++ /dev/null @@ -1,315 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.geom; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import net.sourceforge.plantuml.Log; - -abstract class AbstractFigure { - - private final Set<LineSegmentInt> segments = new HashSet<LineSegmentInt>(); - - @Override - public String toString() { - return segments.toString(); - } - - @Override - final public boolean equals(Object obj) { - final AbstractFigure other = (AbstractFigure) obj; - return segments.equals(other.segments); - } - - @Override - final public int hashCode() { - return segments.hashCode(); - } - - protected boolean knowThisPoint(Point2DInt p) { - for (LineSegmentInt seg : segments) { - if (seg.getP1().equals(p) || seg.getP2().equals(p)) { - return true; - } - } - return false; - } - - LineSegmentInt existingSegment(Point2DInt p1, Point2DInt p2) { - for (LineSegmentInt seg : segments) { - if (seg.getP1().equals(p1) && seg.getP2().equals(p2)) { - return seg; - } - if (seg.getP1().equals(p2) && seg.getP2().equals(p1)) { - return seg; - } - } - return null; - } - - Collection<LineSegmentInt> getSegmentsWithExtremity(Point2DInt extremity, Collection<LineSegmentInt> exceptions) { - final Collection<LineSegmentInt> result = new HashSet<LineSegmentInt>(); - for (LineSegmentInt seg : segments) { - if (exceptions.contains(seg)) { - continue; - } - if (seg.getP1().equals(extremity) || seg.getP2().equals(extremity)) { - result.add(seg); - } - } - return Collections.unmodifiableCollection(result); - } - - public void addSegment(LineSegmentInt seg) { - segments.add(seg); - } - - protected final Set<LineSegmentInt> getSegments() { - return Collections.unmodifiableSet(segments); - } - - @Deprecated - public Polyline addPath(Point2DInt start, Point2DInt end) { - if (knowThisPoint(start) && knowThisPoint(end)) { - return getPath(start, end); - } - final LineSegmentInt direct = new LineSegmentInt(start, end); - addSegment(direct); - return new PolylineImpl(start, end); - } - - public Polyline addDirectLink(Point2DInt start, Point2DInt end) { - final LineSegmentInt direct = new LineSegmentInt(start, end); - addSegment(direct); - Log.println("AbstractFigure::addDirectLink " + direct); - return new PolylineImpl(start, end); - } - - public boolean isSimpleSegmentPossible(Point2DInt start, Point2DInt end) { - final LineSegmentInt direct = new LineSegmentInt(start, end); - return hasIntersectionStrict(direct) == false; - } - - public Polyline getPath(Pointable start, Pointable end) { - if (knowThisPoint(start.getPosition()) == false) { - throw new IllegalArgumentException(); - } - if (knowThisPoint(end.getPosition()) == false) { - throw new IllegalArgumentException("" + end.getPosition()); - } - if (isSimpleSegmentPossible(start.getPosition(), end.getPosition())) { - throw new IllegalArgumentException(); - // return new PolylineImpl(start, end); - } - if (arePointsConnectable(start.getPosition(), end.getPosition()) == false) { - return null; - } - return findBestPath(start, end); - } - - private Polyline findBestPath(Pointable start, Pointable end) { - Log.println("start=" + start.getPosition()); - Log.println("end=" + end.getPosition()); - final Set<Point2DInt> points = getAllPoints(); - if (points.contains(start.getPosition()) == false || points.contains(end.getPosition()) == false) { - throw new IllegalArgumentException(); - } - points.remove(start.getPosition()); - points.remove(end.getPosition()); - final List<Neighborhood> neighborhoods = new ArrayList<Neighborhood>(); - for (Point2DInt p : points) { - neighborhoods.addAll(getSingularity(p).getNeighborhoods()); - } - for (int i = 0; i < neighborhoods.size(); i++) { - Log.println("N" + (i + 1) + " " + neighborhoods.get(i)); - } - final Dijkstra dijkstra = new Dijkstra(neighborhoods.size() + 2); - Log.println("size=" + dijkstra.getSize()); - for (int i = 0; i < neighborhoods.size(); i++) { - if (isConnectable(start.getPosition(), neighborhoods.get(i))) { - dijkstra.addLink(0, i + 1, distance(start.getPosition(), neighborhoods.get(i).getCenter())); - } - } - for (int i = 0; i < neighborhoods.size(); i++) { - for (int j = 0; j < neighborhoods.size(); j++) { - if (i == j) { - continue; - } - if (isConnectable(neighborhoods.get(i), neighborhoods.get(j))) { - dijkstra.addLink(i + 1, j + 1, distance(neighborhoods.get(i).getCenter(), neighborhoods.get(j) - .getCenter())); - } - } - } - for (int i = 0; i < neighborhoods.size(); i++) { - if (isConnectable(end.getPosition(), neighborhoods.get(i))) { - dijkstra.addLink(i + 1, neighborhoods.size() + 1, distance(end.getPosition(), neighborhoods.get(i) - .getCenter())); - } - } - final List<Integer> path = dijkstra.getBestPath(); - if (path.get(path.size() - 1) != neighborhoods.size() + 1) { - throw new IllegalStateException("No Path"); - } - assert path.size() > 2; - - Log.println("PATH=" + path); - final List<Neighborhood> usedNeighborhoods = new ArrayList<Neighborhood>(); - for (int i = 1; i < path.size() - 1; i++) { - final int idx = path.get(i) - 1; - usedNeighborhoods.add(neighborhoods.get(idx)); - } - return findApproximatePath(start, end, usedNeighborhoods); - } - - private Polyline findApproximatePath(Pointable start, Pointable end, final List<Neighborhood> neighborhoods) { - System.err - .println("findApproximatePath " + start.getPosition() + " " + end.getPosition() + " " + neighborhoods); - final PolylineImpl result = new PolylineImpl(start, end); - for (Neighborhood n : neighborhoods) { - Log.println("Neighborhood =" + n); - final double d = getProximaDistance(n.getCenter()) / 2; - final double a = n.getMiddle(); - Log.println("d=" + d); - Log.println("a=" + a * 180 / Math.PI); - final double deltaX = d * Math.cos(a); - final double deltaY = d * Math.sin(a); - assert d > 0; - Log.println("Result = " + n.getCenter().translate((int) deltaX, (int) deltaY)); - result.addIntermediate(n.getCenter().translate((int) deltaX, (int) deltaY)); - } - return result; - } - - private double getProximaDistance(Point2DInt center) { - double result = Double.MAX_VALUE; - for (Point2DInt p : getAllPoints()) { - if (center.equals(p)) { - continue; - } - final double cur = new LineSegmentInt(p, center).getLength(); - result = Math.min(result, cur); - } - return result; - } - - static private double distance(Point2DInt p1, Point2DInt p2) { - return new LineSegmentInt(p1, p2).getLength(); - } - - public boolean isConnectable(Point2DInt p, Neighborhood n) { - final LineSegmentInt seg = new LineSegmentInt(n.getCenter(), p); - if (hasIntersectionStrict(seg)) { - return false; - } - final double angle = Singularity.convertAngle(seg.getAngle()); - return n.isInAngleLarge(angle); - } - - public boolean isConnectable(Neighborhood n1, Neighborhood n2) { - final boolean result = isConnectableInternal(n1, n2); - assert result == isConnectableInternal(n2, n1); - return result; - } - - private boolean isConnectableInternal(Neighborhood n1, Neighborhood n2) { - if (n1.getCenter().equals(n2.getCenter())) { - return false; - } - final LineSegmentInt seg1 = new LineSegmentInt(n1.getCenter(), n2.getCenter()); - if (hasIntersectionStrict(seg1)) { - return false; - } - final double angle1 = Singularity.convertAngle(seg1.getAngle()); - final double angle2 = Singularity.convertAngle(seg1.getOppositeAngle()); - assert angle2 == Singularity.convertAngle(new LineSegmentInt(n2.getCenter(), n1.getCenter()).getAngle()); - if (n1.isInAngleStrict(angle1) && n2.isInAngleStrict(angle2)) { - return true; - } - if (n1.isAngleLimit(angle1) && n2.isAngleLimit(angle2)) { - if (n1.is360() || n2.is360()) { - return true; - } - final Orientation o1 = n1.getOrientationFrom(angle1); - final Orientation o2 = n2.getOrientationFrom(angle2); - return o1 != o2; - } - return false; - } - - private boolean hasIntersectionStrict(LineSegmentInt direct) { - for (LineSegmentInt seg : getSegments()) { - if (seg.atLeastOneCommonExtremities(direct)) { - continue; - } - if (seg.doesIntersect(direct)) { - Log.println("seg=" + seg); - Log.println("direct=" + direct); - Log.println("AbstractFigure::hasIntersectionStrict true"); - return true; - } - } - Log.println("AbstractFigure::hasIntersectionStrict false"); - return false; - } - - public Singularity getSingularity(Point2DInt center) { - final Singularity singularity = new Singularity(center); - for (LineSegmentInt seg : getSegments()) { - if (seg.containsPoint(center)) { - singularity.addLineSegment(seg); - } - } - return singularity; - } - - private Set<Point2DInt> getAllPoints() { - final Set<Point2DInt> result = new HashSet<Point2DInt>(); - for (LineSegmentInt seg : segments) { - result.add(seg.getP1()); - result.add(seg.getP2()); - } - return result; - } - - abstract boolean arePointsConnectable(Point2DInt p1, Point2DInt p2); - -} diff --git a/src/net/sourceforge/plantuml/geom/AbstractPolyline.java b/src/net/sourceforge/plantuml/geom/AbstractPolyline.java deleted file mode 100644 index bc0c1af..0000000 --- a/src/net/sourceforge/plantuml/geom/AbstractPolyline.java +++ /dev/null @@ -1,200 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.geom; - -import java.awt.geom.GeneralPath; - -abstract class AbstractPolyline implements Polyline { - - private final Pointable start; - private final Pointable end; - - public AbstractPolyline(Pointable start, Pointable end) { - this.start = start; - this.end = end; - } - - @Override - final public String toString() { - return segments().toString(); - } - - final public boolean doesTouch(Polyline other) { - final boolean result = doesTouchInternal(other); - assert result == ((AbstractPolyline) other).doesTouchInternal(this); - return result; - } - - private boolean doesTouchInternal(Polyline other) { - for (int i = 0; i < nbSegments(); i++) { - final LineSegmentInt seg1 = segments().get(i); - for (int j = 0; j < other.nbSegments(); j++) { - final LineSegmentInt seg2 = other.segments().get(j); - final boolean ignoreExtremities = i == 0 || i == nbSegments() - 1 || j == 0 - || j == other.nbSegments() - 1; - if (ignoreExtremities == false && seg1.doesIntersect(seg2)) { - return true; - } - if (ignoreExtremities && seg1.doesIntersectButNotSameExtremity(seg2)) { - return true; - } - } - } - return false; - } - - final public LineSegmentInt getFirst() { - return segments().get(0); - } - - final public LineSegmentInt getLast() { - return segments().get(nbSegments() - 1); - } - - final public double getLength() { - double result = 0; - for (LineSegmentInt seg : segments()) { - result += seg.getLength(); - } - return result; - } - - final public Point2DInt clipStart(Box box) { - assert box.doesIntersect(segments().get(0)); - final Point2DInt inter[] = box.intersect(segments().get(0)); - assert inter.length == 1; - segments().set( - 0, - new LineSegmentInt(inter[0].getXint(), inter[0].getYint(), segments().get(0).getP2().getXint(), - segments().get(0).getP2().getYint())); - return inter[0]; - } - - final public Point2DInt clipEnd(Box box) { - final int last = nbSegments() - 1; - if (last == -1) { - return null; - } - assert box.doesIntersect(segments().get(last)); - final Point2DInt inter[] = box.intersect(segments().get(last)); - assert inter.length == 1; - segments().set( - last, - new LineSegmentInt(segments().get(last).getP1().getXint(), segments().get(last).getP1().getYint(), - inter[0].getXint(), inter[0].getYint())); - return inter[0]; - } - - final public boolean intersectBox(Box b) { - for (LineSegmentInt seg : segments()) { - if (b.doesIntersect(seg)) { - return true; - } - } - return false; - } - - final public double getDistance(Box b) { - double result = Double.MAX_VALUE; - for (LineSegmentInt seg : segments()) { - if (b.doesIntersect(seg)) { - result = Math.min(result, seg.getDistance(b.getCenterPoint())); - } - } - return result; - } - - final public double getDistance(Polyline other) { - double result = 0; - for (LineSegmentInt seg1 : segments()) { - for (LineSegmentInt seg2 : other.segments()) { - result += seg1.getDistance(seg2); - } - } - return result; - } - - final public GeneralPath asGeneralPath() { - final GeneralPath generalPath = new GeneralPath(); - - for (LineSegmentInt seg : segments()) { - generalPath.append(seg, false); - } - - return generalPath; - } - - final public int getMinX() { - int result = Integer.MAX_VALUE; - for (LineSegmentInt seg : segments()) { - result = Math.min(result, seg.getMinX()); - } - return result; - } - - final public int getMinY() { - int result = Integer.MAX_VALUE; - for (LineSegmentInt seg : segments()) { - result = Math.min(result, seg.getMinY()); - } - return result; - } - - final public int getMaxX() { - int result = Integer.MIN_VALUE; - for (LineSegmentInt seg : segments()) { - result = Math.max(result, seg.getMaxX()); - } - return result; - } - - final public int getMaxY() { - int result = Integer.MIN_VALUE; - for (LineSegmentInt seg : segments()) { - result = Math.max(result, seg.getMaxY()); - } - return result; - } - - public final Pointable getStart() { - return start; - } - - public final Pointable getEnd() { - return end; - } - -} diff --git a/src/net/sourceforge/plantuml/geom/Box.java b/src/net/sourceforge/plantuml/geom/Box.java deleted file mode 100644 index 222171b..0000000 --- a/src/net/sourceforge/plantuml/geom/Box.java +++ /dev/null @@ -1,240 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.geom; - -public class Box implements XMoveable, Pointable { - - private int x; - private int y; - final private int width; - final private int height; - - public Box(int x, int y, int width, int height) { - if (width <= 0 || height <= 0) { - throw new IllegalArgumentException(); - } - this.x = x; - this.y = y; - this.width = width; - this.height = height; - } - - @Override - public String toString() { - return "Box [" + x + "," + y + "] " + width + "," + height; - } - - public Point2DInt[] getCorners() { - final Point2DInt p1 = new Point2DInt(getX(), getY()); - final Point2DInt p2 = new Point2DInt(getX() + getWidth(), getY()); - final Point2DInt p3 = new Point2DInt(getX() + getWidth(), getY() + getHeight()); - final Point2DInt p4 = new Point2DInt(getX(), getY() + getHeight()); - return new Point2DInt[] { p1, p2, p3, p4 }; - } - - public Point2DInt[] getCornersOfOneSide(LineSegmentInt seg, int sgn) { - final Point2DInt[] corners = getCorners(); - final double sgn0 = seg.side(corners[0]); - final double sgn1 = seg.side(corners[1]); - final double sgn2 = seg.side(corners[2]); - final double sgn3 = seg.side(corners[3]); - int nb = 0; - if (Math.signum(sgn0) == sgn) { - nb++; - } - if (Math.signum(sgn1) == sgn) { - nb++; - } - if (Math.signum(sgn2) == sgn) { - nb++; - } - if (Math.signum(sgn3) == sgn) { - nb++; - } - final Point2DInt[] result = new Point2DInt[nb]; - int i = 0; - if (Math.signum(sgn0) == sgn) { - result[i++] = corners[0]; - } - if (Math.signum(sgn1) == sgn) { - result[i++] = corners[1]; - } - if (Math.signum(sgn2) == sgn) { - result[i++] = corners[2]; - } - if (Math.signum(sgn3) == sgn) { - result[i++] = corners[3]; - } - assert nb == i; - return result; - } - - public boolean doesIntersect(LineSegmentInt seg) { - return intersect(seg).length > 0; - } - - public Point2DInt[] intersect(LineSegmentInt seg) { - if (seg.side(this) != 0) { - return new Point2DInt[0]; - } - // Log.println("THIS=" + this); - // Log.println("LineSegment=" + seg); - final Point2DInt corners[] = getCorners(); - final LineSegmentInt seg1 = new LineSegmentInt(corners[0], corners[1]); - final LineSegmentInt seg2 = new LineSegmentInt(corners[1], corners[2]); - final LineSegmentInt seg3 = new LineSegmentInt(corners[2], corners[3]); - final LineSegmentInt seg4 = new LineSegmentInt(corners[3], corners[0]); - final Point2DInt i1 = seg.getSegIntersection(seg1); - Point2DInt i2 = seg.getSegIntersection(seg2); - Point2DInt i3 = seg.getSegIntersection(seg3); - Point2DInt i4 = seg.getSegIntersection(seg4); - - // Log.println("i1="+i1); - // Log.println("i2="+i2); - // Log.println("i3="+i3); - // Log.println("i4="+i4); - - if (i2 != null && i2.equals(i1)) { - i2 = null; - } - if (i3 != null && (i3.equals(i1) || i3.equals(i2))) { - i3 = null; - } - if (i4 != null && (i4.equals(i1) || i4.equals(i2) || i4.equals(i3))) { - i4 = null; - } - - final int nb = countNotNull(i1, i2, i3, i4); - assert nb >= 0 && nb <= 3 : nb; - int i = 0; - final Point2DInt result[] = new Point2DInt[nb]; - if (i1 != null) { - result[i++] = i1; - } - if (i2 != null) { - result[i++] = i2; - } - if (i3 != null) { - result[i++] = i3; - } - if (i4 != null) { - result[i++] = i4; - } - assert i == nb; - assert getCornersOfOneSide(seg, 0).length + getCornersOfOneSide(seg, 1).length - + getCornersOfOneSide(seg, -1).length == 4; - return result; - } - - private int countNotNull(Point2DInt i1, Point2DInt i2, Point2DInt i3, Point2DInt i4) { - int n = 0; - if (i1 != null) { - n++; - } - if (i2 != null) { - n++; - } - if (i3 != null) { - n++; - } - if (i4 != null) { - n++; - } - return n; - } - - public Box outerBox(int margin) { - return new Box(x - margin, y - margin, width + 2 * margin, height + 2 * margin); - } - - public Point2DInt getCenterPoint() { - return new Point2DInt(x + width / 2, y + height / 2); - } - - public void moveX(int delta) { - this.x += delta; - } - - public boolean intersectBox(Box other) { - return other.x + other.width > this.x && other.y + other.height > this.y && other.x < this.x + this.width - && other.y < this.y + this.height; - } - - public final int getX() { - return x; - } - - public final int getY() { - return y; - } - - public final int getWidth() { - return width; - } - - public final int getHeight() { - return height; - } - - public int getMinX() { - return x; - } - - public int getMinY() { - return y; - } - - public int getMaxX() { - return x + width; - } - - public int getMaxY() { - return y + height; - } - - public int getCenterX() { - return x + width / 2; - } - - public int getCenterY() { - return y + height / 2; - } - - public Point2DInt getPosition() { - return getCenterPoint(); - } - -} diff --git a/src/net/sourceforge/plantuml/geom/ClosedArea.java b/src/net/sourceforge/plantuml/geom/ClosedArea.java deleted file mode 100644 index 7b81ca0..0000000 --- a/src/net/sourceforge/plantuml/geom/ClosedArea.java +++ /dev/null @@ -1,297 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.geom; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; - -public class ClosedArea extends AbstractFigure { - - private final List<Point2DInt> points = new ArrayList<Point2DInt>(); - private final List<LineSegmentInt> segmentsList = new ArrayList<LineSegmentInt>(); - - private int minY = Integer.MAX_VALUE; - private int minX = Integer.MAX_VALUE; - private int maxX = Integer.MIN_VALUE; - private int maxY = Integer.MIN_VALUE; - - public ClosedArea() { - assert isConsistent(); - } - - @Override - public String toString() { - return points.toString(); - } - - public boolean contains(Point2DInt point) { - return contains(point.getXint(), point.getYint()); - } - - private boolean contains(int x, int y) { - if (points.size() <= 2) { - return false; - } - if (x > maxX) { - return false; - } - if (x < minX) { - return false; - } - if (y > maxY) { - return false; - } - if (y < minY) { - return false; - } - if (isOnFrontier(new Point2DInt(x, y))) { - return true; - } - int hits = 0; - - int lastx = getLastPoint().getXint(); - int lasty = getLastPoint().getYint(); - int curx; - int cury; - - // Walk the edges of the polygon - for (int i = 0; i < points.size(); lastx = curx, lasty = cury, i++) { - curx = points.get(i).getXint(); - cury = points.get(i).getYint(); - - if (cury == lasty) { - continue; - } - - final int leftx; - if (curx < lastx) { - if (x >= lastx) { - continue; - } - leftx = curx; - } else { - if (x >= curx) { - continue; - } - leftx = lastx; - } - - final double test1; - final double test2; - if (cury < lasty) { - if (y < cury || y >= lasty) { - continue; - } - if (x < leftx) { - hits++; - continue; - } - test1 = x - curx; - test2 = y - cury; - } else { - if (y < lasty || y >= cury) { - continue; - } - if (x < leftx) { - hits++; - continue; - } - test1 = x - lastx; - test2 = y - lasty; - } - - if (test1 < test2 / (lasty - cury) * (lastx - curx)) { - hits++; - } - - } - return (hits & 1) != 0; - - } - - private boolean isConsistent() { - assert getSegments().size() == segmentsList.size(); - assert getSegments().equals(new HashSet<LineSegmentInt>(segmentsList)); - if (getSegments().size() > 0) { - assert getSegments().size() + 1 == points.size() : "points=" + points + " getSegment()=" + getSegments(); - } - for (int i = 0; i < segmentsList.size(); i++) { - final LineSegmentInt seg = segmentsList.get(i); - if (seg.sameExtremities(new LineSegmentInt(points.get(i), points.get(i + 1))) == false) { - return false; - } - } - return true; - } - - public boolean isOnFrontier(Point2DInt point) { - for (LineSegmentInt seg : segmentsList) { - if (seg.containsPoint(point)) { - return true; - } - } - return false; - } - - public boolean isClosed() { - if (getSegments().size() < 3) { - return false; - } - if (getFirstSegment().atLeastOneCommonExtremities(getLastSegment())) { - return true; - } - return false; - } - - ClosedArea append(LineSegmentInt other) { - if (isClosed()) { - throw new IllegalStateException(); - } - if (getSegments().contains(other)) { - throw new IllegalArgumentException(); - } - final ClosedArea result = new ClosedArea(); - for (LineSegmentInt seg : segmentsList) { - result.addSegment(seg); - } - if (result.getSegments().size() > 0 && result.getLastSegment().atLeastOneCommonExtremities(other) == false) { - throw new IllegalArgumentException(); - } - if (points.contains(other.getP1()) && points.contains(other.getP2()) - && other.getP1().equals(getFirstPoint()) == false && other.getP2().equals(getFirstPoint()) == false) { - return null; - } - result.addSegment(other); - assert result.isConsistent(); - - return result; - } - - @Override - public void addSegment(LineSegmentInt seg) { - super.addSegment(seg); - minY = Math.min(minY, seg.getMinY()); - maxY = Math.max(maxY, seg.getMaxY()); - minX = Math.min(minX, seg.getMinX()); - maxX = Math.max(maxX, seg.getMaxX()); - segmentsList.add(seg); - if (points.size() == 0) { - assert getSegments().size() == 1; - points.add(seg.getP1()); - points.add(seg.getP2()); - } else if (points.size() == 2) { - assert segmentsList.size() == 2; - final LineSegmentInt seg0 = segmentsList.get(0); - final LineSegmentInt seg1 = segmentsList.get(1); - points.clear(); - final Point2DInt common = seg0.getCommonExtremities(seg1); - if (common == null) { - throw new IllegalArgumentException(); - } - assert common.equals(seg1.getCommonExtremities(seg0)); - points.add(seg0.getOtherExtremity(common)); - points.add(common); - points.add(seg1.getOtherExtremity(common)); - - } else { - final Point2DInt lastPoint = getLastPoint(); - points.add(seg.getOtherExtremity(lastPoint)); - } - assert isConsistent(); - } - - private Point2DInt getLastPoint() { - return points.get(points.size() - 1); - } - - private Point2DInt getFirstPoint() { - return points.get(0); - } - - public LineSegmentInt getLastSegment() { - return segmentsList.get(segmentsList.size() - 1); - } - - private LineSegmentInt getFirstSegment() { - return segmentsList.get(0); - } - - public Point2DInt getFreePoint() { - if (isClosed()) { - throw new IllegalStateException(); - } - return getLastPoint(); - } - - public int getMinY() { - return minY; - } - - public int getMinX() { - return minX; - } - - public int getMaxY() { - return maxY; - } - - public int getMaxX() { - return maxX; - } - - public boolean contains(ClosedArea other) { - if (isClosed() == false) { - throw new IllegalStateException(); - } - for (Point2DInt point : other.points) { - if (this.contains(point) == false) { - return false; - } - } - return true; - } - - @Override - boolean arePointsConnectable(Point2DInt p1, Point2DInt p2) { - if (isOnFrontier(p1) || isOnFrontier(p2)) { - return true; - } - final boolean pos1 = contains(p1); - final boolean pos2 = contains(p2); - return pos1 == pos2; - } -} diff --git a/src/net/sourceforge/plantuml/geom/CollectionUtils.java b/src/net/sourceforge/plantuml/geom/CollectionUtils.java deleted file mode 100644 index fd587b0..0000000 --- a/src/net/sourceforge/plantuml/geom/CollectionUtils.java +++ /dev/null @@ -1,86 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.geom; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -public class CollectionUtils { - - public static <E> Collection<List<E>> selectUpTo(List<E> original, int nb) { - final List<List<E>> result = new ArrayList<List<E>>(); - for (int i = 1; i <= nb; i++) { - result.addAll(selectExactly(original, i)); - } - return Collections.unmodifiableList(result); - } - - public static <E> Collection<List<E>> selectExactly(List<E> original, int nb) { - if (nb < 0) { - throw new IllegalArgumentException(); - } - if (nb == 0) { - return Collections.emptyList(); - } - if (nb == 1) { - final List<List<E>> result = new ArrayList<List<E>>(); - for (E element : original) { - result.add(Collections.singletonList(element)); - } - return result; - - } - if (nb > original.size()) { - return Collections.emptyList(); - } - if (nb == original.size()) { - return Collections.singletonList(original); - } - final List<List<E>> result = new ArrayList<List<E>>(); - - for (List<E> subList : selectExactly(original.subList(1, original.size()), nb - 1)) { - final List<E> newList = new ArrayList<E>(); - newList.add(original.get(0)); - newList.addAll(subList); - result.add(Collections.unmodifiableList(newList)); - } - result.addAll(selectExactly(original.subList(1, original.size()), nb)); - - return Collections.unmodifiableList(result); - } -} diff --git a/src/net/sourceforge/plantuml/geom/Dijkstra.java b/src/net/sourceforge/plantuml/geom/Dijkstra.java deleted file mode 100644 index 150a4ce..0000000 --- a/src/net/sourceforge/plantuml/geom/Dijkstra.java +++ /dev/null @@ -1,130 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.geom; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -public class Dijkstra { - - final private double basic[][]; - final private double dist[]; - final private int previous[]; - final private Set<Integer> q = new HashSet<Integer>(); - final private int size; - - public Dijkstra(int size) { - this.size = size; - this.basic = new double[size][size]; - this.dist = new double[size]; - this.previous = new int[size]; - for (int i = 0; i < size; i++) { - for (int j = 0; j < size; j++) { - this.basic[i][j] = i == j ? 0 : Double.MAX_VALUE; - } - } - } - - public void addLink(int n1, int n2, double d) { -// Log.println("Adding " + n1 + " " + n2 + " " + d); - if (n1 == n2) { - throw new IllegalArgumentException(); - } - basic[n1][n2] = d; - basic[n2][n1] = d; - - } - - private void init() { - for (int i = 0; i < size; i++) { - this.dist[i] = Double.MAX_VALUE; - this.previous[i] = -1; - this.q.add(i); - } - this.dist[0] = 0; - } - - private void computePrevious() { - init(); - while (q.size() > 0) { - final int u = smallest(); - if (dist[u] == Double.MAX_VALUE) { - return; - } - q.remove(u); - for (int v = 0; v < size; v++) { - if (basic[u][v] == Double.MAX_VALUE) { - continue; - } - final double alt = dist[u] + basic[u][v]; - if (alt < dist[v]) { - dist[v] = alt; - previous[v] = u; - } - } - } - } - - public List<Integer> getBestPath() { - final List<Integer> result = new ArrayList<Integer>(); - computePrevious(); - int u = size - 1; - while (previous[u] >= 0) { - result.add(0, u); - u = previous[u]; - } - result.add(0, 0); - return Collections.unmodifiableList(result); - } - - private int smallest() { - int result = -1; - for (Integer i : q) { - if (result == -1 || dist[i] < dist[result]) { - result = i; - } - } - return result; - } - - public final int getSize() { - return size; - } - -} diff --git a/src/net/sourceforge/plantuml/geom/InflateData.java b/src/net/sourceforge/plantuml/geom/InflateData.java deleted file mode 100644 index 8d7afb0..0000000 --- a/src/net/sourceforge/plantuml/geom/InflateData.java +++ /dev/null @@ -1,67 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.geom; - -public class InflateData implements Comparable<InflateData> { - - private final int pos; - private final int inflation; - - public InflateData(int pos, int inflation) { - if (inflation % 2 != 0) { - throw new IllegalArgumentException(); - } - this.pos = pos; - this.inflation = inflation; - } - - public final int getPos() { - return pos; - } - - public final int getInflation() { - return inflation; - } - - public int compareTo(InflateData other) { - return -(this.pos - other.pos); - } - - @Override - public String toString() { - return "" + pos + " (" + inflation + ")"; - } -} diff --git a/src/net/sourceforge/plantuml/geom/InflationTransform.java b/src/net/sourceforge/plantuml/geom/InflationTransform.java deleted file mode 100644 index b557ff3..0000000 --- a/src/net/sourceforge/plantuml/geom/InflationTransform.java +++ /dev/null @@ -1,211 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.geom; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; -import java.util.ListIterator; -import java.util.SortedSet; -import java.util.TreeSet; - -class Point2DIntComparatorDistance implements Comparator<Point2DInt> { - - private final Point2DInt center; - - public Point2DIntComparatorDistance(Point2DInt center) { - this.center = center; - } - - public int compare(Point2DInt p1, Point2DInt p2) { - return (int) Math.signum(p1.distance(center) - p2.distance(center)); - } - -} - -public class InflationTransform { - - private final List<InflateData> inflateX = new ArrayList<InflateData>(); - private final List<InflateData> inflateY = new ArrayList<InflateData>(); - - public void addInflationX(int xpos, int inflation) { - add(inflateX, xpos, inflation); - } - - @Override - public String toString() { - return "inflateX = " + inflateX + " inflateY = " + inflateY; - } - - public void addInflationY(int ypos, int inflation) { - add(inflateY, ypos, inflation); - } - - static private void add(List<InflateData> list, int ypos, int inflation) { - for (final ListIterator<InflateData> it = list.listIterator(); it.hasNext();) { - final InflateData cur = it.next(); - if (cur.getPos() == ypos) { - it.set(new InflateData(ypos, Math.max(inflation, cur.getInflation()))); - return; - } - } - list.add(new InflateData(ypos, inflation)); - Collections.sort(list); - } - - Collection<Point2DInt> cutPoints(LineSegmentInt original) { - - // Log.println("original=" + original); - // Log.println("inflateX=" + inflateX); - // Log.println("inflateY=" + inflateY); - - final SortedSet<Point2DInt> result = new TreeSet<Point2DInt>(new Point2DIntComparatorDistance(original.getP1())); - - if (original.isHorizontal() == false) { - for (InflateData x : inflateX) { - final LineSegmentInt vertical = new LineSegmentInt(x.getPos(), original.getMinY(), x.getPos(), original - .getMaxY()); - final Point2DInt inter = original.getSegIntersection(vertical); - if (inter != null) { - result.add(inter); - } - } - } - if (original.isVertical() == false) { - for (InflateData y : inflateY) { - final LineSegmentInt horizontal = new LineSegmentInt(original.getMinX(), y.getPos(), - original.getMaxX(), y.getPos()); - final Point2DInt inter = original.getSegIntersection(horizontal); - if (inter != null) { - result.add(inter); - } - } - } - return result; - } - - Collection<LineSegmentInt> cutSegments(LineSegmentInt original) { - final List<LineSegmentInt> result = new ArrayList<LineSegmentInt>(); - Point2DInt cur = original.getP1(); - final Collection<Point2DInt> cutPoints = cutPoints(original); - for (Point2DInt inter : cutPoints) { - if (cur.equals(inter)) { - continue; - } - result.add(new LineSegmentInt(cur, inter)); - cur = inter; - } - if (cur.equals(original.getP2()) == false) { - result.add(new LineSegmentInt(cur, original.getP2())); - } - return result; - } - - Collection<LineSegmentInt> cutSegments(Collection<LineSegmentInt> segments) { - final List<LineSegmentInt> result = new ArrayList<LineSegmentInt>(); - for (LineSegmentInt seg : segments) { - result.addAll(cutSegments(seg)); - } - return result; - } - - private LineSegmentInt inflateSegment(LineSegmentInt seg) { - if (isOnGrid(seg.getP1()) || isOnGrid(seg.getP2())) { - return new LineSegmentInt(inflatePoint2DInt(seg.getP1()), inflatePoint2DInt(seg.getP2())); - } - for (InflateData x : inflateX) { - seg = seg.inflateXAlpha(x); - } - for (InflateData y : inflateY) { - seg = seg.inflateYAlpha(y); - } - return seg; - } - - private boolean isOnGrid(Point2DInt point) { - boolean onGrid = false; - for (InflateData x : inflateX) { - if (point.getX() == x.getPos()) { - onGrid = true; - } - } - if (onGrid == false) { - return false; - } - for (InflateData y : inflateY) { - if (point.getY() == y.getPos()) { - return true; - } - } - return false; - - } - - public Point2DInt inflatePoint2DInt(Point2DInt point) { - for (InflateData x : inflateX) { - point = point.inflateX(x); - } - for (InflateData y : inflateY) { - point = point.inflateY(y); - } - return point; - } - - List<LineSegmentInt> inflateSegmentCollection(Collection<LineSegmentInt> segments) { - final List<LineSegmentInt> result = new ArrayList<LineSegmentInt>(); - for (LineSegmentInt seg : segments) { - result.add(inflateSegment(seg)); - } - return result; - } - - public List<LineSegmentInt> inflate(Collection<LineSegmentInt> segments) { - final List<LineSegmentInt> result = new ArrayList<LineSegmentInt>(); - LineSegmentInt last = null; - final Collection<LineSegmentInt> cutSegments = cutSegments(segments); - for (LineSegmentInt seg : inflateSegmentCollection(cutSegments)) { - if (last != null && last.getP2().equals(seg.getP1()) == false) { - result.add(new LineSegmentInt(last.getP2(), seg.getP1())); - } - result.add(seg); - last = seg; - - } - return result; - } -} diff --git a/src/net/sourceforge/plantuml/geom/Kingdom.java b/src/net/sourceforge/plantuml/geom/Kingdom.java deleted file mode 100644 index fa50fb8..0000000 --- a/src/net/sourceforge/plantuml/geom/Kingdom.java +++ /dev/null @@ -1,123 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.geom; - -import java.util.Collections; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Set; - -public class Kingdom extends AbstractFigure { - - private Set<ClosedArea> buildClosedArea(ClosedArea area) { - if (area.isClosed()) { - throw new IllegalArgumentException(); - } - final Set<ClosedArea> result = new HashSet<ClosedArea>(); - for (LineSegmentInt seg : getSegmentsWithExtremity(area.getFreePoint(), area.getSegments())) { - final ClosedArea newArea = area.append(seg); - if (newArea != null) { - result.add(newArea); - } - } - return Collections.unmodifiableSet(result); - } - - private void grow(Set<ClosedArea> areas) { - for (ClosedArea area : new HashSet<ClosedArea>(areas)) { - if (area.isClosed() == false) { - areas.addAll(buildClosedArea(area)); - } - } - } - - public Set<ClosedArea> getAllClosedArea() { - final Set<ClosedArea> result = new HashSet<ClosedArea>(); - for (LineSegmentInt seg : getSegments()) { - result.add(new ClosedArea().append(seg)); - } - int lastSize; - do { - lastSize = result.size(); - grow(result); - } while (result.size() != lastSize); - for (final Iterator<ClosedArea> it = result.iterator(); it.hasNext();) { - final ClosedArea area = it.next(); - if (area.isClosed() == false) { - it.remove(); - } - } - return Collections.unmodifiableSet(result); - } - - // public Set<ClosedArea> getAllSmallClosedArea() { - // final Set<ClosedArea> all = getAllClosedArea(); - // final Set<ClosedArea> result = new HashSet<ClosedArea>(all); - // - // for (final Iterator<ClosedArea> it = result.iterator(); it.hasNext();) { - // final ClosedArea area = it.next(); - // if (containsAnotherArea(area, all)) { - // it.remove(); - // } - // } - // - // return Collections.unmodifiableSet(result); - // } - - // static private boolean containsAnotherArea(ClosedArea area, - // Set<ClosedArea> all) { - // for (ClosedArea another : all) { - // if (another == area) { - // continue; - // } - // if (area.contains(another)) { - // return true; - // } - // } - // return false; - // } - - @Override - public boolean arePointsConnectable(Point2DInt p1, Point2DInt p2) { - for (ClosedArea area : getAllClosedArea()) { - if (area.arePointsConnectable(p1, p2) == false) { - return false; - } - } - return true; - } - -} diff --git a/src/net/sourceforge/plantuml/geom/LineSegmentInt.java b/src/net/sourceforge/plantuml/geom/LineSegmentInt.java deleted file mode 100644 index 2631315..0000000 --- a/src/net/sourceforge/plantuml/geom/LineSegmentInt.java +++ /dev/null @@ -1,268 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.geom; - -import java.awt.geom.Point2D; -import java.util.Locale; - -public class LineSegmentInt extends AbstractLineSegment { - - private final Point2DInt p1; - private final Point2DInt p2; - - @Override - public String toString() { - return String.format(Locale.US, "( %d,%d - %d,%d )", p1.getXint(), p1.getYint(), p2.getXint(), p2.getYint()); - } - - public LineSegmentInt(int x1, int y1, int x2, int y2) { - this(new Point2DInt(x1, y1), new Point2DInt(x2, y2)); - } - - public LineSegmentInt(Point2DInt p1, Point2DInt p2) { - this.p1 = p1; - this.p2 = p2; - if (p1.equals(p2)) { - throw new IllegalArgumentException(); - } - assert p1 != null && p2 != null; - assert getLength() > 0; - assert this.getDistance(this) == 0; - } - - public boolean containsPoint(Point2D point) { - return side(point) == 0 && isBetween(point, p1, p2); - } - - public double side(Box box) { - final Point2DInt corners[] = box.getCorners(); - final double s0 = side(corners[0]); - final double s1 = side(corners[1]); - final double s2 = side(corners[2]); - final double s3 = side(corners[3]); - if (s0 > 0 && s1 > 0 && s2 > 0 && s3 > 0) { - return 1; - } - if (s0 < 0 && s1 < 0 && s2 < 0 && s3 < 0) { - return -1; - } - return 0; - } - - public boolean doesIntersectButNotSameExtremity(LineSegmentInt other) { - // assert sameExtremities(other) == false; - if (doesIntersect(other) == false) { - return false; - } - if (atLeastOneCommonExtremities(other)) { - return false; - } - return true; - } - - public boolean sameExtremities(LineSegmentInt other) { - if (p1.equals(other.p1) && p2.equals(other.p2)) { - return true; - } - if (p1.equals(other.p2) && p2.equals(other.p1)) { - return true; - } - return false; - } - - public boolean atLeastOneCommonExtremities(LineSegmentInt other) { - if (p1.equals(other.p1)) { - return true; - } - if (p1.equals(other.p2)) { - return true; - } - if (p2.equals(other.p1)) { - return true; - } - if (p2.equals(other.p2)) { - return true; - } - return false; - } - - public Point2DInt getCommonExtremities(LineSegmentInt other) { - if (p1.equals(other.p1)) { - return p1; - } - if (p1.equals(other.p2)) { - return p1; - } - if (p2.equals(other.p1)) { - return p2; - } - if (p2.equals(other.p2)) { - return p2; - } - return null; - } - - public Point2DInt getOtherExtremity(Point2DInt extremity1) { - if (extremity1 == null) { - throw new IllegalArgumentException(); - } - if (extremity1.equals(p1)) { - return p2; - } - if (extremity1.equals(p2)) { - return p1; - } - throw new IllegalArgumentException(); - } - - // Line2D - - @Override - public Point2DInt getP1() { - return p1; - } - - @Override - public Point2DInt getP2() { - return p2; - } - - @Override - public double getX1() { - return p1.getXint(); - } - - @Override - public double getX2() { - return p2.getXint(); - } - - @Override - public double getY1() { - return p1.getYint(); - } - - @Override - public double getY2() { - return p2.getYint(); - } - - public Point2DInt getTranslatedPoint(Point2DInt pointToBeTranslated) { - final int x = p2.getXint() - p1.getXint(); - final int y = p2.getYint() - p1.getYint(); - return new Point2DInt(pointToBeTranslated.getXint() + x, pointToBeTranslated.getYint() + y); - } - - public Point2DInt getCenter() { - return new Point2DInt((p1.getXint() + p2.getXint()) / 2, (p1.getYint() + p2.getYint()) / 2); - } - - public int getMinX() { - return Math.min(p1.getXint(), p2.getXint()); - } - - public int getMaxX() { - return Math.max(p1.getXint(), p2.getXint()); - } - - public int getMinY() { - return Math.min(p1.getYint(), p2.getYint()); - } - - public int getMaxY() { - return Math.max(p1.getYint(), p2.getYint()); - } - - public Point2DInt ortho(Point2D.Double orig, double d) { - final double vectX = p2.getY() - p1.getY(); - final double vectY = -(p2.getX() - p1.getX()); - final double pour = 1.0 * d / 100.0; - final double x = orig.x + vectX * pour; - final double y = orig.y + vectY * pour; - return new Point2DInt((int) Math.round(x), (int) Math.round(y)); - } - - public LineSegmentInt translate(int deltaX, int deltaY) { - return new LineSegmentInt(p1.translate(deltaX, deltaY), p2.translate(deltaX, deltaY)); - } - - public LineSegmentInt inflateXAlpha(InflateData inflateData) { - - final int xpos = inflateData.getPos(); - final int inflation = inflateData.getInflation(); - if (isHorizontal()) { - return new LineSegmentInt(p1.inflateX(inflateData), p2.inflateX(inflateData)); - } - if (getP1().getXint() == xpos && getP2().getXint() == xpos) { - return this.translate(inflation / 2, 0); - } - if (getP1().getXint() <= xpos && getP2().getXint() <= xpos) { - return this; - } - if (getP1().getXint() >= xpos && getP2().getXint() >= xpos) { - return this.translate(inflation, 0); - } - throw new UnsupportedOperationException(toString() + " " + inflateData); - } - - public LineSegmentInt inflateYAlpha(InflateData inflateData) { - final int ypos = inflateData.getPos(); - final int inflation = inflateData.getInflation(); - if (isVertical()) { - return new LineSegmentInt(p1.inflateY(inflateData), p2.inflateY(inflateData)); - } - if (getP1().getYint() == ypos && getP2().getYint() == ypos) { - return this.translate(0, inflation / 2); - } - if (getP1().getYint() <= ypos && getP2().getYint() <= ypos) { - return this; - } - if (getP1().getYint() >= ypos && getP2().getYint() >= ypos) { - return this.translate(0, inflation); - } - throw new UnsupportedOperationException(); - } - - @Override - public Point2DInt getSegIntersection(AbstractLineSegment other) { - final Point2D result = super.getSegIntersection(other); - if (result == null) { - return null; - } - return new Point2DInt((int) Math.round(result.getX()), (int) Math.round(result.getY())); - } - -} diff --git a/src/net/sourceforge/plantuml/geom/Neighborhood.java b/src/net/sourceforge/plantuml/geom/Neighborhood.java deleted file mode 100644 index 9680c2d..0000000 --- a/src/net/sourceforge/plantuml/geom/Neighborhood.java +++ /dev/null @@ -1,119 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.geom; - -public class Neighborhood { - - final private double angle1; - final private double angle2; - final private Point2DInt center; - - public Neighborhood(Point2DInt center) { - this(center, 0, 0); - } - - public boolean is360() { - return angle1 == angle2; - } - - public Neighborhood(Point2DInt center, double angle1, double angle2) { - this.center = center; - this.angle1 = angle1; - this.angle2 = angle2; - } - - @Override - public String toString() { - final int a1 = (int) (angle1 * 180 / Math.PI); - final int a2 = (int) (angle2 * 180 / Math.PI); - return center + " " + a1 + " " + a2; - } - - public final Point2DInt getCenter() { - return center; - } - - public final double getMiddle() { - if (is360()) { - return angle1 + Math.PI; - } - double result = (angle1 + angle2) / 2; - if (angle2 < angle1) { - result += Math.PI; - } - return result; - } - - public boolean isInAngleStrict(double angle) { - if (angle < 0) { - throw new IllegalArgumentException(); - } - if (angle2 > angle1) { - return angle > angle1 && angle < angle2; - } - return angle > angle1 || angle < angle2; - } - - public boolean isInAngleLarge(double angle) { - if (angle < 0) { - throw new IllegalArgumentException(); - } - if (angle2 > angle1) { - return angle >= angle1 && angle <= angle2; - } - return angle >= angle1 || angle <= angle2; - } - - public boolean isAngleLimit(double angle) { - return angle == angle1 || angle == angle2; - } - - public Orientation getOrientationFrom(double angle) { - if (angle1 == angle2) { - throw new IllegalStateException(); - } - if (angle != angle1 && angle != angle2) { - throw new IllegalArgumentException("this=" + this + " angle=" + (int) (angle * 180 / Math.PI)); - } - assert angle == angle1 || angle == angle2; - - if (angle == angle1) { - return Orientation.MATH; - } - return Orientation.CLOCK; - - } -} diff --git a/src/net/sourceforge/plantuml/geom/Orientation.java b/src/net/sourceforge/plantuml/geom/Orientation.java deleted file mode 100644 index b45a7ca..0000000 --- a/src/net/sourceforge/plantuml/geom/Orientation.java +++ /dev/null @@ -1,42 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.geom; - -public enum Orientation { - - CLOCK, MATH - -}
\ No newline at end of file diff --git a/src/net/sourceforge/plantuml/geom/Point2DInt.java b/src/net/sourceforge/plantuml/geom/Point2DInt.java deleted file mode 100644 index 895167d..0000000 --- a/src/net/sourceforge/plantuml/geom/Point2DInt.java +++ /dev/null @@ -1,122 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.geom; - -import java.awt.geom.Point2D; - -public class Point2DInt extends Point2D implements Pointable { - - private final int x; - private final int y; - - @Override - public String toString() { - return "(" + x + "," + y + ")"; - } - - public Point2DInt(int x, int y) { - this.x = x; - this.y = y; - } - - public int getXint() { - return x; - } - - public int getYint() { - return y; - } - - @Override - public double getX() { - return x; - } - - @Override - public double getY() { - return y; - } - - @Override - public void setLocation(double x, double y) { - throw new UnsupportedOperationException(); - } - - public Point2DInt getPosition() { - return this; - } - - public Point2DInt translate(int deltaX, int deltaY) { - return new Point2DInt(x + deltaX, y + deltaY); - } - - public Point2DInt inflateX(int xpos, int inflation) { - if (inflation % 2 != 0) { - throw new IllegalArgumentException(); - } - if (x < xpos) { - return this; - } - if (x == xpos) { - // throw new IllegalArgumentException(); - return translate(inflation / 2, 0); - } - return translate(inflation, 0); - } - - public Point2DInt inflateX(InflateData inflateData) { - return inflateX(inflateData.getPos(), inflateData.getInflation()); - } - - public Point2DInt inflateY(InflateData inflateData) { - return inflateY(inflateData.getPos(), inflateData.getInflation()); - } - - public Point2DInt inflateY(int ypos, int inflation) { - if (inflation % 2 != 0) { - throw new IllegalArgumentException(); - } - if (y < ypos) { - return this; - } - if (y == ypos) { - // throw new IllegalArgumentException(); - return translate(0, inflation / 2); - } - return translate(0, inflation); - } - -} diff --git a/src/net/sourceforge/plantuml/geom/Pointable.java b/src/net/sourceforge/plantuml/geom/Pointable.java deleted file mode 100644 index a55c6b3..0000000 --- a/src/net/sourceforge/plantuml/geom/Pointable.java +++ /dev/null @@ -1,40 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.geom; - -public interface Pointable { - Point2DInt getPosition(); -} diff --git a/src/net/sourceforge/plantuml/geom/Polyline.java b/src/net/sourceforge/plantuml/geom/Polyline.java deleted file mode 100644 index 78bc9f6..0000000 --- a/src/net/sourceforge/plantuml/geom/Polyline.java +++ /dev/null @@ -1,50 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.geom; - -import java.util.List; - -public interface Polyline { - - List<LineSegmentInt> segments(); - - int nbSegments(); - - boolean doesTouch(Polyline other); - - double getLength(); - -} diff --git a/src/net/sourceforge/plantuml/geom/PolylineBreakeable.java b/src/net/sourceforge/plantuml/geom/PolylineBreakeable.java deleted file mode 100644 index 04f912e..0000000 --- a/src/net/sourceforge/plantuml/geom/PolylineBreakeable.java +++ /dev/null @@ -1,154 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.geom; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -public class PolylineBreakeable extends AbstractPolyline implements Polyline { - - static class Breakure { - private int d; - private int u; - - public Breakure(int u, int d) { - this.u = u; - this.d = d; - } - } - - private final List<Breakure> breakures = new ArrayList<Breakure>(); - - public PolylineBreakeable copy(Pointable newStart, Pointable newEnd) { - final PolylineBreakeable result = new PolylineBreakeable(newStart, newEnd); - result.breakures.addAll(this.breakures); - return result; - } - - public PolylineBreakeable(Pointable start, Pointable end) { - super(start, end); - } - - public List<LineSegmentInt> segments() { - if (breakures.size() == 0) { - return Collections.singletonList(new LineSegmentInt(getStart().getPosition(), getEnd().getPosition())); - } - final List<LineSegmentInt> result = new ArrayList<LineSegmentInt>(); - Point2DInt cur = getStart().getPosition(); - for (Breakure breakure : breakures) { - final Point2DInt next = getBreakurePoint(breakure); - result.add(new LineSegmentInt(cur, next)); - cur = next; - } - result.add(new LineSegmentInt(cur, getEnd().getPosition())); - assert nbSegments() == result.size(); - return Collections.unmodifiableList(result); - } - - private Point2DInt getBreakurePoint(Breakure breakure) { - final LineSegmentInt seg = new LineSegmentInt(getStart().getPosition(), getEnd().getPosition()); - return seg.ortho(seg.startTranslatedAsVector(breakure.u), breakure.d); - } - - public int nbSegments() { - return breakures.size() + 1; - } - - public List<XMoveable> getFreedoms() { - final List<XMoveable> allFreedom = new ArrayList<XMoveable>(); - - for (final Breakure breakure : breakures) { - allFreedom.add(new XMoveable() { - @Override - public String toString() { - return super.toString() + " " + PolylineBreakeable.this.toString() + "(d)"; - } - - public void moveX(int delta) { - breakure.d += delta; - } - }); - allFreedom.add(new XMoveable() { - @Override - public String toString() { - return super.toString() + " " + PolylineBreakeable.this.toString() + "(u)"; - } - - public void moveX(int delta) { - breakure.u += delta; - } - }); - allFreedom.add(new XMoveable() { - @Override - public String toString() { - return super.toString() + " " + PolylineBreakeable.this.toString() + "(ud)"; - } - - public void moveX(int delta) { - breakure.u += delta; - breakure.d += delta; - } - }); - allFreedom.add(new XMoveable() { - @Override - public String toString() { - return super.toString() + " " + PolylineBreakeable.this.toString() + "(dud)"; - } - - public void moveX(int delta) { - breakure.u += delta; - breakure.d -= delta; - } - }); - } - - return Collections.unmodifiableList(allFreedom); - } - - public void insertBetweenPoint(int u, int d) { - breakures.add(new Breakure(u, d)); - } - - private void breakMore() { - if (breakures.size() == 1) { - final Breakure b = breakures.get(0); - insertBetweenPoint(b.u / 2, 0); - } - - } - -} diff --git a/src/net/sourceforge/plantuml/geom/PolylineImpl.java b/src/net/sourceforge/plantuml/geom/PolylineImpl.java deleted file mode 100644 index 1824f43..0000000 --- a/src/net/sourceforge/plantuml/geom/PolylineImpl.java +++ /dev/null @@ -1,100 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.geom; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -public class PolylineImpl extends AbstractPolyline implements Polyline { - - final private List<Point2DInt> intermediates = new ArrayList<Point2DInt>(); - - public PolylineImpl(Pointable start, Pointable end) { - super(start, end); - } - - public int nbSegments() { - return intermediates.size() + 1; - } - - public List<LineSegmentInt> segments() { - final List<LineSegmentInt> result = new ArrayList<LineSegmentInt>(); - Point2DInt cur = getStart().getPosition(); - for (Point2DInt intermediate : intermediates) { - result.add(new LineSegmentInt(cur, intermediate)); - cur = intermediate; - } - result.add(new LineSegmentInt(cur, getEnd().getPosition())); - return Collections.unmodifiableList(result); - } - - public void addIntermediate(Point2DInt intermediate) { - assert intermediates.contains(intermediate) == false; - intermediates.add(intermediate); - } - - public void inflate(InflationTransform transform) { - // final List<LineSegment> segments = segments(); - // if (segments.size() == 1) { - // return; - // } - // intermediates.clear(); - // if (segments.size() == 2) { - // final Point2DInt p = segments.get(0).getP2(); - // intermediates.add(transform.inflatePoint2DInt(p)); - // } else { - // final List<LineSegment> segmentsT = transform.inflate(segments); - // for (int i = 0; i < segmentsT.size() - 2; i++) { - // intermediates.add(segmentsT.get(i).getP2()); - // } - // - // } - - final List<LineSegmentInt> segments = transform.inflate(this.segments()); - // Log.println("segments="+segments); - intermediates.clear(); - for (int i = 1; i < segments.size() - 1; i++) { - addIntermediate(segments.get(i).getP1()); - } - } - - public final Collection<Point2DInt> getIntermediates() { - return Collections.unmodifiableCollection(intermediates); - } - -} diff --git a/src/net/sourceforge/plantuml/geom/Singularity.java b/src/net/sourceforge/plantuml/geom/Singularity.java deleted file mode 100644 index e3c54e7..0000000 --- a/src/net/sourceforge/plantuml/geom/Singularity.java +++ /dev/null @@ -1,154 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.geom; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.TreeSet; - -public class Singularity { - - private final TreeSet<Double> angles = new TreeSet<Double>(); - - final private Point2DInt center; - - public Singularity(Point2DInt center) { - this.center = center; - } - - @Override - public String toString() { - final StringBuilder sb = new StringBuilder(center.toString()); - for (Double a : angles) { - final int degree = (int) (a * 180 / Math.PI); - sb.append(' '); - sb.append(degree); - } - return sb.toString(); - } - - public void addLineSegment(LineSegmentInt seg) { - if (seg.getP1().equals(center)) { - angles.add(convertAngle(seg.getAngle())); - } else if (seg.getP2().equals(center)) { - angles.add(convertAngle(seg.getOppositeAngle())); - } else { - assert seg.side(center) == 0 : "side=" + seg.side(center) + " center=" + center + " seg=" + seg; - assert LineSegmentInt.isBetween(center, seg.getP1(), seg.getP2()); - addLineSegment(new LineSegmentInt(center, seg.getP1())); - addLineSegment(new LineSegmentInt(center, seg.getP2())); - } - assert betweenZeroAndTwoPi(); - - } - - static double convertAngle(double a) { - if (a < 0) { - return a + 2 * Math.PI; - } - return a; - } - - private boolean betweenZeroAndTwoPi() { - for (Double d : angles) { - assert d >= 0; - assert d < 2 * Math.PI; - } - return true; - } - - List<Double> getAngles() { - return new ArrayList<Double>(angles); - } - - public boolean crossing(Point2DInt direction1, Point2DInt direction2) { - final boolean result = crossingInternal(direction1, direction2); - assert result == crossingInternal(direction2, direction1); - return result; - } - - private boolean crossingInternal(Point2DInt direction1, Point2DInt direction2) { - if (angles.size() < 2) { - return false; - } - final double angle1 = convertAngle(new LineSegmentInt(center, direction1).getAngle()); - final double angle2 = convertAngle(new LineSegmentInt(center, direction2).getAngle()); - - Double last = null; - for (Double current : angles) { - if (last != null) { - assert last < current; - if (isBetween(angle1, last, current) && isBetween(angle2, last, current)) { - return false; - } - } - last = current; - } - final double first = angles.first(); - if ((angle1 <= first || angle1 >= last) && (angle2 <= first || angle2 >= last)) { - return false; - } - return true; - } - - private boolean isBetween(double test, double v1, double v2) { - assert v1 < v2; - return test >= v1 && test <= v2; - } - - protected final Point2DInt getCenter() { - return center; - } - - public void merge(Singularity other) { - this.angles.addAll(other.angles); - } - - public List<Neighborhood> getNeighborhoods() { - if (angles.size() == 0) { - return Collections.singletonList(new Neighborhood(center)); - } - final List<Neighborhood> result = new ArrayList<Neighborhood>(); - double last = angles.last(); - for (Double currentAngle : angles) { - result.add(new Neighborhood(center, last, currentAngle)); - last = currentAngle; - } - return Collections.unmodifiableList(result); - } - -} diff --git a/src/net/sourceforge/plantuml/geom/SpiderWeb.java b/src/net/sourceforge/plantuml/geom/SpiderWeb.java deleted file mode 100644 index 23776e6..0000000 --- a/src/net/sourceforge/plantuml/geom/SpiderWeb.java +++ /dev/null @@ -1,183 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.geom; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import net.sourceforge.plantuml.Log; - -public class SpiderWeb { - - private final int pointsInCircle = 16; - private int nbRow; - private int nbCol; - - final private int widthCell; - final private int heightCell; - - final private int xMargin = 50; - final private int yMargin = 50; - - private final List<PolylineBreakeable> lines = new ArrayList<PolylineBreakeable>(); - - public SpiderWeb(int widthCell, int heightCell) { - Log.info("widthCell=" + widthCell + " heightCell=" + heightCell); - this.widthCell = widthCell; - this.heightCell = heightCell; - } - - public Point2DInt getMainPoint(int row, int col) { - return new Point2DInt(col * (widthCell + xMargin), row * (heightCell + yMargin)); - } - - public Collection<Point2DInt> getHangPoints(int row, int col) { - // final double dist = Math.pow(1.6, -row - 10) + Math.pow(1.5, -col - - // 10); - assert pointsInCircle % 4 == 0; - final List<Point2DInt> result = new ArrayList<Point2DInt>(); - final int dist = (int) Math.round(Math.sqrt(widthCell * widthCell + heightCell * heightCell) / 10); - for (int i = 0; i < pointsInCircle; i++) { - final Point2DInt main = getMainPoint(row, col); - final int x = main.getXint(); - final int y = main.getYint(); - if (i == 0) { - result.add(new Point2DInt(x + dist, y)); - } else if (i == pointsInCircle / 4) { - result.add(new Point2DInt(x, y + dist)); - } else if (i == 2 * pointsInCircle / 4) { - result.add(new Point2DInt(x - dist, y)); - } else if (i == 3 * pointsInCircle / 4) { - result.add(new Point2DInt(x, y - dist)); - } else { - final double angle = Math.PI * 2.0 * i / pointsInCircle; - final double x1 = x + dist * Math.cos(angle); - final double y1 = y + dist * Math.sin(angle); - result.add(new Point2DInt((int) Math.round(x1), (int) Math.round(y1))); - } - } - // Log.println("getHangPoints="+result); - return result; - } - - public PolylineBreakeable addPolyline(int row1, int col1, int row2, int col2) { - // Log.println("SpiderWeb : adding " + row1 + "," + col1 + " - " - // + row2 + "," + col2); - final PolylineBreakeable result = computePolyline(row1, col1, row2, col2); - // Log.println("SpiderWeb : adding " + result); - if (result != null) { - lines.add(result); - } - return result; - } - - private PolylineBreakeable computePolyline(int row1, int col1, int row2, int col2) { - if (row1 > nbRow) { - nbRow = row1; - } - if (row2 > nbRow) { - nbRow = row2; - } - if (col1 > nbCol) { - nbCol = col1; - } - if (col2 > nbCol) { - nbCol = col2; - } - if (directLinkPossibleForGeometry(row1, col1, row2, col2)) { - // Log.println("Geom OK"); - final PolylineBreakeable direct = new PolylineBreakeable(getMainPoint(row1, col1), getMainPoint(row2, col2)); - if (isCompatible(direct)) { - // Log.println("Direct OK"); - return direct; - } - } - return bestLevel1Line(row1, col1, row2, col2); - } - - private boolean isCompatible(PolylineBreakeable toTest) { - for (PolylineBreakeable p : lines) { - if (p.doesTouch(toTest)) { - return false; - } - } - return true; - } - - private PolylineBreakeable bestLevel1Line(int row1, int col1, int row2, int col2) { - PolylineBreakeable result = null; - for (int u = 5; u <= 95; u += 5) { - for (int d = -200; d <= 200; d += 5) { - final PolylineBreakeable cur = new PolylineBreakeable(getMainPoint(row1, col1), - getMainPoint(row2, col2)); - cur.insertBetweenPoint(u, d); - if ((result == null || cur.getLength() < result.getLength()) && isCompatible(cur)) { - result = cur; - } - - } - } - return result; - } - - boolean directLinkPossibleForGeometry(int row1, int col1, int row2, int col2) { - final int rowMin = Math.min(row1, row2); - final int rowMax = Math.max(row1, row2); - final int colMin = Math.min(col1, col2); - final int colMax = Math.max(col1, col2); - final LineSegmentInt seg = new LineSegmentInt(col1, row1, col2, row2); - for (int r = rowMin; r <= rowMax; r++) { - for (int c = colMin; c <= colMax; c++) { - if (r == row1 && c == col1) { - continue; - } - if (r == row2 && c == col2) { - continue; - } - if (seg.containsPoint(new Point2DInt(c, r))) { - return false; - } - } - } - return true; - } - - final int getPointsInCircle() { - return pointsInCircle; - } - -}
\ No newline at end of file diff --git a/src/net/sourceforge/plantuml/geom/XMoveable.java b/src/net/sourceforge/plantuml/geom/XMoveable.java deleted file mode 100644 index 18440da..0000000 --- a/src/net/sourceforge/plantuml/geom/XMoveable.java +++ /dev/null @@ -1,42 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.geom; - -public interface XMoveable { - - void moveX(int delta); - -}
\ No newline at end of file diff --git a/src/net/sourceforge/plantuml/geom/kinetic/Quadrant.java b/src/net/sourceforge/plantuml/geom/kinetic/Quadrant.java deleted file mode 100644 index 7436dc6..0000000 --- a/src/net/sourceforge/plantuml/geom/kinetic/Quadrant.java +++ /dev/null @@ -1,82 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.geom.kinetic; - -import java.util.Arrays; -import java.util.Collection; -import java.util.HashSet; - -public class Quadrant { - - static final private int SIZE = 100; - - private final int x; - private final int y; - - public Quadrant(int x, int y) { - this.x = x; - this.y = y; - } - - public Quadrant(Point2DCharge pt) { - this((int) pt.getX() / SIZE, (int) pt.getY() / SIZE); - } - - @Override - public boolean equals(Object obj) { - final Quadrant other = (Quadrant) obj; - return x == other.x && y == other.y; - } - - @Override - public int hashCode() { - return x * 3571 + y; - } - - @Override - public String toString() { - return "" + x + "-" + y; - } - - public Collection<Quadrant> neighbourhood() { - final Collection<Quadrant> result = Arrays.asList(new Quadrant(x - 1, y - 1), new Quadrant(x, y - 1), - new Quadrant(x + 1, y - 1), new Quadrant(x - 1, y), this, new Quadrant(x + 1, y), new Quadrant(x - 1, - y + 1), new Quadrant(x, y + 1), new Quadrant(x + 1, y + 1)); - assert new HashSet<Quadrant>(result).size() == 9; - return result; - } - -} diff --git a/src/net/sourceforge/plantuml/geom/kinetic/QuadrantMapper.java b/src/net/sourceforge/plantuml/geom/kinetic/QuadrantMapper.java deleted file mode 100644 index 38b85a2..0000000 --- a/src/net/sourceforge/plantuml/geom/kinetic/QuadrantMapper.java +++ /dev/null @@ -1,106 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.geom.kinetic; - -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -public class QuadrantMapper { - - private final Map<Point2DCharge, Quadrant> quadrants = new HashMap<Point2DCharge, Quadrant>(); - private final Map<Quadrant, HashSet<Point2DCharge>> setOfPoints = new HashMap<Quadrant, HashSet<Point2DCharge>>(); - - public void addPoint(Point2DCharge pt) { - if (quadrants.containsKey(pt)) { - throw new IllegalArgumentException(); - } - final Quadrant q = new Quadrant(pt); - quadrants.put(pt, q); - getSetOfPoints(q).add(pt); - assert getSetOfPoints(q).contains(pt); - assert getSetOfPoints(new Quadrant(pt)).contains(pt); - } - - public Set<Point2DCharge> getAllPoints(Quadrant qt) { - return Collections.unmodifiableSet(getSetOfPoints(qt)); - } - - public Set<Point2DCharge> getAllPoints() { - assert quadrants.keySet().equals(mergeOfSetOfPoints()); - return Collections.unmodifiableSet(quadrants.keySet()); - } - - private Set<Point2DCharge> mergeOfSetOfPoints() { - final Set<Point2DCharge> result = new HashSet<Point2DCharge>(); - for (Set<Point2DCharge> set : setOfPoints.values()) { - assert Collections.disjoint(set, result); - result.addAll(set); - } - return result; - } - - public void updatePoint(Point2DCharge pt) { - final Quadrant newQ = new Quadrant(pt); - final Quadrant old = quadrants.get(pt); - assert getSetOfPoints(old).contains(pt); - if (old.equals(newQ) == false) { - assert getSetOfPoints(newQ).contains(pt) == false; - assert getSetOfPoints(old).contains(pt); - final boolean remove = getSetOfPoints(old).remove(pt); - assert remove; - final boolean add = getSetOfPoints(newQ).add(pt); - assert add; - assert getSetOfPoints(newQ).contains(pt); - assert getSetOfPoints(old).contains(pt) == false; - quadrants.put(pt, newQ); - } - assert getSetOfPoints(new Quadrant(pt)).contains(pt); - } - - private HashSet<Point2DCharge> getSetOfPoints(Quadrant q) { - HashSet<Point2DCharge> result = setOfPoints.get(q); - if (result == null) { - result = new HashSet<Point2DCharge>(); - setOfPoints.put(q, result); - } - return result; - - } - -} diff --git a/src/net/sourceforge/plantuml/geom/kinetic/World.java b/src/net/sourceforge/plantuml/geom/kinetic/World.java deleted file mode 100644 index c0daadb..0000000 --- a/src/net/sourceforge/plantuml/geom/kinetic/World.java +++ /dev/null @@ -1,173 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.geom.kinetic; - -import java.awt.geom.Point2D; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - -public class World implements MoveObserver { - - private final List<Path> paths = new ArrayList<Path>(); - private final Map<Point2DCharge, Path> pathOfPoints = new HashMap<Point2DCharge, Path>(); - private final List<Frame> frames = new ArrayList<Frame>(); - - public void addFrame(Frame frame) { - this.frames.add(frame); - } - - public void addPath(Path path) { - this.paths.add(path); - } - - public VectorForce getElectricForce(Point2DCharge point) { - VectorForce result = new VectorForce(0, 0); - - final Quadrant quadrant = new Quadrant(point); - - for (Quadrant q : quadrant.neighbourhood()) { - for (Point2DCharge pc2 : quadrantMapper.getAllPoints(q)) { - final Path path = pathOfPoints.get(pc2); - if (path.containsPoint2DCharge(point)) { - continue; - } - result = result.plus(getElectricForce(point, pc2)); - } - } - return result; - } - - private VectorForce getElectricForceSlow(Point2DCharge point) { - VectorForce result = new VectorForce(0, 0); - - for (Path path : paths) { - if (path.containsPoint2DCharge(point)) { - continue; - } - for (Point2DCharge pc2 : path.getPoints()) { - result = result.plus(getElectricForce(point, pc2)); - } - } - return result; - } - - static private VectorForce getElectricForce(Point2DCharge onThis, Point2DCharge byThis) { - final double dist = onThis.distance(byThis); - if (dist == 0) { - return new VectorForce(0, 0); - } - final VectorForce result = new VectorForce(byThis.getX() - onThis.getX(), byThis.getY() - onThis.getY()); - final double v = 100.0 * onThis.getCharge() * byThis.getCharge() / dist / dist; - return result.normaliseTo(v); - } - - static private VectorForce getAtomicForce(Point2DCharge onThis, Point2DCharge byThis) { - final double dist = onThis.distance(byThis); - if (dist == 0) { - return new VectorForce(0, 0); - } - final VectorForce result = new VectorForce(byThis.getX() - onThis.getX(), byThis.getY() - onThis.getY()); - double v = 1000 / dist / dist / dist; - if (v > 5) { - v = 5; - } - return result.normaliseTo(v); - } - - Map<Point2DCharge, VectorForce> getForces() { - final Map<Point2DCharge, VectorForce> result = new LinkedHashMap<Point2DCharge, VectorForce>(); - for (Path path : paths) { - for (Point2DCharge pt : path.getPoints()) { - // final VectorForce elastic = new VectorForce(0, 0); - // final VectorForce elect = new VectorForce(0, 0); - final VectorForce elastic = path.getElasticForce(pt); - final VectorForce elect = getElectricForce(pt); - VectorForce force = elastic.plus(elect); - for (Frame f : frames) { - final Point2D inter = f.getFrontierPointViewBy(pt); - if (inter != null) { - final Point2DCharge pchar = new Point2DCharge(inter, 1); - force = force.plus(getAtomicForce(pt, pchar)); - } - } - result.put(pt, force); - } - } - - return result; - } - - public double onePass() { - double result = 0; - final Map<Point2DCharge, VectorForce> forces = getForces(); - for (Map.Entry<Point2DCharge, VectorForce> ent : forces.entrySet()) { - final VectorForce force = ent.getValue(); - result += force.getLength(); - ent.getKey().apply(force); - } - return result; - } - - public final Collection<Path> getPaths() { - return Collections.unmodifiableCollection(paths); - } - - private QuadrantMapper quadrantMapper; - - public void renderContinue() { - quadrantMapper = new QuadrantMapper(); - pathOfPoints.clear(); - for (Path path : paths) { - path.renderContinue(); - } - for (Path path : paths) { - for (Point2DCharge pt : path.getPoints()) { - pt.setMoveObserver(this); - quadrantMapper.addPoint(pt); - pathOfPoints.put(pt, path); - } - } - } - - public void pointMoved(Point2DCharge point) { - quadrantMapper.updatePoint(point); - } -} diff --git a/src/net/sourceforge/plantuml/golem/Magnet.java b/src/net/sourceforge/plantuml/golem/Magnet.java deleted file mode 100644 index 4e685c6..0000000 --- a/src/net/sourceforge/plantuml/golem/Magnet.java +++ /dev/null @@ -1,39 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.golem; - -public class Magnet { -} diff --git a/src/net/sourceforge/plantuml/golem/Square.java b/src/net/sourceforge/plantuml/golem/Square.java deleted file mode 100644 index 1e889b3..0000000 --- a/src/net/sourceforge/plantuml/golem/Square.java +++ /dev/null @@ -1,39 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.golem; - -public class Square { -} diff --git a/src/net/sourceforge/plantuml/graph/ALink.java b/src/net/sourceforge/plantuml/graph/ALink.java deleted file mode 100644 index da4d66d..0000000 --- a/src/net/sourceforge/plantuml/graph/ALink.java +++ /dev/null @@ -1,48 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.graph; - -public interface ALink { - - int getDiffHeight(); - - ANode getNode1(); - - ANode getNode2(); - - public Object getUserData(); - -} diff --git a/src/net/sourceforge/plantuml/graph/ALinkImpl.java b/src/net/sourceforge/plantuml/graph/ALinkImpl.java deleted file mode 100644 index cafc084..0000000 --- a/src/net/sourceforge/plantuml/graph/ALinkImpl.java +++ /dev/null @@ -1,73 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.graph; - -public class ALinkImpl implements ALink { - - private final ANode node1; - private final ANode node2; - private final Object userData; - private final int diffHeight; - - @Override - public String toString() { - return "" + node1 + " -> " + node2; - } - - public ALinkImpl(ANode n1, ANode n2, int diffHeight, Object userData) { - this.node1 = n1; - this.node2 = n2; - this.userData = userData; - this.diffHeight = diffHeight; - } - - public int getDiffHeight() { - return diffHeight; - } - - public ANode getNode1() { - return node1; - } - - public ANode getNode2() { - return node2; - } - - public final Object getUserData() { - return userData; - } - -} diff --git a/src/net/sourceforge/plantuml/graph/ANode.java b/src/net/sourceforge/plantuml/graph/ANode.java deleted file mode 100644 index 6dd60c3..0000000 --- a/src/net/sourceforge/plantuml/graph/ANode.java +++ /dev/null @@ -1,48 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.graph; - -public interface ANode { - - void setRow(int row); - - int getRow(); - - String getCode(); - - public Object getUserData(); - -} diff --git a/src/net/sourceforge/plantuml/graph/ANodeImpl.java b/src/net/sourceforge/plantuml/graph/ANodeImpl.java deleted file mode 100644 index 4592167..0000000 --- a/src/net/sourceforge/plantuml/graph/ANodeImpl.java +++ /dev/null @@ -1,78 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.graph; - -public class ANodeImpl implements ANode { - - private int row = Integer.MIN_VALUE; - private final String code; - private Object userData; - - public ANodeImpl(String code) { - this.code = code; - } - - @Override - public int hashCode() { - return code.hashCode(); - } - - public int getRow() { - return row; - } - - public void setRow(int row) { - this.row = row; - } - - public final String getCode() { - return code; - } - - @Override - public String toString() { - return code + " " + getRow(); - } - - public Object getUserData() { - return userData; - } - - public void setUserData(Object userData) { - this.userData = userData; - } - -} diff --git a/src/net/sourceforge/plantuml/graph/AbstractEntityImage.java b/src/net/sourceforge/plantuml/graph/AbstractEntityImage.java deleted file mode 100644 index 073639d..0000000 --- a/src/net/sourceforge/plantuml/graph/AbstractEntityImage.java +++ /dev/null @@ -1,115 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.graph; - -import java.awt.Font; -import java.awt.Graphics2D; -import java.awt.geom.Dimension2D; - -import net.sourceforge.plantuml.cucadiagram.IEntity; -import net.sourceforge.plantuml.graphic.HtmlColor; -import net.sourceforge.plantuml.graphic.HtmlColorUtils; -import net.sourceforge.plantuml.graphic.StringBounder; -import net.sourceforge.plantuml.ugraphic.ColorMapper; -import net.sourceforge.plantuml.ugraphic.UFont; - -abstract class AbstractEntityImage { - - private final IEntity entity; - - final private HtmlColor red = HtmlColorUtils.MY_RED; - - final private HtmlColor yellow = HtmlColorUtils.MY_YELLOW; - private final HtmlColor yellowNote = HtmlColorUtils.COL_FBFB77; - - final private UFont font14 = UFont.sansSerif(14); - final private UFont font17 = UFont.courier(17).bold(); - final private HtmlColor green = HtmlColorUtils.COL_ADD1B2; - final private HtmlColor violet = HtmlColorUtils.COL_B4A7E5; - final private HtmlColor blue = HtmlColorUtils.COL_A9DCDF; - final private HtmlColor rose = HtmlColorUtils.COL_EB937F; - - public AbstractEntityImage(IEntity entity) { - if (entity == null) { - throw new IllegalArgumentException("entity null"); - } - this.entity = entity; - } - - public abstract Dimension2D getDimension(StringBounder stringBounder); - - public abstract void draw(ColorMapper colorMapper, Graphics2D g2d); - - protected final IEntity getEntity() { - return entity; - } - - protected final HtmlColor getRed() { - return red; - } - - protected final HtmlColor getYellow() { - return yellow; - } - - protected final UFont getFont17() { - return font17; - } - - protected final UFont getFont14() { - return font14; - } - - protected final HtmlColor getGreen() { - return green; - } - - protected final HtmlColor getViolet() { - return violet; - } - - protected final HtmlColor getBlue() { - return blue; - } - - protected final HtmlColor getRose() { - return rose; - } - - protected final HtmlColor getYellowNote() { - return yellowNote; - } -} diff --git a/src/net/sourceforge/plantuml/graph/Board.java b/src/net/sourceforge/plantuml/graph/Board.java deleted file mode 100644 index 24cbcca..0000000 --- a/src/net/sourceforge/plantuml/graph/Board.java +++ /dev/null @@ -1,267 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.graph; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -public class Board { - - private final List<ALink> links; - private final Map<ALink, Integer> initialDirection; - - private final Map<ANode, Integer> nodesCols = new LinkedHashMap<ANode, Integer>(); - - private int hashcodeValue; - private boolean hashcodeComputed = false; - - private Board(Board old) { - this.links = old.links; - this.initialDirection = old.initialDirection; - this.nodesCols.putAll(old.nodesCols); - } - - public Comparator<ALink> getLinkComparator() { - return new LenghtLinkComparator(nodesCols); - } - - public boolean equals(Object o) { - final Board other = (Board) o; - if (this.links != other.links) { - return false; - } - final Iterator<Integer> it1 = this.nodesCols.values().iterator(); - final Iterator<Integer> it2 = other.nodesCols.values().iterator(); - assert this.nodesCols.size() == other.nodesCols.size(); - while (it1.hasNext()) { - if (it1.next().equals(it2.next()) == false) { - return false; - } - } - return true; - } - - @Override - public int hashCode() { - if (this.hashcodeComputed) { - return this.hashcodeValue; - } - this.hashcodeValue = 13; - for (Integer i : nodesCols.values()) { - this.hashcodeValue = this.hashcodeValue * 17 + i; - } - this.hashcodeComputed = true; - return this.hashcodeValue; - } - - public void normalize() { - int minRow = Integer.MAX_VALUE; - int minCol = Integer.MAX_VALUE; - int maxRow = Integer.MIN_VALUE; - int maxCol = Integer.MIN_VALUE; - for (Map.Entry<ANode, Integer> ent : nodesCols.entrySet()) { - minRow = Math.min(minRow, ent.getKey().getRow()); - maxRow = Math.max(maxRow, ent.getKey().getRow()); - minCol = Math.min(minCol, ent.getValue()); - maxCol = Math.max(maxCol, ent.getValue()); - } - for (Map.Entry<ANode, Integer> ent : nodesCols.entrySet()) { - if (minRow != 0) { - ent.getKey().setRow(ent.getKey().getRow() - minRow); - } - if (minCol != 0) { - ent.setValue(ent.getValue() - minCol); - } - } - } - - private void normalizeCol() { - final int minCol = Collections.min(nodesCols.values()); - - if (minCol != 0) { - for (Map.Entry<ANode, Integer> ent : nodesCols.entrySet()) { - ent.setValue(ent.getValue() - minCol); - } - } - } - - void internalMove(String code, int newCol) { - hashcodeComputed = false; - for (ANode n : nodesCols.keySet()) { - if (n.getCode().equals(code)) { - nodesCols.put(n, newCol); - return; - } - } - } - - public Board copy() { - return new Board(this); - } - - public Board(List<ANode> nodes, List<ALink> links) { - for (ANode n : nodes) { - addInRow(n); - } - this.links = Collections.unmodifiableList(new ArrayList<ALink>(links)); - this.initialDirection = new HashMap<ALink, Integer>(); - for (ALink link : links) { - this.initialDirection.put(link, getDirection(link)); - } - } - - public int getInitialDirection(ALink link) { - return initialDirection.get(link); - } - - public int getDirection(ALink link) { - return getCol(link.getNode2()) - getCol(link.getNode1()); - } - - private void addInRow(ANode n) { - hashcodeComputed = false; - int col = 0; - while (true) { - if (getNodeAt(n.getRow(), col) == null) { - nodesCols.put(n, col); - assert getNodeAt(n.getRow(), col) == n; - return; - } - col++; - } - } - - public Collection<ANode> getNodes() { - return Collections.unmodifiableCollection(nodesCols.keySet()); - } - - public Collection<ANode> getNodesInRow(int row) { - final List<ANode> result = new ArrayList<ANode>(); - for (ANode n : nodesCols.keySet()) { - if (n.getRow() == row) { - result.add(n); - } - } - return Collections.unmodifiableCollection(result); - } - - public final List<? extends ALink> getLinks() { - return Collections.unmodifiableList(links); - } - - public int getCol(ANode n) { - return nodesCols.get(n); - } - - public void applyMove(Move move) { - final ANode piece = getNodeAt(move.getRow(), move.getCol()); - if (piece == null) { - throw new IllegalArgumentException(); - } - final ANode piece2 = getNodeAt(move.getRow(), move.getNewCol()); - nodesCols.put(piece, move.getNewCol()); - if (piece2 != null) { - nodesCols.put(piece2, move.getCol()); - } - normalizeCol(); - hashcodeComputed = false; - } - - public Collection<Move> getAllPossibleMoves() { - final List<Move> result = new ArrayList<Move>(); - for (Map.Entry<ANode, Integer> ent : nodesCols.entrySet()) { - final int row = ent.getKey().getRow(); - final int col = ent.getValue(); - result.add(new Move(row, col, -1)); - result.add(new Move(row, col, 1)); - } - return result; - } - - public ANode getNodeAt(int row, int col) { - for (Map.Entry<ANode, Integer> ent : nodesCols.entrySet()) { - if (ent.getKey().getRow() == row && ent.getValue().intValue() == col) { - return ent.getKey(); - } - } - return null; - } - - public Set<ANode> getConnectedNodes(ANode root, int level) { - if (level < 0) { - throw new IllegalArgumentException(); - } - if (level == 0) { - return Collections.singleton(root); - } - final Set<ANode> result = new HashSet<ANode>(); - if (level == 1) { - for (ALink link : links) { - if (link.getNode1() == root) { - result.add(link.getNode2()); - } else if (link.getNode2() == root) { - result.add(link.getNode1()); - } - - } - } else { - for (ANode n : getConnectedNodes(root, level - 1)) { - result.addAll(getConnectedNodes(n, 1)); - } - } - return Collections.unmodifiableSet(result); - } - - public Set<ALink> getAllLinks(Set<ANode> nodes) { - final Set<ALink> result = new HashSet<ALink>(); - for (ALink link : links) { - if (nodes.contains(link.getNode1()) || nodes.contains(link.getNode2())) { - result.add(link); - } - } - return Collections.unmodifiableSet(result); - } - -} diff --git a/src/net/sourceforge/plantuml/graph/BoardCollection.java b/src/net/sourceforge/plantuml/graph/BoardCollection.java deleted file mode 100644 index 98855f9..0000000 --- a/src/net/sourceforge/plantuml/graph/BoardCollection.java +++ /dev/null @@ -1,128 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.graph; - -import java.util.ArrayList; -import java.util.List; - -public class BoardCollection { - - static class Entry implements Comparable<Entry> { - final private Board board; - final private double cost; - private boolean explored; - - public Entry(Board b, CostComputer costComputer) { - this.board = b; - if (costComputer == null) { - this.cost = 0; - } else { - this.cost = costComputer.getCost(b); - } - } - - public int compareTo(Entry other) { - return (int) Math.signum(this.cost - other.cost); - } - - @Override - public boolean equals(Object obj) { - final Entry other = (Entry) obj; - return board.equals(other.board); - } - - @Override - public int hashCode() { - return board.hashCode(); - } - - } - - private final SortedCollection<Entry> all = new SortedCollectionArrayList<Entry>(); - - private final CostComputer costComputer; - - public BoardCollection(CostComputer costComputer) { - this.costComputer = costComputer; - } - - public int size() { - return all.size(); - } - - public Board getAndSetExploredSmallest() { - for (Entry ent : all) { - if (ent.explored == false) { - ent.explored = true; - assert costComputer.getCost(ent.board) == ent.cost; - // Log.println("Peeking " + ent.cost); - return ent.board; - } - } - return null; - } - - public double getBestCost() { - for (Entry ent : all) { - return ent.cost; - } - return 0; - } - - public Board getBestBoard() { - for (Entry ent : all) { - return ent.board; - } - return null; - } - - public List<Double> getCosts() { - final List<Double> result = new ArrayList<Double>(); - for (Entry ent : all) { - result.add(costComputer.getCost(ent.board)); - } - return result; - } - - public void add(Board b) { - all.add(new Entry(b, costComputer)); - } - - public boolean contains(Board b) { - return all.contains(new Entry(b, null)); - } - -} diff --git a/src/net/sourceforge/plantuml/graph/BoardExplorer.java b/src/net/sourceforge/plantuml/graph/BoardExplorer.java deleted file mode 100644 index c99e804..0000000 --- a/src/net/sourceforge/plantuml/graph/BoardExplorer.java +++ /dev/null @@ -1,86 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.graph; - -import java.util.HashSet; -import java.util.Set; - -public class BoardExplorer { - - private final BoardCollection all = new BoardCollection(new KenavoCostComputer()); - - public BoardExplorer(Board init) { - all.add(init); - } - - public double getBestCost() { - return all.getBestCost(); - } - - public Board getBestBoard() { - return all.getBestBoard(); - } - - public int collectionSize() { - return all.size(); - } - - public boolean onePass() { - final Board smallest = all.getAndSetExploredSmallest(); - if (smallest == null) { - return true; - } - final Set<Board> moves = nextBoards(smallest); - for (Board newBoard : moves) { - if (all.contains(newBoard)) { - continue; - } - all.add(newBoard); - } - return false; - } - - public Set<Board> nextBoards(Board board) { - final Set<Board> result = new HashSet<Board>(); - for (Move m : board.getAllPossibleMoves()) { - final Board copy = board.copy(); - copy.applyMove(m); - result.add(copy); - } - return result; - } - -} diff --git a/src/net/sourceforge/plantuml/graph/CostComputer.java b/src/net/sourceforge/plantuml/graph/CostComputer.java deleted file mode 100644 index b29bcf1..0000000 --- a/src/net/sourceforge/plantuml/graph/CostComputer.java +++ /dev/null @@ -1,42 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.graph; - -public interface CostComputer { - - double getCost(Board board); - -}
\ No newline at end of file diff --git a/src/net/sourceforge/plantuml/graph/ElectricCharge.java b/src/net/sourceforge/plantuml/graph/ElectricCharge.java deleted file mode 100644 index 41508d1..0000000 --- a/src/net/sourceforge/plantuml/graph/ElectricCharge.java +++ /dev/null @@ -1,70 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.graph; - -import java.awt.geom.Point2D; - -public class ElectricCharge { - - private boolean moveable; - private final Point2D position; - private final double charge; - - public ElectricCharge(double x, double y, double charge) { - this.position = new Point2D.Double(x, y); - this.charge = charge; - } - - public Point2D getPosition() { - return position; - } - - public double getCharge() { - return charge; - } - - public final boolean isMoveable() { - return moveable; - } - - public final void setMoveable(boolean moveable) { - this.moveable = moveable; - } - - public void move(double deltax, double deltay) { - position.setLocation(position.getX() + deltax, position.getY() + deltay); - } -} diff --git a/src/net/sourceforge/plantuml/graph/ElectricWord.java b/src/net/sourceforge/plantuml/graph/ElectricWord.java deleted file mode 100644 index 7181000..0000000 --- a/src/net/sourceforge/plantuml/graph/ElectricWord.java +++ /dev/null @@ -1,68 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.graph; - -import java.awt.geom.Point2D; -import java.awt.geom.Rectangle2D; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -public class ElectricWord { - - private List<ElectricCharge> charges = new ArrayList<ElectricCharge>(); - - public ElectricWord(Rectangle2D playingZone) { - - } - - public void addGlueArea(Rectangle2D glue) { - - } - - public void addCharge(ElectricCharge charge) { - - } - - public void addCharges(Collection<ElectricCharge> charges) { - - } - - public Point2D getForceAt(Point2D position, double charge, Collection<ElectricCharge> ignoredCharges) { - return null; - } - -} diff --git a/src/net/sourceforge/plantuml/graph/EntityImageActivityBar.java b/src/net/sourceforge/plantuml/graph/EntityImageActivityBar.java deleted file mode 100644 index e1da35f..0000000 --- a/src/net/sourceforge/plantuml/graph/EntityImageActivityBar.java +++ /dev/null @@ -1,66 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.graph; - -import java.awt.Color; -import java.awt.Graphics2D; -import java.awt.geom.Dimension2D; - -import net.sourceforge.plantuml.Dimension2DDouble; -import net.sourceforge.plantuml.cucadiagram.IEntity; -import net.sourceforge.plantuml.graphic.StringBounder; -import net.sourceforge.plantuml.ugraphic.ColorMapper; - -class EntityImageActivityBar extends AbstractEntityImage { - - private final int width = 100; - private final int height = 8; - - public EntityImageActivityBar(IEntity entity) { - super(entity); - } - - @Override - public Dimension2D getDimension(StringBounder stringBounder) { - return new Dimension2DDouble(width, height); - } - - @Override - public void draw(ColorMapper colorMapper, Graphics2D g2d) { - g2d.setColor(Color.BLACK); - g2d.fillRect(0, 0, width, height); - } -} diff --git a/src/net/sourceforge/plantuml/graph/EntityImageActivityBranch.java b/src/net/sourceforge/plantuml/graph/EntityImageActivityBranch.java deleted file mode 100644 index ebb544d..0000000 --- a/src/net/sourceforge/plantuml/graph/EntityImageActivityBranch.java +++ /dev/null @@ -1,73 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.graph; - -import java.awt.Graphics2D; -import java.awt.Polygon; -import java.awt.geom.Dimension2D; - -import net.sourceforge.plantuml.Dimension2DDouble; -import net.sourceforge.plantuml.cucadiagram.IEntity; -import net.sourceforge.plantuml.graphic.StringBounder; -import net.sourceforge.plantuml.ugraphic.ColorMapper; - -class EntityImageActivityBranch extends AbstractEntityImage { - - private final int size = 10; - - public EntityImageActivityBranch(IEntity entity) { - super(entity); - } - - @Override - public Dimension2D getDimension(StringBounder stringBounder) { - return new Dimension2DDouble(size * 2, size * 2); - } - - @Override - public void draw(ColorMapper colorMapper, Graphics2D g2d) { - final Polygon p = new Polygon(); - p.addPoint(size, 0); - p.addPoint(size * 2, size); - p.addPoint(size, size * 2); - p.addPoint(0, size); - - g2d.setColor(colorMapper.getMappedColor(getYellow())); - g2d.fill(p); - g2d.setColor(colorMapper.getMappedColor(getRed())); - g2d.draw(p); - } -} diff --git a/src/net/sourceforge/plantuml/graph/EntityImageActivityCircle.java b/src/net/sourceforge/plantuml/graph/EntityImageActivityCircle.java deleted file mode 100644 index e5f01cc..0000000 --- a/src/net/sourceforge/plantuml/graph/EntityImageActivityCircle.java +++ /dev/null @@ -1,70 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.graph; - -import java.awt.Color; -import java.awt.Graphics2D; -import java.awt.geom.Dimension2D; - -import net.sourceforge.plantuml.Dimension2DDouble; -import net.sourceforge.plantuml.cucadiagram.IEntity; -import net.sourceforge.plantuml.graphic.StringBounder; -import net.sourceforge.plantuml.ugraphic.ColorMapper; - -class EntityImageActivityCircle extends AbstractEntityImage { - - private final int diameterExternal; - private final int diameterInternal; - - public EntityImageActivityCircle(IEntity entity, int diameterExternal, int diameterInternal) { - super(entity); - this.diameterExternal = diameterExternal; - this.diameterInternal = diameterInternal; - } - - @Override - public Dimension2D getDimension(StringBounder stringBounder) { - return new Dimension2DDouble(diameterExternal, diameterExternal); - } - - @Override - public void draw(ColorMapper colorMapper, Graphics2D g2d) { - g2d.setColor(Color.BLACK); - final int delta = diameterExternal - diameterInternal + 1; - g2d.drawOval(0, 0, diameterExternal, diameterExternal); - g2d.fillOval(delta / 2, delta / 2, diameterInternal, diameterInternal); - } -} diff --git a/src/net/sourceforge/plantuml/graph/EntityImageCircleInterface.java b/src/net/sourceforge/plantuml/graph/EntityImageCircleInterface.java deleted file mode 100644 index 752f215..0000000 --- a/src/net/sourceforge/plantuml/graph/EntityImageCircleInterface.java +++ /dev/null @@ -1,92 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.graph; - -import java.awt.Graphics2D; -import java.awt.geom.Dimension2D; - -import net.sourceforge.plantuml.Dimension2DDouble; -import net.sourceforge.plantuml.SpriteContainerEmpty; -import net.sourceforge.plantuml.cucadiagram.IEntity; -import net.sourceforge.plantuml.graphic.FontConfiguration; -import net.sourceforge.plantuml.graphic.HorizontalAlignment; -import net.sourceforge.plantuml.graphic.StringBounder; -import net.sourceforge.plantuml.graphic.TextBlock; -import net.sourceforge.plantuml.skin.CircleInterface; -import net.sourceforge.plantuml.ugraphic.ColorMapper; - -class EntityImageCircleInterface extends AbstractEntityImage { - - final private TextBlock name; - final private CircleInterface circleInterface; - - public EntityImageCircleInterface(IEntity entity) { - super(entity); - this.name = entity.getDisplay().create(FontConfiguration.blackBlueTrue(getFont14()), - HorizontalAlignment.CENTER, new SpriteContainerEmpty()); - this.circleInterface = new CircleInterface(getYellow(), getRed()); - } - - @Override - public Dimension2D getDimension(StringBounder stringBounder) { - final Dimension2D nameDim = name.calculateDimension(stringBounder); - final double manWidth = circleInterface.getPreferredWidth(stringBounder); - final double manHeight = circleInterface.getPreferredHeight(stringBounder); - return new Dimension2DDouble(Math.max(manWidth, nameDim.getWidth()), manHeight + nameDim.getHeight()); - } - - @Override - public void draw(ColorMapper colorMapper, Graphics2D g2d) { - throw new UnsupportedOperationException(); - // final Dimension2D dimTotal = getDimension(StringBounderUtils.asStringBounder(g2d)); - // final Dimension2D nameDim = name.calculateDimension(StringBounderUtils.asStringBounder(g2d)); - // - // final double manWidth = circleInterface.getPreferredWidth(StringBounderUtils.asStringBounder(g2d)); - // final double manHeight = circleInterface.getPreferredHeight(StringBounderUtils.asStringBounder(g2d)); - // - // final double manX = (dimTotal.getWidth() - manWidth) / 2; - // - // g2d.setColor(Color.WHITE); - // g2d.fill(new Rectangle2D.Double(0, 0, dimTotal.getWidth(), dimTotal.getHeight())); - // - // g2d.translate(manX, 0); - // circleInterface.draw(g2d); - // g2d.translate(-manX, 0); - // - // g2d.setColor(Color.BLACK); - // name.drawTOBEREMOVED(g2d, (dimTotal.getWidth() - nameDim.getWidth()) / 2, manHeight); - } -} diff --git a/src/net/sourceforge/plantuml/graph/Galaxy4.java b/src/net/sourceforge/plantuml/graph/Galaxy4.java deleted file mode 100644 index c44a3c1..0000000 --- a/src/net/sourceforge/plantuml/graph/Galaxy4.java +++ /dev/null @@ -1,94 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.graph; - -import java.util.Collections; -import java.util.LinkedHashMap; -import java.util.Map; - -import net.sourceforge.plantuml.Log; -import net.sourceforge.plantuml.geom.Point2DInt; -import net.sourceforge.plantuml.geom.PolylineBreakeable; -import net.sourceforge.plantuml.geom.SpiderWeb; - -public class Galaxy4 { - - final private Board board; - - final private Map<ALink, PolylineBreakeable> lines = new LinkedHashMap<ALink, PolylineBreakeable>(); - final private SpiderWeb spiderWeb; - - public Galaxy4(Board board, int widthCell, int heightCell) { - this.spiderWeb = new SpiderWeb(widthCell, heightCell); - this.board = board; - } - - public Point2DInt getMainPoint(int row, int col) { - return spiderWeb.getMainPoint(row, col); - } - - public PolylineBreakeable getPolyline(ALink link) { - return lines.get(link); - - } - - public void addLink(ALink link) { - final int rowStart = link.getNode1().getRow(); - final int rowEnd = link.getNode2().getRow(); - final int colStart = board.getCol(link.getNode1()); - final int colEnd = board.getCol(link.getNode2()); - - final PolylineBreakeable polyline = spiderWeb.addPolyline(rowStart, colStart, rowEnd, colEnd); - - Log.info("link=" + link + " polyline=" + polyline); - - if (polyline == null) { - Log.info("PENDING " + link + " " + polyline); - } else { - lines.put(link, polyline); - } - - } - - public final Board getBoard() { - return board; - } - - public final Map<ALink, PolylineBreakeable> getLines() { - return Collections.unmodifiableMap(lines); - } - -} diff --git a/src/net/sourceforge/plantuml/graph/GeneralPathFactory.java b/src/net/sourceforge/plantuml/graph/GeneralPathFactory.java deleted file mode 100644 index 7fd54c2..0000000 --- a/src/net/sourceforge/plantuml/graph/GeneralPathFactory.java +++ /dev/null @@ -1,158 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.graph; - -import java.awt.Polygon; -import java.awt.Shape; -import java.awt.geom.AffineTransform; -import java.awt.geom.GeneralPath; -import java.awt.geom.Point2D; - -import net.sourceforge.plantuml.cucadiagram.LinkType; -import net.sourceforge.plantuml.geom.Box; -import net.sourceforge.plantuml.geom.LineSegmentInt; -import net.sourceforge.plantuml.geom.PolylineBreakeable; - -public class GeneralPathFactory { - - private final LinkType linkType; - - public GeneralPathFactory(LinkType linkType) { - this.linkType = linkType; - } - - public Shape getLink(PolylineBreakeable polyline, Box b1, Box b2) { - final LineSegmentInt directSegment = new LineSegmentInt(b1.getCenterX(), b1.getCenterY(), b2.getCenterX(), b2 - .getCenterY()); - assert b1.intersect(directSegment).length == 1; - assert b2.intersect(directSegment).length == 1; - - // final Point2D.Double start = polyline.clipStart(b1); - // final Point2D.Double end = polyline.clipEnd(b2); - final GeneralPath generalPath = polyline.asGeneralPath(); - // addSymbol(generalPath, start, polyline.getFirst(), end, - // polyline.getLast()); - return generalPath; - - } - - private void addSymbol(GeneralPath generalPath, Point2D.Double firstPoint, LineSegmentInt firstSeg, - Point2D.Double lastPoint, LineSegmentInt lastSeg) { -// if (linkType.equals(LinkType.AGREGATION) || linkType.equals(LinkType.COMPOSITION)) { -// addSymbolDiamond(generalPath, lastPoint, lastSeg); -// } else if (linkType.equals(LinkType.AGREGATION_INV) || linkType.equals(LinkType.COMPOSITION_INV)) { -// addSymbolDiamondInv(generalPath, firstPoint, firstSeg); -// } else if (linkType.equals(LinkType.NAVASSOC) || linkType.equals(LinkType.NAVASSOC_DASHED)) { -// addSymbolNavasoc(generalPath, lastPoint, lastSeg); -// } else if (linkType.equals(LinkType.NAVASSOC_INV) || linkType.equals(LinkType.NAVASSOC_DASHED_INV)) { -// addSymbolNavasocInv(generalPath, firstPoint, firstSeg); -// } else if (linkType.equals(LinkType.EXTENDS_INV) || linkType.equals(LinkType.IMPLEMENTS_INV)) { -// addSymbolExtends(generalPath, firstPoint, firstSeg); -// } else if (linkType.equals(LinkType.EXTENDS) || linkType.equals(LinkType.IMPLEMENTS)) { -// addSymbolExtendsInv(generalPath, lastPoint, lastSeg); -// } else { -// assert linkType.equals(LinkType.ASSOCIED) || linkType.equals(LinkType.ASSOCIED_DASHED); -// } - } - - private void addSymbolDiamond(GeneralPath generalPath, Point2D.Double point, LineSegmentInt seg) { - final Polygon arrow = new Polygon(); - arrow.addPoint(0, 0); - arrow.addPoint(-10, 6); - arrow.addPoint(-20, 0); - arrow.addPoint(-10, -6); - - appendAndRotate(generalPath, point, seg, arrow); - } - - private void addSymbolDiamondInv(GeneralPath generalPath, Point2D.Double point, LineSegmentInt seg) { - final Polygon arrow = new Polygon(); - arrow.addPoint(0, 0); - arrow.addPoint(10, 6); - arrow.addPoint(20, 0); - arrow.addPoint(10, -6); - - appendAndRotate(generalPath, point, seg, arrow); - } - - private void addSymbolNavasocInv(GeneralPath generalPath, Point2D.Double point, LineSegmentInt seg) { - final Polygon arrow = new Polygon(); - arrow.addPoint(0, 0); - arrow.addPoint(13, -8); - arrow.addPoint(6, 0); - arrow.addPoint(13, 8); - - appendAndRotate(generalPath, point, seg, arrow); - } - - private void addSymbolNavasoc(GeneralPath generalPath, Point2D.Double point, LineSegmentInt seg) { - final Polygon arrow = new Polygon(); - arrow.addPoint(0, 0); - arrow.addPoint(-13, -8); - arrow.addPoint(-6, 0); - arrow.addPoint(-13, 8); - - appendAndRotate(generalPath, point, seg, arrow); - } - - private void addSymbolExtends(GeneralPath generalPath, Point2D.Double point, LineSegmentInt seg) { - final Polygon arrow = new Polygon(); - arrow.addPoint(0, 0); - arrow.addPoint(25, 7); - arrow.addPoint(25, -7); - - appendAndRotate(generalPath, point, seg, arrow); - } - - private void addSymbolExtendsInv(GeneralPath generalPath, Point2D.Double point, LineSegmentInt seg) { - final Polygon arrow = new Polygon(); - arrow.addPoint(0, 0); - arrow.addPoint(-25, 7); - arrow.addPoint(-25, -7); - - appendAndRotate(generalPath, point, seg, arrow); - } - - private void appendAndRotate(GeneralPath generalPath, Point2D.Double point, LineSegmentInt seg, final Shape shape) { - final AffineTransform at = AffineTransform.getTranslateInstance(point.x, point.y); - final double theta = seg.getAngle(); - at.rotate(theta); - - final Shape r = at.createTransformedShape(shape); - generalPath.append(r, false); - } - -} diff --git a/src/net/sourceforge/plantuml/graph/Graph1.java b/src/net/sourceforge/plantuml/graph/Graph1.java deleted file mode 100644 index 44ef13e..0000000 --- a/src/net/sourceforge/plantuml/graph/Graph1.java +++ /dev/null @@ -1,81 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.graph; - -import java.awt.Color; -import java.awt.Graphics2D; -import java.awt.image.BufferedImage; - -public class Graph1 { - - private final Board board; - private final int widthCell = 40; - private final int heightCell = 40; - - public Graph1(Board board) { - this.board = board; - } - - public BufferedImage createBufferedImage() { - final BufferedImage im = new BufferedImage(widthCell * 15, heightCell * 15, BufferedImage.TYPE_INT_RGB); - final Graphics2D g2d = im.createGraphics(); - g2d.setColor(Color.WHITE); - g2d.fillRect(0, 0, im.getWidth(), im.getHeight()); - - g2d.setColor(Color.BLACK); - for (ANode n : board.getNodes()) { - final int x = board.getCol(n) * widthCell; - final int y = n.getRow() * heightCell; - g2d.drawString(n.getCode(), x + 5, y + heightCell / 2 - 5); - g2d.drawOval(x, y, widthCell / 2, heightCell / 2); - } - - for (ALink link : board.getLinks()) { - final ANode n1 = link.getNode1(); - final ANode n2 = link.getNode2(); - final int x1 = 10 + board.getCol(n1) * widthCell; - final int y1 = 10 + n1.getRow() * heightCell; - final int x2 = 10 + board.getCol(n2) * widthCell; - final int y2 = 10 + n2.getRow() * heightCell; - g2d.drawLine(x1, y1, x2, y2); - - } - - return im; - - } - -} diff --git a/src/net/sourceforge/plantuml/graph/Heap.java b/src/net/sourceforge/plantuml/graph/Heap.java deleted file mode 100644 index fec054f..0000000 --- a/src/net/sourceforge/plantuml/graph/Heap.java +++ /dev/null @@ -1,242 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.graph; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashSet; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - -public class Heap { - - private final Map<String, ANode> nodes = new LinkedHashMap<String, ANode>(); - private final Map<ANode, LinkedHashMap<ANode, ALink>> directChildren = new LinkedHashMap<ANode, LinkedHashMap<ANode, ALink>>(); - private final List<ALink> links = new ArrayList<ALink>(); - - public boolean isEmpty() { - if (links.isEmpty()) { - assert nodes.isEmpty(); - assert directChildren.isEmpty(); - return true; - } - return false; - } - - public void importing(ANode under, ANode otherRoot, Heap otherHeap, int diffHeight, Object userData) { - assert this.directChildren.keySet().contains(under); - assert this.nodes.values().contains(under); - assert otherHeap.nodes.values().contains(otherRoot); - assert otherHeap.directChildren.keySet().contains(otherRoot); - assert this.nodes.values().contains(otherRoot) == false; - assert this.directChildren.keySet().contains(otherRoot) == false; - assert otherHeap.directChildren.keySet().contains(under) == false; - final int oldSize = this.nodes.size(); - assert oldSize == this.directChildren.size(); - this.nodes.putAll(otherHeap.nodes); - this.directChildren.putAll(otherHeap.directChildren); - final ALinkImpl link = new ALinkImpl(under, otherRoot, diffHeight, userData); - this.links.add(link); - this.links.addAll(otherHeap.links); - assert oldSize + otherHeap.nodes.size() == this.nodes.size(); - assert oldSize + otherHeap.directChildren.size() == this.directChildren.size(); - - addUnderMe(under, otherRoot, link); - } - - public void computeRows() { - for (ANode n : nodes.values()) { - n.setRow(Integer.MIN_VALUE); - } - nodes.values().iterator().next().setRow(0); - boolean changed; - do { - onePass(); - changed = false; - for (ANode n : nodes.values()) { - if (n.getRow() != Integer.MIN_VALUE) { - continue; - } - final Map.Entry<ANode, ALink> smallestRowOfChildren = getSmallestRowOfChildren(n); - if (smallestRowOfChildren != null) { - n.setRow(getStartingRow(smallestRowOfChildren)); - } - changed = true; - } - } while (changed); - - minToZero(); - } - - private int getStartingRow(Map.Entry<ANode, ALink> ent) { - assert ent.getValue().getNode2() == ent.getKey(); - return ent.getValue().getNode2().getRow() - ent.getValue().getDiffHeight(); - } - - private void minToZero() { - int min = Integer.MAX_VALUE; - for (ANode n : nodes.values()) { - min = Math.min(min, n.getRow()); - } - if (min == Integer.MIN_VALUE) { - throw new IllegalStateException(); - } - if (min != 0) { - for (ANode n : nodes.values()) { - n.setRow(n.getRow() - min); - } - } - - } - - private Map.Entry<ANode, ALink> getSmallestRowOfChildren(ANode n) { - assert n.getRow() == Integer.MIN_VALUE; - Map.Entry<ANode, ALink> result = null; - for (Map.Entry<ANode, ALink> ent : directChildren.get(n).entrySet()) { - final ANode child = ent.getKey(); - if (child.getRow() == Integer.MIN_VALUE) { - continue; - } - if (result == null || getStartingRow(ent) < getStartingRow(result)) { - result = ent; - } - } - // assert result != null; - return result; - } - - private void onePass() { - boolean changed; - do { - changed = false; - for (ANode n : nodes.values()) { - final int row = n.getRow(); - if (row == Integer.MIN_VALUE) { - continue; - } - for (Map.Entry<ANode, ALink> ent : directChildren.get(n).entrySet()) { - final ANode child = ent.getKey(); - final int diffHeight = ent.getValue().getDiffHeight(); - if (child.getRow() == Integer.MIN_VALUE || child.getRow() < row + diffHeight) { - child.setRow(row + diffHeight); - changed = true; - } - } - } - } while (changed); - } - - private ANode getNode(String code) { - ANode result = nodes.get(code); - if (result == null) { - result = createNewNode(code); - } - return result; - } - - private ANode createNewNode(String code) { - final ANode result = new ANodeImpl(code); - directChildren.put(result, new LinkedHashMap<ANode, ALink>()); - nodes.put(code, result); - assert directChildren.size() == nodes.size(); - return result; - } - - public ANode getExistingNode(String code) { - return nodes.get(code); - } - - public List<ALink> getLinks() { - return Collections.unmodifiableList(links); - } - - public List<ANode> getNodes() { - return Collections.unmodifiableList(new ArrayList<ANode>(nodes.values())); - } - - HashSet<ANode> getAllChildren(ANode n) { - final HashSet<ANode> result = new HashSet<ANode>(directChildren.get(n).keySet()); - int size = 0; - do { - size = result.size(); - for (ANode other : new HashSet<ANode>(result)) { - result.addAll(getAllChildren(other)); - } - } while (result.size() != size); - return result; - } - - public void addLink(String stringLink, int diffHeight, Object userData) { - final LinkString l = new LinkString(stringLink); - final ANode n1 = getNode(l.getNode1()); - final ANode n2 = getNode(l.getNode2()); - if (n1 == n2) { - return; - } - final ALinkImpl link = new ALinkImpl(n1, n2, diffHeight, userData); - links.add(link); - - if (getAllChildren(n2).contains(n1)) { - addUnderMe(n2, n1, link); - } else { - addUnderMe(n1, n2, link); - } - } - - public ANode addNode(String code) { - if (nodes.containsKey(code)) { - throw new IllegalArgumentException(); - } - return createNewNode(code); - } - - private void addUnderMe(final ANode n1, final ANode n2, final ALinkImpl link) { - assert getAllChildren(n2).contains(n1) == false; - directChildren.get(n1).put(n2, link); - assert getAllChildren(n1).contains(n2); - assert getAllChildren(n2).contains(n1) == false; - } - - public int getRowMax() { - int max = Integer.MIN_VALUE; - for (ANode n : nodes.values()) { - max = Math.max(max, n.getRow()); - } - return max; - } - -} diff --git a/src/net/sourceforge/plantuml/graph/KenavoCostComputer.java b/src/net/sourceforge/plantuml/graph/KenavoCostComputer.java deleted file mode 100644 index 97c2b2f..0000000 --- a/src/net/sourceforge/plantuml/graph/KenavoCostComputer.java +++ /dev/null @@ -1,78 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.graph; - -import net.sourceforge.plantuml.geom.LineSegmentInt; - -public class KenavoCostComputer implements CostComputer { - - public double getCost(Board board) { - double result = 0; - for (ALink link1 : board.getLinks()) { - for (ALink link2 : board.getLinks()) { - result += getCost(board, link1, link2); - } - } - return result; - } - - LineSegmentInt getLineSegment(Board board, ALink link) { - final ANode n1 = link.getNode1(); - final ANode n2 = link.getNode2(); - return new LineSegmentInt(board.getCol(n1), n1.getRow(), board.getCol(n2), n2.getRow()); - } - - private double getCost(Board board, ALink link1, ALink link2) { - final LineSegmentInt seg1 = getLineSegment(board, link1); - final LineSegmentInt seg2 = getLineSegment(board, link2); - - final double len1 = getLength(link1, seg1, board); - final double len2 = getLength(link2, seg2, board); - - return len1 * len2 * Math.exp(-seg1.getDistance(seg2)); - } - - private double getLength(ALink link, final LineSegmentInt seg, Board board) { - double coef = 1; - if (link.getNode1().getRow() == link.getNode2().getRow() - && board.getDirection(link) != board.getInitialDirection(link)) { - coef = 1.1; - } - - return seg.getLength() * coef; - } - -} diff --git a/src/net/sourceforge/plantuml/graph/LenghtLinkComparator.java b/src/net/sourceforge/plantuml/graph/LenghtLinkComparator.java deleted file mode 100644 index b316e64..0000000 --- a/src/net/sourceforge/plantuml/graph/LenghtLinkComparator.java +++ /dev/null @@ -1,61 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.graph; - -import java.util.Comparator; -import java.util.Map; - -public class LenghtLinkComparator implements Comparator<ALink> { - - private final Map<ANode, Integer> cols; - - public LenghtLinkComparator(Map<ANode, Integer> cols) { - this.cols = cols; - } - - public int compare(ALink link1, ALink link2) { - return (int) Math.signum(getLenght(link1) - getLenght(link2)); - } - - private double getLenght(ALink link) { - final ANode n1 = link.getNode1(); - final ANode n2 = link.getNode2(); - final int deltaRow = n2.getRow() - n1.getRow(); - final int deltaCol = cols.get(n2) - cols.get(n1); - return deltaRow * deltaRow + deltaCol * deltaCol; - } - -} diff --git a/src/net/sourceforge/plantuml/graph/LinkString.java b/src/net/sourceforge/plantuml/graph/LinkString.java deleted file mode 100644 index c69ec79..0000000 --- a/src/net/sourceforge/plantuml/graph/LinkString.java +++ /dev/null @@ -1,66 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.graph; - -import net.sourceforge.plantuml.command.regex.Matcher2; -import net.sourceforge.plantuml.command.regex.MyPattern; -import net.sourceforge.plantuml.command.regex.Pattern2; - -public class LinkString { - - final private static Pattern2 p = MyPattern.cmpile("(.*)->(.*)"); - - final private String node1; - final private String node2; - - public LinkString(String desc) { - final Matcher2 m = p.matcher(desc); - if (m.find() == false) { - throw new IllegalArgumentException(); - } - node1 = m.group(1); - node2 = m.group(2); - - } - - public final String getNode1() { - return node1; - } - - public final String getNode2() { - return node2; - } -} diff --git a/src/net/sourceforge/plantuml/graph/MethodsOrFieldsArea.java b/src/net/sourceforge/plantuml/graph/MethodsOrFieldsArea.java deleted file mode 100644 index 0d56eaa..0000000 --- a/src/net/sourceforge/plantuml/graph/MethodsOrFieldsArea.java +++ /dev/null @@ -1,96 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.graph; - -import java.awt.geom.Dimension2D; -import java.util.ArrayList; -import java.util.List; - -import net.sourceforge.plantuml.Dimension2DDouble; -import net.sourceforge.plantuml.SpriteContainerEmpty; -import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.cucadiagram.Member; -import net.sourceforge.plantuml.graphic.FontConfiguration; -import net.sourceforge.plantuml.graphic.HorizontalAlignment; -import net.sourceforge.plantuml.graphic.StringBounder; -import net.sourceforge.plantuml.graphic.TextBlock; -import net.sourceforge.plantuml.skin.VisibilityModifier; -import net.sourceforge.plantuml.ugraphic.UFont; -import net.sourceforge.plantuml.ugraphic.UGraphic; -import net.sourceforge.plantuml.ugraphic.UTranslate; - -public class MethodsOrFieldsArea { - - private final UFont font; - private final List<String> strings = new ArrayList<String>(); - - public MethodsOrFieldsArea(List<Member> attributes, UFont font) { - this.font = font; - for (Member att : attributes) { - this.strings.add(att.getDisplay(false)); - } - } - - public VisibilityModifier getVisibilityModifier() { - throw new UnsupportedOperationException(); - } - - public Dimension2D calculateDimension(StringBounder stringBounder) { - double x = 0; - double y = 0; - for (String s : strings) { - final TextBlock bloc = createTextBlock(s); - final Dimension2D dim = bloc.calculateDimension(stringBounder); - y += dim.getHeight(); - x = Math.max(dim.getWidth(), x); - } - return new Dimension2DDouble(x, y); - } - - private TextBlock createTextBlock(String s) { - return Display.create(s).create(FontConfiguration.blackBlueTrue(font), HorizontalAlignment.LEFT, - new SpriteContainerEmpty()); - } - - public void draw(UGraphic ug, double x, double y) { - for (String s : strings) { - final TextBlock bloc = createTextBlock(s); - bloc.drawU(ug.apply(new UTranslate(x, y))); - y += bloc.calculateDimension(ug.getStringBounder()).getHeight(); - } - } - -} diff --git a/src/net/sourceforge/plantuml/graph/Move.java b/src/net/sourceforge/plantuml/graph/Move.java deleted file mode 100644 index d671757..0000000 --- a/src/net/sourceforge/plantuml/graph/Move.java +++ /dev/null @@ -1,78 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.graph; - -public class Move { - - private final int row; - private final int col; - private final int delta; - - @Override - public String toString() { - return row + "." + col + "->" + row + "." + (col + delta); - } - - public Move(int row, int col, int delta) { - if (delta != 1 && delta != -1) { - throw new IllegalArgumentException(); - } - this.row = row; - this.col = col; - this.delta = delta; - } - - public int getRow() { - return row; - } - - public int getCol() { - return col; - } - - public int getNewCol() { - return col + delta; - } - - public int getDelta() { - return delta; - } - - public Move getBackMove() { - return new Move(row, col + delta, -delta); - } - -} diff --git a/src/net/sourceforge/plantuml/graph/Oven.java b/src/net/sourceforge/plantuml/graph/Oven.java deleted file mode 100644 index e533c12..0000000 --- a/src/net/sourceforge/plantuml/graph/Oven.java +++ /dev/null @@ -1,95 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.graph; - -import java.util.Random; - -public class Oven { - - final private double temp; - final private CostComputer costComputer; - - public Oven(double temp, CostComputer costComputer) { - this.temp = temp; - this.costComputer = costComputer; - } - - public Board longTic(int nbTic, Board board, Random rnd) { - double best = costComputer.getCost(board); - Board bestBoard = board.copy(); - for (int i = 0; i < nbTic; i++) { - final double current = tic(board, rnd); - // Log.println("current=" + current + " best=" + best); - if (current < best) { - best = current; - bestBoard = board.copy(); - } - - } - return bestBoard; - } - - public double tic(Board board, Random rnd) { - // Log.println("Oven::tic"); - final double costBefore = costComputer.getCost(board); - final Move move = null; // board.getRandomMove(rnd); - board.applyMove(move); - final double costAfter = costComputer.getCost(board); - final double delta = costAfter - costBefore; - // Log.println("delta=" + delta); - if (delta <= 0) { - return costAfter; - } - assert delta > 0; - assert costAfter > costBefore; - // Log.println("temp=" + temp); - if (temp > 0) { - final double probability = Math.exp(-delta / temp); - final double dice = rnd.nextDouble(); - // Log.println("probability=" + probability + " dice=" + - // dice); - if (dice < probability) { - // Log.println("We keep it"); - return costAfter; - } - } - // Log.println("Roolback"); - board.applyMove(move.getBackMove()); - assert costBefore == costComputer.getCost(board); - return costBefore; - - } -} diff --git a/src/net/sourceforge/plantuml/graph/SimpleCostComputer.java b/src/net/sourceforge/plantuml/graph/SimpleCostComputer.java deleted file mode 100644 index d83f2a2..0000000 --- a/src/net/sourceforge/plantuml/graph/SimpleCostComputer.java +++ /dev/null @@ -1,60 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.graph; - -public class SimpleCostComputer implements CostComputer { - - /* - * (non-Javadoc) - * - * @see net.sourceforge.plantuml.graph.CostComputer#getCost(net.sourceforge.plantuml.graph.Board) - */ - public double getCost(Board board) { - double result = 0; - for (ALink link : board.getLinks()) { - final ANode n1 = link.getNode1(); - final ANode n2 = link.getNode2(); - final int x1 = board.getCol(n1); - final int y1 = n1.getRow(); - final int x2 = board.getCol(n2); - final int y2 = n2.getRow(); - result += Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)); - - } - return result; - } - -} diff --git a/src/net/sourceforge/plantuml/graph/SortedCollection.java b/src/net/sourceforge/plantuml/graph/SortedCollection.java deleted file mode 100644 index f9c52d4..0000000 --- a/src/net/sourceforge/plantuml/graph/SortedCollection.java +++ /dev/null @@ -1,46 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.graph; - -public interface SortedCollection<S extends Comparable<S>> extends Iterable<S> { - - int size(); - - void add(S entry); - - boolean contains(S entry); - -} diff --git a/src/net/sourceforge/plantuml/graph/SortedCollectionArrayList.java b/src/net/sourceforge/plantuml/graph/SortedCollectionArrayList.java deleted file mode 100644 index 7b449ea..0000000 --- a/src/net/sourceforge/plantuml/graph/SortedCollectionArrayList.java +++ /dev/null @@ -1,89 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.graph; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Set; - -public class SortedCollectionArrayList<S extends Comparable<S>> implements SortedCollection<S> { - - private final List<S> allAsList = new ArrayList<S>(); - private final Set<S> allAsSet = new HashSet<S>(); - - public Iterator<S> iterator() { - return allAsList.iterator(); - } - - public void add(S newEntry) { - final int r = Collections.binarySearch(allAsList, newEntry); - if (r >= 0) { - allAsList.add(r, newEntry); - } else { - allAsList.add(-1 - r, newEntry); - } - allAsSet.add(newEntry); - assert isSorted(); - } - - public int size() { - assert allAsSet.size() == allAsList.size(); - return allAsList.size(); - } - - List<S> toList() { - return new ArrayList<S>(allAsList); - } - - boolean isSorted() { - S before = null; - for (S ent : allAsList) { - if (before != null && ent.compareTo(before) < 0) { - return false; - } - before = ent; - } - return true; - } - - public boolean contains(S entry) { - return allAsSet.contains(entry); - } - -} diff --git a/src/net/sourceforge/plantuml/graph/SortedCollectionLinked.java b/src/net/sourceforge/plantuml/graph/SortedCollectionLinked.java deleted file mode 100644 index 023befa..0000000 --- a/src/net/sourceforge/plantuml/graph/SortedCollectionLinked.java +++ /dev/null @@ -1,89 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.graph; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.ListIterator; - -public class SortedCollectionLinked<S extends Comparable<S>> implements SortedCollection<S> { - - private final List<S> all = new LinkedList<S>(); - - public Iterator<S> iterator() { - return all.iterator(); - } - - public void add(S newEntry) { - for (final ListIterator<S> it = all.listIterator(); it.hasNext();) { - final S cur = it.next(); - if (cur.compareTo(newEntry) >= 0) { - it.previous(); - it.add(newEntry); - assert isSorted(); - return; - } - } - all.add(newEntry); - assert isSorted(); - } - - public int size() { - return all.size(); - } - - List<S> toList() { - return new ArrayList<S>(all); - } - - boolean isSorted() { - S before = null; - for (S ent : all) { - if (before != null && ent.compareTo(before) < 0) { - return false; - } - before = ent; - } - return true; - } - - public boolean contains(S entry) { - return all.contains(entry); - } - -} diff --git a/src/net/sourceforge/plantuml/graph/Zoda1.java b/src/net/sourceforge/plantuml/graph/Zoda1.java deleted file mode 100644 index d7edb60..0000000 --- a/src/net/sourceforge/plantuml/graph/Zoda1.java +++ /dev/null @@ -1,168 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.graph; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - -/** - * @deprecated - * - */ -public class Zoda1 { - - private final Map<String, ANodeImpl> nodes = new LinkedHashMap<String, ANodeImpl>(); - private final List<ALink> links = new ArrayList<ALink>(); - - public ANodeImpl getNode(String code) { - ANodeImpl result = nodes.get(code); - if (result == null) { - result = new ANodeImpl(code); - nodes.put(code, result); - } - return result; - } - - public ANodeImpl getExistingNode(String code) { - return nodes.get(code); - } - - public List<ALink> getLinks() { - return Collections.unmodifiableList(links); - } - - public List<ANode> getNodes() { - return Collections.unmodifiableList(new ArrayList<ANode>(nodes.values())); - } - - public void addLink(String link) { - final LinkString l = new LinkString(link); - final ANodeImpl n1 = getNode(l.getNode1()); - final ANodeImpl n2 = getNode(l.getNode2()); - links.add(new ALinkImpl(n1, n2, 1, null)); - } - - public void computeRows() { - getNodes().get(0).setRow(0); - - for (int i = 0; i < links.size(); i++) { - oneStep1(); - oneStep2(); - } - - removeUnplacedNodes(); - } - - private void removeUnplacedNodes() { - for (final Iterator<ANodeImpl> it = nodes.values().iterator(); it.hasNext();) { - final ANodeImpl n = it.next(); - if (n.getRow() == Integer.MIN_VALUE) { - removeLinksOf(n); - it.remove(); - } - } - - } - - private void removeLinksOf(ANodeImpl n) { - for (final Iterator<ALink> it = links.iterator(); it.hasNext();) { - final ALink link = it.next(); - if (link.getNode1() == n || link.getNode2() == n) { - it.remove(); - } - } - - } - - public int getRowMax() { - int max = 0; - for (ANode n : getNodes()) { - if (n.getRow() == Integer.MIN_VALUE) { - return Integer.MIN_VALUE; - } - if (n.getRow() > max) { - max = n.getRow(); - } - } - return max; - } - - private void oneStep1() { - for (ALink link : links) { - final ANode n1 = link.getNode1(); - if (n1.getRow() == Integer.MIN_VALUE) { - continue; - } - final ANode n2 = link.getNode2(); - if (n2.getRow() == Integer.MIN_VALUE) { - n2.setRow(n1.getRow() + 1); - } else if (n2.getRow() < n1.getRow() + 1) { - n2.setRow(n1.getRow() + 1); - } - } - } - - private void oneStep2() { - for (ALink link : links) { - final ANode n1 = link.getNode1(); - final ANode n2 = link.getNode2(); - if (n1.getRow() == Integer.MIN_VALUE && n2.getRow() != Integer.MIN_VALUE) { - if (n2.getRow() == 0) { - allDown(); - } - final int row = n2.getRow() - 1; - if (row == -1) { - throw new UnsupportedOperationException(); - } - n1.setRow(row); - } - } - } - - private void allDown() { - for (ANodeImpl n : nodes.values()) { - if (n.getRow() != Integer.MIN_VALUE) { - n.setRow(n.getRow() + 1); - } - } - - } - -} diff --git a/src/net/sourceforge/plantuml/graph/Zoda2.java b/src/net/sourceforge/plantuml/graph/Zoda2.java deleted file mode 100644 index d02fef7..0000000 --- a/src/net/sourceforge/plantuml/graph/Zoda2.java +++ /dev/null @@ -1,126 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.graph; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashSet; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -public class Zoda2 { - - private final Map<ANode, Heap> heaps = new LinkedHashMap<ANode, Heap>(); - - public ANode getNode(String code) { - for (ANode n : heaps.keySet()) { - if (n.getCode().equals(code)) { - return n; - } - } - return null; - } - - public ANode createAloneNode(String code) { - if (getNode(code) != null) { - throw new IllegalArgumentException(); - } - final Heap h = new Heap(); - final ANode n = h.addNode(code); - heaps.put(n, h); - return n; - } - - public List<? extends ANode> getNodes() { - return Collections.unmodifiableList(new ArrayList<ANode>(heaps.keySet())); - } - - public Set<Heap> getHeaps() { - return new HashSet<Heap>(heaps.values()); - } - - public void addLink(String link, int diffHeight, Object userData) { - final LinkString l; - try { - l = new LinkString(link); - } catch (IllegalArgumentException e) { - e.printStackTrace(); - return; - } - final ANode n1 = getNode(l.getNode1()); - final ANode n2 = getNode(l.getNode2()); - final Heap h1 = n1 == null ? null : heaps.get(n1); - final Heap h2 = n2 == null ? null : heaps.get(n2); - assert h1 == null || h1.isEmpty() == false; - assert h2 == null || h2.isEmpty() == false; - if (h1 == null && h2 == null) { - final Heap h = new Heap(); - h.addLink(link, diffHeight, userData); - recordHeap(h); - } else if (h1 == h2) { - assert h1 != null && h2 != null; - h1.addLink(link, diffHeight, userData); - } else if (h1 == null) { - h2.addLink(link, diffHeight, userData); - recordHeap(h2); - } else if (h2 == null) { - h1.addLink(link, diffHeight, userData); - recordHeap(h1); - } else { - assert h1 != null && h2 != null; - assert h1.getNodes().contains(n1); - h1.importing(n1, n2, h2, diffHeight, userData); - recordHeap(h1); - assert heapMerged(h1, h2); - } - } - - private boolean heapMerged(final Heap destination, final Heap source) { - for (ANode n : source.getNodes()) { - assert heaps.get(n) == destination; - } - return true; - } - - private void recordHeap(final Heap h) { - for (ANode n : h.getNodes()) { - heaps.put((ANodeImpl) n, h); - } - } - -} diff --git a/src/net/sourceforge/plantuml/graph2/CubicCurveFactory.java b/src/net/sourceforge/plantuml/graph2/CubicCurveFactory.java deleted file mode 100644 index 59cdd47..0000000 --- a/src/net/sourceforge/plantuml/graph2/CubicCurveFactory.java +++ /dev/null @@ -1,97 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.graph2; - -import java.awt.geom.CubicCurve2D; -import java.awt.geom.Point2D; -import java.awt.geom.Rectangle2D; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -public class CubicCurveFactory { - - private final Point2D.Double start; - private final Point2D.Double end; - private final RectanglesCollection forbiddenRect = new RectanglesCollection(); - private final List<MyCurve> forbiddenCurves = new ArrayList<MyCurve>(); - - public CubicCurveFactory(Point2D start, Point2D end) { - this.start = new Point2D.Double(start.getX(), start.getY()); - this.end = new Point2D.Double(end.getX(), end.getY()); - } - - public void addForbidden(Rectangle2D.Double rect) { - forbiddenRect.add(rect); - } - - public void addForbidden(MyCurve curve) { - forbiddenCurves.add(curve); - } - - public MyCurve getCubicCurve2D() { - MyCurve result = new MyCurve(new CubicCurve2D.Double(start.getX(), start.getY(), start.getX(), start.getY(), - end.getX(), end.getY(), end.getX(), end.getY())); - if (result.intersects(forbiddenRect) || result.intersects(forbiddenCurves)) { - final Set<Point2D.Double> all = new HashSet<Point2D.Double>(); - all.addAll(MagicPointsFactory.get(start, end)); - for (Rectangle2D.Double rect : forbiddenRect) { - all.addAll(MagicPointsFactory.get(rect)); - } -// Log.println("s1 " + all.size()); -// final long t1 = System.currentTimeMillis(); - double min = Double.MAX_VALUE; - for (Point2D.Double p1 : all) { - for (Point2D.Double p2 : all) { - final MyCurve me = new MyCurve(new CubicCurve2D.Double(start.getX(), start.getY(), p1.getX(), p1 - .getY(), p2.getX(), p2.getY(), end.getX(), end.getY())); - if (me.getLenght() < min && me.intersects(forbiddenRect) == false - && me.intersects(forbiddenCurves) == false) { - result = me; - min = me.getLenght(); - } - } - } -// final long t2 = System.currentTimeMillis() - t1; -// Log.println("s2 = " + t2); -// Log.println("TPS1 = " + RectanglesCollection.TPS1); -// Log.println("TPS2 = " + RectanglesCollection.TPS2); - } - return result; - } - -} diff --git a/src/net/sourceforge/plantuml/graph2/Dijkstra.java b/src/net/sourceforge/plantuml/graph2/Dijkstra.java deleted file mode 100644 index d9f0430..0000000 --- a/src/net/sourceforge/plantuml/graph2/Dijkstra.java +++ /dev/null @@ -1,156 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.graph2; - -/* - * Copyright (c) 2009 the authors listed at the following URL, and/or the - * authors of referenced articles or incorporated external code: - * http://en.literateprograms.org/Dijkstra's_algorithm_(Java)?action=history&offset=20081113161332 - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * Retrieved from: - * http://en.literateprograms.org/Dijkstra's_algorithm_(Java)?oldid=15444 - */ - -// http://www.google.fr/search?hl=fr&source=hp&q=A+star+java&btnG=Recherche+Google&meta=&aq=f&oq= -// http://www.edenwaith.com/products/pige/tutorials/a-star.php -import java.util.ArrayList; -import java.util.List; -import java.util.PriorityQueue; - -public class Dijkstra { - - static class Vertex implements Comparable<Vertex> { - private final Object data; - private final List<Edge> adjacencies = new ArrayList<Edge>(); - private double minDistance = Double.POSITIVE_INFINITY; - private Vertex previous; - - Vertex(Object data) { - this.data = data; - } - - public void addAdjacencies(Vertex target, double dist) { - if (target == null) { - throw new IllegalArgumentException(); - } - adjacencies.add(new Edge(target, dist)); - } - - public String toString() { - return "[ " + data.toString() + " (" + minDistance + ") ] "; - } - - public int compareTo(Vertex other) { - return Double.compare(minDistance, other.minDistance); - } - - public final Object getData() { - return data; - } - - } - - static class Edge { - private final Vertex target; - private final double weight; - - Edge(Vertex argTarget, double argWeight) { - target = argTarget; - weight = argWeight; - } - } - - private final List<Vertex> vertices = new ArrayList<Vertex>(); - - public Vertex addVertex(Object data) { - final Vertex v = new Vertex(data); - vertices.add(v); - return v; - } - - private void computePaths(Vertex source) { - source.minDistance = 0.; - final PriorityQueue<Vertex> vertexQueue = new PriorityQueue<Vertex>(); - vertexQueue.add(source); - - while (vertexQueue.isEmpty() == false) { - final Vertex u = vertexQueue.poll(); - - // Visit each edge exiting u - for (Edge e : u.adjacencies) { - final Vertex v = e.target; - final double weight = e.weight; - final double distanceThroughU = u.minDistance + weight; - if (distanceThroughU < v.minDistance) { - vertexQueue.remove(v); - - v.minDistance = distanceThroughU; - v.previous = u; - vertexQueue.add(v); - } - } - } - } - - public List<Vertex> getShortestPathTo(Vertex source, Vertex target) { - computePaths(source); - final List<Vertex> path = new ArrayList<Vertex>(); - for (Vertex vertex = target; vertex != null; vertex = vertex.previous) { - path.add(0, vertex); - } - - return path; - } - -} diff --git a/src/net/sourceforge/plantuml/graph2/IInflationTransform.java b/src/net/sourceforge/plantuml/graph2/IInflationTransform.java deleted file mode 100644 index c747af3..0000000 --- a/src/net/sourceforge/plantuml/graph2/IInflationTransform.java +++ /dev/null @@ -1,57 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.graph2; - -import java.awt.geom.Line2D; -import java.awt.geom.Point2D; -import java.util.Collection; -import java.util.List; - -public interface IInflationTransform { - - void addInflationX(double xpos, double inflation); - - void addInflationY(double ypos, double inflation); - - double getTotalInflationX(); - - double getTotalInflationY(); - - Point2D inflatePoint2D(Point2D point); - - List<Line2D.Double> inflate(Collection<Line2D.Double> segments); - -}
\ No newline at end of file diff --git a/src/net/sourceforge/plantuml/graph2/IdentityInflationTransform.java b/src/net/sourceforge/plantuml/graph2/IdentityInflationTransform.java deleted file mode 100644 index baecf7c..0000000 --- a/src/net/sourceforge/plantuml/graph2/IdentityInflationTransform.java +++ /dev/null @@ -1,70 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.graph2; - -import java.awt.geom.Line2D; -import java.awt.geom.Point2D; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -public class IdentityInflationTransform implements IInflationTransform { - - public void addInflationX(double xpos, double inflation) { - - } - - public void addInflationY(double ypos, double inflation) { - - } - - public double getTotalInflationX() { - return 0; - } - - public double getTotalInflationY() { - return 0; - } - - public Point2D inflatePoint2D(Point2D point) { - return point; - } - - public List<Line2D.Double> inflate(Collection<Line2D.Double> segments) { - return new ArrayList<Line2D.Double>(segments); - } - -}
\ No newline at end of file diff --git a/src/net/sourceforge/plantuml/graph2/InflateData2.java b/src/net/sourceforge/plantuml/graph2/InflateData2.java deleted file mode 100644 index c1b6846..0000000 --- a/src/net/sourceforge/plantuml/graph2/InflateData2.java +++ /dev/null @@ -1,126 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.graph2; - -public class InflateData2 implements Comparable<InflateData2> { - - private final double pos; - private final double inflation; - - public InflateData2(double pos, double inflation) { - this.pos = pos; - this.inflation = inflation; - } - - public final double getPos() { - return pos; - } - - public final double getInflation() { - return inflation; - } - - public int compareTo(InflateData2 other) { - return -Double.compare(this.pos, other.pos); - } - - // public Point2D inflateX(Point2D pt) { - // if (pt.getX() < pos) { - // return pt; - // } - // if (pt.getX() == pos) { - // return GeomUtils.translate(pt, inflation / 2, 0); - // } - // return GeomUtils.translate(pt, inflation, 0); - // } - // - public double inflateAt(double v) { - if (v == pos) { - return inflation / 2; - } - - if (v < pos) { - return 0; - } - return inflation; - } - - // public Line2D.Double inflateXAlpha(Line2D.Double line) { - // - // if (GeomUtils.isHorizontal(line)) { - // return new Line2D.Double(inflateX(line.getP1()), inflateX(line.getP2())); - // } - // if (line.x1 == pos && line.x2 == pos) { - // return new Line2D.Double(GeomUtils.translate(line.getP1(), inflation / 2, - // 0), GeomUtils.translate(line - // .getP2(), inflation / 2, 0)); - // } - // if (line.x1 <= pos && line.x2 <= pos) { - // return line; - // } - // if (line.x1 >= pos && line.x2 >= pos) { - // return new Line2D.Double(GeomUtils.translate(line.getP1(), inflation, 0), - // GeomUtils.translate(line.getP2(), - // inflation, 0)); - // } - // throw new UnsupportedOperationException(); - // } - // - // public Line2D.Double inflateYAlpha(Line2D.Double line) { - // if (GeomUtils.isVertical(line)) { - // return new Line2D.Double(inflateY(line.getP1()), inflateY(line.getP2())); - // } - // if (line.y1 == pos && line.y2 == pos) { - // return new Line2D.Double(GeomUtils.translate(line.getP1(), 0, inflation / - // 2), GeomUtils.translate(line - // .getP2(), 0, inflation / 2)); - // } - // if (line.y1 <= pos && line.y2 <= pos) { - // return line; - // } - // if (line.y1 >= pos && line.y2 >= pos) { - // return new Line2D.Double(GeomUtils.translate(line.getP1(), 0, inflation), - // GeomUtils.translate(line.getP2(), - // 0, inflation)); - // } - // throw new UnsupportedOperationException(); - // } - - @Override - public String toString() { - return "" + pos + " (" + inflation + ")"; - } -} diff --git a/src/net/sourceforge/plantuml/graph2/InflationTransform2.java b/src/net/sourceforge/plantuml/graph2/InflationTransform2.java deleted file mode 100644 index 97bda85..0000000 --- a/src/net/sourceforge/plantuml/graph2/InflationTransform2.java +++ /dev/null @@ -1,240 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.graph2; - -import java.awt.geom.AffineTransform; -import java.awt.geom.Line2D; -import java.awt.geom.Point2D; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; -import java.util.ListIterator; -import java.util.SortedSet; -import java.util.TreeSet; - -class Point2DComparatorDistance implements Comparator<Point2D> { - - private final Point2D center; - - public Point2DComparatorDistance(Point2D center) { - this.center = center; - } - - public int compare(Point2D p1, Point2D p2) { - return Double.compare(p1.distance(center), p2.distance(center)); - } - -} - -public class InflationTransform2 implements IInflationTransform { - - private final List<InflateData2> inflateX = new ArrayList<InflateData2>(); - private final List<InflateData2> inflateY = new ArrayList<InflateData2>(); - - public void addInflationX(double xpos, double inflation) { - add(inflateX, xpos, inflation); - } - - @Override - public String toString() { - return "inflateX = " + inflateX + " inflateY = " + inflateY; - } - - public void addInflationY(double ypos, double inflation) { - add(inflateY, ypos, inflation); - } - - public double getTotalInflationX() { - return sumInflation(inflateX); - } - - public double getTotalInflationY() { - return sumInflation(inflateY); - } - - static private double sumInflation(List<InflateData2> list) { - double result = 0; - for (InflateData2 data : list) { - result += data.getInflation(); - } - return result; - } - - static private void add(List<InflateData2> list, double ypos, double inflation) { - for (final ListIterator<InflateData2> it = list.listIterator(); it.hasNext();) { - final InflateData2 cur = it.next(); - if (cur.getPos() == ypos) { - it.set(new InflateData2(ypos, Math.max(inflation, cur.getInflation()))); - return; - } - } - list.add(new InflateData2(ypos, inflation)); - Collections.sort(list); - } - - Collection<Point2D.Double> cutPoints(Line2D.Double original) { - - final SortedSet<Point2D.Double> result = new TreeSet<Point2D.Double>(new Point2DComparatorDistance(original - .getP1())); - - if (GeomUtils.isHorizontal(original) == false) { - for (InflateData2 x : inflateX) { - final Line2D.Double vertical = new Line2D.Double(x.getPos(), GeomUtils.getMinY(original), x.getPos(), - GeomUtils.getMaxY(original)); - final Point2D.Double inter = GeomUtils.getSegIntersection(original, vertical); - if (inter != null) { - result.add(inter); - } - } - } - if (GeomUtils.isVertical(original) == false) { - for (InflateData2 y : inflateY) { - final Line2D.Double horizontal = new Line2D.Double(GeomUtils.getMinX(original), y.getPos(), GeomUtils - .getMaxX(original), y.getPos()); - final Point2D.Double inter = GeomUtils.getSegIntersection(original, horizontal); - if (inter != null) { - result.add(inter); - } - } - } - return result; - } - - Collection<Line2D.Double> cutSegments(Line2D.Double original) { - final List<Line2D.Double> result = new ArrayList<Line2D.Double>(); - Point2D.Double cur = (Point2D.Double) original.getP1(); - final Collection<Point2D.Double> cutPoints = cutPoints(original); - for (Point2D.Double inter : cutPoints) { - if (cur.equals(inter)) { - continue; - } - result.add(new Line2D.Double(cur, inter)); - cur = inter; - } - if (cur.equals(original.getP2()) == false) { - result.add(new Line2D.Double(cur, original.getP2())); - } - return result; - } - - Collection<Line2D.Double> cutSegments(Collection<Line2D.Double> segments) { - final List<Line2D.Double> result = new ArrayList<Line2D.Double>(); - for (Line2D.Double seg : segments) { - result.addAll(cutSegments(seg)); - } - return result; - } - - // private Line2D.Double inflateSegment(Line2D.Double seg) { - // // if (isOnGrid(seg.getP1()) && isOnGrid(seg.getP2())) { - // // return new Line2D.Double(inflatePoint2D(seg.getP1()), - // inflatePoint2D(seg.getP2())); - // // } - // // for (InflateData2 x : inflateX) { - // // seg = x.inflateXAlpha(seg); - // // } - // // for (InflateData2 y : inflateY) { - // // seg = y.inflateYAlpha(seg); - // // } - // // return seg; - // return new Line2D.Double(inflatePoint2D(seg.getP1()), - // inflatePoint2D(seg.getP2())); - // } - - // private boolean isOnGrid(Point2D point) { - // boolean onGrid = false; - // for (InflateData2 x : inflateX) { - // if (point.getX() == x.getPos()) { - // onGrid = true; - // } - // } - // if (onGrid == false) { - // return false; - // } - // for (InflateData2 y : inflateY) { - // if (point.getY() == y.getPos()) { - // return true; - // } - // } - // return false; - // - // } - - public Point2D inflatePoint2D(Point2D point) { - return getAffineTransformAt(point).transform(point, null); - } - - AffineTransform getAffineTransformAt(Point2D point) { - double deltaX = 0; - for (InflateData2 x : inflateX) { - deltaX += x.inflateAt(point.getX()); - } - double deltaY = 0; - for (InflateData2 y : inflateY) { - deltaY += y.inflateAt(point.getY()); - } - return AffineTransform.getTranslateInstance(deltaX, deltaY); - } - - List<Line2D.Double> inflateSegmentCollection(Collection<Line2D.Double> segments) { - final List<Line2D.Double> result = new ArrayList<Line2D.Double>(); - for (Line2D.Double seg : segments) { - final AffineTransform at = getAffineTransformAt(new Point2D.Double((seg.x1 + seg.x2) / 2, - (seg.y1 + seg.y2) / 2)); - result.add(new Line2D.Double(at.transform(seg.getP1(), null), at.transform(seg.getP2(), null))); - } - return result; - } - - public List<Line2D.Double> inflate(Collection<Line2D.Double> segments) { - final Collection<Line2D.Double> cutSegments = cutSegments(segments); - Line2D.Double last = null; - final List<Line2D.Double> inflated = inflateSegmentCollection(cutSegments); - final List<Line2D.Double> result = new ArrayList<Line2D.Double>(); - for (Line2D.Double seg : inflated) { - if (last != null && last.getP2().equals(seg.getP1()) == false) { - result.add(new Line2D.Double(last.getP2(), seg.getP1())); - } - result.add(seg); - last = seg; - - } - return result; - } - -} diff --git a/src/net/sourceforge/plantuml/graph2/MagicPointsFactory.java b/src/net/sourceforge/plantuml/graph2/MagicPointsFactory.java deleted file mode 100644 index eb667e1..0000000 --- a/src/net/sourceforge/plantuml/graph2/MagicPointsFactory.java +++ /dev/null @@ -1,75 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.graph2; - -import java.awt.geom.Point2D; -import java.awt.geom.Rectangle2D; -import java.util.ArrayList; -import java.util.List; - -public class MagicPointsFactory { - - private MagicPointsFactory() { - - } - - public static List<Point2D.Double> get(Rectangle2D.Double rect) { - final List<Point2D.Double> result = new ArrayList<Point2D.Double>(); - result.add(new Point2D.Double(rect.x - rect.width, rect.y - rect.height)); - result.add(new Point2D.Double(rect.x, rect.y - rect.height)); - result.add(new Point2D.Double(rect.x + rect.width, rect.y - rect.height)); - result.add(new Point2D.Double(rect.x + 2 * rect.width, rect.y - rect.height)); - - result.add(new Point2D.Double(rect.x - rect.width, rect.y)); - result.add(new Point2D.Double(rect.x + 2 * rect.width, rect.y)); - - result.add(new Point2D.Double(rect.x - rect.width, rect.y + rect.height)); - result.add(new Point2D.Double(rect.x + 2 * rect.width, rect.y + rect.height)); - - result.add(new Point2D.Double(rect.x - rect.width, rect.y + 2 * rect.height)); - result.add(new Point2D.Double(rect.x, rect.y + 2 * rect.height)); - result.add(new Point2D.Double(rect.x + rect.width, rect.y + 2 * rect.height)); - result.add(new Point2D.Double(rect.x + 2 * rect.width, rect.y + 2 * rect.height)); - return result; - } - - public static List<Point2D.Double> get(Point2D.Double p1, Point2D.Double p2) { - final List<Point2D.Double> result = new ArrayList<Point2D.Double>(); - result.add(new Point2D.Double(p1.x, p2.y)); - result.add(new Point2D.Double(p2.x, p1.y)); - return result; - } -} diff --git a/src/net/sourceforge/plantuml/graph2/MagicPointsFactory2.java b/src/net/sourceforge/plantuml/graph2/MagicPointsFactory2.java deleted file mode 100644 index 8b897cc..0000000 --- a/src/net/sourceforge/plantuml/graph2/MagicPointsFactory2.java +++ /dev/null @@ -1,73 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.graph2; - -import java.awt.geom.AffineTransform; -import java.awt.geom.Point2D; -import java.util.ArrayList; -import java.util.List; - -public class MagicPointsFactory2 { - - private final Point2D.Double p1; - private final Point2D.Double p2; - - private final List<Point2D.Double> result = new ArrayList<Point2D.Double>(); - - public MagicPointsFactory2(Point2D.Double p1, Point2D.Double p2) { - this.p1 = p1; - this.p2 = p2; - final double dx = p2.x - p1.x; - final double dy = p2.y - p1.y; - - final int interv = 5; - final int intervAngle = 10; - final double theta = Math.PI * 2 / intervAngle; - for (int a = 0; a < 10; a++) { - final AffineTransform at = AffineTransform.getRotateInstance(theta * a, p1.x, p1.y); - for (int i = 0; i < interv * 2; i++) { - final Point2D.Double p = new Point2D.Double(p1.x + dx * i / interv, p1.y + dy * i / interv); - result.add((Point2D.Double) at.transform(p, null)); - } - } - - } - - public List<Point2D.Double> get() { - return result; - } - -} diff --git a/src/net/sourceforge/plantuml/graph2/Measurer.java b/src/net/sourceforge/plantuml/graph2/Measurer.java deleted file mode 100644 index 1addeed..0000000 --- a/src/net/sourceforge/plantuml/graph2/Measurer.java +++ /dev/null @@ -1,40 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.graph2; - -public interface Measurer<V> { - int getMeasure(V data); -} diff --git a/src/net/sourceforge/plantuml/graph2/MyCurve.java b/src/net/sourceforge/plantuml/graph2/MyCurve.java deleted file mode 100644 index 527a04a..0000000 --- a/src/net/sourceforge/plantuml/graph2/MyCurve.java +++ /dev/null @@ -1,173 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.graph2; - -import java.awt.BasicStroke; -import java.awt.Color; -import java.awt.Graphics2D; -import java.awt.geom.CubicCurve2D; -import java.awt.geom.Line2D; -import java.awt.geom.Point2D; -import java.awt.geom.Rectangle2D; -import java.util.ArrayList; -import java.util.List; - -public class MyCurve { - - private final CubicCurve2D.Double curve; - private final List<Line2D.Double> lines = new ArrayList<Line2D.Double>(); - private final List<Line2D.Double> linesForInters = new ArrayList<Line2D.Double>(); - private Color color = Color.GREEN; - private double lenght = 0; - - public MyCurve(CubicCurve2D.Double curve) { - this.curve = curve; - addCurve(curve); - if (lenght <= 0) { - throw new IllegalStateException(); - } - for (Line2D.Double line : lines) { - linesForInters.add(change(line, curve.getP1(), curve.getP2())); - } - } - - private Line2D.Double change(Line2D.Double line, Point2D p1, Point2D p2) { - if (line.getP1().equals(p1) == false && line.getP2().equals(p2) == false) { - return line; - } - final double dx = line.x2 - line.x1; - final double dy = line.y2 - line.y1; - if (line.getP1().equals(p1)) { - p1 = new Point2D.Double(line.x1 + dx / 10, line.y1 + dy / 10); - } else { - p1 = line.getP1(); - } - if (line.getP2().equals(p2)) { - p2 = new Point2D.Double(line.x2 - dx / 10, line.y2 - dy / 10); - } else { - p2 = line.getP2(); - } - return new Line2D.Double(p1, p2); - } - - public final double getLenght() { - return lenght; - } - - private void addCurve(CubicCurve2D.Double peace) { - final Rectangle2D bounds = peace.getBounds2D(); - final double flat = peace.getFlatness(); - if (flat < 10) { - lines.add(new Line2D.Double(peace.getP1(), peace.getP2())); - lenght += Math.sqrt(bounds.getWidth() * bounds.getWidth() + bounds.getHeight() * bounds.getHeight()); - return; - } - final CubicCurve2D.Double left = new CubicCurve2D.Double(); - final CubicCurve2D.Double right = new CubicCurve2D.Double(); - peace.subdivide(left, right); - addCurve(left); - addCurve(right); - } - - public void drawDebug(Graphics2D g2d) { - for (Line2D r : linesForInters) { - g2d.setColor(color); - g2d.draw(r); - } - g2d.setColor(Color.BLACK); - // g2d.draw(curve); - } - - public void draw(Graphics2D g2d) { - g2d.setStroke(new BasicStroke((float) 1.5)); - g2d.draw(curve); - g2d.setStroke(new BasicStroke()); - } - - public final void setColor(Color color) { - this.color = color; - } - - public boolean intersects(List<MyCurve> others) { - for (MyCurve other : others) { - if (this.intersects(other)) { - return true; - } - } - return false; - } - - private boolean intersects(MyCurve other) { - for (Line2D.Double l1 : this.linesForInters) { - for (Line2D.Double l2 : other.linesForInters) { - if (l1.intersectsLine(l2)) { - return true; - } - } - } - return false; - } - - public boolean intersects(RectanglesCollection forbidden) { - for (Rectangle2D.Double r : forbidden) { - for (Line2D.Double line : lines) { - if (r.intersectsLine(line)) { - return true; - } - } - } - return false; - } - // public static long TPS6; - // - // public RectanglesCollection unrecoveredBy(RectanglesCollection allFrames) - // { - // final long start = System.currentTimeMillis(); - // try { - // final RectanglesCollection result = new RectanglesCollection(); - // for (Rectangle2D.Double r : areas) { - // if (allFrames.intersect(new RectanglesCollection(r)) == false) { - // result.add(r); - // } - // } - // return result; - // } finally { - // TPS6 += System.currentTimeMillis() - start; - // } - // } - // - -} diff --git a/src/net/sourceforge/plantuml/graph2/Neighborhood2.java b/src/net/sourceforge/plantuml/graph2/Neighborhood2.java deleted file mode 100644 index 51cb50d..0000000 --- a/src/net/sourceforge/plantuml/graph2/Neighborhood2.java +++ /dev/null @@ -1,190 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.graph2; - -import java.awt.geom.Line2D; -import java.awt.geom.Point2D; - -import net.sourceforge.plantuml.geom.Orientation; - -public class Neighborhood2 { - - final private double angle1; - final private double angle2; - final private Point2D.Double center; - - public Neighborhood2(Point2D.Double center) { - this(center, 0, 0); - } - - public boolean is360() { - return angle1 == angle2; - } - - public Neighborhood2(Point2D.Double center, double angle1, double angle2) { - this.center = center; - this.angle1 = angle1; - this.angle2 = angle2; - } - - @Override - public boolean equals(Object obj) { - final Neighborhood2 other = (Neighborhood2) obj; - return angle1 == other.angle1 && angle2 == other.angle2 && center.equals(other.center); - } - - @Override - public int hashCode() { - return center.hashCode() * 17 + new Point2D.Double(angle1, angle2).hashCode(); - } - - @Override - public String toString() { - final int a1 = (int) (angle1 * 180 / Math.PI); - final int a2 = (int) (angle2 * 180 / Math.PI); - return center + " " + a1 + " " + a2; - } - - public final Point2D.Double getCenter() { - return center; - } - - // private double getMiddle() { - // if (is360()) { - // return angle1 + 2 * Math.PI / 3; - // } - // double result = (angle1 + angle2) / 2; - // if (angle2 < angle1) { - // result += Math.PI; - // } - // return result; - // } - // - public Point2D.Double getPointInNeighborhood(double dist, Point2D p1, Point2D p2) { - if (p1 == null || p2 == null) { - throw new IllegalArgumentException(); - } - if (dist <= 0) { - throw new IllegalArgumentException(); - } - final double v1 = Singularity2.convertAngle(Singularity2.getAngle(new Line2D.Double(center, p1)) - angle1); - final double v2 = Singularity2.convertAngle(Singularity2.getAngle(new Line2D.Double(center, p2)) - angle1); - if (v1 < 0) { - throw new IllegalStateException(); - } - if (v2 < 0) { - throw new IllegalStateException(); - } - final double middle = (v1 + v2) / 2 + angle1; - return new Point2D.Double(center.x + dist * Math.cos(middle), center.y + dist * Math.sin(middle)); - } - - public boolean isInAngleStrict(double angle) { - if (angle < 0) { - throw new IllegalArgumentException(); - } - if (angle2 > angle1) { - return angle > angle1 && angle < angle2; - } - return angle > angle1 || angle < angle2; - } - - public boolean isInAngleLarge(double angle) { - if (angle < 0) { - throw new IllegalArgumentException(); - } - if (angle2 > angle1) { - return angle >= angle1 && angle <= angle2; - } - return angle >= angle1 || angle <= angle2; - } - - public boolean isAngleLimit(double angle) { - return angle == angle1 || angle == angle2; - } - - public Orientation getOrientationFrom(double angle) { - if (angle1 == angle2) { - throw new IllegalStateException(); - } - if (angle != angle1 && angle != angle2) { - throw new IllegalArgumentException("this=" + this + " angle=" + (int) (angle * 180 / Math.PI)); - } - assert angle == angle1 || angle == angle2; - - if (angle == angle1) { - return Orientation.MATH; - } - return Orientation.CLOCK; - } - - public boolean isConnectable(Neighborhood2 other) { - assert isConnectableInternal(other) == other.isConnectableInternal(this); - return isConnectableInternal(other); - - } - - private boolean isConnectableInternal(Neighborhood2 other) { - if (getCenter().equals(other.getCenter())) { - throw new IllegalArgumentException("Same center"); - } - final Line2D.Double seg1 = new Line2D.Double(getCenter(), other.getCenter()); - - final double angle1 = Singularity2.convertAngle(Singularity2.getAngle(seg1)); - final double angle2 = Singularity2.convertAngle(Singularity2.getOppositeAngle(seg1)); - assert angle2 == Singularity2.convertAngle(Singularity2.getAngle(new Line2D.Double(other.getCenter(), - getCenter()))); - if (isInAngleStrict(angle1) && other.isInAngleStrict(angle2)) { - return true; - } - if (isInAngleStrict(angle1) && other.isInAngleLarge(angle2)) { - return true; - } - if (isInAngleLarge(angle1) && other.isInAngleStrict(angle2)) { - return true; - } - if (isAngleLimit(angle1) && other.isAngleLimit(angle2)) { - if (is360() || other.is360()) { - return true; - } - final Orientation o1 = getOrientationFrom(angle1); - final Orientation o2 = other.getOrientationFrom(angle2); - return o1 != o2; - } - return false; - } - -} diff --git a/src/net/sourceforge/plantuml/graph2/Plan.java b/src/net/sourceforge/plantuml/graph2/Plan.java deleted file mode 100644 index 459f7ae..0000000 --- a/src/net/sourceforge/plantuml/graph2/Plan.java +++ /dev/null @@ -1,255 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.graph2; - -import java.awt.geom.Line2D; -import java.awt.geom.Point2D; -import java.util.ArrayList; -import java.util.Collection; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - -import net.sourceforge.plantuml.Log; -import net.sourceforge.plantuml.graph2.Dijkstra.Vertex; - -public class Plan { - - private final Map<Point2D.Double, Singularity2> points = new LinkedHashMap<Point2D.Double, Singularity2>(); - private final Collection<Line2D.Double> lines = new ArrayList<Line2D.Double>(); - - public void addPoint2D(Point2D.Double point) { - if (points.containsKey(point)) { - throw new IllegalArgumentException(); - } - points.put(point, new Singularity2(point)); - } - - public void debugPrint() { - Log.println("PLAN PRINT"); - for (Singularity2 s : points.values()) { - Log.println("s="+s); - } - for (Line2D.Double l : lines) { - Log.println(GeomUtils.toString(l)); - } - } - - public void createLink(Point2D p1, Point2D p2) { - final Singularity2 s1 = points.get(p1); - final Singularity2 s2 = points.get(p2); - if (s1 == null || s2 == null) { - throw new IllegalArgumentException(); - } - final Line2D.Double line = new Line2D.Double(p1, p2); - - s1.addLineSegment(line); - s2.addLineSegment(line); - lines.add(line); - } - - Singularity2 getSingularity(Point2D pt) { - final Singularity2 result = points.get(pt); - if (result == null) { - throw new IllegalArgumentException(); - } - return result; - } - - List<Neighborhood2> getShortestPathToInternal(Point2D start, Point2D end) { - final Dijkstra dijkstra = new Dijkstra(); - if (points.containsKey(start) == false || points.containsKey(end) == false) { - throw new IllegalArgumentException(); - } - final Vertex vStart = dijkstra.addVertex(start); - final Vertex vEnd = dijkstra.addVertex(end); - final Map<Neighborhood2, Vertex> vertexes = new LinkedHashMap<Neighborhood2, Vertex>(); - for (Singularity2 s : points.values()) { - for (Neighborhood2 n : s.getNeighborhoods()) { - final Vertex v = dijkstra.addVertex(n); - vertexes.put(n, v); - if (n.getCenter().equals(start)) { - vStart.addAdjacencies(v, 0.01); - } - if (n.getCenter().equals(end)) { - v.addAdjacencies(vEnd, 0.01); - } - } - } - - for (Vertex v1 : vertexes.values()) { - for (Vertex v2 : vertexes.values()) { - final Neighborhood2 n1 = (Neighborhood2) v1.getData(); - final Neighborhood2 n2 = (Neighborhood2) v2.getData(); - if (n1.getCenter().equals(n2.getCenter())) { - continue; - } - final Line2D.Double line = new Line2D.Double(n1.getCenter(), n2.getCenter()); - if (isStrictCrossing(line)) { - continue; - } - if (n1.isConnectable(n2) == false) { - continue; - } - final double dist = n1.getCenter().distance(n2.getCenter()); - v1.addAdjacencies(v2, dist); - v2.addAdjacencies(v1, dist); - // Log.println("=(" + n1 + ") (" + n2 + ") " + dist); - } - } - - final List<Vertex> list = dijkstra.getShortestPathTo(vStart, vEnd); - if (list.size() < 2) { - throw new IllegalStateException("list=" + list); - } - final List<Neighborhood2> result = new ArrayList<Neighborhood2>(); - for (Vertex v : list.subList(1, list.size() - 1)) { - result.add((Neighborhood2) v.getData()); - } - return result; - } - - public List<Point2D.Double> getIntermediatePoints(Point2D start, Point2D end) { - // Log.println("start=" + start + " end=" + end); - final List<Point2D.Double> result = new ArrayList<Point2D.Double>(); - final List<Neighborhood2> list = getShortestPathToInternal(start, end); - // Log.println("Neighborhood2 = " + list); - for (int i = 1; i < list.size() - 1; i++) { - final Neighborhood2 n = list.get(i); - final Point2D.Double before = list.get(i - 1).getCenter(); - final Point2D.Double after = list.get(i + 1).getCenter(); - // Log.println("before="+before); - // Log.println("after="+after); - // Log.println("n.getCenter()="+n.getCenter()); - // Log.println("getMindist(n.getCenter())="+getMindist(n.getCenter())); - final Point2D.Double pointInNeighborhood = n.getPointInNeighborhood(getMindist(n.getCenter()) / 2, before, - after); - // Log.println("pointInNeighborhood="+pointInNeighborhood); - result.add(pointInNeighborhood); - } - return result; - - } - - private boolean isStrictCrossing(Line2D.Double line) { - for (Line2D.Double l : lines) { - if (intersectsLineStrict(l, line)) { - return true; - } - } - return false; - } - - public static boolean intersectsLineStrict(Line2D.Double l1, Line2D.Double l2) { - assert intersectsLineStrictInternal(l1, l2) == intersectsLineStrictInternal(l2, l1); - assert intersectsLineStrictInternal(l1, l2) == intersectsLineStrictInternal(inverse(l1), l2); - assert intersectsLineStrictInternal(l1, l2) == intersectsLineStrictInternal(l1, inverse(l2)); - assert intersectsLineStrictInternal(l1, l2) == intersectsLineStrictInternal(inverse(l1), inverse(l2)); - return intersectsLineStrictInternal(l1, l2); - } - - private static Line2D.Double inverse(Line2D.Double line) { - return new Line2D.Double(line.getP2(), line.getP1()); - } - - private static boolean intersectsLineStrictInternal(Line2D.Double l1, Line2D.Double l2) { - if (l1.intersectsLine(l2) == false) { - return false; - } - assert l1.intersectsLine(l2); - - Point2D.Double l1a = (Point2D.Double) l1.getP1(); - Point2D.Double l1b = (Point2D.Double) l1.getP2(); - Point2D.Double l2a = (Point2D.Double) l2.getP1(); - Point2D.Double l2b = (Point2D.Double) l2.getP2(); - - if (l1a.equals(l2a) == false && l1a.equals(l2b) == false && l1b.equals(l2a) == false - && l1b.equals(l2b) == false) { - return true; - } - - if (l1a.equals(l2b)) { - final Point2D.Double tmp = l2a; - l2a = l2b; - l2b = tmp; - } else if (l2a.equals(l1b)) { - final Point2D.Double tmp = l1a; - l1a = l1b; - l1b = tmp; - } else if (l1b.equals(l2b)) { - Point2D.Double tmp = l2a; - l2a = l2b; - l2b = tmp; - tmp = l1a; - l1a = l1b; - l1b = tmp; - } - - assert l1a.equals(l2a); - - return false; - - } - - final double getMindist(Point2D.Double pt) { - double result = Double.MAX_VALUE; - for (Point2D p : points.keySet()) { - if (pt.equals(p)) { - continue; - } - final double v = p.distance(pt); - if (v < 1E-4) { - throw new IllegalStateException(); - } - result = Math.min(result, v); - } - for (Line2D line : lines) { - if (line.getP1().equals(pt) || line.getP2().equals(pt)) { - continue; - } - final double v = line.ptSegDist(pt); - if (result < 1E-4) { - throw new IllegalStateException("pt=" + pt + " line=" + GeomUtils.toString(line)); - } - result = Math.min(result, v); - } - if (result == 0) { - throw new IllegalStateException(); - } - // Log.println("getMindist=" + result); - return result; - } -} diff --git a/src/net/sourceforge/plantuml/graph2/Polyline2.java b/src/net/sourceforge/plantuml/graph2/Polyline2.java deleted file mode 100644 index 9123681..0000000 --- a/src/net/sourceforge/plantuml/graph2/Polyline2.java +++ /dev/null @@ -1,111 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.graph2; - -import java.awt.Color; -import java.awt.Graphics2D; -import java.awt.geom.Line2D; -import java.awt.geom.Point2D; -import java.awt.geom.QuadCurve2D; -import java.util.ArrayList; -import java.util.List; - -public class Polyline2 { - - private final List<Line2D.Double> lines = new ArrayList<Line2D.Double>(); - private Point2D lastCurrent; - private final Point2D end; - - public Polyline2(Point2D start, Point2D end) { - lastCurrent = start; - this.end = end; - } - - public void addLine(Line2D.Double newLine) { - // Log.println("# Polyline2::addLine " + - // GeomUtils.toString(newLine)); - if (lastCurrent.equals(newLine.getP1()) == false) { - lines.add(new Line2D.Double(lastCurrent, newLine.getP1())); - } - lines.add(newLine); - lastCurrent = newLine.getP2(); - } - - private boolean debug = false; - - public void draw(Graphics2D g2d) { - close(); - if (debug) { - g2d.setColor(Color.GREEN); - drawDebug(g2d); - } - g2d.setColor(Color.BLUE); - final List<Point2D.Double> centers = new ArrayList<Point2D.Double>(); - for (Line2D.Double l : lines) { - centers.add(GeomUtils.getCenter(l)); - } - g2d.draw(new Line2D.Double(lines.get(0).getP1(), centers.get(0))); - g2d.draw(new Line2D.Double(centers.get(centers.size() - 1), end)); - for (int i = 0; i < lines.size() - 1; i++) { - final Point2D c1 = centers.get(i); - final Point2D c2 = centers.get(i + 1); - final Point2D ctrl = lines.get(i).getP2(); - assert ctrl.equals(lines.get(i + 1).getP1()); - final QuadCurve2D.Double quad = new QuadCurve2D.Double(c1.getX(), c1.getY(), ctrl.getX(), ctrl.getY(), c2 - .getX(), c2.getY()); - g2d.draw(quad); - } - if (debug) { - for (Point2D.Double c : centers) { - GeomUtils.fillPoint2D(g2d, c); - } - } - } - - private void drawDebug(Graphics2D g2d) { - for (Line2D.Double l : lines) { - g2d.draw(l); - GeomUtils.fillPoint2D(g2d, l.getP1()); - GeomUtils.fillPoint2D(g2d, l.getP2()); - } - } - - private void close() { - if (lastCurrent.equals(end) == false) { - lines.add(new Line2D.Double(lastCurrent, end)); - } - } -} diff --git a/src/net/sourceforge/plantuml/graph2/RectanglesCollection.java b/src/net/sourceforge/plantuml/graph2/RectanglesCollection.java deleted file mode 100644 index c0ac2ad..0000000 --- a/src/net/sourceforge/plantuml/graph2/RectanglesCollection.java +++ /dev/null @@ -1,200 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.graph2; - -import java.awt.geom.Rectangle2D; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -public class RectanglesCollection implements Iterable<Rectangle2D.Double> { - - private final List<Rectangle2D.Double> areas = new ArrayList<Rectangle2D.Double>(); - private final SortedListImpl<Rectangle2D.Double> sortedX1; - private final SortedListImpl<Rectangle2D.Double> sortedX2; - private final SortedListImpl<Rectangle2D.Double> sortedY1; - private final SortedListImpl<Rectangle2D.Double> sortedY2; - - private Rectangle2D.Double max = null; - - public RectanglesCollection() { - sortedX1 = new SortedListImpl<Rectangle2D.Double>(new Measurer<Rectangle2D.Double>() { - public int getMeasure(Rectangle2D.Double data) { - return (int) data.x; - } - }); - sortedX2 = new SortedListImpl<Rectangle2D.Double>(new Measurer<Rectangle2D.Double>() { - public int getMeasure(Rectangle2D.Double data) { - return (int) (data.x + data.width); - } - }); - sortedY1 = new SortedListImpl<Rectangle2D.Double>(new Measurer<Rectangle2D.Double>() { - public int getMeasure(Rectangle2D.Double data) { - return (int) data.y; - } - }); - sortedY2 = new SortedListImpl<Rectangle2D.Double>(new Measurer<Rectangle2D.Double>() { - public int getMeasure(Rectangle2D.Double data) { - return (int) (data.y + data.height); - } - }); - } - - public RectanglesCollection(Rectangle2D.Double rect) { - this(); - add(rect); - } - - public double getSurf() { - if (max == null) { - return 0; - } - return max.getWidth() * max.getHeight(); - } - - public void add(Rectangle2D.Double rect) { - areas.add(rect); - // sortedX1.add(rect); - // sortedX2.add(rect); - // sortedY1.add(rect); - // sortedY2.add(rect); - if (max == null) { - max = rect; - } else { - max = (Rectangle2D.Double) max.createUnion(rect); - } - } - - public Iterator<Rectangle2D.Double> iterator() { - return areas.iterator(); - } - - public boolean intersect(RectanglesCollection other) { - if (this.size() > other.size()) { - return intersectSeveral(this, other); - } - return intersectSeveral(other, this); - } - - static private long TPS1; - static private long TPS2; - - private static boolean intersectSeveral(RectanglesCollection large, RectanglesCollection compact) { - assert large.size() >= compact.size(); - final long start = System.currentTimeMillis(); - try { - for (Rectangle2D.Double r : compact) { - if (large.intersectSimple(r)) { - return true; - } - } - return false; - } finally { - TPS2 += System.currentTimeMillis() - start; - } - } - - private boolean intersectSimple(Rectangle2D.Double rect) { - final long start = System.currentTimeMillis(); - try { - if (max == null || max.intersects(rect) == false) { - return false; - } - for (Rectangle2D.Double r : areas) { - if (rect.intersects(r)) { - return true; - } - } - return false; - } finally { - TPS1 += System.currentTimeMillis() - start; - } - } - - private boolean intersectSimpleOld(Rectangle2D.Double rect) { - final long start = System.currentTimeMillis(); - try { - if (max == null || max.intersects(rect) == false) { - return false; - } - final List<Rectangle2D.Double> lX1 = sortedX1.lesserOrEquals((int) (rect.x + rect.width)); - List<Rectangle2D.Double> lmin = lX1; - if (lX1.size() == 0) { - return false; - } - final List<Rectangle2D.Double> lX2 = sortedX2.biggerOrEquals((int) rect.x); - if (lX2.size() == 0) { - return false; - } - if (lX2.size() < lmin.size()) { - lmin = lX2; - } - final List<Rectangle2D.Double> lY1 = sortedY1.lesserOrEquals((int) (rect.y + rect.height)); - if (lY1.size() == 0) { - return false; - } - if (lY1.size() < lmin.size()) { - lmin = lY1; - } - final List<Rectangle2D.Double> lY2 = sortedY2.biggerOrEquals((int) rect.y); - if (lY2.size() == 0) { - return false; - } - if (lY2.size() < lmin.size()) { - lmin = lY2; - } - for (Rectangle2D.Double r : lmin) { - if (rect.intersects(r)) { - return true; - } - } - return false; - } finally { - TPS1 += System.currentTimeMillis() - start; - } - } - - public int size() { - return areas.size(); - } - - public void addAll(RectanglesCollection other) { - for (Rectangle2D.Double r : other.areas) { - this.add(r); - } - } - -} diff --git a/src/net/sourceforge/plantuml/graph2/Singularity2.java b/src/net/sourceforge/plantuml/graph2/Singularity2.java deleted file mode 100644 index 3edafcc..0000000 --- a/src/net/sourceforge/plantuml/graph2/Singularity2.java +++ /dev/null @@ -1,164 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.graph2; - -import java.awt.geom.Line2D; -import java.awt.geom.Point2D; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.TreeSet; - -public class Singularity2 { - - private final TreeSet<Double> angles = new TreeSet<Double>(); - - final private Point2D.Double center; - - public Singularity2(Point2D.Double center) { - this.center = center; - } - - @Override - public String toString() { - final StringBuilder sb = new StringBuilder(center.toString()); - for (Double a : angles) { - final int degree = (int) (a * 180 / Math.PI); - sb.append(' '); - sb.append(degree); - } - return sb.toString(); - } - - public void addLineSegment(Line2D.Double seg) { - if (seg.getP1().equals(center)) { - angles.add(convertAngle(getAngle(seg))); - } else if (seg.getP2().equals(center)) { - angles.add(convertAngle(getOppositeAngle(seg))); - } else { - throw new IllegalArgumentException(); - } - assert betweenZeroAndTwoPi(); - - } - - static final double getAngle(Line2D.Double line) { - if (line.getP1().equals(line.getP2())) { - throw new IllegalArgumentException(); - } - return Math.atan2(line.getP2().getY() - line.getP1().getY(), line.getP2().getX() - line.getP1().getX()); - } - - static final double getOppositeAngle(Line2D.Double line) { - return Math.atan2(line.getP1().getY() - line.getP2().getY(), line.getP1().getX() - line.getP2().getX()); - } - - static double convertAngle(double a) { - while (a < 0) { - a += 2 * Math.PI; - } - return a; - } - - private boolean betweenZeroAndTwoPi() { - for (Double d : angles) { - assert d >= 0; - assert d < 2 * Math.PI; - } - return true; - } - - List<Double> getAngles() { - return new ArrayList<Double>(angles); - } - - public boolean crossing(Point2D.Double direction1, Point2D.Double direction2) { - final boolean result = crossingInternal(direction1, direction2); - assert result == crossingInternal(direction2, direction1); - return result; - } - - private boolean crossingInternal(Point2D.Double direction1, Point2D.Double direction2) { - if (angles.size() < 2) { - return false; - } - final double angle1 = convertAngle(getAngle(new Line2D.Double(center, direction1))); - final double angle2 = convertAngle(getAngle(new Line2D.Double(center, direction2))); - - Double last = null; - for (Double current : angles) { - if (last != null) { - assert last < current; - if (isBetween(angle1, last, current) && isBetween(angle2, last, current)) { - return false; - } - } - last = current; - } - final double first = angles.first(); - if ((angle1 <= first || angle1 >= last) && (angle2 <= first || angle2 >= last)) { - return false; - } - return true; - } - - private boolean isBetween(double test, double v1, double v2) { - assert v1 < v2; - return test >= v1 && test <= v2; - } - - protected final Point2D.Double getCenter() { - return center; - } - - public void merge(Singularity2 other) { - this.angles.addAll(other.angles); - } - - public List<Neighborhood2> getNeighborhoods() { - if (angles.size() == 0) { - return Collections.singletonList(new Neighborhood2(center)); - } - final List<Neighborhood2> result = new ArrayList<Neighborhood2>(); - double last = angles.last(); - for (Double currentAngle : angles) { - result.add(new Neighborhood2(center, last, currentAngle)); - last = currentAngle; - } - return Collections.unmodifiableList(result); - } - -} diff --git a/src/net/sourceforge/plantuml/graph2/SortedList.java b/src/net/sourceforge/plantuml/graph2/SortedList.java deleted file mode 100644 index 51d61af..0000000 --- a/src/net/sourceforge/plantuml/graph2/SortedList.java +++ /dev/null @@ -1,46 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.graph2; - -import java.util.List; - -public interface SortedList<V> extends Iterable<V> { - public void add(V data); - - public List<V> lesserOrEquals(int v); - - public List<V> biggerOrEquals(int v); -} diff --git a/src/net/sourceforge/plantuml/graph2/SortedListImpl.java b/src/net/sourceforge/plantuml/graph2/SortedListImpl.java deleted file mode 100644 index 0fd3ba8..0000000 --- a/src/net/sourceforge/plantuml/graph2/SortedListImpl.java +++ /dev/null @@ -1,129 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.graph2; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.Iterator; -import java.util.List; - -public class SortedListImpl<V> implements SortedList<V> { - - static class NullableAndEvenMeasurer<V> implements Measurer<V> { - private final Measurer<V> wrapped; - private final int valueForNull; - - NullableAndEvenMeasurer(Measurer<V> wrapped, int valueForNull, boolean plus) { - this.wrapped = wrapped; - if (plus) { - this.valueForNull = valueForNull * 2 + 1; - } else { - this.valueForNull = valueForNull * 2 - 1; - } - } - - public int getMeasure(V data) { - if (data == null) { - return valueForNull; - } - return wrapped.getMeasure(data) * 2; - } - } - - private final Measurer<V> measurer; - private final List<V> all = new ArrayList<V>(); - private final Comparator<V> comparator; - - public SortedListImpl(Measurer<V> m) { - this.measurer = m; - this.comparator = new Comparator<V>() { - public int compare(V o1, V o2) { - final int v1 = measurer.getMeasure(o1); - final int v2 = measurer.getMeasure(o2); - return v1 - v2; - } - }; - } - - public void add(V data) { - final int pos = Collections.binarySearch(all, data, comparator); - if (pos >= 0) { - all.add(pos, data); - } else { - all.add(-pos - 1, data); - } - assert isSorted(); - } - - private int getPos(int v, boolean plus) { - final Measurer<V> m = new NullableAndEvenMeasurer<V>(measurer, v, plus); - final Comparator<V> myComp = new Comparator<V>() { - public int compare(V o1, V o2) { - final int v1 = m.getMeasure(o1); - final int v2 = m.getMeasure(o2); - return v1 - v2; - } - }; - final int pos = Collections.binarySearch(all, null, myComp); - assert pos < 0; - return -pos - 1; - } - - public List<V> lesserOrEquals(int v) { - return all.subList(0, getPos(v, true)); - } - - public List<V> biggerOrEquals(int v) { - return all.subList(getPos(v, false), all.size()); - } - - private boolean isSorted() { - for (int i = 0; i < all.size() - 1; i++) { - final int v1 = measurer.getMeasure(all.get(i)); - final int v2 = measurer.getMeasure(all.get(i + 1)); - if (v1 > v2) { - return false; - } - } - return true; - } - - public Iterator<V> iterator() { - return all.iterator(); - } - -} diff --git a/src/net/sourceforge/plantuml/hector/Box2D.java b/src/net/sourceforge/plantuml/hector/Box2D.java deleted file mode 100644 index a93117b..0000000 --- a/src/net/sourceforge/plantuml/hector/Box2D.java +++ /dev/null @@ -1,81 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.hector; - -import java.awt.geom.Dimension2D; - -import net.sourceforge.plantuml.geom.LineSegmentDouble; - -public class Box2D { - - final private double x1; - final private double y1; - final private double x2; - final private double y2; - - private Box2D(double x1, double y1, double x2, double y2) { - this.x1 = x1; - this.y1 = y1; - this.x2 = x2; - this.y2 = y2; - } - - public static Box2D create(double x, double y, Dimension2D dim) { - return new Box2D(x, y, x + dim.getWidth(), y + dim.getHeight()); - } - - @Override - public String toString() { - return "Box [" + x1 + "," + y1 + "] [" + x2 + "," + y2 + "]"; - } - - public boolean doesIntersect(LineSegmentDouble seg) { - if (seg.doesIntersect(new LineSegmentDouble(x1, y1, x2, y1))) { - return true; - } - if (seg.doesIntersect(new LineSegmentDouble(x2, y1, x2, y2))) { - return true; - } - if (seg.doesIntersect(new LineSegmentDouble(x2, y2, x1, y2))) { - return true; - } - if (seg.doesIntersect(new LineSegmentDouble(x1, y2, x1, y1))) { - return true; - } - return false; - } - -} diff --git a/src/net/sourceforge/plantuml/hector/CucaDiagramFileMakerHectorB1.java b/src/net/sourceforge/plantuml/hector/CucaDiagramFileMakerHectorB1.java deleted file mode 100644 index 0588f9e..0000000 --- a/src/net/sourceforge/plantuml/hector/CucaDiagramFileMakerHectorB1.java +++ /dev/null @@ -1,169 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.hector; - -import java.awt.geom.Dimension2D; -import java.io.IOException; -import java.io.OutputStream; -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - -import net.sourceforge.plantuml.ColorParam; -import net.sourceforge.plantuml.Dimension2DDouble; -import net.sourceforge.plantuml.FileFormatOption; -import net.sourceforge.plantuml.core.ImageData; -import net.sourceforge.plantuml.cucadiagram.CucaDiagram; -import net.sourceforge.plantuml.cucadiagram.ILeaf; -import net.sourceforge.plantuml.cucadiagram.Link; -import net.sourceforge.plantuml.graphic.HtmlColor; -import net.sourceforge.plantuml.graphic.HtmlColorUtils; -import net.sourceforge.plantuml.skin.rose.Rose; -import net.sourceforge.plantuml.svek.CucaDiagramFileMaker; -import net.sourceforge.plantuml.svek.GeneralImageBuilder; -import net.sourceforge.plantuml.svek.IEntityImage; -import net.sourceforge.plantuml.ugraphic.MinMax; -import net.sourceforge.plantuml.ugraphic.UChangeBackColor; -import net.sourceforge.plantuml.ugraphic.UChangeColor; -import net.sourceforge.plantuml.ugraphic.UEllipse; -import net.sourceforge.plantuml.ugraphic.UGraphic; -import net.sourceforge.plantuml.ugraphic.UGraphic2; -import net.sourceforge.plantuml.ugraphic.UTranslate; - -public class CucaDiagramFileMakerHectorB1 implements CucaDiagramFileMaker { - - private final CucaDiagram diagram; - private SkeletonConfiguration configuration; - - // private double singleWidth; - // private double singleHeight; - private double nodeMargin = 40; - - public CucaDiagramFileMakerHectorB1(CucaDiagram diagram) { - this.diagram = diagram; - } - - // final private Map<Pin, IEntityImage> images = new LinkedHashMap<Pin, IEntityImage>(); - // final private Map<Pin, Box2D> boxes = new LinkedHashMap<Pin, Box2D>(); - - final private Map<Link, PinLink> links = new LinkedHashMap<Link, PinLink>(); - - // final private List<Box2D> forbidden = new ArrayList<Box2D>(); - - private double getX(Pin pin) { - return nodeMargin * configuration.getCol(pin); - } - - private double getY(Pin pin) { - return nodeMargin * pin.getRow(); - } - - // private double getCenterX(Pin pin) { - // return singleWidth * configuration.getCol(pin) + singleWidth / 2.0; - // } - // - // private double getCenterY(Pin pin) { - // return singleHeight * pin.getRow() + singleHeight / 2.0; - // } - - public ImageData createFile(OutputStream os, List<String> dotStrings, FileFormatOption fileFormatOption) - throws IOException { - final PinFactory pinFactory = new PinFactory(); - final SkeletonBuilder skeletonBuilder = new SkeletonBuilder(); - links.clear(); - for (Link link : diagram.getLinks()) { - final PinLink pinLink = pinFactory.createPinLink(link); - links.put(link, pinLink); - skeletonBuilder.add(pinLink); - } - - final Skeleton skeleton = skeletonBuilder.createSkeletons().get(0); - this.configuration = SkeletonConfigurationUtils.getBest(skeleton); - - MinMax minMax = MinMax.getEmpty(false); - for (Pin pin : skeleton.getPins()) { - minMax = minMax.addPoint(getX(pin), getY(pin)); - } - - final double borderMargin = 10; - - final Dimension2D dimTotal = new Dimension2DDouble(2 * borderMargin + minMax.getMaxX(), 2 * borderMargin - + minMax.getMaxY()); - UGraphic2 ug = null;// fileFormatOption.createUGraphic(diagram.getColorMapper(), diagram.getDpiFactor(fileFormatOption), - // dimTotal, null, false); - ug = (UGraphic2) ug.apply(new UTranslate(borderMargin, borderMargin)); - - for (PinLink pinLink : skeleton.getPinLinks()) { - drawPinLink(ug, pinLink); - } - - for (Pin pin : skeleton.getPins()) { - drawPin(ug, pin); - } - -// ug.writeImageTOBEMOVED(os, null, diagram.getDpi(fileFormatOption)); -// return new ImageDataSimple(dimTotal); - throw new UnsupportedOperationException(); - } - - private void drawPin(UGraphic ug, Pin pin) { - final double x = getX(pin); - final double y = getY(pin); - final UEllipse circle = new UEllipse(6, 6); - ug.apply(new UChangeColor(HtmlColorUtils.BLACK)).apply(new UChangeBackColor(HtmlColorUtils.BLACK)) - .apply(new UTranslate(x - 3, y - 3)).draw(circle); - } - - private void drawPinLink(UGraphic ug, PinLink pinLink) { - final double x1 = getX(pinLink.getPin1()); - final double y1 = getY(pinLink.getPin1()); - final double x2 = getX(pinLink.getPin2()); - final double y2 = getY(pinLink.getPin2()); - - final Rose rose = new Rose(); - final HtmlColor color = rose.getHtmlColor(diagram.getSkinParam(), ColorParam.arrow); - final List<Box2D> b = new ArrayList<Box2D>(); - final SmartConnection connection = new SmartConnection(x1, y1, x2, y2, b); - connection.draw(ug, color); - } - - private IEntityImage computeImage(final ILeaf leaf) { - final IEntityImage image = GeneralImageBuilder.createEntityImageBlock(leaf, diagram.getSkinParam(), - false, diagram, null, null, null, diagram.getLinks()); - return image; - } -} diff --git a/src/net/sourceforge/plantuml/hector/GrowingTree.java b/src/net/sourceforge/plantuml/hector/GrowingTree.java deleted file mode 100644 index 9b5bdf3..0000000 --- a/src/net/sourceforge/plantuml/hector/GrowingTree.java +++ /dev/null @@ -1,175 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.hector; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -public class GrowingTree { - - private final List<PinLink> all = new ArrayList<PinLink>(); - private final Map<Pin, ArrayList<Pin>> directlyAfter = new HashMap<Pin, ArrayList<Pin>>(); - - public Skeleton createSkeleton() { - final Set<Pin> pins = new LinkedHashSet<Pin>(); - for (PinLink link : all) { - pins.add(link.getPin1()); - pins.add(link.getPin2()); - } - normalizeRowToZero(pins); - return new Skeleton(new ArrayList<Pin>(pins), new ArrayList<PinLink>(all)); - } - - private void normalizeRowToZero(Collection<Pin> pins) { - int minRow = Integer.MAX_VALUE; - for (Pin p : pins) { - final int r = p.getRow(); - if (r == Integer.MAX_VALUE) { - throw new IllegalStateException(); - } - if (r < minRow) { - minRow = r; - } - } - for (Pin p : pins) { - p.push(-minRow); - } - } - - public boolean canBeAdded(PinLink candidat) { - if (all.size() == 0) { - return true; - } - final Pin p1 = candidat.getPin1(); - final Pin p2 = candidat.getPin2(); - if (p1.getRow() == Integer.MAX_VALUE && p2.getRow() == Integer.MAX_VALUE) { - return false; - } - return true; - } - - public void add(PinLink newPinLink) { - final Pin p1 = newPinLink.getPin1(); - final Pin p2 = newPinLink.getPin2(); - if (all.size() == 0) { - newPinLink.getPin1().setRow(0); - simpleRowComputation(newPinLink); - } else if (isPartiallyNew(newPinLink)) { - simpleRowComputation(newPinLink); - } else if (p1.getRow() != Integer.MAX_VALUE && p2.getRow() != Integer.MAX_VALUE) { - final int actualRowDiff = p2.getRow() - p1.getRow(); - final int neededPushForP2 = newPinLink.getLengthStandard() - actualRowDiff; - push(p2, neededPushForP2); - } else { - throw new IllegalArgumentException(); - } - all.add(newPinLink); - getDirectlyAfter(p1).add(p2); - } - - private List<Pin> getDirectlyAfter(Pin p) { - ArrayList<Pin> result = directlyAfter.get(p); - if (result == null) { - result = new ArrayList<Pin>(); - directlyAfter.put(p, result); - } - return result; - } - - private Collection<Pin> getIndirectlyAfter(Pin pin) { - final Set<Pin> result = new HashSet<Pin>(getDirectlyAfter(pin)); - int lastSize = result.size(); - while (true) { - for (Pin p : new ArrayList<Pin>(result)) { - result.addAll(getDirectlyAfter(p)); - } - if (result.size() == lastSize) { - return result; - } - lastSize = result.size(); - } - } - - private void push(Pin p, int push) { - if (push <= 0) { - return; - } - final Collection<Pin> after = getIndirectlyAfter(p); - if (after.contains(p)) { - throw new IllegalStateException(); - } - p.push(push); - for (Pin pp : after) { - pp.push(push); - } - } - - private void simpleRowComputation(PinLink link) { - final Pin p1 = link.getPin1(); - final Pin p2 = link.getPin2(); - if (p1.getRow() == Integer.MAX_VALUE && p2.getRow() != Integer.MAX_VALUE) { - p1.setRow(p2.getRow() - link.getLengthStandard()); - } else if (p1.getRow() != Integer.MAX_VALUE && p2.getRow() == Integer.MAX_VALUE) { - p2.setRow(p1.getRow() + link.getLengthStandard()); - } else { - throw new IllegalArgumentException(); - } - } - - private boolean isPartiallyNew(PinLink link) { - final Pin p1 = link.getPin1(); - final Pin p2 = link.getPin2(); - if (p1.getRow() == Integer.MAX_VALUE && p2.getRow() != Integer.MAX_VALUE) { - return true; - } else if (p1.getRow() != Integer.MAX_VALUE && p2.getRow() == Integer.MAX_VALUE) { - return true; - } else { - return false; - } - } - - public void normalizeRowToZero() { - // TODO Auto-generated method stub - - } - -} diff --git a/src/net/sourceforge/plantuml/hector/HectorPath.java b/src/net/sourceforge/plantuml/hector/HectorPath.java deleted file mode 100644 index 3a7f92c..0000000 --- a/src/net/sourceforge/plantuml/hector/HectorPath.java +++ /dev/null @@ -1,72 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.hector; - -import java.awt.geom.Point2D; -import java.util.ArrayList; -import java.util.List; - -import net.sourceforge.plantuml.geom.LineSegmentDouble; -import net.sourceforge.plantuml.graphic.HtmlColor; -import net.sourceforge.plantuml.ugraphic.UChangeColor; -import net.sourceforge.plantuml.ugraphic.UGraphic; -import net.sourceforge.plantuml.ugraphic.UStroke; - -public class HectorPath { - - private final List<LineSegmentDouble> segments = new ArrayList<LineSegmentDouble>(); - - public void add(LineSegmentDouble seg) { - this.segments.add(seg); - } - - public void add(Point2D p1, Point2D p2) { - add(new LineSegmentDouble(p1, p2)); - } - - @Override - public String toString() { - return segments.toString(); - } - - public void draw(UGraphic ug, HtmlColor color) { - ug = ug.apply(new UChangeColor(color)).apply(new UStroke(1.5)); - for (LineSegmentDouble seg : segments) { - seg.draw(ug); - } - } - -} diff --git a/src/net/sourceforge/plantuml/hector/Pin.java b/src/net/sourceforge/plantuml/hector/Pin.java deleted file mode 100644 index ead918a..0000000 --- a/src/net/sourceforge/plantuml/hector/Pin.java +++ /dev/null @@ -1,78 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.hector; - - -public class Pin { - - private int row; - private int uid = -1; - - private final Object userData; - - public Pin(int row, Object userData) { - this.row = row; - this.userData = userData; - } - - public void setUid(int uid) { - if (this.uid != -1) { - throw new IllegalStateException(); - } - this.uid = uid; - } - - public int getRow() { - return row; - } - - public int getUid() { - return uid; - } - - public Object getUserData() { - return userData; - } - - public void setRow(int row) { - this.row = row; - } - - public void push(int push) { - setRow(getRow() + push); - } - -} diff --git a/src/net/sourceforge/plantuml/hector/PinFactory.java b/src/net/sourceforge/plantuml/hector/PinFactory.java deleted file mode 100644 index e6146ee..0000000 --- a/src/net/sourceforge/plantuml/hector/PinFactory.java +++ /dev/null @@ -1,68 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.hector; - -import java.util.HashMap; -import java.util.Map; - -import net.sourceforge.plantuml.cucadiagram.Link; - -public class PinFactory { - - private final Map<Object, Pin> pins = new HashMap<Object, Pin>(); - - Pin create(Object userData) { - return create(Integer.MAX_VALUE, userData); - } - - public Pin create(int row, Object userData) { - if (userData == null) { - return new Pin(row, userData); - } - Pin result = pins.get(userData); - if (result == null) { - result = new Pin(row, userData); - pins.put(userData, result); - } - return result; - } - - public PinLink createPinLink(Link link) { - final PinLink result = new PinLink(create(link.getEntity1()), create(link.getEntity2()), link.getLength(), link); - return result; - } - -} diff --git a/src/net/sourceforge/plantuml/hector/PinLink.java b/src/net/sourceforge/plantuml/hector/PinLink.java deleted file mode 100644 index 231dac5..0000000 --- a/src/net/sourceforge/plantuml/hector/PinLink.java +++ /dev/null @@ -1,78 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.hector; - -public class PinLink { - - private final Pin pin1; - private final Pin pin2; - private final Object userData; - private final int length; - - public PinLink(Pin pin1, Pin pin2, int length, Object userData) { - if (length < 1) { - throw new IllegalArgumentException(); - } - this.pin1 = pin1; - this.pin2 = pin2; - this.userData = userData; - this.length = length; - } - - public boolean contains(Pin pin) { - return pin == pin1 || pin == pin2; - } - - public boolean doesTouch(PinLink other) { - return other.contains(pin1) || other.contains(pin2); - } - - public Pin getPin1() { - return pin1; - } - - public Pin getPin2() { - return pin2; - } - - public int getLengthDot() { - return length; - } - - public int getLengthStandard() { - return length - 1; - } -} diff --git a/src/net/sourceforge/plantuml/hector/PinLinksContinuousSet.java b/src/net/sourceforge/plantuml/hector/PinLinksContinuousSet.java deleted file mode 100644 index 49fc3e7..0000000 --- a/src/net/sourceforge/plantuml/hector/PinLinksContinuousSet.java +++ /dev/null @@ -1,104 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.hector; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; - -public class PinLinksContinuousSet { - - private final Collection<PinLink> all = new ArrayList<PinLink>(); - - public Skeleton createSkeleton() { - final GrowingTree tree = new GrowingTree(); - final Collection<PinLink> pendings = new ArrayList<PinLink>(all); - while (pendings.size() > 0) { - for (Iterator<PinLink> it = pendings.iterator(); it.hasNext();) { - final PinLink candidat = it.next(); - if (tree.canBeAdded(candidat)) { - tree.add(candidat); - it.remove(); - } - } - } - return tree.createSkeleton(); - - } - - public void add(PinLink newPinLink) { - if (all.size() == 0) { - all.add(newPinLink); - return; - } - if (all.contains(newPinLink)) { - throw new IllegalArgumentException("already"); - } - for (PinLink aLink : all) { - if (newPinLink.doesTouch(aLink)) { - all.add(newPinLink); - return; - } - } - throw new IllegalArgumentException("not connex"); - } - - public void addAll(PinLinksContinuousSet other) { - if (doesTouch(other) == false) { - throw new IllegalArgumentException(); - } - this.all.addAll(other.all); - } - - public boolean doesTouch(PinLink other) { - for (PinLink aLink : all) { - if (other.doesTouch(aLink)) { - return true; - } - } - return false; - } - - public boolean doesTouch(PinLinksContinuousSet otherSet) { - for (PinLink otherLink : otherSet.all) { - if (doesTouch(otherLink)) { - return true; - } - } - return false; - } - -} diff --git a/src/net/sourceforge/plantuml/hector/Skeleton.java b/src/net/sourceforge/plantuml/hector/Skeleton.java deleted file mode 100644 index d02cf7b..0000000 --- a/src/net/sourceforge/plantuml/hector/Skeleton.java +++ /dev/null @@ -1,85 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.hector; - -import java.util.Collection; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Set; -import java.util.SortedSet; -import java.util.TreeSet; - -public class Skeleton { - - private final List<Pin> pins; - private final List<PinLink> pinLinks; - private final SortedSet<Integer> rows = new TreeSet<Integer>(); - - public Skeleton(List<Pin> pins, List<PinLink> pinLinks) { - this.pins = pins; - this.pinLinks = pinLinks; - int uid = 0; - for (Pin pin : pins) { - pin.setUid(uid++); - rows.add(pin.getRow()); - } - } - - public SortedSet<Integer> getRows() { - return rows; - } - - public List<Pin> getPins() { - return pins; - } - - public Collection<Pin> getPinsOfRow(int row) { - final Set<Pin> result = new LinkedHashSet<Pin>(); - for (Pin pin : pins) { - if (pin.getRow() == row) { - result.add(pin); - } - } - return result; - } - - public List<PinLink> getPinLinks() { - return pinLinks; - } - - - -} diff --git a/src/net/sourceforge/plantuml/hector/SkeletonBuilder.java b/src/net/sourceforge/plantuml/hector/SkeletonBuilder.java deleted file mode 100644 index 7519b11..0000000 --- a/src/net/sourceforge/plantuml/hector/SkeletonBuilder.java +++ /dev/null @@ -1,85 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.hector; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -public class SkeletonBuilder { - - private List<PinLinksContinuousSet> sets = new ArrayList<PinLinksContinuousSet>(); - - public void add(PinLink pinLink) { - addInternal(pinLink); - merge(); - - } - - private void merge() { - for (int i = 0; i < sets.size() - 1; i++) { - for (int j = i + 1; j < sets.size(); j++) { - if (sets.get(i).doesTouch(sets.get(j))) { - sets.get(i).addAll(sets.get(j)); - sets.remove(j); - return; - } - } - } - } - - private void addInternal(PinLink pinLink) { - for (PinLinksContinuousSet set : sets) { - if (set.doesTouch(pinLink)) { - set.add(pinLink); - return; - } - } - final PinLinksContinuousSet newSet = new PinLinksContinuousSet(); - newSet.add(pinLink); - sets.add(newSet); - } - - public List<Skeleton> createSkeletons() { - final List<Skeleton> result = new ArrayList<Skeleton>(); - - for (PinLinksContinuousSet set : sets) { - result.add(set.createSkeleton()); - } - - return Collections.unmodifiableList(result); - } -} diff --git a/src/net/sourceforge/plantuml/hector/SkeletonConfiguration.java b/src/net/sourceforge/plantuml/hector/SkeletonConfiguration.java deleted file mode 100644 index 125eecb..0000000 --- a/src/net/sourceforge/plantuml/hector/SkeletonConfiguration.java +++ /dev/null @@ -1,256 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.hector; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -public class SkeletonConfiguration { - - private final int position[]; - private final Skeleton skeleton; - - public static SkeletonConfiguration getDefault(Skeleton skeleton) { - final Collection<Integer> rows = skeleton.getRows(); - final Map<Integer, Integer> free = new HashMap<Integer, Integer>(); - for (Integer i : rows) { - free.put(i, 0); - } - final Collection<Pin> pins = skeleton.getPins(); - final int position[] = new int[pins.size()]; - for (Pin pin : pins) { - final int f = free.get(pin.getRow()); - position[pin.getUid()] = f; - free.put(pin.getRow(), f + 1); - } - return new SkeletonConfiguration(skeleton, position); - } - - @Override - public int hashCode() { - int result = 0; - for (int v : position) { - result = result * 37 + v; - } - return result; - } - - @Override - public boolean equals(Object other) { - final SkeletonConfiguration this2 = (SkeletonConfiguration) other; - if (this.skeleton != this2.skeleton) { - throw new IllegalArgumentException(); - } - if (this.position.length != this2.position.length) { - throw new IllegalArgumentException(); - } - for (int i = 0; i < position.length; i++) { - if (this.position[i] != this2.position[i]) { - return false; - } - } - return true; - } - - @Override - public String toString() { - final int minRow = skeleton.getRows().first(); - final int maxRow = skeleton.getRows().last(); - int minCol = Integer.MAX_VALUE; - int maxCol = Integer.MIN_VALUE; - for (int c : position) { - if (c > maxCol) { - maxCol = c; - } - if (c < minCol) { - minCol = c; - } - } - final StringBuilder result = new StringBuilder(); - for (int r = minRow; r <= maxRow; r++) { - appendRow(result, r, minCol, maxCol); - if (r < maxRow) { - result.append(" "); - } - } - return result.toString(); - } - - private void appendRow(StringBuilder result, int row, int minCol, int maxCol) { - result.append("("); - boolean first = true; - for (int c = minCol; c <= maxCol; c++) { - if (first == false) { - result.append("-"); - } - final Pin pin = getPin(row, c); - if (pin == null) { - result.append("."); - } else { - result.append(pin.getUid()); - } - first = false; - } - result.append(")"); - - } - - private Pin getPin(int row, int col) { - for (Pin p : skeleton.getPinsOfRow(row)) { - if (getCol(p) == col) { - return p; - } - } - return null; - } - - public int getCol(Pin pin) { - return position[pin.getUid()]; - } - - private SkeletonConfiguration(Skeleton skeleton, int position[]) { - this.position = position; - this.skeleton = skeleton; - } - - class Switch implements SkeletonMutation { - private final SkeletonConfiguration newConfiguration; - - public Switch(Pin pin1, Pin pin2) { - if (pin1 == pin2) { - throw new IllegalArgumentException(); - } - final int copy[] = new int[position.length]; - for (int i = 0; i < position.length; i++) { - if (i == pin1.getUid()) { - copy[i] = position[pin2.getUid()]; - } else if (i == pin2.getUid()) { - copy[i] = position[pin1.getUid()]; - } else { - copy[i] = position[i]; - } - } - this.newConfiguration = new SkeletonConfiguration(skeleton, copy); - } - - public SkeletonConfiguration mutate() { - return newConfiguration; - } - } - - class Move implements SkeletonMutation { - private final SkeletonConfiguration newConfiguration; - - public Move(Pin pin, int deltaX) { - final int copy[] = new int[position.length]; - for (int i = 0; i < position.length; i++) { - if (i == pin.getUid()) { - copy[i] = position[i] + deltaX; - } else { - copy[i] = position[i]; - } - } - this.newConfiguration = new SkeletonConfiguration(skeleton, copy); - } - - public SkeletonConfiguration mutate() { - return newConfiguration; - } - } - - private Collection<SkeletonMutation> getMutationForRow(int row) { - final Collection<Pin> pins = skeleton.getPinsOfRow(row); - final Collection<Integer> usedCols = new HashSet<Integer>(); - for (Pin pin : pins) { - usedCols.add(getCol(pin)); - } - final Collection<SkeletonMutation> result = new ArrayList<SkeletonMutation>(); - for (Pin pin1 : pins) { - final int c = getCol(pin1); - if (usedCols.contains(c + 1) == false) { - result.add(new Move(pin1, 1)); - } - if (usedCols.contains(c - 1) == false) { - result.add(new Move(pin1, -1)); - } - for (Pin pin2 : pins) { - if (pin1 == pin2) { - continue; - } - if (getCol(pin1) > getCol(pin2)) { - continue; - } - if (getCol(pin1) == getCol(pin2)) { - throw new IllegalStateException(); - } - result.add(new Switch(pin1, pin2)); - } - } - return result; - } - - public Set<SkeletonConfiguration> getSomeMuteds() { - final Set<SkeletonConfiguration> result = new HashSet<SkeletonConfiguration>(); - for (Integer row : skeleton.getRows()) { - for (SkeletonMutation mutation : getMutationForRow(row)) { - result.add(mutation.mutate()); - } - - } - return result; - } - - public List<PinLink> getPinLinks() { - return skeleton.getPinLinks(); - } - - public double getLength(PinLink link) { - final double x1 = getCol(link.getPin1()); - final double y1 = link.getPin1().getRow(); - final double x2 = getCol(link.getPin2()); - final double y2 = link.getPin2().getRow(); - final double dx = x2 - x1; - final double dy = y2 - y1; - return Math.sqrt(dx * dx + dy * dy); - } - - -} diff --git a/src/net/sourceforge/plantuml/hector/SkeletonConfigurationComparator.java b/src/net/sourceforge/plantuml/hector/SkeletonConfigurationComparator.java deleted file mode 100644 index 627702a..0000000 --- a/src/net/sourceforge/plantuml/hector/SkeletonConfigurationComparator.java +++ /dev/null @@ -1,60 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.hector; - -import java.util.Comparator; - -public class SkeletonConfigurationComparator implements Comparator<SkeletonConfiguration> { - - private final SkeletonConfigurationEvaluator evaluator; - - public SkeletonConfigurationComparator(SkeletonConfigurationEvaluator evaluator) { - this.evaluator = evaluator; - } - - public int compare(SkeletonConfiguration sc1, SkeletonConfiguration sc2) { - final double price1 = evaluator.getPrice(sc1); - final double price2 = evaluator.getPrice(sc2); - if (price1 > price2) { - return 1; - } - if (price1 < price2) { - return -1; - } - return 0; - } - -} diff --git a/src/net/sourceforge/plantuml/hector/SkeletonConfigurationEvaluator.java b/src/net/sourceforge/plantuml/hector/SkeletonConfigurationEvaluator.java deleted file mode 100644 index 9742a5f..0000000 --- a/src/net/sourceforge/plantuml/hector/SkeletonConfigurationEvaluator.java +++ /dev/null @@ -1,42 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.hector; - -public interface SkeletonConfigurationEvaluator { - - public double getPrice(SkeletonConfiguration configuration); - -} diff --git a/src/net/sourceforge/plantuml/hector/SkeletonConfigurationEvaluatorLineLenght.java b/src/net/sourceforge/plantuml/hector/SkeletonConfigurationEvaluatorLineLenght.java deleted file mode 100644 index a6e2f78..0000000 --- a/src/net/sourceforge/plantuml/hector/SkeletonConfigurationEvaluatorLineLenght.java +++ /dev/null @@ -1,48 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.hector; - -public class SkeletonConfigurationEvaluatorLineLenght implements SkeletonConfigurationEvaluator { - - public double getPrice(SkeletonConfiguration configuration) { - double result = 0; - for (PinLink link : configuration.getPinLinks()) { - result += configuration.getLength(link); - } - return result; - } - -} diff --git a/src/net/sourceforge/plantuml/hector/SkeletonConfigurationSet.java b/src/net/sourceforge/plantuml/hector/SkeletonConfigurationSet.java deleted file mode 100644 index b6ecccc..0000000 --- a/src/net/sourceforge/plantuml/hector/SkeletonConfigurationSet.java +++ /dev/null @@ -1,90 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.hector; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; - -public class SkeletonConfigurationSet implements Iterable<SkeletonConfiguration> { - - private final List<SkeletonConfiguration> all; - private final SkeletonConfigurationComparator comparator; - private final int limitSize; - - public SkeletonConfigurationSet(int limitSize, SkeletonConfigurationEvaluator evaluator) { - this.comparator = new SkeletonConfigurationComparator(evaluator); - this.all = new ArrayList<SkeletonConfiguration>(); - this.limitSize = limitSize; - } - - public void add(SkeletonConfiguration skeletonConfiguration) { - this.all.add(skeletonConfiguration); - sortAndTruncate(); - } - - public void addAll(Collection<SkeletonConfiguration> others) { - all.addAll(others); - sortAndTruncate(); - } - - private void sortAndTruncate() { - Collections.sort(all, comparator); - while (all.size() > limitSize) { - all.remove(all.size() - 1); - } - } - - @Override - public String toString() { - return all.toString(); - } - - public int size() { - return all.size(); - } - - public Iterator<SkeletonConfiguration> iterator() { - return new ArrayList<SkeletonConfiguration>(all).iterator(); - } - - public SkeletonConfiguration first() { - return all.get(0); - } - -} diff --git a/src/net/sourceforge/plantuml/hector/SkeletonConfigurationUtils.java b/src/net/sourceforge/plantuml/hector/SkeletonConfigurationUtils.java deleted file mode 100644 index 7b2429c..0000000 --- a/src/net/sourceforge/plantuml/hector/SkeletonConfigurationUtils.java +++ /dev/null @@ -1,57 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.hector; - -public class SkeletonConfigurationUtils { - - public static SkeletonConfiguration getBest(Skeleton skeleton) { - SkeletonConfiguration config = SkeletonConfiguration.getDefault(skeleton); - - final SkeletonConfigurationSet set = new SkeletonConfigurationSet(200, - new SkeletonConfigurationEvaluatorLineLenght()); - set.add(config); - - for (int i = 0; i < 10; i++) { - System.err.println("before size=" + set.size()); - for (SkeletonConfiguration sk : set) { - set.addAll(sk.getSomeMuteds()); - } - System.err.println("after size=" + set.size()); - } - return set.first(); - } - -} diff --git a/src/net/sourceforge/plantuml/hector/SkeletonConfigurations.java b/src/net/sourceforge/plantuml/hector/SkeletonConfigurations.java deleted file mode 100644 index c7d2f0c..0000000 --- a/src/net/sourceforge/plantuml/hector/SkeletonConfigurations.java +++ /dev/null @@ -1,40 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.hector; - -public class SkeletonConfigurations { - -} diff --git a/src/net/sourceforge/plantuml/hector/SkeletonMutation.java b/src/net/sourceforge/plantuml/hector/SkeletonMutation.java deleted file mode 100644 index 593ef96..0000000 --- a/src/net/sourceforge/plantuml/hector/SkeletonMutation.java +++ /dev/null @@ -1,42 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.hector; - -interface SkeletonMutation { - - public SkeletonConfiguration mutate(); - -} diff --git a/src/net/sourceforge/plantuml/hector/SmartConnection.java b/src/net/sourceforge/plantuml/hector/SmartConnection.java deleted file mode 100644 index 8fa7ccd..0000000 --- a/src/net/sourceforge/plantuml/hector/SmartConnection.java +++ /dev/null @@ -1,111 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.hector; - -import java.awt.geom.Point2D; -import java.util.List; - -import net.sourceforge.plantuml.geom.LineSegmentDouble; -import net.sourceforge.plantuml.graphic.HtmlColor; -import net.sourceforge.plantuml.graphic.HtmlColorUtils; -import net.sourceforge.plantuml.ugraphic.UChangeColor; -import net.sourceforge.plantuml.ugraphic.UGraphic; -import net.sourceforge.plantuml.ugraphic.UPath; -import net.sourceforge.plantuml.ugraphic.UStroke; - -class SmartConnection { - - private final double x1; - private final double y1; - private final double x2; - private final double y2; - private final List<Box2D> forbidden; - - public SmartConnection(double x1, double y1, double x2, double y2, List<Box2D> forbidden) { - this.x1 = x1; - this.y1 = y1; - this.x2 = x2; - this.y2 = y2; - this.forbidden = forbidden; - } - - public SmartConnection(Point2D p1, Point2D p2, List<Box2D> b) { - this(p1.getX(), p1.getY(), p2.getX(), p2.getY(), b); - } - - public void draw(UGraphic ug, HtmlColor color) { - final LineSegmentDouble seg = new LineSegmentDouble(x1, y1, x2, y2); - boolean clash = intersect(seg); - if (clash) { - ug = ug.apply(new UChangeColor(HtmlColorUtils.BLACK)).apply(new UStroke(1.0)); - } else { - ug = ug.apply(new UChangeColor(color)).apply(new UStroke(1.5)); - } - seg.draw(ug); - } - - private boolean intersect(LineSegmentDouble seg) { - for (Box2D box : forbidden) { - if (box.doesIntersect(seg)) { - return true; - } - } - return false; - } - - public void drawEx1(UGraphic ug, HtmlColor color) { - ug = ug.apply(new UChangeColor(color)).apply(new UStroke(1.5)); - final double orthoX = -(y2 - y1); - final double orthoY = x2 - x1; - for (int i = -10; i <= 10; i++) { - for (int j = -10; j <= 10; j++) { - final double d1x = orthoX * i / 10.0; - final double d1y = orthoY * i / 10.0; - final double c1x = (x1 + x2) / 2 + d1x; - final double c1y = (y1 + y2) / 2 + d1y; - final double d2x = orthoX * j / 10.0; - final double d2y = orthoY * j / 10.0; - final double c2x = (x1 + x2) / 2 + d2x; - final double c2y = (y1 + y2) / 2 + d2y; - final UPath path = new UPath(); - path.moveTo(x1, y1); - path.cubicTo(c1x, c1y, c2x, c2y, x2, y2); - ug.draw(path); - } - } - } - -} diff --git a/src/net/sourceforge/plantuml/hector/UnlinarCompressedPlan.java b/src/net/sourceforge/plantuml/hector/UnlinarCompressedPlan.java deleted file mode 100644 index 3b0998c..0000000 --- a/src/net/sourceforge/plantuml/hector/UnlinarCompressedPlan.java +++ /dev/null @@ -1,144 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.hector; - -import java.awt.geom.Point2D; - -import net.sourceforge.plantuml.geom.LineSegmentDouble; -import net.sourceforge.plantuml.hector.UnlinearCompression.Rounding; - -class UnlinarCompressedPlan { - - private final UnlinearCompression compX; - private final UnlinearCompression compY; - - public UnlinarCompressedPlan(double inner, double outer) { - this(inner, outer, inner, outer); - } - - public UnlinarCompressedPlan(double innerx, double outerx, double innery, double outery) { - this.compX = new UnlinearCompression(innerx, outerx); - this.compY = new UnlinearCompression(innery, outery); - } - - public double getInnerX() { - return compX.innerSize(); - } - - public double getInnerY() { - return compY.innerSize(); - } - - public HectorPath uncompressSegmentSimple(Point2D pp1, Point2D pp2) { - final HectorPath result = new HectorPath(); - result.add(new LineSegmentDouble(uncompress(pp1, UnlinearCompression.Rounding.CENTRAL), uncompress(pp2, - UnlinearCompression.Rounding.CENTRAL))); - return result; - } - - public HectorPath uncompressSegment(Point2D pp1, Point2D pp2) { - double x1 = pp1.getX(); - double y1 = pp1.getY(); - final double x2 = pp2.getX(); - final double y2 = pp2.getY(); - final HectorPath result = new HectorPath(); - final double y[] = compY.encounteredSingularities(y1, y2); - if (y.length == 0 || x1 == x2) { - result.add(new LineSegmentDouble(uncompress(pp1, UnlinearCompression.Rounding.CENTRAL), uncompress(pp2, - UnlinearCompression.Rounding.CENTRAL))); - return result; - } - System.err.println("len=" + y.length); - final LineSegmentDouble segment = new LineSegmentDouble(pp1, pp2); - for (int i = 0; i < y.length; i++) { - final double x = segment.getIntersectionHorizontal(y[i]); - final Rounding r = i == 0 ? UnlinearCompression.Rounding.CENTRAL : UnlinearCompression.Rounding.BORDER_2; - result.add(uncompress(x1, y1, r), uncompress(x, y[i], UnlinearCompression.Rounding.BORDER_1)); - x1 = x; - y1 = y[i]; - } - result.add(uncompress(x1, y1, UnlinearCompression.Rounding.BORDER_2), uncompress(x2, y2, - UnlinearCompression.Rounding.CENTRAL)); - return result; - - } - - public HectorPath uncompress(LineSegmentDouble segment) { - double x1 = segment.getX1(); - double y1 = segment.getY1(); - final double x2 = segment.getX2(); - final double y2 = segment.getY2(); - final HectorPath result = new HectorPath(); - final double x[] = compX.encounteredSingularities(x1, x2); - if (x.length == 0) { - result.add(getUncompressedSegment(x1, y1, x2, y2, UnlinearCompression.Rounding.BORDER_2)); - return result; - } - for (int i = 0; i < x.length; i++) { - final double y = segment.getIntersectionVertical(x[i]); - result.add(getUncompressedSegment(x1, y1, x[i], y, UnlinearCompression.Rounding.BORDER_2)); - x1 = x[i]; - y1 = y; - } - result.add(getUncompressedSegment(x1, y1, x2, y2, UnlinearCompression.Rounding.BORDER_2)); - return result; - } - - public Point2D uncompress(Point2D pt, UnlinearCompression.Rounding rounding) { - return uncompress(pt.getX(), pt.getY(), rounding); - } - - public Point2D uncompress(double x, double y, UnlinearCompression.Rounding rounding) { - return new Point2D.Double(compX.uncompress(x, rounding), compY.uncompress(y, rounding)); - } - - private LineSegmentDouble getUncompressedSegment(final double x1, final double y1, final double x2, - final double y2, UnlinearCompression.Rounding rounding) { - final LineSegmentDouble un1 = new LineSegmentDouble(compX.uncompress(x1, rounding), compY.uncompress(y1, - rounding), compX.uncompress(x2, rounding), compY.uncompress(y2, rounding)); - return un1; - } - - // private LineSegmentDouble getUncompressedSegmentRoundBefore(final double - // x1, final double y1, final double x2, - // final double y2) { - // final LineSegmentDouble un1 = new LineSegmentDouble(compX.uncompress(x1), - // compY.uncompress(y1), - // compX.uncompress(x2) - compX.innerSize(), compY.uncompress(y2)); - // return un1; - // } - -} diff --git a/src/net/sourceforge/plantuml/hector/UnlinearCompression.java b/src/net/sourceforge/plantuml/hector/UnlinearCompression.java deleted file mode 100644 index d79f6d9..0000000 --- a/src/net/sourceforge/plantuml/hector/UnlinearCompression.java +++ /dev/null @@ -1,112 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.hector; - -class UnlinearCompression { - - static enum Rounding { - BORDER_1, CENTRAL, BORDER_2; - } - - private final double inner; - private final double outer; - - public UnlinearCompression(double inner, double outer) { - this.inner = inner; - this.outer = outer; - } - - public double compress(double x) { - final double pour = x / (inner + outer); - final double pourInter = Math.floor(pour); - x -= pourInter * (inner + outer); - if (x < inner) { - return pourInter * outer; - } - return x - inner + pourInter * outer; - } - - public double uncompress(double x, Rounding rounding) { - final int pourInter = nbOuterBefore(x); - final boolean onBorder = equals(x, pourInter * outer); - if (onBorder && rounding == Rounding.BORDER_1) { - // Nothing - } else if (onBorder && rounding == Rounding.CENTRAL) { - x += inner / 2.0; - } else { - x += inner; - } - x += pourInter * inner; - return x; - } - - private static boolean equals(double d1, double d2) { - return Math.abs(d1 - d2) < .001; - } - - private int nbOuterBefore(double x) { - final double pour = x / outer; - final int pourInter = (int) Math.floor(pour); - return pourInter; - } - - public double[] encounteredSingularities(double from, double to) { - final int outer1 = nbOuterBefore(from) + 1; - int outer2 = nbOuterBefore(to) + 1; - if (equals(to, (outer2 - 1) * outer)) { - outer2--; - } - final double result[]; - if (from <= to) { - result = new double[outer2 - outer1]; - for (int i = 0; i < result.length; i++) { - result[i] = (outer1 + i) * outer; - } - } else { - result = new double[outer1 - outer2]; - for (int i = 0; i < result.length; i++) { - result[i] = (outer1 - 1 - i) * outer; - } - - } - return result; - } - - public double innerSize() { - return inner; - } - -} diff --git a/src/net/sourceforge/plantuml/hector2/MinMax.java b/src/net/sourceforge/plantuml/hector2/MinMax.java deleted file mode 100644 index f783491..0000000 --- a/src/net/sourceforge/plantuml/hector2/MinMax.java +++ /dev/null @@ -1,99 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.hector2; - -import java.util.Collection; - -public class MinMax { - - private final int min; - private final int max; - - private MinMax(int min, int max) { - if (max < min) { - throw new IllegalArgumentException(); - } - this.min = min; - this.max = max; - } - - private MinMax(int value) { - this(value, value); - } - - public MinMax add(int value) { - final int newMin = Math.min(min, value); - final int newMax = Math.max(max, value); - if (min == newMin && max == newMax) { - return this; - } - return new MinMax(newMin, newMax); - } - - public MinMax add(MinMax other) { - final int newMin = Math.min(min, other.min); - final int newMax = Math.max(max, other.max); - if (min == newMin && max == newMax) { - return this; - } - return new MinMax(newMin, newMax); - } - - public final int getMin() { - return min; - } - - public final int getMax() { - return max; - } - - public static MinMax from(Collection<Integer> values) { - MinMax result = null; - for (Integer i : values) { - if (result == null) { - result = new MinMax(i); - } else { - result = result.add(i); - } - } - return result; - } - - public int getDiff() { - return max - min; - } - -} diff --git a/src/net/sourceforge/plantuml/hector2/continuity/Skeleton.java b/src/net/sourceforge/plantuml/hector2/continuity/Skeleton.java deleted file mode 100644 index 3686449..0000000 --- a/src/net/sourceforge/plantuml/hector2/continuity/Skeleton.java +++ /dev/null @@ -1,189 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.hector2.continuity; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import net.sourceforge.plantuml.cucadiagram.IEntity; -import net.sourceforge.plantuml.cucadiagram.Link; - -public class Skeleton { - - private final Set<IEntity> entities = new HashSet<IEntity>(); - private final List<Link> links = new ArrayList<Link>(); - - private Set<IEntity> getDirectChildren(IEntity parent) { - final Set<IEntity> result = new HashSet<IEntity>(); - for (Link link : links) { - if (link.isAutolink()) { - continue; - } - if (link.getEntity1() == parent) { - result.add(link.getEntity2()); - } - } - return Collections.unmodifiableSet(result); - } - - @Override - public String toString() { - return "skeleton " + links; - } - - private Set<IEntity> getIndirectChildren(IEntity parent) { - final Set<IEntity> result = new HashSet<IEntity>(getDirectChildren(parent)); - int currentSize = result.size(); - while (true) { - for (IEntity ent : new HashSet<IEntity>(result)) { - result.addAll(getDirectChildren(ent)); - } - if (result.contains(parent) || result.size() == currentSize) { - return Collections.unmodifiableSet(result); - } - currentSize = result.size(); - } - } - - private boolean hasCycle() { - for (IEntity ent : entities) { - if (getIndirectChildren(ent).contains(ent)) { - return true; - } - } - return false; - } - - public Skeleton removeCycle() { - final Skeleton result = new Skeleton(); - for (Link link : links) { - result.add(link); - if (result.hasCycle()) { - result.links.remove(link); - } - } - return result; - } - - public void add(Link link) { - if (links.contains(link)) { - throw new IllegalArgumentException(); - } - if (link.getEntity1().isGroup()) { - throw new IllegalArgumentException(); - } - if (link.getEntity2().isGroup()) { - throw new IllegalArgumentException(); - } - links.add(link); - entities.add(link.getEntity1()); - entities.add(link.getEntity2()); - } - - public void addAll(Skeleton other) { - for (Link otherLink : other.links) { - this.add(otherLink); - } - - } - - public boolean doesTouch(Link other) { - for (Link link : links) { - if (link.doesTouch(other)) { - return true; - } - } - return false; - } - - public boolean doesTouch(Skeleton other) { - for (Link link : links) { - if (other.doesTouch(link)) { - return true; - } - } - return false; - } - - public void computeLayers() { - if (hasCycle()) { - throw new UnsupportedOperationException(); - } - for (IEntity ent : entities) { - ent.setHectorLayer(0); - } - boolean changed; - do { - changed = false; - for (Link link : links) { - if (ensureLayer(link)) { - changed = true; - } - } - } while (changed); - } - - private boolean ensureLayer(Link link) { - final int lenght = link.getLength(); - final int l1 = link.getEntity1().getHectorLayer(); - final int l2 = link.getEntity2().getHectorLayer(); - if (lenght == 1) { - if (l1 < l2) { - link.getEntity1().setHectorLayer(l2); - return true; - } else if (l2 < l1) { - link.getEntity2().setHectorLayer(l1); - return true; - } - } else { - final int l2theoric = l1 + lenght - 1; - if (l2 < l2theoric) { - link.getEntity2().setHectorLayer(l2theoric); - return true; - } - } - return false; - } - - public Collection<IEntity> entities() { - return Collections.unmodifiableCollection(entities); - } - -} diff --git a/src/net/sourceforge/plantuml/hector2/continuity/SkeletonBuilder.java b/src/net/sourceforge/plantuml/hector2/continuity/SkeletonBuilder.java deleted file mode 100644 index 677395c..0000000 --- a/src/net/sourceforge/plantuml/hector2/continuity/SkeletonBuilder.java +++ /dev/null @@ -1,87 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.hector2.continuity; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import net.sourceforge.plantuml.cucadiagram.Link; - -public class SkeletonBuilder { - - private List<Skeleton> all = new ArrayList<Skeleton>(); - - public void add(Link link) { - addInternal(link); - do { - final boolean changed = merge(); - if (changed == false) { - return; - } - } while (true); - - } - - private boolean merge() { - for (int i = 0; i < all.size() - 1; i++) { - for (int j = i + 1; j < all.size(); j++) { - if (all.get(i).doesTouch(all.get(j))) { - all.get(i).addAll(all.get(j)); - all.remove(j); - return true; - } - } - } - return false; - } - - private void addInternal(Link link) { - for (Skeleton skeleton : all) { - if (skeleton.doesTouch(link)) { - skeleton.add(link); - return; - } - } - final Skeleton newSkeleton = new Skeleton(); - newSkeleton.add(link); - all.add(newSkeleton); - } - - public List<Skeleton> getSkeletons() { - return Collections.unmodifiableList(all); - } -} diff --git a/src/net/sourceforge/plantuml/hector2/graphic/Foo1.java b/src/net/sourceforge/plantuml/hector2/graphic/Foo1.java deleted file mode 100644 index e3df59f..0000000 --- a/src/net/sourceforge/plantuml/hector2/graphic/Foo1.java +++ /dev/null @@ -1,67 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.hector2.graphic; - -import java.awt.geom.Dimension2D; - -import net.sourceforge.plantuml.Dimension2DDouble; -import net.sourceforge.plantuml.cucadiagram.CucaDiagram; -import net.sourceforge.plantuml.cucadiagram.IEntity; -import net.sourceforge.plantuml.cucadiagram.ILeaf; -import net.sourceforge.plantuml.graphic.StringBounder; -import net.sourceforge.plantuml.hector2.layering.Layer; -import net.sourceforge.plantuml.svek.GeneralImageBuilder; -import net.sourceforge.plantuml.svek.IEntityImage; - -public class Foo1 { - - public static Dimension2D getMaxCellDimension(StringBounder stringBounder, Layer layer, CucaDiagram diagram) { - Dimension2D result = new Dimension2DDouble(0, 0); - for (IEntity ent : layer.entities()) { - final IEntityImage image = computeImage((ILeaf) ent, diagram); - final Dimension2D dim = image.calculateDimension(stringBounder); - result = Dimension2DDouble.max(result, dim); - } - return result; - } - - private static IEntityImage computeImage(final ILeaf leaf, CucaDiagram diagram) { - final IEntityImage image = GeneralImageBuilder.createEntityImageBlock(leaf, diagram.getSkinParam(), - false, diagram, null, null, null, diagram.getLinks()); - return image; - } - -} diff --git a/src/net/sourceforge/plantuml/hector2/graphic/Foo2.java b/src/net/sourceforge/plantuml/hector2/graphic/Foo2.java deleted file mode 100644 index 92fedb0..0000000 --- a/src/net/sourceforge/plantuml/hector2/graphic/Foo2.java +++ /dev/null @@ -1,108 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.hector2.graphic; - -import java.awt.geom.Dimension2D; - -import net.sourceforge.plantuml.Dimension2DDouble; -import net.sourceforge.plantuml.cucadiagram.CucaDiagram; -import net.sourceforge.plantuml.cucadiagram.IEntity; -import net.sourceforge.plantuml.cucadiagram.ILeaf; -import net.sourceforge.plantuml.graphic.AbstractTextBlock; -import net.sourceforge.plantuml.graphic.StringBounder; -import net.sourceforge.plantuml.graphic.TextBlock; -import net.sourceforge.plantuml.hector2.MinMax; -import net.sourceforge.plantuml.hector2.layering.Layer; -import net.sourceforge.plantuml.hector2.mpos.Distribution; -import net.sourceforge.plantuml.svek.GeneralImageBuilder; -import net.sourceforge.plantuml.svek.IEntityImage; -import net.sourceforge.plantuml.ugraphic.UGraphic; -import net.sourceforge.plantuml.ugraphic.UTranslate; - -public class Foo2 extends AbstractTextBlock implements TextBlock { - - private final Distribution distribution; - private final CucaDiagram diagram; - - public Foo2(Distribution distribution, CucaDiagram diagram) { - this.distribution = distribution; - this.diagram = diagram; - } - - public Dimension2D getMaxCellDimension(StringBounder stringBounder) { - Dimension2D result = new Dimension2DDouble(0, 0); - for (Layer layer : distribution.getLayers()) { - final Dimension2D dim = Foo1.getMaxCellDimension(stringBounder, layer, diagram); - result = Dimension2DDouble.max(result, dim); - } - return result; - } - - public Dimension2D calculateDimension(StringBounder stringBounder) { - final Dimension2D cell = getMaxCellDimension(stringBounder); - final MinMax longitudes = distribution.getMinMaxLongitudes(); - final double width = (longitudes.getDiff() + 2) * cell.getWidth() / 2; - final double height = cell.getHeight() * distribution.getNbLayers(); - return new Dimension2DDouble(width, height); - } - - public void drawU(UGraphic ug) { - final StringBounder stringBounder = ug.getStringBounder(); - final Dimension2D cell = getMaxCellDimension(stringBounder); - for (Layer layer : distribution.getLayers()) { - drawLayer(ug, layer, cell.getWidth(), cell.getHeight()); - ug = ug.apply(new UTranslate(0, cell.getHeight())); - } - } - - private void drawLayer(UGraphic ug, Layer layer, double w, double h) { - for (IEntity ent : layer.entities()) { - final IEntityImage image = computeImage((ILeaf) ent); - final int longitude = layer.getLongitude(ent); - final Dimension2D dimImage = image.calculateDimension(ug.getStringBounder()); - final double diffx = w - dimImage.getWidth(); - final double diffy = h - dimImage.getHeight(); - image.drawU(ug.apply(new UTranslate(w * longitude / 2 + diffx / 2, diffy / 2))); - } - } - - private IEntityImage computeImage(final ILeaf leaf) { - final IEntityImage image = GeneralImageBuilder.createEntityImageBlock(leaf, diagram.getSkinParam(), - false, diagram, null, null, null, diagram.getLinks()); - return image; - } - -} diff --git a/src/net/sourceforge/plantuml/hector2/layering/Layer.java b/src/net/sourceforge/plantuml/hector2/layering/Layer.java deleted file mode 100644 index 3402cce..0000000 --- a/src/net/sourceforge/plantuml/hector2/layering/Layer.java +++ /dev/null @@ -1,117 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.hector2.layering; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import net.sourceforge.plantuml.cucadiagram.IEntity; -import net.sourceforge.plantuml.hector2.MinMax; -import net.sourceforge.plantuml.hector2.mpos.MutationLayer; -import net.sourceforge.plantuml.hector2.mpos.MutationLayerMove; - -public class Layer { - - private final int id; - private final Map<IEntity, Integer> entities = new HashMap<IEntity, Integer>(); - - public Layer(int id) { - this.id = id; - } - - public Layer duplicate() { - final Layer result = new Layer(id); - result.entities.putAll(this.entities); - return result; - } - - public List<MutationLayer> getPossibleMutations() { - final List<MutationLayer> result = new ArrayList<MutationLayer>(); - for (Map.Entry<IEntity, Integer> ent : entities.entrySet()) { - final IEntity entity = ent.getKey(); - final int longitude = ent.getValue(); - if (isLongitudeFree(longitude + 2)) { - result.add(new MutationLayerMove(this, entity, longitude + 2)); - } - if (isLongitudeFree(longitude - 2)) { - result.add(new MutationLayerMove(this, entity, longitude - 2)); - } - } - return Collections.unmodifiableList(result); - } - - private boolean isLongitudeFree(int longitude) { - return entities.values().contains(longitude) == false; - } - - public void put(IEntity ent, int longitude) { - if (entities.containsKey(ent) == false) { - throw new IllegalArgumentException(); - } - this.entities.put(ent, longitude); - } - - public void add(IEntity ent) { - final int pos = entities.size() * 2; - this.entities.put(ent, pos); - } - - public Collection<IEntity> entities() { - return Collections.unmodifiableCollection(entities.keySet()); - } - - public int getLongitude(IEntity ent) { - return entities.get(ent); - } - - public MinMax getMinMaxLongitudes() { - return MinMax.from(entities.values()); - } - - @Override - public String toString() { - return "layer " + id + " " + entities; - } - - public final int getId() { - return id; - } - -} diff --git a/src/net/sourceforge/plantuml/hector2/layering/LayerFactory.java b/src/net/sourceforge/plantuml/hector2/layering/LayerFactory.java deleted file mode 100644 index 6a00b03..0000000 --- a/src/net/sourceforge/plantuml/hector2/layering/LayerFactory.java +++ /dev/null @@ -1,67 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.hector2.layering; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import net.sourceforge.plantuml.cucadiagram.IEntity; -import net.sourceforge.plantuml.hector2.continuity.Skeleton; - -public class LayerFactory { - - public List<Layer> getLayers(Skeleton skeleton) { - skeleton = skeleton.removeCycle(); - skeleton.computeLayers(); - final List<Layer> result = new ArrayList<Layer>(); - for (IEntity ent : skeleton.entities()) { - ensureLayer(result, ent.getHectorLayer()); - } - for (IEntity ent : skeleton.entities()) { - final int layer = ent.getHectorLayer(); - result.get(layer).add(ent); - } - return Collections.unmodifiableList(result); - } - - private void ensureLayer(List<Layer> result, int layerToAdd) { - while (result.size() <= layerToAdd) { - result.add(new Layer(result.size())); - } - - } -} diff --git a/src/net/sourceforge/plantuml/hector2/mpos/Distribution.java b/src/net/sourceforge/plantuml/hector2/mpos/Distribution.java deleted file mode 100644 index 0a54be1..0000000 --- a/src/net/sourceforge/plantuml/hector2/mpos/Distribution.java +++ /dev/null @@ -1,114 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.hector2.mpos; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -import net.sourceforge.plantuml.cucadiagram.IEntity; -import net.sourceforge.plantuml.cucadiagram.Link; -import net.sourceforge.plantuml.hector2.MinMax; -import net.sourceforge.plantuml.hector2.layering.Layer; - -public class Distribution { - - private final List<Layer> layers; - - public Distribution(List<Layer> layers) { - this.layers = new ArrayList<Layer>(layers); - } - - public Distribution mute(MutationLayer mutation) { - final Distribution result = new Distribution(this.layers); - final int idx = result.layers.indexOf(mutation.getOriginal()); - if (idx == -1) { - throw new IllegalArgumentException(); - } - result.layers.set(idx, mutation.mute()); - return result; - } - - public double cost(Collection<Link> links) { - double result = 0; - for (Link link : links) { - result += getLength(link); - } - return result; - } - - private double getLength(Link link) { - final IEntity ent1 = link.getEntity1(); - final IEntity ent2 = link.getEntity2(); - final int y1 = ent1.getHectorLayer(); - final int x1 = layers.get(y1).getLongitude(ent1); - final int y2 = ent2.getHectorLayer(); - final int x2 = layers.get(y2).getLongitude(ent2); - final int dx = x2 - x1; - final int dy = y2 - y1; - return Math.sqrt(dx * dx + dy * dy); - } - - public List<MutationLayer> getPossibleMutations() { - final List<MutationLayer> result = new ArrayList<MutationLayer>(); - for (Layer layer : layers) { - result.addAll(layer.getPossibleMutations()); - } - return Collections.unmodifiableList(result); - } - - public final List<Layer> getLayers() { - return Collections.unmodifiableList(layers); - } - - public MinMax getMinMaxLongitudes() { - MinMax result = null; - for (Layer layer : layers) { - if (result == null) { - result = layer.getMinMaxLongitudes(); - } else { - result = result.add(layer.getMinMaxLongitudes()); - } - } - return result; - } - - public double getNbLayers() { - return layers.size(); - } - -} diff --git a/src/net/sourceforge/plantuml/hector2/mpos/MutationLayer.java b/src/net/sourceforge/plantuml/hector2/mpos/MutationLayer.java deleted file mode 100644 index 611ff57..0000000 --- a/src/net/sourceforge/plantuml/hector2/mpos/MutationLayer.java +++ /dev/null @@ -1,46 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.hector2.mpos; - -import net.sourceforge.plantuml.hector2.layering.Layer; - -public interface MutationLayer { - - public Layer getOriginal(); - - public Layer mute(); - -} diff --git a/src/net/sourceforge/plantuml/hector2/mpos/MutationLayerMove.java b/src/net/sourceforge/plantuml/hector2/mpos/MutationLayerMove.java deleted file mode 100644 index 5c469ca..0000000 --- a/src/net/sourceforge/plantuml/hector2/mpos/MutationLayerMove.java +++ /dev/null @@ -1,67 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.hector2.mpos; - -import net.sourceforge.plantuml.cucadiagram.IEntity; -import net.sourceforge.plantuml.hector2.layering.Layer; - -public class MutationLayerMove implements MutationLayer { - - private final Layer layer; - private final IEntity entity; - private final int newLongitude; - - public MutationLayerMove(Layer layer, IEntity entity, int newLongitude) { - this.layer = layer; - this.entity = entity; - this.newLongitude = newLongitude; - } - - public Layer mute() { - final Layer result = layer.duplicate(); - result.put(entity, newLongitude); - return result; - } - - public Layer getOriginal() { - return layer; - } - - @Override - public String toString() { - return "{" + layer.getId() + "} " + entity + " moveto " + newLongitude; - } -} diff --git a/src/net/sourceforge/plantuml/jungle/GNodeUtils.java b/src/net/sourceforge/plantuml/jungle/GNodeUtils.java deleted file mode 100644 index 819ddbb..0000000 --- a/src/net/sourceforge/plantuml/jungle/GNodeUtils.java +++ /dev/null @@ -1,56 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.jungle; - -public class GNodeUtils { - -// public static GNode getIndirectChild(GNode root, String id) { -// if (root.getId().equals(id)) { -// return root; -// } -// for (GNode n : root.getChildren()) { -// if (n.getId().equals(id)) { -// return n; -// } -// final GNode result = getIndirectChild(n, id); -// if (result != null) { -// return result; -// } -// } -// return null; -// } - -}
\ No newline at end of file diff --git a/src/net/sourceforge/plantuml/math/AsciiMathOld.java b/src/net/sourceforge/plantuml/math/AsciiMathOld.java deleted file mode 100644 index 2dc1bfe..0000000 --- a/src/net/sourceforge/plantuml/math/AsciiMathOld.java +++ /dev/null @@ -1,151 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.math; - -import java.awt.geom.Dimension2D; -import java.awt.image.BufferedImage; -import java.io.BufferedReader; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - -import javax.script.Invocable; -import javax.script.ScriptEngine; -import javax.script.ScriptEngineManager; -import javax.script.ScriptException; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; - -import net.sourceforge.plantuml.BackSlash; -import net.sourceforge.plantuml.Dimension2DDouble; - -import org.w3c.dom.Document; -import org.w3c.dom.Node; - -public class AsciiMathOld { - - private static final String ASCIIMATH_PARSER_JS_LOCATION = "/net/sourceforge/plantuml/math/"; - - private static String JAVASCRIPT_CODE; - - static { - try { - final BufferedReader br = new BufferedReader(new InputStreamReader( - AsciiMathOld.class.getResourceAsStream(ASCIIMATH_PARSER_JS_LOCATION + "AsciiMathParser.js"), "UTF-8")); - final StringBuilder sb = new StringBuilder(); - String s = null; - while ((s = br.readLine()) != null) { - sb.append(s); - sb.append(BackSlash.NEWLINE); - } - br.close(); - JAVASCRIPT_CODE = sb.toString(); - } catch (Exception e) { - e.printStackTrace(); - } - - } - - private final Node mathML; - - public AsciiMathOld(String form) throws IOException, ScriptException, ParserConfigurationException, - NoSuchMethodException { - final ScriptEngine engine = new ScriptEngineManager().getEngineByName("JavaScript"); - engine.eval(JAVASCRIPT_CODE); - final Invocable inv = (Invocable) engine; - final Document dom = createDocument(); - mathML = (Node) inv.invokeFunction("plantuml", dom, form); - } - - private Document createDocument() throws ParserConfigurationException { - DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); - dbf.setNamespaceAware(true); - DocumentBuilder db = dbf.newDocumentBuilder(); - Document document = db.newDocument(); - return document; - } - - private Dimension2D dim; - - public String getSvg() throws IOException, ClassNotFoundException, NoSuchMethodException, SecurityException, - IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchFieldException { - final ByteArrayOutputStream baos = new ByteArrayOutputStream(); - final Class<?> clConverter = Class.forName("net.sourceforge.jeuclid.converter.Converter"); - final Method getInstance = clConverter.getMethod("getInstance"); - final Object conv = getInstance.invoke(null); - final Method convert = clConverter.getMethod("convert", Node.class, OutputStream.class, String.class, - Class.forName("net.sourceforge.jeuclid.LayoutContext")); - dim = (Dimension2D) convert.invoke(conv, mathML, baos, "image/svg+xml", getLayout()); - return new String(baos.toByteArray()); - } - - public BufferedImage getImage() throws IOException, ClassNotFoundException, NoSuchMethodException, - SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, - NoSuchFieldException { - final Class<?> clConverter = Class.forName("net.sourceforge.jeuclid.converter.Converter"); - final Method getInstance = clConverter.getMethod("getInstance"); - final Object conv = getInstance.invoke(null); - // final LayoutContext layoutContext = LayoutContextImpl.getDefaultLayoutContext(); - - final Method render = clConverter.getMethod("render", Node.class, - Class.forName("net.sourceforge.jeuclid.LayoutContext")); - - final BufferedImage result = (BufferedImage) render.invoke(conv, mathML, getLayout()); - dim = new Dimension2DDouble(result.getWidth(), result.getHeight()); - return result; - } - - private Object getLayout() throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, - InvocationTargetException, IllegalArgumentException, NoSuchFieldException, SecurityException { - final Class<?> clLayoutContextIml = Class.forName("net.sourceforge.jeuclid.context.LayoutContextImpl"); - final Class<?> clParameter = Class.forName("net.sourceforge.jeuclid.context.Parameter"); - final Method getDefaultLayoutContext = clLayoutContextIml.getMethod("getDefaultLayoutContext"); - final Object layoutContext = getDefaultLayoutContext.invoke(null); - - final Method setParameter = clLayoutContextIml.getMethod("setParameter", clParameter, Object.class); - setParameter.invoke(layoutContext, clParameter.getDeclaredField("SCRIPTSIZEMULTIPLIER").get(null), (float) 2); - return layoutContext; - } - - public Dimension2D getDimension() { - return dim; - } - -} diff --git a/src/net/sourceforge/plantuml/math/AsciiMathParser.js b/src/net/sourceforge/plantuml/math/AsciiMathParser.js deleted file mode 100644 index b44b116..0000000 --- a/src/net/sourceforge/plantuml/math/AsciiMathParser.js +++ /dev/null @@ -1,846 +0,0 @@ -/* - -Copyright (c) 2011-2012, The University of Edinburgh -All Rights Reserved - -This file is part of AsciiMathParser.js - -AsciiMathParser.js is free software; you can redistribute it and/or modify it -under the terms of the GNU Lesser General Public License as published by the -Free Software Foundation; either version 3 of the License, or (at your -option) any later version. - -AsciiMathParser.js is 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 Lesser General Public License (at -http://www.gnu.org/licences/lgpl.html) for more details. - -You should have received a copy of the GNU Lesser General Public License -along with AsciiMathParser.js. If not, see <http://www.gnu.org/licenses/lgpl.html>. - -AsciiMathParser.js -================== - -This is a modified and cut-down version of ASCIIMathML.js v2.1 -that allows ASCIIMath to be used solely as a parser for ASCIIMath -input, generating an XML Element Node as a result. - -This may allow you to integrate the ASCIIMath input format with -other software and does not need to be run in a browser. - -The only requirement is that you can provide a DOM Document Object -when creating a parser. (Microsoft's implementation of Document is fine -too.) - -*/ - -/************************************************************************/ - -/* This creates a new Object that you can use to parse ASCIIMath input. - * - * You must pass a DOM Document Object here that will be used to create - * new DOM Nodes. The Doucument itself will not be modified. - * A Microsoft DOM is acceptable. - */ -function AsciiMathParser(document) { - -/* ASCIIMathML.js BEGINS BELOW. - * - * NOTE: I did a global search and replace to make NodeList traversal - * work with the Java DOM, so that childNodes[i] -> childNodes.item(i). - * This was done with the regexp s/(childNodes)\[(.+?)\]/$1.item($2)/g - * - * All other modifications made are shown below on - * lines starting with - * '//MOD: ' - */ - -//------------------------------------------------------------- - -/* -ASCIIMathML.js -============== -This file contains JavaScript functions to convert ASCII math notation -and LaTeX to Presentation MathML. Simple graphics commands are also -translated to SVG images. The conversion is done while the (X)HTML -page loads, and should work with Firefox/Mozilla/Netscape 7+ and Internet -Explorer 6/7 + MathPlayer (http://www.dessci.com/en/products/mathplayer/) + -Adobe SVGview 3.03 (http://www.adobe.com/svg/viewer/install/). - -Just add the next line to your (X)HTML page with this file in the same folder: - -<script type="text/javascript" src="ASCIIMathML.js"></script> - -(using the graphics in IE also requires the file "d.svg" in the same folder). -This is a convenient and inexpensive solution for authoring MathML and SVG. - -Version 2.1 Oct 8, 2008, (c) Peter Jipsen http://www.chapman.edu/~jipsen -This version extends ASCIIMathML.js with LaTeXMathML.js and ASCIIsvg.js. -Latest version at http://www.chapman.edu/~jipsen/mathml/ASCIIMathML.js -If you use it on a webpage, please send the URL to jipsen@chapman.edu - -The LaTeXMathML modifications were made by Douglas Woodall, June 2006. -(for details see header on the LaTeXMathML part in middle of file) -Extensive clean-up and improvements by Paulo Soares, Oct 2007. - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as published by -the Free Software Foundation; either version 3 of the License, or (at -your option) any later version. - -This program is 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 Lesser General Public License -(at http://www.gnu.org/licences/lgpl.html) for more details. -*/ - -//MOD: Most of the global variables defined next are not required, -//MOD: with the exception of the following: -var decimalsign = "."; // change to "," if you like, beware of `(1,2)`! - -/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ - -//MOD: Everything from this point until the character list definitions starting -//MOD: with 'var AMcal' has been removed and replaced with the following: - -// This should be false here, since we're generating an XML DOM, rather than -// something that will be aimed at a specific browser. -var isIE = false; - -// New version of this method to overcome the lack of createElementNS() in MSXML -function createMmlNode(t,frag) { - var node; - if (document.createElementNS) { - node = document.createElementNS("http://www.w3.org/1998/Math/MathML", t); - } - else { - try { - /* MSXML */ - node = document.createNode(1, t, "http://www.w3.org/1998/Math/MathML"); - } - catch (e) { - throw "This DOM Document does not support either createElementNS() or createNS()"; - } - } - if (frag) node.appendChild(frag); - return node; -} - -// character lists for Mozilla/Netscape fonts -var AMcal = [0xEF35,0x212C,0xEF36,0xEF37,0x2130,0x2131,0xEF38,0x210B,0x2110,0xEF39,0xEF3A,0x2112,0x2133,0xEF3B,0xEF3C,0xEF3D,0xEF3E,0x211B,0xEF3F,0xEF40,0xEF41,0xEF42,0xEF43,0xEF44,0xEF45,0xEF46]; -var AMfrk = [0xEF5D,0xEF5E,0x212D,0xEF5F,0xEF60,0xEF61,0xEF62,0x210C,0x2111,0xEF63,0xEF64,0xEF65,0xEF66,0xEF67,0xEF68,0xEF69,0xEF6A,0x211C,0xEF6B,0xEF6C,0xEF6D,0xEF6E,0xEF6F,0xEF70,0xEF71,0x2128]; -var AMbbb = [0xEF8C,0xEF8D,0x2102,0xEF8E,0xEF8F,0xEF90,0xEF91,0x210D,0xEF92,0xEF93,0xEF94,0xEF95,0xEF96,0x2115,0xEF97,0x2119,0x211A,0x211D,0xEF98,0xEF99,0xEF9A,0xEF9B,0xEF9C,0xEF9D,0xEF9E,0x2124]; - -var CONST = 0, UNARY = 1, BINARY = 2, INFIX = 3, LEFTBRACKET = 4, - RIGHTBRACKET = 5, SPACE = 6, UNDEROVER = 7, DEFINITION = 8, - LEFTRIGHT = 9, TEXT = 10, BIG = 11, LONG = 12, STRETCHY = 13, - MATRIX = 14;; // token types - -var AMquote = {input:"\"", tag:"mtext", output:"mbox", tex:null, ttype:TEXT}; - -var AMsymbols = [ -//some greek symbols -{input:"alpha", tag:"mi", output:"\u03B1", tex:null, ttype:CONST}, -{input:"beta", tag:"mi", output:"\u03B2", tex:null, ttype:CONST}, -{input:"chi", tag:"mi", output:"\u03C7", tex:null, ttype:CONST}, -{input:"delta", tag:"mi", output:"\u03B4", tex:null, ttype:CONST}, -{input:"Delta", tag:"mo", output:"\u0394", tex:null, ttype:CONST}, -{input:"epsi", tag:"mi", output:"\u03B5", tex:"epsilon", ttype:CONST}, -{input:"varepsilon", tag:"mi", output:"\u025B", tex:null, ttype:CONST}, -{input:"eta", tag:"mi", output:"\u03B7", tex:null, ttype:CONST}, -{input:"gamma", tag:"mi", output:"\u03B3", tex:null, ttype:CONST}, -{input:"Gamma", tag:"mo", output:"\u0393", tex:null, ttype:CONST}, -{input:"iota", tag:"mi", output:"\u03B9", tex:null, ttype:CONST}, -{input:"kappa", tag:"mi", output:"\u03BA", tex:null, ttype:CONST}, -{input:"lambda", tag:"mi", output:"\u03BB", tex:null, ttype:CONST}, -{input:"Lambda", tag:"mo", output:"\u039B", tex:null, ttype:CONST}, -{input:"mu", tag:"mi", output:"\u03BC", tex:null, ttype:CONST}, -{input:"nu", tag:"mi", output:"\u03BD", tex:null, ttype:CONST}, -{input:"omega", tag:"mi", output:"\u03C9", tex:null, ttype:CONST}, -{input:"Omega", tag:"mo", output:"\u03A9", tex:null, ttype:CONST}, -{input:"phi", tag:"mi", output:"\u03C6", tex:null, ttype:CONST}, -{input:"varphi", tag:"mi", output:"\u03D5", tex:null, ttype:CONST}, -{input:"Phi", tag:"mo", output:"\u03A6", tex:null, ttype:CONST}, -{input:"pi", tag:"mi", output:"\u03C0", tex:null, ttype:CONST}, -{input:"Pi", tag:"mo", output:"\u03A0", tex:null, ttype:CONST}, -{input:"psi", tag:"mi", output:"\u03C8", tex:null, ttype:CONST}, -{input:"Psi", tag:"mi", output:"\u03A8", tex:null, ttype:CONST}, -{input:"rho", tag:"mi", output:"\u03C1", tex:null, ttype:CONST}, -{input:"sigma", tag:"mi", output:"\u03C3", tex:null, ttype:CONST}, -{input:"Sigma", tag:"mo", output:"\u03A3", tex:null, ttype:CONST}, -{input:"tau", tag:"mi", output:"\u03C4", tex:null, ttype:CONST}, -{input:"theta", tag:"mi", output:"\u03B8", tex:null, ttype:CONST}, -{input:"vartheta", tag:"mi", output:"\u03D1", tex:null, ttype:CONST}, -{input:"Theta", tag:"mo", output:"\u0398", tex:null, ttype:CONST}, -{input:"upsilon", tag:"mi", output:"\u03C5", tex:null, ttype:CONST}, -{input:"xi", tag:"mi", output:"\u03BE", tex:null, ttype:CONST}, -{input:"Xi", tag:"mo", output:"\u039E", tex:null, ttype:CONST}, -{input:"zeta", tag:"mi", output:"\u03B6", tex:null, ttype:CONST}, - -//binary operation symbols -//{input:"-", tag:"mo", output:"\u0096", tex:null, ttype:CONST}, -{input:"*", tag:"mo", output:"\u22C5", tex:"cdot", ttype:CONST}, -{input:"**", tag:"mo", output:"\u22C6", tex:"star", ttype:CONST}, -{input:"//", tag:"mo", output:"/", tex:null, ttype:CONST}, -{input:"\\\\", tag:"mo", output:"\\", tex:"backslash", ttype:CONST}, -{input:"setminus", tag:"mo", output:"\\", tex:null, ttype:CONST}, -{input:"xx", tag:"mo", output:"\u00D7", tex:"times", ttype:CONST}, -{input:"-:", tag:"mo", output:"\u00F7", tex:"divide", ttype:CONST}, -{input:"@", tag:"mo", output:"\u26AC", tex:"circ", ttype:CONST}, -{input:"o+", tag:"mo", output:"\u2295", tex:"oplus", ttype:CONST}, -{input:"ox", tag:"mo", output:"\u2297", tex:"otimes", ttype:CONST}, -{input:"o.", tag:"mo", output:"\u2299", tex:"odot", ttype:CONST}, -{input:"sum", tag:"mo", output:"\u2211", tex:null, ttype:UNDEROVER}, -{input:"prod", tag:"mo", output:"\u220F", tex:null, ttype:UNDEROVER}, -{input:"^^", tag:"mo", output:"\u2227", tex:"wedge", ttype:CONST}, -{input:"^^^", tag:"mo", output:"\u22C0", tex:"bigwedge", ttype:UNDEROVER}, -{input:"vv", tag:"mo", output:"\u2228", tex:"vee", ttype:CONST}, -{input:"vvv", tag:"mo", output:"\u22C1", tex:"bigvee", ttype:UNDEROVER}, -{input:"nn", tag:"mo", output:"\u2229", tex:"cap", ttype:CONST}, -{input:"nnn", tag:"mo", output:"\u22C2", tex:"bigcap", ttype:UNDEROVER}, -{input:"uu", tag:"mo", output:"\u222A", tex:"cup", ttype:CONST}, -{input:"uuu", tag:"mo", output:"\u22C3", tex:"bigcup", ttype:UNDEROVER}, - -//binary relation symbols -{input:"!=", tag:"mo", output:"\u2260", tex:"ne", ttype:CONST}, -{input:":=", tag:"mo", output:":=", tex:null, ttype:CONST}, -{input:"lt", tag:"mo", output:"<", tex:null, ttype:CONST}, -{input:"<=", tag:"mo", output:"\u2264", tex:"le", ttype:CONST}, -{input:"lt=", tag:"mo", output:"\u2264", tex:"leq", ttype:CONST}, -{input:">=", tag:"mo", output:"\u2265", tex:"ge", ttype:CONST}, -{input:"geq", tag:"mo", output:"\u2265", tex:null, ttype:CONST}, -{input:"-<", tag:"mo", output:"\u227A", tex:"prec", ttype:CONST}, -{input:"-lt", tag:"mo", output:"\u227A", tex:null, ttype:CONST}, -{input:">-", tag:"mo", output:"\u227B", tex:"succ", ttype:CONST}, -{input:"-<=", tag:"mo", output:"\u2AAF", tex:"preceq", ttype:CONST}, -{input:">-=", tag:"mo", output:"\u2AB0", tex:"succeq", ttype:CONST}, -{input:"in", tag:"mo", output:"\u2208", tex:null, ttype:CONST}, -{input:"!in", tag:"mo", output:"\u2209", tex:"notin", ttype:CONST}, -{input:"sub", tag:"mo", output:"\u2282", tex:"subset", ttype:CONST}, -{input:"sup", tag:"mo", output:"\u2283", tex:"supset", ttype:CONST}, -{input:"sube", tag:"mo", output:"\u2286", tex:"subseteq", ttype:CONST}, -{input:"supe", tag:"mo", output:"\u2287", tex:"supseteq", ttype:CONST}, -{input:"-=", tag:"mo", output:"\u2261", tex:"equiv", ttype:CONST}, -{input:"~=", tag:"mo", output:"\u2245", tex:"cong", ttype:CONST}, -{input:"~~", tag:"mo", output:"\u2248", tex:"approx", ttype:CONST}, -{input:"prop", tag:"mo", output:"\u221D", tex:"propto", ttype:CONST}, - -//logical symbols -{input:"and", tag:"mtext", output:"and", tex:null, ttype:SPACE}, -{input:"or", tag:"mtext", output:"or", tex:null, ttype:SPACE}, -{input:"not", tag:"mo", output:"\u00AC", tex:"neg", ttype:CONST}, -{input:"=>", tag:"mo", output:"\u21D2", tex:"implies", ttype:CONST}, -{input:"if", tag:"mo", output:"if", tex:null, ttype:SPACE}, -{input:"<=>", tag:"mo", output:"\u21D4", tex:"iff", ttype:CONST}, -{input:"AA", tag:"mo", output:"\u2200", tex:"forall", ttype:CONST}, -{input:"EE", tag:"mo", output:"\u2203", tex:"exists", ttype:CONST}, -{input:"_|_", tag:"mo", output:"\u22A5", tex:"bot", ttype:CONST}, -{input:"TT", tag:"mo", output:"\u22A4", tex:"top", ttype:CONST}, -{input:"|--", tag:"mo", output:"\u22A2", tex:"vdash", ttype:CONST}, -{input:"|==", tag:"mo", output:"\u22A8", tex:"models", ttype:CONST}, - -//grouping brackets -{input:"(", tag:"mo", output:"(", tex:null, ttype:LEFTBRACKET}, -{input:")", tag:"mo", output:")", tex:null, ttype:RIGHTBRACKET}, -{input:"[", tag:"mo", output:"[", tex:null, ttype:LEFTBRACKET}, -{input:"]", tag:"mo", output:"]", tex:null, ttype:RIGHTBRACKET}, -{input:"{", tag:"mo", output:"{", tex:null, ttype:LEFTBRACKET}, -{input:"}", tag:"mo", output:"}", tex:null, ttype:RIGHTBRACKET}, -{input:"|", tag:"mo", output:"|", tex:null, ttype:LEFTRIGHT}, -//{input:"||", tag:"mo", output:"||", tex:null, ttype:LEFTRIGHT}, -{input:"(:", tag:"mo", output:"\u2329", tex:"langle", ttype:LEFTBRACKET}, -{input:":)", tag:"mo", output:"\u232A", tex:"rangle", ttype:RIGHTBRACKET}, -{input:"<<", tag:"mo", output:"\u2329", tex:null, ttype:LEFTBRACKET}, -{input:">>", tag:"mo", output:"\u232A", tex:null, ttype:RIGHTBRACKET}, -{input:"{:", tag:"mo", output:"{:", tex:null, ttype:LEFTBRACKET, invisible:true}, -{input:":}", tag:"mo", output:":}", tex:null, ttype:RIGHTBRACKET, invisible:true}, - -//miscellaneous symbols -{input:"int", tag:"mo", output:"\u222B", tex:null, ttype:CONST}, -{input:"dx", tag:"mi", output:"{:d x:}", tex:null, ttype:DEFINITION}, -{input:"dy", tag:"mi", output:"{:d y:}", tex:null, ttype:DEFINITION}, -{input:"dz", tag:"mi", output:"{:d z:}", tex:null, ttype:DEFINITION}, -{input:"dt", tag:"mi", output:"{:d t:}", tex:null, ttype:DEFINITION}, -{input:"oint", tag:"mo", output:"\u222E", tex:null, ttype:CONST}, -{input:"del", tag:"mo", output:"\u2202", tex:"partial", ttype:CONST}, -{input:"grad", tag:"mo", output:"\u2207", tex:"nabla", ttype:CONST}, -{input:"+-", tag:"mo", output:"\u00B1", tex:"pm", ttype:CONST}, -{input:"O/", tag:"mo", output:"\u2205", tex:"emptyset", ttype:CONST}, -{input:"oo", tag:"mo", output:"\u221E", tex:"infty", ttype:CONST}, -{input:"aleph", tag:"mo", output:"\u2135", tex:null, ttype:CONST}, -{input:"...", tag:"mo", output:"...", tex:"ldots", ttype:CONST}, -{input:":.", tag:"mo", output:"\u2234", tex:"therefore", ttype:CONST}, -{input:"/_", tag:"mo", output:"\u2220", tex:"angle", ttype:CONST}, -{input:"\\ ", tag:"mo", output:"\u00A0", tex:null, ttype:CONST}, -{input:"quad", tag:"mo", output:"\u00A0\u00A0", tex:null, ttype:CONST}, -{input:"qquad", tag:"mo", output:"\u00A0\u00A0\u00A0\u00A0", tex:null, ttype:CONST}, -{input:"cdots", tag:"mo", output:"\u22EF", tex:null, ttype:CONST}, -{input:"vdots", tag:"mo", output:"\u22EE", tex:null, ttype:CONST}, -{input:"ddots", tag:"mo", output:"\u22F1", tex:null, ttype:CONST}, -{input:"diamond", tag:"mo", output:"\u22C4", tex:null, ttype:CONST}, -{input:"square", tag:"mo", output:"\u25A1", tex:null, ttype:CONST}, -{input:"|__", tag:"mo", output:"\u230A", tex:"lfloor", ttype:CONST}, -{input:"__|", tag:"mo", output:"\u230B", tex:"rfloor", ttype:CONST}, -{input:"|~", tag:"mo", output:"\u2308", tex:"lceiling", ttype:CONST}, -{input:"~|", tag:"mo", output:"\u2309", tex:"rceiling", ttype:CONST}, -{input:"CC", tag:"mo", output:"\u2102", tex:null, ttype:CONST}, -{input:"NN", tag:"mo", output:"\u2115", tex:null, ttype:CONST}, -{input:"QQ", tag:"mo", output:"\u211A", tex:null, ttype:CONST}, -{input:"RR", tag:"mo", output:"\u211D", tex:null, ttype:CONST}, -{input:"ZZ", tag:"mo", output:"\u2124", tex:null, ttype:CONST}, -{input:"f", tag:"mi", output:"f", tex:null, ttype:UNARY, func:true}, -{input:"g", tag:"mi", output:"g", tex:null, ttype:UNARY, func:true}, - -//standard functions -{input:"lim", tag:"mo", output:"lim", tex:null, ttype:UNDEROVER}, -{input:"Lim", tag:"mo", output:"Lim", tex:null, ttype:UNDEROVER}, -{input:"sin", tag:"mo", output:"sin", tex:null, ttype:UNARY, func:true}, -{input:"cos", tag:"mo", output:"cos", tex:null, ttype:UNARY, func:true}, -{input:"tan", tag:"mo", output:"tan", tex:null, ttype:UNARY, func:true}, -{input:"sinh", tag:"mo", output:"sinh", tex:null, ttype:UNARY, func:true}, -{input:"cosh", tag:"mo", output:"cosh", tex:null, ttype:UNARY, func:true}, -{input:"tanh", tag:"mo", output:"tanh", tex:null, ttype:UNARY, func:true}, -{input:"cot", tag:"mo", output:"cot", tex:null, ttype:UNARY, func:true}, -{input:"sec", tag:"mo", output:"sec", tex:null, ttype:UNARY, func:true}, -{input:"csc", tag:"mo", output:"csc", tex:null, ttype:UNARY, func:true}, -{input:"log", tag:"mo", output:"log", tex:null, ttype:UNARY, func:true}, -{input:"ln", tag:"mo", output:"ln", tex:null, ttype:UNARY, func:true}, -{input:"det", tag:"mo", output:"det", tex:null, ttype:UNARY, func:true}, -{input:"dim", tag:"mo", output:"dim", tex:null, ttype:CONST}, -{input:"mod", tag:"mo", output:"mod", tex:null, ttype:CONST}, -{input:"gcd", tag:"mo", output:"gcd", tex:null, ttype:UNARY, func:true}, -{input:"lcm", tag:"mo", output:"lcm", tex:null, ttype:UNARY, func:true}, -{input:"lub", tag:"mo", output:"lub", tex:null, ttype:CONST}, -{input:"glb", tag:"mo", output:"glb", tex:null, ttype:CONST}, -{input:"min", tag:"mo", output:"min", tex:null, ttype:UNDEROVER}, -{input:"max", tag:"mo", output:"max", tex:null, ttype:UNDEROVER}, - -//arrows -{input:"uarr", tag:"mo", output:"\u2191", tex:"uparrow", ttype:CONST}, -{input:"darr", tag:"mo", output:"\u2193", tex:"downarrow", ttype:CONST}, -{input:"rarr", tag:"mo", output:"\u2192", tex:"rightarrow", ttype:CONST}, -{input:"->", tag:"mo", output:"\u2192", tex:"to", ttype:CONST}, -{input:">->", tag:"mo", output:"\u21A3", tex:"rightarrowtail", ttype:CONST}, -{input:"->>", tag:"mo", output:"\u21A0", tex:"twoheadrightarrow", ttype:CONST}, -{input:">->>", tag:"mo", output:"\u2916", tex:"twoheadrightarrowtail", ttype:CONST}, -{input:"|->", tag:"mo", output:"\u21A6", tex:"mapsto", ttype:CONST}, -{input:"larr", tag:"mo", output:"\u2190", tex:"leftarrow", ttype:CONST}, -{input:"harr", tag:"mo", output:"\u2194", tex:"leftrightarrow", ttype:CONST}, -{input:"rArr", tag:"mo", output:"\u21D2", tex:"Rightarrow", ttype:CONST}, -{input:"lArr", tag:"mo", output:"\u21D0", tex:"Leftarrow", ttype:CONST}, -{input:"hArr", tag:"mo", output:"\u21D4", tex:"Leftrightarrow", ttype:CONST}, -//commands with argument -{input:"sqrt", tag:"msqrt", output:"sqrt", tex:null, ttype:UNARY}, -{input:"root", tag:"mroot", output:"root", tex:null, ttype:BINARY}, -{input:"frac", tag:"mfrac", output:"/", tex:null, ttype:BINARY}, -{input:"/", tag:"mfrac", output:"/", tex:null, ttype:INFIX}, -{input:"stackrel", tag:"mover", output:"stackrel", tex:null, ttype:BINARY}, -{input:"_", tag:"msub", output:"_", tex:null, ttype:INFIX}, -{input:"^", tag:"msup", output:"^", tex:null, ttype:INFIX}, -{input:"hat", tag:"mover", output:"\u005E", tex:null, ttype:UNARY, acc:true}, -{input:"bar", tag:"mover", output:"\u00AF", tex:"overline", ttype:UNARY, acc:true}, -{input:"vec", tag:"mover", output:"\u2192", tex:null, ttype:UNARY, acc:true}, -{input:"dot", tag:"mover", output:".", tex:null, ttype:UNARY, acc:true}, -{input:"ddot", tag:"mover", output:"..", tex:null, ttype:UNARY, acc:true}, -{input:"ul", tag:"munder", output:"\u0332", tex:"underline", ttype:UNARY, acc:true}, -{input:"text", tag:"mtext", output:"text", tex:null, ttype:TEXT}, -{input:"mbox", tag:"mtext", output:"mbox", tex:null, ttype:TEXT}, -AMquote, -{input:"bb", tag:"mstyle", atname:"fontweight", atval:"bold", output:"bb", tex:null, ttype:UNARY}, -{input:"mathbf", tag:"mstyle", atname:"fontweight", atval:"bold", output:"mathbf", tex:null, ttype:UNARY}, -{input:"sf", tag:"mstyle", atname:"fontfamily", atval:"sans-serif", output:"sf", tex:null, ttype:UNARY}, -{input:"mathsf", tag:"mstyle", atname:"fontfamily", atval:"sans-serif", output:"mathsf", tex:null, ttype:UNARY}, -{input:"bbb", tag:"mstyle", atname:"mathvariant", atval:"double-struck", output:"bbb", tex:null, ttype:UNARY, codes:AMbbb}, -{input:"mathbb", tag:"mstyle", atname:"mathvariant", atval:"double-struck", output:"mathbb", tex:null, ttype:UNARY, codes:AMbbb}, -{input:"cc", tag:"mstyle", atname:"mathvariant", atval:"script", output:"cc", tex:null, ttype:UNARY, codes:AMcal}, -{input:"mathcal", tag:"mstyle", atname:"mathvariant", atval:"script", output:"mathcal", tex:null, ttype:UNARY, codes:AMcal}, -{input:"tt", tag:"mstyle", atname:"fontfamily", atval:"monospace", output:"tt", tex:null, ttype:UNARY}, -{input:"mathtt", tag:"mstyle", atname:"fontfamily", atval:"monospace", output:"mathtt", tex:null, ttype:UNARY}, -{input:"fr", tag:"mstyle", atname:"mathvariant", atval:"fraktur", output:"fr", tex:null, ttype:UNARY, codes:AMfrk}, -{input:"mathfrak", tag:"mstyle", atname:"mathvariant", atval:"fraktur", output:"mathfrak", tex:null, ttype:UNARY, codes:AMfrk} -]; - -function compareNames(s1,s2) { - if (s1.input > s2.input) return 1 - else return -1; -} - -var AMnames = []; //list of input symbols - -function initSymbols() { - var texsymbols = [], i; - for (i=0; i<AMsymbols.length; i++) - if (AMsymbols[i].tex) - texsymbols[texsymbols.length] = {input:AMsymbols[i].tex, - tag:AMsymbols[i].tag, output:AMsymbols[i].output, ttype:AMsymbols[i].ttype}; - AMsymbols = AMsymbols.concat(texsymbols); - refreshSymbols(); -} - -function refreshSymbols(){ - var i; - AMsymbols.sort(compareNames); - for (i=0; i<AMsymbols.length; i++) AMnames[i] = AMsymbols[i].input; -//MOD: The following lines are commented out as we're not supporting LaTeX input -// LMsymbols.sort(compareNames); -// for (i=0; i<LMsymbols.length; i++) LMnames[i] = LMsymbols[i].input; -} - -function define(oldstr,newstr) { -//MOD: The following lines are commented out as we're not supporting LaTeX input -// if(oldstr.substr(0,1)=="\\") -// LMsymbols = LMsymbols.concat([{input:oldstr, tag:"mo", output:newstr, -// ttype:DEFINITION}]); -// else - AMsymbols = AMsymbols.concat([{input:oldstr, tag:"mo", output:newstr, - tex:null, ttype:DEFINITION}]); - refreshSymbols(); // this may be a problem if many symbols are defined! -} - - -function AMremoveCharsAndBlanks(str,n) { -//remove n characters and any following blanks - var st; - if (str.charAt(n)=="\\" && str.charAt(n+1)!="\\" && str.charAt(n+1)!=" ") - st = str.slice(n+1); - else st = str.slice(n); - for (var i=0; i<st.length && st.charCodeAt(i)<=32; i=i+1); - return st.slice(i); -} - -function position(arr, str, n) { -// return position >=n where str appears or would be inserted -// assumes arr is sorted - if (n==0) { - var h,m; - n = -1; - h = arr.length; - while (n+1<h) { - m = (n+h) >> 1; - if (arr[m]<str) n = m; else h = m; - } - return h; - } else - for (var i=n; i<arr.length && arr[i]<str; i++); - return i; // i=arr.length || arr[i]>=str -} - -function AMgetSymbol(str) { -//return maximal initial substring of str that appears in names -//return null if there is none - var k = 0; //new pos - var j = 0; //old pos - var mk; //match pos - var st; - var tagst; - var match = ""; - var more = true; - for (var i=1; i<=str.length && more; i++) { - st = str.slice(0,i); //initial substring of length i - j = k; - k = position(AMnames, st, j); - if (k<AMnames.length && str.slice(0,AMnames[k].length)==AMnames[k]){ - match = AMnames[k]; - mk = k; - i = match.length; - } - more = k<AMnames.length && str.slice(0,AMnames[k].length)>=AMnames[k]; - } - AMpreviousSymbol=AMcurrentSymbol; - if (match!=""){ - AMcurrentSymbol=AMsymbols[mk].ttype; - return AMsymbols[mk]; - } -// if str[0] is a digit or - return maxsubstring of digits.digits - AMcurrentSymbol=CONST; - k = 1; - st = str.slice(0,1); - var integ = true; - while ("0"<=st && st<="9" && k<=str.length) { - st = str.slice(k,k+1); - k++; - } - if (st == decimalsign) { - st = str.slice(k,k+1); - if ("0"<=st && st<="9") { - integ = false; - k++; - while ("0"<=st && st<="9" && k<=str.length) { - st = str.slice(k,k+1); - k++; - } - } - } - if ((integ && k>1) || k>2) { - st = str.slice(0,k-1); - tagst = "mn"; - } else { - k = 2; - st = str.slice(0,1); //take 1 character - tagst = (("A">st || st>"Z") && ("a">st || st>"z")?"mo":"mi"); - } - if (st=="-" && AMpreviousSymbol==INFIX) { - AMcurrentSymbol = INFIX; //trick "/" into recognizing "-" on second parse - return {input:st, tag:tagst, output:st, ttype:UNARY, func:true}; - } - return {input:st, tag:tagst, output:st, ttype:CONST}; -} - -function AMremoveBrackets(node) { - var st; - if (node.nodeName=="mrow") { - st = node.firstChild.firstChild.nodeValue; - if (st=="(" || st=="[" || st=="{") node.removeChild(node.firstChild); - } - if (node.nodeName=="mrow") { - st = node.lastChild.firstChild.nodeValue; - if (st==")" || st=="]" || st=="}") node.removeChild(node.lastChild); - } -} - -/*Parsing ASCII math expressions with the following grammar -v ::= [A-Za-z] | greek letters | numbers | other constant symbols -u ::= sqrt | text | bb | other unary symbols for font commands -b ::= frac | root | stackrel binary symbols -l ::= ( | [ | { | (: | {: left brackets -r ::= ) | ] | } | :) | :} right brackets -S ::= v | lEr | uS | bSS Simple expression -I ::= S_S | S^S | S_S^S | S Intermediate expression -E ::= IE | I/I Expression -Each terminal symbol is translated into a corresponding mathml node.*/ - -var AMnestingDepth,AMpreviousSymbol,AMcurrentSymbol; - -function AMparseSexpr(str) { //parses str and returns [node,tailstr] - var symbol, node, result, i, st,// rightvert = false, - newFrag = document.createDocumentFragment(); - str = AMremoveCharsAndBlanks(str,0); - symbol = AMgetSymbol(str); //either a token or a bracket or empty - if (symbol == null || symbol.ttype == RIGHTBRACKET && AMnestingDepth > 0) { - return [null,str]; - } - if (symbol.ttype == DEFINITION) { - str = symbol.output+AMremoveCharsAndBlanks(str,symbol.input.length); - symbol = AMgetSymbol(str); - } - switch (symbol.ttype) { case UNDEROVER: - case CONST: - str = AMremoveCharsAndBlanks(str,symbol.input.length); - return [createMmlNode(symbol.tag, //its a constant - document.createTextNode(symbol.output)),str]; - case LEFTBRACKET: //read (expr+) - AMnestingDepth++; - str = AMremoveCharsAndBlanks(str,symbol.input.length); - result = AMparseExpr(str,true); - AMnestingDepth--; - if (typeof symbol.invisible == "boolean" && symbol.invisible) - node = createMmlNode("mrow",result[0]); - else { - node = createMmlNode("mo",document.createTextNode(symbol.output)); - node = createMmlNode("mrow",node); - node.appendChild(result[0]); - } - return [node,result[1]]; - case TEXT: - if (symbol!=AMquote) str = AMremoveCharsAndBlanks(str,symbol.input.length); - if (str.charAt(0)=="{") i=str.indexOf("}"); - else if (str.charAt(0)=="(") i=str.indexOf(")"); - else if (str.charAt(0)=="[") i=str.indexOf("]"); - else if (symbol==AMquote) i=str.slice(1).indexOf("\"")+1; - else i = 0; - if (i==-1) i = str.length; - st = str.slice(1,i); - if (st.charAt(0) == " ") { - node = createMmlNode("mspace"); - node.setAttribute("width","1ex"); - newFrag.appendChild(node); - } - newFrag.appendChild( - createMmlNode(symbol.tag,document.createTextNode(st))); - if (st.charAt(st.length-1) == " ") { - node = createMmlNode("mspace"); - node.setAttribute("width","1ex"); - newFrag.appendChild(node); - } - str = AMremoveCharsAndBlanks(str,i+1); - return [createMmlNode("mrow",newFrag),str]; - case UNARY: - str = AMremoveCharsAndBlanks(str,symbol.input.length); - result = AMparseSexpr(str); - if (result[0]==null) return [createMmlNode(symbol.tag, - document.createTextNode(symbol.output)),str]; - if (typeof symbol.func == "boolean" && symbol.func) { // functions hack - st = str.charAt(0); - if (st=="^" || st=="_" || st=="/" || st=="|" || st==",") { - return [createMmlNode(symbol.tag, - document.createTextNode(symbol.output)),str]; - } else { - node = createMmlNode("mrow", - createMmlNode(symbol.tag,document.createTextNode(symbol.output))); - node.appendChild(result[0]); - return [node,result[1]]; - } - } - AMremoveBrackets(result[0]); - if (symbol.input == "sqrt") { // sqrt - return [createMmlNode(symbol.tag,result[0]),result[1]]; - } else if (typeof symbol.acc == "boolean" && symbol.acc) { // accent - node = createMmlNode(symbol.tag,result[0]); - node.appendChild(createMmlNode("mo",document.createTextNode(symbol.output))); - return [node,result[1]]; - } else { // font change command -// MOD: The following code generates invalid MathML, so is commented out for the time being. -// if (!isIE && typeof symbol.codes != "undefined") { -// for (i=0; i<result[0].childNodes.length; i++) -// if (result[0].childNodes.item(i).nodeName=="mi" || result[0].nodeName=="mi") { -// st = (result[0].nodeName=="mi"?result[0].firstChild.nodeValue: -// result[0].childNodes.item(i).firstChild.nodeValue); -// var newst = []; -// for (var j=0; j<st.length; j++) -// if (st.charCodeAt(j)>64 && st.charCodeAt(j)<91) newst = newst + -// String.fromCharCode(symbol.codes[st.charCodeAt(j)-65]); -// else newst = newst + st.charAt(j); -// if (result[0].nodeName=="mi") { -// result[0]=createMmlNode("mo"). -// appendChild(document.createTextNode(newst)); -// } -// else result[0].replaceChild(createMmlNode("mo"). -// appendChild(document.createTextNode(newst)), -// result[0].childNodes.item(i)); -// } -// } - node = createMmlNode(symbol.tag,result[0]); - node.setAttribute(symbol.atname,symbol.atval); - return [node,result[1]]; - } - case BINARY: - str = AMremoveCharsAndBlanks(str,symbol.input.length); - result = AMparseSexpr(str); - if (result[0]==null) return [createMmlNode("mo", - document.createTextNode(symbol.input)),str]; - AMremoveBrackets(result[0]); - var result2 = AMparseSexpr(result[1]); - if (result2[0]==null) return [createMmlNode("mo", - document.createTextNode(symbol.input)),str]; - AMremoveBrackets(result2[0]); - if (symbol.input=="root" || symbol.input=="stackrel") - newFrag.appendChild(result2[0]); - newFrag.appendChild(result[0]); - if (symbol.input=="frac") newFrag.appendChild(result2[0]); - return [createMmlNode(symbol.tag,newFrag),result2[1]]; - case INFIX: - str = AMremoveCharsAndBlanks(str,symbol.input.length); - return [createMmlNode("mo",document.createTextNode(symbol.output)),str]; - case SPACE: - str = AMremoveCharsAndBlanks(str,symbol.input.length); - node = createMmlNode("mspace"); - node.setAttribute("width","1ex"); - newFrag.appendChild(node); - newFrag.appendChild( - createMmlNode(symbol.tag,document.createTextNode(symbol.output))); - node = createMmlNode("mspace"); - node.setAttribute("width","1ex"); - newFrag.appendChild(node); - return [createMmlNode("mrow",newFrag),str]; - case LEFTRIGHT: -// if (rightvert) return [null,str]; else rightvert = true; - AMnestingDepth++; - str = AMremoveCharsAndBlanks(str,symbol.input.length); - result = AMparseExpr(str,false); - AMnestingDepth--; - var st = ""; - if (result[0].lastChild!=null) - st = result[0].lastChild.firstChild.nodeValue; - if (st == "|") { // its an absolute value subterm - node = createMmlNode("mo",document.createTextNode(symbol.output)); - node = createMmlNode("mrow",node); - node.appendChild(result[0]); - return [node,result[1]]; - } else { // the "|" is a \mid so use unicode 2223 (divides) for spacing - node = createMmlNode("mo",document.createTextNode("\u2223")); - node = createMmlNode("mrow",node); - return [node,str]; - } - default: -//alert("default"); - str = AMremoveCharsAndBlanks(str,symbol.input.length); - return [createMmlNode(symbol.tag, //its a constant - document.createTextNode(symbol.output)),str]; - } -} - -function AMparseIexpr(str) { - var symbol, sym1, sym2, node, result, underover; - str = AMremoveCharsAndBlanks(str,0); - sym1 = AMgetSymbol(str); - result = AMparseSexpr(str); - node = result[0]; - str = result[1]; - symbol = AMgetSymbol(str); - if (symbol.ttype == INFIX && symbol.input != "/") { - str = AMremoveCharsAndBlanks(str,symbol.input.length); -// if (symbol.input == "/") result = AMparseIexpr(str); else ... - result = AMparseSexpr(str); - if (result[0] == null) // show box in place of missing argument - result[0] = createMmlNode("mo",document.createTextNode("\u25A1")); - else AMremoveBrackets(result[0]); - str = result[1]; -// if (symbol.input == "/") AMremoveBrackets(node); - if (symbol.input == "_") { - sym2 = AMgetSymbol(str); - underover = (sym1.ttype == UNDEROVER); - if (sym2.input == "^") { - str = AMremoveCharsAndBlanks(str,sym2.input.length); - var res2 = AMparseSexpr(str); - AMremoveBrackets(res2[0]); - str = res2[1]; - node = createMmlNode((underover?"munderover":"msubsup"),node); - node.appendChild(result[0]); - node.appendChild(res2[0]); - node = createMmlNode("mrow",node); // so sum does not stretch - } else { - node = createMmlNode((underover?"munder":"msub"),node); - node.appendChild(result[0]); - } - } else { - node = createMmlNode(symbol.tag,node); - node.appendChild(result[0]); - } - } - return [node,str]; -} - -function AMparseExpr(str,rightbracket) { - var symbol, node, result, i, nodeList = [], - newFrag = document.createDocumentFragment(); - do { - str = AMremoveCharsAndBlanks(str,0); - result = AMparseIexpr(str); - node = result[0]; - str = result[1]; - symbol = AMgetSymbol(str); - if (symbol.ttype == INFIX && symbol.input == "/") { - str = AMremoveCharsAndBlanks(str,symbol.input.length); - result = AMparseIexpr(str); - if (result[0] == null) // show box in place of missing argument - result[0] = createMmlNode("mo",document.createTextNode("\u25A1")); - else AMremoveBrackets(result[0]); - str = result[1]; - AMremoveBrackets(node); - node = createMmlNode(symbol.tag,node); - node.appendChild(result[0]); - newFrag.appendChild(node); - symbol = AMgetSymbol(str); - } - else if (node!=undefined) newFrag.appendChild(node); - } while ((symbol.ttype != RIGHTBRACKET && - (symbol.ttype != LEFTRIGHT || rightbracket) - || AMnestingDepth == 0) && symbol!=null && symbol.output!=""); - if (symbol.ttype == RIGHTBRACKET || symbol.ttype == LEFTRIGHT) { -// if (AMnestingDepth > 0) AMnestingDepth--; - var len = newFrag.childNodes.length; - if (len>0 && newFrag.childNodes.item(len-1).nodeName == "mrow" && len>1 && - newFrag.childNodes.item(len-2).nodeName == "mo" && - newFrag.childNodes.item(len-2).firstChild.nodeValue == ",") { //matrix - var right = newFrag.childNodes.item(len-1).lastChild.firstChild.nodeValue; - if (right==")" || right=="]") { - var left = newFrag.childNodes.item(len-1).firstChild.firstChild.nodeValue; - if (left=="(" && right==")" && symbol.output != "}" || - left=="[" && right=="]") { - var pos = []; // positions of commas - var matrix = true; - var m = newFrag.childNodes.length; - for (i=0; matrix && i<m; i=i+2) { - pos[i] = []; - node = newFrag.childNodes.item(i); - if (matrix) matrix = node.nodeName=="mrow" && - (i==m-1 || node.nextSibling.nodeName=="mo" && - node.nextSibling.firstChild.nodeValue==",")&& - node.firstChild.firstChild.nodeValue==left && - node.lastChild.firstChild.nodeValue==right; - if (matrix) - for (var j=0; j<node.childNodes.length; j++) - if (node.childNodes.item(j).firstChild.nodeValue==",") - pos[i][pos[i].length]=j; - if (matrix && i>1) matrix = pos[i].length == pos[i-2].length; - } - if (matrix) { - var row, frag, n, k, table = document.createDocumentFragment(); - for (i=0; i<m; i=i+2) { - row = document.createDocumentFragment(); - frag = document.createDocumentFragment(); - node = newFrag.firstChild; // <mrow>(-,-,...,-,-)</mrow> - n = node.childNodes.length; - k = 0; - node.removeChild(node.firstChild); //remove ( - for (j=1; j<n-1; j++) { - if (typeof pos[i][k] != "undefined" && j==pos[i][k]){ - node.removeChild(node.firstChild); //remove , - row.appendChild(createMmlNode("mtd",frag)); - k++; - } else frag.appendChild(node.firstChild); - } - row.appendChild(createMmlNode("mtd",frag)); - if (newFrag.childNodes.length>2) { - newFrag.removeChild(newFrag.firstChild); //remove <mrow>)</mrow> - newFrag.removeChild(newFrag.firstChild); //remove <mo>,</mo> - } - table.appendChild(createMmlNode("mtr",row)); - } - node = createMmlNode("mtable",table); - if (typeof symbol.invisible == "boolean" && symbol.invisible) node.setAttribute("columnalign","left"); - newFrag.replaceChild(node,newFrag.firstChild); - } - } - } - } - str = AMremoveCharsAndBlanks(str,symbol.input.length); - if (typeof symbol.invisible != "boolean" || !symbol.invisible) { - node = createMmlNode("mo",document.createTextNode(symbol.output)); - newFrag.appendChild(node); - } - } - return [newFrag,str]; -} - -//MOD: The rest of the code is not required! - -//------------------------------------------------------------- - -/* ASCIIMathML.js has ended! */ - -initSymbols(); - -/* Parses the given ASCIIMathInput, returning a <math> DOM Element */ -this.parseAsciiMathInput = function(asciiMathInput) { - var options = arguments[1] || {}; - - /* Call up ASCIIMath to do the actual parsing, generating a document fragment */ - var content = AMparseExpr(asciiMathInput.replace(/^\s+/g,""), false)[0]; - - /* If adding source annotation, then we need to wrap things up appropriately */ - if (options.addSourceAnnotation) { - var semantics = createMmlNode("semantics", content.length==1 ? content : createMmlNode("mrow", content)); - - var annotation = createMmlNode("annotation", document.createTextNode(asciiMathInput)); - annotation.setAttribute("encoding", "ASCIIMathInput"); - semantics.appendChild(annotation); - - content = semantics; - } - - /* Create the containing <math> element */ - var math = createMmlNode("math", content); - if (options.displayMode) { - math.setAttribute("display", "block"); - } - return math; -}; - -// (end of unindented constructor defined at top of file) -}; -function plantuml(dom, asciiMathInput) { - var asciiMathParser = new AsciiMathParser(dom); - var mathElement = asciiMathParser.parseAsciiMathInput(asciiMathInput); - return mathElement; -} diff --git a/src/net/sourceforge/plantuml/mda/MDADiagramImpl.java b/src/net/sourceforge/plantuml/mda/MDADiagramImpl.java deleted file mode 100644 index 851b7ad..0000000 --- a/src/net/sourceforge/plantuml/mda/MDADiagramImpl.java +++ /dev/null @@ -1,85 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.mda; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -import net.sourceforge.plantuml.BlockUml; -import net.sourceforge.plantuml.SourceStringReader; -import net.sourceforge.plantuml.api.mda.option2.MDADiagram; -import net.sourceforge.plantuml.api.mda.option2.MDAPackage; -import net.sourceforge.plantuml.classdiagram.ClassDiagram; -import net.sourceforge.plantuml.core.Diagram; -import net.sourceforge.plantuml.cucadiagram.IGroup; -import net.sourceforge.plantuml.cucadiagram.entity.EntityFactory; - -public class MDADiagramImpl implements MDADiagram { - - public static MDADiagram create(String uml) { - List<BlockUml> blocks = new SourceStringReader(uml).getBlocks(); - if (blocks.size() == 0) { - uml = "@startuml\n" + uml + "\n@enduml"; - blocks = new SourceStringReader(uml).getBlocks(); - if (blocks.size() == 0) { - return null; - } - } - final BlockUml block = blocks.get(0); - final Diagram diagram = block.getDiagram(); - if (diagram instanceof ClassDiagram) { - return new MDADiagramImpl((ClassDiagram) diagram); - } - return null; - } - - private final Collection<MDAPackage> packages = new ArrayList<MDAPackage>(); - - private MDADiagramImpl(ClassDiagram classDiagram) { - final EntityFactory entityFactory = classDiagram.getEntityFactory(); - packages.add(new MDAPackageImpl(entityFactory.getRootGroup())); - for (IGroup group : entityFactory.getGroupsvalues()) { - packages.add(new MDAPackageImpl(group)); - } - } - - public Collection<MDAPackage> getPackages() { - return Collections.unmodifiableCollection(packages); - } - -} diff --git a/src/net/sourceforge/plantuml/mda/MDAEntityImpl.java b/src/net/sourceforge/plantuml/mda/MDAEntityImpl.java deleted file mode 100644 index 757fb94..0000000 --- a/src/net/sourceforge/plantuml/mda/MDAEntityImpl.java +++ /dev/null @@ -1,53 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.mda; - -import net.sourceforge.plantuml.api.mda.option2.MDAEntity; -import net.sourceforge.plantuml.cucadiagram.ILeaf; - -public class MDAEntityImpl implements MDAEntity { - - private final ILeaf leaf; - - public MDAEntityImpl(ILeaf leaf) { - this.leaf = leaf; - } - - public String getName() { - return leaf.getCode().getFullName(); - } - -} diff --git a/src/net/sourceforge/plantuml/mda/MDAPackageImpl.java b/src/net/sourceforge/plantuml/mda/MDAPackageImpl.java deleted file mode 100644 index 5d26810..0000000 --- a/src/net/sourceforge/plantuml/mda/MDAPackageImpl.java +++ /dev/null @@ -1,71 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.mda; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; - -import net.sourceforge.plantuml.api.mda.option2.MDAEntity; -import net.sourceforge.plantuml.api.mda.option2.MDAPackage; -import net.sourceforge.plantuml.cucadiagram.GroupRoot; -import net.sourceforge.plantuml.cucadiagram.IGroup; -import net.sourceforge.plantuml.cucadiagram.ILeaf; - -public class MDAPackageImpl implements MDAPackage { - - private final Collection<MDAEntity> entities = new ArrayList<MDAEntity>(); - private final IGroup group; - - public MDAPackageImpl(IGroup group) { - this.group = group; - for (ILeaf leaf : group.getLeafsDirect()) { - entities.add(new MDAEntityImpl(leaf)); - } - } - - public Collection<MDAEntity> getEntities() { - return Collections.unmodifiableCollection(entities); - } - - public String getName() { - if (group instanceof GroupRoot) { - return ""; - } - return group.getCode().getFullName(); - } - -} diff --git a/src/net/sourceforge/plantuml/oregon/BasicGame.java b/src/net/sourceforge/plantuml/oregon/BasicGame.java deleted file mode 100644 index ca48db0..0000000 --- a/src/net/sourceforge/plantuml/oregon/BasicGame.java +++ /dev/null @@ -1,43 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.oregon; - -public interface BasicGame { - - void run(Keyboard keyboard) throws NoInputException; - - Screen getScreen(); -} diff --git a/src/net/sourceforge/plantuml/oregon/Keyboard.java b/src/net/sourceforge/plantuml/oregon/Keyboard.java deleted file mode 100644 index 8494417..0000000 --- a/src/net/sourceforge/plantuml/oregon/Keyboard.java +++ /dev/null @@ -1,42 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.oregon; - -public interface Keyboard { - String input() throws NoInputException; - boolean hasMore(); - -} diff --git a/src/net/sourceforge/plantuml/oregon/KeyboardList.java b/src/net/sourceforge/plantuml/oregon/KeyboardList.java deleted file mode 100644 index 9c99e97..0000000 --- a/src/net/sourceforge/plantuml/oregon/KeyboardList.java +++ /dev/null @@ -1,66 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.oregon; - -import java.util.Arrays; -import java.util.Collection; -import java.util.Iterator; - -public class KeyboardList implements Keyboard { - - private final Iterator<String> data; - - public KeyboardList(String... inputs) { - this(Arrays.asList(inputs)); - } - - public KeyboardList(Collection<String> inputs) { - data = inputs.iterator(); - } - - - public String input() throws NoInputException { - if (data.hasNext()) { - return data.next(); - } - throw new NoInputException(); - } - - public boolean hasMore() { - return data.hasNext(); - } - -} diff --git a/src/net/sourceforge/plantuml/oregon/MagicTable.java b/src/net/sourceforge/plantuml/oregon/MagicTable.java deleted file mode 100644 index 6a59981..0000000 --- a/src/net/sourceforge/plantuml/oregon/MagicTable.java +++ /dev/null @@ -1,233 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.oregon; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Random; - -import net.sourceforge.plantuml.Log; - -public class MagicTable { - - static enum Oc { - USED, NEAR - } - - private final Oc number[] = new Oc[10000]; - - private static ArrayList<int[]> neighbours; - - static { - neighbours = new ArrayList<int[]>(); - for (int i = 0; i < 10000; i++) { - neighbours.add(null); - } - } - - public static int[] getNeighbours(final int nb) { - if (neighbours.get(nb) == null) { - neighbours.set(nb, getNeighboursSlow(nb)); - } - return neighbours.get(nb); - } - - public static int[] getNeighboursSlow(final int nb) { - final int result[] = new int[36]; - - final int v1 = nb % 10; - int root = nb - v1; - int cpt = 0; - for (int i = 0; i < 10; i++) { - final int candidate = root + i; - if (candidate == nb) { - continue; - } - result[cpt++] = candidate; - } - final int v2 = (nb / 10) % 10; - root = nb - v2 * 10; - for (int i = 0; i < 10; i++) { - final int candidate = root + i * 10; - if (candidate == nb) { - continue; - } - result[cpt++] = candidate; - } - final int v3 = (nb / 100) % 10; - root = nb - v3 * 100; - for (int i = 0; i < 10; i++) { - final int candidate = root + i * 100; - if (candidate == nb) { - continue; - } - result[cpt++] = candidate; - } - final int v4 = nb / 1000; - root = nb - v4 * 1000; - for (int i = 0; i < 10; i++) { - final int candidate = root + i * 1000; - if (candidate == nb) { - continue; - } - result[cpt++] = candidate; - } - return result; - } - - public List<Integer> getAllFree() { - final List<Integer> result = new ArrayList<Integer>(10000); - for (int i = 0; i < number.length; i++) { - if (number[i] == null) { - result.add(i); - } - } - return result; - } - - public List<Integer> getAllUsed() { - final List<Integer> result = new ArrayList<Integer>(10000); - for (int i = 0; i < number.length; i++) { - if (number[i] == Oc.USED) { - result.add(i); - } - } - return result; - } - - public boolean isUsuable(int nb) { - if (number[nb] != null) { - return false; - } - for (int near : getNeighbours(nb)) { - if (number[near] != null) { - return false; - } - } - return true; - } - - public void burnNumber(int nb) { - if (number[nb] != null) { - throw new IllegalArgumentException(); - } - number[nb] = Oc.USED; - for (int near : getNeighbours(nb)) { - number[near] = Oc.NEAR; - } - } - - public int getRandomFree(Random rnd) { - final List<Integer> frees = getAllFree(); - // final int size = frees.size(); - // for (int i = 0; i < size; i++) { - // final int pos = rnd.nextInt(frees.size()); - // final int nb = frees.get(pos); - // frees.remove(pos); - // if (isUsuable(nb)) { - // return nb; - // } - // } - Collections.shuffle(frees, rnd); - for (int nb : frees) { - if (isUsuable(nb)) { - return nb; - } - } - return -1; - - } - - public static int size(Random rnd, MagicTable mt) { - int i = 0; - while (true) { - final int candidate = mt.getRandomFree(rnd); - if (candidate == -1) { - break; - } - mt.burnNumber(candidate); - i++; - } - return i; - } - - public static void main(String[] args) { - int max = 0; - final long start = System.currentTimeMillis(); - final Random rnd = new Random(49); - final int nb = 200000; - for (int i = 0; i < nb; i++) { - if (i == 100) { - long dur = (System.currentTimeMillis() - start) / 1000L; - dur = dur * nb / 100; - dur = dur / 3600; - Log.println("Estimated duration = " + dur + " h"); - } - final MagicTable mt = new MagicTable(); - final int v = MagicTable.size(rnd, mt); - if (v > max) { - Log.println("v="+v); - Log.println("mt="+mt.getAllUsed()); - max = v; - } - } - final long duration = System.currentTimeMillis() - start; - Log.println("Duration = " + duration / 1000L / 60); - - } - - public static void main2(String[] args) { - int max = 0; - final long start = System.currentTimeMillis(); - for (int j = 1; j < 100; j++) { - final Random rnd = new Random(j); - for (int i = 0; i < 1000; i++) { - final MagicTable mt = new MagicTable(); - final int v = MagicTable.size(rnd, mt); - if (v > max) { - Log.println("v="+v); - Log.println("mt="+mt.getAllUsed()); - max = v; - } - } - } - final long duration = System.currentTimeMillis() - start; - Log.println("Duration = " + duration / 1000L / 60); - - } - -} diff --git a/src/net/sourceforge/plantuml/oregon/NoInputException.java b/src/net/sourceforge/plantuml/oregon/NoInputException.java deleted file mode 100644 index 9dde2ad..0000000 --- a/src/net/sourceforge/plantuml/oregon/NoInputException.java +++ /dev/null @@ -1,39 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.oregon; - -public class NoInputException extends Exception { -} diff --git a/src/net/sourceforge/plantuml/oregon/OregonBasicGame.java b/src/net/sourceforge/plantuml/oregon/OregonBasicGame.java deleted file mode 100644 index 1f19cb0..0000000 --- a/src/net/sourceforge/plantuml/oregon/OregonBasicGame.java +++ /dev/null @@ -1,940 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.oregon; - -import java.util.Random; - -import net.sourceforge.plantuml.StringUtils; - -public class OregonBasicGame implements BasicGame { - - private Screen screen; - private SmartKeyboard skb; - private Random rnd; - - private int ks; - private int kh; - private int kp; - private int kb; - private int km; - private int kq; - - private double ma; - - private final String da[] = new String[] { "March 29", "April 12", "April 26", "May 10", "May 24", "June 7", - "June 21", "July 5", "July 19", "August 2", "August 16", "August 31", "September 13", "September 27", - "October 11", "October 25", "November 8", "November 22", "December 6", "December 20" }; - - private final int ep[] = new int[] { 6, 11, 13, 15, 17, 22, 32, 35, 37, 42, 44, 54, 64, 69, 95 }; - - public Screen getScreen() { - return screen; - } - - private void print(String s) { - screen.print(s); - } - - private void printb(String s) { - screen.print("<b>** " + s + " **</b>"); - } - - private void print() { - screen.print(); - } - - public void run(Keyboard keyboard) throws NoInputException { - if (screen != null) { - throw new IllegalStateException(); - } - screen = new Screen(); - skb = new SmartKeyboard(keyboard); - init(); - } - - private double rnd() { - if (this.rnd == null) { - this.rnd = new Random(skb.getHistory().hashCode()); - } - return rnd.nextDouble(); - } - - private void init() throws NoInputException { - printInitialScenario490(); - initialPurchasesOfPlayer690(); - initialShootingRanking920(); - screen.clear(); - print("<i>** Your trip is about to begin... **</i>"); - print(); - for (int j = 0; j < 20; j++) { - if (m > 2039) { - madeIt3190(j); - break; - } - print("<b>Monday, " + da[j] + ", 1847</b>. You are " + whereAreWe()); - print(); - if (f < 6) { - print("<b>** You're low on food. Better buy some or go hunting soon. **"); - print(); - } - if (ks == 1 || kh == 1) { - t = t - 10; - if (t < 0) { - needDoctorBadly3010(j); - } - print("Doctor charged <b>$10</b> for his services"); - print("to treat your " + (ks == 1 ? "illness." : "injuries.")); - } - // MP flag to be done? - - m = (int) (m + .5); - print("Total mileage to date is: <b>" + ((int) m) + "</b>"); - m += 200 + (a - 110) / 2.5 + 10 * rnd(); - print(); - // Calculate how far we travel in 2 weeks - print("Here's what you now have (no. of bullets, $ worth of other items) :"); - printInventory3350(); - question1000(j); - eating1310(j); - screen.clear(); - riders1390(j); - // print(); - events1800(j); - // print(); - montains2640(j); - if (skb.hasMore()) { - screen.clear(); - } - } - } - - private void events1800(int j) throws NoInputException { - final int rn = (int) (100.0 * rnd()); - for (int i = 0; i < ep.length; i++) { - if (rn <= ep[i]) { - execEvent(i, j); - return; - } - } - execEvent(ep.length, j); - } - - private void execEvent(int i, int j) throws NoInputException { - switch (i) { - case 0: - printb("Your wagon breaks down. It costs you time and supplies to fix it."); - m = m - 15 - 5 * rnd(); - r = r - 4; - break; - case 1: - printb("An ox gores your leg. That slows you down for the rest of the trip."); - m = m - 25; - a = a - 10; - break; - case 2: - printb("Bad luck... your daughter breaks her arm. You must stop and"); - printb("make a splint and sling with some of your medical supplies."); - m = m - 5 - 4 * rnd(); - r = r - 1 - 2 * rnd(); - break; - case 3: - printb("An ox wanders off and you have to spend time looking for it."); - m = m - 17; - break; - case 4: - printb("Your son gets lost and you spend half a day searching for him."); - m = m - 10; - break; - case 5: - printb("Nothing but contaminated and stagnant water near the trail."); - printb("You lose time looking for a clean spring or creek."); - m = m - 2 - 10 * rnd(); - break; - - case 6: - if (m > 950) { - int c1 = 0; - if (c < 11 + 2 * rnd()) { - c1 = 1; - } - printb("Cold weather... Brrrrrrr! ... You " + (c1 == 1 ? "don't " : "") - + "have enough clothing to keep warm."); - if (c1 == 1) { - dealWithIllness2880(j); - } - } else { - printb("Heavy rains. Traveling is slow in the mud and you break your spare"); - printb("ox yoke using it to pry your wagon out of the mud. Worse yet, some"); - printb("of your ammo is damaged by the water."); - m = m - 5 - 10 * rnd(); - r = r - 7; - b = b - 400; - f = f - 5; - } - break; - - case 7: - printb("Bandits attacking!"); - final int br1 = shoot3870(); - b = b - 20 * br1; - if (b > 0) { - if (br1 <= 1) { - print("That was the quickest draw outside of Dodge City."); - print("You got at least one and drove 'em off."); - return; - } - } else { - t = t / 3; - print("You try to drive them off but you run out of bullets."); - print("They grab as much cash as they can find."); - - } - print("You get shot in the leg -"); - kh = 1; - print("and they grab one of your oxen."); - a = a - 10; - r = r - 2; - print("Better have a doc look at your leg... and soon!"); - break; - - case 8: - printb("You have a fire in your wagon. Food and supplies are damaged."); - m = m - 15; - f = f - 20; - b = b - 400; - r = r - 2 * 6 * rnd(); - break; - - case 9: - printb("You lose your way in heavy fog. Time lost regaining the trail."); - m = m - 10 - 5 * rnd(); - break; - - case 10: - printb("You come upon a rattlesnake and before you are able to get your gun"); - printb("out, it bites you."); - b = b - 10; - r = r - 2; - if (r < 0) { - printb("You have no medical supplies left, and you die of poison."); - die3060(j); - - } - print("Fortunately, you acted quickly, sucked out the poison, and"); - print("treated the wound. It is painful, but you'll survive."); - break; - - case 11: - print("Your wagon gets swamped fording a river; you lose food and clothes."); - m = m - 20 - 20 * rnd(); - f = f - 15; - c = c - 10; - break; - - case 12: - printb("You're sound asleep and you hear a noise... get up to investigate."); - printb("It's wild animals! They attack you!"); - final int br2 = shoot3870(); - if (b <= 39) { - print("You're almost out of ammo; can't reach more."); - print("The wolves come at you biting and clawing."); - kh = 1; - die3030(j); - } - if (br2 <= 2) { - print("Nice shooting, pardner... They didn't get much."); - } else { - print("Kind of slow on the draw. The wolves got at your food and clothes."); - b = b - 20 * br2; - c = c - 2 * br2; - f = f - 4 * br2; - } - break; - - case 13: - printb("You're caught in a fierce hailstorm; ammo and supplies are damaged."); - m = m - 5 - 10 * rnd(); - b = b - 150; - r = r - 2 - 2 * rnd(); - break; - - case 14: - if (e == 1) { - dealWithIllness2880(j); - } else if (e == 2 && rnd() > .25) { - dealWithIllness2880(j); - } else if (e == 3 && rnd() > .5) { - dealWithIllness2880(j); - } - break; - - case 15: - printb("Helpful Indians show you where to find more food."); - f = f + 7; - break; - - default: - printb("EVENT " + i); - } - print(); - - } - - private void madeIt3190(int j) throws NoInputException { - final double ml = (2040 - ma) / (m - ma); - f = f + (1 - ml) * (8 + 5 * e); - print("You finally arrived at Oregon City after 2040 long miles."); - print("You're exhausted and haggard, but you made it! A real pioneer!"); - final int d = (int) (14 * (j + ml)); - final int dm = (int) (d / 30.5); - final int dd = (int) (d - 30.5 * dm); - print("You've been on the trail for " + dm + " months and " + dd + " days."); - print("You have few supplies remaining :"); - printInventory3350(); - print(); - print("President James A. Polk sends you his heartiest"); - - print("congratulations and wishes you a prosperous life in your new home."); - throw new NoInputException(); - } - - private boolean riders1390(int j) throws NoInputException { - final double value = (Math.pow(m / 100 - 4, 2) + 72) / (Math.pow(m / 100 - 4, 2) + 12) - 1; - final double random = 10.0 * rnd(); - if (random > value) { - return false; - } - int gh = 0; - if (rnd() > .2) { - gh = 1; - } - print(); - print("Riders ahead! They " + (gh == 1 ? "don't " : "") + "look hostile."); - int gt; - do { - print("You can <b>(1)</b> run, <b>(2)</b> attack, <b>(3)</b> ignore them, or <b>(4)</b> circle wagons."); - gt = skb.inputInt(screen); - } while (gt < 0 || gt > 4); - if (rnd() < .2) { - gh = 1 - gh; - } - if (gh == 1) { - if (gt == 1) { - m = m + 15; - a = a - 5; - } else if (gt == 2) { - m = m - 5; - b = b - 100; - } else if (gt == 4) { - m = m - 20; - } - print("Riders were friendly, but check for possible losses."); - return true; - } - if (gt == 1) { - m = m + 20; - r = r - 7; - b = b - 150; - a = a - 20; - } else if (gt == 2) { - final int br = shoot3870(); - b = b - br * 40 - 80; - riderShoot(br); - } else if (gt == 3) { - if (rnd() > .8) { - print("They did not attack. Whew!"); - return true; - } - b = b - 150; - r = r - 7; - } else { - assert gt == 4; - final int br = shoot3870(); - b = b - br * 30 - 80; - m = m - 25; - riderShoot(br); - } - print("Riders were hostile. Better check for losses!"); - if (b >= 0) { - return true; - } - print(); - print("<b>Oh, my gosh!</b>"); - print("They're coming back and you're out of ammo! Your dreams turn to"); - print("dust as you and your family are massacred on the prairie."); - print3110(j); - return true; - - } - - private void riderShoot(final int br) { - if (br <= 1) { - print("Nice shooting - you drove them off."); - } else if (br <= 4) { - print("Kind of slow with your Colt .45."); - } else { - print("Pretty slow on the draw, partner. You got a nasty flesh wound."); - kh = 1; - print("You'll have to see the doc soon as you can."); - } - } - - private void montains2640(int j) throws NoInputException { - if (m <= 975) { - return; - } - final double mm = m / 100.0 - 15; - if (10 * rnd() > 9 - (mm * mm + 72) / (mm * mm + 12)) { - southPass2750(j); - return; - } - print("You're in rugged mountain country."); - if (rnd() <= .1) { - print("You get lost and lose valuable time trying to find the trail."); - m = m - 60; - southPass2750(j); - return; - } - if (rnd() > .11) { - print("The going is really slow; oxen are very tired."); - m = m - 45 - 50 * rnd(); - } else { - print("Trail cave in damages your wagon. You lose time and supplies."); - m = m - 20 - 30 * rnd(); - b = b - 200; - r = r - 3; - } - southPass2750(j); - - } - - private void southPass2750(int j) throws NoInputException { - if (kp == 0) { - kp = 1; - if (rnd() < .8) { - blizzard2840(j); - return; - } - print("You made it safely through the South Pass....no snow!"); - } - if (m < 1700) { - return; - } - if (km == 0) { - km = 1; - if (rnd() < .7) { - blizzard2840(j); - } - } - - } - - private void blizzard2840(int j) throws NoInputException { - print("Blizzard in the mountain pass. Going is slow; supplies are lost."); - kb = 1; - m = m - 30 - 40 * rnd(); - f = f - 12; - b = b - 200; - r = r - 5; - if (c < 18 + 2 * rnd()) { - dealWithIllness2880(j); - } - } - - private void dealWithIllness2880(int j) throws NoInputException { - if (100 * rnd() < 10 + 35 * (e - 1)) { - print("Mild illness. Your own medicine will cure it."); - m -= 5; - r -= 1; - } else if (100 * rnd() < 100.0 - 40.0 / Math.pow(4.0, e - 1)) { - print("The whole family is sick. Your medicine will probably work okay."); - m -= 5; - r -= 2.5; - } else { - print("Serious illness in the family. You'll have to stop and see a doctor"); - print("soon. For now, your medicine will work."); - r -= 5; - ks = 1; - } - if (r <= 0) { - print("...if only you had enough."); - outOfMedicalSupplies3020(j); - } - - } - - private void eating1310(int j) throws NoInputException { - if (f < 5) { - die3000(j); - return; - } - do { - print("Do you want to eat <b>(1)</b> poorly, <b>(2)</b> moderately or <b>(3)</b> well ?"); - e = skb.inputInt(screen); - if (e < 1 || e > 3) { - print("Enter 1, 2, or 3, please."); - break; - } - final int ee = (int) (4 + 2.5 * e); - if (e == 1 && ee > f) { - f = 0; - return; - } - if (ee > f) { - print("You don't have enough to eat that well."); - break; - } - f -= ee; - return; - } while (true); - - } - - private void needDoctorBadly3010(int j) throws NoInputException { - print("<b>You need a doctor badly but can't afford one.</b>"); - die3030(j); - } - - private void outOfMedicalSupplies3020(int j) throws NoInputException { - print("<b>You have run out of all medical supplies.</b>"); - print(); - die3030(j); - } - - private void die3000(int j) throws NoInputException { - screen.clear(); - print("<b>You run out of food and starve to death.</b>"); - print(); - print3110(j); - } - - private void die3030(int j) throws NoInputException { - print("The wilderness is unforgiving and you die of " + (kh == 1 ? "your injuries" : "pneumonia")); - die3060(j); - } - - private void die3060(int j) throws NoInputException { - print("Your family tries to push on, but finds the going too rough"); - print(" without you."); - print3110(j); - } - - private void print3110(int j) throws NoInputException { - print("Some travelers find the bodies of you and your"); - print("family the following spring. They give you a decent"); - print("burial and notify your next of kin."); - print(); - print("At the time of your unfortunate demise, you had been on the trail"); - final int d = 14 * j; - final int dm = (int) (d / 30.5); - final int dd = (int) (d - 30.5 * dm); - print("for " + dm + " months and " + dd + " days and had covered " + (int) ((m + 70)) + " miles."); - print(); - print("You had a few supplies left :"); - printInventory3350(); - throw new NoInputException(); - } - - private void question1000(int j) throws NoInputException { - int x; - if (j % 2 == 1) { - do { - print("Want to <b>(1)</b> stop at the next fort, <b>(2)</b> hunt, or <b>(3)</b> push on ?"); - x = skb.inputInt(screen); - if (x == 3) { - return; - } - if (x == 1) { - stopAtFort1100(j); - return; - } - if (x == 2) { - hunt1200(j); - if (kq == 0) { - return; - } - } - } while (true); - } else { - do { - print("Would you like to <b>(1)</b> hunt or <b>(2)</b> continue on ?"); - x = skb.inputInt(screen); - if (x == 2) { - return; - } - } while (x < 1 || x > 2); - if (x == 1) { - hunt1200(j); - } - } - - } - - private void hunt1200(int j) throws NoInputException { - kq = 0; - if (b <= 39) { - print("Tough luck. You don't have enough ammo to hunt."); - kq = 1; - return; - } - m = m - 45; - final int br = shoot3870(); - if (br <= 1) { - print("Right between the eyes... you got a big one!"); - print("Full bellies tonight!"); - b = b - 10 - 4 * rnd(); - f = f + 26 + 3 * rnd(); - return; - } - if (100.0 * rnd() < 13 * br) { - print("You missed completely... and your dinner got away."); - return; - } - print("Nice shot... right on target... good eatin' tonight!"); - f = f + 24 - 2 * br; - b = b - 10 - 3 * br; - return; - } - - private void stopAtFort1100(int j) throws NoInputException { - if (t <= 0) { - print("You sing with the folks there and get a good"); - print("night's sleep, but you have no money to buy anything."); - return; - } - - while (true) { - print("What would you like to spend on each of the following"); - print("Food?"); - final double p1 = skb.inputInt(screen); - print("Ammunition?"); - final double p2 = skb.inputInt(screen); - print("Clothing?"); - final double p3 = skb.inputInt(screen); - print("Medicine and supplies?"); - final double p4 = skb.inputInt(screen); - final double p = p1 + p2 + p3 + p4; - print("The storekeeper tallies up your bill. It comes to $" + ((int) p)); - if (t >= p) { - t = t - p; - f = f + .67 * p1; - b = b + 33 * p2; - c = c + .67 * p3; - r = r + .67 * p4; - return; - } - print("Uh, oh. That's more than you have. Better start over."); - } - } - - private void printInventory3350() { - // print("+------+------+------+---------+--------------------+"); - print(); - print("| <u>Cash</u> | <u>Food</u> | <u>Ammo</u> | <u>Clothes</u> | <u>Medicine/parts/...</u> |"); - print("+------+------+------+---------+--------------------+"); - if (t < 0) { - t = 0; - } - if (f < 0) { - f = 0; - } - if (b < 0) { - b = 0; - } - if (c < 0) { - c = 0; - } - if (r < 0) { - r = 0; - } - print(String.format("|%5d |%5d |%5d | %5d | %5d |", (int) t, (int) f, (int) b, (int) c, (int) r)); - print("+------+------+------+---------+--------------------+"); - print(); - } - - private String whereAreWe() { - if (m < 5) { - return "on the high prairie."; - } - if (m < 200) { - return "near Independence Crossing on the Big Blue River."; - } - if (m < 350) { - return "following the Platte River."; - } - if (m < 450) { - return "near Fort Kearney."; - } - if (m < 600) { - return "following the North Platte River."; - } - if (m < 750) { - return "within sight of Chimney Rock."; - } - if (m < 850) { - return "near Fort Laramie."; - } - if (m < 1000) { - return "close upon Independence Rock."; - } - if (m < 1050) { - return "in the Big Horn Mountains."; - } - if (m < 1150) { - return "following the Green River."; - } - if (m < 1250) { - return "not too far from Fort Hall."; - } - if (m < 1400) { - return "following the Snake River."; - } - if (m < 1550) { - return "not far from Fort Boise."; - } - if (m < 1850) { - return "in the Blue Mountains."; - } - return "following the Columbia River"; - - } - - private void printInitialScenario490() { - print(" Your journey over the Oregon Trail takes place in 1847."); - print(); - print("Starting in Independence, Missouri, you plan to take your family of"); - print("five over 2040 tough miles to Oregon City."); - print(); - print(" Having saved <b>$420</b> for the trip, you bought a wagon for <b>$70</b> and"); - print("now have to purchase the following items :"); - print(); - print(" * <b>Oxen</b> (spending more will buy you a larger and better team which"); - print(" will be faster so you'll be on the trail for less time)"); - print(" * <b>Food</b> (you'll need ample food to keep up your strength and health)"); - print(" * <b>Ammunition</b> ($1 buys a belt of 50 bullets. You'll need ammo for"); - print(" hunting and for fighting off attacks by bandits and animals)"); - print(" * <b>Clothing</b> (you'll need warm clothes, especially when you hit the"); - print(" snow and freezing weather in the mountains)"); - print(" * <b>Other supplies</b> (includes medicine, first-aid supplies, tools, and"); - print(" wagon parts for unexpected emergencies)"); - print(); - print(" You can spend all your money at the start or save some to spend"); - print("at forts along the way. However, items cost more at the forts. You"); - print("can also hunt for food if you run low."); - print(); - - } - - private void initialPurchasesOfPlayer690() throws NoInputException { - if (skb.hasMore()) { - screen.clear(); - } - do { - print("How much do you want to pay for a team of oxen ?"); - a = skb.inputInt(screen); - if (a < 100) { - print("No one in town has a team that cheap"); - continue; - } - break; - } while (true); - if (a >= 151) { - print("You choose an honest dealer who tells you that $" + a + " is too much for"); - print("a team of oxen. He charges you $150 and gives you $" + (a - 150) + " change."); - a = 150; - } - do { - print(); - print("How much do you want to spend on food ?"); - f = skb.inputInt(screen); - if (f <= 13) { - print("That won't even get you to the Kansas River"); - print(" - better spend a bit more."); - continue; - } - if (a + f > 300) { - print("You wont't have any for ammo and clothes."); - continue; - } - break; - } while (true); - do { - print(); - print("How much do you want to spend on ammunition ?"); - b = skb.inputInt(screen); - if (b < 2) { - print("Better take a bit just for protection."); - continue; - } - if (a + f + b > 320) { - print("That won't leave any money for clothes."); - continue; - } - break; - } while (true); - do { - print(); - print("How much do you want to spend on clothes ?"); - c = skb.inputInt(screen); - if (c <= 24) { - print("Your family is going to be mighty cold in."); - print("the mountains."); - print("Better spend a bit more."); - continue; - } - if (a + f + b + c > 345) { - print("That leaves nothing for medicine."); - continue; - } - break; - } while (true); - do { - print(); - screen.print("How much for medicine, bandage, repair parts, etc. ?"); - r = skb.inputInt(screen); - if (r <= 5) { - print("That's not at all wise."); - continue; - } - if (a + f + b + c + r > 350) { - print("You don't have that much money."); - continue; - } - break; - } while (true); - t = 350 - a - f - b - c - r; - print(); - print("You now have <b>$" + ((int) t) + " left.</b>"); - b = 50 * b; - } - - private void initialShootingRanking920() throws NoInputException { - print(); - print("Please rank your shooting (typing) ability as follows :"); - print(" (1) Ace marksman (2) Good shot (3) Fair to middlin'"); - print(" (4) Need more practice (5) Shaky knees"); - do { - print(); - print("How do you rank yourself ?"); - dr = skb.inputInt(screen); - if (dr >= 1 && dr <= 6) { - return; - } - print("Please enter 1, 2, 3, 4 or 5."); - } while (true); - } - - private int e; - private int a; - private double b; - private double f; - private double c; - private double r; - private double t; - private int dr; - private double m; - - enum ShootingWord { - POW, BANG, BLAM, WHOP, WHAM, ZING, ZACK, ZANG, WOOSH, BAM, ZAP, BOOM, WOW, CLANG, BOING, ZOW, PANG, ZOSH, KAZ, KOOG, ZOOP, PONG, PING, BAZ, ZONG, PAM, POOM, DOING; - - public static ShootingWord safeValueOf(String s) { - try { - return valueOf(StringUtils.goUpperCase(s)); - } catch (IllegalArgumentException e) { - return null; - } - } - - public int decode(ShootingWord key) { - return (ordinal() + key.ordinal()) % NB_WORDS; - } - - public ShootingWord encode(int v) { - v = v - this.ordinal(); - if (v < 0) { - v += NB_WORDS; - } - return ShootingWord.values()[v]; - } - } - - private static int NB_WORDS = ShootingWord.values().length; - - private int getTime() { - return (int) ((System.currentTimeMillis() / 1000L) % NB_WORDS); - } - - private int shoot3870() throws NoInputException { - final int time1 = getTime(); - final ShootingWord word1Printed = ShootingWord.values()[time1]; - if (skb.hasMore() == false) { - print("Type: " + word1Printed); - } - final String typed1 = skb.input(screen); - ShootingWord wordType1 = ShootingWord.safeValueOf(typed1); - final int delta; - if (wordType1 == null) { - delta = NB_WORDS - 1; - wordType1 = ShootingWord.values()[NB_WORDS - 1]; - } else { - delta = protect(getTime() - wordType1.ordinal()); - } - // print("delta="+delta); - final ShootingWord word2 = wordType1.encode(delta); - if (skb.hasMore() == false) { - print("Type: " + word2); - } - final String typed2 = skb.input(screen); - final ShootingWord wordType2 = ShootingWord.safeValueOf(typed2); - final int duration = wordType2 == null ? NB_WORDS : wordType1.decode(wordType2) - dr; - // print("duration=" + duration); - if (duration < 0) { - return 0; - } - return duration; - } - - private int protect(int v) { - while (v >= NB_WORDS) { - v -= NB_WORDS; - } - while (v < 0) { - v += NB_WORDS; - } - return v; - } - -} diff --git a/src/net/sourceforge/plantuml/oregon/PSystemOregon.java b/src/net/sourceforge/plantuml/oregon/PSystemOregon.java deleted file mode 100644 index 2958650..0000000 --- a/src/net/sourceforge/plantuml/oregon/PSystemOregon.java +++ /dev/null @@ -1,115 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.oregon; - -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.FileFormatOption; -import net.sourceforge.plantuml.StringUtils; -import net.sourceforge.plantuml.core.DiagramDescription; -import net.sourceforge.plantuml.core.ImageData; -import net.sourceforge.plantuml.graphic.GraphicStrings; -import net.sourceforge.plantuml.svek.TextBlockBackcolored; -import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity; -import net.sourceforge.plantuml.ugraphic.ImageBuilder; - -public class PSystemOregon extends AbstractPSystem { - - private Screen screen; - private List<String> inputs; - - @Deprecated - public PSystemOregon(Keyboard keyboard) { - final BasicGame game = new OregonBasicGame(); - try { - game.run(keyboard); - this.screen = game.getScreen(); - // this.screen = new Screen(); - // screen.print("Game ended??"); - } catch (NoInputException e) { - this.screen = game.getScreen(); - } - } - - public PSystemOregon() { - this.inputs = new ArrayList<String>(); - } - - public void add(String line) { - if (StringUtils.isNotEmpty(line)) { - inputs.add(line); - } - } - - private Screen getScreen() { - if (screen == null) { - final Keyboard keyboard = new KeyboardList(inputs); - final BasicGame game = new OregonBasicGame(); - try { - game.run(keyboard); - this.screen = game.getScreen(); - // this.screen = new Screen(); - // screen.print("Game ended??"); - } catch (NoInputException e) { - this.screen = game.getScreen(); - } - } - return screen; - } - - @Override - final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed) - throws IOException { - final TextBlockBackcolored result = getGraphicStrings(); - final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, result.getBackcolor(), - getMetadata(), null, 0, 0, null, false); - imageBuilder.setUDrawable(result); - return imageBuilder.writeImageTOBEMOVED(fileFormat, seed, os); - } - - private TextBlockBackcolored getGraphicStrings() throws IOException { - return GraphicStrings.createGreenOnBlackMonospaced(getScreen().getLines()); - } - - public DiagramDescription getDescription() { - return new DiagramDescription("(The Oregon Trail)"); - } - -} diff --git a/src/net/sourceforge/plantuml/oregon/PSystemOregonFactory.java b/src/net/sourceforge/plantuml/oregon/PSystemOregonFactory.java deleted file mode 100644 index c6ae42b..0000000 --- a/src/net/sourceforge/plantuml/oregon/PSystemOregonFactory.java +++ /dev/null @@ -1,65 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.oregon; - -import net.sourceforge.plantuml.command.PSystemBasicFactory; - -public class PSystemOregonFactory extends PSystemBasicFactory<PSystemOregon> { - - // public PSystemOregon getSystem() { - // final Keyboard keyboard; - // if (inputs == null) { - // keyboard = new KeyboardList(""); - // } else { - // keyboard = new KeyboardList(inputs); - // } - // system = new PSystemOregon(keyboard); - // return system; - // } - - @Override - public PSystemOregon executeLine(PSystemOregon system, String line) { - if (system == null && line.equalsIgnoreCase("run oregon trail")) { - return new PSystemOregon(); - } - if (system == null) { - return null; - } - system.add(line); - return system; - } - -} diff --git a/src/net/sourceforge/plantuml/oregon/Screen.java b/src/net/sourceforge/plantuml/oregon/Screen.java deleted file mode 100644 index fdd034c..0000000 --- a/src/net/sourceforge/plantuml/oregon/Screen.java +++ /dev/null @@ -1,65 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.oregon; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -public class Screen { - private final List<String> lines = new ArrayList<String>(); - - public void clear() { - lines.clear(); - } - - public void print(String s) { - lines.add(s); - } - - public void print() { - lines.add(" "); - } - - public List<String> getLines() { - return Collections.unmodifiableList(lines); - } - - public String getLastLine() { - return lines.get(lines.size()-1); - } - -} diff --git a/src/net/sourceforge/plantuml/oregon/SecureCoder.java b/src/net/sourceforge/plantuml/oregon/SecureCoder.java deleted file mode 100644 index 378388b..0000000 --- a/src/net/sourceforge/plantuml/oregon/SecureCoder.java +++ /dev/null @@ -1,72 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.oregon; - -public class SecureCoder { - - private static final int m[] = { 38, 152, 264, 491, 573, 616, 727, 880, 905, 1090, 1188, 1315, 1544, 1603, 1756, - 1831, 1962, 2025, 2100, 2257, 2381, 2469, 2536, 2714, 2948, 3077, 3166, 3219, 3340, 3455, 3701, 3892, 3934, - 4193, 4372, 4404, 4521, 4650, 4739, 4865, 4987, 5053, 5135, 5282, 5309, 5446, 5628, 5817, 5970, 6002, 6174, - 6295, 6367, 6420, 6558, 6689, 6913, 7061, 7129, 7206, 7333, 7510, 7697, 7742, 7854, 8084, 8147, 8230, 8326, - 8412, 8599, 8675, 8763, 8808, 8951, 9049, 9111, 9223, 9394, 9478, 9507, 9632, 9785 }; - - private static final int dec[] = new int[10000]; - - static { - for (int i = 0; i < dec.length; i++) { - dec[i] = -1; - } - for (int i = 0; i < m.length; i++) { - final int enc = m[i]; - dec[enc] = i; - for (int n : MagicTable.getNeighbours(enc)) { - if (dec[n] != -1) { - throw new IllegalStateException(); - } - dec[n] = i + 1000; - } - } - } - - public int encode(int i) { - return m[i]; - } - - public int decode(int v) { - return dec[v]; - } - -} diff --git a/src/net/sourceforge/plantuml/oregon/SmartKeyboard.java b/src/net/sourceforge/plantuml/oregon/SmartKeyboard.java deleted file mode 100644 index 21aca01..0000000 --- a/src/net/sourceforge/plantuml/oregon/SmartKeyboard.java +++ /dev/null @@ -1,75 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.oregon; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -public class SmartKeyboard { - - private final Keyboard keyboard; - private final List<String> history = new ArrayList<String>(); - - public SmartKeyboard(Keyboard keyboard) { - this.keyboard = keyboard; - } - - public String input(Screen screen) throws NoInputException { - final String s = keyboard.input(); - history.add(s); - screen.print("<i>? " + s); - return s; - } - - public int inputInt(Screen screen) throws NoInputException { - final String s = input(screen); - if (s.matches("\\d+") == false) { - screen.print("Please enter a valid number instead of " + s); - throw new NoInputException(); - } - return Integer.parseInt(s); - } - - public boolean hasMore() { - return keyboard.hasMore(); - } - - public List<String> getHistory() { - return Collections.unmodifiableList(history); - } - -} diff --git a/src/net/sourceforge/plantuml/posimo/AbstractEntityImage2.java b/src/net/sourceforge/plantuml/posimo/AbstractEntityImage2.java deleted file mode 100644 index 4f1c22e..0000000 --- a/src/net/sourceforge/plantuml/posimo/AbstractEntityImage2.java +++ /dev/null @@ -1,85 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.posimo; - -import java.awt.geom.Dimension2D; - -import net.sourceforge.plantuml.ColorParam; -import net.sourceforge.plantuml.FontParam; -import net.sourceforge.plantuml.ISkinParam; -import net.sourceforge.plantuml.cucadiagram.IEntity; -import net.sourceforge.plantuml.graphic.HtmlColor; -import net.sourceforge.plantuml.graphic.StringBounder; -import net.sourceforge.plantuml.skin.rose.Rose; -import net.sourceforge.plantuml.ugraphic.UFont; - -abstract class AbstractEntityImage2 implements IEntityImageBlock { - - private final IEntity entity; - private final ISkinParam skinParam; - - private final Rose rose = new Rose(); - - public AbstractEntityImage2(IEntity entity, ISkinParam skinParam) { - if (entity == null) { - throw new IllegalArgumentException("entity null"); - } - this.entity = entity; - this.skinParam = skinParam; - } - - public abstract Dimension2D getDimension(StringBounder stringBounder); - - protected final IEntity getEntity() { - return entity; - } - - protected UFont getFont(FontParam fontParam) { - return skinParam.getFont(null, false, fontParam); - } - - protected HtmlColor getFontColor(FontParam fontParam) { - return skinParam.getFontHtmlColor(null, fontParam); - } - - protected final HtmlColor getColor(ColorParam colorParam) { - return rose.getHtmlColor(skinParam, colorParam); - } - - protected final ISkinParam getSkinParam() { - return skinParam; - } -} diff --git a/src/net/sourceforge/plantuml/posimo/Decor.java b/src/net/sourceforge/plantuml/posimo/Decor.java deleted file mode 100644 index a583616..0000000 --- a/src/net/sourceforge/plantuml/posimo/Decor.java +++ /dev/null @@ -1,45 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.posimo; - -import java.awt.geom.Point2D; - -import net.sourceforge.plantuml.ugraphic.UGraphic; - -public interface Decor { - - void drawDecor(UGraphic ug, Point2D start, double direction); -} diff --git a/src/net/sourceforge/plantuml/posimo/DecorInterfaceProvider.java b/src/net/sourceforge/plantuml/posimo/DecorInterfaceProvider.java deleted file mode 100644 index fdc7f11..0000000 --- a/src/net/sourceforge/plantuml/posimo/DecorInterfaceProvider.java +++ /dev/null @@ -1,80 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.posimo; - -import java.awt.geom.Point2D; - -import net.sourceforge.plantuml.cucadiagram.LinkStyle; -import net.sourceforge.plantuml.ugraphic.UEllipse; -import net.sourceforge.plantuml.ugraphic.UGraphic; -import net.sourceforge.plantuml.ugraphic.UStroke; -import net.sourceforge.plantuml.ugraphic.UTranslate; - -public class DecorInterfaceProvider implements Decor { - - private final double radius = 5; - private final double radius2 = 9; - private final LinkStyle style; - - // private final double distanceCircle = 16; - - public DecorInterfaceProvider(LinkStyle style) { -// if (style != LinkStyle.__toremove_INTERFACE_PROVIDER && style != LinkStyle.__toremove_INTERFACE_USER) { -// throw new IllegalArgumentException(); -// } - this.style = style; - } - - public void drawDecor(UGraphic ug, Point2D start, double direction) { - final double cornerX = start.getX() - radius; - final double cornerY = start.getY() - radius; - final double cornerX2 = start.getX() - radius2 - 0 * Math.sin(direction * Math.PI / 180.0); - final double cornerY2 = start.getY() - radius2 - 0 * Math.cos(direction * Math.PI / 180.0); - -// if (style == LinkStyle.__toremove_INTERFACE_USER) { -// direction += 180; -// } - if (direction >= 360) { - direction -= 360; - } - - final UEllipse arc = new UEllipse(2 * radius2, 2 * radius2, direction + 15, 180 - 30); - ug = ug.apply(new UStroke(1.5)); - ug.apply(new UTranslate(cornerX2, cornerY2)).draw(arc); - ug.apply(new UTranslate(cornerX, cornerY)).draw(new UEllipse(2 * radius, 2 * radius)); - } - -} diff --git a/src/net/sourceforge/plantuml/posimo/EntityImageNote2.java b/src/net/sourceforge/plantuml/posimo/EntityImageNote2.java deleted file mode 100644 index 37fd779..0000000 --- a/src/net/sourceforge/plantuml/posimo/EntityImageNote2.java +++ /dev/null @@ -1,81 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.posimo; - -import java.awt.geom.Dimension2D; -import java.util.Collection; - -import net.sourceforge.plantuml.Dimension2DDouble; -import net.sourceforge.plantuml.ISkinParam; -import net.sourceforge.plantuml.cucadiagram.IEntity; -import net.sourceforge.plantuml.cucadiagram.Link; -import net.sourceforge.plantuml.graphic.StringBounder; -import net.sourceforge.plantuml.skin.Area; -import net.sourceforge.plantuml.skin.Component; -import net.sourceforge.plantuml.skin.ComponentType; -import net.sourceforge.plantuml.skin.SimpleContext2D; -import net.sourceforge.plantuml.skin.rose.Rose; -import net.sourceforge.plantuml.ugraphic.UGraphic; -import net.sourceforge.plantuml.ugraphic.UTranslate; - -public class EntityImageNote2 extends AbstractEntityImage2 { - - private final Component comp; - - public EntityImageNote2(IEntity entity, ISkinParam skinParam, Collection<Link> links) { - super(entity, skinParam); - - final Rose skin = new Rose(); - - comp = skin.createComponent(ComponentType.NOTE, null, skinParam, entity.getDisplay()); - - } - - @Override - public Dimension2D getDimension(StringBounder stringBounder) { - final double height = comp.getPreferredHeight(stringBounder); - final double width = comp.getPreferredWidth(stringBounder); - return new Dimension2DDouble(width, height); - } - - public void drawU(UGraphic ug, double xTheoricalPosition, double yTheoricalPosition, double marginWidth, - double marginHeight) { - ug = ug.apply(new UTranslate(xTheoricalPosition, yTheoricalPosition)); - comp.drawU(ug, new Area(getDimension(ug.getStringBounder())), new SimpleContext2D(false)); - - } - -} diff --git a/src/net/sourceforge/plantuml/posimo/Frame.java b/src/net/sourceforge/plantuml/posimo/Frame.java deleted file mode 100644 index 8443bcf..0000000 --- a/src/net/sourceforge/plantuml/posimo/Frame.java +++ /dev/null @@ -1,133 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.posimo; - -import java.awt.geom.Dimension2D; -import java.util.List; - -import net.sourceforge.plantuml.ColorParam; -import net.sourceforge.plantuml.Dimension2DDouble; -import net.sourceforge.plantuml.FontParam; -import net.sourceforge.plantuml.ISkinParam; -import net.sourceforge.plantuml.graphic.HtmlColor; -import net.sourceforge.plantuml.graphic.StringBounder; -import net.sourceforge.plantuml.graphic.TextBlock; -import net.sourceforge.plantuml.skin.Area; -import net.sourceforge.plantuml.skin.Component; -import net.sourceforge.plantuml.skin.Context2D; -import net.sourceforge.plantuml.skin.rose.Rose; -import net.sourceforge.plantuml.ugraphic.UChangeBackColor; -import net.sourceforge.plantuml.ugraphic.UChangeColor; -import net.sourceforge.plantuml.ugraphic.UFont; -import net.sourceforge.plantuml.ugraphic.UGraphic; -import net.sourceforge.plantuml.ugraphic.UPolygon; -import net.sourceforge.plantuml.ugraphic.URectangle; -import net.sourceforge.plantuml.ugraphic.UStroke; -import net.sourceforge.plantuml.ugraphic.UTranslate; - -public class Frame implements Component { - - private final List<? extends CharSequence> name; - private final ISkinParam skinParam; - private final Rose rose = new Rose(); - - // private final Color textColor; - // private final Color lineColor; - // private final Font font; - - public Frame(List<? extends CharSequence> name, ISkinParam skinParam) { - this.name = name; - this.skinParam = skinParam; - // this.textColor = textColor; - // this.lineColor = lineColor; - // this.font = font; - } - - public void drawU(UGraphic ug, Area area, Context2D context) { - final Dimension2D dimensionToUse = area.getDimensionToUse(); - final HtmlColor lineColor = rose.getHtmlColor(skinParam, ColorParam.packageBorder); - ug = ug.apply(new UChangeColor(lineColor)); - ug = ug.apply(new UChangeBackColor(null)); - ug.apply(new UStroke(1.4)).draw(new URectangle(dimensionToUse.getWidth(), dimensionToUse.getHeight())); - - final TextBlock textBlock = createTextBloc(); - textBlock.drawU(ug.apply(new UTranslate(2, 2))); - - final Dimension2D textDim = getTextDim(ug.getStringBounder()); - final double x = textDim.getWidth() + 6; - final double y = textDim.getHeight() + 6; - final UPolygon poly = new UPolygon(); - poly.addPoint(x, 0); - poly.addPoint(x, y - 6); - poly.addPoint(x - 6, y); - poly.addPoint(0, y); - poly.addPoint(0, 0); - ug.apply(new UStroke(1.4)).draw(poly); - - } - - public double getPreferredHeight(StringBounder stringBounder) { - final Dimension2D dim = getTextDim(stringBounder); - return dim.getHeight() + 8; - } - - public double getPreferredWidth(StringBounder stringBounder) { - final Dimension2D dim = getTextDim(stringBounder); - return dim.getWidth() + 8; - } - - public Dimension2D getTextDim(StringBounder stringBounder) { - final TextBlock bloc = createTextBloc(); - return bloc.calculateDimension(stringBounder); - } - - private TextBlock createTextBloc() { - final UFont font = skinParam.getFont(null, false, FontParam.PACKAGE); - final HtmlColor textColor = skinParam.getFontHtmlColor(null, FontParam.PACKAGE); - // final TextBlock bloc = Display.create(name).create(new FontConfiguration(font, textColor, - // skinParam.getHyperlinkColor(), skinParam.useUnderlineForHyperlink()), HorizontalAlignment.LEFT, new - // SpriteContainerEmpty()); - // return bloc; - throw new UnsupportedOperationException(); - } - - public final Dimension2D getPreferredDimension(StringBounder stringBounder) { - final double w = getPreferredWidth(stringBounder); - final double h = getPreferredHeight(stringBounder); - return new Dimension2DDouble(w, h); - } - -} diff --git a/src/net/sourceforge/plantuml/posimo/IEntityImageBlock.java b/src/net/sourceforge/plantuml/posimo/IEntityImageBlock.java deleted file mode 100644 index 8e63966..0000000 --- a/src/net/sourceforge/plantuml/posimo/IEntityImageBlock.java +++ /dev/null @@ -1,49 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.posimo; - -import java.awt.geom.Dimension2D; - -import net.sourceforge.plantuml.graphic.StringBounder; -import net.sourceforge.plantuml.ugraphic.UGraphic; - -public interface IEntityImageBlock { - - Dimension2D getDimension(StringBounder stringBounder); - - void drawU(UGraphic ug, double xTheoricalPosition, double yTheoricalPosition, double marginWidth, - double marginHeight); -}
\ No newline at end of file diff --git a/src/net/sourceforge/plantuml/posimo/LabelImage.java b/src/net/sourceforge/plantuml/posimo/LabelImage.java deleted file mode 100644 index f09504b..0000000 --- a/src/net/sourceforge/plantuml/posimo/LabelImage.java +++ /dev/null @@ -1,84 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.posimo; - -import java.awt.geom.Dimension2D; - -import net.sourceforge.plantuml.ISkinParam; -import net.sourceforge.plantuml.cucadiagram.Link; -import net.sourceforge.plantuml.graphic.StringBounder; -import net.sourceforge.plantuml.graphic.TextBlock; -import net.sourceforge.plantuml.skin.rose.Rose; -import net.sourceforge.plantuml.ugraphic.UGraphic; -import net.sourceforge.plantuml.ugraphic.UTranslate; - -public class LabelImage { - - // private final Entity entity; - final private ISkinParam param; - final private Rose rose; - final private TextBlock name; - - public LabelImage(Link link, Rose rose, ISkinParam param) { - if (link == null) { - throw new IllegalArgumentException(); - } - // this.entity = entity; - this.param = param; - this.rose = rose; -// this.name = link.getLabel().create( -// new FontConfiguration(param.getFont(FontParam.CLASS, null, false), HtmlColorUtils.BLACK, -// param.getHyperlinkColor(), param.useUnderlineForHyperlink()), HorizontalAlignment.CENTER, -// new SpriteContainerEmpty()); - throw new UnsupportedOperationException(); - } - - public Dimension2D getDimension(StringBounder stringBounder) { - final Dimension2D dim = name.calculateDimension(stringBounder); - return dim; - // return Dimension2DDouble.delta(dim, 2 * margin); - } - - public void drawU(UGraphic ug, double x, double y) { - // final Dimension2D dim = getDimension(ug.getStringBounder()); - // ug.getParam().setBackcolor(rose.getHtmlColor(param, - // ColorParam.classBackground).getColor()); - // ug.getParam().setColor(rose.getHtmlColor(param, - // ColorParam.classBorder).getColor()); - // ug.draw(x, y, new URectangle(dim.getWidth(), dim.getHeight())); - name.drawU(ug.apply(new UTranslate(x, y))); - } -} diff --git a/src/net/sourceforge/plantuml/posimo/LineRectIntersection.java b/src/net/sourceforge/plantuml/posimo/LineRectIntersection.java deleted file mode 100644 index 2f17e73..0000000 --- a/src/net/sourceforge/plantuml/posimo/LineRectIntersection.java +++ /dev/null @@ -1,83 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.posimo; - -import java.awt.geom.Line2D; -import java.awt.geom.Point2D; -import java.awt.geom.Rectangle2D; - -public class LineRectIntersection { - - private final Point2D inter; - - public LineRectIntersection(Line2D line, Rectangle2D rect) { - final Point2D p1 = new Point2D.Double(rect.getMinX(), rect.getMinY()); - final Point2D p2 = new Point2D.Double(rect.getMaxX(), rect.getMinY()); - final Point2D p3 = new Point2D.Double(rect.getMaxX(), rect.getMaxY()); - final Point2D p4 = new Point2D.Double(rect.getMinX(), rect.getMaxY()); - - final Point2D inter1 = new LineSegmentIntersection(new Line2D.Double(p1, p2), line).getIntersection(); - final Point2D inter2 = new LineSegmentIntersection(new Line2D.Double(p2, p3), line).getIntersection(); - final Point2D inter3 = new LineSegmentIntersection(new Line2D.Double(p3, p4), line).getIntersection(); - final Point2D inter4 = new LineSegmentIntersection(new Line2D.Double(p4, p1), line).getIntersection(); - - final Point2D o = line.getP1(); - inter = getCloser(o, inter1, inter2, inter3, inter4); - - } - - public static Point2D getCloser(final Point2D o, final Point2D... other) { - double minDist = Double.MAX_VALUE; - Point2D result = null; - - for (Point2D pt : other) { - if (pt != null) { - final double dist = pt.distanceSq(o); - if (dist < minDist) { - minDist = dist; - result = pt; - } - } - } - - return result; - } - - public final Point2D getIntersection() { - return inter; - } - -} diff --git a/src/net/sourceforge/plantuml/posimo/LineSegmentIntersection.java b/src/net/sourceforge/plantuml/posimo/LineSegmentIntersection.java deleted file mode 100644 index 0d2117b..0000000 --- a/src/net/sourceforge/plantuml/posimo/LineSegmentIntersection.java +++ /dev/null @@ -1,81 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.posimo; - -import java.awt.geom.Line2D; -import java.awt.geom.Point2D; - -public class LineSegmentIntersection { - - private final Point2D inter; - - // http://local.wasp.uwa.edu.au/~pbourke/geometry/lineline2d/ - - public LineSegmentIntersection(Line2D segment, Line2D lineB) { - final double x1 = segment.getX1(); - final double y1 = segment.getY1(); - final double x2 = segment.getX2(); - final double y2 = segment.getY2(); - final double x3 = lineB.getX1(); - final double y3 = lineB.getY1(); - final double x4 = lineB.getX2(); - final double y4 = lineB.getY2(); - - final double den = (y4 - y3) * (x2 - x1) - (x4 - x3) * (y2 - y1); - - if (den == 0) { - inter = null; - } else { - - final double uA1 = (x4 - x3) * (y1 - y3) - (y4 - y3) * (x1 - x3); - final double uA = uA1 / den; - - final double x = x1 + uA * (x2 - x1); - final double y = y1 + uA * (y2 - y1); - - if (uA >= 0 && uA <= 1) { - inter = new Point2D.Double(x, y); - } else { - inter = null; - } - } - } - - public final Point2D getIntersection() { - return inter; - } - -} diff --git a/src/net/sourceforge/plantuml/posimo/MargedBlock.java b/src/net/sourceforge/plantuml/posimo/MargedBlock.java deleted file mode 100644 index fca9f0b..0000000 --- a/src/net/sourceforge/plantuml/posimo/MargedBlock.java +++ /dev/null @@ -1,90 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.posimo; - -import java.awt.geom.Dimension2D; -import java.awt.geom.Point2D; - -import net.sourceforge.plantuml.graphic.StringBounder; - -public class MargedBlock { - - private final Block block; - private final IEntityImageBlock imageBlock; - private final double marginDecorator; - private final Dimension2D imageDimension; - - static private int uid = 1; - - public MargedBlock(StringBounder stringBounder, IEntityImageBlock imageBlock, double marginDecorator, Cluster parent) { - this.imageBlock = imageBlock; - this.marginDecorator = marginDecorator; - this.imageDimension = imageBlock.getDimension(stringBounder); - this.block = new Block(uid++, imageDimension.getWidth() + 2 * marginDecorator, imageDimension.getHeight() + 2 - * marginDecorator, parent); - } - - public Block getBlock() { - return block; - } - - public double getMarginDecorator() { - return marginDecorator; - } - - public IEntityImageBlock getImageBlock() { - return imageBlock; - } - - public Positionable getImagePosition() { - return new Positionable() { - - public Dimension2D getSize() { - return imageDimension; - } - - public Point2D getPosition() { - final Point2D pos = block.getPosition(); - return new Point2D.Double(pos.getX() + marginDecorator, pos.getY() + marginDecorator); - } - - public void moveSvek(double deltaX, double deltaY) { - throw new UnsupportedOperationException(); - } - }; - } - -} diff --git a/src/net/sourceforge/plantuml/posimo/Mirror.java b/src/net/sourceforge/plantuml/posimo/Mirror.java deleted file mode 100644 index e51723a..0000000 --- a/src/net/sourceforge/plantuml/posimo/Mirror.java +++ /dev/null @@ -1,54 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.posimo; - -public class Mirror { - - private final double max; - - public Mirror(double max) { - this.max = max; - } - - public double getMirrored(double v) { - if (v < 0 || v > max) { - throw new IllegalArgumentException(); - } - //return v; - return max - v; - } - -} diff --git a/src/net/sourceforge/plantuml/posimo/PathDrawer.java b/src/net/sourceforge/plantuml/posimo/PathDrawer.java deleted file mode 100644 index d4a87c8..0000000 --- a/src/net/sourceforge/plantuml/posimo/PathDrawer.java +++ /dev/null @@ -1,46 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.posimo; - -import net.sourceforge.plantuml.ugraphic.UGraphic; - -public interface PathDrawer { - - public void drawPathBefore(UGraphic ug, Positionable start, Positionable end, Path path); - - public void drawPathAfter(UGraphic ug, Positionable start, Positionable end, Path path); - -} diff --git a/src/net/sourceforge/plantuml/posimo/PathDrawerInterface.java b/src/net/sourceforge/plantuml/posimo/PathDrawerInterface.java deleted file mode 100644 index 2707b21..0000000 --- a/src/net/sourceforge/plantuml/posimo/PathDrawerInterface.java +++ /dev/null @@ -1,329 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.posimo; - -import java.awt.geom.CubicCurve2D; -import java.awt.geom.Point2D; -import java.util.Collection; -import java.util.Map; - -import net.sourceforge.plantuml.ColorParam; -import net.sourceforge.plantuml.ISkinParam; -import net.sourceforge.plantuml.cucadiagram.LinkDecor; -import net.sourceforge.plantuml.cucadiagram.LinkStyle; -import net.sourceforge.plantuml.cucadiagram.LinkType; -import net.sourceforge.plantuml.skin.rose.Rose; -import net.sourceforge.plantuml.ugraphic.UChangeBackColor; -import net.sourceforge.plantuml.ugraphic.UChangeColor; -import net.sourceforge.plantuml.ugraphic.UGraphic; -import net.sourceforge.plantuml.ugraphic.UPolygon; -import net.sourceforge.plantuml.ugraphic.URectangle; -import net.sourceforge.plantuml.ugraphic.UTranslate; - -public class PathDrawerInterface implements PathDrawer { - - private final Rose rose; - private final ISkinParam param; - private final LinkType linkType; - - public static PathDrawerInterface create(ISkinParam param, LinkType linkType) { - return new PathDrawerInterface(new Rose(), param, linkType); - } - - private PathDrawerInterface(Rose rose, ISkinParam param, LinkType linkType) { - this.rose = rose; - this.param = param; - this.linkType = linkType; - } - - public void drawPathBefore(UGraphic ug, Positionable start, Positionable end, Path path) { - // // final DotPath dotPath = path.getDotPath(); - // // goDash(ug); - // // ug.draw(0, 0, dotPath); - // // noDash(ug); - } - - private void noDash(UGraphic ug) { - // ug.getParam().resetStroke(); - throw new UnsupportedOperationException(); - } - - private void goDash(UGraphic ug) { - // ug.getParam().setStroke(new UStroke(8, 8, 1.0)); - throw new UnsupportedOperationException(); - } - - public void drawPathAfter(UGraphic ug, Positionable start, Positionable end, Path path) { - DotPath dotPath = path.getDotPath(); - final Racorder racorder = new RacorderOrthogonal(); - // final Racorder racorder = new RacorderInToCenter(); - // final Racorder racorder = new RacorderFollowTangeante(); - - final Point2D endPath = dotPath.getEndPoint(); - final DotPath in = racorder.getRacordIn(PositionableUtils.convert(end), dotPath.getEndTangeante()); - // final Point2D inPoint = in.getFrontierIntersection(end); - final Point2D inPoint = in.getEndPoint(); - // final double theta1_ = in.getEndAngle() + Math.PI / 2; - // Log.println("theta1_=" + theta1_ + " " + theta1_ * 180 / - // Math.PI); - final double theta1 = atan2(endPath, inPoint); - // Log.println("theta1=" + theta1 + " " + theta1 * 180 / - // Math.PI); - final Point2D middle1 = drawSymbol(ug, theta1, inPoint, linkType.getDecor1()); - - final Point2D startPath = dotPath.getStartPoint(); - final DotPath out = racorder.getRacordOut(PositionableUtils.convert(start), dotPath.getStartTangeante()); - // final Point2D outPoint = out.getFrontierIntersection(start); - final Point2D outPoint = out.getStartPoint(); - // final double theta2_ = out.getStartAngle() - Math.PI / 2; - // Log.println("theta2_=" + theta2_ + " " + theta2_ * 180 / - // Math.PI); - final double theta2 = atan2(startPath, outPoint); - // Log.println("theta2=" + theta2 + " " + theta2 * 180 / - // Math.PI); - final Point2D middle2 = drawSymbol(ug, theta2, outPoint, linkType.getDecor2()); - - if (middle1 != null) { - final CubicCurve2D.Double after = getLine(endPath, middle1); - dotPath = dotPath.addAfter(after); - // dotPath = dotPath.addAfter(in); - } - - if (middle2 != null) { - final CubicCurve2D.Double before = getLine(middle2, startPath); - dotPath = dotPath.addBefore(before); - // dotPath = dotPath.addBefore(out); - } - - final LinkStyle style = linkType.getStyle(); -// if (style == LinkStyle.__toremove_INTERFACE_PROVIDER || style == LinkStyle.__toremove_INTERFACE_USER) { -// final Decor decor = new DecorInterfaceProvider(style); -// final Map<Point2D, Double> all = dotPath.somePoints(); -// final Point2D p = getFarest(outPoint, inPoint, all.keySet()); -// -// ug = ug.apply(new UChangeBackColor(rose.getHtmlColor(param, ColorParam.background))); -// ug = ug.apply(new UChangeColor(rose.getHtmlColor(param, ColorParam.classBorder))); -// -// decor.drawDecor(ug, p, all.get(p)); -// } - - throw new UnsupportedOperationException(); -// ug = ug.apply(new UChangeColor(rose.getHtmlColor(param, ColorParam.classBorder))); -// if (linkType.isDashed()) { -// goDash(ug); -// } -// ug.draw(dotPath); -// if (linkType.isDashed()) { -// noDash(ug); -// } - } - - private double atan2(final Point2D endPath, final Point2D inPoint) { - final double y = -endPath.getX() + inPoint.getX(); - final double x = endPath.getY() - inPoint.getY(); - final double angle = Math.atan2(y, x); - // Log.println("x=" + x + " y=" + y + " angle=" + angle + " " + angle * 180.0 / Math.PI); - return angle; - } - - private Point2D drawSymbol(UGraphic ug, double theta, final Point2D position, LinkDecor decor) { - // if (1==1) { - // return null; - // } - // Point2D middle1 = null; - // // final double theta = Math.atan2( - // // -direction.getX() + position.getX(), direction.getY() - // // - position.getY()); - // if (decor == LinkDecor.SQUARRE) { - // middle1 = drawSquare(ug, position.getX(), position.getY()); - // } else if (decor == LinkDecor.EXTENDS) { - // middle1 = drawExtends(ug, position.getX(), position.getY(), theta); - // } else if (decor == LinkDecor.AGREGATION) { - // ug.getParam().setBackcolor(rose.getHtmlColor(param, ColorParam.background)); - // ug.getParam().setColor(rose.getHtmlColor(param, ColorParam.classBorder)); - // middle1 = drawDiamond(ug, position.getX(), position.getY(), theta); - // } else if (decor == LinkDecor.COMPOSITION) { - // ug.getParam().setBackcolor(rose.getHtmlColor(param, ColorParam.classBorder)); - // ug.getParam().setColor(null); - // middle1 = drawDiamond(ug, position.getX(), position.getY(), theta); - // } else if (decor == LinkDecor.NONE) { - // middle1 = position; - // } else if (decor == LinkDecor.ARROW) { - // ug.getParam().setBackcolor(rose.getHtmlColor(param, ColorParam.classBorder)); - // ug.getParam().setColor(rose.getHtmlColor(param, ColorParam.classBorder)); - // middle1 = drawArrow(ug, position.getX(), position.getY(), theta); - // } - // return middle1; - throw new UnsupportedOperationException(); - } - - private CubicCurve2D.Double getLine(final Point2D p1, Point2D p2) { - return new CubicCurve2D.Double(p1.getX(), p1.getY(), p1.getX(), p1.getY(), p2.getX(), p2.getY(), p2.getX(), - p2.getY()); - } - - private static Point2D getFarest(Point2D p1, Point2D p2, Collection<Point2D> all) { - Point2D result = null; - double farest = 0; - for (Point2D p : all) { - if (result == null) { - result = p; - farest = p1.distanceSq(result) + p2.distanceSq(result); - continue; - } - final double candidat = p1.distanceSq(p) + p2.distanceSq(p); - if (candidat < farest) { - result = p; - farest = candidat; - } - } - if (result == null) { - throw new IllegalArgumentException(); - } - return result; - } - - private Point2D drawSquare(UGraphic ug, double centerX, double centerY) { - ug = ug.apply(new UChangeBackColor(rose.getHtmlColor(param, ColorParam.classBackground))); - ug = ug.apply(new UChangeColor(rose.getHtmlColor(param, ColorParam.classBorder))); - final double width = 10; - final double height = 10; - ug.apply(new UTranslate(centerX - width / 2, centerY - height / 2)).draw(new URectangle(width, height)); - return new Point2D.Double(centerX, centerY); - } - - Point2D drawExtends(UGraphic ug, double x, double y, double theta) { - ug = ug.apply(new UChangeBackColor(rose.getHtmlColor(param, ColorParam.background))); - ug = ug.apply(new UChangeColor(rose.getHtmlColor(param, ColorParam.classBorder))); - - // final double theta = Math.atan2(-pathPoint.getX() + x, - // pathPoint.getY() - y); - - final UPolygon triangle = new UPolygon(); - triangle.addPoint(0, 1); - final double width = 18; - final double height = 26; - triangle.addPoint(-width / 2, height); - triangle.addPoint(width / 2, height); - triangle.rotate(theta); - ug.apply(new UTranslate(x, y)).draw(triangle); - - final Point2D middle = BezierUtils.middle(triangle.getPoints().get(1), triangle.getPoints().get(2)); - middle.setLocation(middle.getX() + x, middle.getY() + y); - return middle; - } - - private Point2D drawDiamond(UGraphic ug, double x, double y, double theta) { - - // final double theta = Math.atan2(-pathPoint.getX() + x, - // pathPoint.getY() - y); - - final UPolygon triangle = new UPolygon(); - triangle.addPoint(0, 0); - final double width = 10; - final double height = 14; - triangle.addPoint(-width / 2, height / 2); - triangle.addPoint(0, height); - triangle.addPoint(width / 2, height / 2); - triangle.rotate(theta); - ug.apply(new UTranslate(x, y)).draw(triangle); - - final Point2D middle = triangle.getPoints().get(2); - middle.setLocation(middle.getX() + x, middle.getY() + y); - return middle; - - } - - private Point2D drawArrow(UGraphic ug, double x, double y, double theta) { - - // final double theta = Math.atan2(-pathPoint.getX() + x, - // pathPoint.getY() - y); - - final UPolygon triangle = new UPolygon(); - triangle.addPoint(0, 0); - final double width = 12; - final double height = 10; - triangle.addPoint(-width / 2, height); - final double height2 = 4; - triangle.addPoint(0, height2); - triangle.addPoint(width / 2, height); - triangle.rotate(theta); - ug.apply(new UTranslate(x, y)).draw(triangle); - - final Point2D middle = triangle.getPoints().get(2); - middle.setLocation(middle.getX() + x, middle.getY() + y); - return middle; - } - - private Point2D nullIfContained(Point2D p, Positionable start, Positionable end) { - if (PositionableUtils.contains(start, p)) { - return null; - } - if (PositionableUtils.contains(end, p)) { - return null; - } - return p; - } - - // private void drawPath(UGraphic ug, PointList points, Positionable start, - // Positionable end) { - // Decor decor = new DecorInterfaceProvider(); - // Point2D last = null; - // final int nb = 10; - // final double t1 = - // points.getIntersectionDouble(PositionableUtils.convert(start)); - // final double t2 = - // points.getIntersectionDouble(PositionableUtils.convert(end)); - // for (int i = 0; i <= nb; i++) { - // final double d = t1 + (t2 - t1) * i / nb; - // final Point2D cur = nullIfContained(points.getPoint(d), start, end); - // if (last != null && cur != null) { - // ug.draw(last.getX(), last.getY(), new ULine(cur.getX() - last.getX(), - // cur.getY() - last.getY())); - // if (decor != null) { - // decor.drawLine(ug, last, cur); - // decor = null; - // } - // } - // last = cur; - // } - // - // for (Point2D p : points.getPoints()) { - // ug.draw(p.getX() - 1, p.getY() - 1, new UEllipse(2, 2)); - // } - // } - -} diff --git a/src/net/sourceforge/plantuml/posimo/Racorder.java b/src/net/sourceforge/plantuml/posimo/Racorder.java deleted file mode 100644 index 05a2858..0000000 --- a/src/net/sourceforge/plantuml/posimo/Racorder.java +++ /dev/null @@ -1,44 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.posimo; - -import java.awt.geom.Line2D; -import java.awt.geom.Rectangle2D; - -public interface Racorder { - public DotPath getRacordIn(Rectangle2D rect, Line2D tangeante); - public DotPath getRacordOut(Rectangle2D rect, Line2D tangeante); -} diff --git a/src/net/sourceforge/plantuml/posimo/RacorderAbstract.java b/src/net/sourceforge/plantuml/posimo/RacorderAbstract.java deleted file mode 100644 index f6c478e..0000000 --- a/src/net/sourceforge/plantuml/posimo/RacorderAbstract.java +++ /dev/null @@ -1,58 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.posimo; - -import java.awt.geom.Line2D; -import java.awt.geom.Rectangle2D; - -public abstract class RacorderAbstract implements Racorder { - - public final DotPath getRacordOut(Rectangle2D rect, Line2D tangeante) { - tangeante = symetric(tangeante); - return getRacordIn(rect, tangeante).reverse(); - } - - private static Line2D symetric(Line2D line) { - final double x1 = line.getX1(); - final double y1 = line.getY1(); - final double x2 = line.getX2(); - final double y2 = line.getY2(); - final double dx = x2 - x1; - final double dy = y2 - y1; - return new Line2D.Double(x1, y1, x1 - dx, y1 - dy); - } - -} diff --git a/src/net/sourceforge/plantuml/posimo/RacorderFollowTangeante.java b/src/net/sourceforge/plantuml/posimo/RacorderFollowTangeante.java deleted file mode 100644 index e9af35e..0000000 --- a/src/net/sourceforge/plantuml/posimo/RacorderFollowTangeante.java +++ /dev/null @@ -1,73 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.posimo; - -import java.awt.geom.CubicCurve2D; -import java.awt.geom.Line2D; -import java.awt.geom.Point2D; -import java.awt.geom.Rectangle2D; - -public class RacorderFollowTangeante extends RacorderAbstract implements Racorder { - - public DotPath getRacordIn(Rectangle2D rect, Line2D tangeante) { - -// Log.println("rect x=" + rect.getX() + " y=" + rect.getY() + " w=" + rect.getWidth() + " h=" -// + rect.getHeight()); -// Log.println("tangeante (" + tangeante.getX1() + "," + tangeante.getY1() + ") (" + tangeante.getX2() -// + "," + tangeante.getY2() + ")"); - - final DotPath result = new DotPath(); - - // final Point2D inter = BezierUtils.intersect((Line2D.Double) - // tangeante, rect); - Point2D inter = new LineRectIntersection(tangeante, rect).getIntersection(); -// Log.println("inter=" + inter); - - if (inter == null) { - final Point2D p1 = new Point2D.Double(rect.getMinX(), rect.getMinY()); - final Point2D p2 = new Point2D.Double(rect.getMaxX(), rect.getMinY()); - final Point2D p3 = new Point2D.Double(rect.getMaxX(), rect.getMaxY()); - final Point2D p4 = new Point2D.Double(rect.getMinX(), rect.getMaxY()); - - inter = LineRectIntersection.getCloser(tangeante.getP1(), p1, p2, p3, p4); - } - - final CubicCurve2D.Double curv = new CubicCurve2D.Double(tangeante.getX1(), tangeante.getY1(), - tangeante.getX1(), tangeante.getY1(), inter.getX(), inter.getY(), inter.getX(), inter.getY()); - return result.addAfter(curv); - } - -} diff --git a/src/net/sourceforge/plantuml/posimo/RacorderFollowTangeanteOld.java b/src/net/sourceforge/plantuml/posimo/RacorderFollowTangeanteOld.java deleted file mode 100644 index ea15f31..0000000 --- a/src/net/sourceforge/plantuml/posimo/RacorderFollowTangeanteOld.java +++ /dev/null @@ -1,58 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.posimo; - -import java.awt.geom.CubicCurve2D; -import java.awt.geom.Line2D; -import java.awt.geom.Point2D; -import java.awt.geom.Rectangle2D; - -public class RacorderFollowTangeanteOld extends RacorderAbstract implements Racorder { - - public DotPath getRacordIn(Rectangle2D rect, Line2D tangeante) { - - final DotPath result = new DotPath(); - - final Point2D center = new Point2D.Double(rect.getCenterX(), rect.getCenterY()); - final Line2D.Double line = new Line2D.Double(tangeante.getP1(), center); - final Point2D inter = BezierUtils.intersect(line, rect); - - final CubicCurve2D.Double curv = new CubicCurve2D.Double(tangeante.getX1(), tangeante.getY1(), tangeante - .getX2(), tangeante.getY2(), tangeante.getX2(), tangeante.getY2(), inter.getX(), inter.getY()); - return result.addAfter(curv); - } - -} diff --git a/src/net/sourceforge/plantuml/posimo/RacorderInToCenter.java b/src/net/sourceforge/plantuml/posimo/RacorderInToCenter.java deleted file mode 100644 index 606b200..0000000 --- a/src/net/sourceforge/plantuml/posimo/RacorderInToCenter.java +++ /dev/null @@ -1,57 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.posimo; - -import java.awt.geom.CubicCurve2D; -import java.awt.geom.Line2D; -import java.awt.geom.Point2D; -import java.awt.geom.Rectangle2D; - -public class RacorderInToCenter extends RacorderAbstract implements Racorder { - - public DotPath getRacordIn(Rectangle2D rect, Line2D tangeante) { - final DotPath result = new DotPath(); - - final Point2D center = new Point2D.Double(rect.getCenterX(), rect.getCenterY()); - final Line2D.Double line = new Line2D.Double(tangeante.getP1(), center); - final Point2D inter = BezierUtils.intersect(line, rect); - - final CubicCurve2D.Double curv = new CubicCurve2D.Double(line.getX1(), line.getY1(), line.getX1(), - line.getY1(), inter.getX(), inter.getY(), inter.getX(), inter.getY()); - return result.addAfter(curv); - } - -} diff --git a/src/net/sourceforge/plantuml/posimo/RacorderOrthogonal.java b/src/net/sourceforge/plantuml/posimo/RacorderOrthogonal.java deleted file mode 100644 index 65ab209..0000000 --- a/src/net/sourceforge/plantuml/posimo/RacorderOrthogonal.java +++ /dev/null @@ -1,83 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.posimo; - -import java.awt.geom.CubicCurve2D; -import java.awt.geom.Line2D; -import java.awt.geom.Point2D; -import java.awt.geom.Rectangle2D; - -public class RacorderOrthogonal extends RacorderAbstract implements Racorder { - - public DotPath getRacordIn(Rectangle2D rect, Line2D tangeante) { - - final Point2D in = tangeante.getP1(); - - final DotPath result = new DotPath(); - Point2D inter = null; - - if (in.getX() > rect.getMinX() && in.getX() < rect.getMaxX()) { - if (in.getY() < rect.getMinY()) { - inter = new Point2D.Double(in.getX(), rect.getMinY()); - } else if (in.getY() > rect.getMaxY()) { - inter = new Point2D.Double(in.getX(), rect.getMaxY()); - } else { - throw new IllegalArgumentException(); - } - } else if (in.getY() > rect.getMinY() && in.getY() < rect.getMaxY()) { - if (in.getX() < rect.getMinX()) { - inter = new Point2D.Double(rect.getMinX(), in.getY()); - } else if (in.getX() > rect.getMaxX()) { - inter = new Point2D.Double(rect.getMaxX(), in.getY()); - } else { - throw new IllegalArgumentException(); - } - } else { - final Point2D p1 = new Point2D.Double(rect.getMinX(), rect.getMinY()); - final Point2D p2 = new Point2D.Double(rect.getMaxX(), rect.getMinY()); - final Point2D p3 = new Point2D.Double(rect.getMaxX(), rect.getMaxY()); - final Point2D p4 = new Point2D.Double(rect.getMinX(), rect.getMaxY()); - - inter = LineRectIntersection.getCloser(tangeante.getP1(), p1, p2, p3, p4); - - } - - final CubicCurve2D.Double curv = new CubicCurve2D.Double(tangeante.getX1(), tangeante.getY1(), - tangeante.getX1(), tangeante.getY1(), inter.getX(), inter.getY(), inter.getX(), inter.getY()); - return result.addAfter(curv); - } - -} diff --git a/src/net/sourceforge/plantuml/posimo/SimpleDrawer.java b/src/net/sourceforge/plantuml/posimo/SimpleDrawer.java deleted file mode 100644 index 37169ea..0000000 --- a/src/net/sourceforge/plantuml/posimo/SimpleDrawer.java +++ /dev/null @@ -1,99 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.posimo; - -import java.awt.Color; -import java.awt.Graphics2D; -import java.awt.geom.Dimension2D; -import java.awt.geom.Point2D; -import java.awt.geom.Rectangle2D; -import java.util.ArrayList; -import java.util.Collection; - -public class SimpleDrawer { - - private final Cluster root; - private final Collection<Path> paths; - - public SimpleDrawer(Cluster root, Collection<Path> paths) { - this.root = root; - this.paths = paths; - } - - public void draw(Graphics2D g2d) { - g2d.setColor(Color.BLACK); - for (Clusterable cl : root.getContents()) { - final Block b = (Block) cl; - final Point2D pos = b.getPosition(); - final Dimension2D dim = b.getSize(); - // drawRectCentered(g2d, pos, dim); - drawRect(g2d, pos, dim); - } - - g2d.setColor(Color.GREEN); - for (Path p : paths) { - final Label label = p.getLabel(); - final Point2D labelPos = label.getPosition(); - final Dimension2D labelDim = label.getSize(); - // final double x1 = labelPos.getX(); - // final double y1 = labelPos.getY(); - // g2d.draw(new Ellipse2D.Double(x1 - 1, y1 - 1, 3, 3)); - // drawRectCentered(g2d, labelPos, labelDim); - drawRect(g2d, labelPos, labelDim); - } - - g2d.setColor(Color.RED); - for (Path p : paths) { - p.getDotPath().draw(g2d, 0, 0); - } - - for (Cluster sub : root.getSubClusters()) { - new SimpleDrawer(sub, new ArrayList<Path>()).draw(g2d); - } - - } - - private void drawRectCentered(Graphics2D g2d, final Point2D pos, final Dimension2D dim) { - final Rectangle2D rect = new Rectangle2D.Double(pos.getX() - dim.getWidth() / 2, pos.getY() - dim.getHeight() - / 2, dim.getWidth(), dim.getHeight()); - g2d.draw(rect); - } - - private void drawRect(Graphics2D g2d, final Point2D pos, final Dimension2D dim) { - final Rectangle2D rect = new Rectangle2D.Double(pos.getX(), pos.getY(), dim.getWidth(), dim.getHeight()); - g2d.draw(rect); - } -} diff --git a/src/net/sourceforge/plantuml/posimo/TwoLinesIntersection.java b/src/net/sourceforge/plantuml/posimo/TwoLinesIntersection.java deleted file mode 100644 index 963496e..0000000 --- a/src/net/sourceforge/plantuml/posimo/TwoLinesIntersection.java +++ /dev/null @@ -1,73 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.posimo; - -import java.awt.geom.Line2D; -import java.awt.geom.Point2D; - -public class TwoLinesIntersection { - - private final Point2D inter; - - public TwoLinesIntersection(Line2D lineA, Line2D lineB) { - final double x1 = lineA.getX1(); - final double y1 = lineA.getY1(); - final double x2 = lineA.getX2(); - final double y2 = lineA.getY2(); - final double x3 = lineB.getX1(); - final double y3 = lineB.getY1(); - final double x4 = lineB.getX2(); - final double y4 = lineB.getY2(); - - final double den = (y4 - y3) * (x2 - x1) - (x4 - x3) * (y2 - y1); - - final double uA1 = (x4 - x3) * (y1 - y3) - (y4 - y3) * (x1 - x3); - final double uA = uA1 / den; - - // final double uB1 = (x2 - x1) * (y1 - y3) - (y2 - y1) * (x1 - x3); - // uB = uB1 / den; - - final double x = x1 + uA * (x2 - x1); - final double y = y1 + uA * (y2 - y1); - - inter = new Point2D.Double(x, y); - } - - public final Point2D getIntersection() { - return inter; - } - -} diff --git a/src/net/sourceforge/plantuml/posimo/data.txt b/src/net/sourceforge/plantuml/posimo/data.txt deleted file mode 100644 index 2fe8aec..0000000 --- a/src/net/sourceforge/plantuml/posimo/data.txt +++ /dev/null @@ -1,38 +0,0 @@ -@startuml -interface Positionable { - + Dimension2D getSize(); - + Point2D getPosition(); -} - -interface Clusterable { - +Cluster getParent(); -} - -Positionable <|-- Clusterable - -class Cluster - -Cluster *-- Cluster : subclusters -Clusterable <|.. Cluster -Cluster *-- Block -Clusterable <|.. Block - -Path *-- "2" Cluster -Path --> Label : has one -Positionable <|-- Label - -SimpleDrawer --> Cluster -SimpleDrawer *--> Path - -class GraphvizSolver { - + Dimension2D solve(Cluster root, Collection<Path> paths) -} -GraphvizSolver --> Cluster -GraphvizSolver *--> Path - - -'Clusterable --> Cluster : Parent - - - -@enduml diff --git a/src/net/sourceforge/plantuml/project/BasicInstantArithmetic.java b/src/net/sourceforge/plantuml/project/BasicInstantArithmetic.java deleted file mode 100644 index 2f6a554..0000000 --- a/src/net/sourceforge/plantuml/project/BasicInstantArithmetic.java +++ /dev/null @@ -1,84 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.project; - -class BasicInstantArithmetic implements InstantArithmetic { - - private final DayClose dayClose; - - BasicInstantArithmetic(DayClose dayClose) { - if (dayClose == null) { - throw new IllegalArgumentException(); - } - this.dayClose = dayClose; - } - - public Instant add(Instant i1, Duration duration) { - Instant result = i1; - final long min = duration.getMinutes(); - if (min < 0) { - throw new IllegalArgumentException(); - } - for (long i = 0; i < min; i += 24 * 60 * 60) { - result = result.next(dayClose); - } - return result; - } - - public Instant sub(Instant i1, Duration duration) { - Instant result = i1; - final long min = duration.getMinutes(); - if (min < 0) { - throw new IllegalArgumentException(); - } - for (long i = 0; i < min; i += 24 * 60 * 60) { - result = result.prev(dayClose); - } - return result; - } - - public Duration diff(Instant i1, Instant i2) { - if (i2.compareTo(i1) < 0) { - throw new IllegalArgumentException(); - } - long minutes = 0; - while (i2.compareTo(i1) > 0) { - minutes += 24 * 60 * 60; - i1 = i1.next(null); - } - return new Duration(minutes); - } -} diff --git a/src/net/sourceforge/plantuml/project/Constant.java b/src/net/sourceforge/plantuml/project/Constant.java deleted file mode 100644 index d76b5a3..0000000 --- a/src/net/sourceforge/plantuml/project/Constant.java +++ /dev/null @@ -1,58 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.project; - -class Constant implements Expression { - - private final Numeric value; - - public Constant(Numeric value) { - this.value = value; - } - - public String getDescription() { - return "Constant:" + value; - } - - public NumericType getNumericType() { - return value.getNumericType(); - } - - public Numeric getValue() { - return value; - } - -} diff --git a/src/net/sourceforge/plantuml/project/Day.java b/src/net/sourceforge/plantuml/project/Day.java deleted file mode 100644 index 5cba10e..0000000 --- a/src/net/sourceforge/plantuml/project/Day.java +++ /dev/null @@ -1,177 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.project; - -import java.util.Calendar; -import java.util.GregorianCalendar; - -public class Day implements Comparable<Day> { - - private final int numDay; - private final Month month; - private final int year; - private final WeekDay weekDay; - - private Day(int year, Month month, int numDay, WeekDay weekDay) { - this.year = year; - this.month = month; - this.numDay = numDay; - this.weekDay = weekDay; - } - - public static boolean isValidDesc(String desc) { - if (desc.matches("^\\d{4}/\\d{2}/\\d{2}$")) { - return true; - } - if (desc.matches("^\\d{2}-[A-Za-z]{3}-\\d{4}$")) { - return true; - } - return false; - } - - public Day(String desc) { - if (desc.matches("^\\d{4}/\\d{2}/\\d{2}$")) { - this.year = Integer.parseInt(desc.substring(0, 4)); - this.month = Month.fromNum(Integer.parseInt(desc.substring(5, 7))); - this.numDay = Integer.parseInt(desc.substring(8, 10)); - } else if (desc.matches("^\\d{2}-[A-Za-z]{3}-\\d{4}$")) { - this.year = Integer.parseInt(desc.substring(7, 11)); - this.month = Month.valueOf(desc.substring(3, 6)); - this.numDay = Integer.parseInt(desc.substring(0, 2)); - } else { - throw new IllegalArgumentException(desc); - } - final int wd = new GregorianCalendar(year, month.getNum() - 1, numDay).get(Calendar.DAY_OF_WEEK); - this.weekDay = WeekDay.values()[wd - 1]; - } - - public Day next(DayClose dayClose) { - if (dayClose == null) { - return nextInternal(); - } - if (dayClose.isClose(this)) { - throw new IllegalArgumentException(); - } - Day result = nextInternal(); - while (dayClose.isClose(result)) { - result = result.nextInternal(); - } - return result; - } - - public Day prev(DayClose dayClose) { - if (dayClose == null) { - return prevInternal(); - } - if (dayClose.isClose(this)) { - throw new IllegalArgumentException(); - } - Day result = prevInternal(); - while (dayClose.isClose(result)) { - result = result.prevInternal(); - } - return result; - } - - private Day nextInternal() { - if (numDay < month.getNbDays(year)) { - return new Day(year, month, numDay + 1, weekDay.next()); - } - final Month next = month.next(); - if (next == null) { - return new Day(year + 1, Month.JAN, 1, weekDay.next()); - } - return new Day(year, next, 1, weekDay.next()); - } - - private Day prevInternal() { - if (numDay > 1) { - return new Day(year, month, numDay - 1, weekDay.prev()); - } - final Month prev = month.prev(); - if (prev == null) { - return new Day(year - 1, Month.DEC, 31, weekDay.prev()); - } - return new Day(year, prev, prev.getNbDays(year), weekDay.prev()); - } - - @Override - public String toString() { - return "" + weekDay + " " + year + "-" + month + "-" + String.format("%02d", numDay); - } - - public final int getNumDay() { - return numDay; - } - - public final Month getMonth() { - return month; - } - - public final int getYear() { - return year; - } - - public int compareTo(Day other) { - if (year > other.year) { - return 1; - } - if (year < other.year) { - return -1; - } - final int cmpMonth = month.compareTo(other.month); - if (cmpMonth != 0) { - return cmpMonth; - } - return numDay - other.numDay; - } - - @Override - public boolean equals(Object obj) { - final Day this2 = (Day) obj; - return this.numDay == this2.numDay && this.month == this2.month && this.year == this2.year; - } - - @Override - public int hashCode() { - return numDay * 420 + year + month.hashCode(); - } - - public final WeekDay getWeekDay() { - return weekDay; - } - -} diff --git a/src/net/sourceforge/plantuml/project/DayClose.java b/src/net/sourceforge/plantuml/project/DayClose.java deleted file mode 100644 index 676bc55..0000000 --- a/src/net/sourceforge/plantuml/project/DayClose.java +++ /dev/null @@ -1,42 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.project; - -interface DayClose { - - boolean isClose(Day day); - -} diff --git a/src/net/sourceforge/plantuml/project/DayCloseNone.java b/src/net/sourceforge/plantuml/project/DayCloseNone.java deleted file mode 100644 index 4add1aa..0000000 --- a/src/net/sourceforge/plantuml/project/DayCloseNone.java +++ /dev/null @@ -1,44 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.project; - -class DayCloseNone implements DayClose { - - public boolean isClose(Day day) { - return false; - } - -} diff --git a/src/net/sourceforge/plantuml/project/DayCloseOr.java b/src/net/sourceforge/plantuml/project/DayCloseOr.java deleted file mode 100644 index ce91e1d..0000000 --- a/src/net/sourceforge/plantuml/project/DayCloseOr.java +++ /dev/null @@ -1,58 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.project; - -import java.util.ArrayList; -import java.util.List; - -class DayCloseOr implements DayClose { - - private final List<DayClose> all = new ArrayList<DayClose>(); - - public boolean isClose(Day day) { - for (DayClose dc : all) { - if (dc.isClose(day)) { - return true; - } - } - return false; - } - - public void add(DayClose dayClose) { - all.add(dayClose); - } - -} diff --git a/src/net/sourceforge/plantuml/project/DayCloseWeekDay.java b/src/net/sourceforge/plantuml/project/DayCloseWeekDay.java deleted file mode 100644 index 5b0ff6f..0000000 --- a/src/net/sourceforge/plantuml/project/DayCloseWeekDay.java +++ /dev/null @@ -1,53 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.project; - -class DayCloseWeekDay implements DayClose { - - private final WeekDay weekDay; - - public DayCloseWeekDay(WeekDay weekDay) { - this.weekDay = weekDay; - } - - public boolean isClose(Day day) { - if (day.getWeekDay() == weekDay) { - return true; - } - return false; - } - -} diff --git a/src/net/sourceforge/plantuml/project/Duration.java b/src/net/sourceforge/plantuml/project/Duration.java deleted file mode 100644 index 05f562d..0000000 --- a/src/net/sourceforge/plantuml/project/Duration.java +++ /dev/null @@ -1,82 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.project; - -class Duration implements Numeric { - - private final long minutes; - - public Duration(long minutes) { - this.minutes = minutes; - } - - public Duration(NumericNumber value) { - this(value.getIntValue() * 24L * 60 * 60); - } - - public Numeric add(Numeric other) { - return new Duration(((Duration) other).minutes + minutes); - } - - public static Duration of(long days) { - return new Duration(days * 24 * 60 * 60); - } - - public NumericType getNumericType() { - return NumericType.DURATION; - } - - public long getMinutes() { - return minutes; - } - - @Override - public String toString() { - return "DURATION:" + minutes / (24 * 60 * 60); - } - - public int compareTo(Numeric other) { - final Duration this2 = (Duration) other; - if (this2.minutes > minutes) { - return -1; - } - if (this2.minutes < minutes) { - return 1; - } - return 0; - } - -} diff --git a/src/net/sourceforge/plantuml/project/Expression.java b/src/net/sourceforge/plantuml/project/Expression.java deleted file mode 100644 index 61b6fc6..0000000 --- a/src/net/sourceforge/plantuml/project/Expression.java +++ /dev/null @@ -1,46 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.project; - -public interface Expression { - - Numeric getValue(); - - String getDescription(); - - NumericType getNumericType(); - -} diff --git a/src/net/sourceforge/plantuml/project/Formal.java b/src/net/sourceforge/plantuml/project/Formal.java deleted file mode 100644 index 2f6f960..0000000 --- a/src/net/sourceforge/plantuml/project/Formal.java +++ /dev/null @@ -1,40 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.project; - -interface Formal extends Expression { - -} diff --git a/src/net/sourceforge/plantuml/project/FormalAddition.java b/src/net/sourceforge/plantuml/project/FormalAddition.java deleted file mode 100644 index 212c333..0000000 --- a/src/net/sourceforge/plantuml/project/FormalAddition.java +++ /dev/null @@ -1,60 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.project; - -class FormalAddition implements Formal { - - private final Expression exp1; - private final Expression exp2; - - public FormalAddition(Expression exp1, Expression exp2) { - this.exp1 = exp1; - this.exp2 = exp2; - } - - public String getDescription() { - return "add " + exp1 + " " + exp2; - } - - public NumericType getNumericType() { - return exp1.getNumericType(); - } - - public Numeric getValue() { - return exp1.getValue().add(exp2.getValue()); - } - -} diff --git a/src/net/sourceforge/plantuml/project/FormalAdditionInstantDuration.java b/src/net/sourceforge/plantuml/project/FormalAdditionInstantDuration.java deleted file mode 100644 index 0e6a135..0000000 --- a/src/net/sourceforge/plantuml/project/FormalAdditionInstantDuration.java +++ /dev/null @@ -1,67 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.project; - -class FormalAdditionInstantDuration implements Formal { - - private final Expression exp1; - private final Expression exp2; - private final InstantArithmetic math; - - public FormalAdditionInstantDuration(Expression exp1, Expression exp2, InstantArithmetic math) { - this.exp1 = exp1; - this.exp2 = exp2; - this.math = math; - } - - public String getDescription() { - return "addID " + exp1 + " " + exp2; - } - - public NumericType getNumericType() { - return exp1.getNumericType(); - } - - public Numeric getValue() { - if (exp2.getNumericType() == NumericType.NUMBER) { - final Duration d = new Duration((NumericNumber) exp2.getValue()); - return math.add((Instant) exp1.getValue(), d); - } - - return math.add((Instant) exp1.getValue(), (Duration) exp2.getValue()); - } - -} diff --git a/src/net/sourceforge/plantuml/project/FreeVariable.java b/src/net/sourceforge/plantuml/project/FreeVariable.java deleted file mode 100644 index c72933d..0000000 --- a/src/net/sourceforge/plantuml/project/FreeVariable.java +++ /dev/null @@ -1,71 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.project; - -class FreeVariable implements Expression { - - private Expression value; - private final String name; - private final NumericType type; - - public FreeVariable(String name, NumericType type) { - this.name = name; - this.type = type; - } - - public String getDescription() { - return "$" + name + "=" + (value == null ? "null" : value.getDescription()); - } - - public NumericType getNumericType() { - return type; - } - - public Numeric getValue() { - if (value == null) { - return null; - } - return value.getValue(); - } - - public void setValue(Expression expression) { - if (expression.getNumericType() != type) { - throw new IllegalArgumentException("Bad type"); - } - this.value = expression; - } - -} diff --git a/src/net/sourceforge/plantuml/project/IncompleteItem.java b/src/net/sourceforge/plantuml/project/IncompleteItem.java deleted file mode 100644 index 96b5012..0000000 --- a/src/net/sourceforge/plantuml/project/IncompleteItem.java +++ /dev/null @@ -1,192 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.project; - -import java.util.EnumMap; -import java.util.EnumSet; -import java.util.List; -import java.util.Map; - -class IncompleteItem implements Item { - - private Map<ItemCaract, Numeric> data = new EnumMap<ItemCaract, Numeric>(ItemCaract.class); - - private final InstantArithmetic math; - - private final Item parent; - - private final String code; - - public IncompleteItem(String code, Item parent, InstantArithmetic math) { - this.math = math; - this.code = code; - this.parent = parent; - } - - public void setData(ItemCaract caract, Numeric value) { - if (caract.getNumericType() != value.getNumericType()) { - throw new IllegalArgumentException(); - } - if (data.containsKey(caract.getNumericType())) { - throw new IllegalStateException(); - } - data.put(caract, value); - boolean change = false; - do { - change = false; - change = eventuallyUseBeginComplete() || change; - change = eventuallyUseBeginDuration() || change; - change = eventuallyUseCompleteDuration() || change; - change = eventuallyUseDurationWork() || change; - change = eventuallyUseDurationLoad() || change; - change = eventuallyUseLoadWork() || change; - } while (change); - } - - private boolean eventuallyUseDurationWork() { - if (data.containsKey(ItemCaract.DURATION) && data.containsKey(ItemCaract.WORK) - && data.containsKey(ItemCaract.LOAD) == false) { - final Duration d = (Duration) data.get(ItemCaract.DURATION); - final NumericNumber w = (NumericNumber) data.get(ItemCaract.WORK); - data.put(ItemCaract.LOAD, new Load(d.getMinutes() * w.getIntValue())); - return true; - } - return false; - } - - private boolean eventuallyUseLoadWork() { - if (data.containsKey(ItemCaract.LOAD) && data.containsKey(ItemCaract.WORK) - && data.containsKey(ItemCaract.DURATION) == false) { - final Load l = (Load) data.get(ItemCaract.LOAD); - final NumericNumber w = (NumericNumber) data.get(ItemCaract.WORK); - data.put(ItemCaract.DURATION, new Duration(l.getMinuteMen() / w.getIntValue())); - return true; - } - return false; - } - - private boolean eventuallyUseDurationLoad() { - if (data.containsKey(ItemCaract.DURATION) && data.containsKey(ItemCaract.LOAD) - && data.containsKey(ItemCaract.WORK) == false) { - final Duration d = (Duration) data.get(ItemCaract.DURATION); - final Load l = (Load) data.get(ItemCaract.LOAD); - data.put(ItemCaract.WORK, new NumericNumber((int) (l.getMinuteMen() / d.getMinutes()))); - return true; - } - return false; - } - - private boolean eventuallyUseBeginDuration() { - if (data.containsKey(ItemCaract.BEGIN) && data.containsKey(ItemCaract.DURATION) - && data.containsKey(ItemCaract.COMPLETED) == false) { - final Instant i1 = (Instant) data.get(ItemCaract.BEGIN); - final Duration d = (Duration) data.get(ItemCaract.DURATION); - data.put(ItemCaract.COMPLETED, math.add(i1, d)); - return true; - } - return false; - } - - private boolean eventuallyUseCompleteDuration() { - if (data.containsKey(ItemCaract.COMPLETED) && data.containsKey(ItemCaract.DURATION) - && data.containsKey(ItemCaract.BEGIN) == false) { - final Instant i2 = (Instant) data.get(ItemCaract.COMPLETED); - final Duration d = (Duration) data.get(ItemCaract.DURATION); - data.put(ItemCaract.BEGIN, math.sub(i2, d)); - return true; - } - return false; - } - - private boolean eventuallyUseBeginComplete() { - if (data.containsKey(ItemCaract.BEGIN) && data.containsKey(ItemCaract.COMPLETED) - && data.containsKey(ItemCaract.DURATION) == false) { - final Instant i1 = (Instant) data.get(ItemCaract.BEGIN); - final Instant i2 = (Instant) data.get(ItemCaract.COMPLETED); - if (i2.compareTo(i1) <= 0) { - throw new IllegalArgumentException(); - } - data.put(ItemCaract.DURATION, math.diff(i1, i2)); - return true; - } - return false; - } - - public boolean isValid() { - return data.size() == EnumSet.allOf(ItemCaract.class).size(); - } - - public Instant getBegin() { - return (Instant) data.get(ItemCaract.BEGIN); - } - - public Instant getCompleted() { - return (Instant) data.get(ItemCaract.COMPLETED); - } - - public Duration getDuration() { - return (Duration) data.get(ItemCaract.DURATION); - } - - public Load getLoad() { - return (Load) data.get(ItemCaract.LOAD); - } - - public NumericNumber getWork() { - return (NumericNumber) data.get(ItemCaract.WORK); - } - - public boolean isLeaf() { - return true; - } - - public Item getParent() { - return parent; - } - - public List<Item> getChildren() { - return null; - } - - public String getCode() { - return code; - } - - @Override - public String toString() { - return code + " " + data.toString(); - } -} diff --git a/src/net/sourceforge/plantuml/project/Instant.java b/src/net/sourceforge/plantuml/project/Instant.java deleted file mode 100644 index c9afe8a..0000000 --- a/src/net/sourceforge/plantuml/project/Instant.java +++ /dev/null @@ -1,87 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.project; - -public class Instant implements Numeric { - - private final Day value; - - public Instant(Day d) { - this.value = d; - } - - public Numeric add(Numeric other) { - throw new UnsupportedOperationException(); - } - - public NumericType getNumericType() { - return NumericType.INSTANT; - } - - public Day getDay() { - return value; - } - - public Instant next(DayClose dayClose) { - return new Instant(value.next(dayClose)); - } - - public Instant prev(DayClose dayClose) { - return new Instant(value.prev(dayClose)); - } - - @Override - public String toString() { - return "Instant:" + value; - } - - public int compareTo(Numeric other) { - final Instant this2 = (Instant) other; - return value.compareTo(this2.value); - } - - @Override - public int hashCode() { - return value.hashCode(); - } - - @Override - public boolean equals(Object obj) { - final Instant other = (Instant) obj; - return value.equals(other.value); - } - -} diff --git a/src/net/sourceforge/plantuml/project/InstantArithmetic.java b/src/net/sourceforge/plantuml/project/InstantArithmetic.java deleted file mode 100644 index 2baf2c8..0000000 --- a/src/net/sourceforge/plantuml/project/InstantArithmetic.java +++ /dev/null @@ -1,45 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.project; - -interface InstantArithmetic { - - public Instant add(Instant i1, Duration duration); - - public Instant sub(Instant i1, Duration duration); - - public Duration diff(Instant i1, Instant i2); -} diff --git a/src/net/sourceforge/plantuml/project/Item.java b/src/net/sourceforge/plantuml/project/Item.java deleted file mode 100644 index 9c871a1..0000000 --- a/src/net/sourceforge/plantuml/project/Item.java +++ /dev/null @@ -1,62 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.project; - -import java.util.List; - -public interface Item { - - Instant getBegin(); - - Instant getCompleted(); - - Duration getDuration(); - - Load getLoad(); - - NumericNumber getWork(); - - boolean isLeaf(); - - Item getParent(); - - List<Item> getChildren(); - - public String getCode(); - - public boolean isValid(); - -} diff --git a/src/net/sourceforge/plantuml/project/ItemCaract.java b/src/net/sourceforge/plantuml/project/ItemCaract.java deleted file mode 100644 index 7399124..0000000 --- a/src/net/sourceforge/plantuml/project/ItemCaract.java +++ /dev/null @@ -1,73 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.project; - -enum ItemCaract { - BEGIN(NumericType.INSTANT), // - COMPLETED(NumericType.INSTANT), // - DURATION(NumericType.DURATION), // - LOAD(NumericType.LOAD), // - WORK(NumericType.NUMBER); - - private final NumericType type; - - private ItemCaract(NumericType type) { - this.type = type; - } - - public NumericType getNumericType() { - return type; - } - - public Numeric getData(Item item) { - if (this == BEGIN) { - return item.getBegin(); - } - if (this == COMPLETED) { - return item.getCompleted(); - } - if (this == DURATION) { - return item.getDuration(); - } - if (this == LOAD) { - return item.getLoad(); - } - if (this == WORK) { - return item.getWork(); - } - throw new UnsupportedOperationException(); - } -} diff --git a/src/net/sourceforge/plantuml/project/ItemComparator.java b/src/net/sourceforge/plantuml/project/ItemComparator.java deleted file mode 100644 index c18e5e0..0000000 --- a/src/net/sourceforge/plantuml/project/ItemComparator.java +++ /dev/null @@ -1,60 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.project; - -import java.util.Comparator; - -public class ItemComparator implements Comparator<Item> { - - public int compare(Item it1, Item it2) { - final int cmp1 = it1.getBegin().compareTo(it2.getBegin()); - if (cmp1 != 0) { - return cmp1; - } - if (it1 instanceof Jalon && it2 instanceof Jalon == false) { - return -1; - } - if (it2 instanceof Jalon && it1 instanceof Jalon == false) { - return 1; - } - final int cmp2 = it2.getCompleted().compareTo(it1.getCompleted()); - if (cmp2 != 0) { - return cmp2; - } - return it1.getCode().compareTo(it2.getCode()); - } - -} diff --git a/src/net/sourceforge/plantuml/project/Jalon.java b/src/net/sourceforge/plantuml/project/Jalon.java deleted file mode 100644 index a82dd83..0000000 --- a/src/net/sourceforge/plantuml/project/Jalon.java +++ /dev/null @@ -1,95 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.project; - -import java.util.List; - -public class Jalon implements Item { - - private Instant begin; - private final String code; - private final Item parent; - - public Jalon(String code, Item parent) { - this.code = code; - this.parent = parent; - } - - public Instant getBegin() { - return begin; - } - - public Instant getCompleted() { - return begin; - } - - public Duration getDuration() { - return new Duration(0); - } - - public Load getLoad() { - return new Load(0); - } - - public NumericNumber getWork() { - return new NumericNumber(1); - } - - public boolean isLeaf() { - return true; - } - - public Item getParent() { - return parent; - } - - public List<Item> getChildren() { - return null; - } - - public String getCode() { - return code; - } - - public boolean isValid() { - return begin != null; - } - - public void setInstant(Numeric value) { - this.begin = (Instant) value; - } - -} diff --git a/src/net/sourceforge/plantuml/project/Load.java b/src/net/sourceforge/plantuml/project/Load.java deleted file mode 100644 index a4f7b19..0000000 --- a/src/net/sourceforge/plantuml/project/Load.java +++ /dev/null @@ -1,80 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.project; - -class Load implements Numeric { - - private final long minuteMen; - - public Load(long minuteMen) { - this.minuteMen = minuteMen; - } - - public Load(NumericNumber value) { - this(value.getIntValue() * 24L * 60 * 60); - } - - public Numeric add(Numeric other) { - return new Load(((Load) other).minuteMen + minuteMen); - } - - public NumericType getNumericType() { - return NumericType.LOAD; - } - - public int compareTo(Numeric other) { - final Load this2 = (Load) other; - if (this2.minuteMen > minuteMen) { - return -1; - } - if (this2.minuteMen < minuteMen) { - return 1; - } - return 0; - } - - public final long getMinuteMen() { - return minuteMen; - } - - @Override - public String toString() { - return "LOAD:" + minuteMen / (24 * 60 * 60); - } - - - -} diff --git a/src/net/sourceforge/plantuml/project/Month.java b/src/net/sourceforge/plantuml/project/Month.java deleted file mode 100644 index b8932a8..0000000 --- a/src/net/sourceforge/plantuml/project/Month.java +++ /dev/null @@ -1,90 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.project; - -import java.util.ArrayList; -import java.util.EnumSet; -import java.util.List; - -public enum Month { - - JAN(31), FEB(28), MAR(31), APR(30), MAY(31), JUN(30), JUL(31), AUG(31), SEP(30), OCT(31), NOV(30), DEC(31); - - final private int nbDays; - - private Month(int nbDays) { - this.nbDays = nbDays; - } - - public final int getNbDays(int year) { - if (this == FEB && year % 4 == 0) { - return 29; - } - return nbDays; - } - - public final int getNum() { - return ordinal() + 1; - } - - public final int getNumNormal() { - return ordinal(); - } - - public Month next() { - if (this == DEC) { - return null; - } - final List<Month> all = new ArrayList<Month>(EnumSet.allOf(Month.class)); - return all.get(getNum()); - } - - public Month prev() { - if (this == JAN) { - return null; - } - final List<Month> all = new ArrayList<Month>(EnumSet.allOf(Month.class)); - return all.get(getNum() - 2); - } - - public static Month fromNum(int num) { - if (num < 1 || num > 12) { - throw new IllegalArgumentException(); - } - final List<Month> all = new ArrayList<Month>(EnumSet.allOf(Month.class)); - return all.get(num - 1); - } -} diff --git a/src/net/sourceforge/plantuml/project/Numeric.java b/src/net/sourceforge/plantuml/project/Numeric.java deleted file mode 100644 index 3b0e15f..0000000 --- a/src/net/sourceforge/plantuml/project/Numeric.java +++ /dev/null @@ -1,43 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.project; - -public interface Numeric extends Comparable<Numeric> { - Numeric add(Numeric other); - - NumericType getNumericType(); - -} diff --git a/src/net/sourceforge/plantuml/project/NumericNumber.java b/src/net/sourceforge/plantuml/project/NumericNumber.java deleted file mode 100644 index 17d9231..0000000 --- a/src/net/sourceforge/plantuml/project/NumericNumber.java +++ /dev/null @@ -1,77 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.project; - -class NumericNumber implements Numeric { - - private final int value; - - public NumericNumber(int v) { - this.value = v; - } - - public Numeric add(Numeric other) { - if (other.getNumericType() != getNumericType()) { - throw new IllegalArgumentException(); - } - return new NumericNumber(value + ((NumericNumber) other).value); - } - - public NumericType getNumericType() { - return NumericType.NUMBER; - } - - public int getIntValue() { - return value; - } - - @Override - public String toString() { - return "Number:" + value; - } - - public int compareTo(Numeric other) { - final NumericNumber this2 = (NumericNumber) other; - if (this2.value > value) { - return -1; - } - if (this2.value < value) { - return 1; - } - return 0; - } - -} diff --git a/src/net/sourceforge/plantuml/project/NumericType.java b/src/net/sourceforge/plantuml/project/NumericType.java deleted file mode 100644 index e71e3f9..0000000 --- a/src/net/sourceforge/plantuml/project/NumericType.java +++ /dev/null @@ -1,80 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.project; - -enum NumericType { - - NUMBER, INSTANT, LOAD, DURATION; - - public NumericType add(NumericType other) { - if (this == NUMBER) { - return addNumber(other); - } - if (this == INSTANT) { - return null; - } - if (this == LOAD) { - return addLoad(other); - } - if (this == DURATION) { - return addDuration(other); - } - throw new UnsupportedOperationException(); - - } - - private NumericType addDuration(NumericType other) { - if (other == DURATION) { - return DURATION; - } - return null; - } - - private NumericType addLoad(NumericType other) { - if (other == LOAD) { - return LOAD; - } - return null; - } - - private NumericType addNumber(NumericType other) { - if (other == NUMBER) { - return NUMBER; - } - return null; - } - -} diff --git a/src/net/sourceforge/plantuml/project/PSystemProject.java b/src/net/sourceforge/plantuml/project/PSystemProject.java deleted file mode 100644 index bb20a6c..0000000 --- a/src/net/sourceforge/plantuml/project/PSystemProject.java +++ /dev/null @@ -1,129 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.project; - -import java.awt.Color; -import java.awt.Graphics2D; -import java.awt.image.BufferedImage; -import java.io.IOException; -import java.io.OutputStream; - -import net.sourceforge.plantuml.AbstractPSystem; -import net.sourceforge.plantuml.Dimension2DDouble; -import net.sourceforge.plantuml.EmptyImageBuilder; -import net.sourceforge.plantuml.FileFormat; -import net.sourceforge.plantuml.FileFormatOption; -import net.sourceforge.plantuml.StringUtils; -import net.sourceforge.plantuml.api.ImageDataSimple; -import net.sourceforge.plantuml.core.DiagramDescription; -import net.sourceforge.plantuml.core.ImageData; -import net.sourceforge.plantuml.eps.EpsStrategy; -import net.sourceforge.plantuml.png.PngIO; -import net.sourceforge.plantuml.project.graphic.GanttDiagramUnused; -import net.sourceforge.plantuml.ugraphic.ColorMapper; -import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity; -import net.sourceforge.plantuml.ugraphic.eps.UGraphicEps; -import net.sourceforge.plantuml.ugraphic.g2d.UGraphicG2d; -import net.sourceforge.plantuml.ugraphic.svg.UGraphicSvg; - -public class PSystemProject extends AbstractPSystem { - - private final Project project = new Project(); - private final Color background = Color.WHITE; - private final ColorMapper colorMapper = new ColorMapperIdentity(); - - public int getNbImages() { - return 1; - } - - public DiagramDescription getDescription() { - return new DiagramDescription("(Project)"); - } - - @Override - final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormatOption, long seed) - throws IOException { - final GanttDiagramUnused diagram = new GanttDiagramUnused(project); - final FileFormat fileFormat = fileFormatOption.getFileFormat(); - if (fileFormat == FileFormat.PNG) { - final BufferedImage im = createImage(diagram); - PngIO.write(im, os, fileFormatOption.isWithMetadata() ? getMetadata() : null, 96); - } else if (fileFormat == FileFormat.SVG) { - final UGraphicSvg svg = new UGraphicSvg(true, new Dimension2DDouble(0, 0), colorMapper, - StringUtils.getAsHtml(background), false, 1.0, fileFormatOption.getSvgLinkTarget(), - fileFormatOption.getHoverColor(), seed()); - diagram.draw(svg, 0, 0); - svg.createXml(os, fileFormatOption.isWithMetadata() ? getMetadata() : null); - } else if (fileFormat == FileFormat.EPS) { - final UGraphicEps eps = new UGraphicEps(colorMapper, EpsStrategy.getDefault2()); - diagram.draw(eps, 0, 0); - os.write(eps.getEPSCode().getBytes()); - } else if (fileFormat == FileFormat.EPS_TEXT) { - final UGraphicEps eps = new UGraphicEps(colorMapper, EpsStrategy.WITH_MACRO_AND_TEXT); - diagram.draw(eps, 0, 0); - os.write(eps.getEPSCode().getBytes()); - } else { - throw new UnsupportedOperationException(); - } - return ImageDataSimple.ok(); - } - - private BufferedImage createImage(GanttDiagramUnused diagram) { - EmptyImageBuilder builder = new EmptyImageBuilder(10, 10, background); - Graphics2D g2d = builder.getGraphics2D(); - UGraphicG2d ug = new UGraphicG2d(colorMapper, g2d, 1.0); - - final double height = diagram.getHeight(ug.getStringBounder()); - final double width = diagram.getWidth(ug.getStringBounder()); - - g2d.dispose(); - - builder = new EmptyImageBuilder(width, height, background); - final BufferedImage im = builder.getBufferedImage(); - g2d = builder.getGraphics2D(); - - ug = new UGraphicG2d(colorMapper, g2d, 1.0); - ug.setBufferedImage(im); - diagram.draw(ug, 0, 0); - g2d.dispose(); - return im; - } - - public final Project getProject() { - return project; - } - -} diff --git a/src/net/sourceforge/plantuml/project/ParentItem.java b/src/net/sourceforge/plantuml/project/ParentItem.java deleted file mode 100644 index b356376..0000000 --- a/src/net/sourceforge/plantuml/project/ParentItem.java +++ /dev/null @@ -1,133 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.project; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; - -public class ParentItem implements Item { - - private final String code; - private final Item parent; - - private final List<Item> children = new ArrayList<Item>(); - - public ParentItem(String code, Item parent) { - this.code = code; - this.parent = parent; - } - - @Override - public String toString() { - final StringBuilder sb = new StringBuilder(code + " {"); - for (final Iterator<Item> it = children.iterator(); it.hasNext();) { - final Item child = it.next(); - sb.append(child.getCode()); - if (it.hasNext()) { - sb.append(", "); - } - } - sb.append("}"); - return sb.toString(); - } - - public Instant getBegin() { - Instant result = null; - for (Item it : children) { - if (result == null || result.compareTo(it.getBegin()) > 0) { - result = it.getBegin(); - } - } - return result; - } - - public Instant getCompleted() { - Instant result = null; - for (Item it : children) { - if (result == null || result.compareTo(it.getCompleted()) < 0) { - result = it.getCompleted(); - } - } - return result; - } - - public Duration getDuration() { - throw new UnsupportedOperationException(); - } - - public Load getLoad() { - throw new UnsupportedOperationException(); - } - - public NumericNumber getWork() { - throw new UnsupportedOperationException(); - } - - public boolean isLeaf() { - return false; - } - - public Item getParent() { - return parent; - } - - public List<Item> getChildren() { - return Collections.unmodifiableList(children); - } - - public String getCode() { - return code; - } - - public void addChild(Item child) { - this.children.add(child); - } - - public boolean isValid() { - if (children.size() == 0) { - return false; - } - for (Item it : children) { - if (it.isValid() == false) { - return false; - } - } - return true; - } - -} diff --git a/src/net/sourceforge/plantuml/project/Project.java b/src/net/sourceforge/plantuml/project/Project.java deleted file mode 100644 index 13bf076..0000000 --- a/src/net/sourceforge/plantuml/project/Project.java +++ /dev/null @@ -1,283 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.project; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.TreeMap; - -import net.sourceforge.plantuml.StringUtils; - -public class Project { - - private final Map<String, FreeVariable> variables = new TreeMap<String, FreeVariable>(); - - private final Map<String, Item> items = new TreeMap<String, Item>(); - - private final Map<String, Ressource> ressources = new TreeMap<String, Ressource>(); - - private final DayCloseOr dayClose = new DayCloseOr(); - - public Project() { - } - - public final Instant getStart() { - Instant result = null; - for (Item it : getValidItems()) { - if (result == null || result.compareTo(it.getBegin()) > 0) { - result = it.getBegin(); - } - } - return result; - } - - public final Instant getEnd() { - Instant result = null; - for (Item it : getValidItems()) { - if (result == null || result.compareTo(it.getCompleted()) < 0) { - result = it.getCompleted(); - } - } - return result; - } - - public FreeVariable createVariable(String name, NumericType type) { - if (variables.containsKey(name)) { - throw new IllegalArgumentException("Already exist: " + name); - } - final FreeVariable variable = new FreeVariable(name, type); - variables.put(name, variable); - return variable; - } - - public Expression getExpression(String desc) { - desc = StringUtils.trin(desc); - final int plus = desc.indexOf('+'); - - if (plus != -1) { - final Expression exp1 = getExpression(desc.substring(0, plus)); - final Expression exp2 = getExpression(desc.substring(plus + 1)); - if (exp1.getNumericType() == NumericType.INSTANT - && (exp2.getNumericType() == NumericType.DURATION || exp2.getNumericType() == NumericType.NUMBER)) { - return new FormalAdditionInstantDuration(exp1, exp2, new BasicInstantArithmetic(dayClose)); - } - if (exp2.getNumericType() == NumericType.INSTANT - && (exp1.getNumericType() == NumericType.DURATION || exp1.getNumericType() == NumericType.NUMBER)) { - return new FormalAdditionInstantDuration(exp2, exp1, new BasicInstantArithmetic(dayClose)); - } - return new FormalAddition(exp1, exp2); - } - - if (desc.matches("^\\d+$")) { - return new Constant(new NumericNumber(Integer.parseInt(desc))); - } - if (desc.matches("^\\$\\w+$")) { - final String varName = desc.substring(1); - final FreeVariable v = variables.get(varName); - if (v != null) { - return v; - } - throw new IllegalArgumentException("No such variable: " + desc); - } - if (Day.isValidDesc(desc)) { - final Day d = new Day(desc); - return new Constant(new Instant(d)); - } - if (desc.matches("^[\\w/]+\\$(begin|completed|work|load|duration)$")) { - final int idx = desc.indexOf('$'); - final String varName = desc.substring(0, idx); - final Item item = items.get(varName); - if (item == null) { - throw new IllegalArgumentException("No such variable: " + desc); - } - return new Constant(ItemCaract.valueOf(StringUtils.goUpperCase(desc.substring(idx + 1))).getData(item)); - } - if (desc.startsWith("^")) { - final Item item = items.get(desc.substring(1)); - if (item == null) { - throw new IllegalArgumentException("No such variable: " + desc); - } - return new Constant(item.getBegin()); - } - throw new IllegalArgumentException("cannot parse"); - } - - public boolean affectation(String destination, Expression expression) { - if (destination.startsWith("^")) { - return affectationJalon(destination, expression); - } - if (destination.startsWith("~")) { - return affectationRessource(destination, expression); - } - final int idx = destination.indexOf('$'); - if (idx == -1) { - return affectationVariable(destination, expression); - } - final String itemName = destination.substring(0, idx); - final Item item = getItem(itemName); - if (item instanceof IncompleteItem == false) { - return false; - } - final IncompleteItem incompleteItem = (IncompleteItem) item; - final String suf = destination.substring(idx + 1); - if (suf.equalsIgnoreCase("begin")) { - incompleteItem.setData(ItemCaract.BEGIN, expression.getValue()); - } else if (suf.equalsIgnoreCase("completed")) { - incompleteItem.setData(ItemCaract.COMPLETED, expression.getValue()); - } else if (suf.equalsIgnoreCase("work")) { - incompleteItem.setData(ItemCaract.WORK, expression.getValue()); - } else if (suf.equalsIgnoreCase("duration")) { - if (expression.getNumericType() == NumericType.NUMBER) { - expression = new Constant(new Duration((NumericNumber) expression.getValue())); - } - incompleteItem.setData(ItemCaract.DURATION, expression.getValue()); - } else if (suf.equalsIgnoreCase("LOAD")) { - if (expression.getNumericType() == NumericType.NUMBER) { - expression = new Constant(new Load((NumericNumber) expression.getValue())); - } - incompleteItem.setData(ItemCaract.LOAD, expression.getValue()); - } else { - return false; - } - return true; - } - - private boolean affectationRessource(String res, Expression expression) { - res = res.substring(1); - final int idx = res.indexOf('$'); - final String suf = res.substring(idx + 1); - if (suf.equals("capacity")) { - final Ressource ressource = getRessource(res.substring(0, idx)); - ressource.setCapacity(((NumericNumber) expression.getValue()).getIntValue()); - return true; - } - return false; - } - - private Ressource getRessource(String code) { - Ressource result = ressources.get(code); - if (result == null) { - result = new Ressource(code); - ressources.put(code, result); - } - return result; - } - - private boolean affectationJalon(String jalon, Expression expression) { - final Jalon it = getItemJalon(jalon.substring(1)); - it.setInstant(expression.getValue()); - return true; - } - - private Jalon getItemJalon(String jalon) { - Jalon result = (Jalon) items.get(jalon); - if (result == null) { - result = new Jalon(jalon, null); - items.put(jalon, result); - - } - return result; - } - - private Item getItem(String code) { - Item result = items.get(code); - if (result == null) { - final int idx = code.indexOf('/'); - if (idx == -1) { - result = new IncompleteItem(code, null, new BasicInstantArithmetic(dayClose)); - } else { - final ParentItem parent = getItemParent(code.substring(0, idx)); - result = new IncompleteItem(code, parent, new BasicInstantArithmetic(dayClose)); - parent.addChild(result); - } - items.put(code, result); - } - return result; - } - - private ParentItem getItemParent(String code) { - Item result = items.get(code); - if (result == null) { - final int idx = code.indexOf('/'); - if (idx == -1) { - result = new ParentItem(code, null); - items.put(code, result); - } else { - throw new UnsupportedOperationException(); - } - } - return (ParentItem) result; - } - - private boolean affectationVariable(String destination, Expression expression) { - if (variables.containsKey(destination) == false) { - return false; - } - variables.get(destination).setValue(expression); - return true; - } - - public List<Item> getValidItems() { - final List<Item> result = new ArrayList<Item>(); - for (Item item : items.values()) { - if (item.isValid()) { - result.add(item); - } - } - Collections.sort(result, new ItemComparator()); - return Collections.unmodifiableList(result); - } - - public final DayClose getDayClose() { - return dayClose; - } - - public void closeWeekDay(WeekDay weekDay) { - dayClose.add(new DayCloseWeekDay(weekDay)); - } - - // public Item getItem(String code) { - // BasicItem result = items.get(code); - // if (result == null) { - // result = new BasicItem(code); - // items.put(code, result); - // } - // return result; - // } - -} diff --git a/src/net/sourceforge/plantuml/project/Ressource.java b/src/net/sourceforge/plantuml/project/Ressource.java deleted file mode 100644 index 7de543f..0000000 --- a/src/net/sourceforge/plantuml/project/Ressource.java +++ /dev/null @@ -1,60 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.project; - -public class Ressource { - - private final String code; - - private int capacity = 1; - - public Ressource(String code) { - this.code = code; - } - - public DayClose getDayClose() { - return new DayCloseNone(); - } - - public final int getCapacity() { - return capacity; - } - - public final void setCapacity(int capacity) { - this.capacity = capacity; - } - -} diff --git a/src/net/sourceforge/plantuml/project/WeekDay.java b/src/net/sourceforge/plantuml/project/WeekDay.java deleted file mode 100644 index 82322a3..0000000 --- a/src/net/sourceforge/plantuml/project/WeekDay.java +++ /dev/null @@ -1,62 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.project; - -import java.util.ArrayList; -import java.util.EnumSet; -import java.util.List; - -public enum WeekDay { - - SUN, MON, TUE, WED, THU, FRI, SAT; - - public WeekDay next() { - if (this.ordinal() == 6) { - return SUN; - } - final List<WeekDay> all = new ArrayList<WeekDay>(EnumSet.allOf(WeekDay.class)); - return all.get(this.ordinal() + 1); - } - - public WeekDay prev() { - if (this.ordinal() == 0) { - return SAT; - } - final List<WeekDay> all = new ArrayList<WeekDay>(EnumSet.allOf(WeekDay.class)); - return all.get(this.ordinal() - 1); - } - -} diff --git a/src/net/sourceforge/plantuml/project/command/CommandAffectation.java b/src/net/sourceforge/plantuml/project/command/CommandAffectation.java deleted file mode 100644 index 539b8d9..0000000 --- a/src/net/sourceforge/plantuml/project/command/CommandAffectation.java +++ /dev/null @@ -1,61 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.project.command; - -import java.util.List; - -import net.sourceforge.plantuml.StringUtils; -import net.sourceforge.plantuml.command.CommandExecutionResult; -import net.sourceforge.plantuml.command.SingleLineCommand; -import net.sourceforge.plantuml.project.Expression; -import net.sourceforge.plantuml.project.PSystemProject; - -public class CommandAffectation extends SingleLineCommand<PSystemProject> { - - public CommandAffectation() { - super("(?i)^\\s*([~\\^]?[\\w$/]+)\\s*:=\\s*(.+)$"); - } - - @Override - protected CommandExecutionResult executeArg(PSystemProject diagram, List<String> arg) { - final Expression exp = diagram.getProject().getExpression(StringUtils.trin(arg.get(1))); - final boolean ok = diagram.getProject().affectation(StringUtils.trin(arg.get(0)), exp); - if (ok) { - return CommandExecutionResult.ok(); - } - return CommandExecutionResult.error("Cannot execute"); - } -} diff --git a/src/net/sourceforge/plantuml/project/command/CommandCloseWeekDay.java b/src/net/sourceforge/plantuml/project/command/CommandCloseWeekDay.java deleted file mode 100644 index 388ecf5..0000000 --- a/src/net/sourceforge/plantuml/project/command/CommandCloseWeekDay.java +++ /dev/null @@ -1,58 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.project.command; - -import java.util.List; - -import net.sourceforge.plantuml.StringUtils; -import net.sourceforge.plantuml.command.CommandExecutionResult; -import net.sourceforge.plantuml.command.SingleLineCommand; -import net.sourceforge.plantuml.project.PSystemProject; -import net.sourceforge.plantuml.project.WeekDay; - -public class CommandCloseWeekDay extends SingleLineCommand<PSystemProject> { - - public CommandCloseWeekDay() { - super("(?i)^\\s*close\\s+(\\w{3,}day)\\s*$"); - } - - @Override - protected CommandExecutionResult executeArg(PSystemProject diagram, List<String> arg) { - final WeekDay weekDay = WeekDay.valueOf(StringUtils.goUpperCase(arg.get(0).substring(0, 3))); - diagram.getProject().closeWeekDay(weekDay); - return CommandExecutionResult.ok(); - } -} diff --git a/src/net/sourceforge/plantuml/project/graphic/GanttDiagramUnused.java b/src/net/sourceforge/plantuml/project/graphic/GanttDiagramUnused.java deleted file mode 100644 index e849f4d..0000000 --- a/src/net/sourceforge/plantuml/project/graphic/GanttDiagramUnused.java +++ /dev/null @@ -1,140 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.project.graphic; - -import java.util.Map; -import java.util.SortedMap; - -import net.sourceforge.plantuml.Log; -import net.sourceforge.plantuml.graphic.HtmlColor; -import net.sourceforge.plantuml.graphic.HtmlColorSetSimple; -import net.sourceforge.plantuml.graphic.HtmlColorUtils; -import net.sourceforge.plantuml.graphic.StringBounder; -import net.sourceforge.plantuml.project.Instant; -import net.sourceforge.plantuml.project.Item; -import net.sourceforge.plantuml.project.Jalon; -import net.sourceforge.plantuml.project.Project; -import net.sourceforge.plantuml.ugraphic.UChangeBackColor; -import net.sourceforge.plantuml.ugraphic.UChangeColor; -import net.sourceforge.plantuml.ugraphic.UGraphic; -import net.sourceforge.plantuml.ugraphic.ULine; -import net.sourceforge.plantuml.ugraphic.UPolygon; -import net.sourceforge.plantuml.ugraphic.URectangle; -import net.sourceforge.plantuml.ugraphic.UShape; -import net.sourceforge.plantuml.ugraphic.UTranslate; - -public class GanttDiagramUnused { - - private final Project project; - private final TimeScale timeScale; - private final ItemHeader itemHeader; - - public GanttDiagramUnused(Project project) { - this.project = project; - this.timeScale = new TimeScale(project); - this.itemHeader = new ItemHeader(project); - } - - public void draw(UGraphic ug, double x, double y) { - final StringBounder stringBounder = ug.getStringBounder(); - final double x0start = itemHeader.getWidth(stringBounder); - - final double timeScaleHeight = timeScale.getHeight(stringBounder); - - final SortedMap<Instant, Double> pos = timeScale.getAbscisse(stringBounder); - for (Item it : project.getValidItems()) { - final Instant start = it.getBegin(); - final Instant completed = it.getCompleted(); - if (pos.get(start) == null || pos.get(completed) == null) { - Log.println("PB " + it); - continue; - } - final double x1 = pos.get(start) + 3; - final double x2 = pos.get(completed) - 3; - - final double yitem = timeScaleHeight + itemHeader.getPosition(stringBounder, it) + 3; - - final UShape rect; - if (it instanceof Jalon) { - rect = new UPolygon(); - ((UPolygon) rect).addPoint(0, 3); - ((UPolygon) rect).addPoint(3, 0); - ((UPolygon) rect).addPoint(6, 3); - ((UPolygon) rect).addPoint(3, 6); - } else { - rect = new URectangle(x2 - x1, 3); - } - ug = ug.apply(new UChangeColor(HtmlColorUtils.GREEN)); - ug = ug.apply(new UChangeBackColor(HtmlColorUtils.GRAY)); - ug.apply(new UTranslate(x0start + x1, yitem)).draw(rect); - - } - - drawGrid(ug, x + x0start, y + timeScaleHeight, pos); - - ug = ug.apply(new UChangeColor(HtmlColorUtils.BLACK)); - ug = ug.apply(new UChangeBackColor(null)); - timeScale.draw(ug, x + x0start, y); - itemHeader.draw(ug, x, y + timeScaleHeight); - - } - - private final HtmlColor lightGray = new HtmlColorSetSimple().getColorIfValid("#C8C8C8"); - - private void drawGrid(UGraphic ug, double x, double y, SortedMap<Instant, Double> pos) { - final ULine line = new ULine(0, itemHeader.getHeight(ug.getStringBounder())); - Instant last = null; - for (Map.Entry<Instant, Double> ent : pos.entrySet()) { - final double xcur = ent.getValue(); - if (last == null || last.next(null).equals(ent.getKey())) { - ug = ug.apply(new UChangeColor(lightGray)); - } else { - ug = ug.apply(new UChangeColor(HtmlColorUtils.BLACK)); - } - ug.apply(new UTranslate(x + xcur, y)).draw(line); - last = ent.getKey(); - } - } - - public double getWidth(StringBounder stringBounder) { - return itemHeader.getWidth(stringBounder) + timeScale.getWidth(stringBounder) + 3; - } - - public double getHeight(StringBounder stringBounder) { - return itemHeader.getHeight(stringBounder) + timeScale.getHeight(stringBounder) + 3; - } - -}
\ No newline at end of file diff --git a/src/net/sourceforge/plantuml/project/graphic/ItemHeader.java b/src/net/sourceforge/plantuml/project/graphic/ItemHeader.java deleted file mode 100644 index e5764e0..0000000 --- a/src/net/sourceforge/plantuml/project/graphic/ItemHeader.java +++ /dev/null @@ -1,116 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.project.graphic; - -import java.awt.Font; -import java.awt.geom.Dimension2D; - -import net.sourceforge.plantuml.SpriteContainerEmpty; -import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.graphic.FontConfiguration; -import net.sourceforge.plantuml.graphic.HorizontalAlignment; -import net.sourceforge.plantuml.graphic.HtmlColorUtils; -import net.sourceforge.plantuml.graphic.StringBounder; -import net.sourceforge.plantuml.graphic.TextBlock; -import net.sourceforge.plantuml.project.Item; -import net.sourceforge.plantuml.project.Project; -import net.sourceforge.plantuml.ugraphic.UChangeColor; -import net.sourceforge.plantuml.ugraphic.UFont; -import net.sourceforge.plantuml.ugraphic.UGraphic; -import net.sourceforge.plantuml.ugraphic.ULine; -import net.sourceforge.plantuml.ugraphic.URectangle; -import net.sourceforge.plantuml.ugraphic.UTranslate; - -class ItemHeader { - - private final UFont font = UFont.serif(9); - private final Project project; - private final FontConfiguration fontConfig = FontConfiguration.blackBlueTrue(font); - - public ItemHeader(Project project) { - this.project = project; - } - - public void draw(UGraphic ug, double x, double y) { - - final StringBounder stringBounder = ug.getStringBounder(); - - ug = ug.apply(new UChangeColor(HtmlColorUtils.BLACK)); - ug.apply(new UTranslate(x, y)).draw(new URectangle(getWidth(stringBounder), getHeight(stringBounder))); - - for (Item it : project.getValidItems()) { - final TextBlock b = Display.create("" + it.getCode()).create(fontConfig, HorizontalAlignment.LEFT, - new SpriteContainerEmpty()); - final Dimension2D dim = b.calculateDimension(stringBounder); - b.drawU(ug.apply(new UTranslate(x, y))); - y += dim.getHeight(); - ug.apply(new UTranslate(x, y)).draw(new ULine(getWidth(stringBounder), 0)); - } - } - - public double getWidth(StringBounder stringBounder) { - double width = 0; - for (Item it : project.getValidItems()) { - final Dimension2D dim = stringBounder.calculateDimension(font, it.getCode()); - width = Math.max(width, dim.getWidth()); - } - return width; - } - - public double getHeight(StringBounder stringBounder) { - double height = 0; - for (Item it : project.getValidItems()) { - final Dimension2D dim = stringBounder.calculateDimension(font, it.getCode()); - height += dim.getHeight(); - - } - return height; - } - - public double getPosition(StringBounder stringBounder, Item item) { - double pos = 0; - for (Item it : project.getValidItems()) { - if (it == item) { - return pos; - } - final Dimension2D dim = stringBounder.calculateDimension(font, it.getCode()); - pos += dim.getHeight(); - - } - throw new IllegalArgumentException(); - } - -}
\ No newline at end of file diff --git a/src/net/sourceforge/plantuml/project/graphic/TimeScale.java b/src/net/sourceforge/plantuml/project/graphic/TimeScale.java deleted file mode 100644 index 30a84b7..0000000 --- a/src/net/sourceforge/plantuml/project/graphic/TimeScale.java +++ /dev/null @@ -1,159 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.project.graphic; - -import java.awt.Font; -import java.awt.geom.Dimension2D; -import java.util.Collections; -import java.util.SortedMap; -import java.util.TreeMap; - -import net.sourceforge.plantuml.SpriteContainerEmpty; -import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.graphic.FontConfiguration; -import net.sourceforge.plantuml.graphic.HorizontalAlignment; -import net.sourceforge.plantuml.graphic.HtmlColorUtils; -import net.sourceforge.plantuml.graphic.StringBounder; -import net.sourceforge.plantuml.graphic.TextBlock; -import net.sourceforge.plantuml.project.Day; -import net.sourceforge.plantuml.project.Instant; -import net.sourceforge.plantuml.project.Month; -import net.sourceforge.plantuml.project.Project; -import net.sourceforge.plantuml.ugraphic.UChangeColor; -import net.sourceforge.plantuml.ugraphic.UFont; -import net.sourceforge.plantuml.ugraphic.UGraphic; -import net.sourceforge.plantuml.ugraphic.ULine; -import net.sourceforge.plantuml.ugraphic.URectangle; -import net.sourceforge.plantuml.ugraphic.UTranslate; - -class TimeScale { - - private final UFont font = UFont.serif(9); - private final Project project; - private final FontConfiguration fontConfig = FontConfiguration.blackBlueTrue(font); - - public TimeScale(Project project) { - this.project = project; - } - - public void draw(UGraphic ug, final double x, double y) { - final StringBounder stringBounder = ug.getStringBounder(); - final double monthHeight = getMonthHeight(stringBounder); - final double caseWidth = getCaseWidth(stringBounder); - final double caseHeight = getCaseHeight(stringBounder); - final int nb = getNbCase(); - - ug = ug.apply(new UChangeColor(HtmlColorUtils.BLACK)); - ug.apply(new UTranslate(x, y)).draw(new URectangle(nb * caseWidth, monthHeight)); - final Instant end = project.getEnd(); - - Month printed = null; - - double curx = x; - for (Instant cur = project.getStart(); cur.compareTo(end) <= 0; cur = cur.next(project.getDayClose())) { - final Day d = cur.getDay(); - if (printed == null || d.getMonth() != printed) { - ug.apply(new UTranslate(curx, y)).draw(new ULine(0, monthHeight)); - printed = d.getMonth(); - final TextBlock b = Display.create(printed.name()).create(fontConfig, HorizontalAlignment.LEFT, - new SpriteContainerEmpty()); - final Dimension2D dim = b.calculateDimension(stringBounder); - b.drawU(ug.apply(new UTranslate(curx, (y + (monthHeight - dim.getHeight()) / 2)))); - } - curx += caseWidth; - } - - curx = x; - y += monthHeight; - ug.apply(new UTranslate(x, y)).draw(new URectangle(nb * caseWidth, caseHeight)); - - for (Instant cur = project.getStart(); cur.compareTo(end) <= 0; cur = cur.next(project.getDayClose())) { - final Day d = cur.getDay(); - final TextBlock b = Display.create("" + d.getNumDay()).create(fontConfig, HorizontalAlignment.LEFT, - new SpriteContainerEmpty()); - final Dimension2D dim = b.calculateDimension(stringBounder); - b.drawU(ug.apply(new UTranslate((curx + (caseWidth - dim.getWidth()) / 2), (y + (caseHeight - dim - .getHeight()) / 2)))); - curx += caseWidth; - ug.apply(new UTranslate(curx, y)).draw(new ULine(0, caseHeight)); - } - } - - public SortedMap<Instant, Double> getAbscisse(StringBounder stringBounder) { - final SortedMap<Instant, Double> pos = new TreeMap<Instant, Double>(); - final double caseWidth = getCaseWidth(stringBounder); - final Instant end = project.getEnd(); - double x = 0; - for (Instant cur = project.getStart(); cur.compareTo(end) <= 0; cur = cur.next(project.getDayClose())) { - pos.put(cur, x); - x += caseWidth; - } - return Collections.unmodifiableSortedMap(pos); - } - - private int getNbCase() { - int result = 0; - final Instant end = project.getEnd(); - for (Instant cur = project.getStart(); cur.compareTo(end) <= 0; cur = cur.next(project.getDayClose())) { - result++; - } - return result; - } - - private double getCaseWidth(StringBounder stringBounder) { - final Dimension2D dim00 = stringBounder.calculateDimension(font, "00"); - return dim00.getWidth() + 3; - } - - private double getCaseHeight(StringBounder stringBounder) { - final Dimension2D dim00 = stringBounder.calculateDimension(font, "00"); - return dim00.getHeight() + 3; - } - - private double getMonthHeight(StringBounder stringBounder) { - final Dimension2D dimZZ = stringBounder.calculateDimension(font, "ZZ"); - return dimZZ.getHeight() + 3; - } - - public double getWidth(StringBounder stringBounder) { - return getCaseWidth(stringBounder) * getNbCase(); - } - - public double getHeight(StringBounder stringBounder) { - return getCaseHeight(stringBounder) + getMonthHeight(stringBounder); - } - -}
\ No newline at end of file diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/FreeYStrategy.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/FreeYStrategy.java deleted file mode 100644 index dbca1f8..0000000 --- a/src/net/sourceforge/plantuml/sequencediagram/graphic/FreeYStrategy.java +++ /dev/null @@ -1,45 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.sequencediagram.graphic; - -import net.sourceforge.plantuml.sequencediagram.Event; - -interface FreeYStrategy { - - double peekPosition(Event event, ParticipantRange range); - - void addElement(Event event, ParticipantRange range, double height); -} diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/FreeYStrategyBasic.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/FreeYStrategyBasic.java deleted file mode 100644 index c4e87e0..0000000 --- a/src/net/sourceforge/plantuml/sequencediagram/graphic/FreeYStrategyBasic.java +++ /dev/null @@ -1,49 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.sequencediagram.graphic; - -import net.sourceforge.plantuml.sequencediagram.Event; - -class FreeYStrategyBasic implements FreeYStrategy { - - public double peekPosition(Event event, ParticipantRange range) { - return 0; - } - - public void addElement(Event event, ParticipantRange range, double height) { - } - -} diff --git a/src/net/sourceforge/plantuml/sequencediagram/puma/FixedLink.java b/src/net/sourceforge/plantuml/sequencediagram/puma/FixedLink.java deleted file mode 100644 index 6b58713..0000000 --- a/src/net/sourceforge/plantuml/sequencediagram/puma/FixedLink.java +++ /dev/null @@ -1,60 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.sequencediagram.puma; - -public class FixedLink { - - final private SegmentPosition segmentPosition1; - final private SegmentPosition segmentPosition2; - - public FixedLink(SegmentPosition segmentPosition1, SegmentPosition segmentPosition2) { - this.segmentPosition1 = segmentPosition1; - this.segmentPosition2 = segmentPosition2; - } - - public boolean pushIfNeed() { - final double p1 = segmentPosition1.getPosition(); - final double p2 = segmentPosition2.getPosition(); - if (p1 == p2) { - return false; - } - final double diff = p1 - p2; - segmentPosition2.getSegment().push(diff); - assert segmentPosition1.getPosition() == segmentPosition2.getPosition(); - return true; - } - -} diff --git a/src/net/sourceforge/plantuml/sequencediagram/puma/PSegment.java b/src/net/sourceforge/plantuml/sequencediagram/puma/PSegment.java deleted file mode 100644 index 287102d..0000000 --- a/src/net/sourceforge/plantuml/sequencediagram/puma/PSegment.java +++ /dev/null @@ -1,73 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.sequencediagram.puma; - -public class PSegment { - - private final double minsize; - private double startx; - private double endx; - - public PSegment(double minsize) { - this.minsize = minsize; - this.startx = 0; - this.endx = minsize; - } - - public double getMinsize() { - return minsize; - } - - public void push(double delta) { - this.startx += delta; - this.endx += delta; - } - - public String getDebugPosition() { - return "" + ((int) startx) + "-" + ((int) endx); - } - - public double getPosition(double position) { - if (position == 0) { - return startx; - } - if (position == 1) { - return endx; - } - throw new UnsupportedOperationException(); - } - -} diff --git a/src/net/sourceforge/plantuml/sequencediagram/puma/PUnivers.java b/src/net/sourceforge/plantuml/sequencediagram/puma/PUnivers.java deleted file mode 100644 index 6fd4bed..0000000 --- a/src/net/sourceforge/plantuml/sequencediagram/puma/PUnivers.java +++ /dev/null @@ -1,71 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.sequencediagram.puma; - -import java.util.ArrayList; -import java.util.Collection; - -public class PUnivers { - - private final Collection<PSegment> all = new ArrayList<PSegment>(); - private final Collection<FixedLink> links = new ArrayList<FixedLink>(); - - public PSegment createPSegment(double minsize) { - final PSegment result = new PSegment(minsize); - all.add(result); - return result; - } - - public void addFixedLink(PSegment segment1, double position1, PSegment segment2, double position2) { - final FixedLink link = new FixedLink(new SegmentPosition(segment1, position1), new SegmentPosition(segment2, - position2)); - links.add(link); - - } - - public void solve() { - boolean changed = false; - do { - changed = false; - for (FixedLink link : links) { - if (link.pushIfNeed()) { - changed = true; - } - } - } while (changed); - - } -} diff --git a/src/net/sourceforge/plantuml/sequencediagram/puma/PushDirection.java b/src/net/sourceforge/plantuml/sequencediagram/puma/PushDirection.java deleted file mode 100644 index 0fc06d4..0000000 --- a/src/net/sourceforge/plantuml/sequencediagram/puma/PushDirection.java +++ /dev/null @@ -1,41 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.sequencediagram.puma; - -public enum PushDirection { - - TOLEFT, TORIGHT -} diff --git a/src/net/sourceforge/plantuml/sequencediagram/puma/PushSide.java b/src/net/sourceforge/plantuml/sequencediagram/puma/PushSide.java deleted file mode 100644 index 32b3b00..0000000 --- a/src/net/sourceforge/plantuml/sequencediagram/puma/PushSide.java +++ /dev/null @@ -1,41 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.sequencediagram.puma; - -public enum PushSide { - - START, END -} diff --git a/src/net/sourceforge/plantuml/sequencediagram/puma/PushStrategy.java b/src/net/sourceforge/plantuml/sequencediagram/puma/PushStrategy.java deleted file mode 100644 index 9139380..0000000 --- a/src/net/sourceforge/plantuml/sequencediagram/puma/PushStrategy.java +++ /dev/null @@ -1,41 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.sequencediagram.puma; - -public enum PushStrategy { - - MOVE, ENLARGE -} diff --git a/src/net/sourceforge/plantuml/sequencediagram/puma/SegmentPosition.java b/src/net/sourceforge/plantuml/sequencediagram/puma/SegmentPosition.java deleted file mode 100644 index 272cb8a..0000000 --- a/src/net/sourceforge/plantuml/sequencediagram/puma/SegmentPosition.java +++ /dev/null @@ -1,57 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.sequencediagram.puma; - -public class SegmentPosition { - - final private PSegment segment; - final private double position; - - public SegmentPosition(PSegment segment, double position) { - this.segment = segment; - this.position = position; - } - - public double getPosition() { - return segment.getPosition(position); - } - - public PSegment getSegment() { - return segment; - - } - -} diff --git a/src/net/sourceforge/plantuml/skin/bluemodern/AbstractComponentBlueModernArrow.java b/src/net/sourceforge/plantuml/skin/bluemodern/AbstractComponentBlueModernArrow.java deleted file mode 100644 index f90e701..0000000 --- a/src/net/sourceforge/plantuml/skin/bluemodern/AbstractComponentBlueModernArrow.java +++ /dev/null @@ -1,94 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.skin.bluemodern; - -import net.sourceforge.plantuml.ISkinSimple; -import net.sourceforge.plantuml.LineBreakStrategy; -import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.graphic.FontConfiguration; -import net.sourceforge.plantuml.graphic.HorizontalAlignment; -import net.sourceforge.plantuml.graphic.HtmlColor; -import net.sourceforge.plantuml.skin.AbstractTextualComponent; -import net.sourceforge.plantuml.skin.ArrowComponent; -import net.sourceforge.plantuml.skin.ArrowConfiguration; - -public abstract class AbstractComponentBlueModernArrow extends AbstractTextualComponent implements ArrowComponent { - - private final int arrowDeltaX = 12; - private final int arrowDeltaY = 10; - - private final int arrowDeltaX2 = 10; - private final int arrowDeltaY2 = 5; - private final ArrowConfiguration arrowConfiguration; - private final HtmlColor foregroundColor; - - public AbstractComponentBlueModernArrow(HtmlColor foregroundColor, FontConfiguration font, Display stringsToDisplay, ArrowConfiguration arrowConfiguration, ISkinSimple spriteContainer) { - super(LineBreakStrategy.NONE, stringsToDisplay, font, HorizontalAlignment.LEFT, 17, 17, - 2, spriteContainer, false, null, null); - this.arrowConfiguration = arrowConfiguration; - this.foregroundColor = foregroundColor; - } - - protected final HtmlColor getForegroundColor() { - return foregroundColor; - } - - final protected int getArrowDeltaX() { - return arrowDeltaX; - } - - final protected int getArrowDeltaY() { - return arrowDeltaY; - } - - final protected int getArrowDeltaY2() { - return arrowDeltaY2; - } - - final protected int getArrowDeltaX2() { - return arrowDeltaX2; - } - - @Override - public final double getPaddingY() { - return 6; - } - - final protected ArrowConfiguration getArrowConfiguration() { - return arrowConfiguration; - } - -} diff --git a/src/net/sourceforge/plantuml/skin/bluemodern/BlueModern.java b/src/net/sourceforge/plantuml/skin/bluemodern/BlueModern.java deleted file mode 100644 index b53948c..0000000 --- a/src/net/sourceforge/plantuml/skin/bluemodern/BlueModern.java +++ /dev/null @@ -1,188 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.skin.bluemodern; - -import net.sourceforge.plantuml.FontParam; -import net.sourceforge.plantuml.ISkinParam; -import net.sourceforge.plantuml.LineParam; -import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.graphic.HorizontalAlignment; -import net.sourceforge.plantuml.graphic.HtmlColor; -import net.sourceforge.plantuml.graphic.HtmlColorUtils; -import net.sourceforge.plantuml.graphic.SymbolContext; -import net.sourceforge.plantuml.skin.ArrowConfiguration; -import net.sourceforge.plantuml.skin.Component; -import net.sourceforge.plantuml.skin.ComponentType; -import net.sourceforge.plantuml.skin.Skin; -import net.sourceforge.plantuml.skin.rose.ComponentRoseDestroy; -import net.sourceforge.plantuml.skin.rose.ComponentRoseGroupingElse; -import net.sourceforge.plantuml.skin.rose.ComponentRoseGroupingSpace; -import net.sourceforge.plantuml.skin.rose.ComponentRoseReference; -import net.sourceforge.plantuml.skin.rose.Rose; -import net.sourceforge.plantuml.ugraphic.UFont; - -public class BlueModern implements Skin { - - private final UFont bigFont = UFont.sansSerif(20).bold(); - private final UFont participantFont = UFont.sansSerif(17); - private final UFont normalFont = UFont.sansSerif(13); - private final UFont smallFont = UFont.sansSerif(11).bold(); - - private final HtmlColor hyperlinkColor = HtmlColorUtils.BLUE; - private final boolean useUnderlineForHyperlink = true; - private final HtmlColor blue1 = HtmlColorUtils.COL_527BC6; - private final HtmlColor blue2 = HtmlColorUtils.COL_D1DBEF; - private final HtmlColor blue3 = HtmlColorUtils.COL_D7E0F2; - - private final HtmlColor red = HtmlColorUtils.MY_RED; - - private final HtmlColor lineColor = HtmlColorUtils.COL_989898; - private final HtmlColor borderGroupColor = HtmlColorUtils.COL_BBBBBB; - - public Component createComponent(ComponentType type, ArrowConfiguration config, ISkinParam param, - Display stringsToDisplay) { - - if (type.isArrow()) { - final HtmlColor sequenceArrow = config.getColor() == null ? HtmlColorUtils.BLACK : config.getColor(); - if (config.isSelfArrow()) { - return new ComponentBlueModernSelfArrow(sequenceArrow, normalFont.toFont2(HtmlColorUtils.BLACK, - useUnderlineForHyperlink, hyperlinkColor, param.getTabSize()), stringsToDisplay, config, param); - } - return new ComponentBlueModernArrow(sequenceArrow, useUnderlineForHyperlink, normalFont.toFont2( - HtmlColorUtils.BLACK, useUnderlineForHyperlink, hyperlinkColor, param.getTabSize()), - stringsToDisplay, config, param); - } - if (type == ComponentType.PARTICIPANT_HEAD) { - return new ComponentBlueModernParticipant(blue1, blue2, participantFont.toFont2(HtmlColorUtils.WHITE, - useUnderlineForHyperlink, hyperlinkColor, param.getTabSize()), stringsToDisplay, param); - } - if (type == ComponentType.PARTICIPANT_TAIL) { - return new ComponentBlueModernParticipant(blue1, blue2, participantFont.toFont2(HtmlColorUtils.WHITE, - useUnderlineForHyperlink, hyperlinkColor, param.getTabSize()), stringsToDisplay, param); - } - if (type == ComponentType.PARTICIPANT_LINE) { - return new ComponentBlueModernLine(lineColor); - } - if (type == ComponentType.CONTINUE_LINE) { - return new ComponentBlueModernLine(lineColor); - } - if (type == ComponentType.ACTOR_HEAD) { - return new ComponentBlueModernActor(blue2, blue1, participantFont.toFont2(blue1, useUnderlineForHyperlink, - hyperlinkColor, param.getTabSize()), stringsToDisplay, true, param); - } - if (type == ComponentType.ACTOR_TAIL) { - return new ComponentBlueModernActor(blue2, blue1, participantFont.toFont2(blue1, useUnderlineForHyperlink, - hyperlinkColor, param.getTabSize()), stringsToDisplay, false, param); - } - if (type == ComponentType.NOTE) { - return new ComponentBlueModernNote(HtmlColorUtils.WHITE, HtmlColorUtils.BLACK, normalFont.toFont2( - HtmlColorUtils.BLACK, useUnderlineForHyperlink, hyperlinkColor, param.getTabSize()), - stringsToDisplay, param); - } - if (type == ComponentType.ALIVE_BOX_CLOSE_CLOSE) { - return new ComponentBlueModernActiveLine(blue1, true, true); - } - if (type == ComponentType.ALIVE_BOX_CLOSE_OPEN) { - return new ComponentBlueModernActiveLine(blue1, true, false); - } - if (type == ComponentType.ALIVE_BOX_OPEN_CLOSE) { - return new ComponentBlueModernActiveLine(blue1, false, true); - } - if (type == ComponentType.ALIVE_BOX_OPEN_OPEN) { - return new ComponentBlueModernActiveLine(blue1, false, false); - } - if (type == ComponentType.DELAY_LINE) { - return new ComponentBlueModernDelayLine(lineColor); - } - if (type == ComponentType.DELAY_TEXT) { - return new ComponentBlueModernDelayText(param.getFont(null, false, FontParam.SEQUENCE_DELAY).toFont2( - HtmlColorUtils.BLACK, useUnderlineForHyperlink, hyperlinkColor, param.getTabSize()), - stringsToDisplay, param); - } - if (type == ComponentType.DESTROY) { - return new ComponentRoseDestroy(red); - } - if (type == ComponentType.GROUPING_HEADER) { - return new ComponentBlueModernGroupingHeader(blue1, blue3, borderGroupColor, HtmlColorUtils.BLACK, - normalFont.toFont2(HtmlColorUtils.WHITE, useUnderlineForHyperlink, hyperlinkColor, - param.getTabSize()), smallFont, stringsToDisplay, param); - } - if (type == ComponentType.GROUPING_ELSE) { - return new ComponentRoseGroupingElse(HtmlColorUtils.BLACK, smallFont.toFont2(HtmlColorUtils.BLACK, - useUnderlineForHyperlink, hyperlinkColor, param.getTabSize()), stringsToDisplay.get(0), param, - blue3); - } - if (type == ComponentType.GROUPING_SPACE) { - return new ComponentRoseGroupingSpace(7); - } - // if (type == ComponentType.TITLE) { - // return new ComponentRoseTitle(bigFont.toFont2(HtmlColorUtils.BLACK, useUnderlineForHyperlink, - // hyperlinkColor, param.getTabSize()), stringsToDisplay, param); - // } - if (type == ComponentType.REFERENCE) { - return new ComponentRoseReference(normalFont.toFont2(HtmlColorUtils.BLACK, useUnderlineForHyperlink, - hyperlinkColor, param.getTabSize()), new SymbolContext(blue1, borderGroupColor).withStroke(Rose - .getStroke(param, LineParam.sequenceDividerBorder, 2)), normalFont.toFont2(HtmlColorUtils.WHITE, - useUnderlineForHyperlink, hyperlinkColor, param.getTabSize()), stringsToDisplay, - HorizontalAlignment.CENTER, param, blue3); - } - if (type == ComponentType.NEWPAGE) { - return new ComponentBlueModernNewpage(blue1); - } - if (type == ComponentType.DIVIDER) { - return new ComponentBlueModernDivider(normalFont.toFont2(HtmlColorUtils.BLACK, useUnderlineForHyperlink, - hyperlinkColor, param.getTabSize()), blue2, blue1, HtmlColorUtils.BLACK, stringsToDisplay, param); - } - // if (type == ComponentType.SIGNATURE) { - // return new ComponentRoseTitle(smallFont.toFont2(HtmlColorUtils.BLACK, useUnderlineForHyperlink, - // hyperlinkColor, param.getTabSize()), Display.create("This skin was created ", "in April 2009."), - // param); - // } - if (type == ComponentType.ENGLOBER) { - return new ComponentBlueModernEnglober(blue1, blue3, stringsToDisplay, param.getFont(null, false, - FontParam.SEQUENCE_BOX).toFont2(HtmlColorUtils.BLACK, useUnderlineForHyperlink, hyperlinkColor, - param.getTabSize()), param); - } - - return null; - - } - - public Object getProtocolVersion() { - return 1; - } - -} diff --git a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernActiveLine.java b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernActiveLine.java deleted file mode 100644 index c388a70..0000000 --- a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernActiveLine.java +++ /dev/null @@ -1,82 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.skin.bluemodern; - -import java.awt.geom.Dimension2D; - -import net.sourceforge.plantuml.graphic.HtmlColor; -import net.sourceforge.plantuml.graphic.StringBounder; -import net.sourceforge.plantuml.skin.AbstractComponent; -import net.sourceforge.plantuml.skin.Area; -import net.sourceforge.plantuml.ugraphic.UChangeBackColor; -import net.sourceforge.plantuml.ugraphic.UChangeColor; -import net.sourceforge.plantuml.ugraphic.UGraphic; -import net.sourceforge.plantuml.ugraphic.URectangle; -import net.sourceforge.plantuml.ugraphic.UTranslate; - -public class ComponentBlueModernActiveLine extends AbstractComponent { - - private final int shadowview = 3; - private final HtmlColor foregroundColor; - - public ComponentBlueModernActiveLine(HtmlColor foregroundColor, boolean closeUp, boolean closeDown) { - this.foregroundColor = foregroundColor; - } - - @Override - protected void drawInternalU(UGraphic ug, Area area) { - final Dimension2D dimensionToUse = area.getDimensionToUse(); - final StringBounder stringBounder = ug.getStringBounder(); - final int x = (int) (dimensionToUse.getWidth() - getPreferredWidth(stringBounder)) / 2; - final ShadowShape shadowShape = new ShadowShape(getPreferredWidth(stringBounder), dimensionToUse.getHeight() - - shadowview, 3); - shadowShape.drawU(ug.apply(new UTranslate(shadowview, shadowview))); - - ug.apply(new UChangeColor(foregroundColor)) - .apply(new UChangeBackColor(foregroundColor)).apply(new UTranslate(x, 0)).draw(new URectangle(getPreferredWidth(stringBounder), dimensionToUse.getHeight() - shadowview)); - } - - @Override - public double getPreferredHeight(StringBounder stringBounder) { - return 0; - } - - @Override - public double getPreferredWidth(StringBounder stringBounder) { - return 10; - } - -} diff --git a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernActor.java b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernActor.java deleted file mode 100644 index 42f78fc..0000000 --- a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernActor.java +++ /dev/null @@ -1,99 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.skin.bluemodern; - -import net.sourceforge.plantuml.ISkinSimple; -import net.sourceforge.plantuml.LineBreakStrategy; -import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.graphic.FontConfiguration; -import net.sourceforge.plantuml.graphic.HorizontalAlignment; -import net.sourceforge.plantuml.graphic.HtmlColor; -import net.sourceforge.plantuml.graphic.StringBounder; -import net.sourceforge.plantuml.graphic.TextBlock; -import net.sourceforge.plantuml.skin.AbstractTextualComponent; -import net.sourceforge.plantuml.skin.Area; -import net.sourceforge.plantuml.skin.StickMan; -import net.sourceforge.plantuml.ugraphic.UChangeColor; -import net.sourceforge.plantuml.ugraphic.UGraphic; -import net.sourceforge.plantuml.ugraphic.UTranslate; - -public class ComponentBlueModernActor extends AbstractTextualComponent { - - private final StickMan stickman; - private final boolean head; - - public ComponentBlueModernActor(HtmlColor backgroundColor, HtmlColor foregroundColor, FontConfiguration font, - Display stringsToDisplay, boolean head, ISkinSimple spriteContainer) { - super(LineBreakStrategy.NONE, stringsToDisplay, font, HorizontalAlignment.CENTER, 3, 3, - 0, spriteContainer, false, null, null); - this.head = head; - stickman = new StickMan(backgroundColor, foregroundColor); - } - - @Override - protected void drawInternalU(UGraphic ug, Area area) { - ug = ug.apply(new UChangeColor(getFontColor())); - final TextBlock textBlock = getTextBlock(); - final StringBounder stringBounder = ug.getStringBounder(); - final double delta = (getPreferredWidth(stringBounder) - stickman.getPreferredWidth()) / 2; - - if (head) { - textBlock - .drawU(ug.apply(new UTranslate(getTextMiddlePostion(stringBounder), stickman.getPreferredHeight()))); - ug = ug.apply(new UTranslate(delta, 0)); - } else { - textBlock.drawU(ug.apply(new UTranslate(getTextMiddlePostion(stringBounder), 0))); - ug = ug.apply(new UTranslate(delta, getTextHeight(stringBounder))); - } - stickman.drawU(ug); - - } - - private double getTextMiddlePostion(StringBounder stringBounder) { - return (getPreferredWidth(stringBounder) - getTextWidth(stringBounder)) / 2.0; - } - - @Override - public double getPreferredHeight(StringBounder stringBounder) { - return stickman.getPreferredHeight() + getTextHeight(stringBounder); - } - - @Override - public double getPreferredWidth(StringBounder stringBounder) { - return Math.max(stickman.getPreferredWidth(), getTextWidth(stringBounder)); - } - -} diff --git a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernArrow.java b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernArrow.java deleted file mode 100644 index 36ab05a..0000000 --- a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernArrow.java +++ /dev/null @@ -1,197 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.skin.bluemodern; - -import java.awt.Graphics2D; -import java.awt.geom.Dimension2D; -import java.awt.geom.Point2D; - -import net.sourceforge.plantuml.ISkinSimple; -import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.graphic.FontConfiguration; -import net.sourceforge.plantuml.graphic.HtmlColor; -import net.sourceforge.plantuml.graphic.StringBounder; -import net.sourceforge.plantuml.skin.Area; -import net.sourceforge.plantuml.skin.ArrowConfiguration; -import net.sourceforge.plantuml.skin.ArrowDirection; -import net.sourceforge.plantuml.skin.ArrowPart; -import net.sourceforge.plantuml.ugraphic.UChangeBackColor; -import net.sourceforge.plantuml.ugraphic.UChangeColor; -import net.sourceforge.plantuml.ugraphic.UGraphic; -import net.sourceforge.plantuml.ugraphic.ULine; -import net.sourceforge.plantuml.ugraphic.UPolygon; -import net.sourceforge.plantuml.ugraphic.UStroke; -import net.sourceforge.plantuml.ugraphic.UTranslate; - -public class ComponentBlueModernArrow extends AbstractComponentBlueModernArrow { - - public ComponentBlueModernArrow(HtmlColor foregroundColor, boolean useUnderlineForHyperlink, - FontConfiguration font, Display stringsToDisplay, ArrowConfiguration arrowConfiguration, - ISkinSimple spriteContainer) { - super(foregroundColor, font, stringsToDisplay, arrowConfiguration, spriteContainer); - } - - @Override - protected void drawInternalU(UGraphic ug, Area area) { - if (getArrowConfiguration().isHidden()) { - return; - } - final Dimension2D dimensionToUse = area.getDimensionToUse(); - final StringBounder stringBounder = ug.getStringBounder(); - final int textHeight = (int) getTextHeight(stringBounder); - - ug = ug.apply(new UChangeColor(getForegroundColor())); - ug = ug.apply(new UChangeBackColor(getForegroundColor())); - - final int x2 = (int) dimensionToUse.getWidth(); - - if (getArrowConfiguration().isDotted()) { - ug = ArrowConfiguration.stroke(ug, 5, 2, 1); - } else { - ug = ug.apply(new UStroke(2)); - } - - ug.apply(new UTranslate(2, textHeight)).draw(new ULine(x2 - 4, 0)); - ug = ug.apply(new UStroke()); - - final int direction = getDirection(); - final UPolygon polygon = new UPolygon(); - - if (getArrowConfiguration().isAsync()) { - ug = ug.apply(new UStroke(1.5)); - if (direction == 1) { - if (getArrowConfiguration().getPart() != ArrowPart.BOTTOM_PART) { - ug.apply(new UTranslate(x2 - getArrowDeltaX2(), textHeight - getArrowDeltaY2())).draw( - new ULine(getArrowDeltaX2(), getArrowDeltaY2())); - } - if (getArrowConfiguration().getPart() != ArrowPart.TOP_PART) { - ug.apply(new UTranslate(x2 - getArrowDeltaX2(), textHeight + getArrowDeltaY2())).draw( - new ULine(getArrowDeltaX2(), -getArrowDeltaY2())); - } - } else { - if (getArrowConfiguration().getPart() != ArrowPart.BOTTOM_PART) { - ug.apply(new UTranslate(getArrowDeltaX2(), textHeight - getArrowDeltaY2())).draw( - new ULine(-getArrowDeltaX2(), getArrowDeltaY2())); - } - if (getArrowConfiguration().getPart() != ArrowPart.TOP_PART) { - ug.apply(new UTranslate(getArrowDeltaX2(), textHeight + getArrowDeltaY2())).draw( - new ULine(-getArrowDeltaX2(), -getArrowDeltaY2())); - } - } - ug = ug.apply(new UStroke()); - } else if (direction == 1) { - createPolygonNormal(textHeight, x2, polygon); - } else { - createPolygonReverse(textHeight, polygon); - } - ug.draw(polygon); - - getTextBlock().drawU(ug.apply(new UTranslate(getMarginX1(), 0))); - } - - private void createPolygonReverse(final int textHeight, final UPolygon polygon) { - if (getArrowConfiguration().getPart() == ArrowPart.TOP_PART) { - polygon.addPoint(getArrowDeltaX(), textHeight - getArrowDeltaY()); - polygon.addPoint(0, textHeight); - polygon.addPoint(getArrowDeltaX(), textHeight); - } else if (getArrowConfiguration().getPart() == ArrowPart.BOTTOM_PART) { - polygon.addPoint(getArrowDeltaX(), textHeight); - polygon.addPoint(0, textHeight); - polygon.addPoint(getArrowDeltaX(), textHeight + getArrowDeltaY()); - } else { - polygon.addPoint(getArrowDeltaX(), textHeight - getArrowDeltaY()); - polygon.addPoint(0, textHeight); - polygon.addPoint(getArrowDeltaX(), textHeight + getArrowDeltaY()); - } - } - - private void createPolygonNormal(final int textHeight, final int x2, final UPolygon polygon) { - if (getArrowConfiguration().getPart() == ArrowPart.TOP_PART) { - polygon.addPoint(x2 - getArrowDeltaX(), textHeight - getArrowDeltaY()); - polygon.addPoint(x2, textHeight); - polygon.addPoint(x2 - getArrowDeltaX(), textHeight); - } else if (getArrowConfiguration().getPart() == ArrowPart.BOTTOM_PART) { - polygon.addPoint(x2 - getArrowDeltaX(), textHeight); - polygon.addPoint(x2, textHeight); - polygon.addPoint(x2 - getArrowDeltaX(), textHeight + getArrowDeltaY()); - } else { - polygon.addPoint(x2 - getArrowDeltaX(), textHeight - getArrowDeltaY()); - polygon.addPoint(x2, textHeight); - polygon.addPoint(x2 - getArrowDeltaX(), textHeight + getArrowDeltaY()); - } - } - - protected int getDirection(Graphics2D g2d) { - return getDirection(); - } - - protected int getDirection() { - if (getArrowConfiguration().getArrowDirection() == ArrowDirection.LEFT_TO_RIGHT_NORMAL) { - return 1; - } - if (getArrowConfiguration().getArrowDirection() == ArrowDirection.RIGHT_TO_LEFT_REVERSE) { - return -1; - } - throw new IllegalStateException(); - } - - @Override - public double getPreferredHeight(StringBounder stringBounder) { - return getTextHeight(stringBounder) + getArrowDeltaY() + 2 * getPaddingY(); - } - - @Override - public double getPreferredWidth(StringBounder stringBounder) { - return getTextWidth(stringBounder); - } - - public Point2D getStartPoint(StringBounder stringBounder, Dimension2D dimensionToUse) { - final int textHeight = (int) getTextHeight(stringBounder); - if (getArrowConfiguration().getArrowDirection() == ArrowDirection.LEFT_TO_RIGHT_NORMAL) { - return new Point2D.Double(getPaddingX(), textHeight + getPaddingY()); - } - return new Point2D.Double(dimensionToUse.getWidth() + getPaddingX(), textHeight + getPaddingY()); - } - - public Point2D getEndPoint(StringBounder stringBounder, Dimension2D dimensionToUse) { - final int textHeight = (int) getTextHeight(stringBounder); - if (getArrowConfiguration().getArrowDirection() == ArrowDirection.LEFT_TO_RIGHT_NORMAL) { - return new Point2D.Double(dimensionToUse.getWidth() + getPaddingX(), textHeight + getPaddingY()); - } - return new Point2D.Double(getPaddingX(), textHeight + getPaddingY()); - } - -} diff --git a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernDelayLine.java b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernDelayLine.java deleted file mode 100644 index 6d128db..0000000 --- a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernDelayLine.java +++ /dev/null @@ -1,79 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.skin.bluemodern; - -import java.awt.geom.Dimension2D; - -import net.sourceforge.plantuml.graphic.HtmlColor; -import net.sourceforge.plantuml.graphic.StringBounder; -import net.sourceforge.plantuml.skin.AbstractComponent; -import net.sourceforge.plantuml.skin.Area; -import net.sourceforge.plantuml.skin.ArrowConfiguration; -import net.sourceforge.plantuml.ugraphic.UAntiAliasing; -import net.sourceforge.plantuml.ugraphic.UChangeBackColor; -import net.sourceforge.plantuml.ugraphic.UChangeColor; -import net.sourceforge.plantuml.ugraphic.UGraphic; -import net.sourceforge.plantuml.ugraphic.ULine; -import net.sourceforge.plantuml.ugraphic.UTranslate; - -public class ComponentBlueModernDelayLine extends AbstractComponent { - - private final HtmlColor color; - - public ComponentBlueModernDelayLine(HtmlColor color) { - this.color = color; - } - - @Override - protected void drawInternalU(UGraphic ug, Area area) { - final Dimension2D dimensionToUse = area.getDimensionToUse(); - ug = ug.apply(new UChangeColor(color)); - ug = ArrowConfiguration.stroke(ug, 1, 4, 1); - final int x = (int) (dimensionToUse.getWidth() / 2); - ug.apply(new UChangeBackColor(color)).apply(UAntiAliasing.ANTI_ALIASING_OFF).apply(new UTranslate(x + 1, 0)).draw(new ULine(0, dimensionToUse.getHeight())); - } - - @Override - public double getPreferredHeight(StringBounder stringBounder) { - return 20; - } - - @Override - public double getPreferredWidth(StringBounder stringBounder) { - return 2; - } - -} diff --git a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernDelayText.java b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernDelayText.java deleted file mode 100644 index f661910..0000000 --- a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernDelayText.java +++ /dev/null @@ -1,84 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.skin.bluemodern; - -import java.awt.geom.Dimension2D; - -import net.sourceforge.plantuml.ISkinSimple; -import net.sourceforge.plantuml.LineBreakStrategy; -import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.graphic.FontConfiguration; -import net.sourceforge.plantuml.graphic.HorizontalAlignment; -import net.sourceforge.plantuml.graphic.StringBounder; -import net.sourceforge.plantuml.graphic.TextBlock; -import net.sourceforge.plantuml.skin.AbstractTextualComponent; -import net.sourceforge.plantuml.skin.Area; -import net.sourceforge.plantuml.ugraphic.UGraphic; -import net.sourceforge.plantuml.ugraphic.UTranslate; - -public class ComponentBlueModernDelayText extends AbstractTextualComponent { - - public ComponentBlueModernDelayText(FontConfiguration font, Display stringsToDisplay, - ISkinSimple spriteContainer) { - super(LineBreakStrategy.NONE, stringsToDisplay, font, HorizontalAlignment.CENTER, 4, 4, - 4, spriteContainer, false, null, null); - } - - @Override - protected void drawInternalU(UGraphic ug, Area area) { - final Dimension2D dimensionToUse = area.getDimensionToUse(); - final TextBlock textBlock = getTextBlock(); - final StringBounder stringBounder = ug.getStringBounder(); - final double textWidth = getTextWidth(stringBounder); - final double textHeight = getTextHeight(stringBounder); - - final double xpos = (dimensionToUse.getWidth() - textWidth) / 2; - final double ypos = (dimensionToUse.getHeight() - textHeight) / 2; - - textBlock.drawU(ug.apply(new UTranslate(xpos, (ypos + getMarginY())))); - } - - @Override - public double getPreferredHeight(StringBounder stringBounder) { - return getTextHeight(stringBounder) + 20; - } - - @Override - public double getPreferredWidth(StringBounder stringBounder) { - return getTextWidth(stringBounder) + 30; - } - -} diff --git a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernDivider.java b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernDivider.java deleted file mode 100644 index 06b32b6..0000000 --- a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernDivider.java +++ /dev/null @@ -1,114 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.skin.bluemodern; - -import java.awt.geom.Dimension2D; - -import net.sourceforge.plantuml.ISkinSimple; -import net.sourceforge.plantuml.LineBreakStrategy; -import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.graphic.FontConfiguration; -import net.sourceforge.plantuml.graphic.HorizontalAlignment; -import net.sourceforge.plantuml.graphic.HtmlColor; -import net.sourceforge.plantuml.graphic.HtmlColorUtils; -import net.sourceforge.plantuml.graphic.StringBounder; -import net.sourceforge.plantuml.graphic.TextBlock; -import net.sourceforge.plantuml.skin.AbstractTextualComponent; -import net.sourceforge.plantuml.skin.Area; -import net.sourceforge.plantuml.ugraphic.UChangeBackColor; -import net.sourceforge.plantuml.ugraphic.UChangeColor; -import net.sourceforge.plantuml.ugraphic.UGraphic; -import net.sourceforge.plantuml.ugraphic.ULine; -import net.sourceforge.plantuml.ugraphic.URectangle; -import net.sourceforge.plantuml.ugraphic.UStroke; -import net.sourceforge.plantuml.ugraphic.UTranslate; - -public class ComponentBlueModernDivider extends AbstractTextualComponent { - - private final HtmlColor background1; - private final HtmlColor background2; - private final HtmlColor borderColor; - - public ComponentBlueModernDivider(FontConfiguration font, HtmlColor background1, HtmlColor background2, - HtmlColor borderColor, Display stringsToDisplay, ISkinSimple spriteContainer) { - super(LineBreakStrategy.NONE, stringsToDisplay, font, HorizontalAlignment.CENTER, 4, 4, - 4, spriteContainer, false, null, null); - this.background1 = background1; - this.background2 = background2; - this.borderColor = borderColor; - } - - @Override - protected void drawInternalU(UGraphic ug, Area area) { - final Dimension2D dimensionToUse = area.getDimensionToUse(); - final TextBlock textBlock = getTextBlock(); - final StringBounder stringBounder = ug.getStringBounder(); - final double textWidth = getTextWidth(stringBounder); - final double textHeight = getTextHeight(stringBounder); - - final double deltaX = 6; - final double xpos = (dimensionToUse.getWidth() - textWidth - deltaX) / 2; - final double ypos = (dimensionToUse.getHeight() - textHeight) / 2; - - ug = ug.apply(new UChangeColor(HtmlColorUtils.BLACK)); - ug = ug.apply(new UChangeBackColor(HtmlColorUtils.BLACK)); - ug = ug.apply(new UStroke(2)); - - ug.apply(new UTranslate(0, dimensionToUse.getHeight() / 2 - 1)).draw(new ULine(dimensionToUse.getWidth(), 0)); - ug.apply(new UTranslate(0, dimensionToUse.getHeight() / 2 + 2)).draw(new ULine(dimensionToUse.getWidth(), 0)); - - final FillRoundShape shape = new FillRoundShape(textWidth + deltaX, textHeight, background1, background2, 5); - shape.drawU(ug.apply(new UTranslate(xpos, ypos))); - - ug = ug.apply(new UChangeColor(borderColor)); - ug = ug.apply(new UChangeBackColor(null)); - ug.apply(new UTranslate(xpos, ypos)).draw(new URectangle(textWidth + deltaX, textHeight, 5, 5)); - ug = ug.apply(new UStroke()); - - textBlock.drawU(ug.apply(new UTranslate(xpos + deltaX, ypos + getMarginY()))); - } - - @Override - public double getPreferredHeight(StringBounder stringBounder) { - return getTextHeight(stringBounder) + 20; - } - - @Override - public double getPreferredWidth(StringBounder stringBounder) { - return getTextWidth(stringBounder) + 30; - } - -} diff --git a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernEnglober.java b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernEnglober.java deleted file mode 100644 index a063996..0000000 --- a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernEnglober.java +++ /dev/null @@ -1,97 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.skin.bluemodern; - -import java.awt.geom.Dimension2D; - -import net.sourceforge.plantuml.ISkinSimple; -import net.sourceforge.plantuml.LineBreakStrategy; -import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.graphic.FontConfiguration; -import net.sourceforge.plantuml.graphic.HorizontalAlignment; -import net.sourceforge.plantuml.graphic.HtmlColor; -import net.sourceforge.plantuml.graphic.StringBounder; -import net.sourceforge.plantuml.skin.AbstractTextualComponent; -import net.sourceforge.plantuml.skin.Area; -import net.sourceforge.plantuml.ugraphic.UChangeBackColor; -import net.sourceforge.plantuml.ugraphic.UChangeColor; -import net.sourceforge.plantuml.ugraphic.UGraphic; -import net.sourceforge.plantuml.ugraphic.URectangle; -import net.sourceforge.plantuml.ugraphic.UStroke; -import net.sourceforge.plantuml.ugraphic.UTranslate; - -public class ComponentBlueModernEnglober extends AbstractTextualComponent { - - private final HtmlColor borderColor; - private final HtmlColor backColor; - - public ComponentBlueModernEnglober(HtmlColor borderColor, HtmlColor backColor, Display strings, - FontConfiguration font, ISkinSimple spriteContainer) { - super(LineBreakStrategy.NONE, strings, font, HorizontalAlignment.CENTER, 4, 4, 1, spriteContainer, false, - null, null); - this.borderColor = borderColor; - this.backColor = backColor; - } - - @Override - protected void drawBackgroundInternalU(UGraphic ug, Area area) { - final Dimension2D dimensionToUse = area.getDimensionToUse(); - ug = ug.apply(new UChangeColor(borderColor)); - ug = ug.apply(new UChangeBackColor(backColor)); - ug.apply(new UStroke(2)).draw(new URectangle(dimensionToUse.getWidth(), dimensionToUse.getHeight(), 9, 9)); - final double xpos = (dimensionToUse.getWidth() - getPureTextWidth(ug.getStringBounder())) / 2; - - getTextBlock().drawU(ug.apply(new UTranslate(xpos, 0))); - } - - @Override - protected void drawInternalU(UGraphic ug, Area area) { - // ug.getParam().setColor(Color.RED); - // ug.getParam().setBackcolor(Color.YELLOW); - // ug.draw(0, 0, new URectangle(dimensionToUse.getWidth(), - // dimensionToUse.getHeight())); - } - - @Override - public double getPreferredHeight(StringBounder stringBounder) { - return getTextHeight(stringBounder) + 3; - } - - @Override - public double getPreferredWidth(StringBounder stringBounder) { - return getTextWidth(stringBounder) + 10; - } -} diff --git a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernGroupingHeader.java b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernGroupingHeader.java deleted file mode 100644 index a683aa7..0000000 --- a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernGroupingHeader.java +++ /dev/null @@ -1,161 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.skin.bluemodern; - -import java.awt.geom.Dimension2D; - -import net.sourceforge.plantuml.ISkinSimple; -import net.sourceforge.plantuml.LineBreakStrategy; -import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.graphic.FontConfiguration; -import net.sourceforge.plantuml.graphic.HorizontalAlignment; -import net.sourceforge.plantuml.graphic.HtmlColor; -import net.sourceforge.plantuml.graphic.StringBounder; -import net.sourceforge.plantuml.graphic.TextBlock; -import net.sourceforge.plantuml.skin.AbstractTextualComponent; -import net.sourceforge.plantuml.skin.Area; -import net.sourceforge.plantuml.ugraphic.UChangeBackColor; -import net.sourceforge.plantuml.ugraphic.UChangeColor; -import net.sourceforge.plantuml.ugraphic.UFont; -import net.sourceforge.plantuml.ugraphic.UGraphic; -import net.sourceforge.plantuml.ugraphic.ULine; -import net.sourceforge.plantuml.ugraphic.UPolygon; -import net.sourceforge.plantuml.ugraphic.URectangle; -import net.sourceforge.plantuml.ugraphic.UStroke; -import net.sourceforge.plantuml.ugraphic.UTranslate; - -public class ComponentBlueModernGroupingHeader extends AbstractTextualComponent { - - private final int cornersize = 10; - private final int commentMargin = 0; // 8; - - private final TextBlock commentTextBlock; - - private final HtmlColor headerBackgroundColor; - private final HtmlColor generalBackgroundColor; - private final HtmlColor borderColor; - - public ComponentBlueModernGroupingHeader(HtmlColor headerBackgroundColor, HtmlColor generalBackgroundColor, - HtmlColor borderColor, HtmlColor fontColor2, FontConfiguration bigFont, UFont smallFont, Display strings, - ISkinSimple spriteContainer) { - super(LineBreakStrategy.NONE, strings.get(0), bigFont, HorizontalAlignment.LEFT, 15, 30, 1, spriteContainer, null, null); - this.headerBackgroundColor = headerBackgroundColor; - this.generalBackgroundColor = generalBackgroundColor; - this.borderColor = borderColor; - if (strings.size() == 1 || strings.get(1) == null) { - this.commentTextBlock = null; - } else { - final FontConfiguration fontConfiguration = new FontConfiguration(smallFont, fontColor2, - bigFont.getHyperlinkColor(), bigFont.useUnderlineForHyperlink(), spriteContainer.getTabSize()); - this.commentTextBlock = Display.create("[" + strings.get(1) + "]").create(fontConfiguration, - HorizontalAlignment.LEFT, spriteContainer); - } - } - - // @Override - // public double getPaddingY() { - // return 6; - // } - - @Override - final public double getPreferredWidth(StringBounder stringBounder) { - final double sup; - if (commentTextBlock == null) { - sup = commentMargin * 2; - } else { - final Dimension2D size = commentTextBlock.calculateDimension(stringBounder); - sup = getMarginX1() + commentMargin + size.getWidth(); - - } - return getTextWidth(stringBounder) + sup; - } - - @Override - final public double getPreferredHeight(StringBounder stringBounder) { - return getTextHeight(stringBounder) + 2 * getPaddingY(); - } - - @Override - protected void drawBackgroundInternalU(UGraphic ug, Area area) { - final Dimension2D dimensionToUse = area.getDimensionToUse(); - ug.apply(new UChangeColor(borderColor)).apply(new UStroke(2)) - .apply(new UChangeBackColor(generalBackgroundColor)) - .draw(new URectangle(dimensionToUse.getWidth(), dimensionToUse.getHeight())); - } - - @Override - protected void drawInternalU(UGraphic ug, Area area) { - final Dimension2D dimensionToUse = area.getDimensionToUse(); - ug = ug.apply(new UChangeColor(borderColor)); - ug.apply(new UStroke(2)).draw(new URectangle(dimensionToUse.getWidth(), dimensionToUse.getHeight())); - - final StringBounder stringBounder = ug.getStringBounder(); - final int textWidth = (int) getTextWidth(stringBounder); - final int textHeight = (int) getTextHeight(stringBounder); - - final UPolygon polygon = new UPolygon(); - polygon.addPoint(0, 0); - polygon.addPoint(textWidth, 0); - - polygon.addPoint(textWidth, textHeight - cornersize); - polygon.addPoint(textWidth - cornersize, textHeight); - - polygon.addPoint(0, textHeight); - polygon.addPoint(0, 0); - - ug = ug.apply(new UStroke(2)); - ug = ug.apply(new UChangeBackColor(headerBackgroundColor)); - ug.draw(polygon); - ug.draw(new ULine(dimensionToUse.getWidth(), 0)); - - final double heightWithoutPadding = dimensionToUse.getHeight() - getPaddingY(); - - ug.apply(new UTranslate(dimensionToUse.getWidth(), 0)).draw(new ULine(0, heightWithoutPadding)); - ug.apply(new UTranslate(0, textHeight)).draw(new ULine(0, heightWithoutPadding - textHeight)); - ug = ug.apply(new UStroke()); - - getTextBlock().drawU(ug.apply(new UTranslate(getMarginX1(), getMarginY()))); - - if (commentTextBlock != null) { - final int x1 = getMarginX1() + textWidth; - final int y2 = getMarginY() + 1; - - commentTextBlock.drawU(ug.apply(new UChangeColor(generalBackgroundColor)).apply( - new UTranslate(x1 + commentMargin, y2))); - } - } - -} diff --git a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernLine.java b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernLine.java deleted file mode 100644 index d0670ff..0000000 --- a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernLine.java +++ /dev/null @@ -1,76 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.skin.bluemodern; - -import java.awt.geom.Dimension2D; - -import net.sourceforge.plantuml.graphic.HtmlColor; -import net.sourceforge.plantuml.graphic.StringBounder; -import net.sourceforge.plantuml.skin.AbstractComponent; -import net.sourceforge.plantuml.skin.Area; -import net.sourceforge.plantuml.ugraphic.UChangeBackColor; -import net.sourceforge.plantuml.ugraphic.UChangeColor; -import net.sourceforge.plantuml.ugraphic.UGraphic; -import net.sourceforge.plantuml.ugraphic.URectangle; -import net.sourceforge.plantuml.ugraphic.UTranslate; - -public class ComponentBlueModernLine extends AbstractComponent { - - private final HtmlColor color; - - public ComponentBlueModernLine(HtmlColor color) { - this.color = color; - } - - @Override - protected void drawInternalU(UGraphic ug, Area area) { - final Dimension2D dimensionToUse = area.getDimensionToUse(); - final int x = (int) (dimensionToUse.getWidth() / 2); - final StringBounder stringBounder = ug.getStringBounder(); - ug.apply(new UChangeColor(color)).apply(new UChangeBackColor(color)).apply(new UTranslate(x, 0)).draw(new URectangle(getPreferredWidth(stringBounder), dimensionToUse.getHeight())); - } - - @Override - public double getPreferredHeight(StringBounder stringBounder) { - return 20; - } - - @Override - public double getPreferredWidth(StringBounder stringBounder) { - return 2; - } - -} diff --git a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernNewpage.java b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernNewpage.java deleted file mode 100644 index 2e5dae5..0000000 --- a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernNewpage.java +++ /dev/null @@ -1,74 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.skin.bluemodern; - -import java.awt.geom.Dimension2D; - -import net.sourceforge.plantuml.graphic.HtmlColor; -import net.sourceforge.plantuml.graphic.StringBounder; -import net.sourceforge.plantuml.skin.AbstractComponent; -import net.sourceforge.plantuml.skin.Area; -import net.sourceforge.plantuml.skin.ArrowConfiguration; -import net.sourceforge.plantuml.ugraphic.UChangeColor; -import net.sourceforge.plantuml.ugraphic.UGraphic; -import net.sourceforge.plantuml.ugraphic.ULine; - -public class ComponentBlueModernNewpage extends AbstractComponent { - - private final HtmlColor foregroundColor; - - public ComponentBlueModernNewpage(HtmlColor foregroundColor) { - this.foregroundColor = foregroundColor; - } - - @Override - protected void drawInternalU(UGraphic ug, Area area) { - final Dimension2D dimensionToUse = area.getDimensionToUse(); - ug = ArrowConfiguration.stroke(ug, 10, 2, 1); - ug.apply(new UChangeColor(foregroundColor)).draw(new ULine(dimensionToUse.getWidth(), 0)); - } - - @Override - public double getPreferredHeight(StringBounder stringBounder) { - return 2; - } - - @Override - public double getPreferredWidth(StringBounder stringBounder) { - return 0; - } - -} diff --git a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernNote.java b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernNote.java deleted file mode 100644 index 10df111..0000000 --- a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernNote.java +++ /dev/null @@ -1,119 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.skin.bluemodern; - -import net.sourceforge.plantuml.ISkinSimple; -import net.sourceforge.plantuml.LineBreakStrategy; -import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.graphic.FontConfiguration; -import net.sourceforge.plantuml.graphic.HorizontalAlignment; -import net.sourceforge.plantuml.graphic.HtmlColor; -import net.sourceforge.plantuml.graphic.StringBounder; -import net.sourceforge.plantuml.skin.AbstractTextualComponent; -import net.sourceforge.plantuml.skin.Area; -import net.sourceforge.plantuml.ugraphic.UChangeBackColor; -import net.sourceforge.plantuml.ugraphic.UChangeColor; -import net.sourceforge.plantuml.ugraphic.UGraphic; -import net.sourceforge.plantuml.ugraphic.ULine; -import net.sourceforge.plantuml.ugraphic.UPolygon; -import net.sourceforge.plantuml.ugraphic.UTranslate; - -final public class ComponentBlueModernNote extends AbstractTextualComponent { - - private final int shadowview = 4; - private final int cornersize = 10; - private final HtmlColor back; - private final HtmlColor foregroundColor; - - public ComponentBlueModernNote(HtmlColor back, HtmlColor foregroundColor, FontConfiguration font, - Display strings, ISkinSimple spriteContainer) { - super(LineBreakStrategy.NONE, strings, font, HorizontalAlignment.LEFT, 6, 15, 5, spriteContainer, false, - null, null); - this.back = back; - this.foregroundColor = foregroundColor; - } - - @Override - final public double getPreferredWidth(StringBounder stringBounder) { - final double result = getTextWidth(stringBounder) + 2 * getPaddingX(); - return result; - } - - @Override - final public double getPreferredHeight(StringBounder stringBounder) { - return getTextHeight(stringBounder) + 2 * getPaddingY(); - } - - @Override - public double getPaddingX() { - return 9; - } - - @Override - public double getPaddingY() { - return 9; - } - - @Override - protected void drawInternalU(UGraphic ug, Area area) { - final StringBounder stringBounder = ug.getStringBounder(); - final double textHeight = getTextHeight(stringBounder); - - final double textWidth = getTextWidth(stringBounder); - - final ShadowShape shadowShape = new ShadowShape(textWidth, textHeight, 3); - shadowShape.drawU(ug.apply(new UTranslate(shadowview, shadowview))); - - final UPolygon polygon = new UPolygon(); - polygon.addPoint(0, 0); - polygon.addPoint(0, textHeight); - polygon.addPoint(textWidth, textHeight); - polygon.addPoint(textWidth, cornersize); - polygon.addPoint(textWidth - cornersize, 0); - polygon.addPoint(0, 0); - - ug = ug.apply(new UChangeBackColor(back)); - ug = ug.apply(new UChangeColor(foregroundColor)); - ug.draw(polygon); - - ug.apply(new UTranslate(textWidth - cornersize, 0)).draw(new ULine(0, cornersize)); - ug.apply(new UTranslate(textWidth, cornersize)).draw(new ULine(-cornersize, 0)); - - getTextBlock().drawU(ug.apply(new UTranslate(getMarginX1(), getMarginY()))); - - } - -} diff --git a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernParticipant.java b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernParticipant.java deleted file mode 100644 index 405ea4f..0000000 --- a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernParticipant.java +++ /dev/null @@ -1,92 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.skin.bluemodern; - -import net.sourceforge.plantuml.ISkinSimple; -import net.sourceforge.plantuml.LineBreakStrategy; -import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.graphic.FontConfiguration; -import net.sourceforge.plantuml.graphic.HorizontalAlignment; -import net.sourceforge.plantuml.graphic.HtmlColor; -import net.sourceforge.plantuml.graphic.StringBounder; -import net.sourceforge.plantuml.skin.AbstractTextualComponent; -import net.sourceforge.plantuml.skin.Area; -import net.sourceforge.plantuml.ugraphic.UChangeColor; -import net.sourceforge.plantuml.ugraphic.UGraphic; -import net.sourceforge.plantuml.ugraphic.UTranslate; - -public class ComponentBlueModernParticipant extends AbstractTextualComponent { - - private final int shadowview = 3; - private final HtmlColor blue1; - private final HtmlColor blue2; - - public ComponentBlueModernParticipant(HtmlColor blue1, HtmlColor blue2, FontConfiguration font, - Display stringsToDisplay, ISkinSimple spriteContainer) { - super(LineBreakStrategy.NONE, stringsToDisplay, font, HorizontalAlignment.CENTER, 7, 7, - 7, spriteContainer, false, null, null); - this.blue1 = blue1; - this.blue2 = blue2; - } - - @Override - protected void drawInternalU(UGraphic ug, Area area) { - final StringBounder stringBounder = ug.getStringBounder(); - - final ShadowShape shadowShape = new ShadowShape(getTextWidth(stringBounder), getTextHeight(stringBounder), 10); - final UGraphic ugShadow = ug.apply(new UTranslate(shadowview, shadowview)).apply(new UChangeColor(null)); - // ug.translate(shadowview, shadowview); - shadowShape.drawU(ugShadow); - // ug.translate(-shadowview, -shadowview); - - final FillRoundShape shape = new FillRoundShape(getTextWidth(stringBounder), getTextHeight(stringBounder), - blue1, blue2, 10); - shape.drawU(ug); - - getTextBlock().drawU(ug.apply(new UTranslate(getMarginX1(), getMarginY()))); - } - - @Override - public double getPreferredHeight(StringBounder stringBounder) { - return getTextHeight(stringBounder) + shadowview; - } - - @Override - public double getPreferredWidth(StringBounder stringBounder) { - return getTextWidth(stringBounder); - } - -} diff --git a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernSelfArrow.java b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernSelfArrow.java deleted file mode 100644 index 65eaf39..0000000 --- a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernSelfArrow.java +++ /dev/null @@ -1,157 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.skin.bluemodern; - -import java.awt.geom.Dimension2D; -import java.awt.geom.Point2D; - -import net.sourceforge.plantuml.ISkinSimple; -import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.graphic.FontConfiguration; -import net.sourceforge.plantuml.graphic.HtmlColor; -import net.sourceforge.plantuml.graphic.StringBounder; -import net.sourceforge.plantuml.skin.Area; -import net.sourceforge.plantuml.skin.ArrowConfiguration; -import net.sourceforge.plantuml.skin.ArrowPart; -import net.sourceforge.plantuml.ugraphic.UChangeBackColor; -import net.sourceforge.plantuml.ugraphic.UChangeColor; -import net.sourceforge.plantuml.ugraphic.UGraphic; -import net.sourceforge.plantuml.ugraphic.ULine; -import net.sourceforge.plantuml.ugraphic.UPolygon; -import net.sourceforge.plantuml.ugraphic.UStroke; -import net.sourceforge.plantuml.ugraphic.UTranslate; - -public class ComponentBlueModernSelfArrow extends AbstractComponentBlueModernArrow { - - private final double arrowWidth = 45; - - public ComponentBlueModernSelfArrow(HtmlColor foregroundColor, FontConfiguration font, Display stringsToDisplay, - ArrowConfiguration arrowConfiguration, ISkinSimple spriteContainer) { - super(foregroundColor, font, stringsToDisplay, arrowConfiguration, spriteContainer); - } - - @Override - protected void drawInternalU(UGraphic ug, Area area) { - if (getArrowConfiguration().isHidden()) { - return; - } - final StringBounder stringBounder = ug.getStringBounder(); - final int textHeight = (int) getTextHeight(stringBounder); - - ug = ug.apply(new UChangeBackColor(getForegroundColor())).apply(new UChangeColor(getForegroundColor())); - final double x2 = arrowWidth - 3; - - if (getArrowConfiguration().isDotted()) { - ug = ArrowConfiguration.stroke(ug, 5, 2, 1); - } else { - ug = ug.apply(new UStroke(2)); - } - - ug.apply(new UTranslate(0, textHeight)).draw(new ULine(x2, 0)); - - final int textAndArrowHeight = (int) (textHeight + getArrowOnlyHeight(stringBounder)); - - ug.apply(new UTranslate(x2, textHeight)).draw(new ULine(0, textAndArrowHeight - textHeight)); - ug.apply(new UTranslate(x2, textAndArrowHeight)).draw(new ULine(2 - x2, 0)); - - ug = ug.apply(new UStroke()); - - final int delta = (int) getArrowOnlyHeight(stringBounder); - - if (getArrowConfiguration().isAsync()) { - if (getArrowConfiguration().getPart() != ArrowPart.BOTTOM_PART) { - ug.apply(new UStroke(1.5)) - .apply(new UTranslate(getArrowDeltaX2(), textHeight - getArrowDeltaY2() + delta)) - .draw(new ULine(-getArrowDeltaX2(), getArrowDeltaY2())); - } - if (getArrowConfiguration().getPart() != ArrowPart.TOP_PART) { - ug.apply(new UStroke(1.5)) - .apply(new UTranslate(getArrowDeltaX2(), textHeight + getArrowDeltaY2() + delta)) - .draw(new ULine(-getArrowDeltaX2(), -getArrowDeltaY2())); - } - } else { - final UPolygon polygon = getPolygon(textHeight, delta); - ug.draw(polygon); - } - - getTextBlock().drawU(ug.apply(new UTranslate(getMarginX1(), 0))); - - } - - private UPolygon getPolygon(final int textHeight, final int delta) { - final UPolygon polygon = new UPolygon(); - if (getArrowConfiguration().getPart() == ArrowPart.TOP_PART) { - polygon.addPoint(getArrowDeltaX(), textHeight - getArrowDeltaY() + delta); - polygon.addPoint(0, textHeight + delta); - polygon.addPoint(getArrowDeltaX(), textHeight + delta); - } else if (getArrowConfiguration().getPart() == ArrowPart.BOTTOM_PART) { - polygon.addPoint(getArrowDeltaX(), textHeight + delta); - polygon.addPoint(0, textHeight + delta); - polygon.addPoint(getArrowDeltaX(), textHeight + getArrowDeltaY() + delta); - } else { - polygon.addPoint(getArrowDeltaX(), textHeight - getArrowDeltaY() + delta); - polygon.addPoint(0, textHeight + delta); - polygon.addPoint(getArrowDeltaX(), textHeight + getArrowDeltaY() + delta); - } - return polygon; - } - - @Override - public double getPreferredHeight(StringBounder stringBounder) { - return getTextHeight(stringBounder) + getArrowDeltaY() + getArrowOnlyHeight(stringBounder) + 2 * getPaddingY(); - } - - private double getArrowOnlyHeight(StringBounder stringBounder) { - return 13; - } - - @Override - public double getPreferredWidth(StringBounder stringBounder) { - return Math.max(getTextWidth(stringBounder), arrowWidth); - } - - public Point2D getStartPoint(StringBounder stringBounder, Dimension2D dimensionToUse) { - final int textHeight = (int) getTextHeight(stringBounder); - return new Point2D.Double(getPaddingX(), textHeight + getPaddingY()); - } - - public Point2D getEndPoint(StringBounder stringBounder, Dimension2D dimensionToUse) { - final int textHeight = (int) getTextHeight(stringBounder); - final int textAndArrowHeight = (int) (textHeight + getArrowOnlyHeight(stringBounder)); - return new Point2D.Double(getPaddingX(), textAndArrowHeight + getPaddingY()); - } - -} diff --git a/src/net/sourceforge/plantuml/skin/bluemodern/FillRoundShape.java b/src/net/sourceforge/plantuml/skin/bluemodern/FillRoundShape.java deleted file mode 100644 index 5183b0e..0000000 --- a/src/net/sourceforge/plantuml/skin/bluemodern/FillRoundShape.java +++ /dev/null @@ -1,80 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.skin.bluemodern; - -import java.awt.GradientPaint; -import java.awt.Graphics2D; -import java.awt.geom.RoundRectangle2D; - -import net.sourceforge.plantuml.graphic.HtmlColor; -import net.sourceforge.plantuml.graphic.HtmlColorGradient; -import net.sourceforge.plantuml.ugraphic.ColorMapper; -import net.sourceforge.plantuml.ugraphic.UChangeBackColor; -import net.sourceforge.plantuml.ugraphic.UGraphic; -import net.sourceforge.plantuml.ugraphic.URectangle; - -public class FillRoundShape { - - final private double width; - final private double height; - final private double corner; - final private HtmlColor c1; - final private HtmlColor c2; - - public FillRoundShape(double width, double height, HtmlColor c1, HtmlColor c2, double corner) { - this.width = width; - this.height = height; - this.c1 = c1; - this.c2 = c2; - this.corner = corner; - - } - - public void draw(ColorMapper mapper, Graphics2D g2d) { - final GradientPaint paint = new GradientPaint(0, 0, mapper.getMappedColor(c1), (float) width, (float) height, - mapper.getMappedColor(c2)); - final RoundRectangle2D r = new RoundRectangle2D.Double(0, 0, width, height, corner * 2, corner * 2); - g2d.setPaint(paint); - g2d.fill(r); - } - - public void drawU(UGraphic ug) { - final HtmlColorGradient gradient = new HtmlColorGradient(c1, c2, '\\'); - final URectangle r = new URectangle(width, height, corner * 2, corner * 2); - ug.apply(new UChangeBackColor(gradient)).draw(r); - } - -} diff --git a/src/net/sourceforge/plantuml/skin/bluemodern/ShadowShape.java b/src/net/sourceforge/plantuml/skin/bluemodern/ShadowShape.java deleted file mode 100644 index 2c3c427..0000000 --- a/src/net/sourceforge/plantuml/skin/bluemodern/ShadowShape.java +++ /dev/null @@ -1,47 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.skin.bluemodern; - -import net.sourceforge.plantuml.graphic.HtmlColorUtils; - -public class ShadowShape extends FillRoundShape { - - public ShadowShape(double width, double height, double corner) { - super(width, height, HtmlColorUtils.LIGHT_GRAY, HtmlColorUtils.GRAY, corner); - - } - -} diff --git a/src/net/sourceforge/plantuml/stats/StatsUtilsIncrement.java b/src/net/sourceforge/plantuml/stats/StatsUtilsIncrement.java index 7d8af87..d92bbaa 100644 --- a/src/net/sourceforge/plantuml/stats/StatsUtilsIncrement.java +++ b/src/net/sourceforge/plantuml/stats/StatsUtilsIncrement.java @@ -35,11 +35,6 @@ */ package net.sourceforge.plantuml.stats; -import java.util.concurrent.ConcurrentMap; -import java.util.concurrent.locks.Lock; -import java.util.concurrent.locks.ReentrantLock; -import java.util.prefs.Preferences; - import net.sourceforge.plantuml.FileFormat; import net.sourceforge.plantuml.PSystemError; import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3; @@ -51,7 +46,11 @@ import net.sourceforge.plantuml.jcckit.PSystemJcckit; import net.sourceforge.plantuml.math.PSystemMath; import net.sourceforge.plantuml.salt.PSystemSalt; import net.sourceforge.plantuml.stats.api.Stats; -import net.sourceforge.plantuml.sudoku.PSystemSudoku; + +import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.locks.Lock; +import java.util.concurrent.locks.ReentrantLock; +import java.util.prefs.Preferences; public class StatsUtilsIncrement { @@ -122,9 +121,6 @@ public class StatsUtilsIncrement { if (type == PSystemSalt.class) { return "Salt"; } - if (type == PSystemSudoku.class) { - return "Sudoku"; - } if (type == PSystemDot.class) { return "Dot"; } diff --git a/src/net/sourceforge/plantuml/sudoku/DLXEngine.java b/src/net/sourceforge/plantuml/sudoku/DLXEngine.java deleted file mode 100644 index 2055c11..0000000 --- a/src/net/sourceforge/plantuml/sudoku/DLXEngine.java +++ /dev/null @@ -1,1175 +0,0 @@ -/**************************************************************************** - * DLXEngine.java - * - * Created on den 30 december 2005, 01:04 - * - * DLXEngine - * Sudoku puzzle generator and solver based on the suexg and suexk by - * Gunter Stertenbrink. Suexg and suexk are C implementations of the - * Dancing Links algorithm by Donald Knuth and optimized for performance - * which means that certain cleanup work has been done. There is still - * lots of these activities left to do, however, the code is nasty and - * hard to read - but extremely efficient. - * - * The code is public domain so feel free to use it. - *****************************************************************************/ - -package net.sourceforge.plantuml.sudoku; - -import java.io.FileOutputStream; -import java.io.IOException; -import java.util.Random; - -/******************************************************************************* - * dlx_solver solve any Sudoku in a fraction of a second. Input is a string of - * dots and digits representing the puzzle to solve and output is the solved - * puzzle. - * - * @author Rolf Sandberg - ******************************************************************************/ -class dlx_solver { - static final int M = 8; // change this for larger grids. Use symbols as in - // L[] below - static final int M2 = M * M; - static final int M4 = M2 * M2; - - /** Pseudo-random number generator */ - long MWC() { - return random.nextLong(); - } - - int A0[][] = new int[M2 + 9][M2 + 9], A[][] = new int[M2 + 9][M2 + 9], Rows[] = new int[4 * M4 + 9], - Cols[] = new int[M2 * M4 + 9], Row[][] = new int[4 * M4 + 9][M2 + 9]; - int Col[][] = new int[M2 * M4 + 9][5], Ur[] = new int[M2 * M4 + 9], Uc[] = new int[4 * M4 + 9], V[] = new int[M2 - * M4 + 9]; - int C[] = new int[M4 + 9], I[] = new int[M4 + 9], T[] = new int[M2 * M4 + 9], P[] = new int[M2 * M4 + 9]; - int Mr[] = { 0, 1, 63, 1023, 4095, 16383, 46655, 131071, 262143 }; - int Mc[] = { 0, 1, 63, 511, 1023, 4095, 8191, 16383, 16383 }; - int Mw[] = { 0, 1, 3, 15, 15, 31, 63, 63, 63 }; - - int nocheck = 0, max, _try_; - final int rnd = 0; - int min, clues, gu, tries; - long Node[] = new long[M4 + 9]; - long nodes, tnodes, solutions, vmax, smax, time0, time1, t1, x1; - double xx, yy; - int q, a, p, i, i1, j, k, l, r, r1, c, c1, c2, n, N = 0, N2, N4, m, m0, m1, x, y, s; - char L[] = { '.', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', - 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', - 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', - '#', '*', '~' }; - - /** State machine states */ - static final int M6 = 10; - static final int M7 = 11; - static final int RESTART = 12; - static final int M22 = 13; - static final int M3 = 14; - static final int M44 = 15; - static final int NEXT_TRY = 16; - static final int END = 30; - - /** - * Solver function. Input parameter: A puzzle to solve Output: The solved - * puzzle - */ - String solve(String puzzle) { - String result = new String(); - int STATE = M6; - - vmax = 4000000; - smax = 25; - p = 1; - q = 0; - - if (q > 0) { - vmax = 99999999; - smax = 99999999; - } - - N = 3; - N2 = N * N; - N4 = N2 * N2; - m = 4 * N4; - n = N2 * N4; - - if (puzzle.length() < N4) { - return "Error, puzzle incomplete"; - } - - while (STATE != END) { - switch (STATE) { - case M6: - clues = 0; - i = 0; - for (x = 0; x < N2; x++) - for (y = 0; y < N2; y++) { - c = puzzle.charAt(x * N2 + y); - j = 0; - - if (c == '-' || c == '.' || c == '0' || c == '*') { - A0[x][y] = j; - i++; - } else { - while (L[j] != c && j <= N2) - j++; - - if (j <= N2) { - A0[x][y] = j; - if (j > 0) - clues++; - i++; - } - } - } - - if (clues == N4) { - clues--; - A0[1][1] = 0; - } - - if (p < 8) { - for (i = 0; i <= N4; i++) - Node[i] = 0; - } - tnodes = 0; - - case RESTART: - r = 0; - for (x = 1; x <= N2; x++) - for (y = 1; y <= N2; y++) - for (s = 1; s <= N2; s++) { - r++; - Cols[r] = 4; - Col[r][1] = x * N2 - N2 + y; - Col[r][4] = (N * ((x - 1) / N) + (y - 1) / N) * N2 + s + N4; - - Col[r][3] = x * N2 - N2 + s + N4 * 2; - Col[r][2] = y * N2 - N2 + s + N4 * 3; - } - for (c = 1; c <= m; c++) - Rows[c] = 0; - - for (r = 1; r <= n; r++) - for (c = 1; c <= Cols[r]; c++) { - x = Col[r][c]; - Rows[x]++; - Row[x][Rows[x]] = r; - } - - for (x = 0; x < N2; x++) - for (y = 0; y < N2; y++) - A[x][y] = A0[x][y]; - - for (i = 0; i <= n; i++) - Ur[i] = 0; - for (i = 0; i <= m; i++) - Uc[i] = 0; - - solutions = 0; - - for (x = 1; x <= N2; x++) - for (y = 1; y <= N2; y++) - if (A[x - 1][y - 1] > 0) { - r = x * N4 - N4 + y * N2 - N2 + A[x - 1][y - 1]; - - for (j = 1; j <= Cols[r]; j++) { - c1 = Col[r][j]; - if (Uc[c1] > 0 && nocheck == 0) { - STATE = NEXT_TRY; - break; - } - - Uc[c1]++; - - for (k = 1; k <= Rows[c1]; k++) { - r1 = Row[c1][k]; - Ur[r1]++; - } - } - if (STATE == NEXT_TRY) - break; - } - if (STATE == NEXT_TRY) - break; - - if (rnd > 0 && rnd != 17 && rnd != 18) - shuffle(); - - for (c = 1; c <= m; c++) { - V[c] = 0; - for (r = 1; r <= Rows[c]; r++) - if (Ur[Row[c][r]] == 0) - V[c]++; - } - - i = clues; - nodes = 0; - m0 = 0; - m1 = 0; - gu = 0; - solutions = 0; - - case M22: - i++; - I[i] = 0; - min = n + 1; - if (i > N4 || m0 > 0) { - STATE = M44; - break; - } - if (m1 > 0) { - C[i] = m1; - STATE = M3; - break; - } - for (c = 1; c <= m; c++) - if (Uc[c] == 0) { - if (V[c] <= min) - c1 = c; - if (V[c] < min) { - min = V[c]; - C[i] = c; - if (min < 2) { - STATE = M3; - break; - } - } - } - if (STATE == M3) - break; - - gu++; - if (min > 2) { - STATE = M3; - break; - } - - if ((rnd & 255) == 18) - if ((nodes & 1) > 0) { - c = m + 1; - c--; - while (Uc[c] > 0 || V[c] != 2) - c--; - C[i] = c; - } - - if ((rnd & 255) == 17) { - c1 = (int) (MWC() & Mc[N]); - while (c1 >= m) - c1 = (int) (MWC() & Mc[N]); - c1++; - - for (c = c1; c <= m; c++) - if (Uc[c] == 0) - if (V[c] == 2) { - C[i] = c; - STATE = M3; - break; - } - for (c = 1; c < c1; c++) - if (Uc[c] == 0) - if (V[c] == 2) { - C[i] = c; - STATE = M3; - break; - } - } - - case M3: - c = C[i]; - I[i]++; - if (I[i] > Rows[c]) { - STATE = M44; - break; - } - - r = Row[c][I[i]]; - if (Ur[r] > 0) { - STATE = M3; - break; - } - m0 = 0; - m1 = 0; - - if (q > 0 && i > 32 && i < 65) - if ((MWC() & 127) < q) { - STATE = M3; - break; - } - - k = N4; - x = (r - 1) / k + 1; - y = ((r - 1) % k) / j + 1; - s = (r - 1) % j + 1; - - if ((p & 1) > 0) { - j = N2; - k = N4; - x = (r - 1) / k + 1; - y = ((r - 1) % k) / j + 1; - s = (r - 1) % j + 1; - A[x - 1][y - 1] = s; - if (i == k) { - for (x = 0; x < j; x++) - for (y = 0; y < j; y++) - result = result.concat(String.valueOf(L[A[x][y]])); - result = result.concat(" #\n"); - } - } - - for (j = 1; j <= Cols[r]; j++) { - c1 = Col[r][j]; - Uc[c1]++; - } - - for (j = 1; j <= Cols[r]; j++) { - c1 = Col[r][j]; - - for (k = 1; k <= Rows[c1]; k++) { - r1 = Row[c1][k]; - Ur[r1]++; - if (Ur[r1] == 1) - for (l = 1; l <= Cols[r1]; l++) { - c2 = Col[r1][l]; - V[c2]--; - - if (Uc[c2] + V[c2] < 1) - m0 = c2; - if (Uc[c2] == 0 && V[c2] < 2) - m1 = c2; - } - } - } - Node[i]++; - tnodes++; - nodes++; - if (rnd > 99 && nodes > rnd) { - STATE = RESTART; - break; - } - if (i == N4) - solutions++; - - if (solutions >= smax) { - System.out.println("smax xolutions found"); - if (_try_ == 1) - System.out.print("+"); - STATE = NEXT_TRY; - break; - } - if (tnodes > vmax) { - if (_try_ == 1) - System.out.print("-"); - STATE = NEXT_TRY; - break; - } - STATE = M22; - break; - - case M44: - i--; - c = C[i]; - r = Row[c][I[i]]; - if (i == clues) { - STATE = NEXT_TRY; - break; - } - - for (j = 1; j <= Cols[r]; j++) { - c1 = Col[r][j]; - Uc[c1]--; - - for (k = 1; k <= Rows[c1]; k++) { - r1 = Row[c1][k]; - Ur[r1]--; - - if (Ur[r1] == 0) - for (l = 1; l <= Cols[r1]; l++) { - c2 = Col[r1][l]; - V[c2]++; - } - } - } - if (p > 0) { - j = N2; - k = N4; - x = (r - 1) / k + 1; - y = ((r - 1) % k) / j + 1; - s = (r - 1) % j + 1; - A[x - 1][y - 1] = 0; - } - if (i > clues) { - STATE = M3; - break; - } - - case NEXT_TRY: - time1 = System.currentTimeMillis(); - x1 = time1 - time0; - - time0 = time1; - - if (q > 0) { - xx = 128; - yy = 128 - q; - xx = xx / yy; - yy = solutions; - for (i = 1; i < 33; i++) - yy = yy * xx; - System.out.println("clues: " + clues + " estimated solutions:" + yy + " time " + x1 + "ms"); - - STATE = END; - break; - } - if ((p == 0 || p == 1) && tnodes <= 999999) { - if (solutions >= smax) - result = result.concat("More than " + solutions + " solutions ( bad sudoku!! ), rating " - + (100 * tnodes / solutions) + ", time " + x1 + " ms"); - else if (solutions == 1) - result = result.concat(solutions + " solution, rating " + (100 * tnodes) + ", time " + x1 - + " ms"); - else if (solutions == 0) - result = result.concat("0 solutions, no rating possible, time " + x1 + " ms"); - else - result = result.concat(solutions + " solutions ( bad sudoku!! ), rating " - + (100 * tnodes / solutions) + ", time " + x1 + " ms"); - - STATE = END; - break; - } - if (p == 6) { - System.out.println(solutions); - STATE = END; - break; - } - if (p == 0 || p == 1) { - System.out.println(solutions + " solution(s), rating " + (100 * tnodes) + ", time " + x1 + "ms"); - } - if (p > 5) { - x = 0; - for (i = 1; i <= N4; i++) { - x += Node[i]; - System.out.print(Node[i]); - if (i % 9 == 0) - System.out.println(); - } - System.out.println(x); - } - STATE = END; - break; - } // end of switch statement - } // end of while loop - return result; - } - - /** - * Helper function. - */ - int shuffle() { - for (i = 1; i <= m; i++) { - a = (int) ((MWC() >> 8) & Mc[N]); - while (a >= i) - a = (int) ((MWC() >> 8) & Mc[N]); - a++; - P[i] = P[a]; - P[a] = i; - } - - for (c = 1; c <= m; c++) { - Rows[c] = 0; - T[c] = Uc[c]; - } - - for (c = 1; c <= m; c++) - Uc[P[c]] = T[c]; - - for (r = 1; r <= n; r++) - for (i = 1; i <= Cols[r]; i++) { - c = P[Col[r][i]]; - Col[r][i] = c; - Rows[c]++; - Row[c][Rows[c]] = r; - } - - for (i = 1; i <= n; i++) { - a = (int) ((MWC() >> 8) & Mr[N]); - while (a >= i) - a = (int) ((MWC() >> 8) & Mr[N]); - a++; - P[i] = P[a]; - P[a] = i; - } - - for (r = 1; r <= n; r++) { - Cols[r] = 0; - T[r] = Ur[r]; - } - - for (r = 1; r <= n; r++) - Ur[P[r]] = T[r]; - - for (c = 1; c <= m; c++) - for (i = 1; i <= Rows[c]; i++) { - r = P[Row[c][i]]; - Row[c][i] = r; - Cols[r]++; - Col[r][Cols[r]] = c; - } - - for (r = 1; r <= n; r++) { - for (i = 1; i <= Cols[r]; i++) { - a = (int) ((MWC() >> 8) & 7); - while (a >= i) - a = (int) ((MWC() >> 8) & 7); - a++; - P[i] = P[a]; - P[a] = i; - } - - for (i = 1; i <= Cols[r]; i++) - T[i] = Col[r][P[i]]; - - for (i = 1; i <= Cols[r]; i++) - Col[r][i] = T[i]; - } - - for (c = 1; c <= m; c++) { - for (i = 1; i <= Rows[c]; i++) { - a = (int) ((MWC() >> 8) & Mw[N]); - while (a >= i) - a = (int) ((MWC() >> 8) & Mw[N]); - a++; - P[i] = P[a]; - P[a] = i; - } - - for (i = 1; i <= Rows[c]; i++) - T[i] = Row[c][P[i]]; - - for (i = 1; i <= Rows[c]; i++) - Row[c][i] = T[i]; - } - return 0; - } - - private final Random random; - - /** Creates a new instance of dlx_solver */ - public dlx_solver(Random random) { - this.random = random; - } -} - -/******************************************************************************* - * dlx_generator generate single solution locally minimized Sudoku puzzles. - * Locally minimized means that all keys that can be removed without creating a - * degenerate Sudoku (multiple solutions) are removed. - ******************************************************************************/ -class dlx_generator { - long MWC() { - return random.nextLong(); - } - - int Rows[] = new int[325], Cols[] = new int[730], Row[][] = new int[325][10], Col[][] = new int[730][5], - Ur[] = new int[730], Uc[] = new int[325], V[] = new int[325], W[] = new int[325]; - int P[] = new int[88], A[] = new int[88], C[] = new int[88], I[] = new int[88], Two[] = new int[888]; - char B[] = { '0', '1', '1', '1', '2', '2', '2', '3', '3', '3', '1', '1', '1', '2', '2', '2', '3', '3', '3', '1', - '1', '1', '2', '2', '2', '3', '3', '3', '4', '4', '4', '5', '5', '5', '6', '6', '6', '4', '4', '4', '5', - '5', '5', '6', '6', '6', '4', '4', '4', '5', '5', '5', '6', '6', '6', '7', '7', '7', '8', '8', '8', '9', - '9', '9', '7', '7', '7', '8', '8', '8', '9', '9', '9', '7', '7', '7', '8', '8', '8', '9', '9', '9' }; - char H[][] = new char[326][7]; - long c2, w; - int b, f, s1, m0, c1, r1, l, i1, m1, m2, a, p, i, j, k, r, c, d, n = 729, m = 324, x, y, s, z, fi; - int mi1, mi2, q7, part, nt, rate, nodes, solutions, min, samples, sam1, clues; - char L[] = { '.', '1', '2', '3', '4', '5', '6', '7', '8', '9' }; - - /** State machine states */ - static final int M0S = 10; - static final int M0 = 11; - static final int MR1 = 12; - static final int MR3 = 13; - static final int MR4 = 14; - static final int M2 = 15; - static final int M3 = 16; - static final int M4 = 17; - static final int M9 = 18; - static final int MR = 19; - static final int END = 20; - static final int M6 = 21; - - /** Set to true to generate debug output */ - boolean DBG = false; - - /** Output trace messages */ - void dbg(String s) { - if (DBG) - System.out.println(s); - } - - private final Random random; - - public dlx_generator(Random random) { - dbg("In constructor"); - this.random = random; - } - - /** - * Save the generated Sudoku to a file. - */ - void saveSudokuToFile(String s) { - FileOutputStream FO = null; - byte[] buffer = new byte[s.length() + 1]; - int i = 0; - - while (i < s.length()) { - buffer[i] = (byte) s.charAt(i); - i++; - } - - try { - FO = new FileOutputStream("generated_sudoku.sdk"); - FO.write(buffer); - FO.close(); - } catch (IOException IOE) { - // Well, well, well.... - return; - } - } - - /** - * Initialization code for both generate() and rate() - */ - void initialize() { - for (i = 0; i < 888; i++) { - j = 1; - while (j <= i) - j += j; - Two[i] = j - 1; - } - - r = 0; - for (x = 1; x <= 9; x++) - for (y = 1; y <= 9; y++) - for (s = 1; s <= 9; s++) { - r++; - Cols[r] = 4; - Col[r][1] = x * 9 - 9 + y; - Col[r][2] = (B[x * 9 - 9 + y] - 48) * 9 - 9 + s + 81; - Col[r][3] = x * 9 - 9 + s + 81 * 2; - Col[r][4] = y * 9 - 9 + s + 81 * 3; - } - - for (c = 1; c <= m; c++) - Rows[c] = 0; - - for (r = 1; r <= n; r++) - for (c = 1; c <= Cols[r]; c++) { - a = Col[r][c]; - Rows[a]++; - Row[a][Rows[a]] = r; - } - - c = 0; - for (x = 1; x <= 9; x++) - for (y = 1; y <= 9; y++) { - c++; - H[c][0] = 'r'; - H[c][1] = L[x]; - H[c][2] = 'c'; - H[c][3] = L[y]; - H[c][4] = 0; - } - - c = 81; - for (b = 1; b <= 9; b++) - for (s = 1; s <= 9; s++) { - c++; - H[c][0] = 'b'; - H[c][1] = L[b]; - H[c][2] = 's'; - H[c][3] = L[s]; - H[c][4] = 0; - } - - c = 81 * 2; - for (x = 1; x <= 9; x++) - for (s = 1; s <= 9; s++) { - c++; - H[c][0] = 'r'; - H[c][1] = L[x]; - H[c][2] = 's'; - H[c][3] = L[s]; - H[c][4] = 0; - } - - c = 81 * 3; - for (y = 1; y <= 9; y++) - for (s = 1; s <= 9; s++) { - c++; - H[c][0] = 'c'; - H[c][1] = L[y]; - H[c][2] = 's'; - H[c][3] = L[s]; - H[c][4] = 0; - } - } - - /* - * Rating function - */ - public long rate(String puzzle) { - int STATE = M6; - int Solutions; - - z = 100; - fi = 0; - rate = 1; - - for (i = 0; i < 88; i++) - A[i] = 0; - - initialize(); - - while (STATE != END) { - switch (STATE) { - case M6: - clues = 0; - for (i = 1; i <= 81; i++) { - c = puzzle.charAt(i - 1); - j = 0; - - if (c == '-' || c == '.' || c == '0' || c == '*') { - A[i] = j; - } else { - while (L[j] != c && j <= 9) - j++; - - if (j <= 9) { - A[i] = j; - } - } - } - - if (clues == 81) { - clues--; - A[1] = 0; - } - - nt = 0; - mi1 = 9999; - for (f = 0; f < z; f++) { - Solutions = solve(); - if (Solutions != 1) { - if (Solutions > 1) - nt = -1 * Solutions; - STATE = END; - break; - } - nt += nodes; - if (nodes < mi1) { - mi1 = nodes; - mi2 = C[clues]; - } - } - if (STATE == END) - break; - - if (fi > 0) - if ((nt / z) > fi) { - for (i = 1; i <= 81; i++) - System.out.println(L[A[i]]); - System.out.println(); - STATE = M6; - break; - } - - if (fi > 0) { - STATE = M6; - break; - } - - if ((z & 1) > 0) { - System.out.println(nt / z); - STATE = M6; - break; - } - - if (rate > 1) - System.out.println("hint: " + H[mi2]); - - STATE = END; - break; - } // End of switch statement - } // End of while loop - return (nt); - } - - public String[] generate(int Samples, int Rate) { - int STATE = M0S; - String result[] = new String[Samples]; - - dbg("Entering generate"); - - samples = 1000; - if (Samples > 0) - samples = Samples; - - for (i = 0; i < samples; i++) - result[i] = new String(); - - // Set to 1 for rating, set to 2 for rating and hint - rate = 0; - if (Rate > 0) - rate = Rate; - if (rate > 2) - rate = 2; - - initialize(); - - dbg("Entering state machine"); - - sam1 = -1; - while (STATE != END) { - switch (STATE) { - case M0S: - sam1++; - if (sam1 >= samples) { - STATE = END; - break; - } - - case M0: - for (i = 1; i <= 81; i++) - A[i] = 0; - part = 0; - q7 = 0; - - case MR1: - i1 = (int) ((MWC() >> 8) & 127); - if (i1 > 80) { - STATE = MR1; - break; - } - - i1++; - if (A[i1] > 0) { - STATE = MR1; - break; - } - - case MR3: - s = (int) ((MWC() >> 9) & 15); - if (s > 8) { - STATE = MR3; - break; - } - - s++; - A[i1] = s; - m2 = solve(); - q7++; - - if (m2 < 1) - A[i1] = 0; - - if (m2 != 1) { - STATE = MR1; - break; - } - - part++; - if (solve() != 1) { - STATE = M0; - break; - } - - case MR4: - for (i = 1; i <= 81; i++) { - x = (int) ((MWC() >> 8) & 127); - while (x >= i) { - x = (int) ((MWC() >> 8) & 127); - } - x++; - P[i] = P[x]; - P[x] = i; - } - - for (i1 = 1; i1 <= 81; i1++) { - s1 = A[P[i1]]; - A[P[i1]] = 0; - if (solve() > 1) - A[P[i1]] = s1; - } - - if (rate > 0) { - nt = 0; - mi1 = 9999; - for (f = 0; f < 100; f++) { - solve(); - nt += nodes; - if (nodes < mi1) { - mi1 = nodes; - mi2 = C[clues]; - } - } - result[sam1] = result[sam1].concat("Rating:" + nt + "# "); - if (rate > 1) { - result[sam1] = result[sam1].concat("hint: " + String.valueOf(H[mi2]).substring(0, 4) + " #\n"); - } else - result[sam1] = result[sam1].concat("\n"); - } - - for (i = 1; i <= 81; i++) { - result[sam1] = result[sam1].concat(String.valueOf(L[A[i]])); - if (i % 9 == 0) { - result[sam1] = result[sam1].concat("\n"); - } - } - result[sam1] = result[sam1].concat("\n"); - - default: - dbg("Default case. New state M0S"); - STATE = M0S; - break; - } // end of switch statement - } // end of while loop - return result; - } - - int solve() {// returns 0 (no solution), 1 (unique sol.), 2 (more than - // one sol.) - int STATE = M2; - - for (i = 0; i <= n; i++) - Ur[i] = 0; - for (i = 0; i <= m; i++) - Uc[i] = 0; - clues = 0; - - for (i = 1; i <= 81; i++) - if (A[i] > 0) { - clues++; - r = i * 9 - 9 + A[i]; - - for (j = 1; j <= Cols[r]; j++) { - d = Col[r][j]; - if (Uc[d] > 0) - return 0; - Uc[d]++; - - for (k = 1; k <= Rows[d]; k++) { - Ur[Row[d][k]]++; - } - } - } - - for (c = 1; c <= m; c++) { - V[c] = 0; - for (r = 1; r <= Rows[c]; r++) - if (Ur[Row[c][r]] == 0) - V[c]++; - } - - i = clues; - m0 = 0; - m1 = 0; - solutions = 0; - nodes = 0; - - dbg("Solve: Entering state machine"); - - while (STATE != END) { - switch (STATE) { - case M2: - i++; - I[i] = 0; - min = n + 1; - if ((i > 81) || (m0 > 0)) { - STATE = M4; - break; - } - - if (m1 > 0) { - C[i] = m1; - STATE = M3; - break; - } - - w = 0; - for (c = 1; c <= m; c++) - if (Uc[c] == 0) { - if (V[c] < 2) { - C[i] = c; - STATE = M3; - break; - } - - if (V[c] <= min) { - w++; - W[(int) w] = c; - } - ; - - if (V[c] < min) { - w = 1; - W[(int) w] = c; - min = V[c]; - } - } - - if (STATE == M3) { - // break in for loop detected, continue breaking - break; - } - - case MR: - c2 = (MWC() & Two[(int) w]); - while (c2 >= w) { - c2 = (MWC() & Two[(int) w]); - } - C[i] = W[(int) c2 + 1]; - - case M3: - c = C[i]; - I[i]++; - if (I[i] > Rows[c]) { - STATE = M4; - break; - } - - r = Row[c][I[i]]; - if (Ur[r] > 0) { - STATE = M3; - break; - } - m0 = 0; - m1 = 0; - nodes++; - for (j = 1; j <= Cols[r]; j++) { - c1 = Col[r][j]; - Uc[c1]++; - } - - for (j = 1; j <= Cols[r]; j++) { - c1 = Col[r][j]; - for (k = 1; k <= Rows[c1]; k++) { - r1 = Row[c1][k]; - Ur[r1]++; - if (Ur[r1] == 1) - for (l = 1; l <= Cols[r1]; l++) { - c2 = Col[r1][l]; - V[(int) c2]--; - if (Uc[(int) c2] + V[(int) c2] < 1) - m0 = (int) c2; - if (Uc[(int) c2] == 0 && V[(int) c2] < 2) - m1 = (int) c2; - } - } - } - - if (i == 81) - solutions++; - - if (solutions > 1) { - STATE = M9; - break; - } - STATE = M2; - break; - - case M4: - i--; - if (i == clues) { - STATE = M9; - break; - } - c = C[i]; - r = Row[c][I[i]]; - - for (j = 1; j <= Cols[r]; j++) { - c1 = Col[r][j]; - Uc[c1]--; - for (k = 1; k <= Rows[c1]; k++) { - r1 = Row[c1][k]; - Ur[r1]--; - if (Ur[r1] == 0) - for (l = 1; l <= Cols[r1]; l++) { - c2 = Col[r1][l]; - V[(int) c2]++; - } - } - } - - if (i > clues) { - STATE = M3; - break; - } - - case M9: - STATE = END; - break; - default: - STATE = END; - break; - } // end of switch statement - } // end of while statement - return solutions; - } -} - -/** - * - * @author Rolf Sandberg - */ - -public class DLXEngine { - dlx_generator generator; - dlx_solver solver; - - public DLXEngine(Random random) { - generator = new dlx_generator(random); - solver = new dlx_solver(random); - } - - String generate(int minrating, int maxrating) { - // Date t = new Date(); - // long start = t.getTime(); - // int tries = 0, i, samples = 5; - // long rating = 0; - String ss[] = generator.generate(1, 0); - return ss[0]; - - // Generator: - // First arg: rand seed - // Second arg: #samples, ignored if <= 0 - // Third arg: rating and hints, ignored if <= 0 - - // Task: Find a Sudoku with a rating in a specified interval. - // Do it by generating samples and examine them - // Continue until an appropriate puzzle is found. - // while(tries < 9999999) { - // tries++; - // t = new Date(); - // ss = generator.generate(samples, 0); - // for(i = 0; i < samples; i++) { - // rating = generator.rate(ss[i].replace("\n","").trim()); - // if(rating > minrating && rating < maxrating) { - // return ss[i]; - // } - // } - // System.out.println(minrating + ", " + maxrating + ", " + rating + ", - // looping"); - // } - // return ss[0]; - } - - long rate(String s) { - return generator.rate(s); - } - - String solve(String s) { - String result = solver.solve(s); - return result; - } -} diff --git a/src/net/sourceforge/plantuml/sudoku/GraphicsSudoku.java b/src/net/sourceforge/plantuml/sudoku/GraphicsSudoku.java deleted file mode 100644 index 8f921f4..0000000 --- a/src/net/sourceforge/plantuml/sudoku/GraphicsSudoku.java +++ /dev/null @@ -1,170 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.sudoku; - -import java.awt.Color; -import java.awt.Graphics2D; -import java.awt.image.BufferedImage; -import java.io.IOException; -import java.io.OutputStream; -import java.util.ArrayList; -import java.util.List; - -import net.sourceforge.plantuml.Dimension2DDouble; -import net.sourceforge.plantuml.EmptyImageBuilder; -import net.sourceforge.plantuml.FileFormat; -import net.sourceforge.plantuml.SpriteContainerEmpty; -import net.sourceforge.plantuml.TikzFontDistortion; -import net.sourceforge.plantuml.api.ImageDataSimple; -import net.sourceforge.plantuml.core.ImageData; -import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.eps.EpsStrategy; -import net.sourceforge.plantuml.graphic.FontConfiguration; -import net.sourceforge.plantuml.graphic.HorizontalAlignment; -import net.sourceforge.plantuml.graphic.HtmlColorUtils; -import net.sourceforge.plantuml.graphic.TextBlock; -import net.sourceforge.plantuml.png.PngIO; -import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity; -import net.sourceforge.plantuml.ugraphic.UChangeBackColor; -import net.sourceforge.plantuml.ugraphic.UChangeColor; -import net.sourceforge.plantuml.ugraphic.UFont; -import net.sourceforge.plantuml.ugraphic.UGraphic; -import net.sourceforge.plantuml.ugraphic.URectangle; -import net.sourceforge.plantuml.ugraphic.UTranslate; -import net.sourceforge.plantuml.ugraphic.eps.UGraphicEps; -import net.sourceforge.plantuml.ugraphic.g2d.UGraphicG2d; -import net.sourceforge.plantuml.ugraphic.svg.UGraphicSvg; -import net.sourceforge.plantuml.ugraphic.tikz.UGraphicTikz; - -public class GraphicsSudoku { - - private final ISudoku sudoku; - private final UFont numberFont = UFont.sansSerif(20).bold(); - private final UFont font = UFont.sansSerif(11); - - public GraphicsSudoku(ISudoku sudoku) { - this.sudoku = sudoku; - } - - public ImageData writeImageEps(OutputStream os) throws IOException { - final UGraphicEps ug = new UGraphicEps(new ColorMapperIdentity(), EpsStrategy.WITH_MACRO_AND_TEXT); - drawInternal(ug); - os.write(ug.getEPSCode().getBytes()); - return ImageDataSimple.ok(); - } - - public ImageData writeImageSvg(OutputStream os) throws IOException { - final UGraphicSvg ug = new UGraphicSvg(true, new Dimension2DDouble(0, 0), new ColorMapperIdentity(), - (String) null, false, 1.0, null, null, 0); - drawInternal(ug); - ug.createXml(os, null); - return ImageDataSimple.ok(); - } - - public ImageData writeImageLatex(OutputStream os, FileFormat fileFormat) throws IOException { - final UGraphicTikz ug = new UGraphicTikz(new ColorMapperIdentity(), 1, fileFormat == FileFormat.LATEX, - TikzFontDistortion.getDefault()); - drawInternal(ug); - ug.createTikz(os); - return ImageDataSimple.ok(); - } - - public ImageData writeImagePng(OutputStream os) throws IOException { - final EmptyImageBuilder builder = new EmptyImageBuilder(sudoWidth, sudoHeight + textTotalHeight, Color.WHITE); - final BufferedImage im = builder.getBufferedImage(); - final Graphics2D g3d = builder.getGraphics2D(); - - final UGraphic ug = new UGraphicG2d(new ColorMapperIdentity(), g3d, 1.0); - - drawInternal(ug); - g3d.dispose(); - PngIO.write(im, os, 96); - return new ImageDataSimple(im.getWidth(), im.getHeight()); - } - - final private int xOffset = 5; - final private int yOffset = 5; - - final private int cellWidth = 30; - final private int cellHeight = 32; - - final private int numberxOffset = 10; - final private int numberyOffset = 5; - - final private int textTotalHeight = 50; - - final private int boldWidth = 3; - final private int sudoHeight = 9 * cellHeight + 2 * yOffset + boldWidth; - final private int sudoWidth = 9 * cellWidth + 2 * xOffset + boldWidth; - - private void drawInternal(UGraphic ug) { - ug = ug.apply(new UTranslate(xOffset, yOffset)); - - for (int x = 0; x < 9; x++) { - for (int y = 0; y < 9; y++) { - final int num = sudoku.getGiven(x, y); - if (num > 0) { - final TextBlock text = Display.create("" + num).create(FontConfiguration.blackBlueTrue(numberFont), - HorizontalAlignment.CENTER, new SpriteContainerEmpty()); - text.drawU(ug.apply(new UTranslate((numberxOffset + x * cellWidth), - (numberyOffset + y * cellHeight)))); - } - } - } - - ug = ug.apply(new UChangeBackColor(HtmlColorUtils.BLACK)).apply(new UChangeColor(null)); - for (int i = 0; i < 10; i++) { - final boolean bold = i % boldWidth == 0; - final int w = bold ? boldWidth : 1; - ug.apply(new UTranslate(0, i * cellHeight)).draw(new URectangle(9 * cellWidth + boldWidth, w)); - } - for (int i = 0; i < 10; i++) { - final boolean bold = i % boldWidth == 0; - final int w = bold ? boldWidth : 1; - ug.apply(new UTranslate(i * cellWidth, 0)).draw(new URectangle(w, 9 * cellHeight + boldWidth)); - } - - ug = ug.apply(new UTranslate(0, sudoHeight)); - final List<String> texts = new ArrayList<String>(); - texts.add("http://plantuml.com"); - texts.add("Seed " + Long.toString(sudoku.getSeed(), 36)); - texts.add("Difficulty " + sudoku.getRatting()); - final TextBlock textBlock = Display.create(texts).create(FontConfiguration.blackBlueTrue(font), - HorizontalAlignment.LEFT, new SpriteContainerEmpty()); - textBlock.drawU(ug); - } - -} diff --git a/src/net/sourceforge/plantuml/sudoku/ISudoku.java b/src/net/sourceforge/plantuml/sudoku/ISudoku.java deleted file mode 100644 index 1db78ae..0000000 --- a/src/net/sourceforge/plantuml/sudoku/ISudoku.java +++ /dev/null @@ -1,46 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.sudoku; - -public interface ISudoku { - - int getGiven(int x, int y); - - long getRatting(); - - long getSeed(); - -}
\ No newline at end of file diff --git a/src/net/sourceforge/plantuml/sudoku/PSystemSudoku.java b/src/net/sourceforge/plantuml/sudoku/PSystemSudoku.java deleted file mode 100644 index f207faa..0000000 --- a/src/net/sourceforge/plantuml/sudoku/PSystemSudoku.java +++ /dev/null @@ -1,76 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.sudoku; - -import java.io.IOException; -import java.io.OutputStream; - -import net.sourceforge.plantuml.AbstractPSystem; -import net.sourceforge.plantuml.FileFormat; -import net.sourceforge.plantuml.FileFormatOption; -import net.sourceforge.plantuml.core.DiagramDescription; -import net.sourceforge.plantuml.core.ImageData; - -public class PSystemSudoku extends AbstractPSystem { - - final private ISudoku sudoku; - - @Override - final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed) - throws IOException { - final GraphicsSudoku sud = new GraphicsSudoku(sudoku); - if (fileFormat.getFileFormat() == FileFormat.EPS) { - return sud.writeImageEps(os); - } - if (fileFormat.getFileFormat() == FileFormat.SVG) { - return sud.writeImageSvg(os); - } - if (fileFormat.getFileFormat() == FileFormat.LATEX - || fileFormat.getFileFormat() == FileFormat.LATEX_NO_PREAMBLE) { - return sud.writeImageLatex(os, fileFormat.getFileFormat()); - } - return sud.writeImagePng(os); - } - - public DiagramDescription getDescription() { - return new DiagramDescription("(Sudoku)"); - } - - public PSystemSudoku(Long seed) { - sudoku = new SudokuDLX(seed); - } - -} diff --git a/src/net/sourceforge/plantuml/sudoku/PSystemSudokuFactory.java b/src/net/sourceforge/plantuml/sudoku/PSystemSudokuFactory.java deleted file mode 100644 index 57362d3..0000000 --- a/src/net/sourceforge/plantuml/sudoku/PSystemSudokuFactory.java +++ /dev/null @@ -1,62 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.sudoku; - -import net.sourceforge.plantuml.AbstractPSystem; -import net.sourceforge.plantuml.StringUtils; -import net.sourceforge.plantuml.command.PSystemSingleLineFactory; -import net.sourceforge.plantuml.command.regex.Matcher2; -import net.sourceforge.plantuml.command.regex.MyPattern; -import net.sourceforge.plantuml.command.regex.Pattern2; - -public class PSystemSudokuFactory extends PSystemSingleLineFactory { - - final private static Pattern2 p = MyPattern.cmpile("(?i)^sudoku(?:[%s]+([0-9a-zA-Z]+))?[%s]*$"); - - @Override - protected AbstractPSystem executeLine(String line) { - final Matcher2 m = p.matcher(line); - if (m.find() == false) { - return null; - } - - if (m.group(1) == null) { - return new PSystemSudoku(null); - } - return new PSystemSudoku(Long.parseLong(StringUtils.goLowerCase(m.group(1)), 36)); - } - -} diff --git a/src/net/sourceforge/plantuml/sudoku/SudokuDLX.java b/src/net/sourceforge/plantuml/sudoku/SudokuDLX.java deleted file mode 100644 index b9b498b..0000000 --- a/src/net/sourceforge/plantuml/sudoku/SudokuDLX.java +++ /dev/null @@ -1,92 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.sudoku; - -import java.util.Random; - -import net.sourceforge.plantuml.Log; -import net.sourceforge.plantuml.StringUtils; - -public class SudokuDLX implements ISudoku { - - private final String tab[]; - private final long seed; - private final long rate; - - public SudokuDLX(Long seed) { - if (seed == null) { - this.seed = Math.abs(new Random().nextLong()); - } else { - this.seed = Math.abs(seed.longValue()); - } - final DLXEngine engine = new DLXEngine(new Random(this.seed)); - final String s = engine.generate(10000, 100000); - rate = engine.rate(s.replace("\n", "").trim()); - tab = s.split("\\s"); - } - - public long getRatting() { - return rate; - } - - public long getSeed() { - return seed; - } - - public int getGiven(int x, int y) { - final char c = tab[x].charAt(y); - if (c == '.') { - return 0; - } - return c - '0'; - } - - public void print() { - for (String s : tab) { - Log.println(s); - } - Log.println("Rate=" + rate); - Log.println("Seed=" + StringUtils.goUpperCase(Long.toString(seed, 36))); - } - - public static void main(String[] args) { - for (int i = 0; i < 1; i++) { - final SudokuDLX sudoku = new SudokuDLX(null); - sudoku.print(); - } - } - -} diff --git a/src/net/sourceforge/plantuml/svek/ArithmeticStrategyMax.java b/src/net/sourceforge/plantuml/svek/ArithmeticStrategyMax.java deleted file mode 100644 index f1cc9e5..0000000 --- a/src/net/sourceforge/plantuml/svek/ArithmeticStrategyMax.java +++ /dev/null @@ -1,52 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.svek; - -public class ArithmeticStrategyMax implements ArithmeticStrategy { - - private double max; - - public void eat(double v) { - if (v > max) { - max = v; - } - } - - public double getResult() { - return max; - } - -}
\ No newline at end of file diff --git a/src/net/sourceforge/plantuml/svek/Line.java b/src/net/sourceforge/plantuml/svek/Line.java index ba4fed8..3d4573b 100644 --- a/src/net/sourceforge/plantuml/svek/Line.java +++ b/src/net/sourceforge/plantuml/svek/Line.java @@ -841,26 +841,6 @@ public class Line implements Moveable, Hideable { } - private void avoid(Point2D.Double move, Positionable pos, Shape sh) { - final Oscillator oscillator = new Oscillator(); - final Point2D.Double orig = new Point2D.Double(move.x, move.y); - while (cut(pos, sh)) { - final Point2D.Double m = oscillator.nextPosition(); - move.setLocation(orig.x + m.x, orig.y + m.y); - } - } - - private boolean cut(Positionable pos, Shape sh) { - return BezierUtils.intersect(pos, sh) || tooClose(pos); - } - - private boolean tooClose(Positionable pos) { - final double dist = dotPath.getMinDist(BezierUtils.getCenter(pos)); - final Dimension2D dim = pos.getSize(); - // Log.println("dist=" + dist); - return dist < (dim.getWidth() / 2 + 2) || dist < (dim.getHeight() / 2 + 2); - } - public void moveSvek(double deltaX, double deltaY) { this.dx += deltaX; this.dy += deltaY; diff --git a/src/net/sourceforge/plantuml/svek/Oscillator.java b/src/net/sourceforge/plantuml/svek/Oscillator.java deleted file mode 100644 index 9ef4348..0000000 --- a/src/net/sourceforge/plantuml/svek/Oscillator.java +++ /dev/null @@ -1,89 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.svek; - -import java.awt.geom.Point2D; - -public class Oscillator { - - private int n = 3; - private int i = 0; - private char seg = 'A'; - - private int x = -1; - private int y = -1; - - public Point2D.Double nextPosition() { - assert n % 2 == 1; - final int halfN = (n - 1) / 2; - final Point2D.Double result = new Point2D.Double(x, y); - i++; - if (seg == 'A') { - x++; - if (x > halfN) { - seg = 'B'; - x = halfN; - y = -halfN + 1; - } - } else if (seg == 'B') { - y++; - if (y > halfN) { - seg = 'C'; - x = halfN - 1; - y = halfN; - } - } else if (seg == 'C') { - x--; - if (x < -halfN) { - seg = 'D'; - x = -halfN; - y = halfN - 1; - } - } else if (seg == 'D') { - y--; - if (y == -halfN) { - n += 2; - i = 0; - x = -((n - 1) / 2); - y = x; - seg = 'A'; - } - } else { - throw new UnsupportedOperationException(); - } - return result; - } -} diff --git a/src/net/sourceforge/plantuml/swing/MainWindow2.java b/src/net/sourceforge/plantuml/swing/MainWindow2.java index ad1628b..bcf1fb6 100644 --- a/src/net/sourceforge/plantuml/swing/MainWindow2.java +++ b/src/net/sourceforge/plantuml/swing/MainWindow2.java @@ -79,7 +79,7 @@ import javax.swing.SwingUtilities; import javax.swing.Timer; import javax.swing.border.CompoundBorder; -import net.sourceforge.plantuml.DirWatcher2; +import net.sourceforge.plantuml.DirWatcher; import net.sourceforge.plantuml.GeneratedImage; import net.sourceforge.plantuml.Log; import net.sourceforge.plantuml.Option; @@ -101,7 +101,7 @@ public class MainWindow2 extends JFrame { final private Set<ImageWindow2> openWindows2 = new HashSet<ImageWindow2>(); final private Option option; - private DirWatcher2 dirWatcher; + private DirWatcher dirWatcher; private String getExtensions() { return prefs.get(KEY_PATTERN, getDefaultFileExtensions()); @@ -160,7 +160,7 @@ public class MainWindow2 extends JFrame { final File dir = getDirectory(arg); setIconImage(PSystemVersion.getPlantumlSmallIcon2()); this.option = option; - dirWatcher = new DirWatcher2(dir, option, getRegexpPattern(getExtensions())); + dirWatcher = new DirWatcher(dir, option, getRegexpPattern(getExtensions())); Log.info("Showing MainWindow"); scrollPane = new JScrollPane(jList1); @@ -306,7 +306,7 @@ public class MainWindow2 extends JFrame { private void changeDir(File dir) { prefs.put(KEY_DIR, dir.getAbsolutePath()); dirWatcher.cancel(); - dirWatcher = new DirWatcher2(dir, option, getRegexpPattern(getExtensions())); + dirWatcher = new DirWatcher(dir, option, getRegexpPattern(getExtensions())); setTitle(dir.getAbsolutePath()); Log.info("Creating DirWatcher"); currentDirectoryListing2.clear(); diff --git a/src/net/sourceforge/plantuml/telnet/AcceptTelnetClient.java b/src/net/sourceforge/plantuml/telnet/AcceptTelnetClient.java deleted file mode 100644 index 22f0f5e..0000000 --- a/src/net/sourceforge/plantuml/telnet/AcceptTelnetClient.java +++ /dev/null @@ -1,92 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.telnet; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.net.Socket; - -import net.sourceforge.plantuml.FileFormat; -import net.sourceforge.plantuml.FileFormatOption; -import net.sourceforge.plantuml.Log; -import net.sourceforge.plantuml.SourceStringReader; - -class AcceptTelnetClient extends Thread { - final private Socket clientSocket; - final private BufferedReader br; - final private OutputStream os; - - AcceptTelnetClient(Socket socket) throws Exception { - clientSocket = socket; - System.out.println("Client Connected ..."); - br = new BufferedReader(new InputStreamReader(clientSocket.getInputStream())); - os = clientSocket.getOutputStream(); - - start(); - } - - public String runInternal() throws IOException { - final StringBuilder sb = new StringBuilder(); - while (true) { - final String s = br.readLine(); - if (s == null) { - return sb.toString(); - } - Log.println("S=" + s); - sb.append(s); - sb.append('\n'); - if (s.equalsIgnoreCase("@enduml")) { - return sb.toString(); - } - } - } - - public void run() { - try { - final String uml = runInternal(); - Log.println("UML=" + uml); - final SourceStringReader s = new SourceStringReader(uml); - s.outputImage(os, new FileFormatOption(FileFormat.ATXT)); - os.close(); - br.close(); - } catch (IOException e) { - e.printStackTrace(); - } - - } -}
\ No newline at end of file diff --git a/src/net/sourceforge/plantuml/telnet/TelnetServer.java b/src/net/sourceforge/plantuml/telnet/TelnetServer.java deleted file mode 100644 index 91f77b3..0000000 --- a/src/net/sourceforge/plantuml/telnet/TelnetServer.java +++ /dev/null @@ -1,50 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.telnet; - -import java.net.ServerSocket; -import java.net.Socket; - -public class TelnetServer { - public static void main(String args[]) throws Exception { - final ServerSocket server = new ServerSocket(4242); - while (true) { - final Socket socket = server.accept(); - new AcceptTelnetClient(socket); - } - } - -} diff --git a/src/net/sourceforge/plantuml/ugraphic/InflaterSet.java b/src/net/sourceforge/plantuml/ugraphic/InflaterSet.java deleted file mode 100644 index cd455d5..0000000 --- a/src/net/sourceforge/plantuml/ugraphic/InflaterSet.java +++ /dev/null @@ -1,69 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.ugraphic; - -import java.util.ArrayList; -import java.util.List; - -public class InflaterSet { - - static class Inflater { - private final double start; - private final double size; - - private Inflater(double start, double size) { - this.start = start; - this.size = size; - } - } - - private final List<Inflater> all = new ArrayList<Inflater>(); - - public void addInflater(double start, double size) { - all.add(new Inflater(start, size)); - } - - public double inflate(double v) { - double result = v; - for (Inflater in : all) { - if (v > in.start) { - result += in.size; - } - } - return result; - } - -} diff --git a/src/net/sourceforge/plantuml/ugraphic/sprite/SpriteGrayLevel.java b/src/net/sourceforge/plantuml/ugraphic/sprite/SpriteGrayLevel.java index 2d1951c..80c311c 100644 --- a/src/net/sourceforge/plantuml/ugraphic/sprite/SpriteGrayLevel.java +++ b/src/net/sourceforge/plantuml/ugraphic/sprite/SpriteGrayLevel.java @@ -47,8 +47,6 @@ import net.sourceforge.plantuml.code.AsciiEncoder; import net.sourceforge.plantuml.code.AsciiEncoderFinalZeros; import net.sourceforge.plantuml.code.CompressionZlib; import net.sourceforge.plantuml.code.CompressionZopfliZlib; -import net.sourceforge.plantuml.code.PairInt; -import net.sourceforge.plantuml.code.SpiralOnRectangle; import net.sourceforge.plantuml.ugraphic.ColorChangerMonochrome; public enum SpriteGrayLevel { @@ -255,22 +253,6 @@ public enum SpriteGrayLevel { return cut(new AsciiEncoderFinalZeros().encode(comp)); } - private List<String> encodeZSpiral(BufferedImage img) { - final int width = img.getWidth(); - final int height = img.getHeight(); - final byte raw[] = new byte[width * height]; - final int coef = 16 / nbColor; - final SpiralOnRectangle spiral = new SpiralOnRectangle(width, height); - for (int cpt = 0; cpt < width * height; cpt++) { - final PairInt pt = spiral.nextPoint(); - final int color = getGrayOn16(img, pt.getX(), pt.getY()) / coef; - raw[cpt] = (byte) color; - } - // final byte[] comp = new CompressionZlib().compress(raw); - final byte[] comp = new CompressionZopfliZlib().compress(raw); - return cut(new AsciiEncoderFinalZeros().encode(comp)); - } - private List<String> cut(String s) { final List<String> result = new ArrayList<String>(); for (int i = 0; i < s.length(); i += 120) { diff --git a/src/net/sourceforge/plantuml/ugraphic/svg/DriverNoneSvg.java b/src/net/sourceforge/plantuml/ugraphic/svg/DriverNoneSvg.java deleted file mode 100644 index 0afc848..0000000 --- a/src/net/sourceforge/plantuml/ugraphic/svg/DriverNoneSvg.java +++ /dev/null @@ -1,48 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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.ugraphic.svg; - -import net.sourceforge.plantuml.svg.SvgGraphics; -import net.sourceforge.plantuml.ugraphic.ColorMapper; -import net.sourceforge.plantuml.ugraphic.UDriver; -import net.sourceforge.plantuml.ugraphic.UParam; -import net.sourceforge.plantuml.ugraphic.UShape; - -public class DriverNoneSvg implements UDriver<SvgGraphics> { - - public void draw(UShape shape, double x, double y, ColorMapper mapper, UParam param, SvgGraphics object) { - } - -} |