diff --git a/build.gradle b/build.gradle index 8fd5b1b..c1d26ab 100755 --- a/build.gradle +++ b/build.gradle @@ -86,7 +86,6 @@ apply plugin: 'org.asciidoctor.convert' apply plugin: 'com.github.kt3k.coveralls' apply plugin: 'com.github.ben-manes.versions' apply plugin: 'net.nemerosa.versioning' -apply plugin: 'com.jfrog.bintray' repositories { if (project.hasProperty('groovyfx_useMavenLocal') && Boolean.valueOf(project.groovyfx_useMavenLocal)) { mavenLocal() } diff --git a/gradle/publishing.gradle b/gradle/publishing.gradle index b55d9bb..c8f7e74 100644 --- a/gradle/publishing.gradle +++ b/gradle/publishing.gradle @@ -16,6 +16,8 @@ // ------------- Bintray deployment --------------- +apply plugin: 'com.jfrog.bintray' + def pomConfig = { name project.name url project.project_url diff --git a/src/main/groovy/groovyx/javafx/factory/CanvasFactory.groovy b/src/main/groovy/groovyx/javafx/factory/CanvasFactory.groovy index 8d54d04..bca72d0 100644 --- a/src/main/groovy/groovyx/javafx/factory/CanvasFactory.groovy +++ b/src/main/groovy/groovyx/javafx/factory/CanvasFactory.groovy @@ -1,5 +1,5 @@ /* - * Copyright 2011-2016 the original author or authors. + * Copyright 2011-2019 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. @@ -13,15 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ - package groovyx.javafx.factory import groovyx.javafx.canvas.CanvasOperation import groovyx.javafx.canvas.DrawOperations +import javafx.collections.FXCollections import javafx.scene.canvas.Canvas /** @@ -30,32 +26,32 @@ import javafx.scene.canvas.Canvas */ class CanvasFactory extends AbstractNodeFactory { private static final String CANVAS_OPERATIONS_LIST_PROPERTY = "__canvasOperationsList" - + CanvasFactory() { - super(Canvas); + super(Canvas) } - + CanvasFactory(Class beanClass) { - super(beanClass); + super(beanClass) } - + @Override public void setChild(FactoryBuilderSupport builder, Object parent, Object child) { if (child instanceof CanvasOperation) { - def operations = builder.parentContext.get(CANVAS_OPERATIONS_LIST_PROPERTY, []) + def operations = builder.parentContext.get(CANVAS_OPERATIONS_LIST_PROPERTY, FXCollections.observableList([])) operations << child - }else { - super.setChild(builder, parent, child); + } else { + super.setChild(builder, parent, child) } } - - + + @Override void onNodeCompleted(FactoryBuilderSupport builder, Object parent, Object node) { def operations = builder.context.remove(CANVAS_OPERATIONS_LIST_PROPERTY) - def dop = new DrawOperations(operations: operations, canvas: node); - dop.draw(); - node.userData = dop; + def dop = new DrawOperations(operations: operations, canvas: node) + dop.draw() + node.userData = dop super.onNodeCompleted(builder, parent, node) } } diff --git a/src/main/groovy/groovyx/javafx/factory/ContainerFactory.groovy b/src/main/groovy/groovyx/javafx/factory/ContainerFactory.groovy index a6af3d7..55e6dc6 100644 --- a/src/main/groovy/groovyx/javafx/factory/ContainerFactory.groovy +++ b/src/main/groovy/groovyx/javafx/factory/ContainerFactory.groovy @@ -1,5 +1,5 @@ /* - * Copyright 2011-2016 the original author or authors. + * Copyright 2011-2019 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. @@ -15,6 +15,7 @@ */ package groovyx.javafx.factory +import javafx.collections.FXCollections import javafx.scene.Node import javafx.scene.NodeBuilder import javafx.scene.Parent @@ -27,13 +28,12 @@ import javafx.scene.layout.GridPane */ class ContainerFactory extends AbstractNodeFactory { private static final String BUILDER_LIST_PROPERTY = "__builderList" - + ContainerFactory(Class beanClass) { - super(beanClass); + super(beanClass) } - - public void setChild(FactoryBuilderSupport builder, Object parent, Object child) { + void setChild(FactoryBuilderSupport builder, Object parent, Object child) { if (child instanceof Node) { if (parent instanceof BorderPane) { parent.setCenter(child) @@ -64,7 +64,7 @@ class ContainerFactory extends AbstractNodeFactory { } } } else if (child instanceof NodeBuilder) { - def builderList = builder.parentContext.get(BUILDER_LIST_PROPERTY, []) + def builderList = builder.parentContext.get(BUILDER_LIST_PROPERTY, FXCollections.observableList([])) builderList << child } else { super.setChild(builder, parent, child) diff --git a/src/main/groovy/groovyx/javafx/factory/DrawFactory.groovy b/src/main/groovy/groovyx/javafx/factory/DrawFactory.groovy index 04defd9..8a35e7c 100644 --- a/src/main/groovy/groovyx/javafx/factory/DrawFactory.groovy +++ b/src/main/groovy/groovyx/javafx/factory/DrawFactory.groovy @@ -1,5 +1,5 @@ /* - * Copyright 2011-2016 the original author or authors. + * Copyright 2011-2019 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. @@ -13,15 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ - package groovyx.javafx.factory import groovyx.javafx.canvas.CanvasOperation import groovyx.javafx.canvas.DrawOperations +import javafx.collections.FXCollections import javafx.scene.canvas.Canvas /** @@ -30,40 +26,38 @@ import javafx.scene.canvas.Canvas */ class DrawFactory extends AbstractNodeFactory { private static final String DRAW_OPERATIONS_LIST_PROPERTY = "__drawOperationsList" - + DrawFactory() { - super(DrawOperations); + super(DrawOperations) } - + DrawFactory(Class beanClass) { - super(beanClass); + super(beanClass) } - + @Override - public Object newInstance(FactoryBuilderSupport builder, Object name, Object value, Map attributes) throws InstantiationException, IllegalAccessException { - DrawOperations operations = super.newInstance(builder, name, value, attributes); - if(value instanceof Canvas) - operations.canvas = value; + Object newInstance(FactoryBuilderSupport builder, Object name, Object value, Map attributes) throws InstantiationException, IllegalAccessException { + DrawOperations operations = super.newInstance(builder, name, value, attributes) + if (value instanceof Canvas) + operations.canvas = value operations } - + @Override - public void setChild(FactoryBuilderSupport builder, Object parent, Object child) { + void setChild(FactoryBuilderSupport builder, Object parent, Object child) { if (child instanceof CanvasOperation) { - def operations = builder.parentContext.get(DRAW_OPERATIONS_LIST_PROPERTY, []) + def operations = builder.parentContext.get(DRAW_OPERATIONS_LIST_PROPERTY, FXCollections.observableList([])) operations << child - }else { - super.setChild(builder, parent, child); + } else { + super.setChild(builder, parent, child) } } - - + @Override void onNodeCompleted(FactoryBuilderSupport builder, Object parent, Object node) { node.operations = builder.context.remove(DRAW_OPERATIONS_LIST_PROPERTY) - if(node.canvas != null) + if (node.canvas != null) node.draw() super.onNodeCompleted(builder, parent, node) } } - diff --git a/src/main/groovy/groovyx/javafx/factory/SceneFactory.groovy b/src/main/groovy/groovyx/javafx/factory/SceneFactory.groovy index db3005a..785cdc5 100644 --- a/src/main/groovy/groovyx/javafx/factory/SceneFactory.groovy +++ b/src/main/groovy/groovyx/javafx/factory/SceneFactory.groovy @@ -1,5 +1,5 @@ /* - * Copyright 2011-2016 the original author or authors. + * Copyright 2011-2019 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. @@ -18,6 +18,7 @@ package groovyx.javafx.factory import groovyx.javafx.event.GroovyChangeListener import groovyx.javafx.event.GroovyEventHandler import groovyx.javafx.event.GroovyInvalidationListener +import javafx.collections.FXCollections import javafx.event.EventHandler import javafx.scene.Group import javafx.scene.Node @@ -33,19 +34,19 @@ import org.codehaus.groovy.runtime.InvokerHelper */ class SceneFactory extends AbstractFXBeanFactory { private static final String BUILDER_LIST_PROPERTY = "__builderList" - - boolean syntheticRoot = false; - + + boolean syntheticRoot = false + SceneFactory() { - super(Scene); + super(Scene) } - + SceneFactory(Class beanClass) { - super(beanClass); + super(beanClass) } - public Object newInstance(FactoryBuilderSupport builder, Object name, Object value, Map attributes) throws InstantiationException, IllegalAccessException { - Scene scene; + Object newInstance(FactoryBuilderSupport builder, Object name, Object value, Map attributes) throws InstantiationException, IllegalAccessException { + Scene scene if (checkValue(name, value)) { scene = value } else { @@ -55,93 +56,93 @@ class SceneFactory extends AbstractFXBeanFactory { def depthBuffer = attributes.remove("depthBuffer") ?: false def antiAliasing = attributes.remove("antiAliasing") ?: SceneAntialiasing.DISABLED - if(root == null) { + if (root == null) { root = new Group() syntheticRoot = true } - + scene = new Scene(root, width, height, depthBuffer, antiAliasing) } - def id = attributes.remove("id"); - if(id != null) - builder.getVariables().put(id, scene); - return scene; + def id = attributes.remove("id") + if (id != null) + builder.getVariables().put(id, scene) + return scene } - public void setChild(FactoryBuilderSupport builder, Object parent, Object child) { - Scene scene = (Scene)parent + void setChild(FactoryBuilderSupport builder, Object parent, Object child) { + Scene scene = (Scene) parent // If we have a synthetic root, then the first child Node either becomes // the root (if it's a Parent) or becomes a child of the synthetic root. // Either way, our synthetic root is no longer synthetic. - if(syntheticRoot && child instanceof Node) { - syntheticRoot = false; - if(child instanceof Parent ) { - scene.root = child; + if (syntheticRoot && child instanceof Node) { + syntheticRoot = false + if (child instanceof Parent) { + scene.root = child return } } - - switch(child) { + + switch (child) { case Node: scene.root.children.add(child) - break; + break case String: - scene.stylesheets.add(child); - break; + scene.stylesheets.add(child) + break case List: - scene.stylesheets.addAll(child.collect {it.toString()}) - break; + scene.stylesheets.addAll(child.collect { it.toString() }) + break case GroovyEventHandler: - InvokerHelper.setProperty(scene, child.property, child); - break; + InvokerHelper.setProperty(scene, child.property, child) + break case NodeBuilder: - def builderList = builder.parentContext.get(BUILDER_LIST_PROPERTY, []) + def builderList = builder.parentContext.get(BUILDER_LIST_PROPERTY, FXCollections.observableList([])) builderList << child - break; + break case GroovyChangeListener: case GroovyInvalidationListener: - if(parent.metaClass.respondsTo(parent, child.property + "Property")) - parent."${child.property}Property"().addListener(child); - break; + if (parent.metaClass.respondsTo(parent, child.property + "Property")) + parent."${child.property}Property"().addListener(child) + break } } - public boolean onHandleNodeAttributes( FactoryBuilderSupport builder, Object node, Map attributes ) { - def scene = (Scene)node + boolean onHandleNodeAttributes(FactoryBuilderSupport builder, Object node, Map attributes) { + def scene = (Scene) node def attr = attributes.remove("stylesheets") - if(attr) { - if(attr instanceof List) + if (attr) { + if (attr instanceof List) scene.stylesheets.addAll(attr) - else + else scene.stylesheets.add(attr.toString()) } - for(v in AbstractNodeFactory.nodeEvents) { - if(attributes.containsKey(v)) { - def val = attributes.remove(v); - if(val instanceof Closure) { + for (v in AbstractNodeFactory.nodeEvents) { + if (attributes.containsKey(v)) { + def val = attributes.remove(v) + if (val instanceof Closure) { FXHelper.setPropertyOrMethod(node, v, val as EventHandler) /***** - def handler = new GroovyEventHandler(v); - handler.setClosure((Closure)val); + def handler = new GroovyEventHandler(v) + handler.setClosure((Closure)val) ****/ - }else if(val instanceof EventHandler) { + } else if(val instanceof EventHandler) { FXHelper.setPropertyOrMethod(node, v, val) } } } - return super.onHandleNodeAttributes(builder, node, attributes); + return super.onHandleNodeAttributes(builder, node, attributes) } @Override void onNodeCompleted(FactoryBuilderSupport builder, Object parent, Object node) { if (node instanceof Scene && node.root == null) { - node.root = new Group(); + node.root = new Group() } - + def builderList = builder.context.remove(BUILDER_LIST_PROPERTY) builderList?.each { - node.root.children.add(it.build()); + node.root.children.add(it.build()) } } }