Skip to content

Commit 7cd5ac9

Browse files
committed
Add source copy of https://github.com/nidi3/graphviz-java to reduce dependencies (some create serious problems within Eclipse)
1 parent afe0a3b commit 7cd5ac9

File tree

88 files changed

+7174
-34
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+7174
-34
lines changed

build.gradle

Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,11 @@ repositories {
3333
}
3434

3535
dependencies {
36-
implementation "guru.nidi:graphviz-java:${graphvizVersion}"
3736
implementation "org.apache.commons:commons-lang3:${commonsLangVersion}"
37+
implementation "guru.nidi.com.kitfox:svgSalamander:1.1.2"
38+
implementation "org.apache.commons:commons-exec:1.3"
39+
implementation "com.google.code.findbugs:jsr305:3.0.2"
40+
implementation "org.slf4j:slf4j-api:1.7.26"
3841

3942
testImplementation "org.junit.jupiter:junit-jupiter-api:${jUnitVersion}"
4043
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${jUnitVersion}"
@@ -166,36 +169,14 @@ platform {
166169
instruction 'Bundle-Vendor', 'Context Mapper'
167170
version = version
168171
}
169-
}
170-
171-
bundle(group: 'guru.nidi', name: 'graphviz-java', version: graphvizVersion) {
172-
bnd {
173-
instruction 'Import-Package', "!org.graalvm.polyglot,*"
174-
}
175-
}
176-
177-
bundle(group: 'com.eclipsesource.j2v8', name: 'j2v8_linux_x86_64', version: '4.6.0') {
178-
bnd {
179-
}
180-
}
181-
182-
bundle(group: 'com.eclipsesource.j2v8', name: 'j2v8_macosx_x86_64', version: '4.6.0') {
183-
bnd {
184-
}
185-
}
186-
187-
bundle(group: 'com.eclipsesource.j2v8', name: 'j2v8_win32_x86', version: '4.6.0') {
188-
bnd {
189-
}
190-
}
191-
192-
bundle(group: 'com.eclipsesource.j2v8', name: 'j2v8_win32_x86_64', version: '4.6.0') {
193-
bnd {
194-
}
172+
exclude module: 'slf4j-api'
173+
exclude module: 'jcl-over-slf4j'
174+
exclude module: 'jul-to-slf4j'
175+
exclude module: 'commons-logging'
195176
}
196177

197178
featureId 'org.contextmapper.contextmap.generator.feature'
198-
featureName 'ContextMappers Context Map Generator'
179+
featureName 'Context Map Generator'
199180
featureVersion project.version.toString().endsWith('SNAPSHOT') ? project.version.toString().replace("SNAPSHOT", "") + new SimpleDateFormat("YYYYMMddHHmmss").format(new Date()) : project.version.toString()
200181
featureProvider 'Context Mapper'
201182

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Copyright © 2015 Stefan Niederhauser (nidin@gmx.ch)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package guru.nidi.graphviz;
17+
18+
import javax.annotation.Nonnull;
19+
import javax.annotation.meta.TypeQualifierDefault;
20+
import java.lang.annotation.*;
21+
22+
@Documented
23+
@Nonnull
24+
@TypeQualifierDefault({ElementType.PARAMETER, ElementType.METHOD, ElementType.FIELD})
25+
@Retention(RetentionPolicy.CLASS)
26+
@Target(ElementType.PACKAGE)
27+
public @interface NonnullApi {
28+
}
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
/*
2+
* Copyright © 2015 Stefan Niederhauser (nidin@gmx.ch)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package guru.nidi.graphviz.attribute;
17+
18+
import javax.annotation.Nullable;
19+
20+
import static guru.nidi.graphviz.attribute.Attributes.attr;
21+
import static guru.nidi.graphviz.attribute.Attributes.attrs;
22+
import static java.util.Locale.ENGLISH;
23+
24+
public final class Arrow extends SingleAttributes<String, ForLink> {
25+
public enum DirType {
26+
FORWARD, BACK, BOTH, NONE
27+
}
28+
29+
public static final Arrow
30+
BOX = new Arrow("box"),
31+
CROW = new Arrow("crow"),
32+
CURVE = new Arrow("curve"),
33+
DIAMOND = new Arrow("diamond"),
34+
DOT = new Arrow("dot"),
35+
ICURVE = new Arrow("icurve"),
36+
INV = new Arrow("inv"),
37+
NONE = new Arrow("none"),
38+
NORMAL = new Arrow("normal"),
39+
TEE = new Arrow("tee"),
40+
VEE = new Arrow("vee");
41+
42+
private Arrow(String key, String value) {
43+
super(key, value);
44+
}
45+
46+
private Arrow(String value) {
47+
super("arrowhead", value);
48+
}
49+
50+
public Arrow tail() {
51+
return key("arrowtail");
52+
}
53+
54+
public Arrow open() {
55+
return value(value.charAt(0) == 'o' ? value : ("o" + value));
56+
}
57+
58+
public Arrow left() {
59+
return arrowDir("l");
60+
}
61+
62+
public Arrow right() {
63+
return arrowDir("r");
64+
}
65+
66+
public Arrow and(Arrow arrow) {
67+
return value(arrow.value + value);
68+
}
69+
70+
public Attributes<ForLink> size(double size) {
71+
return config(size, null);
72+
}
73+
74+
public Attributes<ForLink> dir(DirType type) {
75+
return config(0, type);
76+
}
77+
78+
public Attributes<ForLink> config(double size, @Nullable DirType type) {
79+
Attributes<ForLink> a = this;
80+
if (size > 0) {
81+
a = attrs(a, attr("arrowsize", size));
82+
}
83+
if (type != null) {
84+
a = attrs(a, attr("dir", type.name().toLowerCase(ENGLISH)));
85+
}
86+
return a;
87+
}
88+
89+
private Arrow arrowDir(String dir) {
90+
switch (value.charAt(0)) {
91+
case 'l':
92+
case 'r':
93+
return value(dir + value.substring(1));
94+
case 'o':
95+
final char s = value.charAt(1);
96+
return value("o" + dir + (s == 'r' || s == 'l' ? value.substring(2) : value.substring(1)));
97+
default:
98+
return value(dir + value);
99+
}
100+
}
101+
}
102+
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* Copyright © 2015 Stefan Niederhauser (nidin@gmx.ch)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package guru.nidi.graphviz.attribute;
17+
18+
import javax.annotation.Nullable;
19+
import java.util.List;
20+
21+
import static guru.nidi.graphviz.attribute.Attributes.attr;
22+
import static guru.nidi.graphviz.attribute.Attributes.attrs;
23+
24+
public interface Attributed<T, F extends For> extends Attributes<F> {
25+
default T with(String name, @Nullable Object value) {
26+
return with(attr(name, value));
27+
}
28+
29+
default T with(Attributes<? extends F> attr1, Attributes<? extends F> attr2) {
30+
return with(attrs(attr1, attr2));
31+
}
32+
33+
default T with(Attributes<? extends F> attr1, Attributes<? extends F> attr2, Attributes<? extends F> attr3) {
34+
return with(attrs(attr1, attr2, attr3));
35+
}
36+
37+
default T with(Attributes<? extends F> attr1, Attributes<? extends F> attr2,
38+
Attributes<? extends F> attr3, Attributes<? extends F> attr4) {
39+
return with(attrs(attr1, attr2, attr3, attr4));
40+
}
41+
42+
//cannot use @SafeVarargs here, that's why we have the specializations for 2..4 attrs
43+
default T with(Attributes<? extends F>... attributes) {
44+
return with(attrs(attributes));
45+
}
46+
47+
default T with(List<Attributes<? extends F>> attributes) {
48+
return with(attrs(attributes));
49+
}
50+
51+
T with(Attributes<? extends F> attribute);
52+
}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/*
2+
* Copyright © 2015 Stefan Niederhauser (nidin@gmx.ch)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package guru.nidi.graphviz.attribute;
17+
18+
import javax.annotation.Nullable;
19+
import java.util.Iterator;
20+
import java.util.List;
21+
import java.util.Map.Entry;
22+
23+
import static java.util.Arrays.asList;
24+
25+
public interface Attributes<F extends For> extends Iterable<Entry<String, Object>> {
26+
Attributes<? super F> applyTo(MapAttributes<? super F> attrs);
27+
28+
default Attributes<? super F> applyTo(Attributes<? super F> attrs) {
29+
if (!(attrs instanceof MapAttributes)) {
30+
throw new UnsupportedOperationException("attributes must be a MapAttributes");
31+
}
32+
@SuppressWarnings("unchecked") final MapAttributes<? super F> as = (MapAttributes<? super F>) attrs;
33+
return applyTo(as);
34+
}
35+
36+
default Attributes<F> copy() {
37+
@SuppressWarnings("unchecked") final Attributes<F> copy = (Attributes<F>) applyTo(attrs());
38+
return copy;
39+
}
40+
41+
static <F extends For> Attributes<F> attr(String key, @Nullable Object value) {
42+
return new MapAttributes<F>().add(key, value);
43+
}
44+
45+
static <F extends For> Attributes<F> attrs() {
46+
return new MapAttributes<>();
47+
}
48+
49+
@SafeVarargs
50+
static <F extends For> Attributes<F> attrs(Attributes<? extends F>... attributes) {
51+
return attrs(asList(attributes));
52+
}
53+
54+
static <F extends For> Attributes<F> attrs(List<Attributes<? extends F>> attributes) {
55+
final MapAttributes<F> res = new MapAttributes<>();
56+
for (Attributes<? extends F> attribute : attributes) {
57+
attribute.applyTo(res);
58+
}
59+
return res;
60+
}
61+
62+
@Nullable
63+
default Object get(String key) {
64+
return applyTo(new MapAttributes<>()).get(key);
65+
}
66+
67+
@Override
68+
default Iterator<Entry<String, Object>> iterator() {
69+
return applyTo(new MapAttributes<>()).iterator();
70+
}
71+
72+
default boolean isEmpty() {
73+
return applyTo(new MapAttributes<>()).isEmpty();
74+
}
75+
}

0 commit comments

Comments
 (0)