org.stathissideris.ascii2image.text.GridPatternGroup Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of plantuml-epl Show documentation
Show all versions of plantuml-epl Show documentation
PlantUML is a component that allows to quickly write diagrams from text.
// THIS FILE HAS BEEN GENERATED BY A PREPROCESSOR.
/* +=======================================================================
* |
* | PlantUML : a free UML diagram generator
* |
* +=======================================================================
*
* (C) Copyright 2009-2024, Arnaud Roques
*
* Project Info: https://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* https://plantuml.com/patreon (only 1$ per month!)
* https://plantuml.com/liberapay (only 1€ per month!)
* https://plantuml.com/paypal
*
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the Eclipse Public License.
*
* THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC
* LICENSE ("AGREEMENT"). [Eclipse Public License - v 1.0]
*
* ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES
* RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
*
* You may obtain a copy of the License at
*
* http://www.eclipse.org/legal/epl-v10.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* PlantUML can occasionally display sponsored or advertising messages. Those
* messages are usually generated on welcome or error images and never on
* functional diagrams.
* See https://plantuml.com/professional if you want to remove them
*
* Images (whatever their format : PNG, SVG, EPS...) generated by running PlantUML
* are owned by the author of their corresponding sources code (that is, their
* textual description in PlantUML language). Those images are not covered by
* this EPL license.
*
* The generated images can then be used without any reference to the EPL license.
* It is not even necessary to stipulate that they have been generated with PlantUML,
* although this will be appreciated by the PlantUML team.
*
* There is an exception : if the textual description in PlantUML language is also covered
* by any license, then the generated images are logically covered
* by the very same license.
*
* This is the IGY distribution (Install GraphViz by Yourself).
* You have to install GraphViz and to setup the GRAPHVIZ_DOT environment variable
* (see https://plantuml.com/graphviz-dot )
*
* Icons provided by OpenIconic : https://useiconic.com/open
* Archimate sprites provided by Archi : http://www.archimatetool.com
* Stdlib AWS provided by https://github.com/milo-minderbinder/AWS-PlantUML
* Stdlib Icons provided https://github.com/tupadr3/plantuml-icon-font-sprites
* ASCIIMathML (c) Peter Jipsen http://www.chapman.edu/~jipsen
* ASCIIMathML (c) David Lippman http://www.pierce.ctc.edu/dlippman
* CafeUndZopfli ported by Eugene Klyuchnikov https://github.com/eustas/CafeUndZopfli
* Brotli (c) by the Brotli Authors https://github.com/google/brotli
* Themes (c) by Brett Schwarz https://github.com/bschwarz/puml-themes
* Twemoji (c) by Twitter at https://twemoji.twitter.com/
*
*/
package org.stathissideris.ascii2image.text;
import java.util.ArrayList;
import java.util.Iterator;
/**
*
* @author Efstathios Sideris
*/
public class GridPatternGroup extends ArrayList {
public boolean areAllMatchedBy(TextGrid grid){
Iterator it = iterator();
while (it.hasNext()) {
GridPattern pattern = it.next();
if(!pattern.isMatchedBy(grid)) return false;
}
return true;
}
public boolean isAnyMatchedBy(TextGrid grid){
Iterator it = iterator();
while (it.hasNext()) {
GridPattern pattern = it.next();
if(pattern.isMatchedBy(grid)) return true;
}
return false;
}
public void add(GridPattern... patterns) {
for(GridPattern p : patterns) add(p);
}
//TODO: define criteria for on-line type?
public static final GridPatternGroup cornerCriteria = new GridPatternGroup();
public static final GridPatternGroup normalCornerCriteria = new GridPatternGroup();
public static final GridPatternGroup roundCornerCriteria = new GridPatternGroup();
public static final GridPatternGroup corner1Criteria = new GridPatternGroup();
public static final GridPatternGroup corner2Criteria = new GridPatternGroup();
public static final GridPatternGroup corner3Criteria = new GridPatternGroup();
public static final GridPatternGroup corner4Criteria = new GridPatternGroup();
public static final GridPatternGroup normalCorner1Criteria = new GridPatternGroup();
public static final GridPatternGroup normalCorner2Criteria = new GridPatternGroup();
public static final GridPatternGroup normalCorner3Criteria = new GridPatternGroup();
public static final GridPatternGroup normalCorner4Criteria = new GridPatternGroup();
public static final GridPatternGroup roundCorner1Criteria = new GridPatternGroup();
public static final GridPatternGroup roundCorner2Criteria = new GridPatternGroup();
public static final GridPatternGroup roundCorner3Criteria = new GridPatternGroup();
public static final GridPatternGroup roundCorner4Criteria = new GridPatternGroup();
public static final GridPatternGroup intersectionCriteria = new GridPatternGroup();
public static final GridPatternGroup TCriteria = new GridPatternGroup();
public static final GridPatternGroup inverseTCriteria = new GridPatternGroup();
public static final GridPatternGroup KCriteria = new GridPatternGroup();
public static final GridPatternGroup inverseKCriteria = new GridPatternGroup();
public static final GridPatternGroup crossCriteria = new GridPatternGroup();
public static final GridPatternGroup stubCriteria = new GridPatternGroup();
public static final GridPatternGroup verticalLinesEndCriteria = new GridPatternGroup();
public static final GridPatternGroup horizontalLinesEndCriteria = new GridPatternGroup();
public static final GridPatternGroup linesEndCriteria = new GridPatternGroup();
public static final GridPatternGroup crossOnLineCriteria = new GridPatternGroup();
public static final GridPatternGroup horizontalCrossOnLineCriteria = new GridPatternGroup();
public static final GridPatternGroup verticalCrossOnLineCriteria = new GridPatternGroup();
public static final GridPatternGroup starOnLineCriteria = new GridPatternGroup();
public static final GridPatternGroup horizontalStarOnLineCriteria = new GridPatternGroup();
public static final GridPatternGroup verticalStarOnLineCriteria = new GridPatternGroup();
public static final GridPatternGroup loneDiagonalCriteria = new GridPatternGroup();
static {
GridPattern crossPattern1 = new GridPattern(
".6.",
"4+8",
".2."
);
crossCriteria.add(crossPattern1);
GridPattern KPattern1 = new GridPattern(
".6.",
"%4+8",
".2."
);
KCriteria.add(KPattern1);
GridPattern inverseKPattern1 = new GridPattern(
".6.",
"4+%8",
".2."
);
inverseKCriteria.add(inverseKPattern1);
GridPattern TPattern1 = new GridPattern(
".%6.",
"4+8",
".2."
);
TCriteria.add(TPattern1);
GridPattern inverseTPattern1 = new GridPattern(
".6.",
"4+8",
".%2."
);
inverseTCriteria.add(inverseTPattern1);
// ****** normal corners *******
GridPattern normalCorner1Pattern1 = new GridPattern(
".[.",
"~+(",
".^."
);
normalCorner1Criteria.add(normalCorner1Pattern1);
GridPattern normalCorner2Pattern1 = new GridPattern(
".[.",
"(+~",
".^."
);
normalCorner2Criteria.add(normalCorner2Pattern1);
GridPattern normalCorner3Pattern1 = new GridPattern(
".^.",
"(+~",
".[."
);
normalCorner3Criteria.add(normalCorner3Pattern1);
GridPattern normalCorner4Pattern1 = new GridPattern(
".^.",
"~+(",
".[."
);
normalCorner4Criteria.add(normalCorner4Pattern1);
// ******* round corners *******
GridPattern roundCorner1Pattern1 = new GridPattern(
".[.",
"~/4",
".2."
);
roundCorner1Criteria.add(roundCorner1Pattern1);
GridPattern roundCorner2Pattern1 = new GridPattern(
".[.",
"4\\~",
".2."
);
roundCorner2Criteria.add(roundCorner2Pattern1);
GridPattern roundCorner3Pattern1 = new GridPattern(
".6.",
"4/~",
".[."
);
roundCorner3Criteria.add(roundCorner3Pattern1);
GridPattern roundCorner4Pattern1 = new GridPattern(
".6.",
"~\\8",
".[."
);
roundCorner4Criteria.add(roundCorner4Pattern1);
//stubs
GridPattern stubPattern1 = new GridPattern(
"!^!",
"!+!",
".!."
);
stubCriteria.add(stubPattern1);
GridPattern stubPattern2 = new GridPattern(
"!^!",
"!+!",
".-."
);
stubCriteria.add(stubPattern2);
GridPattern stubPattern3 = new GridPattern(
"!!.",
"(+!",
"!!."
);
stubCriteria.add(stubPattern3);
GridPattern stubPattern4 = new GridPattern(
"!!.",
"(+|",
"!!."
);
stubCriteria.add(stubPattern4);
GridPattern stubPattern5 = new GridPattern(
".!.",
"!+!",
"!^!"
);
stubCriteria.add(stubPattern5);
GridPattern stubPattern6 = new GridPattern(
".-.",
"!+!",
"!^!"
);
stubCriteria.add(stubPattern6);
GridPattern stubPattern7 = new GridPattern(
".!!",
"!+(",
".!!"
);
stubCriteria.add(stubPattern7);
GridPattern stubPattern8 = new GridPattern(
".!!",
"|+(",
".!!"
);
stubCriteria.add(stubPattern8);
// ****** ends of lines ******
GridPattern verticalLinesEndPattern1 = new GridPattern(
".^.",
".|.",
".!."
);
verticalLinesEndCriteria.add(verticalLinesEndPattern1);
GridPattern verticalLinesEndPattern2 = new GridPattern(
".^.",
".|.",
".-."
);
verticalLinesEndCriteria.add(verticalLinesEndPattern2);
GridPattern horizontalLinesEndPattern3 = new GridPattern(
"...",
"(-!",
"..."
);
horizontalLinesEndCriteria.add(horizontalLinesEndPattern3);
GridPattern horizontalLinesEndPattern4 = new GridPattern(
"...",
"(-|",
"..."
);
horizontalLinesEndCriteria.add(horizontalLinesEndPattern4);
GridPattern verticalLinesEndPattern5 = new GridPattern(
".!.",
".|.",
".^."
);
verticalLinesEndCriteria.add(verticalLinesEndPattern5);
GridPattern verticalLinesEndPattern6 = new GridPattern(
".-.",
".|.",
".^."
);
verticalLinesEndCriteria.add(verticalLinesEndPattern6);
GridPattern horizontalLinesEndPattern7 = new GridPattern(
"...",
"!-(",
"..."
);
horizontalLinesEndCriteria.add(horizontalLinesEndPattern7);
GridPattern horizontalLinesEndPattern8 = new GridPattern(
"...",
"|-(",
"..."
);
horizontalLinesEndCriteria.add(horizontalLinesEndPattern8);
// ****** others *******
GridPattern horizontalCrossOnLinePattern1 = new GridPattern(
"...",
"(+(",
"..."
);
horizontalCrossOnLineCriteria.add(horizontalCrossOnLinePattern1);
GridPattern verticalCrossOnLinePattern1 = new GridPattern(
".^.",
".+.",
".^."
);
verticalCrossOnLineCriteria.add(verticalCrossOnLinePattern1);
GridPattern horizontalStarOnLinePattern1 = new GridPattern(
"...",
"(*(",
"..."
);
horizontalStarOnLineCriteria.add(horizontalStarOnLinePattern1);
GridPattern horizontalStarOnLinePattern2 = new GridPattern(
"...",
"!*(",
"..."
);
horizontalStarOnLineCriteria.add(horizontalStarOnLinePattern2);
GridPattern horizontalStarOnLinePattern3 = new GridPattern(
"...",
"(*!",
"..."
);
horizontalStarOnLineCriteria.add(horizontalStarOnLinePattern3);
GridPattern verticalStarOnLinePattern1 = new GridPattern(
".^.",
".*.",
".^."
);
verticalStarOnLineCriteria.add(verticalStarOnLinePattern1);
GridPattern verticalStarOnLinePattern2 = new GridPattern(
".!.",
".*.",
".^."
);
verticalStarOnLineCriteria.add(verticalStarOnLinePattern2);
GridPattern verticalStarOnLinePattern3 = new GridPattern(
".^.",
".*.",
".!."
);
verticalStarOnLineCriteria.add(verticalStarOnLinePattern3);
GridPattern loneDiagonalPattern1 = new GridPattern(
".%6%7",
"%4/%8",
"%3%2."
);
loneDiagonalCriteria.add(loneDiagonalPattern1);
GridPattern loneDiagonalPattern2 = new GridPattern(
"%1%6.",
"%4\\%8",
".%2%5"
);
loneDiagonalCriteria.add(loneDiagonalPattern2);
//groups
intersectionCriteria.addAll(crossCriteria);
intersectionCriteria.addAll(KCriteria);
intersectionCriteria.addAll(TCriteria);
intersectionCriteria.addAll(inverseKCriteria);
intersectionCriteria.addAll(inverseTCriteria);
normalCornerCriteria.addAll(normalCorner1Criteria);
normalCornerCriteria.addAll(normalCorner2Criteria);
normalCornerCriteria.addAll(normalCorner3Criteria);
normalCornerCriteria.addAll(normalCorner4Criteria);
roundCornerCriteria.addAll(roundCorner1Criteria);
roundCornerCriteria.addAll(roundCorner2Criteria);
roundCornerCriteria.addAll(roundCorner3Criteria);
roundCornerCriteria.addAll(roundCorner4Criteria);
corner1Criteria.addAll(normalCorner1Criteria);
corner1Criteria.addAll(roundCorner1Criteria);
corner2Criteria.addAll(normalCorner2Criteria);
corner2Criteria.addAll(roundCorner2Criteria);
corner3Criteria.addAll(normalCorner3Criteria);
corner3Criteria.addAll(roundCorner3Criteria);
corner4Criteria.addAll(normalCorner4Criteria);
corner4Criteria.addAll(roundCorner4Criteria);
cornerCriteria.addAll(normalCornerCriteria);
cornerCriteria.addAll(roundCornerCriteria);
crossOnLineCriteria.addAll(horizontalCrossOnLineCriteria);
crossOnLineCriteria.addAll(verticalCrossOnLineCriteria);
starOnLineCriteria.addAll(horizontalStarOnLineCriteria);
starOnLineCriteria.addAll(verticalStarOnLineCriteria);
linesEndCriteria.addAll(horizontalLinesEndCriteria);
linesEndCriteria.addAll(verticalLinesEndCriteria);
linesEndCriteria.addAll(stubCriteria);
}
}