mirror of
https://github.com/octoleo/plantuml.git
synced 2024-11-16 02:07:08 +00:00
Fix style issues and DisplayPositionned typo
This commit is contained in:
parent
48a736e300
commit
bbeb280022
@ -50,6 +50,7 @@ import net.sourceforge.plantuml.core.ImageData;
|
|||||||
import net.sourceforge.plantuml.core.UmlSource;
|
import net.sourceforge.plantuml.core.UmlSource;
|
||||||
import net.sourceforge.plantuml.cucadiagram.Display;
|
import net.sourceforge.plantuml.cucadiagram.Display;
|
||||||
import net.sourceforge.plantuml.cucadiagram.DisplayPositioned;
|
import net.sourceforge.plantuml.cucadiagram.DisplayPositioned;
|
||||||
|
import net.sourceforge.plantuml.cucadiagram.DisplayPositionned;
|
||||||
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
|
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
|
||||||
import net.sourceforge.plantuml.graphic.VerticalAlignment;
|
import net.sourceforge.plantuml.graphic.VerticalAlignment;
|
||||||
import net.sourceforge.plantuml.stats.StatsUtilsIncrement;
|
import net.sourceforge.plantuml.stats.StatsUtilsIncrement;
|
||||||
@ -128,7 +129,7 @@ public abstract class AbstractPSystem implements Diagram {
|
|||||||
this.splitPagesVertical = splitPagesVertical;
|
this.splitPagesVertical = splitPagesVertical;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DisplayPositioned getTitle() {
|
public DisplayPositionned getTitle() {
|
||||||
if (source == null) {
|
if (source == null) {
|
||||||
return DisplayPositioned.single(Display.empty(), HorizontalAlignment.CENTER, VerticalAlignment.TOP);
|
return DisplayPositioned.single(Display.empty(), HorizontalAlignment.CENTER, VerticalAlignment.TOP);
|
||||||
}
|
}
|
||||||
|
@ -37,11 +37,12 @@ package net.sourceforge.plantuml;
|
|||||||
|
|
||||||
import net.sourceforge.plantuml.cucadiagram.Display;
|
import net.sourceforge.plantuml.cucadiagram.Display;
|
||||||
import net.sourceforge.plantuml.cucadiagram.DisplayPositioned;
|
import net.sourceforge.plantuml.cucadiagram.DisplayPositioned;
|
||||||
|
import net.sourceforge.plantuml.cucadiagram.DisplayPositionned;
|
||||||
import net.sourceforge.plantuml.cucadiagram.DisplaySection;
|
import net.sourceforge.plantuml.cucadiagram.DisplaySection;
|
||||||
|
|
||||||
public interface Annotated {
|
public interface Annotated {
|
||||||
|
|
||||||
public DisplayPositioned getTitle();
|
public DisplayPositionned getTitle();
|
||||||
|
|
||||||
public DisplayPositioned getCaption();
|
public DisplayPositioned getCaption();
|
||||||
|
|
||||||
|
@ -179,7 +179,7 @@ public class AnnotatedWorker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private TextBlock addTitle(TextBlock original) {
|
private TextBlock addTitle(TextBlock original) {
|
||||||
final DisplayPositioned title = annotated.getTitle();
|
final DisplayPositioned title = (DisplayPositioned) annotated.getTitle();
|
||||||
if (title.isNull()) {
|
if (title.isNull()) {
|
||||||
return original;
|
return original;
|
||||||
}
|
}
|
||||||
|
@ -44,6 +44,7 @@ import net.sourceforge.plantuml.core.Diagram;
|
|||||||
import net.sourceforge.plantuml.core.UmlSource;
|
import net.sourceforge.plantuml.core.UmlSource;
|
||||||
import net.sourceforge.plantuml.cucadiagram.Display;
|
import net.sourceforge.plantuml.cucadiagram.Display;
|
||||||
import net.sourceforge.plantuml.cucadiagram.DisplayPositioned;
|
import net.sourceforge.plantuml.cucadiagram.DisplayPositioned;
|
||||||
|
import net.sourceforge.plantuml.cucadiagram.DisplayPositionned;
|
||||||
import net.sourceforge.plantuml.cucadiagram.DisplaySection;
|
import net.sourceforge.plantuml.cucadiagram.DisplaySection;
|
||||||
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
|
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
|
||||||
import net.sourceforge.plantuml.graphic.VerticalAlignment;
|
import net.sourceforge.plantuml.graphic.VerticalAlignment;
|
||||||
@ -172,7 +173,7 @@ public abstract class TitledDiagram extends AbstractPSystem implements Diagram,
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
final public DisplayPositioned getTitle() {
|
final public DisplayPositionned getTitle() {
|
||||||
return title;
|
return title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,9 +37,10 @@ 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
|
@Deprecated
|
||||||
@ -47,4 +48,7 @@ public interface DisplayPositionned {
|
|||||||
|
|
||||||
public Display getDisplay();
|
public Display getDisplay();
|
||||||
|
|
||||||
|
public boolean isNull();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -101,7 +101,7 @@ public abstract class AbstractTaskDraw implements TaskDraw {
|
|||||||
abstract StyleSignature getStyleSignature();
|
abstract StyleSignature getStyleSignature();
|
||||||
|
|
||||||
private StyleSignature getStyleSignatureUnstarted() {
|
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() {
|
final protected HColor getLineColor() {
|
||||||
|
99
src/net/sourceforge/plantuml/style/Context.java
Normal file
99
src/net/sourceforge/plantuml/style/Context.java
Normal 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -118,7 +118,7 @@ public enum SName {
|
|||||||
timeline, //
|
timeline, //
|
||||||
timingDiagram, //
|
timingDiagram, //
|
||||||
title, //
|
title, //
|
||||||
unstartedTask, //
|
unstarted, //
|
||||||
usecase, //
|
usecase, //
|
||||||
wbsDiagram, //
|
wbsDiagram, //
|
||||||
yamlDiagram; //
|
yamlDiagram; //
|
||||||
|
@ -41,7 +41,6 @@ import java.util.ArrayList;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.EnumMap;
|
import java.util.EnumMap;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -105,8 +104,8 @@ public class StyleLoader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String NAME_USER = "[\\w()]+?";
|
private final static String KEYNAMES = "[\\w(), ]+?";
|
||||||
private final static Pattern2 userName = MyPattern.cmpile("^[.:]?(" + NAME_USER + ")([%s]+\\*)?[%s]*\\{$");
|
private final static Pattern2 keyName = MyPattern.cmpile("^[.:]?(" + KEYNAMES + ")([%s]+\\*)?[%s]*\\{$");
|
||||||
private final static Pattern2 propertyAndValue = MyPattern.cmpile("^([\\w]+):?[%s]+(.*?);?$");
|
private final static Pattern2 propertyAndValue = MyPattern.cmpile("^([\\w]+):?[%s]+(.*?);?$");
|
||||||
private final static Pattern2 closeBracket = MyPattern.cmpile("^\\}$");
|
private final static Pattern2 closeBracket = MyPattern.cmpile("^\\}$");
|
||||||
|
|
||||||
@ -114,7 +113,7 @@ public class StyleLoader {
|
|||||||
lines = lines.eventuallyMoveAllEmptyBracket();
|
lines = lines.eventuallyMoveAllEmptyBracket();
|
||||||
final List<Style> result = new ArrayList<>();
|
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>>();
|
final List<Map<PName, Value>> maps = new ArrayList<Map<PName, Value>>();
|
||||||
boolean inComment = false;
|
boolean inComment = false;
|
||||||
for (StringLocated s : lines) {
|
for (StringLocated s : lines) {
|
||||||
@ -134,14 +133,14 @@ public class StyleLoader {
|
|||||||
if (x != -1) {
|
if (x != -1) {
|
||||||
trimmed = trimmed.substring(0, x).trim();
|
trimmed = trimmed.substring(0, x).trim();
|
||||||
}
|
}
|
||||||
final Matcher2 mUserName = userName.matcher(trimmed);
|
final Matcher2 mKeyNames = keyName.matcher(trimmed);
|
||||||
if (mUserName.find()) {
|
if (mKeyNames.find()) {
|
||||||
String n = mUserName.group(1);
|
String names = mKeyNames.group(1).replace(" ", "");
|
||||||
final boolean isRecurse = mUserName.group(2) != null;
|
final boolean isRecurse = mKeyNames.group(2) != null;
|
||||||
if (isRecurse) {
|
if (isRecurse) {
|
||||||
n += "*";
|
names += "*";
|
||||||
}
|
}
|
||||||
context.add(n);
|
context = context.push(names);
|
||||||
maps.add(new EnumMap<PName, Value>(PName.class));
|
maps.add(new EnumMap<PName, Value>(PName.class));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -157,10 +156,12 @@ public class StyleLoader {
|
|||||||
final Matcher2 mCloseBracket = closeBracket.matcher(trimmed);
|
final Matcher2 mCloseBracket = closeBracket.matcher(trimmed);
|
||||||
if (mCloseBracket.find()) {
|
if (mCloseBracket.find()) {
|
||||||
if (context.size() > 0) {
|
if (context.size() > 0) {
|
||||||
final StyleSignature signature = contextToSignature(context);
|
final Collection<StyleSignature> signatures = context.toSignatures();
|
||||||
|
for (StyleSignature signature : signatures) {
|
||||||
final Style style = new Style(signature, maps.get(maps.size() - 1));
|
final Style style = new Style(signature, maps.get(maps.size() - 1));
|
||||||
result.add(style);
|
result.add(style);
|
||||||
context.remove(context.size() - 1);
|
}
|
||||||
|
context = context.pop();
|
||||||
maps.remove(maps.size() - 1);
|
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
@ -80,7 +80,7 @@ public class Version {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static int beta() {
|
public static int beta() {
|
||||||
final int beta = 5;
|
final int beta = 6;
|
||||||
return beta;
|
return beta;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user