Moved to use jakarta for JAXB.
Added standalone nashorn (for now).
--- /dev/null
+.lib/
+*/build/
+*/dist/
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;
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 {
d.setvalue(encodeArray(bb.array()));
//d.setvalue("dummy");
-
try {
JAXBContext jc = JAXBContext.newInstance(Map.class);
//Unmarshaller u = jc.createUnmarshaller();
} catch (JAXBException ex) {
Logger.getLogger(Tiled.class.getName()).log(Level.SEVERE, null, ex);
}
+
System.out.println("done");
}
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);
//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"));
}
}
//
-// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2
-// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
-// 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 <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// 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 = {
/**
* Gets the value of the encoding property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public String getEncoding() {
return encoding;
/**
* Sets the value of the encoding property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setEncoding(String value) {
this.encoding = value;
/**
* Gets the value of the compression property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public String getCompression() {
return compression;
/**
* Sets the value of the compression property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setCompression(String value) {
this.compression = value;
/**
* Gets the value of the value property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public String getvalue() {
return value;
/**
* Sets the value of the value property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setvalue(String value) {
this.value = value;
//
-// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2
-// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
-// 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 <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// 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 = {
/**
* Gets the value of the format property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public String getFormat() {
return format;
/**
* Sets the value of the format property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setFormat(String value) {
this.format = value;
/**
* Gets the value of the id property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public String getId() {
return id;
/**
* Sets the value of the id property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setId(String value) {
this.id = value;
/**
* Gets the value of the source property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public String getSource() {
return source;
/**
* Sets the value of the source property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setSource(String value) {
this.source = value;
/**
* Gets the value of the trans property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public String getTrans() {
return trans;
/**
* Sets the value of the trans property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setTrans(String value) {
this.trans = value;
/**
* Gets the value of the data property.
- *
+ *
* @return
* possible object is
* {@link Data }
- *
+ *
*/
public Data getData() {
return data;
/**
* Sets the value of the data property.
- *
+ *
* @param value
* allowed object is
* {@link Data }
- *
+ *
*/
public void setData(Data value) {
this.data = value;
//
-// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2
-// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
-// 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 <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// 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 = {
/**
* Gets the value of the name property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public String getName() {
return name;
/**
* Sets the value of the name property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setName(String value) {
this.name = value;
/**
* Gets the value of the width property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public int getWidth() {
return width;
/**
* Sets the value of the width property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setWidth(int value) {
this.width = value;
/**
* Gets the value of the height property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public int getHeight() {
return height;
/**
* Sets the value of the height property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setHeight(int value) {
this.height = value;
/**
* Gets the value of the x property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public int getX() {
return x;
/**
* Sets the value of the x property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setX(int value) {
this.x = value;
/**
* Gets the value of the y property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public int getY() {
return y;
/**
* Sets the value of the y property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setY(int value) {
this.y = value;
/**
* Gets the value of the opacity property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public float getOpacity() {
return opacity;
/**
* Sets the value of the opacity property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setOpacity(float value) {
this.opacity = value;
/**
* Gets the value of the visible property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public int getVisible() {
return visible;
/**
* Sets the value of the visible property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setVisible(int value) {
this.visible = value;
/**
* Gets the value of the properties property.
- *
+ *
* @return
* possible object is
* {@link Properties }
- *
+ *
*/
public Properties getProperties() {
return properties;
/**
* Sets the value of the properties property.
- *
+ *
* @param value
* allowed object is
* {@link Properties }
- *
+ *
*/
public void setProperties(Properties value) {
this.properties = value;
/**
* Gets the value of the data property.
- *
+ *
* @return
* possible object is
* {@link Data }
- *
+ *
*/
public Data getData() {
return data;
/**
* Sets the value of the data property.
- *
+ *
* @param value
* allowed object is
* {@link Data }
- *
+ *
*/
public void setData(Data value) {
this.data = value;
//
-// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2
-// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
-// 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 <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// 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 = {
/**
* Gets the value of the xmlns property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public String getXmlns() {
return xmlns;
/**
* Sets the value of the xmlns property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setXmlns(String value) {
this.xmlns = value;
/**
* Gets the value of the xmlnsXsi property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public String getXmlnsXsi() {
return xmlnsXsi;
/**
* Sets the value of the xmlnsXsi property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setXmlnsXsi(String value) {
this.xmlnsXsi = value;
/**
* Gets the value of the xsiSchemaLocation property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public String getXsiSchemaLocation() {
return xsiSchemaLocation;
/**
* Sets the value of the xsiSchemaLocation property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setXsiSchemaLocation(String value) {
this.xsiSchemaLocation = value;
/**
* Gets the value of the version property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public String getVersion() {
return version;
/**
* Sets the value of the version property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setVersion(String value) {
this.version = value;
/**
* Gets the value of the orientation property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public String getOrientation() {
return orientation;
/**
* Sets the value of the orientation property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setOrientation(String value) {
this.orientation = value;
/**
* Gets the value of the width property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public int getWidth() {
return width;
/**
* Sets the value of the width property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setWidth(int value) {
this.width = value;
/**
* Gets the value of the height property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public int getHeight() {
return height;
/**
* Sets the value of the height property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setHeight(int value) {
this.height = value;
/**
* Gets the value of the tilewidth property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public int getTilewidth() {
return tilewidth;
/**
* Sets the value of the tilewidth property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setTilewidth(int value) {
this.tilewidth = value;
/**
* Gets the value of the tileheight property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public int getTileheight() {
return tileheight;
/**
* Sets the value of the tileheight property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setTileheight(int value) {
this.tileheight = value;
/**
* Gets the value of the properties property.
- *
+ *
* @return
* possible object is
* {@link Properties }
- *
+ *
*/
public Properties getProperties() {
return properties;
/**
* Sets the value of the properties property.
- *
+ *
* @param value
* allowed object is
* {@link Properties }
- *
+ *
*/
public void setProperties(Properties value) {
this.properties = value;
/**
* Gets the value of the tileset property.
- *
+ *
* <p>
* 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 <CODE>set</CODE> method for the tileset property.
- *
+ *
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getTileset().add(newItem);
* </pre>
- *
- *
+ *
+ *
* <p>
* Objects of the following type(s) are allowed in the list
* {@link Tileset }
- *
- *
+ *
+ *
*/
public List<Tileset> getTileset() {
if (tileset == null) {
/**
* Gets the value of the layerOrObjectgroup property.
- *
+ *
* <p>
* 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 <CODE>set</CODE> method for the layerOrObjectgroup property.
- *
+ *
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getLayerOrObjectgroup().add(newItem);
* </pre>
- *
- *
+ *
+ *
* <p>
* Objects of the following type(s) are allowed in the list
* {@link Layer }
* {@link Objectgroup }
- *
- *
+ *
+ *
*/
public List<java.lang.Object> getLayerOrObjectgroup() {
if (layerOrObjectgroup == null) {
//
-// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2
-// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
-// 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 <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// 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 = {
/**
* Gets the value of the name property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public String getName() {
return name;
/**
* Sets the value of the name property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setName(String value) {
this.name = value;
/**
* Gets the value of the type property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public String getType() {
return type;
/**
* Sets the value of the type property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setType(String value) {
this.type = value;
/**
* Gets the value of the x property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public int getX() {
return x;
/**
* Sets the value of the x property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setX(int value) {
this.x = value;
/**
* Gets the value of the y property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public int getY() {
return y;
/**
* Sets the value of the y property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setY(int value) {
this.y = value;
/**
* Gets the value of the width property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public int getWidth() {
return width;
/**
* Sets the value of the width property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setWidth(int value) {
this.width = value;
/**
* Gets the value of the height property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public int getHeight() {
return height;
/**
* Sets the value of the height property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setHeight(int value) {
this.height = value;
/**
* Gets the value of the properties property.
- *
+ *
* @return
* possible object is
* {@link Properties }
- *
+ *
*/
public Properties getProperties() {
return properties;
/**
* Sets the value of the properties property.
- *
+ *
* @param value
* allowed object is
* {@link Properties }
- *
+ *
*/
public void setProperties(Properties value) {
this.properties = value;
/**
* Gets the value of the image property.
- *
+ *
* @return
* possible object is
* {@link Image }
- *
+ *
*/
public Image getImage() {
return image;
/**
* Sets the value of the image property.
- *
+ *
* @param value
* allowed object is
* {@link Image }
- *
+ *
*/
public void setImage(Image value) {
this.image = value;
//
-// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2
-// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
-// 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 <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// 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.
- * <p>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.
+ * <p>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 {
/**
* 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();
/**
* Create an instance of {@link Image }
- *
+ *
*/
public Image createImage() {
return new Image();
/**
* Create an instance of {@link Tile }
- *
+ *
*/
public Tile createTile() {
return new Tile();
/**
* Create an instance of {@link Properties }
- *
+ *
*/
public Properties createProperties() {
return new Properties();
/**
* Create an instance of {@link Objectgroup }
- *
+ *
*/
public Objectgroup createObjectgroup() {
return new Objectgroup();
/**
* Create an instance of {@link Object }
- *
+ *
*/
public Object createObject() {
return new Object();
/**
* Create an instance of {@link Data }
- *
+ *
*/
public Data createData() {
return new Data();
/**
* Create an instance of {@link Map }
- *
+ *
*/
public Map createMap() {
return new Map();
/**
* Create an instance of {@link Layer }
- *
+ *
*/
public Layer createLayer() {
return new Layer();
/**
* Create an instance of {@link Property }
- *
+ *
*/
public Property createProperty() {
return new Property();
//
-// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2
-// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
-// 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 <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// 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 = {
/**
* Gets the value of the name property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public String getName() {
return name;
/**
* Sets the value of the name property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setName(String value) {
this.name = value;
/**
* Gets the value of the width property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public int getWidth() {
return width;
/**
* Sets the value of the width property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setWidth(int value) {
this.width = value;
/**
* Gets the value of the height property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public int getHeight() {
return height;
/**
* Sets the value of the height property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setHeight(int value) {
this.height = value;
/**
* Gets the value of the x property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public int getX() {
return x;
/**
* Sets the value of the x property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setX(int value) {
this.x = value;
/**
* Gets the value of the y property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public int getY() {
return y;
/**
* Sets the value of the y property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setY(int value) {
this.y = value;
/**
* Gets the value of the object property.
- *
+ *
* <p>
* 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 <CODE>set</CODE> method for the object property.
- *
+ *
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getObject().add(newItem);
* </pre>
- *
- *
+ *
+ *
* <p>
* Objects of the following type(s) are allowed in the list
* {@link Object }
- *
- *
+ *
+ *
*/
public List<Object> getObject() {
if (object == null) {
//
-// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2
-// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
-// 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 <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// 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 = {
/**
* Gets the value of the property property.
- *
+ *
* <p>
* 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 <CODE>set</CODE> method for the property property.
- *
+ *
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getProperty().add(newItem);
* </pre>
- *
- *
+ *
+ *
* <p>
* Objects of the following type(s) are allowed in the list
* {@link Property }
- *
- *
+ *
+ *
*/
public List<Property> getProperty() {
if (property == null) {
//
-// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2
-// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
-// 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 <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// 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 = "")
/**
* Gets the value of the name property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public String getName() {
return name;
/**
* Sets the value of the name property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setName(String value) {
this.name = value;
/**
* Gets the value of the value property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public String getValue() {
return value;
/**
* Sets the value of the value property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setValue(String value) {
this.value = value;
//
-// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2
-// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
-// 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 <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// 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 = {
/**
* Gets the value of the id property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public int getId() {
return id;
/**
* Sets the value of the id property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setId(int value) {
this.id = value;
/**
* Gets the value of the gid property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public String getGid() {
return gid;
/**
* Sets the value of the gid property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setGid(String value) {
this.gid = value;
/**
* Gets the value of the properties property.
- *
+ *
* @return
* possible object is
* {@link Properties }
- *
+ *
*/
public Properties getProperties() {
return properties;
/**
* Sets the value of the properties property.
- *
+ *
* @param value
* allowed object is
* {@link Properties }
- *
+ *
*/
public void setProperties(Properties value) {
this.properties = value;
/**
* Gets the value of the image property.
- *
+ *
* @return
* possible object is
* {@link Image }
- *
+ *
*/
public Image getImage() {
return image;
/**
* Sets the value of the image property.
- *
+ *
* @param value
* allowed object is
* {@link Image }
- *
+ *
*/
public void setImage(Image value) {
this.image = value;
//
-// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2
-// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
-// 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 <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// 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 = {
/**
* Gets the value of the name property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public String getName() {
return name;
/**
* Sets the value of the name property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setName(String value) {
this.name = value;
/**
* Gets the value of the firstgid property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public int getFirstgid() {
return firstgid;
/**
* Sets the value of the firstgid property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setFirstgid(int value) {
this.firstgid = value;
/**
* Gets the value of the source property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public String getSource() {
return source;
/**
* Sets the value of the source property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setSource(String value) {
this.source = value;
/**
* Gets the value of the tilewidth property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public int getTilewidth() {
return tilewidth;
/**
* Sets the value of the tilewidth property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setTilewidth(int value) {
this.tilewidth = value;
/**
* Gets the value of the tileheight property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public int getTileheight() {
return tileheight;
/**
* Sets the value of the tileheight property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setTileheight(int value) {
this.tileheight = value;
/**
* Gets the value of the spacing property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public int getSpacing() {
return spacing;
/**
* Sets the value of the spacing property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setSpacing(int value) {
this.spacing = value;
/**
* Gets the value of the margin property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public String getMargin() {
return margin;
/**
* Sets the value of the margin property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setMargin(String value) {
this.margin = value;
/**
* Gets the value of the image property.
- *
+ *
* <p>
* 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 <CODE>set</CODE> method for the image property.
- *
+ *
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getImage().add(newItem);
* </pre>
- *
- *
+ *
+ *
* <p>
* Objects of the following type(s) are allowed in the list
* {@link Image }
- *
- *
+ *
+ *
*/
public List<Image> getImage() {
if (image == null) {
/**
* Gets the value of the tile property.
- *
+ *
* <p>
* 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 <CODE>set</CODE> method for the tile property.
- *
+ *
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getTile().add(newItem);
* </pre>
- *
- *
+ *
+ *
* <p>
* Objects of the following type(s) are allowed in the list
* {@link Tile }
- *
- *
+ *
+ *
*/
public List<Tile> getTile() {
if (tile == null) {
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);
void onBattle(Thing thing);
//int getCost();
};
-
+
public static void main(String[] args) throws ScriptException, InterruptedException {
if (true) {
Thing thing = new Thing();
Compilable comp = ((Compilable)engine);
CompiledScript cbob = comp.compile(bob);
-
-
+
+
engine.eval(bob);
-
+
engine.eval("var bob = {\n"
+ "cost:1,\n"
+ "description:'kind bob',\n"
+ "onFlee: function(thing) {"
+ "}"
+ "}\n");
-
-
+
+
engine.eval(""
+ "onBattle= function(thing) {"
+ "println('on battle!');"
//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'); }");
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);
} catch (NoSuchMethodException ex) {
Logger.getLogger(Junk.class.getName()).log(Level.SEVERE, null, ex);
}
-
+
for (Entry<String, Object> e : engine.getBindings(ScriptContext.ENGINE_SCOPE).entrySet()) {
System.out.println("`" + e.getKey() + "'= " + e.getValue() + " " + e.getValue().getClass().getName());
}
/**
* Low level map management and helpers.
- *
+ *
* Some of the helpers provide higher level functionality like path finding.
*
* @author notzed
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");
}
@Override
public void start(Stage stage) {
+ try {
frame = new MainFrameFX();
game = new Dusk(frame);
stage.show();
game.startUp();
+ } catch (Throwable t) {
+ t.printStackTrace();
+ System.exit(1);
+ }
}
@Override
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.
* 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;
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;
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;
/**
* This is the main JavaFX window.
- *
+ * <p>
* It handles all the GUI related operations.
- *
+ * <p>
* 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 {
//layers.setScaleX(2);
//layers.setScaleY(2);
-
panel = new BorderPane();
panel.setMaxWidth(320);
main.setRight(panel);
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);
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<ActionEvent>() {
+ FadeTransition fade = new FadeTransition(dur, node);
+ fade.setInterpolator(Interpolator.EASE_IN);
+ fade.setFromValue(1);
+ fade.setToValue(0);
+ fade.setOnFinished(new EventHandler<ActionEvent>() {
@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);
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);
GridPane.setHalignment(login, HPos.CENTER);
loginPane.add(login, 1, 6, 2, 1);
-
GridPane.setVgrow(hbox, Priority.NEVER);
GridPane.setVgrow(login, Priority.NEVER);
}
});
-
}
/**
@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");
}
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);
/**
* 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();
};
EventHandler<ActionEvent> attackHandler = new EventHandler<ActionEvent>() {
public void handle(ActionEvent t) {
- game.attack((Entity) ((MenuItem) t.getSource()).getUserData());
+ game.attack((Entity)((MenuItem)t.getSource()).getUserData());
}
};
EventHandler<ActionEvent> lookHandler = new EventHandler<ActionEvent>() {
public void handle(ActionEvent t) {
- game.look((Entity) ((MenuItem) t.getSource()).getUserData());
+ game.look((Entity)((MenuItem)t.getSource()).getUserData());
}
};
EventHandler<ActionEvent> actionHandler = new EventHandler<ActionEvent>() {
public void handle(ActionEvent t) {
- MenuItem mi = (MenuItem) t.getSource();
+ MenuItem mi = (MenuItem)t.getSource();
game.command(mi.getText());
}
};
EventHandler<ActionEvent> getHandler = new EventHandler<ActionEvent>() {
public void handle(ActionEvent t) {
- game.take((Entity) ((MenuItem) t.getSource()).getUserData());
+ game.take((Entity)((MenuItem)t.getSource()).getUserData());
}
};
EventHandler<ActionEvent> dropHandler = new EventHandler<ActionEvent>() {
public void handle(ActionEvent t) {
- game.drop(((MenuItem) t.getSource()).getText());
+ game.drop(((MenuItem)t.getSource()).getText());
}
};
void setStringMenu(final MenuButton menu, List<String> list, EventHandler<ActionEvent> handle) {
final List<MenuItem> 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
void setEntityMenu(final MenuButton menu, List<Entity> list, EventHandler<ActionEvent> handle) {
final List<MenuItem> 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() {
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;
anims[1] = data.createTile(304, 0, 0, tileSize, tileSize).getViewport();
final List<ImageView> 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
for (int x = 0; x < map.cols; x++) {
Collection<Entity> 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);
}
}
//for (Entity e : map.getEntities()) {
// drawEntity(map.offx, map.offy, children, e);
//}
-
Platform.runLater(new Runnable() {
@Override
public void run() {
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);
} 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);
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;
/**
*
-/**
- * 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 <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 <COPYRIGHT HOLDER> 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<Duration> delayProperty() { return this.delayObjectProperty; }
- final private ObjectProperty<Duration> delayObjectProperty = new SimpleObjectProperty<Duration>(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<Duration> cycleDurationProperty() { return this.cycleDurationObjectProperty; }
- final private ObjectProperty<Duration> cycleDurationObjectProperty = new SimpleObjectProperty<Duration>(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<Boolean> repeatsProperty() { return this.repeatsObjectProperty; }
- final private ObjectProperty<Boolean> repeatsObjectProperty = new SimpleObjectProperty<Boolean>(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<TimerTask> timerTaskAtomicReference = new AtomicReference<TimerTask>(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;
- }
-}
+/**\r
+ * Copyright (c) 2011-2021, JFXtras\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ * Redistributions of source code must retain the above copyright\r
+ * notice, this list of conditions and the following disclaimer.\r
+ * Redistributions in binary form must reproduce the above copyright\r
+ * notice, this list of conditions and the following disclaimer in the\r
+ * documentation and/or other materials provided with the distribution.\r
+ * Neither the name of the organization nor the\r
+ * names of its contributors may be used to endorse or promote products\r
+ * derived from this software without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND\r
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\r
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r
+ * DISCLAIMED. IN NO EVENT SHALL JFXTRAS BE LIABLE FOR ANY\r
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\r
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\r
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\r
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ */\r
+package jfxtras.animation;\r
+\r
+import java.util.TimerTask;\r
+import java.util.concurrent.atomic.AtomicReference;\r
+\r
+import javafx.application.Platform;\r
+import javafx.beans.property.ObjectProperty;\r
+import javafx.beans.property.SimpleObjectProperty;\r
+import javafx.util.Duration;\r
+\r
+/**\r
+ * A timer class in the spirit of java.swing.Timer but using JavaFX properties.\r
+ * \r
+ * @author Tom Eugelink\r
+ *\r
+ */\r
+public class Timer\r
+{\r
+ // ==================================================================================================================\r
+ // CONSTRUCTOR\r
+ \r
+ /**\r
+ * \r
+ * @param runnable\r
+ */\r
+ public Timer(Runnable runnable)\r
+ {\r
+ this(true, runnable);\r
+ }\r
+ \r
+ /**\r
+ * \r
+ * @param isDaemon\r
+ * @param runnable\r
+ */\r
+ public Timer(boolean isDaemon, final Runnable runnable)\r
+ {\r
+ this.runnable = runnable;\r
+ this.isDaemon = isDaemon;\r
+ }\r
+ final private Runnable runnable;\r
+ final private boolean isDaemon;\r
+ volatile private java.util.Timer timer;\r
+ \r
+ // ==================================================================================================================\r
+ // PROPERTIES\r
+ \r
+ /** delay: initial delay */\r
+ public ObjectProperty<Duration> delayProperty() { return this.delayObjectProperty; }\r
+ final private ObjectProperty<Duration> delayObjectProperty = new SimpleObjectProperty<Duration>(this, "delay", Duration.millis(0));\r
+ public Duration getDelay() { return this.delayObjectProperty.getValue(); }\r
+ public void setDelay(Duration value) { this.delayObjectProperty.setValue(value); }\r
+ public Timer withDelay(Duration value) { setDelay(value); return this; }\r
+ \r
+ /** cycleDuration: time between fires */\r
+ public ObjectProperty<Duration> cycleDurationProperty() { return this.cycleDurationObjectProperty; }\r
+ final private ObjectProperty<Duration> cycleDurationObjectProperty = new SimpleObjectProperty<Duration>(this, "cycleDuration", Duration.millis(1000));\r
+ public Duration getCycleDuration() { return this.cycleDurationObjectProperty.getValue(); }\r
+ public void setCycleDuration(Duration value) { this.cycleDurationObjectProperty.setValue(value); }\r
+ public Timer withCycleDuration(Duration value) { setCycleDuration(value); return this; }\r
+ \r
+ /** repeats: If flag is false, instructs the Timer to send only one action event to its listeners. */\r
+ public ObjectProperty<Boolean> repeatsProperty() { return this.repeatsObjectProperty; }\r
+ final private ObjectProperty<Boolean> repeatsObjectProperty = new SimpleObjectProperty<Boolean>(this, "repeats", Boolean.TRUE);\r
+ public boolean getRepeats() { return this.repeatsObjectProperty.getValue(); }\r
+ public void setRepeats(boolean value) { this.repeatsObjectProperty.setValue(value); }\r
+ public Timer withRepeats(boolean value) { setRepeats(value); return this; }\r
+ \r
+ \r
+ // ==================================================================================================================\r
+ // TIMER\r
+ \r
+ /**\r
+ * Start the timer\r
+ */\r
+ synchronized public Timer start()\r
+ {\r
+ // check if the timer is already running\r
+ if (timerTaskAtomicReference.get() != null) throw new IllegalStateException("Timer already started");\r
+ \r
+ // create a task and schedule it\r
+ final TimerTask lTimerTask = new TimerTask()\r
+ {\r
+ @Override\r
+ public void run()\r
+ {\r
+ Platform.runLater(runnable);\r
+ if (repeatsObjectProperty.getValue().booleanValue() == false)\r
+ {\r
+ stop();\r
+ }\r
+ }\r
+ };\r
+ if (timer == null) {\r
+ timer = new java.util.Timer(isDaemon);\r
+ }\r
+ timer.schedule(lTimerTask, (long)this.delayObjectProperty.getValue().toMillis(), (long)this.cycleDurationObjectProperty.getValue().toMillis());\r
+ \r
+ // remember for future reference\r
+ timerTaskAtomicReference.set(lTimerTask);\r
+ \r
+ // for chaining\r
+ return this;\r
+ }\r
+ final private AtomicReference<TimerTask> timerTaskAtomicReference = new AtomicReference<TimerTask>(null);\r
+ \r
+ /**\r
+ * stop the timer if running\r
+ */\r
+ public Timer stop()\r
+ {\r
+ TimerTask lTimerTask = timerTaskAtomicReference.getAndSet(null);\r
+ if (lTimerTask != null)\r
+ {\r
+ lTimerTask.cancel();\r
+ }\r
+ if (timer != null) {\r
+ timer.cancel();\r
+ timer = null;\r
+ }\r
+ \r
+ // for chaining\r
+ return this;\r
+ }\r
+ \r
+ /**\r
+ * restart the timer\r
+ */\r
+ public Timer restart()\r
+ {\r
+ stop();\r
+ start();\r
+ \r
+ // for chaining\r
+ return this;\r
+ }\r
+}\r
--- /dev/null
+/**\r
+ * Copyright (c) 2011-2021, JFXtras\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ * Redistributions of source code must retain the above copyright\r
+ * notice, this list of conditions and the following disclaimer.\r
+ * Redistributions in binary form must reproduce the above copyright\r
+ * notice, this list of conditions and the following disclaimer in the\r
+ * documentation and/or other materials provided with the distribution.\r
+ * Neither the name of the organization nor the\r
+ * names of its contributors may be used to endorse or promote products\r
+ * derived from this software without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND\r
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\r
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r
+ * DISCLAIMED. IN NO EVENT SHALL JFXTRAS BE LIABLE FOR ANY\r
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\r
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\r
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\r
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ */\r
+package jfxtras.css;\r
+\r
+import javafx.css.CssMetaData;\r
+import javafx.css.StyleConverter;\r
+import javafx.css.Styleable;\r
+import javafx.css.StyleableProperty;\r
+import javafx.scene.control.Control;\r
+import javafx.scene.control.Skin;\r
+\r
+/**\r
+ * Creating CssMetaData for a property in a skin has some casting, this class hides that away.\r
+ *\r
+ * @param <S>\r
+ * @param <SK>\r
+ * @param <V>\r
+ */\r
+public abstract class CssMetaDataForSkinProperty<S extends Styleable, SK extends Skin<?>, V> extends CssMetaData<S, V> {\r
+\r
+ protected CssMetaDataForSkinProperty(String cssId, StyleConverter<?, V> styleConverter, V initialValue) {\r
+ super(cssId, styleConverter, initialValue);\r
+ }\r
+ \r
+ public V getInitialValue() {\r
+ return super.getInitialValue(null);\r
+ }\r
+ \r
+ @Override public boolean isSettable(S n) {\r
+ Control c = (Control)n;\r
+ SK s = (SK)c.getSkin();\r
+ return !getProperty(s).isBound(); \r
+ }\r
+ @Override public StyleableProperty<V> getStyleableProperty(S n) { \r
+ Control c = (Control)n;\r
+ SK s = (SK)c.getSkin();\r
+ return (StyleableProperty<V>)getProperty(s); \r
+ }\r
+ \r
+ abstract protected javafx.beans.property.Property<V> getProperty(SK s);\r
+}\r
--- /dev/null
+/**
+ * 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<T> extends SkinBase<ListSpinner<T>>
+{
+ // TODO: vertical centering
+
+ // ==================================================================================================================
+ // CONSTRUCTOR
+
+ /**
+ *
+ */
+ public ListSpinnerSkin(ListSpinner<T> control)
+ {
+ super(control);
+ construct();
+ }
+
+ /*
+ *
+ */
+ private void construct()
+ {
+ // setup component
+ createNodes();
+
+ // react to value changes in the model
+ getSkinnable().editableProperty().addListener( (ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) -> {
+ replaceValueNode();
+ });
+ replaceValueNode();
+
+ // react to value changes in the model
+ getSkinnable().valueProperty().addListener( (ObservableValue<? extends T> 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<ArrowPosition> arrowPositionProperty() { return arrowPosition; }
+ private ObjectProperty<ArrowPosition> arrowPosition = new SimpleStyleableObjectProperty<ArrowPosition>(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<T> withArrowPosition(ArrowPosition value) { setArrowPosition(value); return this; }
+ public enum ArrowPosition {LEADING, TRAILING, SPLIT}
+
+ /**
+ * arrowDirection
+ */
+ public final ObjectProperty<ArrowDirection> arrowDirectionProperty() { return arrowDirection; }
+ private ObjectProperty<ArrowDirection> arrowDirection = new SimpleStyleableObjectProperty<ArrowDirection>(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<T> withArrowDirection(ArrowDirection value) { setArrowDirection(value); return this; }
+ public enum ArrowDirection {VERTICAL, HORIZONTAL}
+
+ /**
+ * valueAlignment
+ */
+ public final ObjectProperty<Pos> valueAlignmentProperty() { return valueAlignment; }
+ private ObjectProperty<Pos> valueAlignment = new SimpleStyleableObjectProperty<Pos>(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<T> withValueAlignment(Pos value) { setValueAlignment(value); return this; }
+
+ // -------------------------
+
+ private static class StyleableProperties
+ {
+ private static final CssMetaData<ListSpinner<?>, ArrowPosition> ARROW_POSITION = new CssMetaDataForSkinProperty<ListSpinner<?>, ListSpinnerSkin<?>, ArrowPosition>("-fxx-arrow-position", new EnumConverter<ArrowPosition>(ArrowPosition.class), ArrowPosition.TRAILING ) {
+ @Override
+ protected ObjectProperty<ArrowPosition> getProperty(ListSpinnerSkin<?> s) {
+ return s.arrowPositionProperty();
+ }
+ };
+
+ private static final CssMetaData<ListSpinner<?>, ArrowDirection> ARROW_DIRECTION = new CssMetaDataForSkinProperty<ListSpinner<?>, ListSpinnerSkin<?>, ArrowDirection>("-fxx-arrow-direction", new EnumConverter<ArrowDirection>(ArrowDirection.class), ArrowDirection.HORIZONTAL ) {
+ @Override
+ protected ObjectProperty<ArrowDirection> getProperty(ListSpinnerSkin<?> s) {
+ return s.arrowDirectionProperty();
+ }
+ };
+
+ private static final CssMetaData<ListSpinner<?>, Pos> VALUE_ALIGNMENT = new CssMetaDataForSkinProperty<ListSpinner<?>, ListSpinnerSkin<?>, Pos>("-fxx-value-alignment", new EnumConverter<Pos>(Pos.class), Pos.CENTER_LEFT ) {
+ @Override
+ protected ObjectProperty<Pos> getProperty(ListSpinnerSkin<?> s) {
+ return s.valueAlignmentProperty();
+ }
+ };
+
+ private static final List<CssMetaData<? extends Styleable, ?>> STYLEABLES;
+ static {
+ final List<CssMetaData<? extends Styleable, ?>> styleables = new ArrayList<CssMetaData<? extends Styleable, ?>>(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<CssMetaData<? extends Styleable, ?>> 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<CssMetaData<? extends Styleable, ?>> 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<T> 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<T, Integer> 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;
+ }
+ }
+ }
+}
+++ /dev/null
-/* basic settings */\r
-.ListSpinner { \r
- -fx-skin: "jfxtras.labs.internal.scene.control.skin.ListSpinnerCaspianSkin";\r
- -fx-background-color: -fx-shadow-highlight-color, -fx-outer-border, -fx-inner-border, -fx-body-color;\r
- -fx-background-insets: 0 0 -1 0, 0, 1, 2;\r
- -fx-background-radius: 5, 5, 4, 3;\r
- -fx-padding: 0.266667em 0.233333em 0.25em 0.233333em;\r
- -fx-text-fill: -fx-text-base-color;\r
-}\r
-\r
-.ListSpinner:hover {\r
- -fx-color: -fx-hover-base;\r
-}\r
-\r
-.ListSpinner:focused { \r
- -fx-color: -fx-focused-base;\r
- -fx-background-color: -fx-focus-color, -fx-outer-border, -fx-inner-border, -fx-body-color;\r
- -fx-background-insets: -1.4, 0, 1, 2;\r
- -fx-background-radius: 6.4, 5, 4, 3; \r
-}\r
-\r
-.ListSpinner .value { \r
- -fx-padding: 0.0em 0.2em 0.0em 0.2em;\r
-}\r
-\r
-.ListSpinner .left-arrow { \r
- -fx-shape: "M4,-4 L0,0 L4,4 Z";\r
- -fx-scale-shape: false;\r
-}\r
-.ListSpinner .right-arrow { \r
- -fx-shape: "M0,-4 L4,0 L0,4 Z";\r
- -fx-scale-shape: false;\r
-}\r
-.ListSpinner .down-arrow { \r
- -fx-shape: "M-4,-2 L0,2 L4,-2 Z";\r
- -fx-scale-shape: false;\r
-}\r
-.ListSpinner .up-arrow { \r
- -fx-shape: "M4,2 L-4,2 L0,-2 Z";\r
- -fx-scale-shape: false;\r
-}\r
-.ListSpinner .idle {\r
- -fx-background-color: -fx-mark-color;\r
-}\r
-.ListSpinner .clicked { \r
- -fx-background-color: -fx-focus-color;\r
-}\r
+++ /dev/null
-/**
- * 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 <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 <COPYRIGHT HOLDER> 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<T> extends BehaviorBase<ListSpinner<T>>
-{
- // ==================================================================================================================
- // CONSTRUCTOR
-
- /**
- *
- * @param control
- */
- public ListSpinnerBehavior(ListSpinner<T> 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<T, Integer> 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<T> 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<KeyBinding> KEY_BINDINGS = new ArrayList<KeyBinding>();
- 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<KeyBinding> 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);
- }
- }
-}
+++ /dev/null
-/**
- * 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 <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 <COPYRIGHT HOLDER> 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<T> extends SkinBase<ListSpinner<T>, ListSpinnerBehavior<T>>
-{
- // TODO: vertical centering
-
- // ==================================================================================================================
- // CONSTRUCTOR
-
- /**
- *
- */
- public ListSpinnerCaspianSkin(ListSpinner<T> control)
- {
- super(control, new ListSpinnerBehavior<T>(control));
- construct();
- }
-
- /*
- *
- */
- private void construct()
- {
- // setup component
- createNodes();
-
- // react to value changes in the model
- getSkinnable().editableProperty().addListener(new ChangeListener<Boolean>()
- {
- @Override
- public void changed(ObservableValue<? extends Boolean> arg0, Boolean arg1, Boolean arg2)
- {
- replaceValueNode();
- }
- });
- replaceValueNode();
-
- // react to value changes in the model
- getSkinnable().valueProperty().addListener(new ChangeListener<T>()
- {
- @Override
- public void changed(ObservableValue<? extends T> observableValue, T oldValue, T newValue)
- {
- refreshValue();
- }
- });
- refreshValue();
-
- // react to value changes in the model
- getSkinnable().arrowDirectionProperty().addListener(new ChangeListener<ListSpinner.ArrowDirection>()
- {
- @Override
- public void changed(ObservableValue<? extends ArrowDirection> observableValue, ArrowDirection oldValue, ArrowDirection newValue)
- {
- setArrowCSS();
- layoutGridPane();
- }
- });
- setArrowCSS();
- layoutGridPane();
-
- // react to value changes in the model
- getSkinnable().alignmentProperty().addListener(new ChangeListener<Pos>()
- {
- @Override
- public void changed(ObservableValue<? extends Pos> 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<MouseEvent>()
- {
- @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<MouseEvent>()
- {
- @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<MouseEvent>()
- {
- @Override public void handle(MouseEvent evt)
- {
- unclickArrows();
- repeatDecrementClickTimer.stop();
- repeatIncrementClickTimer.stop();
- }
- });
- gridPane.setOnMouseExited(new EventHandler<MouseEvent>()
- {
- @Override public void handle(MouseEvent evt)
- {
- unclickArrows();
- repeatDecrementClickTimer.stop();
- repeatIncrementClickTimer.stop();
- }
- });
- // mouse wheel
- gridPane.setOnScroll(new EventHandler<ScrollEvent>()
- {
- @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<ActionEvent>()
- {
- @Override
- public void handle(ActionEvent evt)
- {
- parse(textField);
- }
- });
- textField.setOnKeyPressed(new EventHandler<KeyEvent>()
- {
- @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");
- }
- }
-}
+++ /dev/null
-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<Integer>
-{
- /**
- *
- */
- 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
-/**
- * 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 <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 <COPYRIGHT HOLDER> 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;
-
+/**\r
+ * Copyright (c) 2011-2021, JFXtras\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ * Redistributions of source code must retain the above copyright\r
+ * notice, this list of conditions and the following disclaimer.\r
+ * Redistributions in binary form must reproduce the above copyright\r
+ * notice, this list of conditions and the following disclaimer in the\r
+ * documentation and/or other materials provided with the distribution.\r
+ * Neither the name of the organization nor the\r
+ * names of its contributors may be used to endorse or promote products\r
+ * derived from this software without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND\r
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\r
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r
+ * DISCLAIMED. IN NO EVENT SHALL JFXTRAS BE LIABLE FOR ANY\r
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\r
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\r
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\r
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ */\r
+package jfxtras.scene.control;\r
+\r
import java.util.Arrays;
import javafx.beans.property.ObjectProperty;
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<T> extends Control
-{
- // TODO: implement SelectionModel?
- // ==================================================================================================================
- // CONSTRUCTOR
-
- /**
- */
- public ListSpinner()
- {
- construct();
- }
-
- // ------------
- // model
-
- /**
- * @param items The item list used to populate the spinner.
- */
- public ListSpinner(ObservableList<T> 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<T> items, T startValue)
+import javafx.util.StringConverter;\r
+\r
+/**\r
+ * This is a spinner, showing one value at a time from a list.\r
+ * This value is set and retrieved through the value property.\r
+ * Basically a spinner shows a list of values and can do a "next" or "previous".\r
+ * \r
+ * A spinner can be editable, the user can then type a value instead of selecting it.\r
+ * If the value exists in the list, the spinner will simply jump to it. \r
+ * If the value does not exist, the AddCallback is called if defined.\r
+ * \r
+ * - If the AddCallback returns null, spinner will only refresh the current index.\r
+ * - If the AddCallback returns an Integer, spinner will jump to that index (usually the index where the new value was added to the list). \r
+ *\r
+ * \r
+ * '''\r
+ * \r
+ * In the default skin you can style the text in the control using CSS like so:\r
+ * [source,css]\r
+ * --\r
+ * .ListSpinner .value { \r
+ * -fx-font-weight: bold;\r
+ * }\r
+ * --\r
+ * \r
+ * The "value" class applies to the text in both readonly and editable spinners, use the "readonly" or "editable" class to style either mode specifically.\r
+ * 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.\r
+ * \r
+ * The default skin has a number of styleable properies which use the text representation of an enum for their value:\r
+ * \r
+ * [source,css]\r
+ * --\r
+ * .ListSpinner { \r
+ * -fxx-arrow-position: {LEADING, TRAILING, SPLIT}\r
+ * -fxx-arrow-direction: {VERTICAL, HORIZONTAL}\r
+ * -fxx-value-alignment: see javafx.geometry.Pos (https://docs.oracle.com/javase/8/javafx/api/javafx/geometry/Pos.html) \r
+ * }\r
+ * --\r
+ * \r
+ * @author Tom Eugelink\r
+ */\r
+public class ListSpinner<T> extends Control\r
+{\r
+ // TODO: implement SelectionModel?\r
+ // ==================================================================================================================\r
+ // CONSTRUCTOR\r
+\r
+ /**\r
+ */\r
+ public ListSpinner()\r
+ {\r
+ construct();\r
+ }\r
+\r
+ // ------------\r
+ // model\r
+ \r
+ /**\r
+ * @param items The item list used to populate the spinner.\r
+ */\r
+ public ListSpinner(ObservableList<T> items)\r
+ {\r
+ construct();\r
+ setItems(items);\r
+ first();\r
+ }\r
+\r
+ /**\r
+ * @param items The item list used to populate the spinner.\r
+ * @param startValue The initial value of the spinner (one of the items).\r
+ */\r
+ public ListSpinner(ObservableList<T> items, T startValue)\r
+ {\r
+ construct();\r
+ setItems(items);\r
+ setValue(startValue);\r
+ }\r
+\r
+ // ------------\r
+ // convenience\r
+ \r
+ /**\r
+ * @param list\r
+ */\r
+ public ListSpinner(final java.util.List<T> list)\r
+ {\r
+ this( FXCollections.observableList(list) );\r
+ }\r
+\r
+ /**\r
+ * @param list\r
+ */\r
+ public ListSpinner(T... list)\r
+ {\r
+ this( Arrays.asList(list) );\r
+ }\r
+\r
+ /**\r
+ * @param from\r
+ * @param to\r
+ */\r
+ public ListSpinner(int from, int to)\r
+ {\r
+ this( (java.util.List<T>) new ListSpinnerIntegerList(from, to) );\r
+ }\r
+\r
+ /**\r
+ * @param from\r
+ * @param to\r
+ * @param step\r
+ */\r
+ public ListSpinner(int from, int to, int step)\r
+ {\r
+ this( (java.util.List<T>) new ListSpinnerIntegerList(from, to, step) );\r
+ }\r
+\r
+ // ------------\r
+ \r
+ /*\r
+ * \r
+ */\r
+ private void construct()\r
+ {\r
+ // setup the CSS\r
+ // the -fx-skin attribute in the CSS sets which Skin class is used\r
+ this.getStyleClass().add(ListSpinner.class.getSimpleName());\r
+ \r
+ // react to changes of the value\r
+ this.valueObjectProperty.addListener(new ChangeListener<T>()\r
+ {\r
+ @Override\r
+ public void changed(ObservableValue<? extends T> property, T oldValue, T newValue)\r
+ {\r
+ // get the value of the new index\r
+ int lIdx = getItems().indexOf(newValue);\r
+ \r
+ // set the value\r
+ if (ListSpinner.equals(indexObjectProperty.getValue(), lIdx) == false)\r
+ {\r
+ indexObjectProperty.setValue(lIdx);\r
+ }\r
+ }\r
+ });\r
+ \r
+ // react to changes of the index\r
+ this.indexObjectProperty.addListener(new ChangeListener<Integer>()\r
+ {\r
+ @Override\r
+ public void changed(ObservableValue<? extends Integer> property, Integer oldIndex, Integer newIndex)\r
+ {\r
+ // get the value of the new index\r
+ T lValue = newIndex < 0 ? null : getItems().get(newIndex);\r
+ \r
+ // set the value\r
+ if (ListSpinner.equals(valueObjectProperty.getValue(), lValue) == false)\r
+ {\r
+ valueObjectProperty.setValue(lValue);\r
+ }\r
+ }\r
+ });\r
+ \r
+ // react to changes of the items\r
+ this.itemsObjectProperty.addListener(new ChangeListener<ObservableList<T>>()\r
+ {\r
+ @Override\r
+ public void changed(ObservableValue<? extends ObservableList<T>> property, ObservableList<T> oldList, ObservableList<T> newList)\r
+ {\r
+ if (oldList != null) oldList.removeListener(listChangeListener);\r
+ if (newList != null) newList.addListener(listChangeListener);\r
+ }\r
+ });\r
+ }\r
+ \r
+ /*\r
+ * react to observable list changes\r
+ * TODO: what is sticky, index or value? Now: index\r
+ */\r
+ private ListChangeListener<T> listChangeListener = new ListChangeListener<T>()\r
+ {\r
+ @Override\r
+ public void onChanged(javafx.collections.ListChangeListener.Change<? extends T> change)\r
+ {\r
+ // get current index\r
+ int lIndex = getIndex();\r
+ \r
+ // is it still valid?\r
+ if (lIndex >= getItems().size()) \r
+ {\r
+ lIndex = getItems().size() - 1;\r
+ setIndex(lIndex);\r
+ return;\r
+ }\r
+ \r
+ // (re)set the value of the index\r
+ valueObjectProperty.setValue( getItems().get(lIndex) );\r
+ }\r
+ };\r
+\r
+ /**\r
+ * Return the path to the CSS file so things are setup right\r
+ */\r
+ @Override public String getUserAgentStylesheet()\r
+ {\r
+ return ListSpinner.class.getResource("/jfxtras/internal/scene/control/" + ListSpinner.class.getSimpleName() + ".css").toExternalForm();\r
+ }\r
+\r
+ @Override public Skin<?> createDefaultSkin() {\r
+ return new jfxtras.internal.scene.control.skin.ListSpinnerSkin(this); \r
+ }\r
+\r
+ // ==================================================================================================================\r
+ // PROPERTIES\r
+\r
+ /** Id */\r
+ public ListSpinner<T> withId(String value) { setId(value); return this; }\r
+\r
+ /** Value: the currently show value of the list. */\r
+ public ObjectProperty<T> valueProperty() { return this.valueObjectProperty; }\r
+ final private ObjectProperty<T> valueObjectProperty = new SimpleObjectProperty<T>(this, "value", null)\r
+ {\r
+ public void set(T value)\r
+ {\r
+ if (getItems().indexOf(value) < 0) throw new IllegalArgumentException("Value does not exist in the list: " + value); \r
+ super.set(value);\r
+ }\r
+ };\r
+ // java bean API\r
+ public T getValue() { return this.valueObjectProperty.getValue(); }\r
+ public void setValue(T value) { this.valueObjectProperty.setValue(value); }\r
+ public ListSpinner<T> withValue(T value) { setValue(value); return this; }\r
+ \r
+ /** Index: the currently show index in the list. */\r
+ public ObjectProperty<Integer> indexProperty() { return this.indexObjectProperty; }\r
+ final private ObjectProperty<Integer> indexObjectProperty = new SimpleObjectProperty<Integer>(this, "index", null)\r
+ {\r
+ public void set(Integer value)\r
+ {\r
+ if (value == null) throw new NullPointerException("Null not allowed as the value for index");\r
+ if (value >= getItems().size()) throw new IllegalArgumentException("Index out of bounds: " + value + ", valid values are 0-" + (getItems().size() - 1)); \r
+ super.set(value);\r
+ }\r
+ };\r
+ public Integer getIndex() { return this.indexObjectProperty.getValue(); }\r
+ public void setIndex(Integer value) { this.indexObjectProperty.setValue(value); }\r
+ public ListSpinner<T> withIndex(Integer value) { setIndex(value); return this; }\r
+ \r
+ /** Cyclic: what happens at the beginning or end of the list, stop or cycle to the other end. */\r
+ public ObjectProperty<Boolean> cyclicProperty() { return this.cyclicObjectProperty; }\r
+ final private ObjectProperty<Boolean> cyclicObjectProperty = new SimpleObjectProperty<Boolean>(this, "cyclic", false)\r
+ {\r
+ public void set(Boolean value)\r
+ {\r
+ if (value == null) throw new NullPointerException("Null not allowed as the value for cyclic");\r
+ super.set(value);\r
+ }\r
+ };\r
+ public Boolean isCyclic() { return this.cyclicObjectProperty.getValue(); }\r
+ public void setCyclic(Boolean value) { this.cyclicObjectProperty.setValue(value); }\r
+ public ListSpinner<T> withCyclic(Boolean value) { setCyclic(value); return this; }\r
+\r
+ /** 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. */\r
+ public ObjectProperty<Boolean> editableProperty() { return this.editableObjectProperty; }\r
+ final private ObjectProperty<Boolean> editableObjectProperty = new SimpleObjectProperty<Boolean>(this, "editable", false)\r
+ {\r
+ public void set(Boolean value)\r
+ {\r
+ if (value == null) throw new NullPointerException("Null not allowed as the value for editable");\r
+ super.set(value);\r
+ }\r
+ };\r
+ public Boolean isEditable() { return this.editableObjectProperty.getValue(); }\r
+ public void setEditable(Boolean value) { this.editableObjectProperty.setValue(value); }\r
+ public ListSpinner<T> withEditable(Boolean value) { setEditable(value); return this; }\r
+\r
+ /** Postfix: a string to be placed after the value, this can for example be a unit like "kg" */\r
+ public ObjectProperty<String> postfixProperty() { return this.postfixObjectProperty; }\r
+ final private ObjectProperty<String> postfixObjectProperty = new SimpleObjectProperty<String>(this, "postfix", "");\r
+ public String getPostfix() { return this.postfixObjectProperty.getValue(); }\r
+ public void setPostfix(String value) { this.postfixObjectProperty.setValue(value); }\r
+ public ListSpinner<T> withPostfix(String value) { setPostfix(value); return this; }\r
+\r
+ /** Prefix: a string to be placed before the list value, this can for example be a currency */\r
+ public ObjectProperty<String> prefixProperty() { return this.prefixObjectProperty; }\r
+ final private ObjectProperty<String> prefixObjectProperty = new SimpleObjectProperty<String>(this, "prefix", "");\r
+ public String getPrefix() { return this.prefixObjectProperty.getValue(); }\r
+ public void setPrefix(String value) { this.prefixObjectProperty.setValue(value); }\r
+ public ListSpinner<T> withPrefix(String value) { setPrefix(value); return this; }\r
+\r
+ /** Items: the list. */\r
+ public ObjectProperty<ObservableList<T>> itemsProperty() { return this.itemsObjectProperty; }\r
+ final private ObjectProperty<ObservableList<T>> itemsObjectProperty = new SimpleObjectProperty<ObservableList<T>>(this, "items", null)\r
+ {\r
+ public void set(ObservableList<T> value)\r
+ {\r
+ if (value == null) throw new NullPointerException("Null not allowed as the value for items");\r
+ super.set(value);\r
+ }\r
+ };\r
+ public ObservableList<T> getItems() { return this.itemsObjectProperty.getValue(); }\r
+ public void setItems(ObservableList<T> value) { this.itemsObjectProperty.setValue(value); }\r
+ public ListSpinner<T> withItems(ObservableList<T> value) { setItems(value); return this; }\r
+\r
+ /** CellFactory: generate the cell to render a value */\r
+ public ObjectProperty<Callback<ListSpinner<T>, Node>> cellFactoryProperty() { return this.cellFactoryObjectProperty; }\r
+ final private ObjectProperty<Callback<ListSpinner<T>, Node>> cellFactoryObjectProperty = new SimpleObjectProperty<Callback<ListSpinner<T>, Node>>(this, "cellFactory", new DefaultCellFactory());\r
+ public Callback<ListSpinner<T>, Node> getCellFactory() { return this.cellFactoryObjectProperty.getValue(); }\r
+ public void setCellFactory(Callback<ListSpinner<T>, Node> value) { this.cellFactoryObjectProperty.setValue(value); }\r
+ public ListSpinner<T> withCellFactory(Callback<ListSpinner<T>, Node> value) { setCellFactory(value); return this; }\r
+\r
+ /** StringConverter<T>: convert a value in the list to its string representation and (when in edit mode) vice versa. */\r
+ public ObjectProperty<StringConverter<T>> stringConverterProperty() { return this.stringConverterObjectProperty; }\r
+ final private ObjectProperty<StringConverter<T>> stringConverterObjectProperty = new SimpleObjectProperty<StringConverter<T>>(this, "stringConverter", new DefaultStringConverter());\r
+ public StringConverter<T> getStringConverter() { return this.stringConverterObjectProperty.getValue(); }\r
+ public void setStringConverter(StringConverter<T> value) { this.stringConverterObjectProperty.setValue(value); }\r
+ public ListSpinner<T> withStringConverter(StringConverter<T> value) { setStringConverter(value); return this; }\r
+\r
+ /** AddCallback: this callback is called in editable mode when a value is entered that is not found in the list. \r
+ * It is up to the coder to added it to the list or not.\r
+ * @return the index where of the position the ListSpinner must show or null (do nothing expect refresh the currently show index)\r
+ */\r
+ public ObjectProperty<Callback<T, Integer>> addCallbackProperty() { return this.addCallbackObjectProperty; }\r
+ final private ObjectProperty<Callback<T, Integer>> addCallbackObjectProperty = new SimpleObjectProperty<Callback<T, Integer>>(this, "addCallback", null);\r
+ public Callback<T, Integer> getAddCallback() { return this.addCallbackObjectProperty.getValue(); }\r
+ public void setAddCallback(Callback<T, Integer> value) { this.addCallbackObjectProperty.setValue(value); }\r
+ public ListSpinner<T> withAddCallback(Callback<T, Integer> value) { setAddCallback(value); return this; }\r
+\r
+ // ==================================================================================================================\r
+ // StringConverter\r
+ \r
+ /**\r
+ * A string converter that does a simple toString, but cannot convert to an object\r
+ * @see org.jfxextras.util.StringConverterFactory \r
+ */\r
+ class DefaultStringConverter extends StringConverter<T>\r
+ {\r
+ @Override\r
+ public T fromString(String string)\r
+ {\r
+ throw new IllegalStateException("No StringConverter is set. An editable Spinner must have a StringConverter to be able to render and parse the value.");\r
+ }\r
+\r
+ @Override\r
+ public String toString(T value)\r
+ {\r
+ return value == null ? "" : value.toString();\r
+ }\r
+ }\r
+ \r
+ // ==================================================================================================================\r
+ // CellFactory\r
+ \r
+ /**\r
+ * Default cell factory\r
+ */\r
+ class DefaultCellFactory implements Callback<ListSpinner<T>, Node>\r
+ {\r
+ private Label label = null;\r
+ \r
+ @Override\r
+ public Node call(ListSpinner<T> spinner)\r
+ {\r
+ // get value\r
+ T lValue = spinner.getValue();\r
+ \r
+ // label not yet created\r
+ if (this.label == null) \r
+ {\r
+ this.label = new Label();\r
+ }\r
+ this.label.setText( lValue == null ? "" : spinner.getPrefix() + getStringConverter().toString(lValue) + spinner.getPostfix() );\r
+ return this.label;\r
+ }\r
+ };\r
+ \r
+ // ==================================================================================================================\r
+ // EVENTS\r
+ \r
+ /** 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) */\r
+ public ObjectProperty<EventHandler<CycleEvent>> onCycleProperty() { return iOnCycleObjectProperty; }\r
+ final private ObjectProperty<EventHandler<CycleEvent>> iOnCycleObjectProperty = new SimpleObjectProperty<EventHandler<CycleEvent>>(null);\r
+ // java bean API\r
+ public EventHandler<CycleEvent> getOnCycle() { return iOnCycleObjectProperty.getValue(); }\r
+ public void setOnCycle(EventHandler<CycleEvent> value) { iOnCycleObjectProperty.setValue(value); }\r
+ public ListSpinner<T> withOnCycle(EventHandler<CycleEvent> value) { setOnCycle(value); return this; }\r
+ final static public String ONCYCLE_PROPERTY_ID = "onCycle";\r
+ \r
+ /**\r
+ * CycleEvent \r
+ */\r
+ static public class CycleEvent extends Event\r
+ {\r
+ /**\r
+ * The only valid EventType for the CycleEvent.\r
+ */\r
+ public static final EventType<CycleEvent> CYCLE = new EventType<CycleEvent>(Event.ANY, "CYCLE");\r
+\r
+ /**\r
+ * \r
+ */\r
+ public CycleEvent()\r
+ {\r
+ super(CYCLE);\r
+ }\r
+\r
+ /**\r
+ * \r
+ * @param source\r
+ * @param target\r
+ */\r
+ public CycleEvent(Object source, EventTarget target)\r
+ {\r
+ super(source, target, new EventType<CycleEvent>());\r
+ }\r
+ \r
+ public Object getOldIdx() { return this.oldIdx; }\r
+ private Object oldIdx;\r
+ \r
+ public Object getNewIdx() { return this.newIdx; }\r
+ private Object newIdx;\r
+ \r
+ \r
+ public boolean cycledDown() { return cycleDirection == CycleDirection.TOP_TO_BOTTOM; }\r
+ public boolean cycledUp() { return cycleDirection == CycleDirection.BOTTOM_TO_TOP; }\r
+ CycleDirection cycleDirection;\r
+ }\r
+ \r
+ /**\r
+ * we're cycling, fire the event\r
+ */\r
+ public void fireCycleEvent(CycleDirection cycleDirection)\r
+ {\r
+ EventHandler<CycleEvent> lCycleEventHandler = getOnCycle();\r
+ if (lCycleEventHandler != null)\r
+ {\r
+ CycleEvent lCycleEvent = new CycleEvent();\r
+ lCycleEvent.cycleDirection = cycleDirection;\r
+ lCycleEventHandler.handle(lCycleEvent);\r
+ }\r
+ }\r
+ static public enum CycleDirection { TOP_TO_BOTTOM, BOTTOM_TO_TOP }\r
+ \r
+ \r
+ // ==================================================================================================================\r
+ // BEHAVIOR\r
+\r
+ /**\r
+ * \r
+ */\r
+ public void first()\r
+ {\r
+ // nothing to do\r
+ if (getItems() == null || getItems().size() == 0) return;\r
+ \r
+ // set the new index (this will update the value)\r
+ indexObjectProperty.setValue(0);\r
+ }\r
+ \r
+ /**\r
+ * \r
+ */\r
+ public void decrement()\r
{
- construct();
- setItems(items);
- setValue(startValue);
- }
-
- // ------------
- // convenience
-
- /**
- * @param list
- */
- public ListSpinner(java.util.List<T> 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<T>) new ListSpinnerIntegerList(from, to) );
- }
-
- /**
- * @param from
- * @param to
- * @param step
- */
- public ListSpinner(int from, int to, int step)
- {
- this( (java.util.List<T>) 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<T>()
- {
- @Override
- public void changed(ObservableValue<? extends T> 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<Integer>()
- {
- @Override
- public void changed(ObservableValue<? extends Integer> 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<ObservableList<T>>()
- {
- @Override
- public void changed(ObservableValue<? extends ObservableList<T>> property, ObservableList<T> oldList, ObservableList<T> 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<T> listChangeListener = new ListChangeListener<T>()
- {
- @Override
- public void onChanged(javafx.collections.ListChangeListener.Change<? extends T> 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<T> valueProperty() { return this.valueObjectProperty; }
- final private ObjectProperty<T> valueObjectProperty = new SimpleObjectProperty<T>(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<T> withValue(T value) { setValue(value); return this; }
-
- /** Index: */
- public ObjectProperty<Integer> indexProperty() { return this.indexObjectProperty; }
- final private ObjectProperty<Integer> indexObjectProperty = new SimpleObjectProperty<Integer>(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<T> withIndex(Integer value) { setIndex(value); return this; }
-
- /** Cyclic: */
- public ObjectProperty<Boolean> cyclicProperty() { return this.cyclicObjectProperty; }
- final private ObjectProperty<Boolean> cyclicObjectProperty = new SimpleObjectProperty<Boolean>(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<T> withCyclic(Boolean value) { setCyclic(value); return this; }
-
- /** Editable: */
- public ObjectProperty<Boolean> editableProperty() { return this.editableObjectProperty; }
- final private ObjectProperty<Boolean> editableObjectProperty = new SimpleObjectProperty<Boolean>(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<T> withEditable(Boolean value) { setEditable(value); return this; }
-
- /** Postfix: */
- public ObjectProperty<String> postfixProperty() { return this.postfixObjectProperty; }
- final private ObjectProperty<String> postfixObjectProperty = new SimpleObjectProperty<String>(this, "postfix", "");
- public String getPostfix() { return this.postfixObjectProperty.getValue(); }
- public void setPostfix(String value) { this.postfixObjectProperty.setValue(value); }
- public ListSpinner<T> withPostfix(String value) { setPostfix(value); return this; }
-
- /** Prefix: */
- public ObjectProperty<String> prefixProperty() { return this.prefixObjectProperty; }
- final private ObjectProperty<String> prefixObjectProperty = new SimpleObjectProperty<String>(this, "prefix", "");
- public String getPrefix() { return this.prefixObjectProperty.getValue(); }
- public void setPrefix(String value) { this.prefixObjectProperty.setValue(value); }
- public ListSpinner<T> withPrefix(String value) { setPrefix(value); return this; }
-
- /** Items: */
- public ObjectProperty<ObservableList<T>> itemsProperty() { return this.itemsObjectProperty; }
- final private ObjectProperty<ObservableList<T>> itemsObjectProperty = new SimpleObjectProperty<ObservableList<T>>(this, "items", null)
- {
- public void set(ObservableList<T> value)
- {
- if (value == null) throw new NullPointerException("Null not allowed as the value for items");
- super.set(value);
- }
- };
- public ObservableList<T> getItems() { return this.itemsObjectProperty.getValue(); }
- public void setItems(ObservableList<T> value) { this.itemsObjectProperty.setValue(value); }
- public ListSpinner<T> withItems(ObservableList<T> value) { setItems(value); return this; }
-
- /** CellFactory: */
- public ObjectProperty<Callback<ListSpinner<T>, Node>> cellFactoryProperty() { return this.cellFactoryObjectProperty; }
- final private ObjectProperty<Callback<ListSpinner<T>, Node>> cellFactoryObjectProperty = new SimpleObjectProperty<Callback<ListSpinner<T>, Node>>(this, "cellFactory", new DefaultCellFactory());
- public Callback<ListSpinner<T>, Node> getCellFactory() { return this.cellFactoryObjectProperty.getValue(); }
- public void setCellFactory(Callback<ListSpinner<T>, Node> value) { this.cellFactoryObjectProperty.setValue(value); }
- public ListSpinner<T> withCellFactory(Callback<ListSpinner<T>, Node> value) { setCellFactory(value); return this; }
-
- /** StringConverter<T>: */
- public ObjectProperty<StringConverter<T>> stringConverterProperty() { return this.stringConverterObjectProperty; }
- final private ObjectProperty<StringConverter<T>> stringConverterObjectProperty = new SimpleObjectProperty<StringConverter<T>>(this, "stringConverter", new DefaultStringConverter());
- public StringConverter<T> getStringConverter() { return this.stringConverterObjectProperty.getValue(); }
- public void setStringConverter(StringConverter<T> value) { this.stringConverterObjectProperty.setValue(value); }
- public ListSpinner<T> withStringConverter(StringConverter<T> value) { setStringConverter(value); return this; }
-
- /** ArrowDirection: */
- public ObjectProperty<ArrowDirection> arrowDirectionProperty() { return this.arrowDirectionObjectProperty; }
- final private ObjectProperty<ArrowDirection> arrowDirectionObjectProperty = new SimpleObjectProperty<ArrowDirection>(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<T> withArrowDirection(ArrowDirection value) { setArrowDirection(value); return this; }
- public enum ArrowDirection {VERTICAL, HORIZONTAL}
-
- /** ArrowPosition: */
- public ObjectProperty<ArrowPosition> arrowPositionProperty() { return this.arrowPositionObjectProperty; }
- final private ObjectProperty<ArrowPosition> arrowPositionObjectProperty = new SimpleObjectProperty<ArrowPosition>(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<T> withArrowPosition(ArrowPosition value) { setArrowPosition(value); return this; }
- public enum ArrowPosition {LEADING, TRAILING, SPLIT}
-
- /** Alignment: only applicable in non edit mode */
- public ObjectProperty<Pos> alignmentProperty() { return this.alignmentObjectProperty; }
- final private ObjectProperty<Pos> alignmentObjectProperty = new SimpleObjectProperty<Pos>(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<T> withAlignment(Pos value) { setAlignment(value); return this; }
-
- /** AddCallback: */
- public ObjectProperty<Callback<T, Integer>> addCallbackProperty() { return this.addCallbackObjectProperty; }
- final private ObjectProperty<Callback<T, Integer>> addCallbackObjectProperty = new SimpleObjectProperty<Callback<T, Integer>>(this, "addCallback", null);
- public Callback<T, Integer> getAddCallback() { return this.addCallbackObjectProperty.getValue(); }
- public void setAddCallback(Callback<T, Integer> value) { this.addCallbackObjectProperty.setValue(value); }
- public ListSpinner<T> withAddCallback(Callback<T, Integer> 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<T>
- {
- @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<ListSpinner<T>, Node>
- {
- private Label label = null;
-
- @Override
- public Node call(ListSpinner<T> 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<EventHandler<CycleEvent>> onCycleProperty() { return iOnCycleObjectProperty; }
- final private ObjectProperty<EventHandler<CycleEvent>> iOnCycleObjectProperty = new SimpleObjectProperty<EventHandler<CycleEvent>>(null);
- // java bean API
- public EventHandler<CycleEvent> getOnCycle() { return iOnCycleObjectProperty.getValue(); }
- public void setOnCycle(EventHandler<CycleEvent> value) { iOnCycleObjectProperty.setValue(value); }
- public ListSpinner<T> withOnCycle(EventHandler<CycleEvent> 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<CycleEvent>());
- }
-
- /**
- *
- * @param source
- * @param target
- */
- public CycleEvent(Object source, EventTarget target)
- {
- super(source, target, new EventType<CycleEvent>());
- }
-
- 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<CycleEvent> 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\r
+ if (getItems() == null || getItems().size() == 0) return;\r
+ \r
+ // get the current index\r
+ int lOldIdx = this.indexObjectProperty.getValue();\r
+ \r
+ // get the previous index (usually current - 1)\r
+ int lIdx = lOldIdx - 1;\r
+ \r
+ // if end\r
+ if (lIdx < 0)\r
+ {\r
+ // if we're not cyclic\r
+ if (isCyclic() != null && isCyclic().booleanValue() == false)\r
+ {\r
+ // do nothing\r
+ return;\r
+ }\r
+ \r
+ // cycle to the other end: get the last value\r
+ lIdx = getItems().size() - 1;\r
+ \r
+ // notify listener that we've cycled\r
+ fireCycleEvent(CycleDirection.BOTTOM_TO_TOP);\r
+ }\r
+\r
+ // set the new index (this will update the value)\r
+ indexObjectProperty.setValue(lIdx);\r
+ }\r
+ \r
+ /**\r
+ * \r
+ */\r
+ public void increment()\r
+ {\r
+ // nothing to do\r
+ if (getItems() == null || getItems().size() == 0) return;\r
+ \r
+ // get the current index\r
+ int lOldIdx = this.indexObjectProperty.getValue();\r
+ \r
+ // get the next index (usually current + 1)\r
+ int lIdx = lOldIdx + 1;\r
+ \r
+ // if null is return, there is no next index (usually current + 1)\r
+ if (lIdx >= getItems().size())\r
+ {\r
+ // if we're not cyclic\r
+ if (isCyclic() != null && isCyclic().booleanValue() == false)\r
+ {\r
+ // do nothing\r
+ return;\r
+ }\r
+ \r
+ // cycle to the other end: get the first value\r
+ lIdx = 0;\r
+ \r
+ // notify listener that we've cycled\r
+ fireCycleEvent(CycleDirection.TOP_TO_BOTTOM);\r
+ }\r
+ \r
+ // set the new index (this will update the value)\r
+ indexObjectProperty.setValue(lIdx);\r
+ }\r
+\r
+ /**\r
+ * Get the last index; if the data provide is endless, this method mail fail!\r
+ */\r
+ public void last()\r
+ {\r
+ // nothing to do\r
+ if (getItems() == null || getItems().size() == 0) return;\r
+ \r
+ // set the new index (this will update the value)\r
+ indexObjectProperty.setValue(getItems().size() - 1);\r
+ }\r
+\r
+ /**\r
+ * Does a o1.equals(o2) but also checks if o1 or o2 are null.\r
+ * @param o1\r
+ * @param o2\r
+ * @return True if the two values are equal, false otherwise.\r
+ */\r
+ static public boolean equals(Object o1, Object o2)\r
+ {\r
+ if ( o1 == null && o2 == null ) return true;\r
+ if ( o1 != null && o2 == null ) return false;\r
+ if ( o1 == null && o2 != null ) return false;\r
+ // TODO: compare arrays if (o1.getClass().isArray() && o2.getClass().isArray()) return Arrays.equals( (Object[])o1, (Object[])o2 ); \r
+ return o1.equals(o2);\r
+ }\r
+\r
+}\r
--- /dev/null
+/**\r
+ * Copyright (c) 2011-2021, JFXtras\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ * Redistributions of source code must retain the above copyright\r
+ * notice, this list of conditions and the following disclaimer.\r
+ * Redistributions in binary form must reproduce the above copyright\r
+ * notice, this list of conditions and the following disclaimer in the\r
+ * documentation and/or other materials provided with the distribution.\r
+ * Neither the name of the organization nor the\r
+ * names of its contributors may be used to endorse or promote products\r
+ * derived from this software without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND\r
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\r
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r
+ * DISCLAIMED. IN NO EVENT SHALL JFXTRAS BE LIABLE FOR ANY\r
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\r
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\r
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\r
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ */\r
+package jfxtras.scene.control;\r
+\r
+import java.math.BigInteger;\r
+\r
+/**\r
+ * Items for Spinner providing an BigInteger range without actually creating a list with all values.\r
+ * 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).\r
+ * So the difference between the from and to values (to-from) cannot be larger than Integer.MAX_VALUE.\r
+ * What this class allows is that this range can be anywhere in the BigInteger's range. \r
+ */\r
+public class ListSpinnerBigIntegerList extends java.util.AbstractList<BigInteger>\r
+{\r
+ /**\r
+ * \r
+ */\r
+ public ListSpinnerBigIntegerList()\r
+ {\r
+ this( BigInteger.valueOf(Integer.MIN_VALUE / 2).add(BigInteger.ONE), BigInteger.valueOf(Integer.MAX_VALUE / 2), BigInteger.ONE);\r
+ }\r
+ \r
+ /**\r
+ * \r
+ * @param from\r
+ * @param to\r
+ */\r
+ public ListSpinnerBigIntegerList(BigInteger from, BigInteger to)\r
+ {\r
+ this(from, to, from.compareTo(to) > 0 ? BigInteger.valueOf(-1) : BigInteger.ONE);\r
+ }\r
+ \r
+ /**\r
+ * \r
+ * @param from\r
+ * @param to\r
+ * @param step\r
+ */\r
+ public ListSpinnerBigIntegerList(BigInteger from, BigInteger to, BigInteger step)\r
+ {\r
+ this.from = from;\r
+ this.size = to.subtract(from).divide(step).add(BigInteger.ONE).intValue();\r
+ if (this.size < 0) throw new IllegalArgumentException("This results in a negative size: " + from + ", " + to + "," + step);\r
+ this.step = step;\r
+ }\r
+ private BigInteger from;\r
+ private int size;\r
+ private BigInteger step;\r
+ \r
+ \r
+ // ===============================================================================\r
+ // List interface\r
+ \r
+ @Override\r
+ public BigInteger get(int index)\r
+ {\r
+ if (index < 0) throw new IllegalArgumentException("Index cannot be < 0: " + index);\r
+ BigInteger lValue = this.from.add(BigInteger.valueOf(index).multiply(this.step));\r
+ return lValue;\r
+ }\r
+\r
+ @Override\r
+ public int indexOf(Object o)\r
+ {\r
+ // calculate the index\r
+ BigInteger lValue = (BigInteger)o;\r
+ BigInteger lIndexBigInteger = lValue.subtract(this.from).divide(this.step);\r
+ int lIndex = lIndexBigInteger.intValue();\r
+ if (lIndex > size) return -1;\r
+ \r
+ // check if that what is at the index matches with out value\r
+ BigInteger lValueAtIndex = get(lIndex);\r
+ if (o.equals(lValueAtIndex) == false) return -1;\r
+ \r
+ // found it\r
+ return lIndex;\r
+ }\r
+ \r
+ @Override\r
+ public int size()\r
+ {\r
+ return this.size;\r
+ }\r
+}
\ No newline at end of file
--- /dev/null
+/**\r
+ * Copyright (c) 2011-2021, JFXtras\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ * Redistributions of source code must retain the above copyright\r
+ * notice, this list of conditions and the following disclaimer.\r
+ * Redistributions in binary form must reproduce the above copyright\r
+ * notice, this list of conditions and the following disclaimer in the\r
+ * documentation and/or other materials provided with the distribution.\r
+ * Neither the name of the organization nor the\r
+ * names of its contributors may be used to endorse or promote products\r
+ * derived from this software without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND\r
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\r
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r
+ * DISCLAIMED. IN NO EVENT SHALL JFXTRAS BE LIABLE FOR ANY\r
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\r
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\r
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\r
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ */\r
+package jfxtras.scene.control;\r
+\r
+/**\r
+ * Items for Spinner providing an integer range without actually creating a list with all values.\r
+ */\r
+public class ListSpinnerIntegerList extends java.util.AbstractList<Integer>\r
+{\r
+ /**\r
+ * \r
+ */\r
+ public ListSpinnerIntegerList()\r
+ {\r
+ this( (Integer.MIN_VALUE / 2) + 1, Integer.MAX_VALUE / 2, 1);\r
+ }\r
+ \r
+ /**\r
+ * \r
+ * @param from\r
+ * @param to\r
+ */\r
+ public ListSpinnerIntegerList(int from, int to)\r
+ {\r
+ this(from, to, from > to ? -1 : 1);\r
+ }\r
+ \r
+ /**\r
+ * \r
+ * @param from\r
+ * @param to\r
+ * @param step\r
+ */\r
+ public ListSpinnerIntegerList(int from, int to, int step)\r
+ {\r
+ this.from = from;\r
+ this.size = ((to - from) / step) + 1;\r
+ if (size < 0) throw new IllegalArgumentException("This results in a negative size: " + from + ", " + to + "," + step);\r
+ this.step = step;\r
+ }\r
+ private int from;\r
+ private int size;\r
+ private int step;\r
+ \r
+ \r
+ // ===============================================================================\r
+ // List interface\r
+ \r
+ @Override\r
+ public Integer get(int index)\r
+ {\r
+ if (index < 0) throw new IllegalArgumentException("Index cannot be < 0: " + index);\r
+ int lValue = this.from + (index * this.step);\r
+ return lValue;\r
+ }\r
+\r
+ @Override\r
+ public int indexOf(Object o)\r
+ {\r
+ // calculate the index\r
+ int lValue = ((Integer)o).intValue();\r
+ int lIndex = (lValue - this.from) / this.step;\r
+ if (lIndex < 0 || lIndex >= size) return -1;\r
+ \r
+ // check if that what is at the index matches with out value\r
+ Integer lValueAtIndex = get(lIndex);\r
+ if (o.equals(lValueAtIndex) == false) return -1;\r
+ \r
+ // found it\r
+ return lIndex;\r
+ }\r
+ \r
+ @Override\r
+ public int size()\r
+ {\r
+ return this.size;\r
+ }\r
+}
\ No newline at end of file
--- /dev/null
+/**\r
+ * Copyright (c) 2011-2021, JFXtras\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ * Redistributions of source code must retain the above copyright\r
+ * notice, this list of conditions and the following disclaimer.\r
+ * Redistributions in binary form must reproduce the above copyright\r
+ * notice, this list of conditions and the following disclaimer in the\r
+ * documentation and/or other materials provided with the distribution.\r
+ * Neither the name of the organization nor the\r
+ * names of its contributors may be used to endorse or promote products\r
+ * derived from this software without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND\r
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\r
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r
+ * DISCLAIMED. IN NO EVENT SHALL JFXTRAS BE LIABLE FOR ANY\r
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\r
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\r
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\r
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ */\r
+package jfxtras.scene.layout;\r
+\r
+import javafx.scene.Node;\r
+\r
+class GenericLayoutConstraints\r
+{\r
+ /**\r
+ * The layout constraints\r
+ *\r
+ */\r
+ public static class C<T>\r
+ {\r
+ // minWidth\r
+ public T minWidth(double value) { this.minWidth = value; return (T)this; }\r
+ double minWidth = -1;\r
+ double minWidthReset = UNKNOWN;\r
+ \r
+ // prefWidth\r
+ public T prefWidth(double value) { this.prefWidth = value; return (T)this; }\r
+ double prefWidth = -1;\r
+ double prefWidthReset = UNKNOWN;\r
+ \r
+ // maxWidth\r
+ public T maxWidth(double value) { this.maxWidth = value; return (T)this; }\r
+ double maxWidth = -1;\r
+ double maxWidthReset = UNKNOWN;\r
+\r
+ // minHeight\r
+ public T minHeight(double value) { this.minHeight = value; return (T)this; }\r
+ double minHeight = -1;\r
+ double minHeightReset = UNKNOWN;\r
+\r
+ // prefHeight\r
+ public T prefHeight(double value) { this.prefHeight = value; return (T)this; }\r
+ double prefHeight = -1;\r
+ double prefHeightReset = UNKNOWN;\r
+ \r
+ // maxHeight\r
+ public T maxHeight(double value) { this.maxHeight = value; return (T)this; }\r
+ double maxHeight = -1;\r
+ double maxHeightReset = UNKNOWN;\r
+ \r
+ /**\r
+ * @param node\r
+ */\r
+ protected void rememberResetValues(Node node)\r
+ {\r
+ if (node instanceof javafx.scene.layout.Region)\r
+ {\r
+ javafx.scene.layout.Region lRegion = (javafx.scene.layout.Region)node;\r
+ \r
+ // setup the reset values on the first apply\r
+ if (minWidthReset == UNKNOWN) minWidthReset = lRegion.getMinWidth();\r
+ if (prefWidthReset == UNKNOWN) prefWidthReset = lRegion.getPrefWidth();\r
+ if (maxWidthReset == UNKNOWN) maxWidthReset = lRegion.getMaxWidth();\r
+ if (minHeightReset == UNKNOWN) minHeightReset = lRegion.getMinHeight();\r
+ if (prefHeightReset == UNKNOWN) prefHeightReset = lRegion.getPrefHeight();\r
+ if (maxHeightReset == UNKNOWN) maxHeightReset = lRegion.getMaxHeight();\r
+ }\r
+ }\r
+ \r
+ /**\r
+ * @param node\r
+ */\r
+ protected void apply(Node node)\r
+ {\r
+ if (node instanceof javafx.scene.layout.Region)\r
+ {\r
+ javafx.scene.layout.Region lRegion = (javafx.scene.layout.Region)node;\r
+ \r
+ // setup the reset values on the first apply\r
+ rememberResetValues(lRegion);\r
+ \r
+ // either set or reset values\r
+ lRegion.setMinWidth(minWidth >= 0 ? minWidth : minWidthReset);\r
+ lRegion.setPrefWidth(prefWidth >= 0 ? prefWidth : prefWidthReset);\r
+ lRegion.setMaxWidth(maxWidth >= 0 ? maxWidth : maxWidthReset);\r
+ lRegion.setMinHeight(minHeight >= 0 ? minHeight : minHeightReset);\r
+ lRegion.setPrefHeight(prefHeight >= 0 ? prefHeight : prefHeightReset);\r
+ lRegion.setMaxHeight(maxHeight >= 0 ? maxHeight : maxHeightReset);\r
+ }\r
+ }\r
+ \r
+ }\r
+ static final double UNKNOWN = -Double.MIN_NORMAL + 10.0;\r
+ \r
+ /**\r
+ * \r
+ */\r
+ static public void overrideMaxWidth(Node node, C c)\r
+ {\r
+ // just to prevent problems\r
+ if (node == null) return;\r
+ \r
+ // make max issues go away\r
+ if (node instanceof javafx.scene.layout.Region)\r
+ {\r
+ javafx.scene.layout.Region lRegion = (javafx.scene.layout.Region)node;\r
+ lRegion.setMaxWidth( c.maxWidth >= 0 ? c.maxWidth : Double.MAX_VALUE);\r
+ }\r
+ }\r
+ \r
+ /**\r
+ * \r
+ */\r
+ static public void overrideMaxHeight(Node node, C c)\r
+ {\r
+ // just to prevent problems\r
+ if (node == null) return;\r
+ \r
+ // make max issues go away\r
+ if (node instanceof javafx.scene.layout.Region)\r
+ {\r
+ javafx.scene.layout.Region lRegion = (javafx.scene.layout.Region)node;\r
+ lRegion.setMaxHeight( c.maxHeight >= 0 ? c.maxHeight : Double.MAX_VALUE);
+ }\r
+ }\r
+ \r
+}\r
--- /dev/null
+/**\r
+ * Copyright (c) 2011-2021, JFXtras\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ * Redistributions of source code must retain the above copyright\r
+ * notice, this list of conditions and the following disclaimer.\r
+ * Redistributions in binary form must reproduce the above copyright\r
+ * notice, this list of conditions and the following disclaimer in the\r
+ * documentation and/or other materials provided with the distribution.\r
+ * Neither the name of the organization nor the\r
+ * names of its contributors may be used to endorse or promote products\r
+ * derived from this software without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND\r
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\r
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r
+ * DISCLAIMED. IN NO EVENT SHALL JFXTRAS BE LIABLE FOR ANY\r
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\r
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\r
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\r
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ */\r
+package jfxtras.scene.layout;\r
+\r
+import java.util.WeakHashMap;\r
+\r
+import javafx.collections.ListChangeListener;\r
+import javafx.scene.Node;\r
+\r
+/**\r
+ * A drop-in replacement for JavaFX's HBox using layout constraints.\r
+ * So instead of:\r
+ * [source,java]\r
+ * --\r
+ * HBox lHBox = new HBox(5.0);\r
+ * Button b1 = new Button("short");\r
+ * lHBox.getChildren().add(b1);\r
+ * HBox.setHgrow(b1, Priority.ALWAYS);\r
+ * --\r
+ *\r
+ * You can write:\r
+ * [source,java]\r
+ * --\r
+ * HBox lHBox = new HBox(5.0);\r
+ * lHBox.add(new Button("short"), new HBox.C().hgrow(Priority.ALWAYS));\r
+ * --\r
+ *\r
+ * This class is not a reimplementation of HBox, but only applies a different API.\r
+ * \r
+ * @author Tom Eugelink\r
+ *\r
+ */\r
+public class HBox extends javafx.scene.layout.HBox\r
+{\r
+ // ========================================================================================================================================================\r
+ // Constructors\r
+ \r
+ /**\r
+ * \r
+ */\r
+ public HBox()\r
+ {\r
+ super();\r
+ construct();\r
+ }\r
+ \r
+ /**\r
+ * \r
+ * @param spacing\r
+ */\r
+ public HBox(double spacing)\r
+ {\r
+ super(spacing);\r
+ construct();\r
+ }\r
+
+ /**
+ *
+ * @param spacing
+ * @param nodes
+ */\r
+ public HBox(double spacing, Node... nodes) {
+ super(spacing, nodes);
+ construct();
+ }
+
+ /**
+ *
+ * @param nodes
+ */
+ public HBox(Node... nodes) {
+ super(nodes);
+ construct();
+ }
+
+ /**\r
+ * \r
+ */\r
+ private void construct()\r
+ {\r
+ getChildren().addListener(new ListChangeListener<Node>()\r
+ {\r
+ @Override\r
+ public void onChanged(javafx.collections.ListChangeListener.Change<? extends Node> changes)\r
+ {\r
+ while (changes.next())\r
+ {\r
+ for (Node lNode : changes.getAddedSubList())\r
+ {\r
+ C lC = cMap.get(lNode);\r
+ if (lC != null) lC.apply(lNode);\r
+ }\r
+ }\r
+ }\r
+ });\r
+ }\r
+ \r
+ \r
+ // ========================================================================================================================================================\r
+ // Properties\r
+ \r
+ /**\r
+ * \r
+ * @param value\r
+ * @return\r
+ */\r
+ public HBox withSpacing(double value)\r
+ {\r
+ super.setSpacing(value);\r
+ return this;\r
+ }\r
+ \r
+ \r
+ // ========================================================================================================================================================\r
+ // Layout constraints\r
+ \r
+ /**\r
+ * The layout constraints\r
+ *\r
+ */\r
+ public static class C extends GenericLayoutConstraints.C<C>\r
+ {\r
+ // hgrow\r
+ public C hgrow(javafx.scene.layout.Priority value) { this.hgrow = value; return this; }\r
+ private javafx.scene.layout.Priority hgrow = null;\r
+ private javafx.scene.layout.Priority hgrowReset = null;\r
+ \r
+ // margin\r
+ public C margin(javafx.geometry.Insets value) { this.margin = value; return this; }\r
+ private javafx.geometry.Insets margin = null;\r
+ private javafx.geometry.Insets marginReset = null;\r
+ \r
+ /**\r
+ * @param node\r
+ */\r
+ protected void rememberResetValues(Node node)\r
+ {\r
+ super.rememberResetValues(node);\r
+ hgrowReset = javafx.scene.layout.HBox.getHgrow(node);\r
+ marginReset = javafx.scene.layout.HBox.getMargin(node);\r
+ }\r
+ \r
+ /**\r
+ * \r
+ * @param node\r
+ */\r
+ protected void apply(Node node)\r
+ {\r
+ // sanatize the node\r
+ super.apply(node);\r
+\r
+ // apply constraints\r
+ if (hgrow != null) GenericLayoutConstraints.overrideMaxWidth(node, this);\r
+ javafx.scene.layout.HBox.setHgrow(node, hgrow != null ? hgrow : hgrowReset);\r
+ javafx.scene.layout.HBox.setMargin(node, margin != null ? margin : marginReset);\r
+ }\r
+ }\r
+ \r
+ /**\r
+ * The collection of layout constraints\r
+ */\r
+ private WeakHashMap<Node, C> cMap = new WeakHashMap<>();\r
+ \r
+ /**\r
+ * Add\r
+ */\r
+ public HBox add(Node node)\r
+ {\r
+ // add node\r
+ getChildren().add(node);
+ return this;\r
+ }\r
+\r
+ /**\r
+ * Add\r
+ */\r
+ public HBox add(Node node, C c)\r
+ {\r
+ // remember constraints\r
+ cMap.put(node, c);\r
+ c.rememberResetValues(node);\r
+ \r
+ // add node\r
+ getChildren().add(node);
+ return this;\r
+ }\r
+\r
+ /**\r
+ * Remove a node completely\r
+ * @param node\r
+ */\r
+ public HBox remove(Node node)\r
+ {\r
+ // remove node\r
+ getChildren().remove(node);\r
+ \r
+ // remove constraints\r
+ cMap.remove(node);
+ return this;\r
+ }\r
+\r
+ /**\r
+ * set constraint without adding the node (in case the node might end up here because of an animation or something) \r
+ */\r
+ public void setConstraint(Node node, C c)\r
+ {\r
+ // remember constraints\r
+ cMap.put(node, c);\r
+ c.rememberResetValues(node);\r
+ }\r
+\r
+ /**\r
+ * Remove a constraint, not the node.\r
+ * @param node\r
+ */\r
+ public void removeConstraintsFor(Node node)\r
+ {\r
+ cMap.remove(node);\r
+ }\r
+ \r
+ /**\r
+ * Remove a node, not the constraints.\r
+ * @param node\r
+ */\r
+ public void removeNode(Node node)\r
+ {\r
+ getChildren().remove(node);\r
+ }\r
+}\r
--- /dev/null
+/**\r
+ * Copyright (c) 2011-2021, JFXtras\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ * Redistributions of source code must retain the above copyright\r
+ * notice, this list of conditions and the following disclaimer.\r
+ * Redistributions in binary form must reproduce the above copyright\r
+ * notice, this list of conditions and the following disclaimer in the\r
+ * documentation and/or other materials provided with the distribution.\r
+ * Neither the name of the organization nor the\r
+ * names of its contributors may be used to endorse or promote products\r
+ * derived from this software without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND\r
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\r
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r
+ * DISCLAIMED. IN NO EVENT SHALL JFXTRAS BE LIABLE FOR ANY\r
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\r
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\r
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\r
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ */\r
+package jfxtras.scene.layout;\r
+\r
+import java.util.WeakHashMap;\r
+\r
+import javafx.collections.ListChangeListener;\r
+import javafx.scene.Node;\r
+\r
+/**\r
+ * A drop-in replacement for JavaFX's VBox using layout constraints.\r
+ * So instead of:\r
+ * [source,java]\r
+ * --\r
+ * VBox lVBox = new VBox(5.0);\r
+ * Button b1 = new Button("short");\r
+ * lVBox.getChildren().add(b1);\r
+ * VBox.setVgrow(b1, Priority.ALWAYS);\r
+ * --\r
+ *\r
+ * You can write:\r
+ * [source,java]\r
+ * --\r
+ * VBox lVBox = new VBox(5.0);\r
+ * lVBox.add(new Button("short"), new VBox.C().vgrow(Priority.ALWAYS));\r
+ * --\r
+ *\r
+ * This class is not a reimplementation of VBox, but only applies a different API.\r
+ * \r
+ * @author Tom Eugelink\r
+ *\r
+ */\r
+public class VBox extends javafx.scene.layout.VBox\r
+{\r
+ // ========================================================================================================================================================\r
+ // Constructors\r
+ \r
+ /**\r
+ * \r
+ */\r
+ public VBox()\r
+ {\r
+ super();\r
+ construct();\r
+ }\r
+ \r
+ /**\r
+ * \r
+ * @param spacing\r
+ */\r
+ public VBox(double spacing)\r
+ {\r
+ super(spacing);\r
+ construct();\r
+ }\r
+
+ /**
+ *
+ * @param spacing
+ * @param nodes
+ */\r
+ public VBox(double spacing, Node... nodes) {
+ super(spacing, nodes);
+ construct();
+ }
+
+ /**
+ *
+ * @param nodes
+ */
+ public VBox(Node... nodes) {
+ super(nodes);
+ construct();
+ }
+
+ /**\r
+ * \r
+ */\r
+ private void construct()\r
+ {\r
+ getChildren().addListener(new ListChangeListener<Node>()\r
+ {\r
+ @Override\r
+ public void onChanged(javafx.collections.ListChangeListener.Change<? extends Node> changes)\r
+ {\r
+ while (changes.next())\r
+ {\r
+ for (Node lNode : changes.getAddedSubList())\r
+ {\r
+ C lC = cMap.get(lNode);\r
+ if (lC != null) lC.apply(lNode);\r
+ }\r
+ }\r
+ }\r
+ });\r
+ }\r
+ \r
+ \r
+ // ========================================================================================================================================================\r
+ // Properties\r
+ \r
+ /**\r
+ * \r
+ * @param value\r
+ * @return\r
+ */\r
+ public VBox withSpacing(double value)\r
+ {\r
+ super.setSpacing(value);\r
+ return this;\r
+ }\r
+ \r
+ \r
+ // ========================================================================================================================================================\r
+ // Layout constraints\r
+ \r
+ /**\r
+ * The layout constraints\r
+ */\r
+ public static class C extends GenericLayoutConstraints.C<C>\r
+ {\r
+ // vgrow\r
+ public C vgrow(javafx.scene.layout.Priority value) { this.vgrow = value; return this; }\r
+ private javafx.scene.layout.Priority vgrow = null;\r
+ private javafx.scene.layout.Priority vgrowReset = null;\r
+ \r
+ // margin\r
+ public C margin(javafx.geometry.Insets value) { this.margin= value; return this; }\r
+ javafx.geometry.Insets margin = null;\r
+ javafx.geometry.Insets marginReset = null;\r
+ \r
+ /**\r
+ * @param node\r
+ */\r
+ protected void rememberResetValues(Node node)\r
+ {\r
+ super.rememberResetValues(node);\r
+ vgrowReset = javafx.scene.layout.VBox.getVgrow(node);\r
+ marginReset = javafx.scene.layout.VBox.getMargin(node);\r
+ }\r
+ \r
+ /**\r
+ * \r
+ * @param node\r
+ */\r
+ protected void apply(Node node)\r
+ {\r
+ // sanatize the node\r
+ super.apply(node);\r
+\r
+ // apply constraints\r
+ if (vgrow != null) GenericLayoutConstraints.overrideMaxHeight(node, this);\r
+ javafx.scene.layout.VBox.setVgrow(node, vgrow != null ? vgrow : vgrowReset);\r
+ javafx.scene.layout.VBox.setMargin(node, margin != null ? margin : marginReset);\r
+ }\r
+ }\r
+ \r
+ /**\r
+ * The collection of layout constraints\r
+ */\r
+ private WeakHashMap<Node, C> cMap = new WeakHashMap<>();\r
+\r
+ /**\r
+ * \r
+ * @param node\r
+ */\r
+ public VBox add(Node node)\r
+ {\r
+ // add node\r
+ getChildren().add(node);
+ return this;\r
+ }\r
+\r
+ /**\r
+ * \r
+ * @param node\r
+ * @param c\r
+ */\r
+ public VBox add(Node node, C c)\r
+ {\r
+ // remember constraints\r
+ cMap.put(node, c);\r
+ c.rememberResetValues(node);\r
+ \r
+ // add node\r
+ getChildren().add(node);
+ return this;\r
+ }\r
+\r
+ /**\r
+ * Remove a node completely\r
+ * @param node\r
+ */\r
+ public VBox remove(Node node)\r
+ {\r
+ // remove node\r
+ getChildren().remove(node);\r
+ \r
+ // remove constraints\r
+ cMap.remove(node);
+ return this;\r
+ }\r
+\r
+ /**\r
+ * set constraint without adding the node (in case the node might end up here because of an animation or something)\r
+ * @param node\r
+ * @param c\r
+ */\r
+ public void setConstraint(Node node, C c)\r
+ {\r
+ // remember constraints\r
+ cMap.put(node, c);\r
+ c.rememberResetValues(node);\r
+ }\r
+\r
+ /**\r
+ * Remove a constraint, not the node.\r
+ * @param node\r
+ */\r
+ public void removeConstraintsFor(Node node)\r
+ {\r
+ cMap.remove(node);\r
+ }\r
+ \r
+ /**\r
+ * Remove a node, not the constraints.\r
+ * @param node\r
+ */\r
+ public void removeNode(Node node)\r
+ {\r
+ getChildren().remove(node);\r
+ }\r
+}\r
--- /dev/null
+/**
+ * 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 <code>null</code>
+ */
+ 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 <code>null</code>
+ */
+ 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<Node> 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;
+ }
+
+}
--- /dev/null
+
+# 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
--- /dev/null
+
+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.
/**
* Layer of a map. i.e. a set of tiles.
- *
+ *
* Hmm, should this virtualise it's view?
* @author Michael Zucchi <notzed@gmail.com>
*/
setBottom(hscroll);
setRight(vscroll);
}
-
-
+
+
void main() {
- ComboBoxListCell.forListView(null);
-
ListView lv = null;
lv.setCellFactory(new Callback() {
throw new UnsupportedOperationException("Not supported yet.");
}
});
-
+
}
class MapView extends Pane {
// track/update visible portion?
}
-
-
+
+
}
//
-// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2
-// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
-// 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 <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// 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 = {
/**
* Gets the value of the encoding property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public String getEncoding() {
return encoding;
/**
* Sets the value of the encoding property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setEncoding(String value) {
this.encoding = value;
/**
* Gets the value of the compression property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public String getCompression() {
return compression;
/**
* Sets the value of the compression property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setCompression(String value) {
this.compression = value;
/**
* Gets the value of the value property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public String getvalue() {
return value;
/**
* Sets the value of the value property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setvalue(String value) {
this.value = value;
//
-// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2
-// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
-// 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 <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// 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 = {
/**
* Gets the value of the format property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public String getFormat() {
return format;
/**
* Sets the value of the format property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setFormat(String value) {
this.format = value;
/**
* Gets the value of the id property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public String getId() {
return id;
/**
* Sets the value of the id property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setId(String value) {
this.id = value;
/**
* Gets the value of the source property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public String getSource() {
return source;
/**
* Sets the value of the source property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setSource(String value) {
this.source = value;
/**
* Gets the value of the trans property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public String getTrans() {
return trans;
/**
* Sets the value of the trans property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setTrans(String value) {
this.trans = value;
/**
* Gets the value of the data property.
- *
+ *
* @return
* possible object is
* {@link Data }
- *
+ *
*/
public Data getData() {
return data;
/**
* Sets the value of the data property.
- *
+ *
* @param value
* allowed object is
* {@link Data }
- *
+ *
*/
public void setData(Data value) {
this.data = value;
//
-// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2
-// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
-// 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 <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// 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 = {
/**
* Gets the value of the name property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public String getName() {
return name;
/**
* Sets the value of the name property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setName(String value) {
this.name = value;
/**
* Gets the value of the width property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public int getWidth() {
return width;
/**
* Sets the value of the width property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setWidth(int value) {
this.width = value;
/**
* Gets the value of the height property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public int getHeight() {
return height;
/**
* Sets the value of the height property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setHeight(int value) {
this.height = value;
/**
* Gets the value of the x property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public int getX() {
return x;
/**
* Sets the value of the x property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setX(int value) {
this.x = value;
/**
* Gets the value of the y property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public int getY() {
return y;
/**
* Sets the value of the y property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setY(int value) {
this.y = value;
/**
* Gets the value of the opacity property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public float getOpacity() {
return opacity;
/**
* Sets the value of the opacity property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setOpacity(float value) {
this.opacity = value;
/**
* Gets the value of the visible property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public int getVisible() {
return visible;
/**
* Sets the value of the visible property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setVisible(int value) {
this.visible = value;
/**
* Gets the value of the properties property.
- *
+ *
* @return
* possible object is
* {@link Properties }
- *
+ *
*/
public Properties getProperties() {
return properties;
/**
* Sets the value of the properties property.
- *
+ *
* @param value
* allowed object is
* {@link Properties }
- *
+ *
*/
public void setProperties(Properties value) {
this.properties = value;
/**
* Gets the value of the data property.
- *
+ *
* @return
* possible object is
* {@link Data }
- *
+ *
*/
public Data getData() {
return data;
/**
* Sets the value of the data property.
- *
+ *
* @param value
* allowed object is
* {@link Data }
- *
+ *
*/
public void setData(Data value) {
this.data = value;
//
-// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2
-// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
-// 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 <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// 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 = {
/**
* Gets the value of the xmlns property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public String getXmlns() {
return xmlns;
/**
* Sets the value of the xmlns property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setXmlns(String value) {
this.xmlns = value;
/**
* Gets the value of the xmlnsXsi property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public String getXmlnsXsi() {
return xmlnsXsi;
/**
* Sets the value of the xmlnsXsi property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setXmlnsXsi(String value) {
this.xmlnsXsi = value;
/**
* Gets the value of the xsiSchemaLocation property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public String getXsiSchemaLocation() {
return xsiSchemaLocation;
/**
* Sets the value of the xsiSchemaLocation property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setXsiSchemaLocation(String value) {
this.xsiSchemaLocation = value;
/**
* Gets the value of the version property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public String getVersion() {
return version;
/**
* Sets the value of the version property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setVersion(String value) {
this.version = value;
/**
* Gets the value of the orientation property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public String getOrientation() {
return orientation;
/**
* Sets the value of the orientation property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setOrientation(String value) {
this.orientation = value;
/**
* Gets the value of the width property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public int getWidth() {
return width;
/**
* Sets the value of the width property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setWidth(int value) {
this.width = value;
/**
* Gets the value of the height property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public int getHeight() {
return height;
/**
* Sets the value of the height property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setHeight(int value) {
this.height = value;
/**
* Gets the value of the tilewidth property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public int getTilewidth() {
return tilewidth;
/**
* Sets the value of the tilewidth property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setTilewidth(int value) {
this.tilewidth = value;
/**
* Gets the value of the tileheight property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public int getTileheight() {
return tileheight;
/**
* Sets the value of the tileheight property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setTileheight(int value) {
this.tileheight = value;
/**
* Gets the value of the properties property.
- *
+ *
* @return
* possible object is
* {@link Properties }
- *
+ *
*/
public Properties getProperties() {
return properties;
/**
* Sets the value of the properties property.
- *
+ *
* @param value
* allowed object is
* {@link Properties }
- *
+ *
*/
public void setProperties(Properties value) {
this.properties = value;
/**
* Gets the value of the tileset property.
- *
+ *
* <p>
* 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 <CODE>set</CODE> method for the tileset property.
- *
+ *
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getTileset().add(newItem);
* </pre>
- *
- *
+ *
+ *
* <p>
* Objects of the following type(s) are allowed in the list
* {@link Tileset }
- *
- *
+ *
+ *
*/
public List<Tileset> getTileset() {
if (tileset == null) {
/**
* Gets the value of the layerOrObjectgroup property.
- *
+ *
* <p>
* 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 <CODE>set</CODE> method for the layerOrObjectgroup property.
- *
+ *
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getLayerOrObjectgroup().add(newItem);
* </pre>
- *
- *
+ *
+ *
* <p>
* Objects of the following type(s) are allowed in the list
* {@link Layer }
* {@link Objectgroup }
- *
- *
+ *
+ *
*/
public List<java.lang.Object> getLayerOrObjectgroup() {
if (layerOrObjectgroup == null) {
//
-// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2
-// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
-// 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 <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// 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 = {
/**
* Gets the value of the name property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public String getName() {
return name;
/**
* Sets the value of the name property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setName(String value) {
this.name = value;
/**
* Gets the value of the type property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public String getType() {
return type;
/**
* Sets the value of the type property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setType(String value) {
this.type = value;
/**
* Gets the value of the x property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public int getX() {
return x;
/**
* Sets the value of the x property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setX(int value) {
this.x = value;
/**
* Gets the value of the y property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public int getY() {
return y;
/**
* Sets the value of the y property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setY(int value) {
this.y = value;
/**
* Gets the value of the width property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public int getWidth() {
return width;
/**
* Sets the value of the width property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setWidth(int value) {
this.width = value;
/**
* Gets the value of the height property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public int getHeight() {
return height;
/**
* Sets the value of the height property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setHeight(int value) {
this.height = value;
/**
* Gets the value of the properties property.
- *
+ *
* @return
* possible object is
* {@link Properties }
- *
+ *
*/
public Properties getProperties() {
return properties;
/**
* Sets the value of the properties property.
- *
+ *
* @param value
* allowed object is
* {@link Properties }
- *
+ *
*/
public void setProperties(Properties value) {
this.properties = value;
/**
* Gets the value of the image property.
- *
+ *
* @return
* possible object is
* {@link Image }
- *
+ *
*/
public Image getImage() {
return image;
/**
* Sets the value of the image property.
- *
+ *
* @param value
* allowed object is
* {@link Image }
- *
+ *
*/
public void setImage(Image value) {
this.image = value;
//
-// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2
-// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
-// 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 <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// 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.
- * <p>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.
+ * <p>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 {
/**
* 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();
/**
* Create an instance of {@link Image }
- *
+ *
*/
public Image createImage() {
return new Image();
/**
* Create an instance of {@link Tile }
- *
+ *
*/
public Tile createTile() {
return new Tile();
/**
* Create an instance of {@link Properties }
- *
+ *
*/
public Properties createProperties() {
return new Properties();
/**
* Create an instance of {@link Objectgroup }
- *
+ *
*/
public Objectgroup createObjectgroup() {
return new Objectgroup();
/**
* Create an instance of {@link Object }
- *
+ *
*/
public Object createObject() {
return new Object();
/**
* Create an instance of {@link Data }
- *
+ *
*/
public Data createData() {
return new Data();
/**
* Create an instance of {@link Map }
- *
+ *
*/
public Map createMap() {
return new Map();
/**
* Create an instance of {@link Layer }
- *
+ *
*/
public Layer createLayer() {
return new Layer();
/**
* Create an instance of {@link Property }
- *
+ *
*/
public Property createProperty() {
return new Property();
//
-// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2
-// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
-// 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 <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// 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 = {
/**
* Gets the value of the name property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public String getName() {
return name;
/**
* Sets the value of the name property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setName(String value) {
this.name = value;
/**
* Gets the value of the width property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public int getWidth() {
return width;
/**
* Sets the value of the width property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setWidth(int value) {
this.width = value;
/**
* Gets the value of the height property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public int getHeight() {
return height;
/**
* Sets the value of the height property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setHeight(int value) {
this.height = value;
/**
* Gets the value of the x property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public int getX() {
return x;
/**
* Sets the value of the x property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setX(int value) {
this.x = value;
/**
* Gets the value of the y property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public int getY() {
return y;
/**
* Sets the value of the y property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setY(int value) {
this.y = value;
/**
* Gets the value of the object property.
- *
+ *
* <p>
* 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 <CODE>set</CODE> method for the object property.
- *
+ *
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getObject().add(newItem);
* </pre>
- *
- *
+ *
+ *
* <p>
* Objects of the following type(s) are allowed in the list
* {@link Object }
- *
- *
+ *
+ *
*/
public List<Object> getObject() {
if (object == null) {
//
-// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2
-// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
-// 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 <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// 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 = {
/**
* Gets the value of the property property.
- *
+ *
* <p>
* 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 <CODE>set</CODE> method for the property property.
- *
+ *
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getProperty().add(newItem);
* </pre>
- *
- *
+ *
+ *
* <p>
* Objects of the following type(s) are allowed in the list
* {@link Property }
- *
- *
+ *
+ *
*/
public List<Property> getProperty() {
if (property == null) {
//
-// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2
-// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
-// 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 <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// 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 = "")
/**
* Gets the value of the name property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public String getName() {
return name;
/**
* Sets the value of the name property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setName(String value) {
this.name = value;
/**
* Gets the value of the value property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public String getValue() {
return value;
/**
* Sets the value of the value property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setValue(String value) {
this.value = value;
//
-// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2
-// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
-// 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 <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// 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 = {
/**
* Gets the value of the id property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public int getId() {
return id;
/**
* Sets the value of the id property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setId(int value) {
this.id = value;
/**
* Gets the value of the gid property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public String getGid() {
return gid;
/**
* Sets the value of the gid property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setGid(String value) {
this.gid = value;
/**
* Gets the value of the properties property.
- *
+ *
* @return
* possible object is
* {@link Properties }
- *
+ *
*/
public Properties getProperties() {
return properties;
/**
* Sets the value of the properties property.
- *
+ *
* @param value
* allowed object is
* {@link Properties }
- *
+ *
*/
public void setProperties(Properties value) {
this.properties = value;
/**
* Gets the value of the image property.
- *
+ *
* @return
* possible object is
* {@link Image }
- *
+ *
*/
public Image getImage() {
return image;
/**
* Sets the value of the image property.
- *
+ *
* @param value
* allowed object is
* {@link Image }
- *
+ *
*/
public void setImage(Image value) {
this.image = value;
//
-// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2
-// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
-// 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 <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// 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 = {
/**
* Gets the value of the name property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public String getName() {
return name;
/**
* Sets the value of the name property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setName(String value) {
this.name = value;
/**
* Gets the value of the firstgid property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public int getFirstgid() {
return firstgid;
/**
* Sets the value of the firstgid property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setFirstgid(int value) {
this.firstgid = value;
/**
* Gets the value of the source property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public String getSource() {
return source;
/**
* Sets the value of the source property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setSource(String value) {
this.source = value;
/**
* Gets the value of the tilewidth property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public int getTilewidth() {
return tilewidth;
/**
* Sets the value of the tilewidth property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setTilewidth(int value) {
this.tilewidth = value;
/**
* Gets the value of the tileheight property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public int getTileheight() {
return tileheight;
/**
* Sets the value of the tileheight property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setTileheight(int value) {
this.tileheight = value;
/**
* Gets the value of the spacing property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public int getSpacing() {
return spacing;
/**
* Sets the value of the spacing property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setSpacing(int value) {
this.spacing = value;
/**
* Gets the value of the margin property.
- *
+ *
* @return
* possible object is
* {@link String }
- *
+ *
*/
public String getMargin() {
return margin;
/**
* Sets the value of the margin property.
- *
+ *
* @param value
* allowed object is
* {@link String }
- *
+ *
*/
public void setMargin(String value) {
this.margin = value;
/**
* Gets the value of the image property.
- *
+ *
* <p>
* 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 <CODE>set</CODE> method for the image property.
- *
+ *
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getImage().add(newItem);
* </pre>
- *
- *
+ *
+ *
* <p>
* Objects of the following type(s) are allowed in the list
* {@link Image }
- *
- *
+ *
+ *
*/
public List<Image> getImage() {
if (image == null) {
/**
* Gets the value of the tile property.
- *
+ *
* <p>
* 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 <CODE>set</CODE> method for the tile property.
- *
+ *
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getTile().add(newItem);
* </pre>
- *
- *
+ *
+ *
* <p>
* Objects of the following type(s) are allowed in the list
* {@link Tile }
- *
- *
+ *
+ *
*/
public List<Tile> getTile() {
if (tile == null) {
--- /dev/null
+#
+# 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 <http://www.gnu.org/licenses/>.
+#
+
+# This lets one download maven packages using simple automake syntax.
+
+# maven_<name>_URL = baseurl
+
+# Define the base url. maven_central_URL is already defined as
+# maven_central_URL:=https://repo1.maven.org/maven2
+
+# maven_<name>_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