1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-06-13 13:42:26 +00:00

Fix style issues and DisplayPositionned typo

This commit is contained in:
Arnaud Roques 2021-11-19 17:03:39 +01:00
parent 48a736e300
commit bbeb280022
10 changed files with 130 additions and 40 deletions

View File

@ -50,6 +50,7 @@ import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.core.UmlSource;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.DisplayPositioned;
import net.sourceforge.plantuml.cucadiagram.DisplayPositionned;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.VerticalAlignment;
import net.sourceforge.plantuml.stats.StatsUtilsIncrement;
@ -128,7 +129,7 @@ public abstract class AbstractPSystem implements Diagram {
this.splitPagesVertical = splitPagesVertical;
}
public DisplayPositioned getTitle() {
public DisplayPositionned getTitle() {
if (source == null) {
return DisplayPositioned.single(Display.empty(), HorizontalAlignment.CENTER, VerticalAlignment.TOP);
}

View File

@ -37,11 +37,12 @@ package net.sourceforge.plantuml;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.DisplayPositioned;
import net.sourceforge.plantuml.cucadiagram.DisplayPositionned;
import net.sourceforge.plantuml.cucadiagram.DisplaySection;
public interface Annotated {
public DisplayPositioned getTitle();
public DisplayPositionned getTitle();
public DisplayPositioned getCaption();

View File

@ -179,7 +179,7 @@ public class AnnotatedWorker {
}
private TextBlock addTitle(TextBlock original) {
final DisplayPositioned title = annotated.getTitle();
final DisplayPositioned title = (DisplayPositioned) annotated.getTitle();
if (title.isNull()) {
return original;
}

View File

@ -44,6 +44,7 @@ import net.sourceforge.plantuml.core.Diagram;
import net.sourceforge.plantuml.core.UmlSource;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.DisplayPositioned;
import net.sourceforge.plantuml.cucadiagram.DisplayPositionned;
import net.sourceforge.plantuml.cucadiagram.DisplaySection;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.VerticalAlignment;
@ -172,7 +173,7 @@ public abstract class TitledDiagram extends AbstractPSystem implements Diagram,
}
@Override
final public DisplayPositioned getTitle() {
final public DisplayPositionned getTitle() {
return title;
}

View File

@ -37,14 +37,18 @@ package net.sourceforge.plantuml.cucadiagram;
/**
*
* There is a type in this class name.
* There is a typo in this class name.
*
* You should use directly DisplayPositioned and not this interface which is here for legacy code
* You should use directly DisplayPositioned and not this interface which is here for legacy code.
* This file will be removed, so use DisplayPositioned instead.
*
*/
@Deprecated
public interface DisplayPositionned {
public Display getDisplay();
public boolean isNull();
}

View File

@ -101,7 +101,7 @@ public abstract class AbstractTaskDraw implements TaskDraw {
abstract StyleSignature getStyleSignature();
private StyleSignature getStyleSignatureUnstarted() {
return StyleSignature.of(SName.root, SName.element, SName.ganttDiagram, SName.unstartedTask);
return StyleSignature.of(SName.root, SName.element, SName.ganttDiagram, SName.task, SName.unstarted);
}
final protected HColor getLineColor() {

View File

@ -0,0 +1,99 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.style;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
class Context {
private final List<String> data = new ArrayList<String>();
public Context push(String newString) {
final Context result = new Context();
result.data.addAll(this.data);
result.data.add(newString);
return result;
}
public Context pop() {
if (size() == 0)
throw new IllegalStateException();
final Context result = new Context();
result.data.addAll(this.data.subList(0, this.data.size() - 1));
return result;
}
@Override
public String toString() {
return data.toString();
}
public int size() {
return data.size();
}
public Collection<StyleSignature> toSignatures() {
List<StyleSignature> results = new ArrayList<>(Collections.singletonList(StyleSignature.empty()));
boolean star = false;
for (Iterator<String> it = data.iterator(); it.hasNext();) {
String s = it.next();
if (s.endsWith("*")) {
star = true;
s = s.substring(0, s.length() - 1);
}
final String[] names = s.split(",");
final List<StyleSignature> tmp = new ArrayList<>();
for (StyleSignature ss : results)
for (String name : names)
tmp.add(ss.add(name));
results = tmp;
}
if (star)
for (ListIterator<StyleSignature> it = results.listIterator(); it.hasNext();) {
final StyleSignature tmp = it.next().addStar();
it.set(tmp);
}
return Collections.unmodifiableCollection(results);
}
}

View File

@ -118,7 +118,7 @@ public enum SName {
timeline, //
timingDiagram, //
title, //
unstartedTask, //
unstarted, //
usecase, //
wbsDiagram, //
yamlDiagram; //

View File

@ -41,7 +41,6 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.EnumMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@ -105,8 +104,8 @@ public class StyleLoader {
}
}
private static final String NAME_USER = "[\\w()]+?";
private final static Pattern2 userName = MyPattern.cmpile("^[.:]?(" + NAME_USER + ")([%s]+\\*)?[%s]*\\{$");
private final static String KEYNAMES = "[\\w(), ]+?";
private final static Pattern2 keyName = MyPattern.cmpile("^[.:]?(" + KEYNAMES + ")([%s]+\\*)?[%s]*\\{$");
private final static Pattern2 propertyAndValue = MyPattern.cmpile("^([\\w]+):?[%s]+(.*?);?$");
private final static Pattern2 closeBracket = MyPattern.cmpile("^\\}$");
@ -114,7 +113,7 @@ public class StyleLoader {
lines = lines.eventuallyMoveAllEmptyBracket();
final List<Style> result = new ArrayList<>();
final List<String> context = new ArrayList<>();
Context context = new Context();
final List<Map<PName, Value>> maps = new ArrayList<Map<PName, Value>>();
boolean inComment = false;
for (StringLocated s : lines) {
@ -134,14 +133,14 @@ public class StyleLoader {
if (x != -1) {
trimmed = trimmed.substring(0, x).trim();
}
final Matcher2 mUserName = userName.matcher(trimmed);
if (mUserName.find()) {
String n = mUserName.group(1);
final boolean isRecurse = mUserName.group(2) != null;
final Matcher2 mKeyNames = keyName.matcher(trimmed);
if (mKeyNames.find()) {
String names = mKeyNames.group(1).replace(" ", "");
final boolean isRecurse = mKeyNames.group(2) != null;
if (isRecurse) {
n += "*";
names += "*";
}
context.add(n);
context = context.push(names);
maps.add(new EnumMap<PName, Value>(PName.class));
continue;
}
@ -157,10 +156,12 @@ public class StyleLoader {
final Matcher2 mCloseBracket = closeBracket.matcher(trimmed);
if (mCloseBracket.find()) {
if (context.size() > 0) {
final StyleSignature signature = contextToSignature(context);
final Style style = new Style(signature, maps.get(maps.size() - 1));
result.add(style);
context.remove(context.size() - 1);
final Collection<StyleSignature> signatures = context.toSignatures();
for (StyleSignature signature : signatures) {
final Style style = new Style(signature, maps.get(maps.size() - 1));
result.add(style);
}
context = context.pop();
maps.remove(maps.size() - 1);
}
}
@ -170,21 +171,4 @@ public class StyleLoader {
}
private static StyleSignature contextToSignature(List<String> context) {
StyleSignature result = StyleSignature.empty();
boolean star = false;
for (Iterator<String> it = context.iterator(); it.hasNext();) {
String s = it.next();
if (s.endsWith("*")) {
star = true;
s = s.substring(0, s.length() - 1);
}
result = result.add(s);
}
if (star) {
result = result.addStar();
}
return result;
}
}

View File

@ -80,7 +80,7 @@ public class Version {
}
public static int beta() {
final int beta = 5;
final int beta = 6;
return beta;
}