diff --git a/.travis.yml b/.travis.yml index a6f626d..32e6f0e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,5 +16,4 @@ before_script: script: ./gradlew clean build jdk: - oraclejdk8 - - oraclejdk9 env: TERM=dumb diff --git a/README.adoc b/README.adoc index 6664084..1a663eb 100644 --- a/README.adoc +++ b/README.adoc @@ -1,9 +1,10 @@ = JSilhouette :linkattrs: -:project-owner: aalmiray -:project-repo: kordamp -:project-name: jsilhouette -:project-group: org.kordamp.jsilhouette +:project-owner: aalmiray +:project-repo: kordamp +:project-name: jsilhouette +:project-group: org.kordamp.jsilhouette +:project-version: 0.3.0 image:http://img.shields.io/travis/aalmiray/{project-name}/master.svg["Build Status (travis)", link="https://travis-ci.org/aalmiray/{project-name}"] image:http://img.shields.io/badge/license-ASL2-blue.svg["ASL2 Licensed", link="http://opensource.org/licenses/ASL2"] @@ -17,17 +18,55 @@ JSilhouette provides additional shapes for Java applications. Currently JavaFX i == Installing -You can get the latest version of **JSilhouette** directly from link:https://bintray.com[Bintray's JCenter] repository. +You can get the latest version of **JSilhouette** directly from link:https://bintray.com[Bintray's JCenter] repository or Maven Central. + +[source,groovy] +[subs="attributes"] +.gradle +---- +repositories { + jcenter() +} + +dependencies { + compile '{project-group}:jsilhouette-javafx:{project-version}' +} +---- + +[source,xml] +[subs="attributes,verbatim"] +.maven +---- + + + {project-group} + jsilhouette-javafx + {project-version} + + + + + + central + jcenter + http://jcenter.bintray.com + + +---- Refer to the link:http://aalmiray.github.io/jsilhouette/[guide, window="_blank"] for further information on configuration and usage. +=== Java 9+ + +JSilhouette can be used in a modular fashion when running in Java9+. It's module name is `org.kordamp.jsilhouette.javafx`. + == Building You must meet the following requirements: - * JDK8u40 as a minimum - * Gradle 4.4 + * JDK8u60 as a minimum + * Gradle 4.10 You may used the included gradle wrapper script if you don't have `gradle` installed. @@ -45,7 +84,7 @@ You may used the included gradle wrapper script if you don't have `gradle` insta . Follow the instructions found at http://sdkman.io/ to install SDKMAN. . You need a POSIX environment if running Windows. We recommend using Babun Shell (http://babun.github.io/) - . Once SDKMAN is installed invoke `sdk install gradle 2.10`. + . Once SDKMAN is installed invoke `sdk install gradle 4.10`. . Test your setup by invoking `gradle --version`. .Gdub diff --git a/build.gradle b/build.gradle index d4f1c0b..c7fffe9 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ /* - * Copyright 2015-2017 the original author or authors. + * Copyright 2015-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,19 +23,16 @@ buildscript { } dependencies { - classpath 'org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.8.2' classpath 'nl.javadude.gradle.plugins:license-gradle-plugin:0.11.0' - classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.0' - classpath 'org.ajoberstar:gradle-git:1.7.2' + classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4' + classpath 'org.ajoberstar:gradle-git-publish:0.3.2' classpath 'org.kordamp.gradle:stats-gradle-plugin:0.2.2' - classpath 'com.github.ben-manes:gradle-versions-plugin:0.17.0' - classpath 'net.nemerosa:versioning:2.6.1' - classpath 'org.kordamp.gradle:jdeps-gradle-plugin:0.2.0' - classpath 'gradle.plugin.net.ossindex:ossindex-gradle-plugin:0.1.1' + classpath 'com.github.ben-manes:gradle-versions-plugin:0.20.0' + classpath 'net.nemerosa:versioning:2.7.1' } } -apply plugin: 'org.ajoberstar.github-pages' +apply plugin: 'org.ajoberstar.git-publish' apply plugin: 'net.nemerosa.versioning' Date buildTimeAndDate = new Date() @@ -44,15 +41,14 @@ ext { buildDate = new SimpleDateFormat('yyyy-MM-dd').format(buildTimeAndDate) buildTime = new SimpleDateFormat('HH:mm:ss.SSSZ').format(buildTimeAndDate) buildRevision = versioning.info.commit - buildCreatedBy = "${System.properties['java.version']} (${System.properties['java.vendor']} ${System.properties['java.vm.version']})".toString() + buildJdk = "${System.properties['java.version']} (${System.properties['java.vendor']} ${System.properties['java.vm.version']})".toString() + buildCreatedBy = "Gradle ${gradle.gradleVersion}" } allprojects { apply plugin: 'base' apply plugin: 'idea' apply plugin: 'com.github.ben-manes.versions' - apply plugin: 'net.ossindex.audit' - apply plugin: 'org.kordamp.jdeps' repositories { jcenter() @@ -64,12 +60,17 @@ allprojects { } } - audit { - failOnError = false - } - - jdeps { - failOnError = false + dependencyUpdates.resolutionStrategy = { + componentSelection { rules -> + rules.all { selection -> + boolean rejected = ['alpha', 'beta', 'rc', 'cr', 'm'].any { qualifier -> + selection.candidate.version ==~ /(?i).*[.-]${qualifier}[.\d-]*/ + } + if (rejected) { + selection.reject('Release candidate') + } + } + } } } @@ -82,9 +83,7 @@ idea { subprojects { subproj -> apply plugin: 'java' - apply plugin: 'com.github.kt3k.coveralls' apply plugin: 'org.kordamp.gradle.stats' - apply from: rootProject.file('gradle/code-coverage.gradle') apply from: rootProject.file('gradle/code-quality.gradle') subproj.tasks.withType(JavaCompile) { @@ -97,8 +96,6 @@ subprojects { subproj -> } if (subproj.publishJars.toBoolean()) { - apply from: rootProject.file('gradle/publishing.gradle') - javadoc { excludes = ['**/*.html', 'META-INF/**'] @@ -121,6 +118,7 @@ subprojects { subproj -> } task javadocJar(type: Jar) { + dependsOn 'javadoc' group 'Build' description 'An archive of the javadoc' classifier 'javadoc' @@ -134,6 +132,8 @@ subprojects { subproj -> sourcesJar javadocJar } + + apply from: rootProject.file('gradle/publishing.gradle') } } @@ -142,16 +142,13 @@ evaluationDependsOnChildren() if (!project.hasProperty('githubUsername')) ext.githubUsername = '' if (!project.hasProperty('githubPassword')) ext.githubPassword = '' -githubPages { +gitPublish { repoUri = project.project_scm - pages { + branch = 'gh-pages' + contents { from project(':guide').guide.outputs.files } - - credentials { - username = githubUsername - password = githubPassword - } + commitMessage = "Publish guide for $version" } -publishGhPages.dependsOn(project(':guide').guide) +gitPublishCommit.dependsOn(project(':guide').guide) diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml index 737f30f..13823ee 100644 --- a/config/checkstyle/checkstyle.xml +++ b/config/checkstyle/checkstyle.xml @@ -14,13 +14,16 @@ ~ limitations under the License. --> + "-//Puppy Crawl//DTD Check Configuration 1.2//EN" + "http://www.puppycrawl.com/dtds/configuration_1_2.dtd"> + + + - + @@ -41,9 +44,6 @@ - - - diff --git a/gradle.properties b/gradle.properties index 9c9edbf..075c2be 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,14 +1,14 @@ -version=0.2.2 +version=0.3.0 group=org.kordamp.jsilhouette -sourceCompatibility=1.7 -targetCompatibility=1.7 +sourceCompatibility=1.8 +targetCompatibility=1.8 publishJars=false -project_description=Additional shapes for Java applications +project_description=Additional shapes for JavaFX applications project_url=https://github.com/aalmiray/jsilhouette project_scm=https://github.com/aalmiray/jsilhouette.git project_issues=https://github.com/aalmiray/jsilhouette/issues project_bintray_repo=kordamp project_bintray_org=aalmiray -javadocFooter=Copyright © 2015-2017 Andres Almiray. All rights reserved. +javadocFooter=Copyright © 2015-2018 Andres Almiray. All rights reserved. diff --git a/gradle/code-coverage.gradle b/gradle/code-coverage.gradle deleted file mode 100644 index fd59e45..0000000 --- a/gradle/code-coverage.gradle +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2015-2017 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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. - */ - -apply plugin: 'jacoco' - -jacoco { - toolVersion = '0.7.9' -} - -jacocoTestReport { - group = 'Reporting' - description = 'Generate Jacoco coverage reports after running tests.' - additionalSourceDirs = project.files(sourceSets.main.allSource.srcDirs) - sourceDirectories = project.files(sourceSets.main.allSource.srcDirs) - classDirectories = project.files(sourceSets.main.output) - reports { - xml.enabled = true - csv.enabled = false - html.enabled = true - } -} diff --git a/gradle/code-quality.gradle b/gradle/code-quality.gradle index f1e7968..8ff9ae1 100644 --- a/gradle/code-quality.gradle +++ b/gradle/code-quality.gradle @@ -1,5 +1,5 @@ /* - * Copyright 2015-2017 the original author or authors. + * Copyright 2015-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,6 @@ * limitations under the License. */ -apply plugin: 'jdepend' apply plugin: 'checkstyle' apply plugin: 'com.github.hierynomus.license' @@ -22,45 +21,11 @@ def configDir = new File(buildscript.sourceFile.parentFile.parentFile, 'config') ext.checkstyleConfigDir = "$configDir/checkstyle" checkstyle { - toolVersion = '6.0' + toolVersion = '8.12' configFile = new File(checkstyleConfigDir, 'checkstyle.xml') configProperties.checkstyleConfigDir = checkstyleConfigDir } -if (project.hasProperty('findBugsEnabled') && project.findBugsEnabled.toBoolean()) { - apply plugin: 'findbugs' - findbugs { - toolVersion = '3.0.0' - sourceSets = [sourceSets.main] - ignoreFailures = true - reportsDir = file("$project.buildDir/reports/findbugs") - effort = 'max' - reportLevel = 'high' - } - - findbugsMain { - reports { - xml.enabled = false - html.enabled = true - } - } - - findbugsTest { - reports { - xml.enabled = false - html.enabled = true - } - } -} - - -jdepend { - toolVersion = '2.9.1' - sourceSets = [sourceSets.main] - ignoreFailures = true - reportsDir = file("$project.buildDir/reports/jdepend") -} - license { header = rootProject.file('config/HEADER') strictCheck = true @@ -69,7 +34,7 @@ license { java = 'SLASHSTAR_STYLE' fxml = 'XML_STYLE' } - ext.year = '2015-2017' + ext.year = '2015-2018' exclude '**/*.ttf' exclude '**/*.eot' exclude '**/*.svg' diff --git a/gradle/javafx.gradle b/gradle/javafx.gradle index 0a164cd..36d49c0 100644 --- a/gradle/javafx.gradle +++ b/gradle/javafx.gradle @@ -1,5 +1,5 @@ /* - * Copyright 2015-2017 the original author or authors. + * Copyright 2015-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/gradle/publishing.gradle b/gradle/publishing.gradle index 45f07a6..d23cc86 100644 --- a/gradle/publishing.gradle +++ b/gradle/publishing.gradle @@ -1,5 +1,5 @@ /* - * Copyright 2015-2017 the original author or authors. + * Copyright 2015-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,14 +17,51 @@ apply plugin: 'maven-publish' apply plugin: 'com.jfrog.bintray' +task generateMinPom { + doLast { + String pomHeader = """ + + 4.0.0 + ${project.group} + ${project.name} + ${project.version} + """.stripIndent(12) + + def dependencyTemplate = { dep -> """ + + $dep.group + $dep.name + $dep.version + + """.stripIndent(4) + } + + String deps = configurations.runtime.allDependencies.findAll({it.name!= 'unspecified'}) + .collect({ dep -> dependencyTemplate(dep)}).join('') + + String pom = pomHeader + if (deps) { + pom += " \n$deps\n \n" + } + pom += "" + + project.file("$buildDir/tmp/maven").mkdirs() + project.file("$buildDir/tmp/maven/pom.xml").text = pom + } +} + jar { + dependsOn 'generateMinPom' manifest { attributes( - 'Built-By': buildBy, 'Created-By': buildCreatedBy, - 'Build-Date': buildDate, - 'Build-Time': buildTime, - 'Build-Revision': buildRevision, + 'x-Built-By': buildBy, + 'x-Build-Jdk': buildJdk, + 'x-Build-Date': buildDate, + 'x-Build-Time': buildTime, + 'x-Build-Revision': buildRevision, 'Specification-Title': project.name, 'Specification-Version': project.version, 'Implementation-Title': project.name, @@ -36,36 +73,17 @@ jar { from(rootProject.files('.')) { include 'LICENSE*' } - } -} - -def pomConfig = { - packaging 'jar' - name project.name - description project.project_description - url project.project_url - inceptionYear '2016' - licenses { - license([:]) { - name 'The Apache Software License, Version 2.0' - url 'http://www.apache.org/licenses/LICENSE-2.0.txt' - distribution 'repo' + from(rootProject.file('src/maven')) { + into "maven/${project.group}/${project.name}" + expand( + 'gradle_version': gradle.gradleVersion, + 'project_version': project.version, + 'project_group': project.group, + 'project_name': project.name, + ) } - } - scm { - url project.project_scm - } - developers { - [ - aalmiray : 'Andres Almiray' - ].each { devId, devName -> - developer { - id devId - name devName - roles { - role 'Developer' - } - } + from(file("$buildDir/tmp/maven")) { + into "maven/${project.group}/${project.name}" } } } @@ -77,9 +95,32 @@ publishing { artifact sourcesJar artifact javadocJar - pom.withXml { - asNode().children().last() + pomConfig - asNode().appendNode('description', project.project_description) + pom { + name = project.name + description = project.project_description + url = project.project_url + inceptionYear = '2015' + licenses { + license { + name = 'The Apache Software License, Version 2.0' + url = 'http://www.apache.org/licenses/LICENSE-2.0.txt' + distribution = 'repo' + } + } + scm { + url = project.project_scm + } + developers { + [ + aalmiray: 'Andres Almiray' + ].each { devId, devName -> + developer { + id = devId + name = devName + roles = ['Developer'] + } + } + } } } } @@ -87,6 +128,8 @@ publishing { if (!project.hasProperty('bintrayUsername')) ext.bintrayUsername = '' if (!project.hasProperty('bintrayApiKey')) ext.bintrayApiKey = '' +if (!project.hasProperty('mavenUsername')) ext.mavenUsername = '' +if (!project.hasProperty('mavenPassword')) ext.mavenPassword = '' bintray { user = project.bintrayUsername @@ -98,10 +141,20 @@ bintray { name = rootProject.name desc = rootProject.project_description licenses = ['Apache-2.0'] - labels = ['shapes', 'java', 'javafx'] + labels = ['shapes', 'javafx', 'java'] websiteUrl = project.project_url issueTrackerUrl = project.project_issues vcsUrl = project.project_scm publicDownloadNumbers = true + githubRepo = 'aalmiray/jsilhouette' + version { + name = project.version + vcsTag = "jsilhouette-${project.version}" + mavenCentralSync { + sync = true + user = project.mavenUsername + password = project.mavenPassword + } + } } } diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 01b8bf6..29953ea 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 933b647..e0b3fb8 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-bin.zip diff --git a/settings.gradle b/settings.gradle index 3973ce6..180653a 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,3 +1,5 @@ +enableFeaturePreview('STABLE_PUBLISHING') + rootProject.name = 'jsilhouette' def includeProject = { String projectDirName, String projectName -> @@ -14,5 +16,6 @@ def includeProject = { String projectDirName, String projectName -> } includeProject 'subprojects', 'jsilhouette-javafx' +includeProject 'subprojects', 'sampler-javafx' includeProject 'subprojects', 'guide' includeProject 'subprojects', 'image-generator' diff --git a/src/maven/pom.properties b/src/maven/pom.properties new file mode 100644 index 0000000..a882ed2 --- /dev/null +++ b/src/maven/pom.properties @@ -0,0 +1,4 @@ +# Generated by Gradle $gradle_version +version=$project_version +groupId=$project_group +artifactId=$project_name diff --git a/subprojects/guide/gradle.properties b/subprojects/guide/gradle.properties deleted file mode 100644 index 4fe9e64..0000000 --- a/subprojects/guide/gradle.properties +++ /dev/null @@ -1,2 +0,0 @@ -sourceCompatibility=1.8 -targetCompatibility=1.8 \ No newline at end of file diff --git a/subprojects/guide/guide.gradle b/subprojects/guide/guide.gradle index 693413c..14003d4 100644 --- a/subprojects/guide/guide.gradle +++ b/subprojects/guide/guide.gradle @@ -1,3 +1,19 @@ +/* + * Copyright 2015-2018 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * 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. + */ + buildscript { repositories { jcenter() @@ -39,7 +55,7 @@ configurations { } dependencies { - asciidoclet 'org.asciidoctor:asciidoclet:1.5.4' + asciidoclet 'org.asciidoctor:asciidoclet:1.5.6' java2html 'de.java2html:java2html:5.0' } @@ -81,11 +97,8 @@ task apiDocs(type: Javadoc, dependsOn: copyDocs) { options.windowTitle = "JSilhouette ${project.version}" options.docTitle = "JSilhouette ${project.version}" options.footer = project.javadocFooter - options.links = ['http://www.slf4j.org/apidocs/', - 'http://junit.org/javadoc/latest/', - 'http://docs.oracle.com/javase/8/docs/api/', - 'http://jsr-305.googlecode.com/svn/trunk/javadoc/', - 'http://atinject.googlecode.com/svn/trunk/javadoc/'] + options.links = ['http://docs.oracle.com/javase/8/docs/api/', + 'http://docs.oracle.com/javase/8/javafx/api/'] } task generateJava2html { @@ -163,7 +176,7 @@ asciidoctor { task guide(type: Copy, dependsOn: [apiDocs, /*generateJava2html,*/ asciidoctor]) { destinationDir = "${buildDir}/guide" as File from(apiDocs.destinationDir) { into 'api' } - // from(java2htmlConvertCode.destDir) { into 'api-src'} + from(java2htmlConvertCode.destDir) { into 'api-src'} from("${asciidoctor.outputDir}/html5") } diff --git a/subprojects/image-generator/gradle.properties b/subprojects/image-generator/gradle.properties deleted file mode 100644 index 4fe9e64..0000000 --- a/subprojects/image-generator/gradle.properties +++ /dev/null @@ -1,2 +0,0 @@ -sourceCompatibility=1.8 -targetCompatibility=1.8 \ No newline at end of file diff --git a/subprojects/image-generator/image-generator.gradle b/subprojects/image-generator/image-generator.gradle index f5c5619..0cc2bda 100644 --- a/subprojects/image-generator/image-generator.gradle +++ b/subprojects/image-generator/image-generator.gradle @@ -1,3 +1,19 @@ +/* + * Copyright 2015-2018 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * 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. + */ + apply from: rootProject.file('gradle/javafx.gradle') apply plugin: 'application' diff --git a/subprojects/image-generator/src/main/java/org/kordamp/jsilhouette/Generator.java b/subprojects/image-generator/src/main/java/org/kordamp/jsilhouette/Generator.java index 5caab20..9c6a4e3 100644 --- a/subprojects/image-generator/src/main/java/org/kordamp/jsilhouette/Generator.java +++ b/subprojects/image-generator/src/main/java/org/kordamp/jsilhouette/Generator.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2017 Andres Almiray + * Copyright 2015-2018 Andres Almiray * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/subprojects/jsilhouette-javafx/gradle.properties b/subprojects/jsilhouette-javafx/gradle.properties index de31b32..4c773bf 100644 --- a/subprojects/jsilhouette-javafx/gradle.properties +++ b/subprojects/jsilhouette-javafx/gradle.properties @@ -1,4 +1,2 @@ -sourceCompatibility=1.8 -targetCompatibility=1.8 publishJars=true moduleName=org.kordamp.jsilhouette.javafx diff --git a/subprojects/jsilhouette-javafx/jsilhouette-javafx.gradle b/subprojects/jsilhouette-javafx/jsilhouette-javafx.gradle index 0d1cd96..75b725c 100644 --- a/subprojects/jsilhouette-javafx/jsilhouette-javafx.gradle +++ b/subprojects/jsilhouette-javafx/jsilhouette-javafx.gradle @@ -1,3 +1,19 @@ +/* + * Copyright 2015-2018 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * 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. + */ + apply from: rootProject.file('gradle/javafx.gradle') dependencies { @@ -10,7 +26,7 @@ configurations { } dependencies { - asciidoclet 'org.asciidoctor:asciidoclet:1.5.4' + asciidoclet 'org.asciidoctor:asciidoclet:1.5.6' } evaluationDependsOn ':image-generator' diff --git a/subprojects/jsilhouette-javafx/src/main/java/org/kordamp/jsilhouette/javafx/AbstractCenteredSilhouette.java b/subprojects/jsilhouette-javafx/src/main/java/org/kordamp/jsilhouette/javafx/AbstractCenteredSilhouette.java index 1ec0d80..5bf8499 100644 --- a/subprojects/jsilhouette-javafx/src/main/java/org/kordamp/jsilhouette/javafx/AbstractCenteredSilhouette.java +++ b/subprojects/jsilhouette-javafx/src/main/java/org/kordamp/jsilhouette/javafx/AbstractCenteredSilhouette.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2017 Andres Almiray + * Copyright 2015-2018 Andres Almiray * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/subprojects/jsilhouette-javafx/src/main/java/org/kordamp/jsilhouette/javafx/AbstractSilhouette.java b/subprojects/jsilhouette-javafx/src/main/java/org/kordamp/jsilhouette/javafx/AbstractSilhouette.java index 8d4cfeb..95ae9bc 100644 --- a/subprojects/jsilhouette-javafx/src/main/java/org/kordamp/jsilhouette/javafx/AbstractSilhouette.java +++ b/subprojects/jsilhouette-javafx/src/main/java/org/kordamp/jsilhouette/javafx/AbstractSilhouette.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2017 Andres Almiray + * Copyright 2015-2018 Andres Almiray * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,6 +24,9 @@ import javafx.beans.property.SimpleStringProperty; import javafx.beans.property.StringProperty; import javafx.beans.value.ChangeListener; +import javafx.event.Event; +import javafx.event.EventHandler; +import javafx.event.EventType; import javafx.geometry.Point3D; import javafx.scene.paint.Color; import javafx.scene.paint.Paint; @@ -33,6 +36,8 @@ import javafx.scene.shape.StrokeType; import javafx.scene.transform.Rotate; +import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; import java.util.function.Consumer; /** @@ -78,6 +83,8 @@ public abstract class AbstractSilhouette implements Silhouette { } }; + private final List> eventHandlers = new CopyOnWriteArrayList<>(); + protected void setShape(Shape shape) { shapeProperty().set(shape); } @@ -388,4 +395,70 @@ protected void forwardShapeProperty(Consumer consumer) { consumer.accept(getShape()); } } + + public final void addEventHandler( + final EventType eventType, + final EventHandler eventHandler) { + if (eventType == null) { + throw new NullPointerException("Argument 'eventType' is null"); + } + if (eventHandler == null) { + throw new NullPointerException("Argument 'eventHandler' is null"); + } + + if (shape == null) { + EventHandlerRegistration registration = new EventHandlerRegistration<>(eventType, eventHandler); + if (!eventHandlers.contains(registration)) { + eventHandlers.add(registration); + } + } else { + shape.get().addEventHandler(eventType, eventHandler); + } + } + + public final void removeEventHandler( + final EventType eventType, + final EventHandler eventHandler) { + if (eventType == null) { + throw new NullPointerException("Argument 'eventType' is null"); + } + if (eventHandler == null) { + throw new NullPointerException("Argument 'eventHandler' is null"); + } + + if (shape == null) { + EventHandlerRegistration registration = new EventHandlerRegistration<>(eventType, eventHandler); + eventHandlers.remove(registration); + } else { + shape.get().removeEventHandler(eventType, eventHandler); + } + } + + private static class EventHandlerRegistration { + private final EventType eventType; + private final EventHandler eventHandler; + + private EventHandlerRegistration(EventType eventType, EventHandler eventHandler) { + this.eventType = eventType; + this.eventHandler = eventHandler; + } + + @Override + public boolean equals(Object o) { + if (this == o) { return true; } + if (o == null || getClass() != o.getClass()) { return false; } + + EventHandlerRegistration that = (EventHandlerRegistration) o; + + if (!eventType.equals(that.eventType)) { return false; } + return eventHandler.equals(that.eventHandler); + } + + @Override + public int hashCode() { + int result = eventType.hashCode(); + result = 31 * result + eventHandler.hashCode(); + return result; + } + } } diff --git a/subprojects/jsilhouette-javafx/src/main/java/org/kordamp/jsilhouette/javafx/Almond.java b/subprojects/jsilhouette-javafx/src/main/java/org/kordamp/jsilhouette/javafx/Almond.java index 8662ab7..54405cc 100644 --- a/subprojects/jsilhouette-javafx/src/main/java/org/kordamp/jsilhouette/javafx/Almond.java +++ b/subprojects/jsilhouette-javafx/src/main/java/org/kordamp/jsilhouette/javafx/Almond.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2017 Andres Almiray + * Copyright 2015-2018 Andres Almiray * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/subprojects/jsilhouette-javafx/src/main/java/org/kordamp/jsilhouette/javafx/Arrow.java b/subprojects/jsilhouette-javafx/src/main/java/org/kordamp/jsilhouette/javafx/Arrow.java index bd09b80..65de87a 100644 --- a/subprojects/jsilhouette-javafx/src/main/java/org/kordamp/jsilhouette/javafx/Arrow.java +++ b/subprojects/jsilhouette-javafx/src/main/java/org/kordamp/jsilhouette/javafx/Arrow.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2017 Andres Almiray + * Copyright 2015-2018 Andres Almiray * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/subprojects/jsilhouette-javafx/src/main/java/org/kordamp/jsilhouette/javafx/Asterisk.java b/subprojects/jsilhouette-javafx/src/main/java/org/kordamp/jsilhouette/javafx/Asterisk.java index 0bb7813..33ff164 100644 --- a/subprojects/jsilhouette-javafx/src/main/java/org/kordamp/jsilhouette/javafx/Asterisk.java +++ b/subprojects/jsilhouette-javafx/src/main/java/org/kordamp/jsilhouette/javafx/Asterisk.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2017 Andres Almiray + * Copyright 2015-2018 Andres Almiray * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/subprojects/jsilhouette-javafx/src/main/java/org/kordamp/jsilhouette/javafx/Astroid.java b/subprojects/jsilhouette-javafx/src/main/java/org/kordamp/jsilhouette/javafx/Astroid.java index 53f2964..994f08f 100644 --- a/subprojects/jsilhouette-javafx/src/main/java/org/kordamp/jsilhouette/javafx/Astroid.java +++ b/subprojects/jsilhouette-javafx/src/main/java/org/kordamp/jsilhouette/javafx/Astroid.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2017 Andres Almiray + * Copyright 2015-2018 Andres Almiray * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/subprojects/jsilhouette-javafx/src/main/java/org/kordamp/jsilhouette/javafx/CenteredSilhouette.java b/subprojects/jsilhouette-javafx/src/main/java/org/kordamp/jsilhouette/javafx/CenteredSilhouette.java index 49bca10..30f18b0 100644 --- a/subprojects/jsilhouette-javafx/src/main/java/org/kordamp/jsilhouette/javafx/CenteredSilhouette.java +++ b/subprojects/jsilhouette-javafx/src/main/java/org/kordamp/jsilhouette/javafx/CenteredSilhouette.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2017 Andres Almiray + * Copyright 2015-2018 Andres Almiray * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/subprojects/jsilhouette-javafx/src/main/java/org/kordamp/jsilhouette/javafx/Cross.java b/subprojects/jsilhouette-javafx/src/main/java/org/kordamp/jsilhouette/javafx/Cross.java index 84637e5..514a32d 100644 --- a/subprojects/jsilhouette-javafx/src/main/java/org/kordamp/jsilhouette/javafx/Cross.java +++ b/subprojects/jsilhouette-javafx/src/main/java/org/kordamp/jsilhouette/javafx/Cross.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2017 Andres Almiray + * Copyright 2015-2018 Andres Almiray * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/subprojects/jsilhouette-javafx/src/main/java/org/kordamp/jsilhouette/javafx/Donut.java b/subprojects/jsilhouette-javafx/src/main/java/org/kordamp/jsilhouette/javafx/Donut.java index ba214f0..8059be5 100644 --- a/subprojects/jsilhouette-javafx/src/main/java/org/kordamp/jsilhouette/javafx/Donut.java +++ b/subprojects/jsilhouette-javafx/src/main/java/org/kordamp/jsilhouette/javafx/Donut.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2017 Andres Almiray + * Copyright 2015-2018 Andres Almiray * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/subprojects/jsilhouette-javafx/src/main/java/org/kordamp/jsilhouette/javafx/Lauburu.java b/subprojects/jsilhouette-javafx/src/main/java/org/kordamp/jsilhouette/javafx/Lauburu.java index f4bcd26..2586957 100644 --- a/subprojects/jsilhouette-javafx/src/main/java/org/kordamp/jsilhouette/javafx/Lauburu.java +++ b/subprojects/jsilhouette-javafx/src/main/java/org/kordamp/jsilhouette/javafx/Lauburu.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2017 Andres Almiray + * Copyright 2015-2018 Andres Almiray * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/subprojects/jsilhouette-javafx/src/main/java/org/kordamp/jsilhouette/javafx/MultiRoundRectangle.java b/subprojects/jsilhouette-javafx/src/main/java/org/kordamp/jsilhouette/javafx/MultiRoundRectangle.java index bdfc98d..dc1840c 100644 --- a/subprojects/jsilhouette-javafx/src/main/java/org/kordamp/jsilhouette/javafx/MultiRoundRectangle.java +++ b/subprojects/jsilhouette-javafx/src/main/java/org/kordamp/jsilhouette/javafx/MultiRoundRectangle.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2017 Andres Almiray + * Copyright 2015-2018 Andres Almiray * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/subprojects/jsilhouette-javafx/src/main/java/org/kordamp/jsilhouette/javafx/PathBuilder.java b/subprojects/jsilhouette-javafx/src/main/java/org/kordamp/jsilhouette/javafx/PathBuilder.java index 76012d5..3128490 100644 --- a/subprojects/jsilhouette-javafx/src/main/java/org/kordamp/jsilhouette/javafx/PathBuilder.java +++ b/subprojects/jsilhouette-javafx/src/main/java/org/kordamp/jsilhouette/javafx/PathBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2017 Andres Almiray + * Copyright 2015-2018 Andres Almiray * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/subprojects/jsilhouette-javafx/src/main/java/org/kordamp/jsilhouette/javafx/Rays.java b/subprojects/jsilhouette-javafx/src/main/java/org/kordamp/jsilhouette/javafx/Rays.java index 2def44d..7d178ed 100644 --- a/subprojects/jsilhouette-javafx/src/main/java/org/kordamp/jsilhouette/javafx/Rays.java +++ b/subprojects/jsilhouette-javafx/src/main/java/org/kordamp/jsilhouette/javafx/Rays.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2017 Andres Almiray + * Copyright 2015-2018 Andres Almiray * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/subprojects/jsilhouette-javafx/src/main/java/org/kordamp/jsilhouette/javafx/RegularPolygon.java b/subprojects/jsilhouette-javafx/src/main/java/org/kordamp/jsilhouette/javafx/RegularPolygon.java index 5f8091c..e835b55 100644 --- a/subprojects/jsilhouette-javafx/src/main/java/org/kordamp/jsilhouette/javafx/RegularPolygon.java +++ b/subprojects/jsilhouette-javafx/src/main/java/org/kordamp/jsilhouette/javafx/RegularPolygon.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2017 Andres Almiray + * Copyright 2015-2018 Andres Almiray * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/subprojects/jsilhouette-javafx/src/main/java/org/kordamp/jsilhouette/javafx/RoundPin.java b/subprojects/jsilhouette-javafx/src/main/java/org/kordamp/jsilhouette/javafx/RoundPin.java index 176f446..fab6b2a 100644 --- a/subprojects/jsilhouette-javafx/src/main/java/org/kordamp/jsilhouette/javafx/RoundPin.java +++ b/subprojects/jsilhouette-javafx/src/main/java/org/kordamp/jsilhouette/javafx/RoundPin.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2017 Andres Almiray + * Copyright 2015-2018 Andres Almiray * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/subprojects/jsilhouette-javafx/src/main/java/org/kordamp/jsilhouette/javafx/Silhouette.java b/subprojects/jsilhouette-javafx/src/main/java/org/kordamp/jsilhouette/javafx/Silhouette.java index b0bd30e..1b3509d 100644 --- a/subprojects/jsilhouette-javafx/src/main/java/org/kordamp/jsilhouette/javafx/Silhouette.java +++ b/subprojects/jsilhouette-javafx/src/main/java/org/kordamp/jsilhouette/javafx/Silhouette.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2017 Andres Almiray + * Copyright 2015-2018 Andres Almiray * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,6 +19,9 @@ import javafx.beans.property.DoubleProperty; import javafx.beans.property.ObjectProperty; import javafx.beans.property.StringProperty; +import javafx.event.Event; +import javafx.event.EventHandler; +import javafx.event.EventType; import javafx.geometry.Point3D; import javafx.scene.paint.Paint; import javafx.scene.shape.Shape; @@ -260,4 +263,34 @@ default boolean isVisible() { default void setVisible(boolean visible) { visibleProperty().set(visible); } + + // PENDING_DOC_REVIEW + /** + * Registers an event handler to this node. The handler is called when the + * node receives an {@code Event} of the specified type during the bubbling + * phase of event delivery. + * + * @param the specific event class of the handler + * @param eventType the type of the events to receive by the handler + * @param eventHandler the handler to register + * @throws NullPointerException if the event type or handler is null + */ + void addEventHandler( + final EventType eventType, + final EventHandler eventHandler); + + /** + * Unregisters a previously registered event handler from this node. One + * handler might have been registered for different event types, so the + * caller needs to specify the particular event type from which to + * unregister the handler. + * + * @param the specific event class of the handler + * @param eventType the event type from which to unregister + * @param eventHandler the handler to unregister + * @throws NullPointerException if the event type or handler is null + */ + void removeEventHandler( + final EventType eventType, + final EventHandler eventHandler); } diff --git a/subprojects/jsilhouette-javafx/src/main/java/org/kordamp/jsilhouette/javafx/Star.java b/subprojects/jsilhouette-javafx/src/main/java/org/kordamp/jsilhouette/javafx/Star.java index 7a35968..2ff4694 100644 --- a/subprojects/jsilhouette-javafx/src/main/java/org/kordamp/jsilhouette/javafx/Star.java +++ b/subprojects/jsilhouette-javafx/src/main/java/org/kordamp/jsilhouette/javafx/Star.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2017 Andres Almiray + * Copyright 2015-2018 Andres Almiray * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -54,7 +54,7 @@ public Star() { } public Star(double cx, double cy, double or, double ir) { - this(cy, cy, or, ir, 0); + this(cx, cy, or, ir, 0); } public Star(double cx, double cy, double or, double ir, int sides) { diff --git a/subprojects/sampler-javafx/gradle.properties b/subprojects/sampler-javafx/gradle.properties deleted file mode 100644 index 4fe9e64..0000000 --- a/subprojects/sampler-javafx/gradle.properties +++ /dev/null @@ -1,2 +0,0 @@ -sourceCompatibility=1.8 -targetCompatibility=1.8 \ No newline at end of file diff --git a/subprojects/sampler-javafx/sampler-javafx.gradle b/subprojects/sampler-javafx/sampler-javafx.gradle index 82af119..321c79f 100644 --- a/subprojects/sampler-javafx/sampler-javafx.gradle +++ b/subprojects/sampler-javafx/sampler-javafx.gradle @@ -1,3 +1,19 @@ +/* + * Copyright 2015-2018 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * 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. + */ + apply from: rootProject.file('gradle/javafx.gradle') apply plugin: 'application' diff --git a/subprojects/sampler-javafx/src/main/java/org/kordamp/jsilhouette/Sampler.java b/subprojects/sampler-javafx/src/main/java/org/kordamp/jsilhouette/Sampler.java index 9154b2b..c97fe9b 100644 --- a/subprojects/sampler-javafx/src/main/java/org/kordamp/jsilhouette/Sampler.java +++ b/subprojects/sampler-javafx/src/main/java/org/kordamp/jsilhouette/Sampler.java @@ -23,7 +23,6 @@ import javafx.scene.shape.Shape; import javafx.stage.Stage; import org.kordamp.jsilhouette.javafx.Lauburu; -import org.kordamp.jsilhouette.javafx.Rays; import org.kordamp.jsilhouette.javafx.Silhouette; import java.net.URL;