From d429e0a78198ed2b37e21e09a97759a4cc2bf481 Mon Sep 17 00:00:00 2001 From: Not Zed Date: Mon, 27 Feb 2023 10:52:22 +1030 Subject: [PATCH] Updates to build with OpenJDK 19 and JavaFX 19. Moved to use jakarta for JAXB. Added standalone nashorn (for now). --- .gitignore | 3 + DuskServer/src/duskz/io/Tiled.java | 20 +- DuskServer/src/duskz/io/tiled/Data.java | 51 +- DuskServer/src/duskz/io/tiled/Image.java | 65 +- DuskServer/src/duskz/io/tiled/Layer.java | 100 +- DuskServer/src/duskz/io/tiled/Map.java | 135 +- DuskServer/src/duskz/io/tiled/Object.java | 88 +- .../src/duskz/io/tiled/ObjectFactory.java | 54 +- .../src/duskz/io/tiled/Objectgroup.java | 77 +- DuskServer/src/duskz/io/tiled/Properties.java | 30 +- DuskServer/src/duskz/io/tiled/Property.java | 40 +- DuskServer/src/duskz/io/tiled/Tile.java | 55 +- DuskServer/src/duskz/io/tiled/Tileset.java | 104 +- DuskServer/src/duskz/proto/Junk.java | 26 +- .../src/duskz/server/entityz/TileMap.java | 4 +- DuskZ/src/duskz/client/fx/DuskFX.java | 5 + DuskZ/src/duskz/client/fx/EquipmentPane.java | 2 +- DuskZ/src/duskz/client/fx/MainFrameFX.java | 136 +- .../src/duskz/client/fx/TransactionPane.java | 2 +- .../jfxtras/{labs => }/animation/Timer.java | 318 ++--- .../css/CssMetaDataForSkinProperty.java | 65 + .../scene/control/skin/ListSpinnerSkin.java | 669 ++++++++++ .../internal/scene/control/ListSpinner.css | 47 - .../control/behavior/ListSpinnerBehavior.java | 167 --- .../control/skin/ListSpinnerCaspianSkin.java | 560 -------- .../scene/control/ListSpinnerIntegerList.java | 76 -- .../{labs => }/scene/control/ListSpinner.java | 1178 ++++++++--------- .../control/ListSpinnerBigIntegerList.java | 108 ++ .../scene/control/ListSpinnerIntegerList.java | 102 ++ .../layout/GenericLayoutConstraints.java | 145 ++ DuskZ/src/jfxtras/scene/layout/HBox.java | 253 ++++ DuskZ/src/jfxtras/scene/layout/VBox.java | 257 ++++ DuskZ/src/jfxtras/util/NodeUtil.java | 336 +++++ Makefile | 78 ++ README | 28 + TileZ/src/au/notzed/tilez/MapLayer.java | 14 +- TileZ/src/au/notzed/tilez/io/Data.java | 51 +- TileZ/src/au/notzed/tilez/io/Image.java | 65 +- TileZ/src/au/notzed/tilez/io/Layer.java | 100 +- TileZ/src/au/notzed/tilez/io/Map.java | 135 +- TileZ/src/au/notzed/tilez/io/Object.java | 88 +- .../src/au/notzed/tilez/io/ObjectFactory.java | 54 +- TileZ/src/au/notzed/tilez/io/Objectgroup.java | 77 +- TileZ/src/au/notzed/tilez/io/Properties.java | 30 +- TileZ/src/au/notzed/tilez/io/Property.java | 40 +- TileZ/src/au/notzed/tilez/io/Tile.java | 55 +- TileZ/src/au/notzed/tilez/io/Tileset.java | 104 +- maven.make | 77 ++ 48 files changed, 3751 insertions(+), 2523 deletions(-) create mode 100644 .gitignore rename DuskZ/src/jfxtras/{labs => }/animation/Timer.java (87%) create mode 100644 DuskZ/src/jfxtras/css/CssMetaDataForSkinProperty.java create mode 100644 DuskZ/src/jfxtras/internal/scene/control/skin/ListSpinnerSkin.java delete mode 100644 DuskZ/src/jfxtras/labs/internal/scene/control/ListSpinner.css delete mode 100644 DuskZ/src/jfxtras/labs/internal/scene/control/behavior/ListSpinnerBehavior.java delete mode 100644 DuskZ/src/jfxtras/labs/internal/scene/control/skin/ListSpinnerCaspianSkin.java delete mode 100644 DuskZ/src/jfxtras/labs/scene/control/ListSpinnerIntegerList.java rename DuskZ/src/jfxtras/{labs => }/scene/control/ListSpinner.java (81%) create mode 100644 DuskZ/src/jfxtras/scene/control/ListSpinnerBigIntegerList.java create mode 100644 DuskZ/src/jfxtras/scene/control/ListSpinnerIntegerList.java create mode 100644 DuskZ/src/jfxtras/scene/layout/GenericLayoutConstraints.java create mode 100644 DuskZ/src/jfxtras/scene/layout/HBox.java create mode 100644 DuskZ/src/jfxtras/scene/layout/VBox.java create mode 100644 DuskZ/src/jfxtras/util/NodeUtil.java create mode 100644 Makefile create mode 100644 README create mode 100644 maven.make diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..28a4d2c --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.lib/ +*/build/ +*/dist/ diff --git a/DuskServer/src/duskz/io/Tiled.java b/DuskServer/src/duskz/io/Tiled.java index 74dbcd6..c5ca39d 100644 --- a/DuskServer/src/duskz/io/Tiled.java +++ b/DuskServer/src/duskz/io/Tiled.java @@ -30,6 +30,10 @@ import duskz.io.tiled.Map; import duskz.io.tiled.Property; import duskz.io.tiled.Tile; import duskz.io.tiled.Tileset; +import jakarta.xml.bind.JAXBContext; +import jakarta.xml.bind.JAXBException; +import jakarta.xml.bind.Marshaller; +import jakarta.xml.bind.Unmarshaller; import java.awt.Graphics2D; import java.awt.image.BufferedImage; import java.io.ByteArrayInputStream; @@ -59,15 +63,9 @@ import java.util.zip.GZIPOutputStream; import javax.imageio.ImageIO; import javax.imageio.stream.ImageInputStream; import javax.imageio.stream.MemoryCacheImageInputStream; -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBException; -import javax.xml.bind.Marshaller; -import javax.xml.bind.Unmarshaller; - /** * Tiled loader/converter. This is only experimental at this stage. * - * @author notzed */ public class Tiled { @@ -280,7 +278,6 @@ public class Tiled { d.setvalue(encodeArray(bb.array())); //d.setvalue("dummy"); - try { JAXBContext jc = JAXBContext.newInstance(Map.class); //Unmarshaller u = jc.createUnmarshaller(); @@ -295,6 +292,7 @@ public class Tiled { } catch (JAXBException ex) { Logger.getLogger(Tiled.class.getName()).log(Level.SEVERE, null, ex); } + System.out.println("done"); } @@ -582,10 +580,10 @@ public class Tiled { if (twidth == 0 || theight == 0) throw new IOException("Couldn't find a layer called 'ground'"); - + System.out.printf("Found %d layers\n", nlayers); System.out.printf("Ground on layer %d\n", groundid); - // Create map + // Create map try (DataOutputStream dos = new DataOutputStream(new FileOutputStream(dst))) { // Write header dos.writeInt(TileMap.MAGIC_LAYERED); @@ -673,7 +671,7 @@ public class Tiled { //tiledToDusk(new File("/home/notzed/dusk/maps/do-drop-inn.tmx"), // new File("/home/notzed/src/DuskRPG/DuskFiles/DuskX/defMaps/do-drop-inn")); //testexport(); - tiledToDusk(new File("/home/notzed/dusk/maps/main.tmx"), - new File("/home/notzed/dusk/game/defMaps/main")); + //(new File("/home/notzed/dusk/maps/main.tmx"), + // new File("/home/notzed/dusk/game/defMaps/main")); } } diff --git a/DuskServer/src/duskz/io/tiled/Data.java b/DuskServer/src/duskz/io/tiled/Data.java index f6f9b8f..ae109f9 100644 --- a/DuskServer/src/duskz/io/tiled/Data.java +++ b/DuskServer/src/duskz/io/tiled/Data.java @@ -1,25 +1,24 @@ // -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2013.02.27 at 01:07:39 PM CST +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2013.02.27 at 01:07:39 PM CST // package duskz.io.tiled; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; -import javax.xml.bind.annotation.XmlValue; -import javax.xml.bind.annotation.adapters.NormalizedStringAdapter; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; - +import jakarta.xml.bind.annotation.XmlAccessType; +import jakarta.xml.bind.annotation.XmlAccessorType; +import jakarta.xml.bind.annotation.XmlAttribute; +import jakarta.xml.bind.annotation.XmlRootElement; +import jakarta.xml.bind.annotation.XmlType; +import jakarta.xml.bind.annotation.XmlValue; +import jakarta.xml.bind.annotation.adapters.NormalizedStringAdapter; +import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter; /** - * + * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { @@ -39,11 +38,11 @@ public class Data { /** * Gets the value of the encoding property. - * + * * @return * possible object is * {@link String } - * + * */ public String getEncoding() { return encoding; @@ -51,11 +50,11 @@ public class Data { /** * Sets the value of the encoding property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setEncoding(String value) { this.encoding = value; @@ -63,11 +62,11 @@ public class Data { /** * Gets the value of the compression property. - * + * * @return * possible object is * {@link String } - * + * */ public String getCompression() { return compression; @@ -75,11 +74,11 @@ public class Data { /** * Sets the value of the compression property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setCompression(String value) { this.compression = value; @@ -87,11 +86,11 @@ public class Data { /** * Gets the value of the value property. - * + * * @return * possible object is * {@link String } - * + * */ public String getvalue() { return value; @@ -99,11 +98,11 @@ public class Data { /** * Sets the value of the value property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setvalue(String value) { this.value = value; diff --git a/DuskServer/src/duskz/io/tiled/Image.java b/DuskServer/src/duskz/io/tiled/Image.java index 709c33e..e1d8c0e 100644 --- a/DuskServer/src/duskz/io/tiled/Image.java +++ b/DuskServer/src/duskz/io/tiled/Image.java @@ -1,24 +1,23 @@ // -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2013.02.27 at 01:07:39 PM CST +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2013.02.27 at 01:07:39 PM CST // package duskz.io.tiled; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; -import javax.xml.bind.annotation.adapters.NormalizedStringAdapter; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; - +import jakarta.xml.bind.annotation.XmlAccessType; +import jakarta.xml.bind.annotation.XmlAccessorType; +import jakarta.xml.bind.annotation.XmlAttribute; +import jakarta.xml.bind.annotation.XmlRootElement; +import jakarta.xml.bind.annotation.XmlType; +import jakarta.xml.bind.annotation.adapters.NormalizedStringAdapter; +import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter; /** - * + * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { @@ -41,11 +40,11 @@ public class Image { /** * Gets the value of the format property. - * + * * @return * possible object is * {@link String } - * + * */ public String getFormat() { return format; @@ -53,11 +52,11 @@ public class Image { /** * Sets the value of the format property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setFormat(String value) { this.format = value; @@ -65,11 +64,11 @@ public class Image { /** * Gets the value of the id property. - * + * * @return * possible object is * {@link String } - * + * */ public String getId() { return id; @@ -77,11 +76,11 @@ public class Image { /** * Sets the value of the id property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setId(String value) { this.id = value; @@ -89,11 +88,11 @@ public class Image { /** * Gets the value of the source property. - * + * * @return * possible object is * {@link String } - * + * */ public String getSource() { return source; @@ -101,11 +100,11 @@ public class Image { /** * Sets the value of the source property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setSource(String value) { this.source = value; @@ -113,11 +112,11 @@ public class Image { /** * Gets the value of the trans property. - * + * * @return * possible object is * {@link String } - * + * */ public String getTrans() { return trans; @@ -125,11 +124,11 @@ public class Image { /** * Sets the value of the trans property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setTrans(String value) { this.trans = value; @@ -137,11 +136,11 @@ public class Image { /** * Gets the value of the data property. - * + * * @return * possible object is * {@link Data } - * + * */ public Data getData() { return data; @@ -149,11 +148,11 @@ public class Image { /** * Sets the value of the data property. - * + * * @param value * allowed object is * {@link Data } - * + * */ public void setData(Data value) { this.data = value; diff --git a/DuskServer/src/duskz/io/tiled/Layer.java b/DuskServer/src/duskz/io/tiled/Layer.java index 1d52347..a9cdb40 100644 --- a/DuskServer/src/duskz/io/tiled/Layer.java +++ b/DuskServer/src/duskz/io/tiled/Layer.java @@ -1,26 +1,24 @@ // -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2013.02.27 at 01:07:39 PM CST +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2013.02.27 at 01:07:39 PM CST // package duskz.io.tiled; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; -import javax.xml.bind.annotation.adapters.CollapsedStringAdapter; -import javax.xml.bind.annotation.adapters.NormalizedStringAdapter; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; - +import jakarta.xml.bind.annotation.XmlAccessType; +import jakarta.xml.bind.annotation.XmlAccessorType; +import jakarta.xml.bind.annotation.XmlAttribute; +import jakarta.xml.bind.annotation.XmlElement; +import jakarta.xml.bind.annotation.XmlRootElement; +import jakarta.xml.bind.annotation.XmlType; +import jakarta.xml.bind.annotation.adapters.NormalizedStringAdapter; +import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter; /** - * + * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { @@ -51,11 +49,11 @@ public class Layer { /** * Gets the value of the name property. - * + * * @return * possible object is * {@link String } - * + * */ public String getName() { return name; @@ -63,11 +61,11 @@ public class Layer { /** * Sets the value of the name property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setName(String value) { this.name = value; @@ -75,11 +73,11 @@ public class Layer { /** * Gets the value of the width property. - * + * * @return * possible object is * {@link String } - * + * */ public int getWidth() { return width; @@ -87,11 +85,11 @@ public class Layer { /** * Sets the value of the width property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setWidth(int value) { this.width = value; @@ -99,11 +97,11 @@ public class Layer { /** * Gets the value of the height property. - * + * * @return * possible object is * {@link String } - * + * */ public int getHeight() { return height; @@ -111,11 +109,11 @@ public class Layer { /** * Sets the value of the height property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setHeight(int value) { this.height = value; @@ -123,11 +121,11 @@ public class Layer { /** * Gets the value of the x property. - * + * * @return * possible object is * {@link String } - * + * */ public int getX() { return x; @@ -135,11 +133,11 @@ public class Layer { /** * Sets the value of the x property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setX(int value) { this.x = value; @@ -147,11 +145,11 @@ public class Layer { /** * Gets the value of the y property. - * + * * @return * possible object is * {@link String } - * + * */ public int getY() { return y; @@ -159,11 +157,11 @@ public class Layer { /** * Sets the value of the y property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setY(int value) { this.y = value; @@ -171,11 +169,11 @@ public class Layer { /** * Gets the value of the opacity property. - * + * * @return * possible object is * {@link String } - * + * */ public float getOpacity() { return opacity; @@ -183,11 +181,11 @@ public class Layer { /** * Sets the value of the opacity property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setOpacity(float value) { this.opacity = value; @@ -195,11 +193,11 @@ public class Layer { /** * Gets the value of the visible property. - * + * * @return * possible object is * {@link String } - * + * */ public int getVisible() { return visible; @@ -207,11 +205,11 @@ public class Layer { /** * Sets the value of the visible property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setVisible(int value) { this.visible = value; @@ -219,11 +217,11 @@ public class Layer { /** * Gets the value of the properties property. - * + * * @return * possible object is * {@link Properties } - * + * */ public Properties getProperties() { return properties; @@ -231,11 +229,11 @@ public class Layer { /** * Sets the value of the properties property. - * + * * @param value * allowed object is * {@link Properties } - * + * */ public void setProperties(Properties value) { this.properties = value; @@ -243,11 +241,11 @@ public class Layer { /** * Gets the value of the data property. - * + * * @return * possible object is * {@link Data } - * + * */ public Data getData() { return data; @@ -255,11 +253,11 @@ public class Layer { /** * Sets the value of the data property. - * + * * @param value * allowed object is * {@link Data } - * + * */ public void setData(Data value) { this.data = value; diff --git a/DuskServer/src/duskz/io/tiled/Map.java b/DuskServer/src/duskz/io/tiled/Map.java index 12a6585..54d661e 100644 --- a/DuskServer/src/duskz/io/tiled/Map.java +++ b/DuskServer/src/duskz/io/tiled/Map.java @@ -1,29 +1,28 @@ // -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2013.02.27 at 01:07:39 PM CST +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2013.02.27 at 01:07:39 PM CST // package duskz.io.tiled; +import jakarta.xml.bind.annotation.XmlAccessType; +import jakarta.xml.bind.annotation.XmlAccessorType; +import jakarta.xml.bind.annotation.XmlAttribute; +import jakarta.xml.bind.annotation.XmlElement; +import jakarta.xml.bind.annotation.XmlElements; +import jakarta.xml.bind.annotation.XmlRootElement; +import jakarta.xml.bind.annotation.XmlType; +import jakarta.xml.bind.annotation.adapters.CollapsedStringAdapter; +import jakarta.xml.bind.annotation.adapters.NormalizedStringAdapter; +import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import java.util.ArrayList; import java.util.List; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElements; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; -import javax.xml.bind.annotation.adapters.CollapsedStringAdapter; -import javax.xml.bind.annotation.adapters.NormalizedStringAdapter; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; - /** - * + * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { @@ -67,11 +66,11 @@ public class Map { /** * Gets the value of the xmlns property. - * + * * @return * possible object is * {@link String } - * + * */ public String getXmlns() { return xmlns; @@ -79,11 +78,11 @@ public class Map { /** * Sets the value of the xmlns property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setXmlns(String value) { this.xmlns = value; @@ -91,11 +90,11 @@ public class Map { /** * Gets the value of the xmlnsXsi property. - * + * * @return * possible object is * {@link String } - * + * */ public String getXmlnsXsi() { return xmlnsXsi; @@ -103,11 +102,11 @@ public class Map { /** * Sets the value of the xmlnsXsi property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setXmlnsXsi(String value) { this.xmlnsXsi = value; @@ -115,11 +114,11 @@ public class Map { /** * Gets the value of the xsiSchemaLocation property. - * + * * @return * possible object is * {@link String } - * + * */ public String getXsiSchemaLocation() { return xsiSchemaLocation; @@ -127,11 +126,11 @@ public class Map { /** * Sets the value of the xsiSchemaLocation property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setXsiSchemaLocation(String value) { this.xsiSchemaLocation = value; @@ -139,11 +138,11 @@ public class Map { /** * Gets the value of the version property. - * + * * @return * possible object is * {@link String } - * + * */ public String getVersion() { return version; @@ -151,11 +150,11 @@ public class Map { /** * Sets the value of the version property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setVersion(String value) { this.version = value; @@ -163,11 +162,11 @@ public class Map { /** * Gets the value of the orientation property. - * + * * @return * possible object is * {@link String } - * + * */ public String getOrientation() { return orientation; @@ -175,11 +174,11 @@ public class Map { /** * Sets the value of the orientation property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setOrientation(String value) { this.orientation = value; @@ -187,11 +186,11 @@ public class Map { /** * Gets the value of the width property. - * + * * @return * possible object is * {@link String } - * + * */ public int getWidth() { return width; @@ -199,11 +198,11 @@ public class Map { /** * Sets the value of the width property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setWidth(int value) { this.width = value; @@ -211,11 +210,11 @@ public class Map { /** * Gets the value of the height property. - * + * * @return * possible object is * {@link String } - * + * */ public int getHeight() { return height; @@ -223,11 +222,11 @@ public class Map { /** * Sets the value of the height property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setHeight(int value) { this.height = value; @@ -235,11 +234,11 @@ public class Map { /** * Gets the value of the tilewidth property. - * + * * @return * possible object is * {@link String } - * + * */ public int getTilewidth() { return tilewidth; @@ -247,11 +246,11 @@ public class Map { /** * Sets the value of the tilewidth property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setTilewidth(int value) { this.tilewidth = value; @@ -259,11 +258,11 @@ public class Map { /** * Gets the value of the tileheight property. - * + * * @return * possible object is * {@link String } - * + * */ public int getTileheight() { return tileheight; @@ -271,11 +270,11 @@ public class Map { /** * Sets the value of the tileheight property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setTileheight(int value) { this.tileheight = value; @@ -283,11 +282,11 @@ public class Map { /** * Gets the value of the properties property. - * + * * @return * possible object is * {@link Properties } - * + * */ public Properties getProperties() { return properties; @@ -295,11 +294,11 @@ public class Map { /** * Sets the value of the properties property. - * + * * @param value * allowed object is * {@link Properties } - * + * */ public void setProperties(Properties value) { this.properties = value; @@ -307,25 +306,25 @@ public class Map { /** * Gets the value of the tileset property. - * + * *

* This accessor method returns a reference to the live list, * not a snapshot. Therefore any modification you make to the * returned list will be present inside the JAXB object. * This is why there is not a set method for the tileset property. - * + * *

* For example, to add a new item, do as follows: *

      *    getTileset().add(newItem);
      * 
- * - * + * + * *

* Objects of the following type(s) are allowed in the list * {@link Tileset } - * - * + * + * */ public List getTileset() { if (tileset == null) { @@ -336,26 +335,26 @@ public class Map { /** * Gets the value of the layerOrObjectgroup property. - * + * *

* This accessor method returns a reference to the live list, * not a snapshot. Therefore any modification you make to the * returned list will be present inside the JAXB object. * This is why there is not a set method for the layerOrObjectgroup property. - * + * *

* For example, to add a new item, do as follows: *

      *    getLayerOrObjectgroup().add(newItem);
      * 
- * - * + * + * *

* Objects of the following type(s) are allowed in the list * {@link Layer } * {@link Objectgroup } - * - * + * + * */ public List getLayerOrObjectgroup() { if (layerOrObjectgroup == null) { diff --git a/DuskServer/src/duskz/io/tiled/Object.java b/DuskServer/src/duskz/io/tiled/Object.java index fe12a79..2f65ae8 100644 --- a/DuskServer/src/duskz/io/tiled/Object.java +++ b/DuskServer/src/duskz/io/tiled/Object.java @@ -1,24 +1,24 @@ // -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2013.02.27 at 01:07:39 PM CST +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2013.02.27 at 01:07:39 PM CST // package duskz.io.tiled; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; -import javax.xml.bind.annotation.adapters.NormalizedStringAdapter; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; +import jakarta.xml.bind.annotation.XmlAccessType; +import jakarta.xml.bind.annotation.XmlAccessorType; +import jakarta.xml.bind.annotation.XmlAttribute; +import jakarta.xml.bind.annotation.XmlRootElement; +import jakarta.xml.bind.annotation.XmlType; +import jakarta.xml.bind.annotation.adapters.NormalizedStringAdapter; +import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter; /** - * + * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { @@ -47,11 +47,11 @@ public class Object { /** * Gets the value of the name property. - * + * * @return * possible object is * {@link String } - * + * */ public String getName() { return name; @@ -59,11 +59,11 @@ public class Object { /** * Sets the value of the name property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setName(String value) { this.name = value; @@ -71,11 +71,11 @@ public class Object { /** * Gets the value of the type property. - * + * * @return * possible object is * {@link String } - * + * */ public String getType() { return type; @@ -83,11 +83,11 @@ public class Object { /** * Sets the value of the type property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setType(String value) { this.type = value; @@ -95,11 +95,11 @@ public class Object { /** * Gets the value of the x property. - * + * * @return * possible object is * {@link String } - * + * */ public int getX() { return x; @@ -107,11 +107,11 @@ public class Object { /** * Sets the value of the x property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setX(int value) { this.x = value; @@ -119,11 +119,11 @@ public class Object { /** * Gets the value of the y property. - * + * * @return * possible object is * {@link String } - * + * */ public int getY() { return y; @@ -131,11 +131,11 @@ public class Object { /** * Sets the value of the y property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setY(int value) { this.y = value; @@ -143,11 +143,11 @@ public class Object { /** * Gets the value of the width property. - * + * * @return * possible object is * {@link String } - * + * */ public int getWidth() { return width; @@ -155,11 +155,11 @@ public class Object { /** * Sets the value of the width property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setWidth(int value) { this.width = value; @@ -167,11 +167,11 @@ public class Object { /** * Gets the value of the height property. - * + * * @return * possible object is * {@link String } - * + * */ public int getHeight() { return height; @@ -179,11 +179,11 @@ public class Object { /** * Sets the value of the height property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setHeight(int value) { this.height = value; @@ -191,11 +191,11 @@ public class Object { /** * Gets the value of the properties property. - * + * * @return * possible object is * {@link Properties } - * + * */ public Properties getProperties() { return properties; @@ -203,11 +203,11 @@ public class Object { /** * Sets the value of the properties property. - * + * * @param value * allowed object is * {@link Properties } - * + * */ public void setProperties(Properties value) { this.properties = value; @@ -215,11 +215,11 @@ public class Object { /** * Gets the value of the image property. - * + * * @return * possible object is * {@link Image } - * + * */ public Image getImage() { return image; @@ -227,11 +227,11 @@ public class Object { /** * Sets the value of the image property. - * + * * @param value * allowed object is * {@link Image } - * + * */ public void setImage(Image value) { this.image = value; diff --git a/DuskServer/src/duskz/io/tiled/ObjectFactory.java b/DuskServer/src/duskz/io/tiled/ObjectFactory.java index 1745074..e330cf9 100644 --- a/DuskServer/src/duskz/io/tiled/ObjectFactory.java +++ b/DuskServer/src/duskz/io/tiled/ObjectFactory.java @@ -1,29 +1,29 @@ // -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2013.02.27 at 01:07:39 PM CST +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2013.02.27 at 01:07:39 PM CST // package duskz.io.tiled; -import javax.xml.bind.annotation.XmlRegistry; +import jakarta.xml.bind.annotation.XmlRegistry; /** - * This object contains factory methods for each - * Java content interface and Java element interface - * generated in the generated package. - *

An ObjectFactory allows you to programatically - * construct new instances of the Java representation - * for XML content. The Java representation of XML - * content can consist of schema derived interfaces - * and classes representing the binding of schema - * type definitions, element declarations and model - * groups. Factory methods for each of these are + * This object contains factory methods for each + * Java content interface and Java element interface + * generated in the generated package. + *

An ObjectFactory allows you to programatically + * construct new instances of the Java representation + * for XML content. The Java representation of XML + * content can consist of schema derived interfaces + * and classes representing the binding of schema + * type definitions, element declarations and model + * groups. Factory methods for each of these are * provided in this class. - * + * */ @XmlRegistry public class ObjectFactory { @@ -31,14 +31,14 @@ public class ObjectFactory { /** * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: generated - * + * */ public ObjectFactory() { } /** * Create an instance of {@link Tileset } - * + * */ public Tileset createTileset() { return new Tileset(); @@ -46,7 +46,7 @@ public class ObjectFactory { /** * Create an instance of {@link Image } - * + * */ public Image createImage() { return new Image(); @@ -54,7 +54,7 @@ public class ObjectFactory { /** * Create an instance of {@link Tile } - * + * */ public Tile createTile() { return new Tile(); @@ -62,7 +62,7 @@ public class ObjectFactory { /** * Create an instance of {@link Properties } - * + * */ public Properties createProperties() { return new Properties(); @@ -70,7 +70,7 @@ public class ObjectFactory { /** * Create an instance of {@link Objectgroup } - * + * */ public Objectgroup createObjectgroup() { return new Objectgroup(); @@ -78,7 +78,7 @@ public class ObjectFactory { /** * Create an instance of {@link Object } - * + * */ public Object createObject() { return new Object(); @@ -86,7 +86,7 @@ public class ObjectFactory { /** * Create an instance of {@link Data } - * + * */ public Data createData() { return new Data(); @@ -94,7 +94,7 @@ public class ObjectFactory { /** * Create an instance of {@link Map } - * + * */ public Map createMap() { return new Map(); @@ -102,7 +102,7 @@ public class ObjectFactory { /** * Create an instance of {@link Layer } - * + * */ public Layer createLayer() { return new Layer(); @@ -110,7 +110,7 @@ public class ObjectFactory { /** * Create an instance of {@link Property } - * + * */ public Property createProperty() { return new Property(); diff --git a/DuskServer/src/duskz/io/tiled/Objectgroup.java b/DuskServer/src/duskz/io/tiled/Objectgroup.java index 06cb7fe..069e644 100644 --- a/DuskServer/src/duskz/io/tiled/Objectgroup.java +++ b/DuskServer/src/duskz/io/tiled/Objectgroup.java @@ -1,26 +1,25 @@ // -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2013.02.27 at 01:07:39 PM CST +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2013.02.27 at 01:07:39 PM CST // package duskz.io.tiled; +import jakarta.xml.bind.annotation.XmlAccessType; +import jakarta.xml.bind.annotation.XmlAccessorType; +import jakarta.xml.bind.annotation.XmlAttribute; +import jakarta.xml.bind.annotation.XmlRootElement; +import jakarta.xml.bind.annotation.XmlType; +import jakarta.xml.bind.annotation.adapters.NormalizedStringAdapter; +import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import java.util.ArrayList; import java.util.List; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; -import javax.xml.bind.annotation.adapters.NormalizedStringAdapter; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; - /** - * + * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { @@ -44,11 +43,11 @@ public class Objectgroup { /** * Gets the value of the name property. - * + * * @return * possible object is * {@link String } - * + * */ public String getName() { return name; @@ -56,11 +55,11 @@ public class Objectgroup { /** * Sets the value of the name property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setName(String value) { this.name = value; @@ -68,11 +67,11 @@ public class Objectgroup { /** * Gets the value of the width property. - * + * * @return * possible object is * {@link String } - * + * */ public int getWidth() { return width; @@ -80,11 +79,11 @@ public class Objectgroup { /** * Sets the value of the width property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setWidth(int value) { this.width = value; @@ -92,11 +91,11 @@ public class Objectgroup { /** * Gets the value of the height property. - * + * * @return * possible object is * {@link String } - * + * */ public int getHeight() { return height; @@ -104,11 +103,11 @@ public class Objectgroup { /** * Sets the value of the height property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setHeight(int value) { this.height = value; @@ -116,11 +115,11 @@ public class Objectgroup { /** * Gets the value of the x property. - * + * * @return * possible object is * {@link String } - * + * */ public int getX() { return x; @@ -128,11 +127,11 @@ public class Objectgroup { /** * Sets the value of the x property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setX(int value) { this.x = value; @@ -140,11 +139,11 @@ public class Objectgroup { /** * Gets the value of the y property. - * + * * @return * possible object is * {@link String } - * + * */ public int getY() { return y; @@ -152,11 +151,11 @@ public class Objectgroup { /** * Sets the value of the y property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setY(int value) { this.y = value; @@ -164,25 +163,25 @@ public class Objectgroup { /** * Gets the value of the object property. - * + * *

* This accessor method returns a reference to the live list, * not a snapshot. Therefore any modification you make to the * returned list will be present inside the JAXB object. * This is why there is not a set method for the object property. - * + * *

* For example, to add a new item, do as follows: *

      *    getObject().add(newItem);
      * 
- * - * + * + * *

* Objects of the following type(s) are allowed in the list * {@link Object } - * - * + * + * */ public List getObject() { if (object == null) { diff --git a/DuskServer/src/duskz/io/tiled/Properties.java b/DuskServer/src/duskz/io/tiled/Properties.java index 97355d8..a2bdbca 100644 --- a/DuskServer/src/duskz/io/tiled/Properties.java +++ b/DuskServer/src/duskz/io/tiled/Properties.java @@ -1,23 +1,23 @@ // -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2013.02.27 at 01:07:39 PM CST +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2013.02.27 at 01:07:39 PM CST // package duskz.io.tiled; +import jakarta.xml.bind.annotation.XmlAccessType; +import jakarta.xml.bind.annotation.XmlAccessorType; +import jakarta.xml.bind.annotation.XmlRootElement; +import jakarta.xml.bind.annotation.XmlType; import java.util.ArrayList; import java.util.List; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; /** - * + * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { @@ -30,25 +30,25 @@ public class Properties { /** * Gets the value of the property property. - * + * *

* This accessor method returns a reference to the live list, * not a snapshot. Therefore any modification you make to the * returned list will be present inside the JAXB object. * This is why there is not a set method for the property property. - * + * *

* For example, to add a new item, do as follows: *

      *    getProperty().add(newItem);
      * 
- * - * + * + * *

* Objects of the following type(s) are allowed in the list * {@link Property } - * - * + * + * */ public List getProperty() { if (property == null) { diff --git a/DuskServer/src/duskz/io/tiled/Property.java b/DuskServer/src/duskz/io/tiled/Property.java index 2cd68bb..9d115ae 100644 --- a/DuskServer/src/duskz/io/tiled/Property.java +++ b/DuskServer/src/duskz/io/tiled/Property.java @@ -1,24 +1,24 @@ // -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2013.02.27 at 01:07:39 PM CST +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2013.02.27 at 01:07:39 PM CST // package duskz.io.tiled; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; -import javax.xml.bind.annotation.adapters.NormalizedStringAdapter; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; +import jakarta.xml.bind.annotation.XmlAccessType; +import jakarta.xml.bind.annotation.XmlAccessorType; +import jakarta.xml.bind.annotation.XmlAttribute; +import jakarta.xml.bind.annotation.XmlRootElement; +import jakarta.xml.bind.annotation.XmlType; +import jakarta.xml.bind.annotation.adapters.NormalizedStringAdapter; +import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter; /** - * + * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "") @@ -34,11 +34,11 @@ public class Property { /** * Gets the value of the name property. - * + * * @return * possible object is * {@link String } - * + * */ public String getName() { return name; @@ -46,11 +46,11 @@ public class Property { /** * Sets the value of the name property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setName(String value) { this.name = value; @@ -58,11 +58,11 @@ public class Property { /** * Gets the value of the value property. - * + * * @return * possible object is * {@link String } - * + * */ public String getValue() { return value; @@ -70,11 +70,11 @@ public class Property { /** * Sets the value of the value property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setValue(String value) { this.value = value; diff --git a/DuskServer/src/duskz/io/tiled/Tile.java b/DuskServer/src/duskz/io/tiled/Tile.java index f474d71..8124af5 100644 --- a/DuskServer/src/duskz/io/tiled/Tile.java +++ b/DuskServer/src/duskz/io/tiled/Tile.java @@ -1,24 +1,21 @@ // -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2013.02.27 at 01:07:39 PM CST +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2013.02.27 at 01:07:39 PM CST // package duskz.io.tiled; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; -import javax.xml.bind.annotation.adapters.NormalizedStringAdapter; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; - +import jakarta.xml.bind.annotation.XmlAccessType; +import jakarta.xml.bind.annotation.XmlAccessorType; +import jakarta.xml.bind.annotation.XmlAttribute; +import jakarta.xml.bind.annotation.XmlRootElement; +import jakarta.xml.bind.annotation.XmlType; /** - * + * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { @@ -37,11 +34,11 @@ public class Tile { /** * Gets the value of the id property. - * + * * @return * possible object is * {@link String } - * + * */ public int getId() { return id; @@ -49,11 +46,11 @@ public class Tile { /** * Sets the value of the id property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setId(int value) { this.id = value; @@ -61,11 +58,11 @@ public class Tile { /** * Gets the value of the gid property. - * + * * @return * possible object is * {@link String } - * + * */ public String getGid() { return gid; @@ -73,11 +70,11 @@ public class Tile { /** * Sets the value of the gid property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setGid(String value) { this.gid = value; @@ -85,11 +82,11 @@ public class Tile { /** * Gets the value of the properties property. - * + * * @return * possible object is * {@link Properties } - * + * */ public Properties getProperties() { return properties; @@ -97,11 +94,11 @@ public class Tile { /** * Sets the value of the properties property. - * + * * @param value * allowed object is * {@link Properties } - * + * */ public void setProperties(Properties value) { this.properties = value; @@ -109,11 +106,11 @@ public class Tile { /** * Gets the value of the image property. - * + * * @return * possible object is * {@link Image } - * + * */ public Image getImage() { return image; @@ -121,11 +118,11 @@ public class Tile { /** * Sets the value of the image property. - * + * * @param value * allowed object is * {@link Image } - * + * */ public void setImage(Image value) { this.image = value; diff --git a/DuskServer/src/duskz/io/tiled/Tileset.java b/DuskServer/src/duskz/io/tiled/Tileset.java index f6afbf6..8451f9b 100644 --- a/DuskServer/src/duskz/io/tiled/Tileset.java +++ b/DuskServer/src/duskz/io/tiled/Tileset.java @@ -1,26 +1,26 @@ // -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2013.02.27 at 01:07:39 PM CST +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2013.02.27 at 01:07:39 PM CST // package duskz.io.tiled; +import jakarta.xml.bind.annotation.XmlAccessType; +import jakarta.xml.bind.annotation.XmlAccessorType; +import jakarta.xml.bind.annotation.XmlAttribute; +import jakarta.xml.bind.annotation.XmlRootElement; +import jakarta.xml.bind.annotation.XmlType; +import jakarta.xml.bind.annotation.adapters.NormalizedStringAdapter; +import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import java.util.ArrayList; import java.util.List; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; -import javax.xml.bind.annotation.adapters.NormalizedStringAdapter; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; /** - * + * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { @@ -52,11 +52,11 @@ public class Tileset { /** * Gets the value of the name property. - * + * * @return * possible object is * {@link String } - * + * */ public String getName() { return name; @@ -64,11 +64,11 @@ public class Tileset { /** * Sets the value of the name property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setName(String value) { this.name = value; @@ -76,11 +76,11 @@ public class Tileset { /** * Gets the value of the firstgid property. - * + * * @return * possible object is * {@link String } - * + * */ public int getFirstgid() { return firstgid; @@ -88,11 +88,11 @@ public class Tileset { /** * Sets the value of the firstgid property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setFirstgid(int value) { this.firstgid = value; @@ -100,11 +100,11 @@ public class Tileset { /** * Gets the value of the source property. - * + * * @return * possible object is * {@link String } - * + * */ public String getSource() { return source; @@ -112,11 +112,11 @@ public class Tileset { /** * Sets the value of the source property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setSource(String value) { this.source = value; @@ -124,11 +124,11 @@ public class Tileset { /** * Gets the value of the tilewidth property. - * + * * @return * possible object is * {@link String } - * + * */ public int getTilewidth() { return tilewidth; @@ -136,11 +136,11 @@ public class Tileset { /** * Sets the value of the tilewidth property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setTilewidth(int value) { this.tilewidth = value; @@ -148,11 +148,11 @@ public class Tileset { /** * Gets the value of the tileheight property. - * + * * @return * possible object is * {@link String } - * + * */ public int getTileheight() { return tileheight; @@ -160,11 +160,11 @@ public class Tileset { /** * Sets the value of the tileheight property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setTileheight(int value) { this.tileheight = value; @@ -172,11 +172,11 @@ public class Tileset { /** * Gets the value of the spacing property. - * + * * @return * possible object is * {@link String } - * + * */ public int getSpacing() { return spacing; @@ -184,11 +184,11 @@ public class Tileset { /** * Sets the value of the spacing property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setSpacing(int value) { this.spacing = value; @@ -196,11 +196,11 @@ public class Tileset { /** * Gets the value of the margin property. - * + * * @return * possible object is * {@link String } - * + * */ public String getMargin() { return margin; @@ -208,11 +208,11 @@ public class Tileset { /** * Sets the value of the margin property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setMargin(String value) { this.margin = value; @@ -220,25 +220,25 @@ public class Tileset { /** * Gets the value of the image property. - * + * *

* This accessor method returns a reference to the live list, * not a snapshot. Therefore any modification you make to the * returned list will be present inside the JAXB object. * This is why there is not a set method for the image property. - * + * *

* For example, to add a new item, do as follows: *

      *    getImage().add(newItem);
      * 
- * - * + * + * *

* Objects of the following type(s) are allowed in the list * {@link Image } - * - * + * + * */ public List getImage() { if (image == null) { @@ -249,25 +249,25 @@ public class Tileset { /** * Gets the value of the tile property. - * + * *

* This accessor method returns a reference to the live list, * not a snapshot. Therefore any modification you make to the * returned list will be present inside the JAXB object. * This is why there is not a set method for the tile property. - * + * *

* For example, to add a new item, do as follows: *

      *    getTile().add(newItem);
      * 
- * - * + * + * *

* Objects of the following type(s) are allowed in the list * {@link Tile } - * - * + * + * */ public List getTile() { if (tile == null) { diff --git a/DuskServer/src/duskz/proto/Junk.java b/DuskServer/src/duskz/proto/Junk.java index b28f67e..5ff221d 100644 --- a/DuskServer/src/duskz/proto/Junk.java +++ b/DuskServer/src/duskz/proto/Junk.java @@ -190,12 +190,6 @@ public class Junk { super.checkPackageDefinition(pkg); } - @Override - public void checkMemberAccess(Class clazz, int which) { - System.out.println("check member access: " + clazz + " " + which); - super.checkMemberAccess(clazz, which); - } - @Override public void checkPackageAccess(String pkg) { System.out.println("check package: " + pkg); @@ -297,7 +291,7 @@ public class Junk { void onBattle(Thing thing); //int getCost(); }; - + public static void main(String[] args) throws ScriptException, InterruptedException { if (true) { Thing thing = new Thing(); @@ -319,10 +313,10 @@ public class Junk { Compilable comp = ((Compilable)engine); CompiledScript cbob = comp.compile(bob); - - + + engine.eval(bob); - + engine.eval("var bob = {\n" + "cost:1,\n" + "description:'kind bob',\n" @@ -332,8 +326,8 @@ public class Junk { + "onFlee: function(thing) {" + "}" + "}\n"); - - + + engine.eval("" + "onBattle= function(thing) {" + "println('on battle!');" @@ -344,7 +338,7 @@ public class Junk { //MobScript m = ((Invocable)engine).getInterface(MobScript.class); //System.out.println("by interface"); //m.onBattle(thing); - + engine.eval("var vars = { name: 'a', type: 'shit' };"); engine.eval("function a() { println('first a'); }"); @@ -354,11 +348,11 @@ public class Junk { System.out.println("bob.cost = " + engine.eval("bob.cost")); System.out.println("bob.desc = " + engine.eval("bob.description")); - + try { Invocable iv = (Invocable)engine; iv.invokeMethod(engine.get("bob"), "onBattle", thing); - + MobScript a = ((Invocable)engine).getInterface(engine.get("bob"), MobScript.class); System.out.print("foo - "); a.onBattle(thing); @@ -366,7 +360,7 @@ public class Junk { } catch (NoSuchMethodException ex) { Logger.getLogger(Junk.class.getName()).log(Level.SEVERE, null, ex); } - + for (Entry e : engine.getBindings(ScriptContext.ENGINE_SCOPE).entrySet()) { System.out.println("`" + e.getKey() + "'= " + e.getValue() + " " + e.getValue().getClass().getName()); } diff --git a/DuskServer/src/duskz/server/entityz/TileMap.java b/DuskServer/src/duskz/server/entityz/TileMap.java index 7f55cdb..f422465 100644 --- a/DuskServer/src/duskz/server/entityz/TileMap.java +++ b/DuskServer/src/duskz/server/entityz/TileMap.java @@ -42,7 +42,7 @@ import java.util.zip.GZIPInputStream; /** * Low level map management and helpers. - * + * * Some of the helpers provide higher level functionality like path finding. * * @author notzed @@ -304,7 +304,7 @@ public class TileMap implements Iterable { public void saveAlias(File path) throws IOException { File tmp = new File(path.getParentFile(), path.getName() + ".alias~"); File file = new File(path.getParentFile(), path.getName() + ".alias"); - + // how do i preserve comments? throw new UnsupportedOperationException("Not implemented yet"); } diff --git a/DuskZ/src/duskz/client/fx/DuskFX.java b/DuskZ/src/duskz/client/fx/DuskFX.java index e7f8633..f0450b6 100644 --- a/DuskZ/src/duskz/client/fx/DuskFX.java +++ b/DuskZ/src/duskz/client/fx/DuskFX.java @@ -41,6 +41,7 @@ public class DuskFX extends Application { @Override public void start(Stage stage) { + try { frame = new MainFrameFX(); game = new Dusk(frame); @@ -59,6 +60,10 @@ public class DuskFX extends Application { stage.show(); game.startUp(); + } catch (Throwable t) { + t.printStackTrace(); + System.exit(1); + } } @Override diff --git a/DuskZ/src/duskz/client/fx/EquipmentPane.java b/DuskZ/src/duskz/client/fx/EquipmentPane.java index b57b98b..4be53b1 100644 --- a/DuskZ/src/duskz/client/fx/EquipmentPane.java +++ b/DuskZ/src/duskz/client/fx/EquipmentPane.java @@ -34,7 +34,7 @@ import javafx.scene.control.ListView; import javafx.scene.layout.HBox; import javafx.scene.layout.Priority; import javafx.scene.layout.VBox; -import jfxtras.labs.scene.control.ListSpinner; +import jfxtras.scene.control.ListSpinner; /** * Pane for a list of equipment with detail area and controls. diff --git a/DuskZ/src/duskz/client/fx/MainFrameFX.java b/DuskZ/src/duskz/client/fx/MainFrameFX.java index c82dc54..d991a78 100644 --- a/DuskZ/src/duskz/client/fx/MainFrameFX.java +++ b/DuskZ/src/duskz/client/fx/MainFrameFX.java @@ -18,12 +18,6 @@ * along with DuskZ; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/** - * Changes - * Feb-2013 Michael Zucchi - This is mostly new apart from - * a bit of the keyboard and mouse handler code and the structure of the - * rendering pass. - */ package duskz.client.fx; import duskz.client.Bookmarks; @@ -46,11 +40,10 @@ import java.util.logging.Level; import java.util.logging.Logger; import javafx.animation.Animation; import javafx.animation.FadeTransition; -import javafx.animation.FadeTransitionBuilder; import javafx.animation.Interpolator; import javafx.animation.ParallelTransition; import javafx.animation.Transition; -import javafx.animation.TranslateTransitionBuilder; +import javafx.animation.TranslateTransition; import javafx.application.Platform; import javafx.beans.value.ChangeListener; import javafx.beans.value.ObservableValue; @@ -67,7 +60,6 @@ import javafx.scene.control.Label; import javafx.scene.control.ListView; import javafx.scene.control.MenuButton; import javafx.scene.control.MenuItem; -import javafx.scene.control.MenuItemBuilder; import javafx.scene.control.PasswordField; import javafx.scene.control.Separator; import javafx.scene.control.Tab; @@ -97,13 +89,11 @@ import javafx.util.Duration; /** * This is the main JavaFX window. - * + *

* It handles all the GUI related operations. - * + *

* Prototype code herein, it needs to be split out into functional windows to * make it more manageable - * - * @author notzed */ public class MainFrameFX extends StackPane implements GUI { @@ -148,7 +138,6 @@ public class MainFrameFX extends StackPane implements GUI { //layers.setScaleX(2); //layers.setScaleY(2); - panel = new BorderPane(); panel.setMaxWidth(320); main.setRight(panel); @@ -160,15 +149,15 @@ public class MainFrameFX extends StackPane implements GUI { panel.setCenter(stats); buttons.getChildren().addAll( - attack = new MenuButton("Attack"), - action = new MenuButton("Action"), - look = new MenuButton("Look"), - get = new MenuButton("Get"), - drop = new MenuButton("Drop"), - connect = new Button("Connect"), - merchant = new Button("Merchant"), - equipment = new Button("Equipment"), - quit = new Button("Quit")); + attack = new MenuButton("Attack"), + action = new MenuButton("Action"), + look = new MenuButton("Look"), + get = new MenuButton("Get"), + drop = new MenuButton("Drop"), + connect = new Button("Connect"), + merchant = new Button("Merchant"), + equipment = new Button("Equipment"), + quit = new Button("Quit")); attack.setMaxWidth(Double.MAX_VALUE); action.setMaxWidth(Double.MAX_VALUE); @@ -226,37 +215,33 @@ public class MainFrameFX extends StackPane implements GUI { Duration dur = Duration.millis(1500); // Fade out - Transition fade = - FadeTransitionBuilder.create().node(node) - .duration(dur) - .interpolator(Interpolator.EASE_IN) - .fromValue(1) - .toValue(0) - .onFinished(new EventHandler() { + FadeTransition fade = new FadeTransition(dur, node); + fade.setInterpolator(Interpolator.EASE_IN); + fade.setFromValue(1); + fade.setToValue(0); + fade.setOnFinished(new EventHandler() { @Override public void handle(ActionEvent t) { battle.getChildren().remove(node); } - }).build(); + }); // animate randomly away from centre double a = rand.nextDouble() * Math.PI * 0.75 + direction - Math.PI * 0.375; //a = direction; - double radius = 32; double sx = Math.cos(a) * radius / 2; double sy = Math.sin(a) * radius / 2; double ex = Math.cos(a) * radius + sx; double ey = Math.sin(a) * radius + sy; - Transition move = - TranslateTransitionBuilder.create().node(node) - .duration(dur) - .interpolator(Interpolator.EASE_OUT) - .fromX(sx).fromY(sy) - .toX(ex).toY(ey) - .build(); + TranslateTransition move = new TranslateTransition(dur, node); + move.setInterpolator(Interpolator.EASE_OUT); + move.setFromX(sx); + move.setFromY(sy); + move.setToX(ex); + move.setToY(ey); final Transition t = new ParallelTransition(fade, move); @@ -306,10 +291,10 @@ public class MainFrameFX extends StackPane implements GUI { loginPane.add(l = new Label("Host"), 1, 0); GridPane.setMargin(l, li); - loginPane.add(host = new TextField(), 2, 0); + loginPane.add(host = new TextField("localhost"), 2, 0); loginPane.add(l = new Label("Port"), 1, 1); GridPane.setMargin(l, li); - loginPane.add(port = new TextField(), 2, 1); + loginPane.add(port = new TextField("7474"), 2, 1); GridPane.setHgrow(host, Priority.ALWAYS); GridPane.setHgrow(port, Priority.ALWAYS); @@ -340,7 +325,6 @@ public class MainFrameFX extends StackPane implements GUI { GridPane.setHalignment(login, HPos.CENTER); loginPane.add(login, 1, 6, 2, 1); - GridPane.setVgrow(hbox, Priority.NEVER); GridPane.setVgrow(login, Priority.NEVER); @@ -639,7 +623,6 @@ public class MainFrameFX extends StackPane implements GUI { } }); - } /** @@ -655,7 +638,7 @@ public class MainFrameFX extends StackPane implements GUI { @Override public void visitFile(String file, String text, boolean canSave) { throw new UnsupportedOperationException("Not supported yet."); - // FIXME: implement edit text, + // FIXME: implement edit text, // FIXME: sent using: appParent.outstream.writeBytes("submit "+name+"\n"); // appParent.outstream.writeBytes(txtEdit.getText()+"\n--EOF--\n"); } @@ -686,18 +669,18 @@ public class MainFrameFX extends StackPane implements GUI { if (game.isLoaded()) { Direction dir = null; switch (nkey) { - case UP: - dir = Direction.North; - break; - case DOWN: - dir = Direction.South; - break; - case LEFT: - dir = Direction.West; - break; - case RIGHT: - dir = Direction.East; - break; + case UP: + dir = Direction.North; + break; + case DOWN: + dir = Direction.South; + break; + case LEFT: + dir = Direction.West; + break; + case RIGHT: + dir = Direction.East; + break; } if (dir != null) { game.move(dir); @@ -718,8 +701,8 @@ public class MainFrameFX extends StackPane implements GUI { /** * Map coordinates to screen-relative tiles and pass to game. */ - int x = (int) evt.getX(); - int y = (int) evt.getY(); + int x = (int)evt.getX(); + int y = (int)evt.getY(); int destX = (x / game.getTileSize()) + game.getMapOffsetX(); int destY = (y / game.getTileSize()) + game.getMapOffsetY(); @@ -729,28 +712,28 @@ public class MainFrameFX extends StackPane implements GUI { }; EventHandler attackHandler = new EventHandler() { public void handle(ActionEvent t) { - game.attack((Entity) ((MenuItem) t.getSource()).getUserData()); + game.attack((Entity)((MenuItem)t.getSource()).getUserData()); } }; EventHandler lookHandler = new EventHandler() { public void handle(ActionEvent t) { - game.look((Entity) ((MenuItem) t.getSource()).getUserData()); + game.look((Entity)((MenuItem)t.getSource()).getUserData()); } }; EventHandler actionHandler = new EventHandler() { public void handle(ActionEvent t) { - MenuItem mi = (MenuItem) t.getSource(); + MenuItem mi = (MenuItem)t.getSource(); game.command(mi.getText()); } }; EventHandler getHandler = new EventHandler() { public void handle(ActionEvent t) { - game.take((Entity) ((MenuItem) t.getSource()).getUserData()); + game.take((Entity)((MenuItem)t.getSource()).getUserData()); } }; EventHandler dropHandler = new EventHandler() { public void handle(ActionEvent t) { - game.drop(((MenuItem) t.getSource()).getText()); + game.drop(((MenuItem)t.getSource()).getText()); } }; @@ -783,10 +766,11 @@ public class MainFrameFX extends StackPane implements GUI { void setStringMenu(final MenuButton menu, List list, EventHandler handle) { final List items = new ArrayList<>(); - MenuItemBuilder mib = MenuItemBuilder.create().onAction(handle); - for (String e : list) { - items.add(mib.text(e).build()); + for (String e: list) { + MenuItem mi = new MenuItem(e); + mi.setOnAction(handle); + items.add(mi); } Platform.runLater(new Runnable() { @Override @@ -798,10 +782,12 @@ public class MainFrameFX extends StackPane implements GUI { void setEntityMenu(final MenuButton menu, List list, EventHandler handle) { final List items = new ArrayList<>(); - MenuItemBuilder mib = MenuItemBuilder.create().onAction(handle); - for (Entity e : list) { - items.add(mib.userData(e).text(e.getIndexedName()).build()); + for (Entity e: list) { + MenuItem mi = new MenuItem(e.getIndexedName()); + mi.setUserData(e); + mi.setOnAction(handle); + items.add(mi); } Platform.runLater(new Runnable() { public void run() { @@ -876,7 +862,7 @@ public class MainFrameFX extends StackPane implements GUI { try { System.out.println("set tile image"); // FIXME: put sprites into data manager - data = new DataManagerFX("/home/notzed/house.jar"); + data = new DataManagerFX("tileset.jar"); data.open(); //tileImage = new Image(tiles, false); this.tileSize = tileSize; @@ -915,7 +901,7 @@ public class MainFrameFX extends StackPane implements GUI { anims[1] = data.createTile(304, 0, 0, tileSize, tileSize).getViewport(); final List animated = new ArrayList<>(); - // Build map + // Build map for (int l = 0; l < levelCount; l++) { for (int y = 0; y < map.rows; y++) { // Draw tiles first for whole row @@ -935,7 +921,7 @@ public class MainFrameFX extends StackPane implements GUI { for (int x = 0; x < map.cols; x++) { Collection ents = map.getEntities(x + map.offx, y + map.offy); if (ents != null) { - for (Entity e : ents) { + for (Entity e: ents) { drawEntity(e, map.offx, map.offy, children, upper); } } @@ -948,7 +934,6 @@ public class MainFrameFX extends StackPane implements GUI { //for (Entity e : map.getEntities()) { // drawEntity(map.offx, map.offy, children, e); //} - Platform.runLater(new Runnable() { @Override public void run() { @@ -973,12 +958,11 @@ public class MainFrameFX extends StackPane implements GUI { double y = e.locy - offy; // TODO: just make it an entity node - if (e.intStep == -1) { // Hack: sprites are 64x64 ImageView iv = new ImageView(spriteImage); iv.setViewport(new Rectangle2D(e.intImage * spriteSize, 0, - spriteSize, spriteSize)); + spriteSize, spriteSize)); iv.relocate((x * tileSize) - tileSize / 2, (y * tileSize) - tileSize / 2); iv.setScaleX(0.5); iv.setScaleY(0.5); @@ -987,7 +971,7 @@ public class MainFrameFX extends StackPane implements GUI { } else { ImageView iv = new ImageView(playerImage); iv.setViewport(new Rectangle2D((e.intImage * 8 + e.intStep) * spriteSize, 0, - spriteSize, spriteSize)); + spriteSize, spriteSize)); iv.relocate((x * tileSize) + tileSize / 2 - spriteSize / 2, (y * tileSize) - spriteSize / 2); iv.setScaleX(1); iv.setScaleY(1); diff --git a/DuskZ/src/duskz/client/fx/TransactionPane.java b/DuskZ/src/duskz/client/fx/TransactionPane.java index 637b6f6..62b90ce 100644 --- a/DuskZ/src/duskz/client/fx/TransactionPane.java +++ b/DuskZ/src/duskz/client/fx/TransactionPane.java @@ -34,7 +34,7 @@ import javafx.scene.control.cell.PropertyValueFactory; import javafx.scene.layout.HBox; import javafx.scene.layout.Priority; import javafx.scene.layout.VBox; -import jfxtras.labs.scene.control.ListSpinner; +import jfxtras.scene.control.ListSpinner; /** * diff --git a/DuskZ/src/jfxtras/labs/animation/Timer.java b/DuskZ/src/jfxtras/animation/Timer.java similarity index 87% rename from DuskZ/src/jfxtras/labs/animation/Timer.java rename to DuskZ/src/jfxtras/animation/Timer.java index f7a56fd..d9651c7 100644 --- a/DuskZ/src/jfxtras/labs/animation/Timer.java +++ b/DuskZ/src/jfxtras/animation/Timer.java @@ -1,155 +1,163 @@ -/** - * Copyright (c) 2011, JFXtras - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package jfxtras.labs.animation; - -import java.util.TimerTask; -import java.util.concurrent.atomic.AtomicReference; - -import javafx.application.Platform; -import javafx.beans.property.ObjectProperty; -import javafx.beans.property.SimpleObjectProperty; -import javafx.util.Duration; - -/** - * A timer class in the spirit of java.swing.Timer but using JavaFX properties. - * - * @author Tom Eugelink - * - */ -public class Timer -{ - // ================================================================================================================== - // CONSTRUCTOR - - /** - * - * @param runnable - */ - public Timer(Runnable runnable) - { - this(true, runnable); - } - - /** - * - * @param isDaemon - * @param runnable - */ - public Timer(boolean isDaemon, final Runnable runnable) - { - this.runnable = runnable; - timer = new java.util.Timer(isDaemon); - } - final private Runnable runnable; - final private java.util.Timer timer; - - // ================================================================================================================== - // PROPERTIES - - /** delay: initial delay */ - public ObjectProperty delayProperty() { return this.delayObjectProperty; } - final private ObjectProperty delayObjectProperty = new SimpleObjectProperty(this, "delay", Duration.millis(0)); - public Duration getDelay() { return this.delayObjectProperty.getValue(); } - public void setDelay(Duration value) { this.delayObjectProperty.setValue(value); } - public Timer withDelay(Duration value) { setDelay(value); return this; } - - /** cycleDuration: time between fires */ - public ObjectProperty cycleDurationProperty() { return this.cycleDurationObjectProperty; } - final private ObjectProperty cycleDurationObjectProperty = new SimpleObjectProperty(this, "cycleDuration", Duration.millis(1000)); - public Duration getCycleDuration() { return this.cycleDurationObjectProperty.getValue(); } - public void setCycleDuration(Duration value) { this.cycleDurationObjectProperty.setValue(value); } - public Timer withCycleDuration(Duration value) { setCycleDuration(value); return this; } - - /** repeats: If flag is false, instructs the Timer to send only one action event to its listeners. */ - public ObjectProperty repeatsProperty() { return this.repeatsObjectProperty; } - final private ObjectProperty repeatsObjectProperty = new SimpleObjectProperty(this, "repeats", Boolean.TRUE); - public boolean getRepeats() { return this.repeatsObjectProperty.getValue(); } - public void setRepeats(boolean value) { this.repeatsObjectProperty.setValue(value); } - public Timer withRepeats(boolean value) { setRepeats(value); return this; } - - - // ================================================================================================================== - // TIMER - - /** - * Start the timer - */ - synchronized public Timer start() - { - // check if the timer is already running - if (timerTaskAtomicReference.get() != null) throw new IllegalStateException("Timer already started"); - - // create a task and schedule it - final TimerTask lTimerTask = new TimerTask() - { - @Override - public void run() - { - Platform.runLater(runnable); - if (repeatsObjectProperty.getValue().booleanValue() == false) - { - stop(); - } - } - }; - timer.schedule(lTimerTask, (long)this.delayObjectProperty.getValue().toMillis(), (long)this.cycleDurationObjectProperty.getValue().toMillis()); - - // remember for future reference - timerTaskAtomicReference.set(lTimerTask); - - // for chaining - return this; - } - final private AtomicReference timerTaskAtomicReference = new AtomicReference(null); - - /** - * stop the timer if running - */ - public Timer stop() - { - TimerTask lTimerTask = timerTaskAtomicReference.getAndSet(null); - if (lTimerTask != null) - { - lTimerTask.cancel(); - } - - // for chaining - return this; - } - - /** - * restart the timer - */ - public Timer restart() - { - stop(); - start(); - - // for chaining - return this; - } -} +/** + * Copyright (c) 2011-2021, JFXtras + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the organization nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL JFXTRAS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package jfxtras.animation; + +import java.util.TimerTask; +import java.util.concurrent.atomic.AtomicReference; + +import javafx.application.Platform; +import javafx.beans.property.ObjectProperty; +import javafx.beans.property.SimpleObjectProperty; +import javafx.util.Duration; + +/** + * A timer class in the spirit of java.swing.Timer but using JavaFX properties. + * + * @author Tom Eugelink + * + */ +public class Timer +{ + // ================================================================================================================== + // CONSTRUCTOR + + /** + * + * @param runnable + */ + public Timer(Runnable runnable) + { + this(true, runnable); + } + + /** + * + * @param isDaemon + * @param runnable + */ + public Timer(boolean isDaemon, final Runnable runnable) + { + this.runnable = runnable; + this.isDaemon = isDaemon; + } + final private Runnable runnable; + final private boolean isDaemon; + volatile private java.util.Timer timer; + + // ================================================================================================================== + // PROPERTIES + + /** delay: initial delay */ + public ObjectProperty delayProperty() { return this.delayObjectProperty; } + final private ObjectProperty delayObjectProperty = new SimpleObjectProperty(this, "delay", Duration.millis(0)); + public Duration getDelay() { return this.delayObjectProperty.getValue(); } + public void setDelay(Duration value) { this.delayObjectProperty.setValue(value); } + public Timer withDelay(Duration value) { setDelay(value); return this; } + + /** cycleDuration: time between fires */ + public ObjectProperty cycleDurationProperty() { return this.cycleDurationObjectProperty; } + final private ObjectProperty cycleDurationObjectProperty = new SimpleObjectProperty(this, "cycleDuration", Duration.millis(1000)); + public Duration getCycleDuration() { return this.cycleDurationObjectProperty.getValue(); } + public void setCycleDuration(Duration value) { this.cycleDurationObjectProperty.setValue(value); } + public Timer withCycleDuration(Duration value) { setCycleDuration(value); return this; } + + /** repeats: If flag is false, instructs the Timer to send only one action event to its listeners. */ + public ObjectProperty repeatsProperty() { return this.repeatsObjectProperty; } + final private ObjectProperty repeatsObjectProperty = new SimpleObjectProperty(this, "repeats", Boolean.TRUE); + public boolean getRepeats() { return this.repeatsObjectProperty.getValue(); } + public void setRepeats(boolean value) { this.repeatsObjectProperty.setValue(value); } + public Timer withRepeats(boolean value) { setRepeats(value); return this; } + + + // ================================================================================================================== + // TIMER + + /** + * Start the timer + */ + synchronized public Timer start() + { + // check if the timer is already running + if (timerTaskAtomicReference.get() != null) throw new IllegalStateException("Timer already started"); + + // create a task and schedule it + final TimerTask lTimerTask = new TimerTask() + { + @Override + public void run() + { + Platform.runLater(runnable); + if (repeatsObjectProperty.getValue().booleanValue() == false) + { + stop(); + } + } + }; + if (timer == null) { + timer = new java.util.Timer(isDaemon); + } + timer.schedule(lTimerTask, (long)this.delayObjectProperty.getValue().toMillis(), (long)this.cycleDurationObjectProperty.getValue().toMillis()); + + // remember for future reference + timerTaskAtomicReference.set(lTimerTask); + + // for chaining + return this; + } + final private AtomicReference timerTaskAtomicReference = new AtomicReference(null); + + /** + * stop the timer if running + */ + public Timer stop() + { + TimerTask lTimerTask = timerTaskAtomicReference.getAndSet(null); + if (lTimerTask != null) + { + lTimerTask.cancel(); + } + if (timer != null) { + timer.cancel(); + timer = null; + } + + // for chaining + return this; + } + + /** + * restart the timer + */ + public Timer restart() + { + stop(); + start(); + + // for chaining + return this; + } +} diff --git a/DuskZ/src/jfxtras/css/CssMetaDataForSkinProperty.java b/DuskZ/src/jfxtras/css/CssMetaDataForSkinProperty.java new file mode 100644 index 0000000..c33c509 --- /dev/null +++ b/DuskZ/src/jfxtras/css/CssMetaDataForSkinProperty.java @@ -0,0 +1,65 @@ +/** + * Copyright (c) 2011-2021, JFXtras + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the organization nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL JFXTRAS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package jfxtras.css; + +import javafx.css.CssMetaData; +import javafx.css.StyleConverter; +import javafx.css.Styleable; +import javafx.css.StyleableProperty; +import javafx.scene.control.Control; +import javafx.scene.control.Skin; + +/** + * Creating CssMetaData for a property in a skin has some casting, this class hides that away. + * + * @param + * @param + * @param + */ +public abstract class CssMetaDataForSkinProperty, V> extends CssMetaData { + + protected CssMetaDataForSkinProperty(String cssId, StyleConverter styleConverter, V initialValue) { + super(cssId, styleConverter, initialValue); + } + + public V getInitialValue() { + return super.getInitialValue(null); + } + + @Override public boolean isSettable(S n) { + Control c = (Control)n; + SK s = (SK)c.getSkin(); + return !getProperty(s).isBound(); + } + @Override public StyleableProperty getStyleableProperty(S n) { + Control c = (Control)n; + SK s = (SK)c.getSkin(); + return (StyleableProperty)getProperty(s); + } + + abstract protected javafx.beans.property.Property getProperty(SK s); +} diff --git a/DuskZ/src/jfxtras/internal/scene/control/skin/ListSpinnerSkin.java b/DuskZ/src/jfxtras/internal/scene/control/skin/ListSpinnerSkin.java new file mode 100644 index 0000000..f58f453 --- /dev/null +++ b/DuskZ/src/jfxtras/internal/scene/control/skin/ListSpinnerSkin.java @@ -0,0 +1,669 @@ +/** + * Copyright (c) 2011-2021, JFXtras + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the organization nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL JFXTRAS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package jfxtras.internal.scene.control.skin; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import javafx.beans.InvalidationListener; +import javafx.beans.Observable; +import javafx.beans.property.ObjectProperty; +import javafx.beans.value.ChangeListener; +import javafx.beans.value.ObservableValue; +import javafx.css.CssMetaData; +import javafx.css.SimpleStyleableObjectProperty; +import javafx.css.Styleable; +import javafx.event.ActionEvent; +import javafx.event.EventHandler; +import javafx.geometry.Point2D; +import javafx.geometry.Pos; +import javafx.scene.Node; +import javafx.scene.control.SkinBase; +import javafx.scene.control.TextField; +import javafx.scene.input.KeyCode; +import javafx.scene.input.KeyEvent; +import javafx.scene.input.MouseEvent; +import javafx.scene.layout.BorderPane; +import javafx.scene.layout.ColumnConstraints; +import javafx.scene.layout.Priority; +import javafx.scene.layout.Region; +import javafx.scene.layout.RowConstraints; +import javafx.util.Callback; +import javafx.util.Duration; +import jfxtras.animation.Timer; +import jfxtras.css.CssMetaDataForSkinProperty; +import jfxtras.scene.control.ListSpinner; +import jfxtras.scene.layout.HBox; +import jfxtras.scene.layout.VBox; +import jfxtras.util.NodeUtil; + +import javafx.css.converter.EnumConverter; + +/** + * + * @author Tom Eugelink + * + * Possible extension: drop down list or grid for quick selection + */ +public class ListSpinnerSkin extends SkinBase> +{ + // TODO: vertical centering + + // ================================================================================================================== + // CONSTRUCTOR + + /** + * + */ + public ListSpinnerSkin(ListSpinner control) + { + super(control); + construct(); + } + + /* + * + */ + private void construct() + { + // setup component + createNodes(); + + // react to value changes in the model + getSkinnable().editableProperty().addListener( (ObservableValue observable, Boolean oldValue, Boolean newValue) -> { + replaceValueNode(); + }); + replaceValueNode(); + + // react to value changes in the model + getSkinnable().valueProperty().addListener( (ObservableValue observable, T oldValue, T newValue) -> { + refreshValue(); + }); + refreshValue(); + + // react to value changes in the model + setArrowCSS(); + layout(); + + // react to value changes in the model + alignValue(); + } + + /* + * + */ + private void refreshValue() + { + // if editable + if (getSkinnable().isEditable() == true) + { + // update textfield + T lValue = getSkinnable().getValue(); + textField.setText( getSkinnable().getPrefix() + getSkinnable().getStringConverter().toString(lValue) + getSkinnable().getPostfix() ); + } + else + { + // get node for this value + getSkinnable().getCellFactory().call( getSkinnable() ); + } + } + + // ================================================================================================================== + // StyleableProperties + + /** + * arrowPosition + */ + public final ObjectProperty arrowPositionProperty() { return arrowPosition; } + private ObjectProperty arrowPosition = new SimpleStyleableObjectProperty(StyleableProperties.ARROW_POSITION, this, "arrowPosition", StyleableProperties.ARROW_POSITION.getInitialValue(null)) { + { // anonymous constructor + addListener( (invalidationEvent) -> { + setArrowCSS(); + layout(); + }); + } + }; + public final void setArrowPosition(ArrowPosition value) { arrowPositionProperty().set(value); } + public final ArrowPosition getArrowPosition() { return arrowPosition.get(); } + public final ListSpinnerSkin withArrowPosition(ArrowPosition value) { setArrowPosition(value); return this; } + public enum ArrowPosition {LEADING, TRAILING, SPLIT} + + /** + * arrowDirection + */ + public final ObjectProperty arrowDirectionProperty() { return arrowDirection; } + private ObjectProperty arrowDirection = new SimpleStyleableObjectProperty(StyleableProperties.ARROW_DIRECTION, this, "arrowDirection", StyleableProperties.ARROW_DIRECTION.getInitialValue(null)) { + { // anonymous constructor + addListener( (invalidationEvent) -> { + setArrowCSS(); + layout(); + }); + } + }; + public final void setArrowDirection(ArrowDirection value) { arrowDirectionProperty().set(value); } + public final ArrowDirection getArrowDirection() { return arrowDirection.get(); } + public final ListSpinnerSkin withArrowDirection(ArrowDirection value) { setArrowDirection(value); return this; } + public enum ArrowDirection {VERTICAL, HORIZONTAL} + + /** + * valueAlignment + */ + public final ObjectProperty valueAlignmentProperty() { return valueAlignment; } + private ObjectProperty valueAlignment = new SimpleStyleableObjectProperty(StyleableProperties.VALUE_ALIGNMENT, this, "valueAlignment", StyleableProperties.VALUE_ALIGNMENT.getInitialValue(null)) { + { // anonymous constructor + addListener( (invalidationEvent) -> { + alignValue(); + }); + } + }; + public final void setValueAlignment(Pos value) { valueAlignmentProperty().set(value); } + public final Pos getValueAlignment() { return valueAlignment.get(); } + public final ListSpinnerSkin withValueAlignment(Pos value) { setValueAlignment(value); return this; } + + // ------------------------- + + private static class StyleableProperties + { + private static final CssMetaData, ArrowPosition> ARROW_POSITION = new CssMetaDataForSkinProperty, ListSpinnerSkin, ArrowPosition>("-fxx-arrow-position", new EnumConverter(ArrowPosition.class), ArrowPosition.TRAILING ) { + @Override + protected ObjectProperty getProperty(ListSpinnerSkin s) { + return s.arrowPositionProperty(); + } + }; + + private static final CssMetaData, ArrowDirection> ARROW_DIRECTION = new CssMetaDataForSkinProperty, ListSpinnerSkin, ArrowDirection>("-fxx-arrow-direction", new EnumConverter(ArrowDirection.class), ArrowDirection.HORIZONTAL ) { + @Override + protected ObjectProperty getProperty(ListSpinnerSkin s) { + return s.arrowDirectionProperty(); + } + }; + + private static final CssMetaData, Pos> VALUE_ALIGNMENT = new CssMetaDataForSkinProperty, ListSpinnerSkin, Pos>("-fxx-value-alignment", new EnumConverter(Pos.class), Pos.CENTER_LEFT ) { + @Override + protected ObjectProperty getProperty(ListSpinnerSkin s) { + return s.valueAlignmentProperty(); + } + }; + + private static final List> STYLEABLES; + static { + final List> styleables = new ArrayList>(SkinBase.getClassCssMetaData()); + styleables.add(ARROW_POSITION); + styleables.add(ARROW_DIRECTION); + styleables.add(VALUE_ALIGNMENT); + STYLEABLES = Collections.unmodifiableList(styleables); + } + } + + /** + * @return The CssMetaData associated with this class, which may include the + * CssMetaData of its super classes. + */ + public static List> getClassCssMetaData() { + return StyleableProperties.STYLEABLES; + } + + /** + * This method should delegate to {@link Node#getClassCssMetaData()} so that + * a Node's CssMetaData can be accessed without the need for reflection. + * @return The CssMetaData associated with this node, which may include the + * CssMetaData of its super classes. + */ + public List> getCssMetaData() { + return getClassCssMetaData(); + } + + // ================================================================================================================== + // DRAW + + /** + * Construct the nodes. + * Spinner uses a GridPane where the arrows and the node for the value are laid out according to the arrows direction and location. + * A place holder in inserted into the GridPane to hold the value node, so the spinner can alternate between editable or readonly mode, without having to recreate the GridPane. + */ + private void createNodes() + { + // left arrow + decrementArrow = new Region(); + decrementArrow.getStyleClass().add("idle"); + + // place holder for showing the value + valueHolderNode = new BorderPane(); + valueHolderNode.getStyleClass().add("valuePane"); + //valueHolderNode.setStyle("-fx-border-color: white;"); + + // right arrow + incrementArrow = new Region(); + incrementArrow.getStyleClass().add("idle"); + + // construct a placeholder node + skinNode = new BorderPane(); + skinNode.setCenter(valueHolderNode); + + // we're not catching the mouse events on the individual children, but let it bubble up to the parent and handle it there, this makes our life much more simple + // process mouse clicks + skinNode.setOnMouseClicked( (mouseEvent) -> { + + // if click was the in the greater vicinity of the decrement arrow + if (mouseEventOverArrow(mouseEvent, decrementArrow)) + { + // left + NodeUtil.addStyleClass(decrementArrow, "clicked"); + NodeUtil.removeStyleClass(incrementArrow, "clicked"); + getSkinnable().decrement(); + unclickTimer.restart(); + return; + } + + // if click was the in the greater vicinity of the increment arrow + if (mouseEventOverArrow(mouseEvent, incrementArrow)) + { + // right + NodeUtil.removeStyleClass(decrementArrow, "clicked"); + NodeUtil.addStyleClass(incrementArrow, "clicked"); + getSkinnable().increment(); + unclickTimer.restart(); + return; + } + }); + // process mouse holds + skinNode.setOnMousePressed( evt -> { + + // if click was the in the greater vicinity of the decrement arrow + if (mouseEventOverArrow(evt, decrementArrow)) + { + // left + decrementArrow.getStyleClass().add("clicked"); + repeatDecrementClickTimer.restart(); + } + + // if click was the in the greater vicinity of the increment arrow + else if (mouseEventOverArrow(evt, incrementArrow)) + { + // right + incrementArrow.getStyleClass().add("clicked"); + repeatIncrementClickTimer.restart(); + return; + } + + // if a control does not have the focus, request focus + ListSpinner lControl = getSkinnable(); + if (!lControl.isFocused() && lControl.isFocusTraversable()) { + lControl.requestFocus(); + } + }); + skinNode.setOnMouseReleased( evt -> { + unclickArrows(); + repeatDecrementClickTimer.stop(); + repeatIncrementClickTimer.stop(); + }); + skinNode.setOnMouseExited( evt -> { + unclickArrows(); + repeatDecrementClickTimer.stop(); + repeatIncrementClickTimer.stop(); + }); + // mouse wheel + skinNode.setOnScroll( evt -> { + // if click was the in the greater vicinity of the decrement arrow + if (evt.getDeltaY() < 0 || evt.getDeltaX() < 0) + { + // left + NodeUtil.addStyleClass(decrementArrow, "clicked"); + NodeUtil.removeStyleClass(incrementArrow, "clicked"); + getSkinnable().decrement(); + unclickTimer.restart(); + return; + } + + // if click was the in the greater vicinity of the increment arrow + if (evt.getDeltaY() > 0 || evt.getDeltaX() > 0) + { + // right + NodeUtil.removeStyleClass(decrementArrow, "clicked"); + NodeUtil.addStyleClass(incrementArrow, "clicked"); + getSkinnable().increment(); + unclickTimer.restart(); + return; + } + }); + + // key events + getSkinnable().onKeyTypedProperty().set( keyEvent -> { + KeyCode lKeyCode = keyEvent.getCode(); + if ( KeyCode.MINUS.equals(lKeyCode) + || KeyCode.SUBTRACT.equals(lKeyCode) + || KeyCode.DOWN.equals(lKeyCode) + || KeyCode.LEFT.equals(lKeyCode) + ) { + getSkinnable().decrement(); + } + if ( KeyCode.PLUS.equals(lKeyCode) + || KeyCode.ADD.equals(lKeyCode) + || KeyCode.UP.equals(lKeyCode) + || KeyCode.RIGHT.equals(lKeyCode) + ) { + getSkinnable().increment(); + } + }); + + // add to self + getSkinnable().getStyleClass().add(this.getClass().getSimpleName()); // always add self as style class, because CSS should relate to the skin not the control + getChildren().add(skinNode); + } + private Region decrementArrow = null; + private Region incrementArrow = null; + private BorderPane skinNode = null; + private BorderPane valueHolderNode; + + // timer to remove the click styling on the arrows after a certain delay + final private Timer unclickTimer = new Timer( () -> { + unclickArrows(); + }).withDelay(Duration.millis(100)).withRepeats(false); + + // timer to handle the holding of the decrement button + final private Timer repeatDecrementClickTimer = new Timer( () -> { + getSkinnable().decrement(); + }).withDelay(Duration.millis(500)).withCycleDuration(Duration.millis(50)); + + // timer to handle the holding of the increment button + final private Timer repeatIncrementClickTimer = new Timer( () -> { + getSkinnable().increment(); + }).withDelay(Duration.millis(500)).withCycleDuration(Duration.millis(50)); + + /** + * Check if the mouse event is considered to have happened over the arrow + * @param evt + * @param region + * @return + */ + private boolean mouseEventOverArrow(MouseEvent evt, Region region) + { + // if click was the in the greater vicinity of the arrow + Point2D lClickInRelationToArrow = region.sceneToLocal(evt.getSceneX(), evt.getSceneY()); + if ( lClickInRelationToArrow.getX() >= 0.0 && lClickInRelationToArrow.getX() <= region.getWidth() + && lClickInRelationToArrow.getY() >= 0.0 && lClickInRelationToArrow.getY() <= region.getHeight() + ) + { + return true; + } + return false; + } + + /** + * Remove clicked CSS styling from the arrows + */ + private void unclickArrows() + { + decrementArrow.getStyleClass().remove("clicked"); + incrementArrow.getStyleClass().remove("clicked"); + } + + /** + * Put the correct node for the value's place holder: + * - either the TextField when in editable mode, + * - or a node generated by the cell factory when in readonly mode. + */ + private void replaceValueNode() + { + // clear + valueHolderNode.getChildren().clear(); + + // if not editable + if (getSkinnable().isEditable() == false) + { + // use the cell factory + Node lNode = getSkinnable().getCellFactory().call(getSkinnable()); + //lNode.setStyle("-fx-border-color: blue;"); + valueHolderNode.setCenter(lNode); + if (lNode.getStyleClass().contains("value") == false) lNode.getStyleClass().add("value"); + if (lNode.getStyleClass().contains("readonly") == false) lNode.getStyleClass().add("readonly"); + } + else + { + // use the textfield + if (textField == null) + { + textField = new TextField(); + textField.getStyleClass().add("value"); + textField.getStyleClass().add("editable"); + + // process text entry + textField.focusedProperty().addListener(new InvalidationListener() + { + @Override + public void invalidated(Observable arg0) + { + if (textField.isFocused() == false) + { + parse(textField); + } + } + }); + textField.setOnAction( (actionEvent) -> { + parse(textField); + }); + textField.setOnKeyPressed( (keyEvent) -> { + if (keyEvent.getCode() == KeyCode.ESCAPE) + { + // refresh + refreshValue(); + } + }); + + // alignment + textField.alignmentProperty().bind(valueAlignmentProperty()); + } + valueHolderNode.setCenter(textField); + //textField.setStyle("-fx-border-color: blue;"); + } + + // align + alignValue(); + } + private TextField textField = null; + + /** + * align the value inside the plave holder + */ + private void alignValue() + { + // valueHolderNode always only holds one child (the value) + BorderPane.setAlignment(valueHolderNode.getChildren().get(0), valueAlignmentProperty().getValue()); + } + + // ================================================================================================================== + // EDITABLE + + /** + * Parse the contents of the textfield + * @param textField + */ + protected void parse(TextField textField) + { + // get the text to parse + String lText = textField.getText(); + + // process it + parse(lText); + + // refresh + refreshValue(); + return; + } + + /** + * Lays out the spinner, depending on the location and direction of the arrows. + */ + private void layout() + { + // get the things we decide on + ArrowDirection lArrowDirection = getArrowDirection(); + ArrowPosition lArrowPosition = getArrowPosition(); + + // get helper values + ColumnConstraints lColumnValue = new ColumnConstraints(valueHolderNode.getMinWidth(), valueHolderNode.getPrefWidth(), Double.MAX_VALUE); + lColumnValue.setHgrow(Priority.ALWAYS); + + // get helper values + RowConstraints lRowValue = new RowConstraints(valueHolderNode.getMinHeight(), valueHolderNode.getPrefHeight(), Double.MAX_VALUE); + lRowValue.setVgrow(Priority.ALWAYS); + + // create the grid + skinNode.getChildren().clear(); + skinNode.setCenter(valueHolderNode); + + if (lArrowDirection == ArrowDirection.HORIZONTAL) + { + if (lArrowPosition == ArrowPosition.LEADING) + { + HBox lHBox = new HBox(0); + lHBox.add(decrementArrow, new HBox.C().hgrow(Priority.ALWAYS)); + lHBox.add(incrementArrow, new HBox.C().hgrow(Priority.ALWAYS)); + skinNode.setLeft(lHBox); + BorderPane.setAlignment(lHBox, Pos.CENTER_LEFT); + //lHBox.setStyle("-fx-border-color: blue;"); + } + if (lArrowPosition == ArrowPosition.TRAILING) + { + HBox lHBox = new HBox(0); + lHBox.add(decrementArrow, new HBox.C().hgrow(Priority.ALWAYS)); + lHBox.add(incrementArrow, new HBox.C().hgrow(Priority.ALWAYS)); + skinNode.setRight(lHBox); + BorderPane.setAlignment(lHBox, Pos.CENTER_RIGHT); + //lHBox.setStyle("-fx-border-color: blue;"); + } + if (lArrowPosition == ArrowPosition.SPLIT) + { + skinNode.setLeft(decrementArrow); + skinNode.setRight(incrementArrow); + BorderPane.setAlignment(decrementArrow, Pos.CENTER_LEFT); + BorderPane.setAlignment(incrementArrow, Pos.CENTER_RIGHT); + } + } + if (lArrowDirection == ArrowDirection.VERTICAL) + { + if (lArrowPosition == ArrowPosition.LEADING) + { + VBox lVBox = new VBox(0); + lVBox.add(incrementArrow, new VBox.C().vgrow(Priority.ALWAYS)); + lVBox.add(decrementArrow, new VBox.C().vgrow(Priority.ALWAYS)); + skinNode.setLeft(lVBox); + BorderPane.setAlignment(lVBox, Pos.CENTER_LEFT); + //lVBox.setStyle("-fx-border-color: blue;"); + } + if (lArrowPosition == ArrowPosition.TRAILING) + { + VBox lVBox = new VBox(0); + lVBox.add(incrementArrow, new VBox.C().vgrow(Priority.ALWAYS)); + lVBox.add(decrementArrow, new VBox.C().vgrow(Priority.ALWAYS)); + skinNode.setRight(lVBox); + BorderPane.setAlignment(lVBox, Pos.CENTER_RIGHT); + //lVBox.setStyle("-fx-border-color: blue;"); + } + if (lArrowPosition == ArrowPosition.SPLIT) + { + skinNode.setTop(incrementArrow); + skinNode.setBottom(decrementArrow); + BorderPane.setAlignment(incrementArrow, Pos.TOP_CENTER); + BorderPane.setAlignment(decrementArrow, Pos.BOTTOM_CENTER); + } + } + } + + /** + * Set the CSS according to the direction of the arrows, so the correct arrows are shown + */ + private void setArrowCSS() + { + decrementArrow.getStyleClass().remove("down-arrow"); + decrementArrow.getStyleClass().remove("left-arrow"); + incrementArrow.getStyleClass().remove("up-arrow"); + incrementArrow.getStyleClass().remove("right-arrow"); + if (getArrowDirection().equals(ArrowDirection.HORIZONTAL)) + { + decrementArrow.getStyleClass().add("left-arrow"); + incrementArrow.getStyleClass().add("right-arrow"); + } + else + { + decrementArrow.getStyleClass().add("down-arrow"); + incrementArrow.getStyleClass().add("up-arrow"); + } + } + + // ================================================================================================================== + // EDITABLE + + /** + * Parse the value (which usually comes from the TextField in the skin). + * If the value exists in the current items, select it. + * If not and a callback is defined, call the callback to have it handle it. + * Otherwise do nothing (leave it to the skin). + */ + public void parse(String text) + { + // strip + String lText = text; + String lPostfix = getSkinnable().getPostfix(); + if (lPostfix.length() > 0 && lText.endsWith(lPostfix)) { + lText = lText.substring(0, lText.length() - lPostfix.length()); + } + String lPrefix = getSkinnable().getPrefix(); + if (lPrefix.length() > 0 && lText.startsWith(lPrefix)) { + lText = lText.substring(lPrefix.length()); + } + + // convert from string to value + T lValue = getSkinnable().getStringConverter().fromString(lText); + + // if the value does exists in the domain + int lItemIndex = getSkinnable().getItems().indexOf(lValue); + if (lItemIndex >= 0) + { + // accept value and bail out + getSkinnable().setValue(lValue); + return; + } + + // check to see if we have a addCallback + Callback lAddCallback = getSkinnable().getAddCallback(); + if (lAddCallback != null) + { + // call the callback + Integer lIndex = lAddCallback.call(lValue); + + // if the callback reports that it has processed the value by returning the index where it has added the item. (Or at least the index it wants to show now.) + if (lIndex != null) + { + // accept value and bail out + getSkinnable().setIndex(lIndex); + return; + } + } + } +} diff --git a/DuskZ/src/jfxtras/labs/internal/scene/control/ListSpinner.css b/DuskZ/src/jfxtras/labs/internal/scene/control/ListSpinner.css deleted file mode 100644 index cfeb60d..0000000 --- a/DuskZ/src/jfxtras/labs/internal/scene/control/ListSpinner.css +++ /dev/null @@ -1,47 +0,0 @@ -/* basic settings */ -.ListSpinner { - -fx-skin: "jfxtras.labs.internal.scene.control.skin.ListSpinnerCaspianSkin"; - -fx-background-color: -fx-shadow-highlight-color, -fx-outer-border, -fx-inner-border, -fx-body-color; - -fx-background-insets: 0 0 -1 0, 0, 1, 2; - -fx-background-radius: 5, 5, 4, 3; - -fx-padding: 0.266667em 0.233333em 0.25em 0.233333em; - -fx-text-fill: -fx-text-base-color; -} - -.ListSpinner:hover { - -fx-color: -fx-hover-base; -} - -.ListSpinner:focused { - -fx-color: -fx-focused-base; - -fx-background-color: -fx-focus-color, -fx-outer-border, -fx-inner-border, -fx-body-color; - -fx-background-insets: -1.4, 0, 1, 2; - -fx-background-radius: 6.4, 5, 4, 3; -} - -.ListSpinner .value { - -fx-padding: 0.0em 0.2em 0.0em 0.2em; -} - -.ListSpinner .left-arrow { - -fx-shape: "M4,-4 L0,0 L4,4 Z"; - -fx-scale-shape: false; -} -.ListSpinner .right-arrow { - -fx-shape: "M0,-4 L4,0 L0,4 Z"; - -fx-scale-shape: false; -} -.ListSpinner .down-arrow { - -fx-shape: "M-4,-2 L0,2 L4,-2 Z"; - -fx-scale-shape: false; -} -.ListSpinner .up-arrow { - -fx-shape: "M4,2 L-4,2 L0,-2 Z"; - -fx-scale-shape: false; -} -.ListSpinner .idle { - -fx-background-color: -fx-mark-color; -} -.ListSpinner .clicked { - -fx-background-color: -fx-focus-color; -} diff --git a/DuskZ/src/jfxtras/labs/internal/scene/control/behavior/ListSpinnerBehavior.java b/DuskZ/src/jfxtras/labs/internal/scene/control/behavior/ListSpinnerBehavior.java deleted file mode 100644 index 99e6cf8..0000000 --- a/DuskZ/src/jfxtras/labs/internal/scene/control/behavior/ListSpinnerBehavior.java +++ /dev/null @@ -1,167 +0,0 @@ -/** - * Copyright (c) 2011, JFXtras - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package jfxtras.labs.internal.scene.control.behavior; - -import java.util.ArrayList; -import java.util.List; - -import javafx.scene.input.KeyCode; -import javafx.scene.input.MouseEvent; -import javafx.util.Callback; -import jfxtras.labs.scene.control.ListSpinner; - -import com.sun.javafx.scene.control.behavior.BehaviorBase; -import com.sun.javafx.scene.control.behavior.KeyBinding; - -/** - * - * @author Tom Eugelink - * - */ -public class ListSpinnerBehavior extends BehaviorBase> -{ - // ================================================================================================================== - // CONSTRUCTOR - - /** - * - * @param control - */ - public ListSpinnerBehavior(ListSpinner control) - { - super(control); - construct(); - } - - /* - * - */ - private void construct() - { - - } - - // ================================================================================================================== - // EDITABLE - - /** - * Parse the value (which usually comes from the TextField in the skin). - * If the value exists in the current items, select it. - * If not and a callback is defined, call the callback to have it handle it. - * Otherwise do nothing (leave it to the skin). - */ - public void parse(String text) - { - // strip - String lText = text; - String lPostfix = getControl().getPostfix(); - if (lPostfix.length() > 0 && lText.endsWith(lPostfix)) lText = lText.substring(0, lText.length() - lPostfix.length()); - String lPrefix = getControl().getPrefix(); - if (lPrefix.length() > 0 && lText.startsWith(lPrefix)) lText = lText.substring(lPrefix.length()); - - // convert from string to value - T lValue = getControl().getStringConverter().fromString(lText); - - // if the value does exists in the domain - int lItemIndex = getControl().getItems().indexOf(lValue); - if (lItemIndex >= 0) - { - // accept value and bail out - getControl().setValue(lValue); - return; - } - - // check to see if we have a addCallback - Callback lAddCallback = getControl().getAddCallback(); - if (lAddCallback != null) - { - // call the callback - Integer lIndex = lAddCallback.call(lValue); - - // if the callback reports that it has processed the value by returning the index where it has added the item. (Or at least the index it wants to show now.) - if (lIndex != null) - { - // accept value and bail out - getControl().setIndex(lIndex); - return; - } - } - } - - // ================================================================================================================== - // MOUSE EVENTS - - /** - * - */ - @Override public void mousePressed(MouseEvent evt) - { - // get the control - ListSpinner lControl = getControl(); - - // if a control does not have the focus, request focus - if (!lControl.isFocused() && lControl.isFocusTraversable()) { - lControl.requestFocus(); - } - } - - // ================================================================================================================== - // KEY EVENTS - - final static private String EVENT_PREVIOUS = "PreviousPressed"; - final static private String EVENT_NEXT = "NextPressed"; - protected final static List KEY_BINDINGS = new ArrayList(); - static - { - KEY_BINDINGS.add( new KeyBinding(KeyCode.MINUS, EVENT_PREVIOUS) ); // keyboard - - KEY_BINDINGS.add( new KeyBinding(KeyCode.PLUS, EVENT_NEXT) ); // keyboard + - KEY_BINDINGS.add( new KeyBinding(KeyCode.SUBTRACT, EVENT_PREVIOUS) ); // keypad - - KEY_BINDINGS.add( new KeyBinding(KeyCode.ADD, EVENT_NEXT) ); // keypad + - KEY_BINDINGS.add(new KeyBinding(KeyCode.UP, EVENT_NEXT)); - KEY_BINDINGS.add(new KeyBinding(KeyCode.DOWN, EVENT_PREVIOUS)); - KEY_BINDINGS.add(new KeyBinding(KeyCode.LEFT, EVENT_PREVIOUS)); - KEY_BINDINGS.add(new KeyBinding(KeyCode.RIGHT, EVENT_NEXT)); - KEY_BINDINGS.addAll(TRAVERSAL_BINDINGS); - } - - @Override protected List createKeyBindings() - { - return KEY_BINDINGS; - } - - @Override protected void callAction(String name) { - if (EVENT_PREVIOUS.equals(name)) { - getControl().decrement(); - } - else if (EVENT_NEXT.equals(name)) { - getControl().increment(); - } - else { - super.callAction(name); - } - } -} diff --git a/DuskZ/src/jfxtras/labs/internal/scene/control/skin/ListSpinnerCaspianSkin.java b/DuskZ/src/jfxtras/labs/internal/scene/control/skin/ListSpinnerCaspianSkin.java deleted file mode 100644 index 4cb3b4e..0000000 --- a/DuskZ/src/jfxtras/labs/internal/scene/control/skin/ListSpinnerCaspianSkin.java +++ /dev/null @@ -1,560 +0,0 @@ -/** - * Copyright (c) 2011, JFXtras - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package jfxtras.labs.internal.scene.control.skin; - -import javafx.beans.InvalidationListener; -import javafx.beans.Observable; -import javafx.beans.value.ChangeListener; -import javafx.beans.value.ObservableValue; -import javafx.event.ActionEvent; -import javafx.event.EventHandler; -import javafx.geometry.Point2D; -import javafx.geometry.Pos; -import javafx.scene.Node; -import javafx.scene.control.TextField; -import javafx.scene.input.KeyCode; -import javafx.scene.input.KeyEvent; -import javafx.scene.input.MouseEvent; -import javafx.scene.input.ScrollEvent; -import javafx.scene.layout.BorderPane; -import javafx.scene.layout.ColumnConstraints; -import javafx.scene.layout.GridPane; -import javafx.scene.layout.Priority; -import javafx.scene.layout.Region; -import javafx.scene.layout.RowConstraints; -import javafx.util.Duration; -import jfxtras.labs.animation.Timer; -import jfxtras.labs.internal.scene.control.behavior.ListSpinnerBehavior; -import jfxtras.labs.scene.control.ListSpinner; -import jfxtras.labs.scene.control.ListSpinner.ArrowDirection; -import jfxtras.labs.scene.control.ListSpinner.ArrowPosition; - -import com.sun.javafx.scene.control.skin.SkinBase; - -/** - * - * @author Tom Eugelink - * - * Possible extension: drop down list or grid for quick selection - */ -public class ListSpinnerCaspianSkin extends SkinBase, ListSpinnerBehavior> -{ - // TODO: vertical centering - - // ================================================================================================================== - // CONSTRUCTOR - - /** - * - */ - public ListSpinnerCaspianSkin(ListSpinner control) - { - super(control, new ListSpinnerBehavior(control)); - construct(); - } - - /* - * - */ - private void construct() - { - // setup component - createNodes(); - - // react to value changes in the model - getSkinnable().editableProperty().addListener(new ChangeListener() - { - @Override - public void changed(ObservableValue arg0, Boolean arg1, Boolean arg2) - { - replaceValueNode(); - } - }); - replaceValueNode(); - - // react to value changes in the model - getSkinnable().valueProperty().addListener(new ChangeListener() - { - @Override - public void changed(ObservableValue observableValue, T oldValue, T newValue) - { - refreshValue(); - } - }); - refreshValue(); - - // react to value changes in the model - getSkinnable().arrowDirectionProperty().addListener(new ChangeListener() - { - @Override - public void changed(ObservableValue observableValue, ArrowDirection oldValue, ArrowDirection newValue) - { - setArrowCSS(); - layoutGridPane(); - } - }); - setArrowCSS(); - layoutGridPane(); - - // react to value changes in the model - getSkinnable().alignmentProperty().addListener(new ChangeListener() - { - @Override - public void changed(ObservableValue observableValue, Pos oldValue, Pos newValue) - { - alignValue(); - } - }); - alignValue(); - - } - - /* - * - */ - private void refreshValue() - { - // if editable - if (getSkinnable().isEditable() == true) - { - // update textfield - T lValue = getSkinnable().getValue(); - textField.setText( getSkinnable().getPrefix() + getSkinnable().getStringConverter().toString(lValue) + getSkinnable().getPostfix() ); - } - else - { - // get node for this value - Node lNode = getSkinnable().getCellFactory().call( getSkinnable() ); - } - } - - // ================================================================================================================== - // DRAW - - /** - * Construct the nodes. - * Spinner uses a GridPane where the arrows and the node for the value are laid out according to the arrows direction and location. - * A place holder in inserted into the GridPane to hold the value node, so the spinner can alternate between editable or readonly mode, without having to recreate the GridPane. - */ - private void createNodes() - { - // left arrow - decrementArrow = new Region(); - decrementArrow.getStyleClass().add("idle"); - - // place holder for showing the value - valueGroup = new BorderPane(); - valueGroup.getStyleClass().add("valuePane"); - - // right arrow - incrementArrow = new Region(); - incrementArrow.getStyleClass().add("idle"); - - // construct a gridpane - gridPane = new GridPane(); - - // we're not catching the mouse events on the individual children, but let it bubble up to the parent and handle it there, this makes our life much more simple - // process mouse clicks - gridPane.setOnMouseClicked(new EventHandler() - { - @Override public void handle(MouseEvent evt) - { - // if click was the in the greater vicinity of the decrement arrow - if (mouseEventOverArrow(evt, decrementArrow)) - { - // left - unclickArrows(); - decrementArrow.getStyleClass().add("clicked"); - getSkinnable().decrement(); - unclickTimer.restart(); - return; - } - - // if click was the in the greater vicinity of the increment arrow - if (mouseEventOverArrow(evt, incrementArrow)) - { - // right - unclickArrows(); - incrementArrow.getStyleClass().add("clicked"); - getSkinnable().increment(); - unclickTimer.restart(); - return; - } - } - }); - // process mouse holds - gridPane.setOnMousePressed(new EventHandler() - { - @Override public void handle(MouseEvent evt) - { - // if click was the in the greater vicinity of the decrement arrow - if (mouseEventOverArrow(evt, decrementArrow)) - { - // left - decrementArrow.getStyleClass().add("clicked"); - repeatDecrementClickTimer.restart(); - return; - } - - // if click was the in the greater vicinity of the increment arrow - if (mouseEventOverArrow(evt, incrementArrow)) - { - // right - incrementArrow.getStyleClass().add("clicked"); - repeatIncrementClickTimer.restart(); - return; - } - } - }); - gridPane.setOnMouseReleased(new EventHandler() - { - @Override public void handle(MouseEvent evt) - { - unclickArrows(); - repeatDecrementClickTimer.stop(); - repeatIncrementClickTimer.stop(); - } - }); - gridPane.setOnMouseExited(new EventHandler() - { - @Override public void handle(MouseEvent evt) - { - unclickArrows(); - repeatDecrementClickTimer.stop(); - repeatIncrementClickTimer.stop(); - } - }); - // mouse wheel - gridPane.setOnScroll(new EventHandler() - { - @Override - public void handle(ScrollEvent evt) - { - // if click was the in the greater vicinity of the decrement arrow - if (evt.getDeltaY() < 0 || evt.getDeltaX() < 0) - { - // left - unclickArrows(); - decrementArrow.getStyleClass().add("clicked"); - getSkinnable().decrement(); - unclickTimer.restart(); - return; - } - - // if click was the in the greater vicinity of the increment arrow - if (evt.getDeltaY() > 0 || evt.getDeltaX() > 0) - { - // right - unclickArrows(); - incrementArrow.getStyleClass().add("clicked"); - getSkinnable().increment(); - unclickTimer.restart(); - return; - } - } - }); - - // add to self - this.getStyleClass().add(this.getClass().getSimpleName()); // always add self as style class, because CSS should relate to the skin not the control - getChildren().add(gridPane); - } - private Region decrementArrow = null; - private Region incrementArrow = null; - private GridPane gridPane = null; - private BorderPane valueGroup; - - // timer to remove the click styling on the arrows after a certain delay - final private Timer unclickTimer = new Timer(new Runnable() - { - @Override - public void run() - { - unclickArrows(); - } - }).withDelay(Duration.millis(100)).withRepeats(false); - - // timer to handle the holding of the decrement button - final private Timer repeatDecrementClickTimer = new Timer(new Runnable() - { - @Override - public void run() - { - getSkinnable().decrement(); - } - }).withDelay(Duration.millis(500)).withCycleDuration(Duration.millis(50)); - - // timer to handle the holding of the increment button - final private Timer repeatIncrementClickTimer = new Timer(new Runnable() - { - @Override - public void run() - { - getSkinnable().increment(); - } - }).withDelay(Duration.millis(500)).withCycleDuration(Duration.millis(50)); - - /** - * Check if the mouse event is considered to have happened over the arrow - * @param evt - * @param region - * @return - */ - private boolean mouseEventOverArrow(MouseEvent evt, Region region) - { - // if click was the in the greater vicinity of the decrement arrow - Point2D lClickInRelationToArrow = region.sceneToLocal(evt.getSceneX(), evt.getSceneY()); - if ( lClickInRelationToArrow.getX() >= 0.0 && lClickInRelationToArrow.getX() <= region.getWidth() - && lClickInRelationToArrow.getY() >= 0.0 && lClickInRelationToArrow.getY() <= region.getHeight() - ) - { - return true; - } - return false; - } - - /** - * Remove clicked CSS styling from the arrows - */ - private void unclickArrows() - { - decrementArrow.getStyleClass().remove("clicked"); - incrementArrow.getStyleClass().remove("clicked"); - } - - /** - * Put the correct node for the value's place holder: - * - either the TextField when in editable mode, - * - or a node generated by the cell factory when in readonly mode. - */ - private void replaceValueNode() - { - // clear - valueGroup.getChildren().clear(); - - // if not editable - if (getSkinnable().isEditable() == false) - { - // use the cell factory - Node lNode = getSkinnable().getCellFactory().call(getSkinnable()); - valueGroup.setCenter( lNode ); - if (lNode.getStyleClass().contains("value") == false) lNode.getStyleClass().add("value"); - if (lNode.getStyleClass().contains("readonly") == false) lNode.getStyleClass().add("readonly"); - } - else - { - // use the textfield - if (textField == null) - { - textField = new TextField(); - textField.getStyleClass().add("value"); - textField.getStyleClass().add("editable"); - - // process text entry - textField.focusedProperty().addListener(new InvalidationListener() - { - @Override - public void invalidated(Observable arg0) - { - if (textField.isFocused() == false) - { - parse(textField); - } - } - }); - textField.setOnAction(new EventHandler() - { - @Override - public void handle(ActionEvent evt) - { - parse(textField); - } - }); - textField.setOnKeyPressed(new EventHandler() - { - @Override public void handle(KeyEvent t) - { - if (t.getCode() == KeyCode.ESCAPE) - { - // refresh - refreshValue(); - } - } - }); - - // alignment - textField.alignmentProperty().bind(getSkinnable().alignmentProperty()); - } - valueGroup.setCenter(textField); - } - - // align - alignValue(); - } - private TextField textField = null; - - /** - * align the value inside the plave holder - */ - private void alignValue() - { - // valueGroup always only holds one child (the value) - BorderPane.setAlignment(valueGroup.getChildren().get(0), getSkinnable().alignmentProperty().getValue()); - } - - // ================================================================================================================== - // EDITABLE - - /** - * Parse the contents of the textfield - * @param textField - */ - protected void parse(TextField textField) - { - // get the text to parse - String lText = textField.getText(); - - // process it - getBehavior().parse(lText); - - // refresh - refreshValue(); - return; - } - - /** - * Lays out the spinner, depending on the location and direction of the arrows. - */ - private void layoutGridPane() - { - // get the things we decide on - ArrowDirection lArrowDirection = getSkinnable().getArrowDirection(); - ArrowPosition lArrowPosition = getSkinnable().getArrowPosition(); - - // get helper values - ColumnConstraints lColumnValue = new ColumnConstraints(valueGroup.getMinWidth(), valueGroup.getPrefWidth(), Double.MAX_VALUE); - lColumnValue.setHgrow(Priority.ALWAYS); - ColumnConstraints lColumnArrow = new ColumnConstraints(10); - - // get helper values - RowConstraints lRowValue = new RowConstraints(valueGroup.getMinHeight(), valueGroup.getPrefHeight(), Double.MAX_VALUE); - lRowValue.setVgrow(Priority.ALWAYS); - RowConstraints lRowArrow = new RowConstraints(10); - - // clear the grid - gridPane.getChildren().clear(); - gridPane.getColumnConstraints().clear(); - gridPane.getRowConstraints().clear(); - //gridPane.setGridLinesVisible(true); - - if (lArrowDirection == ArrowDirection.HORIZONTAL) - { - if (lArrowPosition == ArrowPosition.LEADING) - { - // construct a gridpane: one row, three columns: arrow, arrow, value - gridPane.setHgap(3); - gridPane.setVgap(0); - gridPane.add(decrementArrow, 0, 0); - gridPane.add(incrementArrow, 1, 0); - gridPane.add(valueGroup, 2, 0); - gridPane.getColumnConstraints().addAll(lColumnArrow, lColumnArrow, lColumnValue); - } - if (lArrowPosition == ArrowPosition.TRAILING) - { - // construct a gridpane: one row, three columns: value, arrow, arrow - gridPane.setHgap(3); - gridPane.setVgap(0); - gridPane.add(valueGroup, 0, 0); - gridPane.add(decrementArrow, 1, 0); - gridPane.add(incrementArrow, 2, 0); - gridPane.getColumnConstraints().addAll(lColumnValue, lColumnArrow, lColumnArrow); - } - if (lArrowPosition == ArrowPosition.SPLIT) - { - // construct a gridpane: one row, three columns: arrow, value, arrow - gridPane.setHgap(3); - gridPane.setVgap(0); - gridPane.add(decrementArrow, 0, 0); - gridPane.add(valueGroup, 1, 0); - gridPane.add(incrementArrow, 2, 0); - gridPane.getColumnConstraints().addAll(lColumnArrow, lColumnValue, lColumnArrow); - } - } - if (lArrowDirection == ArrowDirection.VERTICAL) - { - if (lArrowPosition == ArrowPosition.LEADING) - { - // construct a gridpane: two rows, two columns: arrows on top, value - gridPane.setHgap(3); - gridPane.setVgap(0); - gridPane.add(incrementArrow, 0, 0); - gridPane.add(decrementArrow, 0, 1); - gridPane.add(valueGroup, 1, 0, 1, 2); - gridPane.getColumnConstraints().addAll(lColumnArrow, lColumnValue); - gridPane.getRowConstraints().addAll(lRowArrow, lRowArrow); - } - if (lArrowPosition == ArrowPosition.TRAILING) - { - // construct a gridpane: two rows, two columns: value, arrows on top - gridPane.setHgap(3); - gridPane.setVgap(0); - gridPane.add(valueGroup, 0, 0, 1, 2); - gridPane.add(incrementArrow, 1, 0); - gridPane.add(decrementArrow, 1, 1); - gridPane.getColumnConstraints().addAll(lColumnValue, lColumnArrow); - gridPane.getRowConstraints().addAll(lRowArrow, lRowArrow); - } - if (lArrowPosition == ArrowPosition.SPLIT) - { - // construct a gridpane: three rows, one columns: arrow, value, arrow - gridPane.setHgap(3); - gridPane.setVgap(0); - gridPane.add(incrementArrow, 0, 0); - gridPane.add(valueGroup, 0, 1); - gridPane.add(decrementArrow, 0, 2); - gridPane.getColumnConstraints().addAll(lColumnValue); - gridPane.getRowConstraints().addAll(lRowArrow, lRowValue, lRowArrow); - } - } - } - - /** - * Set the CSS according to the direction of the arrows, so the correct arrows are shown - */ - private void setArrowCSS() - { - if (getSkinnable().getArrowDirection().equals(ListSpinner.ArrowDirection.HORIZONTAL)) - { - decrementArrow.getStyleClass().add("left-arrow"); - incrementArrow.getStyleClass().add("right-arrow"); - } - else - { - decrementArrow.getStyleClass().add("down-arrow"); - incrementArrow.getStyleClass().add("up-arrow"); - } - } -} diff --git a/DuskZ/src/jfxtras/labs/scene/control/ListSpinnerIntegerList.java b/DuskZ/src/jfxtras/labs/scene/control/ListSpinnerIntegerList.java deleted file mode 100644 index e9c50f5..0000000 --- a/DuskZ/src/jfxtras/labs/scene/control/ListSpinnerIntegerList.java +++ /dev/null @@ -1,76 +0,0 @@ -package jfxtras.labs.scene.control; - -/** - * Items for Spinner providing an integer range without actually creating a list with all values. - */ -public class ListSpinnerIntegerList extends java.util.AbstractList -{ - /** - * - */ - public ListSpinnerIntegerList() - { - this( (Integer.MIN_VALUE / 2) + 1, Integer.MAX_VALUE / 2, 1); - } - - /** - * - * @param from - * @param to - */ - public ListSpinnerIntegerList(int from, int to) - { - this(from, to, from > to ? -1 : 1); - } - - /** - * - * @param from - * @param to - * @param step - */ - public ListSpinnerIntegerList(int from, int to, int step) - { - this.from = from; - this.size = ((to - from) / step) + 1; - if (size < 0) throw new IllegalArgumentException("This results in a negative size: " + from + ", " + to + "," + step); - this.step = step; - } - private int from; - private int size; - private int step; - - - // =============================================================================== - // List interface - - @Override - public Integer get(int index) - { - if (index < 0) throw new IllegalArgumentException("Index cannot be < 0: " + index); - int lValue = this.from + (index * this.step); - return lValue; - } - - @Override - public int indexOf(Object o) - { - // calculate the index - int lValue = ((Integer)o).intValue(); - int lIndex = (lValue - this.from) / this.step; - if (lIndex < 0 || lIndex > size) return -1; - - // check if that what is at the index matches with out value - Integer lValueAtIndex = get(lIndex); - if (o.equals(lValueAtIndex) == false) return -1; - - // found it - return lIndex; - } - - @Override - public int size() - { - return this.size; - } -} \ No newline at end of file diff --git a/DuskZ/src/jfxtras/labs/scene/control/ListSpinner.java b/DuskZ/src/jfxtras/scene/control/ListSpinner.java similarity index 81% rename from DuskZ/src/jfxtras/labs/scene/control/ListSpinner.java rename to DuskZ/src/jfxtras/scene/control/ListSpinner.java index 457c238..30b229e 100644 --- a/DuskZ/src/jfxtras/labs/scene/control/ListSpinner.java +++ b/DuskZ/src/jfxtras/scene/control/ListSpinner.java @@ -1,31 +1,31 @@ -/** - * Copyright (c) 2011, JFXtras - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package jfxtras.labs.scene.control; - +/** + * Copyright (c) 2011-2021, JFXtras + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the organization nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL JFXTRAS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package jfxtras.scene.control; + import java.util.Arrays; import javafx.beans.property.ObjectProperty; @@ -39,575 +39,563 @@ import javafx.event.Event; import javafx.event.EventHandler; import javafx.event.EventTarget; import javafx.event.EventType; -import javafx.geometry.Pos; import javafx.scene.Node; import javafx.scene.control.Control; import javafx.scene.control.Label; +import javafx.scene.control.Skin; import javafx.util.Callback; -import javafx.util.StringConverter; - -/** - * This is a spinner, showing one value at a time from a list. - * This value is set and retrieved from the value property. - * Basically a spinner shows a list of values and can do "next" or "previous" on this. - * - * A spinner can be editable, the user can then type a value instead of selecting it. - * If the value exists in the list, the spinner will simply jump to it. - * If the value does not exist, if defined the AddCallback is called. - * - If the AddCallback returns null, spinner will only refresh the current index. - * - If the AddCallback returns an Integer, spinner will jump to that index (usually the index where the new value was added). - * - * http://openjdk.java.net/projects/openjfx/ux/spinner/index.html - * - * You can style the text in the control using CSS like so: - * .ListSpinner .value { - * -fx-font-weight: bold; - * } - * - * The "value" class applies to the text in both readonly and editable spinners. Use "readonly" or "editable" to style either mode specifically. - * - * @author Tom Eugelink - */ -public class ListSpinner extends Control -{ - // TODO: implement SelectionModel? - // ================================================================================================================== - // CONSTRUCTOR - - /** - */ - public ListSpinner() - { - construct(); - } - - // ------------ - // model - - /** - * @param items The item list used to populate the spinner. - */ - public ListSpinner(ObservableList items) - { - construct(); - setItems(items); - first(); - } - - /** - * @param items The item list used to populate the spinner. - * @param startValue The initial value of the spinner (one of the items). - */ - public ListSpinner(ObservableList items, T startValue) +import javafx.util.StringConverter; + +/** + * This is a spinner, showing one value at a time from a list. + * This value is set and retrieved through the value property. + * Basically a spinner shows a list of values and can do a "next" or "previous". + * + * A spinner can be editable, the user can then type a value instead of selecting it. + * If the value exists in the list, the spinner will simply jump to it. + * If the value does not exist, the AddCallback is called if defined. + * + * - If the AddCallback returns null, spinner will only refresh the current index. + * - If the AddCallback returns an Integer, spinner will jump to that index (usually the index where the new value was added to the list). + * + * + * ''' + * + * In the default skin you can style the text in the control using CSS like so: + * [source,css] + * -- + * .ListSpinner .value { + * -fx-font-weight: bold; + * } + * -- + * + * The "value" class applies to the text in both readonly and editable spinners, use the "readonly" or "editable" class to style either mode specifically. + * There is a left-arrow, right-arrow, up-arrow and down-arrow class that uses a SVG path to draw the arrow, this can be overridden with another SVG to draw a different shape. + * + * The default skin has a number of styleable properies which use the text representation of an enum for their value: + * + * [source,css] + * -- + * .ListSpinner { + * -fxx-arrow-position: {LEADING, TRAILING, SPLIT} + * -fxx-arrow-direction: {VERTICAL, HORIZONTAL} + * -fxx-value-alignment: see javafx.geometry.Pos (https://docs.oracle.com/javase/8/javafx/api/javafx/geometry/Pos.html) + * } + * -- + * + * @author Tom Eugelink + */ +public class ListSpinner extends Control +{ + // TODO: implement SelectionModel? + // ================================================================================================================== + // CONSTRUCTOR + + /** + */ + public ListSpinner() + { + construct(); + } + + // ------------ + // model + + /** + * @param items The item list used to populate the spinner. + */ + public ListSpinner(ObservableList items) + { + construct(); + setItems(items); + first(); + } + + /** + * @param items The item list used to populate the spinner. + * @param startValue The initial value of the spinner (one of the items). + */ + public ListSpinner(ObservableList items, T startValue) + { + construct(); + setItems(items); + setValue(startValue); + } + + // ------------ + // convenience + + /** + * @param list + */ + public ListSpinner(final java.util.List list) + { + this( FXCollections.observableList(list) ); + } + + /** + * @param list + */ + public ListSpinner(T... list) + { + this( Arrays.asList(list) ); + } + + /** + * @param from + * @param to + */ + public ListSpinner(int from, int to) + { + this( (java.util.List) new ListSpinnerIntegerList(from, to) ); + } + + /** + * @param from + * @param to + * @param step + */ + public ListSpinner(int from, int to, int step) + { + this( (java.util.List) new ListSpinnerIntegerList(from, to, step) ); + } + + // ------------ + + /* + * + */ + private void construct() + { + // setup the CSS + // the -fx-skin attribute in the CSS sets which Skin class is used + this.getStyleClass().add(ListSpinner.class.getSimpleName()); + + // react to changes of the value + this.valueObjectProperty.addListener(new ChangeListener() + { + @Override + public void changed(ObservableValue property, T oldValue, T newValue) + { + // get the value of the new index + int lIdx = getItems().indexOf(newValue); + + // set the value + if (ListSpinner.equals(indexObjectProperty.getValue(), lIdx) == false) + { + indexObjectProperty.setValue(lIdx); + } + } + }); + + // react to changes of the index + this.indexObjectProperty.addListener(new ChangeListener() + { + @Override + public void changed(ObservableValue property, Integer oldIndex, Integer newIndex) + { + // get the value of the new index + T lValue = newIndex < 0 ? null : getItems().get(newIndex); + + // set the value + if (ListSpinner.equals(valueObjectProperty.getValue(), lValue) == false) + { + valueObjectProperty.setValue(lValue); + } + } + }); + + // react to changes of the items + this.itemsObjectProperty.addListener(new ChangeListener>() + { + @Override + public void changed(ObservableValue> property, ObservableList oldList, ObservableList newList) + { + if (oldList != null) oldList.removeListener(listChangeListener); + if (newList != null) newList.addListener(listChangeListener); + } + }); + } + + /* + * react to observable list changes + * TODO: what is sticky, index or value? Now: index + */ + private ListChangeListener listChangeListener = new ListChangeListener() + { + @Override + public void onChanged(javafx.collections.ListChangeListener.Change change) + { + // get current index + int lIndex = getIndex(); + + // is it still valid? + if (lIndex >= getItems().size()) + { + lIndex = getItems().size() - 1; + setIndex(lIndex); + return; + } + + // (re)set the value of the index + valueObjectProperty.setValue( getItems().get(lIndex) ); + } + }; + + /** + * Return the path to the CSS file so things are setup right + */ + @Override public String getUserAgentStylesheet() + { + return ListSpinner.class.getResource("/jfxtras/internal/scene/control/" + ListSpinner.class.getSimpleName() + ".css").toExternalForm(); + } + + @Override public Skin createDefaultSkin() { + return new jfxtras.internal.scene.control.skin.ListSpinnerSkin(this); + } + + // ================================================================================================================== + // PROPERTIES + + /** Id */ + public ListSpinner withId(String value) { setId(value); return this; } + + /** Value: the currently show value of the list. */ + public ObjectProperty valueProperty() { return this.valueObjectProperty; } + final private ObjectProperty valueObjectProperty = new SimpleObjectProperty(this, "value", null) + { + public void set(T value) + { + if (getItems().indexOf(value) < 0) throw new IllegalArgumentException("Value does not exist in the list: " + value); + super.set(value); + } + }; + // java bean API + public T getValue() { return this.valueObjectProperty.getValue(); } + public void setValue(T value) { this.valueObjectProperty.setValue(value); } + public ListSpinner withValue(T value) { setValue(value); return this; } + + /** Index: the currently show index in the list. */ + public ObjectProperty indexProperty() { return this.indexObjectProperty; } + final private ObjectProperty indexObjectProperty = new SimpleObjectProperty(this, "index", null) + { + public void set(Integer value) + { + if (value == null) throw new NullPointerException("Null not allowed as the value for index"); + if (value >= getItems().size()) throw new IllegalArgumentException("Index out of bounds: " + value + ", valid values are 0-" + (getItems().size() - 1)); + super.set(value); + } + }; + public Integer getIndex() { return this.indexObjectProperty.getValue(); } + public void setIndex(Integer value) { this.indexObjectProperty.setValue(value); } + public ListSpinner withIndex(Integer value) { setIndex(value); return this; } + + /** Cyclic: what happens at the beginning or end of the list, stop or cycle to the other end. */ + public ObjectProperty cyclicProperty() { return this.cyclicObjectProperty; } + final private ObjectProperty cyclicObjectProperty = new SimpleObjectProperty(this, "cyclic", false) + { + public void set(Boolean value) + { + if (value == null) throw new NullPointerException("Null not allowed as the value for cyclic"); + super.set(value); + } + }; + public Boolean isCyclic() { return this.cyclicObjectProperty.getValue(); } + public void setCyclic(Boolean value) { this.cyclicObjectProperty.setValue(value); } + public ListSpinner withCyclic(Boolean value) { setCyclic(value); return this; } + + /** Editable: is the listspinner editable. It allows the user to type a value instead of only navigating to it, and if the AddCallback is defined, possibly also adding values. */ + public ObjectProperty editableProperty() { return this.editableObjectProperty; } + final private ObjectProperty editableObjectProperty = new SimpleObjectProperty(this, "editable", false) + { + public void set(Boolean value) + { + if (value == null) throw new NullPointerException("Null not allowed as the value for editable"); + super.set(value); + } + }; + public Boolean isEditable() { return this.editableObjectProperty.getValue(); } + public void setEditable(Boolean value) { this.editableObjectProperty.setValue(value); } + public ListSpinner withEditable(Boolean value) { setEditable(value); return this; } + + /** Postfix: a string to be placed after the value, this can for example be a unit like "kg" */ + public ObjectProperty postfixProperty() { return this.postfixObjectProperty; } + final private ObjectProperty postfixObjectProperty = new SimpleObjectProperty(this, "postfix", ""); + public String getPostfix() { return this.postfixObjectProperty.getValue(); } + public void setPostfix(String value) { this.postfixObjectProperty.setValue(value); } + public ListSpinner withPostfix(String value) { setPostfix(value); return this; } + + /** Prefix: a string to be placed before the list value, this can for example be a currency */ + public ObjectProperty prefixProperty() { return this.prefixObjectProperty; } + final private ObjectProperty prefixObjectProperty = new SimpleObjectProperty(this, "prefix", ""); + public String getPrefix() { return this.prefixObjectProperty.getValue(); } + public void setPrefix(String value) { this.prefixObjectProperty.setValue(value); } + public ListSpinner withPrefix(String value) { setPrefix(value); return this; } + + /** Items: the list. */ + public ObjectProperty> itemsProperty() { return this.itemsObjectProperty; } + final private ObjectProperty> itemsObjectProperty = new SimpleObjectProperty>(this, "items", null) + { + public void set(ObservableList value) + { + if (value == null) throw new NullPointerException("Null not allowed as the value for items"); + super.set(value); + } + }; + public ObservableList getItems() { return this.itemsObjectProperty.getValue(); } + public void setItems(ObservableList value) { this.itemsObjectProperty.setValue(value); } + public ListSpinner withItems(ObservableList value) { setItems(value); return this; } + + /** CellFactory: generate the cell to render a value */ + public ObjectProperty, Node>> cellFactoryProperty() { return this.cellFactoryObjectProperty; } + final private ObjectProperty, Node>> cellFactoryObjectProperty = new SimpleObjectProperty, Node>>(this, "cellFactory", new DefaultCellFactory()); + public Callback, Node> getCellFactory() { return this.cellFactoryObjectProperty.getValue(); } + public void setCellFactory(Callback, Node> value) { this.cellFactoryObjectProperty.setValue(value); } + public ListSpinner withCellFactory(Callback, Node> value) { setCellFactory(value); return this; } + + /** StringConverter<T>: convert a value in the list to its string representation and (when in edit mode) vice versa. */ + public ObjectProperty> stringConverterProperty() { return this.stringConverterObjectProperty; } + final private ObjectProperty> stringConverterObjectProperty = new SimpleObjectProperty>(this, "stringConverter", new DefaultStringConverter()); + public StringConverter getStringConverter() { return this.stringConverterObjectProperty.getValue(); } + public void setStringConverter(StringConverter value) { this.stringConverterObjectProperty.setValue(value); } + public ListSpinner withStringConverter(StringConverter value) { setStringConverter(value); return this; } + + /** AddCallback: this callback is called in editable mode when a value is entered that is not found in the list. + * It is up to the coder to added it to the list or not. + * @return the index where of the position the ListSpinner must show or null (do nothing expect refresh the currently show index) + */ + public ObjectProperty> addCallbackProperty() { return this.addCallbackObjectProperty; } + final private ObjectProperty> addCallbackObjectProperty = new SimpleObjectProperty>(this, "addCallback", null); + public Callback getAddCallback() { return this.addCallbackObjectProperty.getValue(); } + public void setAddCallback(Callback value) { this.addCallbackObjectProperty.setValue(value); } + public ListSpinner withAddCallback(Callback value) { setAddCallback(value); return this; } + + // ================================================================================================================== + // StringConverter + + /** + * A string converter that does a simple toString, but cannot convert to an object + * @see org.jfxextras.util.StringConverterFactory + */ + class DefaultStringConverter extends StringConverter + { + @Override + public T fromString(String string) + { + throw new IllegalStateException("No StringConverter is set. An editable Spinner must have a StringConverter to be able to render and parse the value."); + } + + @Override + public String toString(T value) + { + return value == null ? "" : value.toString(); + } + } + + // ================================================================================================================== + // CellFactory + + /** + * Default cell factory + */ + class DefaultCellFactory implements Callback, Node> + { + private Label label = null; + + @Override + public Node call(ListSpinner spinner) + { + // get value + T lValue = spinner.getValue(); + + // label not yet created + if (this.label == null) + { + this.label = new Label(); + } + this.label.setText( lValue == null ? "" : spinner.getPrefix() + getStringConverter().toString(lValue) + spinner.getPostfix() ); + return this.label; + } + }; + + // ================================================================================================================== + // EVENTS + + /** OnCycle: callback for when the list cycles to the other end in cyclic mode (for example to increase a year when a month ListSpinner skips from December to January) */ + public ObjectProperty> onCycleProperty() { return iOnCycleObjectProperty; } + final private ObjectProperty> iOnCycleObjectProperty = new SimpleObjectProperty>(null); + // java bean API + public EventHandler getOnCycle() { return iOnCycleObjectProperty.getValue(); } + public void setOnCycle(EventHandler value) { iOnCycleObjectProperty.setValue(value); } + public ListSpinner withOnCycle(EventHandler value) { setOnCycle(value); return this; } + final static public String ONCYCLE_PROPERTY_ID = "onCycle"; + + /** + * CycleEvent + */ + static public class CycleEvent extends Event + { + /** + * The only valid EventType for the CycleEvent. + */ + public static final EventType CYCLE = new EventType(Event.ANY, "CYCLE"); + + /** + * + */ + public CycleEvent() + { + super(CYCLE); + } + + /** + * + * @param source + * @param target + */ + public CycleEvent(Object source, EventTarget target) + { + super(source, target, new EventType()); + } + + public Object getOldIdx() { return this.oldIdx; } + private Object oldIdx; + + public Object getNewIdx() { return this.newIdx; } + private Object newIdx; + + + public boolean cycledDown() { return cycleDirection == CycleDirection.TOP_TO_BOTTOM; } + public boolean cycledUp() { return cycleDirection == CycleDirection.BOTTOM_TO_TOP; } + CycleDirection cycleDirection; + } + + /** + * we're cycling, fire the event + */ + public void fireCycleEvent(CycleDirection cycleDirection) + { + EventHandler lCycleEventHandler = getOnCycle(); + if (lCycleEventHandler != null) + { + CycleEvent lCycleEvent = new CycleEvent(); + lCycleEvent.cycleDirection = cycleDirection; + lCycleEventHandler.handle(lCycleEvent); + } + } + static public enum CycleDirection { TOP_TO_BOTTOM, BOTTOM_TO_TOP } + + + // ================================================================================================================== + // BEHAVIOR + + /** + * + */ + public void first() + { + // nothing to do + if (getItems() == null || getItems().size() == 0) return; + + // set the new index (this will update the value) + indexObjectProperty.setValue(0); + } + + /** + * + */ + public void decrement() { - construct(); - setItems(items); - setValue(startValue); - } - - // ------------ - // convenience - - /** - * @param list - */ - public ListSpinner(java.util.List list) - { - this( FXCollections.observableList(list) ); - } - - /** - * @param list - */ - public ListSpinner(T... list) - { - this( Arrays.asList(list) ); - } - - /** - * @param from - * @param to - */ - public ListSpinner(int from, int to) - { - this( (java.util.List) new ListSpinnerIntegerList(from, to) ); - } - - /** - * @param from - * @param to - * @param step - */ - public ListSpinner(int from, int to, int step) - { - this( (java.util.List) new ListSpinnerIntegerList(from, to, step) ); - } - - // ------------ - - /* - * - */ - private void construct() - { - // setup the CSS - // the -fx-skin attribute in the CSS sets which Skin class is used - this.getStyleClass().add(this.getClass().getSimpleName()); - - // react to changes of the value - this.valueObjectProperty.addListener(new ChangeListener() - { - @Override - public void changed(ObservableValue property, T oldValue, T newValue) - { - // get the value of the new index - int lIdx = getItems().indexOf(newValue); - - // set the value - if (ListSpinner.equals(indexObjectProperty.getValue(), lIdx) == false) - { - indexObjectProperty.setValue(lIdx); - } - } - }); - - // react to changes of the index - this.indexObjectProperty.addListener(new ChangeListener() - { - @Override - public void changed(ObservableValue property, Integer oldIndex, Integer newIndex) - { - // get the value of the new index - T lValue = newIndex < 0 ? null : getItems().get(newIndex); - - // set the value - if (ListSpinner.equals(valueObjectProperty.getValue(), lValue) == false) - { - valueObjectProperty.setValue(lValue); - } - } - }); - - // react to changes of the items - this.itemsObjectProperty.addListener(new ChangeListener>() - { - @Override - public void changed(ObservableValue> property, ObservableList oldList, ObservableList newList) - { - if (oldList != null) oldList.removeListener(listChangeListener); - if (newList != null) newList.addListener(listChangeListener); - } - }); - } - - /* - * react to observable list changes - * TODO: what is sticky, index or value? Now: index - */ - private ListChangeListener listChangeListener = new ListChangeListener() - { - @Override - public void onChanged(javafx.collections.ListChangeListener.Change change) - { - // get current index - int lIndex = getIndex(); - - // is it still valid? - if (lIndex >= getItems().size()) - { - lIndex = getItems().size() - 1; - setIndex(lIndex); - return; - } - - // (re)set the value of the index - valueObjectProperty.setValue( getItems().get(lIndex) ); - } - }; - - /** - * Return the path to the CSS file so things are setup right - */ - @Override protected String getUserAgentStylesheet() - { - return this.getClass().getResource("/jfxtras/labs/internal/scene/control/" + this.getClass().getSimpleName() + ".css").toString(); - } - - // ================================================================================================================== - // PROPERTIES - - /** Value: */ - public ObjectProperty valueProperty() { return this.valueObjectProperty; } - final private ObjectProperty valueObjectProperty = new SimpleObjectProperty(this, "value", null) - { - public void set(T value) - { - if (getItems().indexOf(value) < 0) throw new IllegalArgumentException("Value does not exist in the list: " + value); - super.set(value); - } - }; - // java bean API - public T getValue() { return this.valueObjectProperty.getValue(); } - public void setValue(T value) { this.valueObjectProperty.setValue(value); } - public ListSpinner withValue(T value) { setValue(value); return this; } - - /** Index: */ - public ObjectProperty indexProperty() { return this.indexObjectProperty; } - final private ObjectProperty indexObjectProperty = new SimpleObjectProperty(this, "index", null) - { - public void set(Integer value) - { - if (value == null) throw new NullPointerException("Null not allowed as the value for index"); - if (value >= getItems().size()) throw new IllegalArgumentException("Index out of bounds: " + value + ", valid values are 0-" + (getItems().size() - 1)); - super.set(value); - } - }; - public Integer getIndex() { return this.indexObjectProperty.getValue(); } - public void setIndex(Integer value) { this.indexObjectProperty.setValue(value); } - public ListSpinner withIndex(Integer value) { setIndex(value); return this; } - - /** Cyclic: */ - public ObjectProperty cyclicProperty() { return this.cyclicObjectProperty; } - final private ObjectProperty cyclicObjectProperty = new SimpleObjectProperty(this, "cyclic", false) - { - public void set(Boolean value) - { - if (value == null) throw new NullPointerException("Null not allowed as the value for cyclic"); - super.set(value); - } - }; - public Boolean isCyclic() { return this.cyclicObjectProperty.getValue(); } - public void setCyclic(Boolean value) { this.cyclicObjectProperty.setValue(value); } - public ListSpinner withCyclic(Boolean value) { setCyclic(value); return this; } - - /** Editable: */ - public ObjectProperty editableProperty() { return this.editableObjectProperty; } - final private ObjectProperty editableObjectProperty = new SimpleObjectProperty(this, "editable", false) - { - public void set(Boolean value) - { - if (value == null) throw new NullPointerException("Null not allowed as the value for editable"); - super.set(value); - } - }; - public Boolean isEditable() { return this.editableObjectProperty.getValue(); } - public void setEditable(Boolean value) { this.editableObjectProperty.setValue(value); } - public ListSpinner withEditable(Boolean value) { setEditable(value); return this; } - - /** Postfix: */ - public ObjectProperty postfixProperty() { return this.postfixObjectProperty; } - final private ObjectProperty postfixObjectProperty = new SimpleObjectProperty(this, "postfix", ""); - public String getPostfix() { return this.postfixObjectProperty.getValue(); } - public void setPostfix(String value) { this.postfixObjectProperty.setValue(value); } - public ListSpinner withPostfix(String value) { setPostfix(value); return this; } - - /** Prefix: */ - public ObjectProperty prefixProperty() { return this.prefixObjectProperty; } - final private ObjectProperty prefixObjectProperty = new SimpleObjectProperty(this, "prefix", ""); - public String getPrefix() { return this.prefixObjectProperty.getValue(); } - public void setPrefix(String value) { this.prefixObjectProperty.setValue(value); } - public ListSpinner withPrefix(String value) { setPrefix(value); return this; } - - /** Items: */ - public ObjectProperty> itemsProperty() { return this.itemsObjectProperty; } - final private ObjectProperty> itemsObjectProperty = new SimpleObjectProperty>(this, "items", null) - { - public void set(ObservableList value) - { - if (value == null) throw new NullPointerException("Null not allowed as the value for items"); - super.set(value); - } - }; - public ObservableList getItems() { return this.itemsObjectProperty.getValue(); } - public void setItems(ObservableList value) { this.itemsObjectProperty.setValue(value); } - public ListSpinner withItems(ObservableList value) { setItems(value); return this; } - - /** CellFactory: */ - public ObjectProperty, Node>> cellFactoryProperty() { return this.cellFactoryObjectProperty; } - final private ObjectProperty, Node>> cellFactoryObjectProperty = new SimpleObjectProperty, Node>>(this, "cellFactory", new DefaultCellFactory()); - public Callback, Node> getCellFactory() { return this.cellFactoryObjectProperty.getValue(); } - public void setCellFactory(Callback, Node> value) { this.cellFactoryObjectProperty.setValue(value); } - public ListSpinner withCellFactory(Callback, Node> value) { setCellFactory(value); return this; } - - /** StringConverter: */ - public ObjectProperty> stringConverterProperty() { return this.stringConverterObjectProperty; } - final private ObjectProperty> stringConverterObjectProperty = new SimpleObjectProperty>(this, "stringConverter", new DefaultStringConverter()); - public StringConverter getStringConverter() { return this.stringConverterObjectProperty.getValue(); } - public void setStringConverter(StringConverter value) { this.stringConverterObjectProperty.setValue(value); } - public ListSpinner withStringConverter(StringConverter value) { setStringConverter(value); return this; } - - /** ArrowDirection: */ - public ObjectProperty arrowDirectionProperty() { return this.arrowDirectionObjectProperty; } - final private ObjectProperty arrowDirectionObjectProperty = new SimpleObjectProperty(this, "arrowDirection", ArrowDirection.HORIZONTAL) - { - public void set(ArrowDirection value) - { - if (value == null) throw new NullPointerException("Null not allowed as the value for arrowDirection"); - super.set(value); - } - }; - public ArrowDirection getArrowDirection() { return this.arrowDirectionObjectProperty.getValue(); } - public void setArrowDirection(ArrowDirection value) { this.arrowDirectionObjectProperty.setValue(value); } - public ListSpinner withArrowDirection(ArrowDirection value) { setArrowDirection(value); return this; } - public enum ArrowDirection {VERTICAL, HORIZONTAL} - - /** ArrowPosition: */ - public ObjectProperty arrowPositionProperty() { return this.arrowPositionObjectProperty; } - final private ObjectProperty arrowPositionObjectProperty = new SimpleObjectProperty(this, "arrowPosition", ArrowPosition.TRAILING) - { - public void set(ArrowPosition value) - { - if (value == null) throw new NullPointerException("Null not allowed as the value for arrowPosition"); - super.set(value); - } - }; - public ArrowPosition getArrowPosition() { return this.arrowPositionObjectProperty.getValue(); } - public void setArrowPosition(ArrowPosition value) { this.arrowPositionObjectProperty.setValue(value); } - public ListSpinner withArrowPosition(ArrowPosition value) { setArrowPosition(value); return this; } - public enum ArrowPosition {LEADING, TRAILING, SPLIT} - - /** Alignment: only applicable in non edit mode */ - public ObjectProperty alignmentProperty() { return this.alignmentObjectProperty; } - final private ObjectProperty alignmentObjectProperty = new SimpleObjectProperty(this, "alignment", Pos.CENTER_LEFT) - { - public void set(Pos value) - { - if (value == null) throw new NullPointerException("Null not allowed as the value for alignment"); - super.set(value); - } - }; - public Pos isAlignment() { return this.alignmentObjectProperty.getValue(); } - public void setAlignment(Pos value) { this.alignmentObjectProperty.setValue(value); } - public ListSpinner withAlignment(Pos value) { setAlignment(value); return this; } - - /** AddCallback: */ - public ObjectProperty> addCallbackProperty() { return this.addCallbackObjectProperty; } - final private ObjectProperty> addCallbackObjectProperty = new SimpleObjectProperty>(this, "addCallback", null); - public Callback getAddCallback() { return this.addCallbackObjectProperty.getValue(); } - public void setAddCallback(Callback value) { this.addCallbackObjectProperty.setValue(value); } - public ListSpinner withAddCallback(Callback value) { setAddCallback(value); return this; } - - // ================================================================================================================== - // StringConverter - - /** - * A string converter that does a simple toString, but cannot convert to an object - * @see org.jfxextras.util.StringConverterFactory - */ - class DefaultStringConverter extends StringConverter - { - @Override - public T fromString(String string) - { - throw new IllegalStateException("No StringConverter is set. An editable Spinner must have a StringConverter to be able to render and parse the value."); - } - - @Override - public String toString(T value) - { - return value == null ? "" : value.toString(); - } - } - - // ================================================================================================================== - // CellFactory - - /** - * Default cell factory - */ - class DefaultCellFactory implements Callback, Node> - { - private Label label = null; - - @Override - public Node call(ListSpinner spinner) - { - // get value - T lValue = spinner.getValue(); - - // label not yet created - if (this.label == null) - { - this.label = new Label(); - } - this.label.setText( lValue == null ? "" : spinner.getPrefix() + getStringConverter().toString(lValue) + spinner.getPostfix() ); - return this.label; - } - }; - - // ================================================================================================================== - // EVENTS - - /** OnCycle: */ - public ObjectProperty> onCycleProperty() { return iOnCycleObjectProperty; } - final private ObjectProperty> iOnCycleObjectProperty = new SimpleObjectProperty>(null); - // java bean API - public EventHandler getOnCycle() { return iOnCycleObjectProperty.getValue(); } - public void setOnCycle(EventHandler value) { iOnCycleObjectProperty.setValue(value); } - public ListSpinner withOnCycle(EventHandler value) { setOnCycle(value); return this; } - final static public String ONCYCLE_PROPERTY_ID = "onCycle"; - - /** - * CycleEvent - */ - static public class CycleEvent extends Event - { - /** - * - */ - public CycleEvent() - { - super(new EventType()); - } - - /** - * - * @param source - * @param target - */ - public CycleEvent(Object source, EventTarget target) - { - super(source, target, new EventType()); - } - - public Object getOldIdx() { return this.oldIdx; } - private Object oldIdx; - - public Object getNewIdx() { return this.newIdx; } - private Object newIdx; - - - public boolean cycledDown() { return cycleDirection == CycleDirection.TOP_TO_BOTTOM; } - public boolean cycledUp() { return cycleDirection == CycleDirection.BOTTOM_TO_TOP; } - CycleDirection cycleDirection; - } - - /** - * we're cycling, fire the event - */ - public void fireCycleEvent(CycleDirection cycleDirection) - { - EventHandler lCycleEventHandler = getOnCycle(); - if (lCycleEventHandler != null) - { - CycleEvent lCycleEvent = new CycleEvent(); - lCycleEvent.cycleDirection = cycleDirection; - lCycleEventHandler.handle(lCycleEvent); - } - } - static public enum CycleDirection { TOP_TO_BOTTOM, BOTTOM_TO_TOP } - - - // ================================================================================================================== - // BEHAVIOR - - /** - * - */ - public void first() - { - // nothing to do - if (getItems() == null || getItems().size() == 0) return; - - // set the new index (this will update the value) - indexObjectProperty.setValue(0); - } - - /** - * - */ - public void decrement() - { - // nothing to do - if (getItems() == null || getItems().size() == 0) return; - - // get the current index - int lOldIdx = this.indexObjectProperty.getValue(); - - // get the previous index (usually current - 1) - int lIdx = lOldIdx - 1; - - // if end - if (lIdx < 0) - { - // if we're not cyclic - if (isCyclic() != null && isCyclic().booleanValue() == false) - { - // do nothing - return; - } - - // cycle to the other end: get the last value - lIdx = getItems().size() - 1; - - // notify listener that we've cycled - fireCycleEvent(CycleDirection.BOTTOM_TO_TOP); - } - - // set the new index (this will update the value) - indexObjectProperty.setValue(lIdx); - } - - /** - * - */ - public void increment() - { - // nothing to do - if (getItems() == null || getItems().size() == 0) return; - - // get the current index - int lOldIdx = this.indexObjectProperty.getValue(); - - // get the next index (usually current + 1) - int lIdx = lOldIdx + 1; - - // if null is return, there is no next index (usually current + 1) - if (lIdx >= getItems().size()) - { - // if we're not cyclic - if (isCyclic() != null && isCyclic().booleanValue() == false) - { - // do nothing - return; - } - - // cycle to the other end: get the first value - lIdx = 0; - - // notify listener that we've cycled - fireCycleEvent(CycleDirection.TOP_TO_BOTTOM); - } - - // set the new index (this will update the value) - indexObjectProperty.setValue(lIdx); - } - - /** - * Get the last index; if the data provide is endless, this method mail fail! - */ - public void last() - { - // nothing to do - if (getItems() == null || getItems().size() == 0) return; - - // set the new index (this will update the value) - indexObjectProperty.setValue(getItems().size() - 1); - } - - /** - * Does a o1.equals(o2) but also checks if o1 or o2 are null. - * @param o1 - * @param o2 - * @return True if the two values are equal, false otherwise. - */ - static public boolean equals(Object o1, Object o2) - { - if ( o1 == null && o2 == null ) return true; - if ( o1 != null && o2 == null ) return false; - if ( o1 == null && o2 != null ) return false; - // TODO: compare arrays if (o1.getClass().isArray() && o2.getClass().isArray()) return Arrays.equals( (Object[])o1, (Object[])o2 ); - return o1.equals(o2); - } - -} + // nothing to do + if (getItems() == null || getItems().size() == 0) return; + + // get the current index + int lOldIdx = this.indexObjectProperty.getValue(); + + // get the previous index (usually current - 1) + int lIdx = lOldIdx - 1; + + // if end + if (lIdx < 0) + { + // if we're not cyclic + if (isCyclic() != null && isCyclic().booleanValue() == false) + { + // do nothing + return; + } + + // cycle to the other end: get the last value + lIdx = getItems().size() - 1; + + // notify listener that we've cycled + fireCycleEvent(CycleDirection.BOTTOM_TO_TOP); + } + + // set the new index (this will update the value) + indexObjectProperty.setValue(lIdx); + } + + /** + * + */ + public void increment() + { + // nothing to do + if (getItems() == null || getItems().size() == 0) return; + + // get the current index + int lOldIdx = this.indexObjectProperty.getValue(); + + // get the next index (usually current + 1) + int lIdx = lOldIdx + 1; + + // if null is return, there is no next index (usually current + 1) + if (lIdx >= getItems().size()) + { + // if we're not cyclic + if (isCyclic() != null && isCyclic().booleanValue() == false) + { + // do nothing + return; + } + + // cycle to the other end: get the first value + lIdx = 0; + + // notify listener that we've cycled + fireCycleEvent(CycleDirection.TOP_TO_BOTTOM); + } + + // set the new index (this will update the value) + indexObjectProperty.setValue(lIdx); + } + + /** + * Get the last index; if the data provide is endless, this method mail fail! + */ + public void last() + { + // nothing to do + if (getItems() == null || getItems().size() == 0) return; + + // set the new index (this will update the value) + indexObjectProperty.setValue(getItems().size() - 1); + } + + /** + * Does a o1.equals(o2) but also checks if o1 or o2 are null. + * @param o1 + * @param o2 + * @return True if the two values are equal, false otherwise. + */ + static public boolean equals(Object o1, Object o2) + { + if ( o1 == null && o2 == null ) return true; + if ( o1 != null && o2 == null ) return false; + if ( o1 == null && o2 != null ) return false; + // TODO: compare arrays if (o1.getClass().isArray() && o2.getClass().isArray()) return Arrays.equals( (Object[])o1, (Object[])o2 ); + return o1.equals(o2); + } + +} diff --git a/DuskZ/src/jfxtras/scene/control/ListSpinnerBigIntegerList.java b/DuskZ/src/jfxtras/scene/control/ListSpinnerBigIntegerList.java new file mode 100644 index 0000000..0f4f95d --- /dev/null +++ b/DuskZ/src/jfxtras/scene/control/ListSpinnerBigIntegerList.java @@ -0,0 +1,108 @@ +/** + * Copyright (c) 2011-2021, JFXtras + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the organization nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL JFXTRAS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package jfxtras.scene.control; + +import java.math.BigInteger; + +/** + * Items for Spinner providing an BigInteger range without actually creating a list with all values. + * Beware: because this is still based on the list inteface, the maximum size of the list is limited by the type used for the index in the list: an integer (Integer.MAX_VALUE). + * So the difference between the from and to values (to-from) cannot be larger than Integer.MAX_VALUE. + * What this class allows is that this range can be anywhere in the BigInteger's range. + */ +public class ListSpinnerBigIntegerList extends java.util.AbstractList +{ + /** + * + */ + public ListSpinnerBigIntegerList() + { + this( BigInteger.valueOf(Integer.MIN_VALUE / 2).add(BigInteger.ONE), BigInteger.valueOf(Integer.MAX_VALUE / 2), BigInteger.ONE); + } + + /** + * + * @param from + * @param to + */ + public ListSpinnerBigIntegerList(BigInteger from, BigInteger to) + { + this(from, to, from.compareTo(to) > 0 ? BigInteger.valueOf(-1) : BigInteger.ONE); + } + + /** + * + * @param from + * @param to + * @param step + */ + public ListSpinnerBigIntegerList(BigInteger from, BigInteger to, BigInteger step) + { + this.from = from; + this.size = to.subtract(from).divide(step).add(BigInteger.ONE).intValue(); + if (this.size < 0) throw new IllegalArgumentException("This results in a negative size: " + from + ", " + to + "," + step); + this.step = step; + } + private BigInteger from; + private int size; + private BigInteger step; + + + // =============================================================================== + // List interface + + @Override + public BigInteger get(int index) + { + if (index < 0) throw new IllegalArgumentException("Index cannot be < 0: " + index); + BigInteger lValue = this.from.add(BigInteger.valueOf(index).multiply(this.step)); + return lValue; + } + + @Override + public int indexOf(Object o) + { + // calculate the index + BigInteger lValue = (BigInteger)o; + BigInteger lIndexBigInteger = lValue.subtract(this.from).divide(this.step); + int lIndex = lIndexBigInteger.intValue(); + if (lIndex > size) return -1; + + // check if that what is at the index matches with out value + BigInteger lValueAtIndex = get(lIndex); + if (o.equals(lValueAtIndex) == false) return -1; + + // found it + return lIndex; + } + + @Override + public int size() + { + return this.size; + } +} \ No newline at end of file diff --git a/DuskZ/src/jfxtras/scene/control/ListSpinnerIntegerList.java b/DuskZ/src/jfxtras/scene/control/ListSpinnerIntegerList.java new file mode 100644 index 0000000..49473b4 --- /dev/null +++ b/DuskZ/src/jfxtras/scene/control/ListSpinnerIntegerList.java @@ -0,0 +1,102 @@ +/** + * Copyright (c) 2011-2021, JFXtras + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the organization nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL JFXTRAS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package jfxtras.scene.control; + +/** + * Items for Spinner providing an integer range without actually creating a list with all values. + */ +public class ListSpinnerIntegerList extends java.util.AbstractList +{ + /** + * + */ + public ListSpinnerIntegerList() + { + this( (Integer.MIN_VALUE / 2) + 1, Integer.MAX_VALUE / 2, 1); + } + + /** + * + * @param from + * @param to + */ + public ListSpinnerIntegerList(int from, int to) + { + this(from, to, from > to ? -1 : 1); + } + + /** + * + * @param from + * @param to + * @param step + */ + public ListSpinnerIntegerList(int from, int to, int step) + { + this.from = from; + this.size = ((to - from) / step) + 1; + if (size < 0) throw new IllegalArgumentException("This results in a negative size: " + from + ", " + to + "," + step); + this.step = step; + } + private int from; + private int size; + private int step; + + + // =============================================================================== + // List interface + + @Override + public Integer get(int index) + { + if (index < 0) throw new IllegalArgumentException("Index cannot be < 0: " + index); + int lValue = this.from + (index * this.step); + return lValue; + } + + @Override + public int indexOf(Object o) + { + // calculate the index + int lValue = ((Integer)o).intValue(); + int lIndex = (lValue - this.from) / this.step; + if (lIndex < 0 || lIndex >= size) return -1; + + // check if that what is at the index matches with out value + Integer lValueAtIndex = get(lIndex); + if (o.equals(lValueAtIndex) == false) return -1; + + // found it + return lIndex; + } + + @Override + public int size() + { + return this.size; + } +} \ No newline at end of file diff --git a/DuskZ/src/jfxtras/scene/layout/GenericLayoutConstraints.java b/DuskZ/src/jfxtras/scene/layout/GenericLayoutConstraints.java new file mode 100644 index 0000000..b8463a1 --- /dev/null +++ b/DuskZ/src/jfxtras/scene/layout/GenericLayoutConstraints.java @@ -0,0 +1,145 @@ +/** + * Copyright (c) 2011-2021, JFXtras + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the organization nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL JFXTRAS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package jfxtras.scene.layout; + +import javafx.scene.Node; + +class GenericLayoutConstraints +{ + /** + * The layout constraints + * + */ + public static class C + { + // minWidth + public T minWidth(double value) { this.minWidth = value; return (T)this; } + double minWidth = -1; + double minWidthReset = UNKNOWN; + + // prefWidth + public T prefWidth(double value) { this.prefWidth = value; return (T)this; } + double prefWidth = -1; + double prefWidthReset = UNKNOWN; + + // maxWidth + public T maxWidth(double value) { this.maxWidth = value; return (T)this; } + double maxWidth = -1; + double maxWidthReset = UNKNOWN; + + // minHeight + public T minHeight(double value) { this.minHeight = value; return (T)this; } + double minHeight = -1; + double minHeightReset = UNKNOWN; + + // prefHeight + public T prefHeight(double value) { this.prefHeight = value; return (T)this; } + double prefHeight = -1; + double prefHeightReset = UNKNOWN; + + // maxHeight + public T maxHeight(double value) { this.maxHeight = value; return (T)this; } + double maxHeight = -1; + double maxHeightReset = UNKNOWN; + + /** + * @param node + */ + protected void rememberResetValues(Node node) + { + if (node instanceof javafx.scene.layout.Region) + { + javafx.scene.layout.Region lRegion = (javafx.scene.layout.Region)node; + + // setup the reset values on the first apply + if (minWidthReset == UNKNOWN) minWidthReset = lRegion.getMinWidth(); + if (prefWidthReset == UNKNOWN) prefWidthReset = lRegion.getPrefWidth(); + if (maxWidthReset == UNKNOWN) maxWidthReset = lRegion.getMaxWidth(); + if (minHeightReset == UNKNOWN) minHeightReset = lRegion.getMinHeight(); + if (prefHeightReset == UNKNOWN) prefHeightReset = lRegion.getPrefHeight(); + if (maxHeightReset == UNKNOWN) maxHeightReset = lRegion.getMaxHeight(); + } + } + + /** + * @param node + */ + protected void apply(Node node) + { + if (node instanceof javafx.scene.layout.Region) + { + javafx.scene.layout.Region lRegion = (javafx.scene.layout.Region)node; + + // setup the reset values on the first apply + rememberResetValues(lRegion); + + // either set or reset values + lRegion.setMinWidth(minWidth >= 0 ? minWidth : minWidthReset); + lRegion.setPrefWidth(prefWidth >= 0 ? prefWidth : prefWidthReset); + lRegion.setMaxWidth(maxWidth >= 0 ? maxWidth : maxWidthReset); + lRegion.setMinHeight(minHeight >= 0 ? minHeight : minHeightReset); + lRegion.setPrefHeight(prefHeight >= 0 ? prefHeight : prefHeightReset); + lRegion.setMaxHeight(maxHeight >= 0 ? maxHeight : maxHeightReset); + } + } + + } + static final double UNKNOWN = -Double.MIN_NORMAL + 10.0; + + /** + * + */ + static public void overrideMaxWidth(Node node, C c) + { + // just to prevent problems + if (node == null) return; + + // make max issues go away + if (node instanceof javafx.scene.layout.Region) + { + javafx.scene.layout.Region lRegion = (javafx.scene.layout.Region)node; + lRegion.setMaxWidth( c.maxWidth >= 0 ? c.maxWidth : Double.MAX_VALUE); + } + } + + /** + * + */ + static public void overrideMaxHeight(Node node, C c) + { + // just to prevent problems + if (node == null) return; + + // make max issues go away + if (node instanceof javafx.scene.layout.Region) + { + javafx.scene.layout.Region lRegion = (javafx.scene.layout.Region)node; + lRegion.setMaxHeight( c.maxHeight >= 0 ? c.maxHeight : Double.MAX_VALUE); + } + } + +} diff --git a/DuskZ/src/jfxtras/scene/layout/HBox.java b/DuskZ/src/jfxtras/scene/layout/HBox.java new file mode 100644 index 0000000..b1278b9 --- /dev/null +++ b/DuskZ/src/jfxtras/scene/layout/HBox.java @@ -0,0 +1,253 @@ +/** + * Copyright (c) 2011-2021, JFXtras + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the organization nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL JFXTRAS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package jfxtras.scene.layout; + +import java.util.WeakHashMap; + +import javafx.collections.ListChangeListener; +import javafx.scene.Node; + +/** + * A drop-in replacement for JavaFX's HBox using layout constraints. + * So instead of: + * [source,java] + * -- + * HBox lHBox = new HBox(5.0); + * Button b1 = new Button("short"); + * lHBox.getChildren().add(b1); + * HBox.setHgrow(b1, Priority.ALWAYS); + * -- + * + * You can write: + * [source,java] + * -- + * HBox lHBox = new HBox(5.0); + * lHBox.add(new Button("short"), new HBox.C().hgrow(Priority.ALWAYS)); + * -- + * + * This class is not a reimplementation of HBox, but only applies a different API. + * + * @author Tom Eugelink + * + */ +public class HBox extends javafx.scene.layout.HBox +{ + // ======================================================================================================================================================== + // Constructors + + /** + * + */ + public HBox() + { + super(); + construct(); + } + + /** + * + * @param spacing + */ + public HBox(double spacing) + { + super(spacing); + construct(); + } + + /** + * + * @param spacing + * @param nodes + */ + public HBox(double spacing, Node... nodes) { + super(spacing, nodes); + construct(); + } + + /** + * + * @param nodes + */ + public HBox(Node... nodes) { + super(nodes); + construct(); + } + + /** + * + */ + private void construct() + { + getChildren().addListener(new ListChangeListener() + { + @Override + public void onChanged(javafx.collections.ListChangeListener.Change changes) + { + while (changes.next()) + { + for (Node lNode : changes.getAddedSubList()) + { + C lC = cMap.get(lNode); + if (lC != null) lC.apply(lNode); + } + } + } + }); + } + + + // ======================================================================================================================================================== + // Properties + + /** + * + * @param value + * @return + */ + public HBox withSpacing(double value) + { + super.setSpacing(value); + return this; + } + + + // ======================================================================================================================================================== + // Layout constraints + + /** + * The layout constraints + * + */ + public static class C extends GenericLayoutConstraints.C + { + // hgrow + public C hgrow(javafx.scene.layout.Priority value) { this.hgrow = value; return this; } + private javafx.scene.layout.Priority hgrow = null; + private javafx.scene.layout.Priority hgrowReset = null; + + // margin + public C margin(javafx.geometry.Insets value) { this.margin = value; return this; } + private javafx.geometry.Insets margin = null; + private javafx.geometry.Insets marginReset = null; + + /** + * @param node + */ + protected void rememberResetValues(Node node) + { + super.rememberResetValues(node); + hgrowReset = javafx.scene.layout.HBox.getHgrow(node); + marginReset = javafx.scene.layout.HBox.getMargin(node); + } + + /** + * + * @param node + */ + protected void apply(Node node) + { + // sanatize the node + super.apply(node); + + // apply constraints + if (hgrow != null) GenericLayoutConstraints.overrideMaxWidth(node, this); + javafx.scene.layout.HBox.setHgrow(node, hgrow != null ? hgrow : hgrowReset); + javafx.scene.layout.HBox.setMargin(node, margin != null ? margin : marginReset); + } + } + + /** + * The collection of layout constraints + */ + private WeakHashMap cMap = new WeakHashMap<>(); + + /** + * Add + */ + public HBox add(Node node) + { + // add node + getChildren().add(node); + return this; + } + + /** + * Add + */ + public HBox add(Node node, C c) + { + // remember constraints + cMap.put(node, c); + c.rememberResetValues(node); + + // add node + getChildren().add(node); + return this; + } + + /** + * Remove a node completely + * @param node + */ + public HBox remove(Node node) + { + // remove node + getChildren().remove(node); + + // remove constraints + cMap.remove(node); + return this; + } + + /** + * set constraint without adding the node (in case the node might end up here because of an animation or something) + */ + public void setConstraint(Node node, C c) + { + // remember constraints + cMap.put(node, c); + c.rememberResetValues(node); + } + + /** + * Remove a constraint, not the node. + * @param node + */ + public void removeConstraintsFor(Node node) + { + cMap.remove(node); + } + + /** + * Remove a node, not the constraints. + * @param node + */ + public void removeNode(Node node) + { + getChildren().remove(node); + } +} diff --git a/DuskZ/src/jfxtras/scene/layout/VBox.java b/DuskZ/src/jfxtras/scene/layout/VBox.java new file mode 100644 index 0000000..4b2d0da --- /dev/null +++ b/DuskZ/src/jfxtras/scene/layout/VBox.java @@ -0,0 +1,257 @@ +/** + * Copyright (c) 2011-2021, JFXtras + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the organization nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL JFXTRAS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package jfxtras.scene.layout; + +import java.util.WeakHashMap; + +import javafx.collections.ListChangeListener; +import javafx.scene.Node; + +/** + * A drop-in replacement for JavaFX's VBox using layout constraints. + * So instead of: + * [source,java] + * -- + * VBox lVBox = new VBox(5.0); + * Button b1 = new Button("short"); + * lVBox.getChildren().add(b1); + * VBox.setVgrow(b1, Priority.ALWAYS); + * -- + * + * You can write: + * [source,java] + * -- + * VBox lVBox = new VBox(5.0); + * lVBox.add(new Button("short"), new VBox.C().vgrow(Priority.ALWAYS)); + * -- + * + * This class is not a reimplementation of VBox, but only applies a different API. + * + * @author Tom Eugelink + * + */ +public class VBox extends javafx.scene.layout.VBox +{ + // ======================================================================================================================================================== + // Constructors + + /** + * + */ + public VBox() + { + super(); + construct(); + } + + /** + * + * @param spacing + */ + public VBox(double spacing) + { + super(spacing); + construct(); + } + + /** + * + * @param spacing + * @param nodes + */ + public VBox(double spacing, Node... nodes) { + super(spacing, nodes); + construct(); + } + + /** + * + * @param nodes + */ + public VBox(Node... nodes) { + super(nodes); + construct(); + } + + /** + * + */ + private void construct() + { + getChildren().addListener(new ListChangeListener() + { + @Override + public void onChanged(javafx.collections.ListChangeListener.Change changes) + { + while (changes.next()) + { + for (Node lNode : changes.getAddedSubList()) + { + C lC = cMap.get(lNode); + if (lC != null) lC.apply(lNode); + } + } + } + }); + } + + + // ======================================================================================================================================================== + // Properties + + /** + * + * @param value + * @return + */ + public VBox withSpacing(double value) + { + super.setSpacing(value); + return this; + } + + + // ======================================================================================================================================================== + // Layout constraints + + /** + * The layout constraints + */ + public static class C extends GenericLayoutConstraints.C + { + // vgrow + public C vgrow(javafx.scene.layout.Priority value) { this.vgrow = value; return this; } + private javafx.scene.layout.Priority vgrow = null; + private javafx.scene.layout.Priority vgrowReset = null; + + // margin + public C margin(javafx.geometry.Insets value) { this.margin= value; return this; } + javafx.geometry.Insets margin = null; + javafx.geometry.Insets marginReset = null; + + /** + * @param node + */ + protected void rememberResetValues(Node node) + { + super.rememberResetValues(node); + vgrowReset = javafx.scene.layout.VBox.getVgrow(node); + marginReset = javafx.scene.layout.VBox.getMargin(node); + } + + /** + * + * @param node + */ + protected void apply(Node node) + { + // sanatize the node + super.apply(node); + + // apply constraints + if (vgrow != null) GenericLayoutConstraints.overrideMaxHeight(node, this); + javafx.scene.layout.VBox.setVgrow(node, vgrow != null ? vgrow : vgrowReset); + javafx.scene.layout.VBox.setMargin(node, margin != null ? margin : marginReset); + } + } + + /** + * The collection of layout constraints + */ + private WeakHashMap cMap = new WeakHashMap<>(); + + /** + * + * @param node + */ + public VBox add(Node node) + { + // add node + getChildren().add(node); + return this; + } + + /** + * + * @param node + * @param c + */ + public VBox add(Node node, C c) + { + // remember constraints + cMap.put(node, c); + c.rememberResetValues(node); + + // add node + getChildren().add(node); + return this; + } + + /** + * Remove a node completely + * @param node + */ + public VBox remove(Node node) + { + // remove node + getChildren().remove(node); + + // remove constraints + cMap.remove(node); + return this; + } + + /** + * set constraint without adding the node (in case the node might end up here because of an animation or something) + * @param node + * @param c + */ + public void setConstraint(Node node, C c) + { + // remember constraints + cMap.put(node, c); + c.rememberResetValues(node); + } + + /** + * Remove a constraint, not the node. + * @param node + */ + public void removeConstraintsFor(Node node) + { + cMap.remove(node); + } + + /** + * Remove a node, not the constraints. + * @param node + */ + public void removeNode(Node node) + { + getChildren().remove(node); + } +} diff --git a/DuskZ/src/jfxtras/util/NodeUtil.java b/DuskZ/src/jfxtras/util/NodeUtil.java new file mode 100644 index 0000000..ca85986 --- /dev/null +++ b/DuskZ/src/jfxtras/util/NodeUtil.java @@ -0,0 +1,336 @@ +/** + * Copyright (c) 2011-2021, JFXtras + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the organization nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL JFXTRAS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package jfxtras.util; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import javafx.beans.Observable; +import javafx.beans.binding.DoubleBinding; +import javafx.beans.value.ObservableNumberValue; +import javafx.collections.FXCollections; +import javafx.collections.ObservableList; +import javafx.scene.Group; +import javafx.scene.Node; +import javafx.scene.Parent; +import javafx.scene.layout.Pane; + +/** + * Utility class that provides methods to simplify node handling. Possible use + * cases are searching for nodes at specific locations, adding/removing nodes + * to/from parents (Parent interface does not give write access to children). + * + * @author Michael Hoffer <info@michaelhoffer.de> + * @author Tom Eugelink <tbee@tbee.org> + */ +public class NodeUtil { + + // no instantiation allowed + private NodeUtil() { + throw new AssertionError(); // not in this class either! + } + + /** + * + * @param node + * @return The X coordinate of the node within the parent. + */ + static public double xInParent(Node node, Node parent) { + double lX = 0; + + while (node != parent) { + double lXDelta = node.getBoundsInParent().getMinX(); + lX += lXDelta; + //System.out.println("xInParent " + node + " -> " + lXDelta + " " + lX); + node = node.getParent(); + } + return lX; + } + + /** + * + * @param node + * @return The Y coordinate of the node within the parent. + */ + static public double yInParent(Node node, Node parent) { + double lY = 0; + + while (node != parent) { + double lYDelta = node.getBoundsInParent().getMinY(); + lY += lYDelta; + //System.out.println("yInParent " + node + " -> " + lYDelta + " " + lY); + node = node.getParent(); + } + return lY; + } + + /** + * + * @param node + * @return The X screen coordinate of the node. + */ + static public double screenX(Node node) { + return sceneX(node) + node.getScene().getWindow().getX(); + } + + /** + * + * @param node + * @return The Y screen coordinate of the node. + */ + static public double screenY(Node node) { + return sceneY(node) + node.getScene().getWindow().getY(); + } + + /** + * + * @param node + * @return The X scene coordinate of the node. + */ + static public double sceneX(Node node) { + return node.localToScene(node.getBoundsInLocal()).getMinX() + node.getScene().getX(); + } + + /** + * + * @param node + * @return The Y scene coordinate of the node. + */ + static public double sceneY(Node node) { + return node.localToScene(node.getBoundsInLocal()).getMinY() + node.getScene().getY(); + } + + /** + * Removes the specified node from its parent. + * + * @param n the node to remove + * + * @throws IllegalArgumentException if an unsupported parent class has been + * specified or the parent is null + */ + public static void removeFromParent(Node n) { + if (n.getParent() instanceof Group) { + ((Group) n.getParent()).getChildren().remove(n); + } else if (n.getParent() instanceof Pane) { + ((Pane) n.getParent()).getChildren().remove(n); + } else { + throw new IllegalArgumentException("Unsupported parent: " + n.getParent()); + } + } + + /** + * Adds the given node to the specified parent. + * + * @param p parent + * @param n node + * + * @throws IllegalArgumentException if an unsupported parent class has been + * specified or the parent is null + */ + public static void addToParent(Parent p, Node n) { + if (p instanceof Group) { + ((Group) p).getChildren().add(n); + } else if (p instanceof Pane) { + ((Pane) p).getChildren().add(n); + } else { + throw new IllegalArgumentException("Unsupported parent: " + p); + } + } + + /** + * Returns the first node at the given location that is an instance of the + * specified class object. The search is performed recursively until either + * a node has been found or a leaf node is reached. + * + * @param p parent node + * @param sceneX x coordinate + * @param sceneY y coordinate + * @param nodeClass node class to search for + * @return a node that contains the specified screen coordinates and is an + * instance of the specified class or {@code null} if no such node + * exist + */ + public static Node getNode(Parent p, double sceneX, double sceneY, Class nodeClass) { + + // dammit! javafx uses "wrong" children order. + List rightOrder = new ArrayList<>(); + rightOrder.addAll(p.getChildrenUnmodifiable()); + Collections.reverse(rightOrder); + + for (Node n : rightOrder) { + boolean contains = n.contains(n.sceneToLocal(sceneX, sceneY)); + + if (contains) { + + if (nodeClass.isAssignableFrom(n.getClass())) { + return n; + } + + if (n instanceof Parent) { + return getNode((Parent) n, sceneX, sceneY, nodeClass); + } + } + } + + return null; + } + + /** + * This method prevents blurry horizontal or vertical lines, use snapXY(x) instead of x. + * @param position (x or y) + * @return + */ + public static double snapXY(double position) { + return ((int) position) + .5; + } + + /** + * This is the snapXY method for using in a binding, for example: + * p1.bind( snapXY( p2.multiply(0.1) )); + * + * @param position (x or y) + * @return + */ + public static DoubleBinding snapXY(final ObservableNumberValue position) { + return new DoubleBinding() { + { + super.bind(position); + } + + @Override + public void dispose() { + super.unbind(position); + } + + @Override + protected double computeValue() { + return NodeUtil.snapXY(position.doubleValue()); + } + + @Override + public ObservableList getDependencies() { + return FXCollections.singletonObservableList(position); + } + }; + } + + + /** + * This method prevents blurry horizontal or vertical lines, use snapWH(x, w) instead of w. + * @param position (x or y) + * @param offset (width or height) + * @return + */ + public static double snapWH(double position, double offset) { + return snapXY(position + offset) - snapXY(position); + } + + /** + * This is the snapXY method for using in a binding, for example: + * p1.bind( snapXY( p2.multiply(0.1) )); + * + * @param position (x or y) + * @param offset (width or height) + * @param dependencies + * @return + */ + public static DoubleBinding snapWH(final ObservableNumberValue position, final ObservableNumberValue offset, final Observable... dependencies) { + return new DoubleBinding() { + { + super.bind(dependencies); + } + + @Override + public void dispose() { + super.unbind(dependencies); + } + + @Override + protected double computeValue() { + return NodeUtil.snapWH(position.doubleValue(), offset.doubleValue()); + } + + @Override + public ObservableList getDependencies() { + return (dependencies.length == 1)? + FXCollections.singletonObservableList(dependencies[0]) + : FXCollections.unmodifiableObservableList(FXCollections.observableArrayList(dependencies)); + } + }; + } + + /** + * This method is used to prevent the remove-add constructs on styleclasses. + * This prevents CSS reprocessed unnecessary, because that is a time consuming process. + * @param node + * @param styleclass + */ + static public void addStyleClass(Node node, String styleclass) { + if (!node.getStyleClass().contains(styleclass)) { + node.getStyleClass().add(styleclass); + } + } + + /** + * The remove operation is already "cheap", so this method is here to only mirror the addStyleClass (which is not cheap) + * @param node + * @param styleclass + */ + static public void removeStyleClass(Node node, String styleclass) { + node.getStyleClass().remove(styleclass); + } + + /** + * Derive a CSS file in the same package and with the same name as the node + * @param n + * @return + */ + static public String deriveCssFile(Node n) { + Class c = n.getClass(); + return c.getResource("/" + c.getPackage().getName().replaceAll("\\.", "/") + "/" + c.getSimpleName() + ".css").toExternalForm(); + } + + /** + * Determine if a node is effectively visible. + * This means that if the node or any of its parents are not visible, the node is effectively not visible. + * Otherwise it is visible. + * + * @param n + * @return + */ + static public boolean isEffectivelyVisible(Node n) { + while (n != null) { + if (!n.isVisible()) { + return false; + } + n = n.getParent(); + } + return true; + } + +} diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..bd70261 --- /dev/null +++ b/Makefile @@ -0,0 +1,78 @@ + +# Temporary makefile + +SUBDIRS=DuskCommon DuskServer DuskZ +JAVA_HOME=/usr/local/jdk +JAVAFX_HOME=/usr/local/javafx-sdk +ANT=/usr/local/netbeans/extide/ant/bin/ant + +JAVAC=$(JAVA_HOME)/bin/javac +JAVA=$(JAVA_HOME)/bin/java + +maven_central_JARS = \ + jakarta.xml.bind:jakarta.xml.bind-api:4.0.0 \ + jakarta.activation:jakarta.activation-api:2.1.1 \ + com.sun.xml.bind:jaxb-impl:4.0.1 \ + com.sun.xml.bind:jaxb-core:4.0.2 + +# two possible javascript engines +maven_central_JARS += \ + org.openjdk.nashorn:nashorn-core:15.4 \ + org.ow2.asm:asm:7.3.1 \ + org.ow2.asm:asm-commons:7.3.1 \ + org.ow2.asm:asm-tree:7.3.1 \ + org.ow2.asm:asm-analysis:7.3.1 \ + org.ow2.asm:asm-util:7.3.1 + +#maven_central_JARS += \ +# org.mozilla:rhino:1.7.14 \ +# org.mozilla:rhino-engine:1.7.14 + +javafx_LIBS=$(patsubst %,$(JAVAFX_HOME)/lib/%.jar,javafx.base javafx.controls javafx.graphics) +server_LIBS=$(strip $(foreach lib,$(maven_central_JARS),\ + .lib/$(word 2,$(subst :, ,$(lib)))-$(word 3,$(subst :, ,$(lib))).jar)) + +client_LIBS=$(javafx_LIBS) +tilez_LIBS=$(strip $(foreach lib,$(maven_central_JARS),\ + .lib/$(word 2,$(subst :, ,$(lib)))-$(word 3,$(subst :, ,$(lib))).jar) \ + DuskServer/build/classes \ + DuskZ/build/classes \ + $(javafx_LIBS)) + +E:= +S:=$(E) $(E) + +all: + $(JAVAC) -g -d DuskCommon/build/classes \ + $$(find DuskCommon/src -name '*.java') + $(JAVAC) -g -d DuskServer/build/classes \ + -cp $(subst $(S),:,$(server_LIBS) DuskCommon/build/classes) \ + $$(find DuskServer/src -name '*.java') + $(JAVAC) -g -d DuskZ/build/classes \ + -cp $(subst $(S),:,$(client_LIBS) DuskCommon/build/classes) \ + $$(find DuskZ/src -name '*.java') + +tilez: + $(JAVAC) -g -d TileZ/build/classes \ + -cp $(subst $(S),:,$(tilez_LIBS)) \ + $$(find TileZ/src -name '*.java') + +clean: + set -e ; for d in $(SUBDIRS); do \ + rm -rf "$$d/build" ; \ + done + +run-server: + $(JAVA) \ + -cp $(subst $(S),:,$(server_LIBS) DuskServer/build/classes DuskCommon/build/classes) \ + duskz.server.entityz.GameServer game + +run-client: + $(JAVA) \ + --module-path $(JAVAFX_HOME)/lib \ + --add-modules javafx.graphics,javafx.controls \ + -cp $(subst $(S),:,DuskZ/build/classes DuskCommon/build/classes DuskZ/src) \ + duskz.client.fx.DuskFX + + +include maven.make diff --git a/README b/README new file mode 100644 index 0000000..6140755 --- /dev/null +++ b/README @@ -0,0 +1,28 @@ + +DuskRPG with JavaFX client +-------------------------- + +This updates the code to build and run with OpenJDK 19 and JavaFX 19 +using the existing file structure. This is a placeholder before +converting to a modularised project. + +Info +---- + +Only a rudimentary makefile is provided. + +First: + +$ make maven-init +$ make all + +This downloads maven artifacts required and then compiles everything, +maven-init only needs to be run once. + +$ make run-server + +Start the server. A compatible game must be installed in './game'. + +$ make run-client + +Run the client. Requires client data files. diff --git a/TileZ/src/au/notzed/tilez/MapLayer.java b/TileZ/src/au/notzed/tilez/MapLayer.java index 09de41a..23c4818 100644 --- a/TileZ/src/au/notzed/tilez/MapLayer.java +++ b/TileZ/src/au/notzed/tilez/MapLayer.java @@ -27,7 +27,7 @@ import javafx.util.Callback; /** * Layer of a map. i.e. a set of tiles. - * + * * Hmm, should this virtualise it's view? * @author Michael Zucchi */ @@ -43,11 +43,9 @@ public class MapLayer extends BorderPane { setBottom(hscroll); setRight(vscroll); } - - + + void main() { - ComboBoxListCell.forListView(null); - ListView lv = null; lv.setCellFactory(new Callback() { @@ -56,12 +54,12 @@ public class MapLayer extends BorderPane { throw new UnsupportedOperationException("Not supported yet."); } }); - + } class MapView extends Pane { // track/update visible portion? } - - + + } diff --git a/TileZ/src/au/notzed/tilez/io/Data.java b/TileZ/src/au/notzed/tilez/io/Data.java index af2b2c1..c23d4ba 100644 --- a/TileZ/src/au/notzed/tilez/io/Data.java +++ b/TileZ/src/au/notzed/tilez/io/Data.java @@ -1,25 +1,24 @@ // -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2013.02.27 at 01:07:39 PM CST +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2013.02.27 at 01:07:39 PM CST // package au.notzed.tilez.io; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; -import javax.xml.bind.annotation.XmlValue; -import javax.xml.bind.annotation.adapters.NormalizedStringAdapter; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; - +import jakarta.xml.bind.annotation.XmlAccessType; +import jakarta.xml.bind.annotation.XmlAccessorType; +import jakarta.xml.bind.annotation.XmlAttribute; +import jakarta.xml.bind.annotation.XmlRootElement; +import jakarta.xml.bind.annotation.XmlType; +import jakarta.xml.bind.annotation.XmlValue; +import jakarta.xml.bind.annotation.adapters.NormalizedStringAdapter; +import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter; /** - * + * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { @@ -39,11 +38,11 @@ public class Data { /** * Gets the value of the encoding property. - * + * * @return * possible object is * {@link String } - * + * */ public String getEncoding() { return encoding; @@ -51,11 +50,11 @@ public class Data { /** * Sets the value of the encoding property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setEncoding(String value) { this.encoding = value; @@ -63,11 +62,11 @@ public class Data { /** * Gets the value of the compression property. - * + * * @return * possible object is * {@link String } - * + * */ public String getCompression() { return compression; @@ -75,11 +74,11 @@ public class Data { /** * Sets the value of the compression property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setCompression(String value) { this.compression = value; @@ -87,11 +86,11 @@ public class Data { /** * Gets the value of the value property. - * + * * @return * possible object is * {@link String } - * + * */ public String getvalue() { return value; @@ -99,11 +98,11 @@ public class Data { /** * Sets the value of the value property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setvalue(String value) { this.value = value; diff --git a/TileZ/src/au/notzed/tilez/io/Image.java b/TileZ/src/au/notzed/tilez/io/Image.java index 0df4b35..b597b25 100644 --- a/TileZ/src/au/notzed/tilez/io/Image.java +++ b/TileZ/src/au/notzed/tilez/io/Image.java @@ -1,24 +1,23 @@ // -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2013.02.27 at 01:07:39 PM CST +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2013.02.27 at 01:07:39 PM CST // package au.notzed.tilez.io; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; -import javax.xml.bind.annotation.adapters.NormalizedStringAdapter; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; - +import jakarta.xml.bind.annotation.XmlAccessType; +import jakarta.xml.bind.annotation.XmlAccessorType; +import jakarta.xml.bind.annotation.XmlAttribute; +import jakarta.xml.bind.annotation.XmlRootElement; +import jakarta.xml.bind.annotation.XmlType; +import jakarta.xml.bind.annotation.adapters.NormalizedStringAdapter; +import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter; /** - * + * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { @@ -41,11 +40,11 @@ public class Image { /** * Gets the value of the format property. - * + * * @return * possible object is * {@link String } - * + * */ public String getFormat() { return format; @@ -53,11 +52,11 @@ public class Image { /** * Sets the value of the format property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setFormat(String value) { this.format = value; @@ -65,11 +64,11 @@ public class Image { /** * Gets the value of the id property. - * + * * @return * possible object is * {@link String } - * + * */ public String getId() { return id; @@ -77,11 +76,11 @@ public class Image { /** * Sets the value of the id property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setId(String value) { this.id = value; @@ -89,11 +88,11 @@ public class Image { /** * Gets the value of the source property. - * + * * @return * possible object is * {@link String } - * + * */ public String getSource() { return source; @@ -101,11 +100,11 @@ public class Image { /** * Sets the value of the source property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setSource(String value) { this.source = value; @@ -113,11 +112,11 @@ public class Image { /** * Gets the value of the trans property. - * + * * @return * possible object is * {@link String } - * + * */ public String getTrans() { return trans; @@ -125,11 +124,11 @@ public class Image { /** * Sets the value of the trans property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setTrans(String value) { this.trans = value; @@ -137,11 +136,11 @@ public class Image { /** * Gets the value of the data property. - * + * * @return * possible object is * {@link Data } - * + * */ public Data getData() { return data; @@ -149,11 +148,11 @@ public class Image { /** * Sets the value of the data property. - * + * * @param value * allowed object is * {@link Data } - * + * */ public void setData(Data value) { this.data = value; diff --git a/TileZ/src/au/notzed/tilez/io/Layer.java b/TileZ/src/au/notzed/tilez/io/Layer.java index d646558..82d4e33 100644 --- a/TileZ/src/au/notzed/tilez/io/Layer.java +++ b/TileZ/src/au/notzed/tilez/io/Layer.java @@ -1,26 +1,24 @@ // -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2013.02.27 at 01:07:39 PM CST +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2013.02.27 at 01:07:39 PM CST // package au.notzed.tilez.io; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; -import javax.xml.bind.annotation.adapters.CollapsedStringAdapter; -import javax.xml.bind.annotation.adapters.NormalizedStringAdapter; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; - +import jakarta.xml.bind.annotation.XmlAccessType; +import jakarta.xml.bind.annotation.XmlAccessorType; +import jakarta.xml.bind.annotation.XmlAttribute; +import jakarta.xml.bind.annotation.XmlElement; +import jakarta.xml.bind.annotation.XmlRootElement; +import jakarta.xml.bind.annotation.XmlType; +import jakarta.xml.bind.annotation.adapters.NormalizedStringAdapter; +import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter; /** - * + * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { @@ -51,11 +49,11 @@ public class Layer { /** * Gets the value of the name property. - * + * * @return * possible object is * {@link String } - * + * */ public String getName() { return name; @@ -63,11 +61,11 @@ public class Layer { /** * Sets the value of the name property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setName(String value) { this.name = value; @@ -75,11 +73,11 @@ public class Layer { /** * Gets the value of the width property. - * + * * @return * possible object is * {@link String } - * + * */ public int getWidth() { return width; @@ -87,11 +85,11 @@ public class Layer { /** * Sets the value of the width property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setWidth(int value) { this.width = value; @@ -99,11 +97,11 @@ public class Layer { /** * Gets the value of the height property. - * + * * @return * possible object is * {@link String } - * + * */ public int getHeight() { return height; @@ -111,11 +109,11 @@ public class Layer { /** * Sets the value of the height property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setHeight(int value) { this.height = value; @@ -123,11 +121,11 @@ public class Layer { /** * Gets the value of the x property. - * + * * @return * possible object is * {@link String } - * + * */ public int getX() { return x; @@ -135,11 +133,11 @@ public class Layer { /** * Sets the value of the x property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setX(int value) { this.x = value; @@ -147,11 +145,11 @@ public class Layer { /** * Gets the value of the y property. - * + * * @return * possible object is * {@link String } - * + * */ public int getY() { return y; @@ -159,11 +157,11 @@ public class Layer { /** * Sets the value of the y property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setY(int value) { this.y = value; @@ -171,11 +169,11 @@ public class Layer { /** * Gets the value of the opacity property. - * + * * @return * possible object is * {@link String } - * + * */ public float getOpacity() { return opacity; @@ -183,11 +181,11 @@ public class Layer { /** * Sets the value of the opacity property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setOpacity(float value) { this.opacity = value; @@ -195,11 +193,11 @@ public class Layer { /** * Gets the value of the visible property. - * + * * @return * possible object is * {@link String } - * + * */ public int getVisible() { return visible; @@ -207,11 +205,11 @@ public class Layer { /** * Sets the value of the visible property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setVisible(int value) { this.visible = value; @@ -219,11 +217,11 @@ public class Layer { /** * Gets the value of the properties property. - * + * * @return * possible object is * {@link Properties } - * + * */ public Properties getProperties() { return properties; @@ -231,11 +229,11 @@ public class Layer { /** * Sets the value of the properties property. - * + * * @param value * allowed object is * {@link Properties } - * + * */ public void setProperties(Properties value) { this.properties = value; @@ -243,11 +241,11 @@ public class Layer { /** * Gets the value of the data property. - * + * * @return * possible object is * {@link Data } - * + * */ public Data getData() { return data; @@ -255,11 +253,11 @@ public class Layer { /** * Sets the value of the data property. - * + * * @param value * allowed object is * {@link Data } - * + * */ public void setData(Data value) { this.data = value; diff --git a/TileZ/src/au/notzed/tilez/io/Map.java b/TileZ/src/au/notzed/tilez/io/Map.java index 6032f63..a60366f 100644 --- a/TileZ/src/au/notzed/tilez/io/Map.java +++ b/TileZ/src/au/notzed/tilez/io/Map.java @@ -1,29 +1,28 @@ // -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2013.02.27 at 01:07:39 PM CST +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2013.02.27 at 01:07:39 PM CST // package au.notzed.tilez.io; +import jakarta.xml.bind.annotation.XmlAccessType; +import jakarta.xml.bind.annotation.XmlAccessorType; +import jakarta.xml.bind.annotation.XmlAttribute; +import jakarta.xml.bind.annotation.XmlElement; +import jakarta.xml.bind.annotation.XmlElements; +import jakarta.xml.bind.annotation.XmlRootElement; +import jakarta.xml.bind.annotation.XmlType; +import jakarta.xml.bind.annotation.adapters.CollapsedStringAdapter; +import jakarta.xml.bind.annotation.adapters.NormalizedStringAdapter; +import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import java.util.ArrayList; import java.util.List; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElements; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; -import javax.xml.bind.annotation.adapters.CollapsedStringAdapter; -import javax.xml.bind.annotation.adapters.NormalizedStringAdapter; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; - /** - * + * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { @@ -67,11 +66,11 @@ public class Map { /** * Gets the value of the xmlns property. - * + * * @return * possible object is * {@link String } - * + * */ public String getXmlns() { return xmlns; @@ -79,11 +78,11 @@ public class Map { /** * Sets the value of the xmlns property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setXmlns(String value) { this.xmlns = value; @@ -91,11 +90,11 @@ public class Map { /** * Gets the value of the xmlnsXsi property. - * + * * @return * possible object is * {@link String } - * + * */ public String getXmlnsXsi() { return xmlnsXsi; @@ -103,11 +102,11 @@ public class Map { /** * Sets the value of the xmlnsXsi property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setXmlnsXsi(String value) { this.xmlnsXsi = value; @@ -115,11 +114,11 @@ public class Map { /** * Gets the value of the xsiSchemaLocation property. - * + * * @return * possible object is * {@link String } - * + * */ public String getXsiSchemaLocation() { return xsiSchemaLocation; @@ -127,11 +126,11 @@ public class Map { /** * Sets the value of the xsiSchemaLocation property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setXsiSchemaLocation(String value) { this.xsiSchemaLocation = value; @@ -139,11 +138,11 @@ public class Map { /** * Gets the value of the version property. - * + * * @return * possible object is * {@link String } - * + * */ public String getVersion() { return version; @@ -151,11 +150,11 @@ public class Map { /** * Sets the value of the version property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setVersion(String value) { this.version = value; @@ -163,11 +162,11 @@ public class Map { /** * Gets the value of the orientation property. - * + * * @return * possible object is * {@link String } - * + * */ public String getOrientation() { return orientation; @@ -175,11 +174,11 @@ public class Map { /** * Sets the value of the orientation property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setOrientation(String value) { this.orientation = value; @@ -187,11 +186,11 @@ public class Map { /** * Gets the value of the width property. - * + * * @return * possible object is * {@link String } - * + * */ public int getWidth() { return width; @@ -199,11 +198,11 @@ public class Map { /** * Sets the value of the width property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setWidth(int value) { this.width = value; @@ -211,11 +210,11 @@ public class Map { /** * Gets the value of the height property. - * + * * @return * possible object is * {@link String } - * + * */ public int getHeight() { return height; @@ -223,11 +222,11 @@ public class Map { /** * Sets the value of the height property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setHeight(int value) { this.height = value; @@ -235,11 +234,11 @@ public class Map { /** * Gets the value of the tilewidth property. - * + * * @return * possible object is * {@link String } - * + * */ public int getTilewidth() { return tilewidth; @@ -247,11 +246,11 @@ public class Map { /** * Sets the value of the tilewidth property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setTilewidth(int value) { this.tilewidth = value; @@ -259,11 +258,11 @@ public class Map { /** * Gets the value of the tileheight property. - * + * * @return * possible object is * {@link String } - * + * */ public int getTileheight() { return tileheight; @@ -271,11 +270,11 @@ public class Map { /** * Sets the value of the tileheight property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setTileheight(int value) { this.tileheight = value; @@ -283,11 +282,11 @@ public class Map { /** * Gets the value of the properties property. - * + * * @return * possible object is * {@link Properties } - * + * */ public Properties getProperties() { return properties; @@ -295,11 +294,11 @@ public class Map { /** * Sets the value of the properties property. - * + * * @param value * allowed object is * {@link Properties } - * + * */ public void setProperties(Properties value) { this.properties = value; @@ -307,25 +306,25 @@ public class Map { /** * Gets the value of the tileset property. - * + * *

* This accessor method returns a reference to the live list, * not a snapshot. Therefore any modification you make to the * returned list will be present inside the JAXB object. * This is why there is not a set method for the tileset property. - * + * *

* For example, to add a new item, do as follows: *

      *    getTileset().add(newItem);
      * 
- * - * + * + * *

* Objects of the following type(s) are allowed in the list * {@link Tileset } - * - * + * + * */ public List getTileset() { if (tileset == null) { @@ -336,26 +335,26 @@ public class Map { /** * Gets the value of the layerOrObjectgroup property. - * + * *

* This accessor method returns a reference to the live list, * not a snapshot. Therefore any modification you make to the * returned list will be present inside the JAXB object. * This is why there is not a set method for the layerOrObjectgroup property. - * + * *

* For example, to add a new item, do as follows: *

      *    getLayerOrObjectgroup().add(newItem);
      * 
- * - * + * + * *

* Objects of the following type(s) are allowed in the list * {@link Layer } * {@link Objectgroup } - * - * + * + * */ public List getLayerOrObjectgroup() { if (layerOrObjectgroup == null) { diff --git a/TileZ/src/au/notzed/tilez/io/Object.java b/TileZ/src/au/notzed/tilez/io/Object.java index d40335d..f05d376 100644 --- a/TileZ/src/au/notzed/tilez/io/Object.java +++ b/TileZ/src/au/notzed/tilez/io/Object.java @@ -1,24 +1,24 @@ // -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2013.02.27 at 01:07:39 PM CST +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2013.02.27 at 01:07:39 PM CST // package au.notzed.tilez.io; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; -import javax.xml.bind.annotation.adapters.NormalizedStringAdapter; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; +import jakarta.xml.bind.annotation.XmlAccessType; +import jakarta.xml.bind.annotation.XmlAccessorType; +import jakarta.xml.bind.annotation.XmlAttribute; +import jakarta.xml.bind.annotation.XmlRootElement; +import jakarta.xml.bind.annotation.XmlType; +import jakarta.xml.bind.annotation.adapters.NormalizedStringAdapter; +import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter; /** - * + * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { @@ -47,11 +47,11 @@ public class Object { /** * Gets the value of the name property. - * + * * @return * possible object is * {@link String } - * + * */ public String getName() { return name; @@ -59,11 +59,11 @@ public class Object { /** * Sets the value of the name property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setName(String value) { this.name = value; @@ -71,11 +71,11 @@ public class Object { /** * Gets the value of the type property. - * + * * @return * possible object is * {@link String } - * + * */ public String getType() { return type; @@ -83,11 +83,11 @@ public class Object { /** * Sets the value of the type property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setType(String value) { this.type = value; @@ -95,11 +95,11 @@ public class Object { /** * Gets the value of the x property. - * + * * @return * possible object is * {@link String } - * + * */ public int getX() { return x; @@ -107,11 +107,11 @@ public class Object { /** * Sets the value of the x property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setX(int value) { this.x = value; @@ -119,11 +119,11 @@ public class Object { /** * Gets the value of the y property. - * + * * @return * possible object is * {@link String } - * + * */ public int getY() { return y; @@ -131,11 +131,11 @@ public class Object { /** * Sets the value of the y property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setY(int value) { this.y = value; @@ -143,11 +143,11 @@ public class Object { /** * Gets the value of the width property. - * + * * @return * possible object is * {@link String } - * + * */ public int getWidth() { return width; @@ -155,11 +155,11 @@ public class Object { /** * Sets the value of the width property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setWidth(int value) { this.width = value; @@ -167,11 +167,11 @@ public class Object { /** * Gets the value of the height property. - * + * * @return * possible object is * {@link String } - * + * */ public int getHeight() { return height; @@ -179,11 +179,11 @@ public class Object { /** * Sets the value of the height property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setHeight(int value) { this.height = value; @@ -191,11 +191,11 @@ public class Object { /** * Gets the value of the properties property. - * + * * @return * possible object is * {@link Properties } - * + * */ public Properties getProperties() { return properties; @@ -203,11 +203,11 @@ public class Object { /** * Sets the value of the properties property. - * + * * @param value * allowed object is * {@link Properties } - * + * */ public void setProperties(Properties value) { this.properties = value; @@ -215,11 +215,11 @@ public class Object { /** * Gets the value of the image property. - * + * * @return * possible object is * {@link Image } - * + * */ public Image getImage() { return image; @@ -227,11 +227,11 @@ public class Object { /** * Sets the value of the image property. - * + * * @param value * allowed object is * {@link Image } - * + * */ public void setImage(Image value) { this.image = value; diff --git a/TileZ/src/au/notzed/tilez/io/ObjectFactory.java b/TileZ/src/au/notzed/tilez/io/ObjectFactory.java index 8b5e11c..a9ce8ef 100644 --- a/TileZ/src/au/notzed/tilez/io/ObjectFactory.java +++ b/TileZ/src/au/notzed/tilez/io/ObjectFactory.java @@ -1,29 +1,29 @@ // -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2013.02.27 at 01:07:39 PM CST +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2013.02.27 at 01:07:39 PM CST // package au.notzed.tilez.io; -import javax.xml.bind.annotation.XmlRegistry; +import jakarta.xml.bind.annotation.XmlRegistry; /** - * This object contains factory methods for each - * Java content interface and Java element interface - * generated in the generated package. - *

An ObjectFactory allows you to programatically - * construct new instances of the Java representation - * for XML content. The Java representation of XML - * content can consist of schema derived interfaces - * and classes representing the binding of schema - * type definitions, element declarations and model - * groups. Factory methods for each of these are + * This object contains factory methods for each + * Java content interface and Java element interface + * generated in the generated package. + *

An ObjectFactory allows you to programatically + * construct new instances of the Java representation + * for XML content. The Java representation of XML + * content can consist of schema derived interfaces + * and classes representing the binding of schema + * type definitions, element declarations and model + * groups. Factory methods for each of these are * provided in this class. - * + * */ @XmlRegistry public class ObjectFactory { @@ -31,14 +31,14 @@ public class ObjectFactory { /** * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: generated - * + * */ public ObjectFactory() { } /** * Create an instance of {@link Tileset } - * + * */ public Tileset createTileset() { return new Tileset(); @@ -46,7 +46,7 @@ public class ObjectFactory { /** * Create an instance of {@link Image } - * + * */ public Image createImage() { return new Image(); @@ -54,7 +54,7 @@ public class ObjectFactory { /** * Create an instance of {@link Tile } - * + * */ public Tile createTile() { return new Tile(); @@ -62,7 +62,7 @@ public class ObjectFactory { /** * Create an instance of {@link Properties } - * + * */ public Properties createProperties() { return new Properties(); @@ -70,7 +70,7 @@ public class ObjectFactory { /** * Create an instance of {@link Objectgroup } - * + * */ public Objectgroup createObjectgroup() { return new Objectgroup(); @@ -78,7 +78,7 @@ public class ObjectFactory { /** * Create an instance of {@link Object } - * + * */ public Object createObject() { return new Object(); @@ -86,7 +86,7 @@ public class ObjectFactory { /** * Create an instance of {@link Data } - * + * */ public Data createData() { return new Data(); @@ -94,7 +94,7 @@ public class ObjectFactory { /** * Create an instance of {@link Map } - * + * */ public Map createMap() { return new Map(); @@ -102,7 +102,7 @@ public class ObjectFactory { /** * Create an instance of {@link Layer } - * + * */ public Layer createLayer() { return new Layer(); @@ -110,7 +110,7 @@ public class ObjectFactory { /** * Create an instance of {@link Property } - * + * */ public Property createProperty() { return new Property(); diff --git a/TileZ/src/au/notzed/tilez/io/Objectgroup.java b/TileZ/src/au/notzed/tilez/io/Objectgroup.java index 4c4da5f..452f77a 100644 --- a/TileZ/src/au/notzed/tilez/io/Objectgroup.java +++ b/TileZ/src/au/notzed/tilez/io/Objectgroup.java @@ -1,26 +1,25 @@ // -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2013.02.27 at 01:07:39 PM CST +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2013.02.27 at 01:07:39 PM CST // package au.notzed.tilez.io; +import jakarta.xml.bind.annotation.XmlAccessType; +import jakarta.xml.bind.annotation.XmlAccessorType; +import jakarta.xml.bind.annotation.XmlAttribute; +import jakarta.xml.bind.annotation.XmlRootElement; +import jakarta.xml.bind.annotation.XmlType; +import jakarta.xml.bind.annotation.adapters.NormalizedStringAdapter; +import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import java.util.ArrayList; import java.util.List; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; -import javax.xml.bind.annotation.adapters.NormalizedStringAdapter; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; - /** - * + * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { @@ -44,11 +43,11 @@ public class Objectgroup { /** * Gets the value of the name property. - * + * * @return * possible object is * {@link String } - * + * */ public String getName() { return name; @@ -56,11 +55,11 @@ public class Objectgroup { /** * Sets the value of the name property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setName(String value) { this.name = value; @@ -68,11 +67,11 @@ public class Objectgroup { /** * Gets the value of the width property. - * + * * @return * possible object is * {@link String } - * + * */ public int getWidth() { return width; @@ -80,11 +79,11 @@ public class Objectgroup { /** * Sets the value of the width property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setWidth(int value) { this.width = value; @@ -92,11 +91,11 @@ public class Objectgroup { /** * Gets the value of the height property. - * + * * @return * possible object is * {@link String } - * + * */ public int getHeight() { return height; @@ -104,11 +103,11 @@ public class Objectgroup { /** * Sets the value of the height property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setHeight(int value) { this.height = value; @@ -116,11 +115,11 @@ public class Objectgroup { /** * Gets the value of the x property. - * + * * @return * possible object is * {@link String } - * + * */ public int getX() { return x; @@ -128,11 +127,11 @@ public class Objectgroup { /** * Sets the value of the x property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setX(int value) { this.x = value; @@ -140,11 +139,11 @@ public class Objectgroup { /** * Gets the value of the y property. - * + * * @return * possible object is * {@link String } - * + * */ public int getY() { return y; @@ -152,11 +151,11 @@ public class Objectgroup { /** * Sets the value of the y property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setY(int value) { this.y = value; @@ -164,25 +163,25 @@ public class Objectgroup { /** * Gets the value of the object property. - * + * *

* This accessor method returns a reference to the live list, * not a snapshot. Therefore any modification you make to the * returned list will be present inside the JAXB object. * This is why there is not a set method for the object property. - * + * *

* For example, to add a new item, do as follows: *

      *    getObject().add(newItem);
      * 
- * - * + * + * *

* Objects of the following type(s) are allowed in the list * {@link Object } - * - * + * + * */ public List getObject() { if (object == null) { diff --git a/TileZ/src/au/notzed/tilez/io/Properties.java b/TileZ/src/au/notzed/tilez/io/Properties.java index 1b7c417..e43733f 100644 --- a/TileZ/src/au/notzed/tilez/io/Properties.java +++ b/TileZ/src/au/notzed/tilez/io/Properties.java @@ -1,23 +1,23 @@ // -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2013.02.27 at 01:07:39 PM CST +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2013.02.27 at 01:07:39 PM CST // package au.notzed.tilez.io; +import jakarta.xml.bind.annotation.XmlAccessType; +import jakarta.xml.bind.annotation.XmlAccessorType; +import jakarta.xml.bind.annotation.XmlRootElement; +import jakarta.xml.bind.annotation.XmlType; import java.util.ArrayList; import java.util.List; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; /** - * + * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { @@ -30,25 +30,25 @@ public class Properties { /** * Gets the value of the property property. - * + * *

* This accessor method returns a reference to the live list, * not a snapshot. Therefore any modification you make to the * returned list will be present inside the JAXB object. * This is why there is not a set method for the property property. - * + * *

* For example, to add a new item, do as follows: *

      *    getProperty().add(newItem);
      * 
- * - * + * + * *

* Objects of the following type(s) are allowed in the list * {@link Property } - * - * + * + * */ public List getProperty() { if (property == null) { diff --git a/TileZ/src/au/notzed/tilez/io/Property.java b/TileZ/src/au/notzed/tilez/io/Property.java index a911217..752e583 100644 --- a/TileZ/src/au/notzed/tilez/io/Property.java +++ b/TileZ/src/au/notzed/tilez/io/Property.java @@ -1,24 +1,24 @@ // -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2013.02.27 at 01:07:39 PM CST +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2013.02.27 at 01:07:39 PM CST // package au.notzed.tilez.io; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; -import javax.xml.bind.annotation.adapters.NormalizedStringAdapter; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; +import jakarta.xml.bind.annotation.XmlAccessType; +import jakarta.xml.bind.annotation.XmlAccessorType; +import jakarta.xml.bind.annotation.XmlAttribute; +import jakarta.xml.bind.annotation.XmlRootElement; +import jakarta.xml.bind.annotation.XmlType; +import jakarta.xml.bind.annotation.adapters.NormalizedStringAdapter; +import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter; /** - * + * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "") @@ -34,11 +34,11 @@ public class Property { /** * Gets the value of the name property. - * + * * @return * possible object is * {@link String } - * + * */ public String getName() { return name; @@ -46,11 +46,11 @@ public class Property { /** * Sets the value of the name property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setName(String value) { this.name = value; @@ -58,11 +58,11 @@ public class Property { /** * Gets the value of the value property. - * + * * @return * possible object is * {@link String } - * + * */ public String getValue() { return value; @@ -70,11 +70,11 @@ public class Property { /** * Sets the value of the value property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setValue(String value) { this.value = value; diff --git a/TileZ/src/au/notzed/tilez/io/Tile.java b/TileZ/src/au/notzed/tilez/io/Tile.java index 4fe55ff..151c6b3 100644 --- a/TileZ/src/au/notzed/tilez/io/Tile.java +++ b/TileZ/src/au/notzed/tilez/io/Tile.java @@ -1,24 +1,21 @@ // -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2013.02.27 at 01:07:39 PM CST +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2013.02.27 at 01:07:39 PM CST // package au.notzed.tilez.io; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; -import javax.xml.bind.annotation.adapters.NormalizedStringAdapter; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; - +import jakarta.xml.bind.annotation.XmlAccessType; +import jakarta.xml.bind.annotation.XmlAccessorType; +import jakarta.xml.bind.annotation.XmlAttribute; +import jakarta.xml.bind.annotation.XmlRootElement; +import jakarta.xml.bind.annotation.XmlType; /** - * + * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { @@ -37,11 +34,11 @@ public class Tile { /** * Gets the value of the id property. - * + * * @return * possible object is * {@link String } - * + * */ public int getId() { return id; @@ -49,11 +46,11 @@ public class Tile { /** * Sets the value of the id property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setId(int value) { this.id = value; @@ -61,11 +58,11 @@ public class Tile { /** * Gets the value of the gid property. - * + * * @return * possible object is * {@link String } - * + * */ public String getGid() { return gid; @@ -73,11 +70,11 @@ public class Tile { /** * Sets the value of the gid property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setGid(String value) { this.gid = value; @@ -85,11 +82,11 @@ public class Tile { /** * Gets the value of the properties property. - * + * * @return * possible object is * {@link Properties } - * + * */ public Properties getProperties() { return properties; @@ -97,11 +94,11 @@ public class Tile { /** * Sets the value of the properties property. - * + * * @param value * allowed object is * {@link Properties } - * + * */ public void setProperties(Properties value) { this.properties = value; @@ -109,11 +106,11 @@ public class Tile { /** * Gets the value of the image property. - * + * * @return * possible object is * {@link Image } - * + * */ public Image getImage() { return image; @@ -121,11 +118,11 @@ public class Tile { /** * Sets the value of the image property. - * + * * @param value * allowed object is * {@link Image } - * + * */ public void setImage(Image value) { this.image = value; diff --git a/TileZ/src/au/notzed/tilez/io/Tileset.java b/TileZ/src/au/notzed/tilez/io/Tileset.java index a0bba6b..6a5bf9e 100644 --- a/TileZ/src/au/notzed/tilez/io/Tileset.java +++ b/TileZ/src/au/notzed/tilez/io/Tileset.java @@ -1,26 +1,26 @@ // -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2013.02.27 at 01:07:39 PM CST +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2013.02.27 at 01:07:39 PM CST // package au.notzed.tilez.io; +import jakarta.xml.bind.annotation.XmlAccessType; +import jakarta.xml.bind.annotation.XmlAccessorType; +import jakarta.xml.bind.annotation.XmlAttribute; +import jakarta.xml.bind.annotation.XmlRootElement; +import jakarta.xml.bind.annotation.XmlType; +import jakarta.xml.bind.annotation.adapters.NormalizedStringAdapter; +import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import java.util.ArrayList; import java.util.List; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; -import javax.xml.bind.annotation.adapters.NormalizedStringAdapter; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; /** - * + * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { @@ -52,11 +52,11 @@ public class Tileset { /** * Gets the value of the name property. - * + * * @return * possible object is * {@link String } - * + * */ public String getName() { return name; @@ -64,11 +64,11 @@ public class Tileset { /** * Sets the value of the name property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setName(String value) { this.name = value; @@ -76,11 +76,11 @@ public class Tileset { /** * Gets the value of the firstgid property. - * + * * @return * possible object is * {@link String } - * + * */ public int getFirstgid() { return firstgid; @@ -88,11 +88,11 @@ public class Tileset { /** * Sets the value of the firstgid property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setFirstgid(int value) { this.firstgid = value; @@ -100,11 +100,11 @@ public class Tileset { /** * Gets the value of the source property. - * + * * @return * possible object is * {@link String } - * + * */ public String getSource() { return source; @@ -112,11 +112,11 @@ public class Tileset { /** * Sets the value of the source property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setSource(String value) { this.source = value; @@ -124,11 +124,11 @@ public class Tileset { /** * Gets the value of the tilewidth property. - * + * * @return * possible object is * {@link String } - * + * */ public int getTilewidth() { return tilewidth; @@ -136,11 +136,11 @@ public class Tileset { /** * Sets the value of the tilewidth property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setTilewidth(int value) { this.tilewidth = value; @@ -148,11 +148,11 @@ public class Tileset { /** * Gets the value of the tileheight property. - * + * * @return * possible object is * {@link String } - * + * */ public int getTileheight() { return tileheight; @@ -160,11 +160,11 @@ public class Tileset { /** * Sets the value of the tileheight property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setTileheight(int value) { this.tileheight = value; @@ -172,11 +172,11 @@ public class Tileset { /** * Gets the value of the spacing property. - * + * * @return * possible object is * {@link String } - * + * */ public int getSpacing() { return spacing; @@ -184,11 +184,11 @@ public class Tileset { /** * Sets the value of the spacing property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setSpacing(int value) { this.spacing = value; @@ -196,11 +196,11 @@ public class Tileset { /** * Gets the value of the margin property. - * + * * @return * possible object is * {@link String } - * + * */ public String getMargin() { return margin; @@ -208,11 +208,11 @@ public class Tileset { /** * Sets the value of the margin property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setMargin(String value) { this.margin = value; @@ -220,25 +220,25 @@ public class Tileset { /** * Gets the value of the image property. - * + * *

* This accessor method returns a reference to the live list, * not a snapshot. Therefore any modification you make to the * returned list will be present inside the JAXB object. * This is why there is not a set method for the image property. - * + * *

* For example, to add a new item, do as follows: *

      *    getImage().add(newItem);
      * 
- * - * + * + * *

* Objects of the following type(s) are allowed in the list * {@link Image } - * - * + * + * */ public List getImage() { if (image == null) { @@ -249,25 +249,25 @@ public class Tileset { /** * Gets the value of the tile property. - * + * *

* This accessor method returns a reference to the live list, * not a snapshot. Therefore any modification you make to the * returned list will be present inside the JAXB object. * This is why there is not a set method for the tile property. - * + * *

* For example, to add a new item, do as follows: *

      *    getTile().add(newItem);
      * 
- * - * + * + * *

* Objects of the following type(s) are allowed in the list * {@link Tile } - * - * + * + * */ public List getTile() { if (tile == null) { diff --git a/maven.make b/maven.make new file mode 100644 index 0000000..8397c82 --- /dev/null +++ b/maven.make @@ -0,0 +1,77 @@ +# +# Copyright (C) 2021 Michael Zucchi +# +# This is the copyright for maven.make +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +# This lets one download maven packages using simple automake syntax. + +# maven__URL = baseurl + +# Define the base url. maven_central_URL is already defined as +# maven_central_URL:=https://repo1.maven.org/maven2 + +# maven__JARS = group:artifact:version group:artifact:version ... + +# Define the artifacts required from the given maven repository. + +# That's it! + +# It defines several make targets. + +# make maven-init +# Will download the jar files. + +# make maven-verify +# Will download and check the signatures using gpg. The public key +# required for verification must be imported to gpg separately. + +# make distclean +# Will delete .lib + +# define maven central +maven_central_URL:=https://repo1.maven.org/maven2 +maven_repository_URL:=https://mvnrepository.com/artifact + +# find out what repositories the makefile defined +maven_REPOS=$(patsubst maven_%_URL,%,$(filter maven_%_URL,$(.VARIABLES))) + +# (group artifact version baseurl) +define maven_func= +.lib/$2-$3.jar: + mkdir -p .lib + wget -O $$@ $(4)/$(subst .,/,$1)/$2/$3/$2-$3.jar || ( rm $$@ ; exit 1 ) +.lib/$2-$3.pom: + mkdir -p .lib + wget -O $$@ $(4)/$(subst .,/,$1)/$2/$3/$2-$3.pom || ( rm $$@ ; exit 1 ) +.lib/$2-$3.jar.asc: .lib/$2-$3.jar + wget -O $$@ $(4)/$(subst .,/,$1)/$2/$3/$2-$3.jar.asc + gpg --batch --verify $$@ $$< || ( rm $$@ ; echo "GPG verification failed, you may need to import the public key." ; exit 1 ) +maven-init: .lib/$2-$3.jar .lib/$2-$3.pom +maven-verify: .lib/$2-$3.jar.asc +endef + +maven-init: +maven-verify: + +.PHONY: maven-init maven-verify + +$(foreach repo,$(maven_REPOS),\ + $(foreach jar,$(maven_$(repo)_JARS), \ + $(eval $(call maven_func,$(word 1,$(subst :, ,$(jar))),$(word 2,$(subst :, ,$(jar))),$(word 3,$(subst :, ,$(jar))),$(maven_$(repo)_URL))))) + +distclean: + rm -rf .lib -- 2.39.2