Skip to content

Commit 397376d

Browse files
committed
initial version (basic functionality already working)
1 parent c16f874 commit 397376d

18 files changed

+1510
-0
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/build/
2+
/.gradle/
3+
/.idea/
4+
/.nb-gradle/
5+
JCSG-PathExtensions.iml

build.gradle

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
plugins {
2+
id 'com.github.hierynomus.license' version '0.13.1'
3+
id 'maven-publish'
4+
id 'net.nemerosa.versioning' version '2.4.0'
5+
id 'com.jfrog.bintray' version '1.7.2'
6+
id 'com.github.ben-manes.versions' version '0.13.0'
7+
}
8+
9+
apply plugin: 'java'
10+
apply from: 'gradle/publishing.gradle'
11+
12+
13+
task wrapper(type: Wrapper) {
14+
gradleVersion = '4.0'
15+
distributionUrl = "https://services.gradle.org/distributions/gradle-$gradleVersion-all.zip"
16+
}
17+
18+
apply plugin: 'java'
19+
20+
sourceCompatibility = 1.8
21+
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
22+
23+
tasks.withType(Javadoc) {
24+
options.addStringOption('Xdoclint:none', '-quiet')
25+
}
26+
27+
repositories {
28+
mavenCentral()
29+
jcenter()
30+
}
31+
32+
dependencies {
33+
testCompile group: 'junit', name: 'junit', version: '4.11'
34+
35+
// vvecmath library
36+
compile group: 'eu.mihosoft.vvecmath', name: 'vvecmath', version: '0.3.8'
37+
compile group: 'eu.mihosoft.vvecmath', name: 'vvecmath', version: '0.3.8', classifier: 'sources'
38+
39+
// jcsg library
40+
compile group: 'eu.mihosoft.vrl.jcsg', name: 'jcsg', version: '0.5.5'
41+
compile group: 'eu.mihosoft.vrl.jcsg', name: 'jcsg', version: '0.5.5', classifier: 'sources'
42+
compile group: 'eu.mihosoft.vrl.jcsg', name: 'jcsg', version: '0.5.5', classifier: 'javadoc'
43+
44+
}
45+
46+
47+
license {
48+
header = rootProject.file('config/HEADER')
49+
strictCheck = true
50+
ignoreFailures = true
51+
mapping {
52+
java = 'SLASHSTAR_STYLE'
53+
groovy = 'SLASHSTAR_STYLE'
54+
fxml = 'XML_STYLE'
55+
}
56+
ext.year = '2017'
57+
ext.author = 'Michael Hoffer <[email protected]>'
58+
exclude '**/*.svg'
59+
exclude '**/eu/mihosoft/jcsg/ext/path/internal/*.java'
60+
}
61+

config/HEADER

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Copyright ${year} ${author}
2+
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.
14+
15+
If you use this software for scientific research then please cite the following publication(s):
16+
17+
M. Hoffer, C. Poliwoda, & G. Wittum. (2013). Visual reflection library:
18+
a framework for declarative GUI programming on the Java platform.
19+
Computing and Visualization in Science, 2013, 16(4),
20+
181–192. http://doi.org/10.1007/s00791-014-0230-y
21+

gradle/project-info.gradle

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// -----------------------------------------------------------------------------
2+
// publishing information
3+
// -----------------------------------------------------------------------------
4+
ext.publishing.artifactId = project.name.toLowerCase()
5+
ext.publishing.groupId = 'eu.mihosoft.jcsg.ext.path'
6+
ext.publishing.versionId = '0.1'
7+
8+
ext.publishing.developerName = 'Michael Hoffer'
9+
ext.publishing.developerAlias = 'miho'
10+
ext.publishing.developerEmail = '[email protected]'
11+
ext.publishing.inceptionYear = '2017'
12+
13+
ext.publishing.bintray.repo = 'JCSG'
14+
ext.publishing.bintray.userOrg = 'miho'
15+
ext.publishing.bintray.name = project.name
16+
17+
ext.publishing.desc = 'JCSG-PathExtensions'
18+
ext.publishing.license = 'BSD 2-Clause'
19+
ext.publishing.licenseUrl = 'https://github.com/miho/VVecMath/blob/master/LICENSE'
20+
ext.publishing.labels = ['vecmath', 'jcsg', 'vrl', 'svg', 'paths']
21+
ext.publishing.websiteUrl = 'https://github.com/miho/JCSG-PathExtensions'
22+
ext.publishing.issueTrackerUrl = 'https://github.com/miho/JCSG-PathExtensions/issues'
23+
ext.publishing.vcsUrl = 'https://github.com/miho/JCSG-PathExtensions.git'
24+
25+
ext.publishing.pomName = ext.publishing.artifactId

gradle/publishing.gradle

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
// -----------------------------------------------------------------------------
2+
// Collect publishing information
3+
// -----------------------------------------------------------------------------
4+
ext.publishing = [:]
5+
ext.publishing.bintray = [:]
6+
7+
ext.publishing.pomName = ext.publishing.artifactId
8+
9+
apply from: "gradle/project-info.gradle"
10+
11+
// -----------------------------------------------------------------------------
12+
// Performs publishing
13+
// -----------------------------------------------------------------------------
14+
15+
task javadocJar(type: Jar, dependsOn: javadoc) {
16+
classifier = 'javadoc'
17+
from javadoc.destinationDir
18+
}
19+
20+
// create one jar for the source files
21+
task sourcesJar(type: Jar, dependsOn: classes) {
22+
classifier = 'sources'
23+
from sourceSets.main.allSource
24+
}
25+
26+
artifacts {
27+
archives jar
28+
archives javadocJar
29+
archives sourcesJar
30+
}
31+
Date buildTimeAndDate = new Date()
32+
ext {
33+
buildDate = new java.text.SimpleDateFormat('yyyy-MM-dd').format(buildTimeAndDate)
34+
buildTime = new java.text.SimpleDateFormat('HH:mm:ss.SSSZ').format(buildTimeAndDate)
35+
}
36+
37+
jar {
38+
manifest {
39+
attributes(
40+
'Built-By': System.properties['user.name'],
41+
'Created-By': System.properties['java.version'] + " (" + System.properties['java.vendor'] + " " + System.properties['java.vm.version'] + ")",
42+
'Build-Date': project.buildDate,
43+
'Build-Time': project.buildTime,
44+
'Build-Revision': versioning.info.commit,
45+
'Specification-Title': project.name,
46+
'Specification-Version': project.version,
47+
'Implementation-Title': project.name,
48+
'Implementation-Version': project.version
49+
)
50+
}
51+
}
52+
53+
54+
def pomConfig = {
55+
name ext.publishing.pomName
56+
description ext.publishing.desc
57+
url ext.publishing.websiteUrl
58+
inceptionYear ext.publishing.inceptionYear
59+
licenses {
60+
license([:]) {
61+
name ext.publishing.license
62+
url ext.publishing.licenseUrl
63+
distribution 'repo'
64+
}
65+
}
66+
scm {
67+
url ext.publishing.vcsUrl
68+
connection ext.publishing.vcsUrl
69+
developerConnection ext.publishing.vcsUrl
70+
}
71+
developers {
72+
developer {
73+
id ext.publishing.developerNameAlias
74+
name ext.publishing.developerName
75+
}
76+
}
77+
}
78+
79+
publishing {
80+
publications {
81+
mavenCustom(MavenPublication) {
82+
groupId publishing.groupId
83+
artifactId publishing.artifactId
84+
version publishing.versionId
85+
from components.java
86+
artifact sourcesJar
87+
artifact javadocJar
88+
89+
pom.withXml {
90+
def root = asNode()
91+
root.appendNode 'description', publishing.desc
92+
root.children().last() + pomConfig
93+
}
94+
}
95+
}
96+
}
97+
98+
if (!project.hasProperty('bintrayUsername')) ext.bintrayUsername = ''
99+
if (!project.hasProperty('bintrayApiKey')) ext.bintrayApiKey = ''
100+
101+
bintray {
102+
user = project.bintrayUsername
103+
key = project.bintrayApiKey
104+
publications = ['mavenCustom']
105+
pkg {
106+
repo = publishing.bintray.repo
107+
userOrg = publishing.bintray.userOrg
108+
name = publishing.bintray.name
109+
desc = publishing.desc
110+
licenses = [publishing.license]
111+
labels = publishing.labels
112+
websiteUrl = publishing.websiteUrl
113+
issueTrackerUrl = publishing.issueTrackerUrl
114+
vcsUrl = publishing.vcsUrl
115+
publicDownloadNumbers = true
116+
117+
version {
118+
name = publishing.versionId
119+
vcsTag = 'v' + publishing.versionId
120+
}
121+
}
122+
}

gradle/wrapper/gradle-wrapper.jar

51.7 KB
Binary file not shown.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#Wed Jun 21 10:43:28 CEST 2017
2+
distributionBase=GRADLE_USER_HOME
3+
distributionPath=wrapper/dists
4+
zipStoreBase=GRADLE_USER_HOME
5+
zipStorePath=wrapper/dists
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-4.0-all.zip

settings.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rootProject.name = 'JCSG-PathExtensions'
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
/*
2+
* Copyright 2017 Michael Hoffer <[email protected]>
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+
* If you use this software for scientific research then please cite the following publication(s):
17+
*
18+
* M. Hoffer, C. Poliwoda, & G. Wittum. (2013). Visual reflection library:
19+
* a framework for declarative GUI programming on the Java platform.
20+
* Computing and Visualization in Science, 2013, 16(4),
21+
* 181–192. http://doi.org/10.1007/s00791-014-0230-y
22+
*/
23+
package eu.mihosoft.jcsg.ext.path;
24+
25+
import eu.mihosoft.vvecmath.Vector3d;
26+
import java.util.ArrayList;
27+
import java.util.List;
28+
29+
/**
30+
* Tools for linear paths.
31+
*
32+
* @author Michael Hoffer <[email protected]>
33+
*/
34+
public final class LinearPathUtil {
35+
36+
private LinearPathUtil() {
37+
throw new AssertionError("Don't instantiate me!");
38+
}
39+
40+
/**
41+
* Extends the specified linear closed path by the given amount.
42+
*
43+
* @param path path to extend
44+
* @param amount amount
45+
* @return extended linear path (list of points)
46+
*/
47+
public static List<Vector3d> extend(List<Vector3d> path, double amount) {
48+
List<Vector3d> result = new ArrayList<>(path.size());
49+
50+
// 1. compute edge normals
51+
List<Vector3d> edgeNormals = new ArrayList<>(path.size());
52+
53+
for (int i = 1; i < path.size(); i++) {
54+
55+
Vector3d segment = path.get(i).minus(path.get(i - 1));
56+
edgeNormals.add(Vector3d.xy(-segment.y(), segment.x()).normalized());
57+
}
58+
59+
Vector3d segment = path.get(0).minus(path.get(path.size() - 1));
60+
edgeNormals.add(Vector3d.xy(-segment.y(), segment.x()).normalized());
61+
62+
// 2. compute vertex normals (average of adjacent edge normals)
63+
List<Vector3d> vertexNormals = new ArrayList<>(path.size());
64+
65+
Vector3d n0 = edgeNormals.get(edgeNormals.size() - 1).
66+
lerp(edgeNormals.get(0), 0.5).
67+
normalized();
68+
vertexNormals.add(n0);
69+
70+
for (int i = 1; i < edgeNormals.size(); i++) {
71+
Vector3d n = edgeNormals.get(i).lerp(edgeNormals.get(i - 1), 0.5).
72+
normalized();
73+
vertexNormals.add(n);
74+
}
75+
76+
// 3. extend path along vertex normals
77+
for (int i = 0; i < path.size(); i++) {
78+
result.add(path.get(i).plus(vertexNormals.get(i).
79+
times(amount * 0.5)));
80+
}
81+
82+
return result;
83+
}
84+
}

0 commit comments

Comments
 (0)