From 0310c88973e4beab08e5526aeaa8320ae685e25f Mon Sep 17 00:00:00 2001 From: Tino Schmidt Date: Thu, 8 Mar 2018 00:15:46 +0100 Subject: [PATCH] Config/settings XML files + default status + added 2 new XSD schemas - added default segment status and removed integers (resolves #13) - added config.xsd that defines project level settings (resolves #17) - added settings.xsd that defines global settings in home folder (resolves #18) - added jaxb2-maven-plugin to the pom file - cleaned and reorganized VisbilityPanel.java - updated and reorganized RhizoAddons.java to handle the new xml files --- pom.xml | 24 + src/main/java/META-INF/sun-jaxb.episode | 23 + .../informatik/rhizoTrak/Project.java | 8 +- .../informatik/rhizoTrak/config/Config.java | 390 +++++++++ .../rhizoTrak/config/GlobalSettings.java | 390 +++++++++ .../rhizoTrak/config/ObjectFactory.java | 87 +++ .../informatik/rhizoTrak/display/Display.java | 2 +- .../informatik/rhizoTrak/display/Node.java | 19 +- .../rhizoTrak/display/RhizoAddons.java | 621 +++++++++------ .../display/addonGui/VisibilityPanel.java | 738 +++--------------- src/main/resources/schemas/config.xsd | 29 + src/main/resources/schemas/settings.xsd | 29 + 12 files changed, 1471 insertions(+), 889 deletions(-) create mode 100644 src/main/java/META-INF/sun-jaxb.episode create mode 100644 src/main/java/de/unihalle/informatik/rhizoTrak/config/Config.java create mode 100644 src/main/java/de/unihalle/informatik/rhizoTrak/config/GlobalSettings.java create mode 100644 src/main/java/de/unihalle/informatik/rhizoTrak/config/ObjectFactory.java create mode 100644 src/main/resources/schemas/config.xsd create mode 100644 src/main/resources/schemas/settings.xsd diff --git a/pom.xml b/pom.xml index ccd14674a..122b7534e 100644 --- a/pom.xml +++ b/pom.xml @@ -267,6 +267,30 @@ + + + + org.codehaus.mojo + jaxb2-maven-plugin + 2.3.1 + + + xjc-configXSD + + xjc + + + + + ${project.basedir}/src/main/java + + src/main/resources/schemas/config.xsd + src/main/resources/schemas/settings.xsd + + false + de.unihalle.informatik.rhizoTrak.config + + org.apache.maven.plugins diff --git a/src/main/java/META-INF/sun-jaxb.episode b/src/main/java/META-INF/sun-jaxb.episode new file mode 100644 index 000000000..24649b27c --- /dev/null +++ b/src/main/java/META-INF/sun-jaxb.episode @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + diff --git a/src/main/java/de/unihalle/informatik/rhizoTrak/Project.java b/src/main/java/de/unihalle/informatik/rhizoTrak/Project.java index 97781454e..ac1daf800 100644 --- a/src/main/java/de/unihalle/informatik/rhizoTrak/Project.java +++ b/src/main/java/de/unihalle/informatik/rhizoTrak/Project.java @@ -566,8 +566,12 @@ static public Project newFSProject(String arg, TemplateThing template_root, Stri // aeekz final OpenDialog od = new OpenDialog("Select status file", dir_project, null); - RhizoAddons.loadStatusFile(od.getPath()); - if(RhizoAddons.userSettingFile.exists()) RhizoAddons.loadUserSettings(); + RhizoAddons.loadConfigFile(od.getPath()); + if(RhizoAddons.userSettingsFile.exists()) + { + Utils.log("@Project: called loadUserSettings("); + RhizoAddons.loadUserSettings(); + } // help the helpless users: if (autocreate_one_layer && null != project && ControlWindow.isGUIEnabled()) { diff --git a/src/main/java/de/unihalle/informatik/rhizoTrak/config/Config.java b/src/main/java/de/unihalle/informatik/rhizoTrak/config/Config.java new file mode 100644 index 000000000..6609ac56e --- /dev/null +++ b/src/main/java/de/unihalle/informatik/rhizoTrak/config/Config.java @@ -0,0 +1,390 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2018.03.07 at 06:54:45 PM CET +// + + +package de.unihalle.informatik.rhizoTrak.config; + +import java.math.BigInteger; +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.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="statusList">
+ *           <complexType>
+ *             <complexContent>
+ *               <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *                 <sequence>
+ *                   <element name="status" maxOccurs="unbounded">
+ *                     <complexType>
+ *                       <complexContent>
+ *                         <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *                           <sequence>
+ *                             <element name="fullName" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ *                             <element name="abbreviation" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ *                             <element name="red" type="{http://www.w3.org/2001/XMLSchema}integer"/>
+ *                             <element name="green" type="{http://www.w3.org/2001/XMLSchema}integer"/>
+ *                             <element name="blue" type="{http://www.w3.org/2001/XMLSchema}integer"/>
+ *                             <element name="alpha" type="{http://www.w3.org/2001/XMLSchema}integer"/>
+ *                             <element name="selectable" type="{http://www.w3.org/2001/XMLSchema}boolean"/>
+ *                           </sequence>
+ *                         </restriction>
+ *                       </complexContent>
+ *                     </complexType>
+ *                   </element>
+ *                 </sequence>
+ *               </restriction>
+ *             </complexContent>
+ *           </complexType>
+ *         </element>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "statusList" +}) +@XmlRootElement(name = "config") +public class Config { + + @XmlElement(required = true) + protected Config.StatusList statusList; + + /** + * Gets the value of the statusList property. + * + * @return + * possible object is + * {@link Config.StatusList } + * + */ + public Config.StatusList getStatusList() { + return statusList; + } + + /** + * Sets the value of the statusList property. + * + * @param value + * allowed object is + * {@link Config.StatusList } + * + */ + public void setStatusList(Config.StatusList value) { + this.statusList = value; + } + + + /** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+     * <complexType>
+     *   <complexContent>
+     *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+     *       <sequence>
+     *         <element name="status" maxOccurs="unbounded">
+     *           <complexType>
+     *             <complexContent>
+     *               <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+     *                 <sequence>
+     *                   <element name="fullName" type="{http://www.w3.org/2001/XMLSchema}string"/>
+     *                   <element name="abbreviation" type="{http://www.w3.org/2001/XMLSchema}string"/>
+     *                   <element name="red" type="{http://www.w3.org/2001/XMLSchema}integer"/>
+     *                   <element name="green" type="{http://www.w3.org/2001/XMLSchema}integer"/>
+     *                   <element name="blue" type="{http://www.w3.org/2001/XMLSchema}integer"/>
+     *                   <element name="alpha" type="{http://www.w3.org/2001/XMLSchema}integer"/>
+     *                   <element name="selectable" type="{http://www.w3.org/2001/XMLSchema}boolean"/>
+     *                 </sequence>
+     *               </restriction>
+     *             </complexContent>
+     *           </complexType>
+     *         </element>
+     *       </sequence>
+     *     </restriction>
+     *   </complexContent>
+     * </complexType>
+     * 
+ * + * + */ + @XmlAccessorType(XmlAccessType.FIELD) + @XmlType(name = "", propOrder = { + "status" + }) + public static class StatusList { + + @XmlElement(required = true) + protected List status; + + /** + * Gets the value of the status property. + * + *

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

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

+         *    getStatus().add(newItem);
+         * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link Config.StatusList.Status } + * + * + */ + public List getStatus() { + if (status == null) { + status = new ArrayList(); + } + return this.status; + } + + + /** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+         * <complexType>
+         *   <complexContent>
+         *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+         *       <sequence>
+         *         <element name="fullName" type="{http://www.w3.org/2001/XMLSchema}string"/>
+         *         <element name="abbreviation" type="{http://www.w3.org/2001/XMLSchema}string"/>
+         *         <element name="red" type="{http://www.w3.org/2001/XMLSchema}integer"/>
+         *         <element name="green" type="{http://www.w3.org/2001/XMLSchema}integer"/>
+         *         <element name="blue" type="{http://www.w3.org/2001/XMLSchema}integer"/>
+         *         <element name="alpha" type="{http://www.w3.org/2001/XMLSchema}integer"/>
+         *         <element name="selectable" type="{http://www.w3.org/2001/XMLSchema}boolean"/>
+         *       </sequence>
+         *     </restriction>
+         *   </complexContent>
+         * </complexType>
+         * 
+ * + * + */ + @XmlAccessorType(XmlAccessType.FIELD) + @XmlType(name = "", propOrder = { + "fullName", + "abbreviation", + "red", + "green", + "blue", + "alpha", + "selectable" + }) + public static class Status { + + @XmlElement(required = true) + protected String fullName; + @XmlElement(required = true) + protected String abbreviation; + @XmlElement(required = true) + protected BigInteger red; + @XmlElement(required = true) + protected BigInteger green; + @XmlElement(required = true) + protected BigInteger blue; + @XmlElement(required = true) + protected BigInteger alpha; + protected boolean selectable; + + /** + * Gets the value of the fullName property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getFullName() { + return fullName; + } + + /** + * Sets the value of the fullName property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setFullName(String value) { + this.fullName = value; + } + + /** + * Gets the value of the abbreviation property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getAbbreviation() { + return abbreviation; + } + + /** + * Sets the value of the abbreviation property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setAbbreviation(String value) { + this.abbreviation = value; + } + + /** + * Gets the value of the red property. + * + * @return + * possible object is + * {@link BigInteger } + * + */ + public BigInteger getRed() { + return red; + } + + /** + * Sets the value of the red property. + * + * @param value + * allowed object is + * {@link BigInteger } + * + */ + public void setRed(BigInteger value) { + this.red = value; + } + + /** + * Gets the value of the green property. + * + * @return + * possible object is + * {@link BigInteger } + * + */ + public BigInteger getGreen() { + return green; + } + + /** + * Sets the value of the green property. + * + * @param value + * allowed object is + * {@link BigInteger } + * + */ + public void setGreen(BigInteger value) { + this.green = value; + } + + /** + * Gets the value of the blue property. + * + * @return + * possible object is + * {@link BigInteger } + * + */ + public BigInteger getBlue() { + return blue; + } + + /** + * Sets the value of the blue property. + * + * @param value + * allowed object is + * {@link BigInteger } + * + */ + public void setBlue(BigInteger value) { + this.blue = value; + } + + /** + * Gets the value of the alpha property. + * + * @return + * possible object is + * {@link BigInteger } + * + */ + public BigInteger getAlpha() { + return alpha; + } + + /** + * Sets the value of the alpha property. + * + * @param value + * allowed object is + * {@link BigInteger } + * + */ + public void setAlpha(BigInteger value) { + this.alpha = value; + } + + /** + * Gets the value of the selectable property. + * + */ + public boolean isSelectable() { + return selectable; + } + + /** + * Sets the value of the selectable property. + * + */ + public void setSelectable(boolean value) { + this.selectable = value; + } + + } + + } + +} diff --git a/src/main/java/de/unihalle/informatik/rhizoTrak/config/GlobalSettings.java b/src/main/java/de/unihalle/informatik/rhizoTrak/config/GlobalSettings.java new file mode 100644 index 000000000..7c79431b5 --- /dev/null +++ b/src/main/java/de/unihalle/informatik/rhizoTrak/config/GlobalSettings.java @@ -0,0 +1,390 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2018.03.07 at 06:54:45 PM CET +// + + +package de.unihalle.informatik.rhizoTrak.config; + +import java.math.BigInteger; +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.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="globalStatusList">
+ *           <complexType>
+ *             <complexContent>
+ *               <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *                 <sequence>
+ *                   <element name="globalStatus" maxOccurs="unbounded">
+ *                     <complexType>
+ *                       <complexContent>
+ *                         <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *                           <sequence>
+ *                             <element name="fullName" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ *                             <element name="abbreviation" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ *                             <element name="red" type="{http://www.w3.org/2001/XMLSchema}integer"/>
+ *                             <element name="green" type="{http://www.w3.org/2001/XMLSchema}integer"/>
+ *                             <element name="blue" type="{http://www.w3.org/2001/XMLSchema}integer"/>
+ *                             <element name="alpha" type="{http://www.w3.org/2001/XMLSchema}integer"/>
+ *                             <element name="selectable" type="{http://www.w3.org/2001/XMLSchema}boolean"/>
+ *                           </sequence>
+ *                         </restriction>
+ *                       </complexContent>
+ *                     </complexType>
+ *                   </element>
+ *                 </sequence>
+ *               </restriction>
+ *             </complexContent>
+ *           </complexType>
+ *         </element>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "globalStatusList" +}) +@XmlRootElement(name = "globalSettings") +public class GlobalSettings { + + @XmlElement(required = true) + protected GlobalSettings.GlobalStatusList globalStatusList; + + /** + * Gets the value of the globalStatusList property. + * + * @return + * possible object is + * {@link GlobalSettings.GlobalStatusList } + * + */ + public GlobalSettings.GlobalStatusList getGlobalStatusList() { + return globalStatusList; + } + + /** + * Sets the value of the globalStatusList property. + * + * @param value + * allowed object is + * {@link GlobalSettings.GlobalStatusList } + * + */ + public void setGlobalStatusList(GlobalSettings.GlobalStatusList value) { + this.globalStatusList = value; + } + + + /** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+     * <complexType>
+     *   <complexContent>
+     *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+     *       <sequence>
+     *         <element name="globalStatus" maxOccurs="unbounded">
+     *           <complexType>
+     *             <complexContent>
+     *               <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+     *                 <sequence>
+     *                   <element name="fullName" type="{http://www.w3.org/2001/XMLSchema}string"/>
+     *                   <element name="abbreviation" type="{http://www.w3.org/2001/XMLSchema}string"/>
+     *                   <element name="red" type="{http://www.w3.org/2001/XMLSchema}integer"/>
+     *                   <element name="green" type="{http://www.w3.org/2001/XMLSchema}integer"/>
+     *                   <element name="blue" type="{http://www.w3.org/2001/XMLSchema}integer"/>
+     *                   <element name="alpha" type="{http://www.w3.org/2001/XMLSchema}integer"/>
+     *                   <element name="selectable" type="{http://www.w3.org/2001/XMLSchema}boolean"/>
+     *                 </sequence>
+     *               </restriction>
+     *             </complexContent>
+     *           </complexType>
+     *         </element>
+     *       </sequence>
+     *     </restriction>
+     *   </complexContent>
+     * </complexType>
+     * 
+ * + * + */ + @XmlAccessorType(XmlAccessType.FIELD) + @XmlType(name = "", propOrder = { + "globalStatus" + }) + public static class GlobalStatusList { + + @XmlElement(required = true) + protected List globalStatus; + + /** + * Gets the value of the globalStatus property. + * + *

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

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

+         *    getGlobalStatus().add(newItem);
+         * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link GlobalSettings.GlobalStatusList.GlobalStatus } + * + * + */ + public List getGlobalStatus() { + if (globalStatus == null) { + globalStatus = new ArrayList(); + } + return this.globalStatus; + } + + + /** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+         * <complexType>
+         *   <complexContent>
+         *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+         *       <sequence>
+         *         <element name="fullName" type="{http://www.w3.org/2001/XMLSchema}string"/>
+         *         <element name="abbreviation" type="{http://www.w3.org/2001/XMLSchema}string"/>
+         *         <element name="red" type="{http://www.w3.org/2001/XMLSchema}integer"/>
+         *         <element name="green" type="{http://www.w3.org/2001/XMLSchema}integer"/>
+         *         <element name="blue" type="{http://www.w3.org/2001/XMLSchema}integer"/>
+         *         <element name="alpha" type="{http://www.w3.org/2001/XMLSchema}integer"/>
+         *         <element name="selectable" type="{http://www.w3.org/2001/XMLSchema}boolean"/>
+         *       </sequence>
+         *     </restriction>
+         *   </complexContent>
+         * </complexType>
+         * 
+ * + * + */ + @XmlAccessorType(XmlAccessType.FIELD) + @XmlType(name = "", propOrder = { + "fullName", + "abbreviation", + "red", + "green", + "blue", + "alpha", + "selectable" + }) + public static class GlobalStatus { + + @XmlElement(required = true) + protected String fullName; + @XmlElement(required = true) + protected String abbreviation; + @XmlElement(required = true) + protected BigInteger red; + @XmlElement(required = true) + protected BigInteger green; + @XmlElement(required = true) + protected BigInteger blue; + @XmlElement(required = true) + protected BigInteger alpha; + protected boolean selectable; + + /** + * Gets the value of the fullName property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getFullName() { + return fullName; + } + + /** + * Sets the value of the fullName property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setFullName(String value) { + this.fullName = value; + } + + /** + * Gets the value of the abbreviation property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getAbbreviation() { + return abbreviation; + } + + /** + * Sets the value of the abbreviation property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setAbbreviation(String value) { + this.abbreviation = value; + } + + /** + * Gets the value of the red property. + * + * @return + * possible object is + * {@link BigInteger } + * + */ + public BigInteger getRed() { + return red; + } + + /** + * Sets the value of the red property. + * + * @param value + * allowed object is + * {@link BigInteger } + * + */ + public void setRed(BigInteger value) { + this.red = value; + } + + /** + * Gets the value of the green property. + * + * @return + * possible object is + * {@link BigInteger } + * + */ + public BigInteger getGreen() { + return green; + } + + /** + * Sets the value of the green property. + * + * @param value + * allowed object is + * {@link BigInteger } + * + */ + public void setGreen(BigInteger value) { + this.green = value; + } + + /** + * Gets the value of the blue property. + * + * @return + * possible object is + * {@link BigInteger } + * + */ + public BigInteger getBlue() { + return blue; + } + + /** + * Sets the value of the blue property. + * + * @param value + * allowed object is + * {@link BigInteger } + * + */ + public void setBlue(BigInteger value) { + this.blue = value; + } + + /** + * Gets the value of the alpha property. + * + * @return + * possible object is + * {@link BigInteger } + * + */ + public BigInteger getAlpha() { + return alpha; + } + + /** + * Sets the value of the alpha property. + * + * @param value + * allowed object is + * {@link BigInteger } + * + */ + public void setAlpha(BigInteger value) { + this.alpha = value; + } + + /** + * Gets the value of the selectable property. + * + */ + public boolean isSelectable() { + return selectable; + } + + /** + * Sets the value of the selectable property. + * + */ + public void setSelectable(boolean value) { + this.selectable = value; + } + + } + + } + +} diff --git a/src/main/java/de/unihalle/informatik/rhizoTrak/config/ObjectFactory.java b/src/main/java/de/unihalle/informatik/rhizoTrak/config/ObjectFactory.java new file mode 100644 index 000000000..49b160985 --- /dev/null +++ b/src/main/java/de/unihalle/informatik/rhizoTrak/config/ObjectFactory.java @@ -0,0 +1,87 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2018.03.07 at 06:54:45 PM CET +// + + +package de.unihalle.informatik.rhizoTrak.config; + +import javax.xml.bind.annotation.XmlRegistry; + + +/** + * This object contains factory methods for each + * Java content interface and Java element interface + * generated in the de.unihalle.informatik.rhizoTrak.config package. + *

An ObjectFactory allows you to programatically + * construct new instances of the Java representation + * for XML content. The Java representation of XML + * content can consist of schema derived interfaces + * and classes representing the binding of schema + * type definitions, element declarations and model + * groups. Factory methods for each of these are + * provided in this class. + * + */ +@XmlRegistry +public class ObjectFactory { + + + /** + * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: de.unihalle.informatik.rhizoTrak.config + * + */ + public ObjectFactory() { + } + + /** + * Create an instance of {@link Config } + * + */ + public Config createConfig() { + return new Config(); + } + + /** + * Create an instance of {@link GlobalSettings } + * + */ + public GlobalSettings createGlobalSettings() { + return new GlobalSettings(); + } + + /** + * Create an instance of {@link GlobalSettings.GlobalStatusList } + * + */ + public GlobalSettings.GlobalStatusList createGlobalSettingsGlobalStatusList() { + return new GlobalSettings.GlobalStatusList(); + } + + /** + * Create an instance of {@link Config.StatusList } + * + */ + public Config.StatusList createConfigStatusList() { + return new Config.StatusList(); + } + + /** + * Create an instance of {@link GlobalSettings.GlobalStatusList.GlobalStatus } + * + */ + public GlobalSettings.GlobalStatusList.GlobalStatus createGlobalSettingsGlobalStatusListGlobalStatus() { + return new GlobalSettings.GlobalStatusList.GlobalStatus(); + } + + /** + * Create an instance of {@link Config.StatusList.Status } + * + */ + public Config.StatusList.Status createConfigStatusListStatus() { + return new Config.StatusList.Status(); + } + +} diff --git a/src/main/java/de/unihalle/informatik/rhizoTrak/display/Display.java b/src/main/java/de/unihalle/informatik/rhizoTrak/display/Display.java index 318944621..bc606c0e0 100644 --- a/src/main/java/de/unihalle/informatik/rhizoTrak/display/Display.java +++ b/src/main/java/de/unihalle/informatik/rhizoTrak/display/Display.java @@ -2297,7 +2297,7 @@ protected void choose(final int screen_x_p, final int screen_y_p, final int x_p, Node nearestNode = currentTreeline.findNearestNode((float)transX,(float) transY, layer); //Utils.log(nearestNode); //check if treeline is clickable if not add it to the remove list - if(RhizoAddons.treeLineClickable[(int)nearestNode.getConfidence()]==false){ + if(nearestNode.getConfidence() > 0 && !RhizoAddons.statusMap.get((int) nearestNode.getConfidence()).isSelectable()) { alternatedList.add(displayable); } } diff --git a/src/main/java/de/unihalle/informatik/rhizoTrak/display/Node.java b/src/main/java/de/unihalle/informatik/rhizoTrak/display/Node.java index 91b83eb00..823def5bf 100644 --- a/src/main/java/de/unihalle/informatik/rhizoTrak/display/Node.java +++ b/src/main/java/de/unihalle/informatik/rhizoTrak/display/Node.java @@ -417,10 +417,9 @@ public void run() { // Draw confidence half-way through the edge // aeekz - int i = (int) confidence; - String s = ""; - if(RhizoAddons.statusFileExists) s = RhizoAddons.statusListAbbr.get(i); - else s = Integer.toString(i); + int i = (int) this.getConfidence(); + if(i > RhizoAddons.getStatusListSize()) Utils.log("@Node: confidence is higher than status list size"); + String s = RhizoAddons.statusList.get(i).getAbbreviation(); final Dimension dim = Utils.getDimensions(s, g.getFont()); g.setColor(Color.white); @@ -1270,7 +1269,7 @@ public void removeChooseHighlight(){ //actyc: get the righ color aka wheter non, first or seconded highlight private Color getCorrectedColor(){ // Utils.log("current high= " + high[0]+"-"+high[1]); - Color result = RhizoAddons.confidencColors.get(this.getConfidence()); + Color result = RhizoAddons.getColorFromStatusMap(this.getConfidence()); // if(high>0){ // result = RhizoAddons.confidencColorsget((byte) 11); // if(high>1){ @@ -1278,14 +1277,8 @@ private Color getCorrectedColor(){ // result = Color.red; // } // } - if(high[0]){ - result = RhizoAddons.confidencColors.get((byte) 11); - } - if(high[1]){ - Color cC = RhizoAddons.confidencColors.get((byte) 11); - result = Color.pink; - //result = new Color(cC.getRed()+10,cC.getGreen(),cC.getBlue()+10); - } + if(high[0]) return Color.ORANGE; // Tino - may be temporary + if(high[1]) return Color.PINK; return result; } } diff --git a/src/main/java/de/unihalle/informatik/rhizoTrak/display/RhizoAddons.java b/src/main/java/de/unihalle/informatik/rhizoTrak/display/RhizoAddons.java index 65aab6622..248515478 100644 --- a/src/main/java/de/unihalle/informatik/rhizoTrak/display/RhizoAddons.java +++ b/src/main/java/de/unihalle/informatik/rhizoTrak/display/RhizoAddons.java @@ -67,6 +67,7 @@ import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; +import java.math.BigInteger; import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; @@ -95,8 +96,10 @@ import javax.swing.SwingUtilities; import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.DefaultTreeModel; - -import com.google.common.io.Files; +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Marshaller; +import javax.xml.bind.Unmarshaller; import de.unihalle.informatik.MiToBo_xml.MTBXMLRootAssociationType; import de.unihalle.informatik.MiToBo_xml.MTBXMLRootImageAnnotationType; @@ -104,10 +107,15 @@ import de.unihalle.informatik.MiToBo_xml.MTBXMLRootProjectType; import de.unihalle.informatik.MiToBo_xml.MTBXMLRootReferenceType; import de.unihalle.informatik.MiToBo_xml.MTBXMLRootSegmentPointType; -import de.unihalle.informatik.MiToBo_xml.MTBXMLRootSegmentStatusType; import de.unihalle.informatik.MiToBo_xml.MTBXMLRootSegmentType; import de.unihalle.informatik.MiToBo_xml.MTBXMLRootType; import de.unihalle.informatik.rhizoTrak.Project; +import de.unihalle.informatik.rhizoTrak.config.Config; +import de.unihalle.informatik.rhizoTrak.config.Config.StatusList; +import de.unihalle.informatik.rhizoTrak.config.Config.StatusList.Status; +import de.unihalle.informatik.rhizoTrak.config.GlobalSettings; +import de.unihalle.informatik.rhizoTrak.config.GlobalSettings.GlobalStatusList.GlobalStatus; +import de.unihalle.informatik.rhizoTrak.config.GlobalSettings.GlobalStatusList; import de.unihalle.informatik.rhizoTrak.conflictManagement.ConflictManager; import de.unihalle.informatik.rhizoTrak.display.Treeline.RadiusNode; import de.unihalle.informatik.rhizoTrak.display.addonGui.ImageImport; @@ -128,48 +136,62 @@ public class RhizoAddons public static File imageDir = null; static boolean test = true; - public static boolean[] treeLineClickable = { true, true, true, true, true, true, true, true, true, true, true }; - static int[] treelineSlider ={255,255,255,255,255,255,255,255,255,255,255}; + static String relativPatchDir="/_images"; - static boolean ini = false; - - private static File statusFile; - public static boolean statusFileExists = false; + + public static File userSettingsFile = new File(System.getProperty("user.home") + File.separator + ".rhizoTrakSettings" + File.separator + "settings.xml"); - public static File userSettingFile = new File(System.getProperty("user.home") + File.separator + ".rhizoTrakSettings" + File.separator + "settings"); + public static List globalStatusList = new ArrayList(); + public static List statusList = new ArrayList(); - public static List statusList = new ArrayList(); - public static List statusListAbbr = new ArrayList(); + // used for drawing, GUI and save/load operations + public static HashMap statusMap = new HashMap(); public static Node lastEditedOrActiveNode = null; private static JFrame colorFrame, imageLoaderFrame; - public static Hashtable confidencColors = new Hashtable(); static AddonGui guiAddons; - - /* initialization and termination stuff */ - + /** - * Initializes GUI - * @author Axel + * Initializes GUI and + * @author Axel, Tino */ public static void init() { - if (ini == false) - { - for (int i = 0; i < 11; i++) - { - confidencColors.put((byte) i, Color.YELLOW); - } - // confi Color 11 is used to mark treelines of current interest - confidencColors.put((byte) 11, Color.CYAN); - ini = true; - } - guiAddons = new AddonGui(); + + // Standard status - always included + Status undefined = new Status(); + undefined.setFullName("UNDEFINED"); + undefined.setAbbreviation("U"); + undefined.setRed(BigInteger.valueOf(255)); + undefined.setBlue(BigInteger.valueOf(255)); + undefined.setGreen(BigInteger.valueOf(0)); + undefined.setAlpha(BigInteger.valueOf(255)); + + statusMap.put(-1, undefined); + + Status virtual = new Status(); + virtual.setFullName("VIRTUAL"); + virtual.setAbbreviation("V"); + virtual.setRed(BigInteger.valueOf(255)); + virtual.setBlue(BigInteger.valueOf(255)); + virtual.setGreen(BigInteger.valueOf(0)); + virtual.setAlpha(BigInteger.valueOf(255)); + statusMap.put(-2, virtual); + + Status connector = new Status(); + connector.setFullName("CONNECTOR"); + connector.setAbbreviation("C"); + connector.setRed(BigInteger.valueOf(255)); + connector.setBlue(BigInteger.valueOf(255)); + connector.setGreen(BigInteger.valueOf(0)); + connector.setAlpha(BigInteger.valueOf(255)); + statusMap.put(-3, connector); } + /** * Calls load methods when opening a project * @param file - saved project file @@ -201,11 +223,13 @@ public void run() Utils.log2("done"); Utils.log2("restoring status conventions..."); - loadStatusFile(file.getAbsolutePath().replace(".xml", ".status")); + loadConfigFile(file.getAbsolutePath()); Utils.log2("done"); - //lock all images - lockAllImagesInAllProjects(); + //lock all images + lockAllImagesInAllProjects(); + + // return; } @@ -220,121 +244,111 @@ public void run() /** * Loads the user settings (color, visibility etc.) - * @author Axel + * @author Axel, Tino */ public static void loadUserSettings() { - - if (!userSettingFile.exists()) + if (!userSettingsFile.exists()) { + setDefaultGlobalStatus(); Utils.log("unable to load user settings: file not found"); return; } - String savetxt = readFileToString(userSettingFile); - ArrayList content = stringToLineArray(savetxt); - - Utils.log(savetxt); - - if (content.size() != 12) + try { - Utils.log("unable to load user settings: incorrect content size"); - return; + JAXBContext context = JAXBContext.newInstance(GlobalSettings.class); + Unmarshaller um = context.createUnmarshaller(); + GlobalSettings gs = (GlobalSettings) um.unmarshal(userSettingsFile); + globalStatusList.addAll(gs.getGlobalStatusList().getGlobalStatus()); + Utils.log(globalStatusList.size()); + + updateStatusMap(); + } + catch (JAXBException e) + { + e.printStackTrace(); } - - for (int i = 0; i < 11; i++) + } + + public static void updateStatusMap() + { + // local status list + for(int i = 0; i < statusList.size(); i++) { - String[] currentLine = content.get(i).split(";"); - if (currentLine.length != 5) - { - Utils.log("unable to load user settings: incorrect line length (1)"); - return; - } + Status s = statusList.get(i); - Color currentColor = stringToColor(currentLine[0] + ";" + currentLine[1] + ";" + currentLine[2] + ";" + currentLine[3]); - - boolean currentBool = false; - if (currentLine[4].equals("true")) + for(GlobalStatus gs: globalStatusList) { - currentBool = true; + if(s.getFullName().equals(gs.getFullName())) + { + Status sTemp = statusMap.get(i); + sTemp.setRed(gs.getRed()); + sTemp.setGreen(gs.getGreen()); + sTemp.setBlue(gs.getBlue()); + sTemp.setAlpha(gs.getAlpha()); + sTemp.setSelectable(gs.isSelectable()); + statusMap.put(i, sTemp); + } } - - confidencColors.put((byte) i, currentColor); - treeLineClickable[i] = currentBool; - } - - String[] currentLine = content.get(11).split(";"); - - if (currentLine.length != 4) - { - Utils.log("Unable to load user settings: incorrect line length (2)"); - return; } - Color currentColor = stringToColor(currentLine[0] + ";" + currentLine[1] + ";" + currentLine[2] + ";" + currentLine[3]); - confidencColors.put((byte) 11, currentColor); - ini = true; } - + + /** - * Reads the status file with the status conventions when a project is opened or a new one is created. * - * @param path - The project status file path + * + * @param path - The project file * @author Tino */ - public static void loadStatusFile(String path) + public static void loadConfigFile(String path) { - if(null != path) statusFile = new File(path); - else return; // the user cancels the open file dialog + // TODO: add popup warnings + // New project.. + if(null == path) // user cancelled the open file dialog + { + setDefaultStatus(); + return; + } + // TODO: check file ending if coming from file chooser + // Open project.. + File configFile = new File(path.replace(".xml", ".cfg")); // looking for cfg file in directory - // TODO: add popup dialogs - if(!statusFile.exists()) return; // can't find status file within the same directory as the xml file - if(!path.endsWith(".status")) return; // selected file does not end with .status + if(!configFile.exists()) + { + setDefaultStatus(); + return; + } - try + try { - FileReader fr = new FileReader(statusFile); - BufferedReader br = new BufferedReader(fr); - - String line = ""; - while((line = br.readLine()) != null) - { - if(!line.startsWith("#") && line.split("\t").length == 2) - { - String[] temp = line.split("\t"); - statusListAbbr.add(temp[0]); - statusList.add(temp[1]); - } - } - - br.close(); + JAXBContext context = JAXBContext.newInstance(Config.class); + Unmarshaller um = context.createUnmarshaller(); + Config config = (Config) um.unmarshal(configFile); + statusList.addAll(config.getStatusList().getStatus()); + + for(int i = 0; i < statusList.size(); i++) + { + statusMap.put(i, statusList.get(i)); + } + + updateStatusMap(); } - catch (Exception e) + catch (JAXBException e) { e.printStackTrace(); } - - statusFileExists = true; + Node.MAX_EDGE_CONFIDENCE = getStatusListSize(); } - /** - * Returns the size of the status list or a default value - * @return Size of the list or default 10 - */ - public static byte getStatusListSize() - { - - if(statusFileExists) return (byte) (statusList.size() - 1); - else return (byte) 10; - } - /** * Loads the connector file * @param file - The project save file * @author Axel - */ + */ public static void loadConnector(File file) { // read the save file @@ -489,30 +503,39 @@ public static void addonSaver(File file) //save connector data saveConnectorData(file); - // if for some reason the selected status file is not in the project folder or the saved project file has - // a different name than the status file create a new one - if(statusFileExists && - (!statusFile.getParent().equals(file.getParent()) || - !statusFile.getName().replace(".status", "").equals(file.getName().replace(".xml", "")))) - saveStatusFile(file); + saveConfigFile(file); return; } /** - * Creates a new status file in the project directory when the original status file has been selected from another - * directory. The content will be identical but the name will be changed to the name of the project file. + * Crates a new config file (.cfg) or overwrites an existing one in the same directory and with the same name as the project file. * * @param file - The project xml file * @author Tino */ - public static void saveStatusFile(File file) + public static void saveConfigFile(File file) { + // TODO: add warnings + if(null == file) return; + + File configFile = new File(file.getAbsolutePath().replace(".xml", ".cfg")); + try { - Files.copy(statusFile, new File(file.getAbsolutePath().replace(".xml", ".status"))); + JAXBContext context = JAXBContext.newInstance(Config.class); + Marshaller m = context.createMarshaller(); + m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); + + StatusList sl = new StatusList(); + sl.getStatus().addAll(statusList); + + Config config = new Config(); + config.setStatusList(sl); + + m.marshal(config, configFile); } - catch (IOException e) + catch (Exception e) { e.printStackTrace(); } @@ -520,33 +543,76 @@ public static void saveStatusFile(File file) /** * Saves the user settings - * @author Axel + * @author Axel, Tino */ public static void saveUserSettings() { - StringBuilder sb = new StringBuilder(); + // string list for easy comparisons + List temp = new ArrayList(); - for (int i = 0; i < 11; i++) + // global status list + for(GlobalStatus s: globalStatusList) { - // color - sb.append(colorToString(confidencColors.get((byte) i))); - sb.append(";" + treeLineClickable[i]); - sb.append("\n"); + temp.add(s.getFullName()); } - sb.append(colorToString(confidencColors.get((byte) 11))); - - File userSettingfolder = new File(System.getProperty("user.home") + File.separator + ".rhizoTrakSettings"); - userSettingfolder.mkdirs(); - if (!userSettingfolder.exists()) + // local status list + for(int i = 0; i < statusList.size(); i++) { - Utils.log("unable to save user settings"); - return; + Status s = statusList.get(i); + + if(!temp.contains(s.getFullName())) // add new global status + { + GlobalStatus gStatus = new GlobalStatus(); + gStatus.setAbbreviation(s.getAbbreviation()); + gStatus.setFullName(s.getFullName()); + gStatus.setRed(s.getRed()); + gStatus.setGreen(s.getGreen()); + gStatus.setBlue(s.getBlue()); + gStatus.setAlpha(s.getAlpha()); + gStatus.setSelectable(s.isSelectable()); + + globalStatusList.add(gStatus); + } + else // update existing global status + { + for(GlobalStatus g: globalStatusList) + { + if(g.getFullName().equals(s.getFullName())) + { + g.setAbbreviation(s.getAbbreviation()); + g.setRed(s.getRed()); + g.setGreen(s.getGreen()); + g.setBlue(s.getBlue()); + g.setAlpha(s.getAlpha()); + g.setSelectable(s.isSelectable()); + } + } + } } + + try + { + if(!userSettingsFile.getParentFile().exists()) userSettingsFile.getParentFile().mkdirs(); - File userSettingFile = new File(System.getProperty("user.home") + File.separator + ".rhizoTrakSettings" + File.separator + "settings"); + JAXBContext context = JAXBContext.newInstance(GlobalSettings.class); + Marshaller m = context.createMarshaller(); + m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); - writeStringToFile(userSettingFile, sb.toString()); + + GlobalStatusList gsl = new GlobalStatusList(); + gsl.getGlobalStatus().addAll(globalStatusList); + + GlobalSettings gs = new GlobalSettings(); + gs.setGlobalStatusList(gsl); + + m.marshal(gs, userSettingsFile); + } + catch(Exception e) + { + e.printStackTrace(); + } + } /** @@ -598,9 +664,140 @@ public static void saveConnectorData(File file) tempconFile.renameTo(conFile); } } + + + // only gets called when no global settings exist yet + public static void setDefaultGlobalStatus() + { + GlobalStatus undefined = new GlobalStatus(); + undefined.setFullName("UNDEFINED"); + undefined.setAbbreviation("U"); + undefined.setRed(BigInteger.valueOf(0)); + undefined.setGreen(BigInteger.valueOf(255)); + undefined.setBlue(BigInteger.valueOf(255)); + undefined.setAlpha(BigInteger.valueOf(255)); + undefined.setSelectable(true); + globalStatusList.add(undefined); + + GlobalStatus connector = new GlobalStatus(); + connector.setFullName("CONNECTOR"); + connector.setAbbreviation("C"); + connector.setRed(BigInteger.valueOf(0)); + connector.setGreen(BigInteger.valueOf(255)); + connector.setBlue(BigInteger.valueOf(255)); + connector.setAlpha(BigInteger.valueOf(255)); + connector.setSelectable(true); + globalStatusList.add(connector); + + GlobalStatus virtual = new GlobalStatus(); + virtual.setFullName("VIRTUAL"); + virtual.setAbbreviation("V"); + virtual.setRed(BigInteger.valueOf(0)); + virtual.setGreen(BigInteger.valueOf(255)); + virtual.setBlue(BigInteger.valueOf(255)); + virtual.setAlpha(BigInteger.valueOf(255)); + virtual.setSelectable(true); + globalStatusList.add(virtual); + + GlobalStatus living = new GlobalStatus(); + living.setFullName("LIVING"); + living.setAbbreviation("L"); + living.setRed(BigInteger.valueOf(0)); + living.setGreen(BigInteger.valueOf(255)); + living.setBlue(BigInteger.valueOf(255)); + living.setAlpha(BigInteger.valueOf(255)); + living.setSelectable(true); + globalStatusList.add(living); + + GlobalStatus dead = new GlobalStatus(); + dead.setFullName("DEAD"); + dead.setAbbreviation("D"); + dead.setRed(BigInteger.valueOf(0)); + dead.setGreen(BigInteger.valueOf(255)); + dead.setBlue(BigInteger.valueOf(255)); + dead.setAlpha(BigInteger.valueOf(255)); + dead.setSelectable(true); + globalStatusList.add(dead); + + GlobalStatus decayed = new GlobalStatus(); + decayed.setFullName("DECAYED"); + decayed.setAbbreviation("Y"); + decayed.setRed(BigInteger.valueOf(0)); + decayed.setGreen(BigInteger.valueOf(255)); + decayed.setBlue(BigInteger.valueOf(255)); + decayed.setAlpha(BigInteger.valueOf(255)); + decayed.setSelectable(true); + globalStatusList.add(decayed); + + GlobalStatus gap = new GlobalStatus(); + gap.setFullName("GAP"); + gap.setAbbreviation("G"); + gap.setRed(BigInteger.valueOf(0)); + gap.setGreen(BigInteger.valueOf(255)); + gap.setBlue(BigInteger.valueOf(255)); + gap.setAlpha(BigInteger.valueOf(255)); + gap.setSelectable(true); + globalStatusList.add(gap); + } + + public static void setDefaultStatus() + { + Status living = new Status(); + living.setFullName("LIVING"); + living.setAbbreviation("L"); + living.setRed(BigInteger.valueOf(0)); + living.setGreen(BigInteger.valueOf(255)); + living.setBlue(BigInteger.valueOf(255)); + living.setAlpha(BigInteger.valueOf(255)); + living.setSelectable(true); + statusList.add(living); + + Status dead = new Status(); + dead.setFullName("DEAD"); + dead.setAbbreviation("D"); + dead.setRed(BigInteger.valueOf(0)); + dead.setGreen(BigInteger.valueOf(255)); + dead.setBlue(BigInteger.valueOf(255)); + dead.setAlpha(BigInteger.valueOf(255)); + dead.setSelectable(true); + statusList.add(dead); + + Status decayed = new Status(); + decayed.setFullName("DECAYED"); + decayed.setAbbreviation("Y"); + decayed.setRed(BigInteger.valueOf(0)); + decayed.setGreen(BigInteger.valueOf(255)); + decayed.setBlue(BigInteger.valueOf(255)); + decayed.setAlpha(BigInteger.valueOf(255)); + decayed.setSelectable(true); + statusList.add(decayed); + + Status gap = new Status(); + gap.setFullName("GAP"); + gap.setAbbreviation("G"); + gap.setRed(BigInteger.valueOf(0)); + gap.setGreen(BigInteger.valueOf(255)); + gap.setBlue(BigInteger.valueOf(255)); + gap.setAlpha(BigInteger.valueOf(255)); + gap.setSelectable(true); + statusList.add(gap); + + for(int i = 0; i < statusList.size(); i++) + { + statusMap.put(i, statusList.get(i)); + } + } /* helpers below */ + public static Color getColorFromStatusMap(int i) + { + Status s = statusMap.get(i); + if(null == s) return Color.BLACK; + return new Color(s.getRed().intValue(), s.getGreen().intValue(), s.getBlue().intValue(), s.getAlpha().intValue()); + } + + /** * * @param file - File to be read @@ -701,7 +898,11 @@ public static ArrayList stringToLineArray(String string) public static void colorChooser(int i, JList list) { Color newColor = JColorChooser.showDialog(list, "Choose color", Color.WHITE); - confidencColors.put((byte) i, newColor); + Status s = statusMap.get(i); + s.setRed(BigInteger.valueOf(newColor.getRed())); + s.setGreen(BigInteger.valueOf(newColor.getGreen())); + s.setBlue(BigInteger.valueOf(newColor.getBlue())); + s.setAlpha(BigInteger.valueOf(newColor.getAlpha())); Display display = Display.getFront(); Layer currentLayer = display.getLayer(); @@ -745,9 +946,9 @@ public static void applyCorrespondingColor() { for (Node cnode : ctree.getRoot().getSubtreeNodes()) { byte currentConfi = cnode.getConfidence(); - Color newColor = confidencColors.get(currentConfi); + Color newColor = getColorFromStatusMap(currentConfi); - if (cnode.getColor() != newColor) + if (!cnode.getColor().equals(newColor)) { cnode.setColor(newColor); repaint = true; @@ -760,20 +961,20 @@ public static void applyCorrespondingColor() { } } - /** * * @param toBeHigh - Treeline to be highlighted * @author Axel */ - public static void highlight(Displayable toBeHigh,boolean choose) + public static void highlight(Displayable toBeHigh, boolean choose) { - if(toBeHigh instanceof Treeline){ + if(toBeHigh instanceof Treeline) + { Treeline tree = (Treeline) toBeHigh; - if(tree.getRoot()==null) - { - return; - } + if(tree.getRoot()==null) + { + return; + } for (Node cnode : tree.getRoot().getSubtreeNodes()) { if(choose){ @@ -792,7 +993,7 @@ public static void highlight(Displayable toBeHigh,boolean choose) * @param toBeHigh - Treeline to be highlighted * @author Axel */ - public static void highlight(List toBeHigh,boolean choose) + public static void highlight(List toBeHigh, boolean choose) { for (Displayable disp : toBeHigh) { @@ -899,7 +1100,8 @@ public static void copyTreeLine() copy.setLayer(nextLayer, true); for (Node cnode : copy.getRoot().getSubtreeNodes()) { cnode.setLayer(nextLayer); - cnode.setColor(confidencColors.get(cnode.getConfidence())); + Color col = getColorFromStatusMap(cnode.getConfidence()); + cnode.setColor(col); } copy.setTitle("treeline"); copy.clearState(); @@ -1695,26 +1897,27 @@ public void run() for (Displayable displayable : al) { if (displayable.getClass() == Treeline.class && displayable.getClass() != Connector.class) - { - Treeline currentTreeline = (Treeline) displayable; - double transX = x_p - currentTreeline.getAffineTransform().getTranslateX(); - double transY = y_p - currentTreeline.getAffineTransform().getTranslateY(); - Node nearestNode = currentTreeline.findNearestNode((float) transX, (float) transY, layer); - if(nearestNode==null){ - alternatedList.add(displayable); - continue; - } - if (RhizoAddons.treeLineClickable[(int) nearestNode.getConfidence()] == false) - { - alternatedList.add(displayable); - } - } - if(displayable.getClass()== Patch.class) - { - if(displayable.isLocked2()==true){ - alternatedList.add(displayable); - } - } + { + Treeline currentTreeline = (Treeline) displayable; + double transX = x_p - currentTreeline.getAffineTransform().getTranslateX(); + double transY = y_p - currentTreeline.getAffineTransform().getTranslateY(); + Node nearestNode = currentTreeline.findNearestNode((float) transX, (float) transY, layer); + if(nearestNode == null) + { + alternatedList.add(displayable); + continue; + } + if(nearestNode.getConfidence() > 0 && !statusMap.get((int) nearestNode.getConfidence()).isSelectable()) + { + alternatedList.add(displayable); + } + } + if(displayable.getClass()== Patch.class) + { + if(displayable.isLocked2()==true){ + alternatedList.add(displayable); + } + } } al.removeAll(alternatedList); @@ -2104,15 +2307,15 @@ private static MTBXMLRootType treelineToXMLType(Treeline treeline, Layer current rootSegment.setEndRadius(endRadius); // TODO: this is temporary - if(statusFileExists && n.getConfidence() < statusList.size()) - { - String status = statusList.get(n.getConfidence()); - if(status.equals("DEAD")) rootSegment.setType(MTBXMLRootSegmentStatusType.DEAD); - else if(status.equals("DECAYED")) rootSegment.setType(MTBXMLRootSegmentStatusType.DECAYED); - else if(status.equals("GAP")) rootSegment.setType(MTBXMLRootSegmentStatusType.GAP); - else rootSegment.setType(MTBXMLRootSegmentStatusType.LIVING); - } - else rootSegment.setType(MTBXMLRootSegmentStatusType.LIVING); // TODO: custom status vs enums? +// if(statusFileExists && n.getConfidence() < statusList.size()) +// { +// String status = statusList.get(n.getConfidence()); +// if(status.equals("DEAD")) rootSegment.setType(MTBXMLRootSegmentStatusType.DEAD); +// else if(status.equals("DECAYED")) rootSegment.setType(MTBXMLRootSegmentStatusType.DECAYED); +// else if(status.equals("GAP")) rootSegment.setType(MTBXMLRootSegmentStatusType.GAP); +// else rootSegment.setType(MTBXMLRootSegmentStatusType.LIVING); +// } +// else rootSegment.setType(MTBXMLRootSegmentStatusType.LIVING); // TODO: custom status vs enums? rootSegmentsArray[i] = rootSegment; } @@ -2277,13 +2480,13 @@ public static void readMTBXML() // TODO: this is temporary byte s = 0; - if(statusFileExists) - { - if(currentRootSegment.getType() == MTBXMLRootSegmentStatusType.LIVING) s = (byte) statusList.indexOf("LIVING"); - else if(currentRootSegment.getType() == MTBXMLRootSegmentStatusType.DEAD) s = (byte) statusList.indexOf("DEAD"); - else if(currentRootSegment.getType() == MTBXMLRootSegmentStatusType.GAP) s = (byte) statusList.indexOf("GAP"); - else if(currentRootSegment.getType() == MTBXMLRootSegmentStatusType.DECAYED) s = (byte) statusList.indexOf("DECAYED"); - } +// if(statusFileExists) +// { +// if(currentRootSegment.getType() == MTBXMLRootSegmentStatusType.LIVING) s = (byte) statusList.indexOf("LIVING"); +// else if(currentRootSegment.getType() == MTBXMLRootSegmentStatusType.DEAD) s = (byte) statusList.indexOf("DEAD"); +// else if(currentRootSegment.getType() == MTBXMLRootSegmentStatusType.GAP) s = (byte) statusList.indexOf("GAP"); +// else if(currentRootSegment.getType() == MTBXMLRootSegmentStatusType.DECAYED) s = (byte) statusList.indexOf("DECAYED"); +// } if(s == -1) s = 0; @@ -2393,8 +2596,7 @@ private static List filterTreelinesByLayer(Layer l, List(); - statusListAbbr = new ArrayList(); + statusList = new ArrayList(); } /** @@ -2428,6 +2630,11 @@ public static String getRelativPatchDir() { public static void setRelativPatchDir(String relativPatchDir) { RhizoAddons.relativPatchDir = relativPatchDir; } + + public static byte getStatusListSize() + { + return (byte) (statusList.size() - 1); + } } @@ -2504,46 +2711,6 @@ private void parseImageName(String name) timepoint = split[5]; } -// public RadiusNode getChild() -// { -// return child; -// } -// -// public RadiusNode getParent() -// { -// return parent; -// } -// -// public float getLength() -// { -// return length; -// } -// -// public float getAvgRadius() -// { -// return avgRadius; -// } -// -// public float getSurfaceArea() -// { -// return surfaceArea; -// } -// -// public float getVolume() -// { -// return volume; -// } -// -// public int getNumberOfChildren() -// { -// return numberOfChildren; -// } -// -// public int getState() -// { -// return state; -// } - public String getStatistics(String sep) { String result = experiment + sep + tube + sep + timepoint + sep + Long.toString(treeID) + sep + Integer.toString(segmentID) + sep + Integer.toString((int) layer.getZ()) + sep + Integer.toString(state) + diff --git a/src/main/java/de/unihalle/informatik/rhizoTrak/display/addonGui/VisibilityPanel.java b/src/main/java/de/unihalle/informatik/rhizoTrak/display/addonGui/VisibilityPanel.java index 384f04621..cd7809335 100644 --- a/src/main/java/de/unihalle/informatik/rhizoTrak/display/addonGui/VisibilityPanel.java +++ b/src/main/java/de/unihalle/informatik/rhizoTrak/display/addonGui/VisibilityPanel.java @@ -54,6 +54,7 @@ import java.awt.Dimension; import java.awt.GridLayout; import java.awt.event.ActionEvent; +import java.math.BigInteger; import java.util.Hashtable; import java.util.List; @@ -73,96 +74,52 @@ import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; +import de.unihalle.informatik.rhizoTrak.config.Config.StatusList.Status; import de.unihalle.informatik.rhizoTrak.display.Display; import de.unihalle.informatik.rhizoTrak.display.RhizoAddons; import de.unihalle.informatik.rhizoTrak.utils.Utils; -public class VisibilityPanel extends JPanel { - - public VisibilityPanel() { +public class VisibilityPanel extends JPanel +{ + + + private Box.Filler filler3; + private Box.Filler filler4; + private Box.Filler filler5; + private JLabel jLabel31; + private JLabel jLabel32; + private JLabel jLabel33; + private JLabel jLabel34; + private JPanel jPanelNames; + + public VisibilityPanel() + { initComponents(); } - private void initComponents() { + // TODO: more cleaning + private void initComponents() + { - jPanelNames = new javax.swing.JPanel(); - jLabel31 = new javax.swing.JLabel(); - filler3 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 10), new java.awt.Dimension(0, 10), + jPanelNames = new JPanel(); + jLabel31 = new JLabel(); + filler3 = new Box.Filler(new java.awt.Dimension(0, 10), new java.awt.Dimension(0, 10), new java.awt.Dimension(32767, 10)); - jLabel32 = new javax.swing.JLabel(); - filler5 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 25), new java.awt.Dimension(0, 25), + jLabel32 = new JLabel(); + filler5 = new Box.Filler(new java.awt.Dimension(0, 25), new java.awt.Dimension(0, 25), new java.awt.Dimension(32767, 25)); - jLabel33 = new javax.swing.JLabel(); - filler4 = new javax.swing.Box.Filler(new java.awt.Dimension(5, 0), new java.awt.Dimension(5, 0), + jLabel33 = new JLabel(); + filler4 = new Box.Filler(new java.awt.Dimension(5, 0), new java.awt.Dimension(5, 0), new java.awt.Dimension(5, 0)); - jLabel34 = new javax.swing.JLabel(); - jPanel1 = new javax.swing.JPanel(); - jLabel1 = new javax.swing.JLabel(); - jSlider1 = new javax.swing.JSlider(); - jCheckBox1 = new javax.swing.JCheckBox(); - jButton1 = new javax.swing.JButton(); - jPanel2 = new javax.swing.JPanel(); - jLabel2 = new javax.swing.JLabel(); - jSlider2 = new javax.swing.JSlider(); - jCheckBox2 = new javax.swing.JCheckBox(); - jButton2 = new javax.swing.JButton(); - jPanel3 = new javax.swing.JPanel(); - jLabel3 = new javax.swing.JLabel(); - jSlider3 = new javax.swing.JSlider(); - jCheckBox3 = new javax.swing.JCheckBox(); - jButton3 = new javax.swing.JButton(); - jPanel4 = new javax.swing.JPanel(); - jLabel4 = new javax.swing.JLabel(); - jSlider4 = new javax.swing.JSlider(); - jCheckBox4 = new javax.swing.JCheckBox(); - jButton4 = new javax.swing.JButton(); - jPanel5 = new javax.swing.JPanel(); - jLabel5 = new javax.swing.JLabel(); - jSlider5 = new javax.swing.JSlider(); - jCheckBox5 = new javax.swing.JCheckBox(); - jButton5 = new javax.swing.JButton(); - jPanel6 = new javax.swing.JPanel(); - jLabel6 = new javax.swing.JLabel(); - jSlider6 = new javax.swing.JSlider(); - jCheckBox6 = new javax.swing.JCheckBox(); - jButton6 = new javax.swing.JButton(); - jPanel7 = new javax.swing.JPanel(); - jLabel7 = new javax.swing.JLabel(); - jSlider7 = new javax.swing.JSlider(); - jCheckBox7 = new javax.swing.JCheckBox(); - jButton7 = new javax.swing.JButton(); - jPanel8 = new javax.swing.JPanel(); - jLabel8 = new javax.swing.JLabel(); - jSlider8 = new javax.swing.JSlider(); - jCheckBox8 = new javax.swing.JCheckBox(); - jButton8 = new javax.swing.JButton(); - jPanel9 = new javax.swing.JPanel(); - jLabel9 = new javax.swing.JLabel(); - jSlider9 = new javax.swing.JSlider(); - jCheckBox9 = new javax.swing.JCheckBox(); - jButton9 = new javax.swing.JButton(); - jPanel10 = new javax.swing.JPanel(); - jLabel10 = new javax.swing.JLabel(); - jSlider10 = new javax.swing.JSlider(); - jCheckBox10 = new javax.swing.JCheckBox(); - jButton10 = new javax.swing.JButton(); - jPanel11 = new javax.swing.JPanel(); - jLabel11 = new javax.swing.JLabel(); - jSlider11 = new javax.swing.JSlider(); - jCheckBox11 = new javax.swing.JCheckBox(); - jButton11 = new javax.swing.JButton(); - jPanel12 = new javax.swing.JPanel(); - jLabel12 = new javax.swing.JLabel(); - jButton12 = new javax.swing.JButton(); - + jLabel34 = new JLabel(); setMinimumSize(new java.awt.Dimension(300, 320)); setName("filter panel"); // NOI18N setPreferredSize(new java.awt.Dimension(300, 320)); - setLayout(new javax.swing.BoxLayout(this, javax.swing.BoxLayout.Y_AXIS)); + setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); setBorder(new EmptyBorder(10, 10, 10, 10)); - jPanelNames.setLayout(new javax.swing.BoxLayout(jPanelNames, javax.swing.BoxLayout.LINE_AXIS)); + jPanelNames.setLayout(new BoxLayout(jPanelNames, BoxLayout.LINE_AXIS)); jLabel31.setText("state"); jPanelNames.add(jLabel31); @@ -180,538 +137,68 @@ private void initComponents() { jPanelNames.add(jLabel34); add(jPanelNames); + + // TODO: add 3 default status first - if(RhizoAddons.statusFileExists) + List status = RhizoAddons.statusList; + for(int i = 0; i < status.size(); i++) { - List status = RhizoAddons.statusList; - List statusAbbr = RhizoAddons.statusListAbbr; + JPanel panel = new JPanel(); + panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS)); - for(int i = 0; i < status.size(); i++) - { - JPanel panel = new JPanel(); - panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS)); - - - String temp = statusAbbr.get(i)+" | "+status.get(i); - JLabel lab = new JLabel(temp); - panel.add(lab); - - // workaround TODO: find max dimensions - panel.add(Box.createRigidArea(new Dimension(80 - Utils.getDimensions(temp, UIManager.getFont("Label.font")).width, 0))); - - JSlider slider = new JSlider(); - slider.setMinimum(0); - slider.setName(Integer.toString(11-i)); - slider.setMaximum(255); - slider.setValue(255); - slider.addChangeListener(sliderAction); - panel.add(slider); - - JCheckBox checkBox = new JCheckBox("", true); - checkBox.setActionCommand(Integer.toString(i)); - checkBox.addActionListener(clickablityAction); - panel.add(checkBox); - - JButton button = new JButton(); - button.setActionCommand(Integer.toString(i)); - button.addActionListener(colorChangeButton); - button.setMaximumSize(new java.awt.Dimension(33, 15)); - button.setMinimumSize(new java.awt.Dimension(33, 15)); - button.setPreferredSize(new java.awt.Dimension(33, 12)); - button.setContentAreaFilled(false); - button.setOpaque(true); - button.setBackground(RhizoAddons.confidencColors.get((byte) i)); - panel.add(button); - - Component[] c = { slider, button }; - componentCollection_hash.put(i, c); - - add(panel); - } - - } - else // temporary solution - { - jPanel1.setLayout(new javax.swing.BoxLayout(jPanel1, javax.swing.BoxLayout.LINE_AXIS)); - - jLabel1.setText("10"); - jPanel1.add(jLabel1); - - jSlider1.setName("1"); - jSlider1.setMinimum(0); - jSlider1.setMaximum(255); - jSlider1.setValue(255); - jSlider1.addChangeListener(sliderAction); - jPanel1.add(jSlider1); - - jCheckBox1.setSelected(checkBoxArray[10]); - jCheckBox1.setActionCommand("10"); - jCheckBox1.addActionListener(clickablityAction); - jPanel1.add(jCheckBox1); - - jButton1.setActionCommand("10"); - jButton1.addActionListener(colorChangeButton); - jButton1.setMaximumSize(new java.awt.Dimension(33, 15)); - jButton1.setMinimumSize(new java.awt.Dimension(33, 15)); - jButton1.setPreferredSize(new java.awt.Dimension(33, 12)); - jButton1.setContentAreaFilled(false); - jButton1.setOpaque(true); - jButton1.setBackground(RhizoAddons.confidencColors.get((byte) 10)); - jPanel1.add(jButton1); - - Component[] c1 = { jSlider1, jButton1 }; - componentCollection_hash.put(10, c1); - add(jPanel1); - - jPanel2.setLayout(new javax.swing.BoxLayout(jPanel2, javax.swing.BoxLayout.LINE_AXIS)); - - jLabel2.setText("9"); - jLabel2.setMaximumSize(new java.awt.Dimension(12, 14)); - jLabel2.setMinimumSize(new java.awt.Dimension(12, 14)); - jLabel2.setPreferredSize(new java.awt.Dimension(12, 14)); - jPanel2.add(jLabel2); + String temp = status.get(i).getAbbreviation()+" | "+status.get(i).getFullName(); + JLabel lab = new JLabel(temp); + panel.add(lab); - jSlider2.setName("2"); - jSlider2.setMinimum(0); - jSlider2.setMaximum(255); - jSlider2.setValue(255); - jSlider2.addChangeListener(sliderAction); - jPanel2.add(jSlider2); - - jCheckBox2.setSelected(checkBoxArray[9]); - jCheckBox2.setActionCommand("9"); - jCheckBox2.addActionListener(clickablityAction); - jPanel2.add(jCheckBox2); - - jButton2.setActionCommand("9"); - jButton2.addActionListener(colorChangeButton); - jButton2.setMaximumSize(new java.awt.Dimension(33, 15)); - jButton2.setMinimumSize(new java.awt.Dimension(33, 15)); - jButton2.setPreferredSize(new java.awt.Dimension(33, 12)); - jButton2.setContentAreaFilled(false); - jButton2.setOpaque(true); - jButton2.setBackground(RhizoAddons.confidencColors.get((byte) 9)); - jPanel2.add(jButton2); - - Component[] c2 = { jSlider2, jButton2 }; - componentCollection_hash.put(9, c2); - add(jPanel2); - - jPanel3.setLayout(new javax.swing.BoxLayout(jPanel3, javax.swing.BoxLayout.LINE_AXIS)); - - jLabel3.setText("8"); - jLabel3.setMaximumSize(new java.awt.Dimension(12, 14)); - jLabel3.setPreferredSize(new java.awt.Dimension(12, 14)); - jPanel3.add(jLabel3); - - jSlider3.setName("3"); - jSlider3.setMinimum(0); - jSlider3.setMaximum(255); - jSlider3.setValue(255); - jSlider3.addChangeListener(sliderAction); - jPanel3.add(jSlider3); - - jCheckBox3.setSelected(checkBoxArray[8]); - jCheckBox3.setActionCommand("8"); - jCheckBox3.addActionListener(clickablityAction); - jPanel3.add(jCheckBox3); - - jButton3.setActionCommand("8"); - jButton3.addActionListener(colorChangeButton); - jButton3.setMaximumSize(new java.awt.Dimension(33, 15)); - jButton3.setMinimumSize(new java.awt.Dimension(33, 15)); - jButton3.setPreferredSize(new java.awt.Dimension(33, 12)); - jButton3.setContentAreaFilled(false); - jButton3.setOpaque(true); - jButton3.setBackground(RhizoAddons.confidencColors.get((byte) 8)); - jPanel3.add(jButton3); - - Component[] c3 = { jSlider3, jButton3 }; - componentCollection_hash.put(8, c3); - add(jPanel3); - - jPanel4.setLayout(new javax.swing.BoxLayout(jPanel4, javax.swing.BoxLayout.LINE_AXIS)); - - jLabel4.setText("7"); - jLabel4.setMaximumSize(new java.awt.Dimension(12, 14)); - jLabel4.setPreferredSize(new java.awt.Dimension(12, 14)); - jPanel4.add(jLabel4); - - jSlider4.setName("4"); - jSlider4.setMinimum(0); - jSlider4.setMaximum(255); - jSlider4.setValue(255); - jSlider4.addChangeListener(sliderAction); - jPanel4.add(jSlider4); - - jCheckBox4.setSelected(checkBoxArray[7]); - jCheckBox4.setActionCommand("7"); - jCheckBox4.addActionListener(clickablityAction); - jPanel4.add(jCheckBox4); - - jButton4.setActionCommand("7"); - jButton4.addActionListener(colorChangeButton); - jButton4.setMaximumSize(new java.awt.Dimension(33, 15)); - jButton4.setMinimumSize(new java.awt.Dimension(33, 15)); - jButton4.setPreferredSize(new java.awt.Dimension(33, 12)); - jButton4.setContentAreaFilled(false); - jButton4.setOpaque(true); - jButton4.setBackground(RhizoAddons.confidencColors.get((byte) 7)); - jPanel4.add(jButton4); - - Component[] c4 = { jSlider4, jButton4 }; - componentCollection_hash.put(7, c4); - add(jPanel4); - - jPanel5.setLayout(new javax.swing.BoxLayout(jPanel5, javax.swing.BoxLayout.LINE_AXIS)); - - jLabel5.setText("6"); - jLabel5.setMaximumSize(new java.awt.Dimension(12, 14)); - jLabel5.setPreferredSize(new java.awt.Dimension(12, 14)); - jPanel5.add(jLabel5); - - jSlider5.setName("5"); - jSlider5.setMinimum(0); - jSlider5.setMaximum(255); - jSlider5.setValue(255); - jSlider5.addChangeListener(sliderAction); - jPanel5.add(jSlider5); - - jCheckBox5.setSelected(checkBoxArray[6]); - jCheckBox5.setActionCommand("6"); - jCheckBox5.addActionListener(clickablityAction); - jPanel5.add(jCheckBox5); - - jButton5.setActionCommand("6"); - jButton5.addActionListener(colorChangeButton); - jButton5.setMaximumSize(new java.awt.Dimension(33, 15)); - jButton5.setMinimumSize(new java.awt.Dimension(33, 15)); - jButton5.setPreferredSize(new java.awt.Dimension(33, 12)); - jButton5.setContentAreaFilled(false); - jButton5.setOpaque(true); - jButton5.setBackground(RhizoAddons.confidencColors.get((byte) 6)); - jPanel5.add(jButton5); - - Component[] c5 = { jSlider5, jButton5 }; - componentCollection_hash.put(6, c5); - add(jPanel5); - - jPanel6.setLayout(new javax.swing.BoxLayout(jPanel6, javax.swing.BoxLayout.LINE_AXIS)); - - jLabel6.setText("5"); - jLabel6.setMaximumSize(new java.awt.Dimension(12, 14)); - jLabel6.setPreferredSize(new java.awt.Dimension(12, 14)); - jPanel6.add(jLabel6); - - jSlider6.setName("6"); - jSlider6.setMinimum(0); - jSlider6.setMaximum(255); - jSlider6.setValue(255); - jSlider6.addChangeListener(sliderAction); - jPanel6.add(jSlider6); - - jCheckBox6.setSelected(checkBoxArray[5]); - jCheckBox6.setActionCommand("5"); - jCheckBox6.addActionListener(clickablityAction); - jPanel6.add(jCheckBox6); - - jButton6.setActionCommand("5"); - jButton6.addActionListener(colorChangeButton); - jButton6.setMaximumSize(new java.awt.Dimension(33, 15)); - jButton6.setMinimumSize(new java.awt.Dimension(33, 15)); - jButton6.setPreferredSize(new java.awt.Dimension(33, 12)); - jButton6.setContentAreaFilled(false); - jButton6.setOpaque(true); - jButton6.setBackground(RhizoAddons.confidencColors.get((byte) 5)); - jPanel6.add(jButton6); - - Component[] c6 = { jSlider6, jButton6 }; - componentCollection_hash.put(5, c6); - add(jPanel6); - - jPanel7.setLayout(new javax.swing.BoxLayout(jPanel7, javax.swing.BoxLayout.LINE_AXIS)); - - jLabel7.setText("4"); - jLabel7.setMaximumSize(new java.awt.Dimension(12, 14)); - jLabel7.setPreferredSize(new java.awt.Dimension(12, 14)); - jPanel7.add(jLabel7); - - jSlider7.setName("7"); - jSlider7.setMinimum(0); - jSlider7.setMaximum(255); - jSlider7.setValue(255); - jSlider7.addChangeListener(sliderAction); - jPanel7.add(jSlider7); - - jCheckBox7.setSelected(checkBoxArray[4]); - jCheckBox7.setActionCommand("4"); - jCheckBox7.addActionListener(clickablityAction); - jPanel7.add(jCheckBox7); - - jButton7.setActionCommand("4"); - jButton7.addActionListener(colorChangeButton); - jButton7.setMaximumSize(new java.awt.Dimension(33, 15)); - jButton7.setMinimumSize(new java.awt.Dimension(33, 15)); - jButton7.setPreferredSize(new java.awt.Dimension(33, 12)); - jButton7.setContentAreaFilled(false); - jButton7.setOpaque(true); - jButton7.setBackground(RhizoAddons.confidencColors.get((byte) 4)); - jPanel7.add(jButton7); - - Component[] c7 = { jSlider7, jButton7 }; - componentCollection_hash.put(4, c7); - add(jPanel7); - - jPanel8.setLayout(new javax.swing.BoxLayout(jPanel8, javax.swing.BoxLayout.LINE_AXIS)); - - jLabel8.setText("3"); - jLabel8.setMaximumSize(new java.awt.Dimension(12, 14)); - jLabel8.setPreferredSize(new java.awt.Dimension(12, 14)); - jPanel8.add(jLabel8); - - jSlider8.setName("8"); - jSlider8.setMinimum(0); - jSlider8.setMaximum(255); - jSlider8.setValue(255); - jSlider8.addChangeListener(sliderAction); - jPanel8.add(jSlider8); - - jCheckBox8.setSelected(checkBoxArray[3]); - jCheckBox8.setActionCommand("3"); - jCheckBox8.addActionListener(clickablityAction); - jPanel8.add(jCheckBox8); - - jButton8.setActionCommand("3"); - jButton8.addActionListener(colorChangeButton); - jButton8.setMaximumSize(new java.awt.Dimension(33, 15)); - jButton8.setMinimumSize(new java.awt.Dimension(33, 15)); - jButton8.setPreferredSize(new java.awt.Dimension(33, 12)); - jButton8.setContentAreaFilled(false); - jButton8.setOpaque(true); - jButton8.setBackground(RhizoAddons.confidencColors.get((byte) 3)); - jPanel8.add(jButton8); - - Component[] c8 = { jSlider8, jButton8 }; - componentCollection_hash.put(3, c8); - add(jPanel8); - - jPanel9.setLayout(new javax.swing.BoxLayout(jPanel9, javax.swing.BoxLayout.LINE_AXIS)); - - jLabel9.setText("2"); - jLabel9.setMaximumSize(new java.awt.Dimension(12, 14)); - jLabel9.setPreferredSize(new java.awt.Dimension(12, 14)); - jPanel9.add(jLabel9); - - jSlider9.setName("9"); - jSlider9.setMinimum(0); - jSlider9.setMaximum(255); - jSlider9.setValue(255); - jSlider9.addChangeListener(sliderAction); - jPanel9.add(jSlider9); - - jCheckBox9.setSelected(checkBoxArray[2]); - jCheckBox9.setActionCommand("2"); - jCheckBox9.addActionListener(clickablityAction); - jPanel9.add(jCheckBox9); - - jButton9.setActionCommand("2"); - jButton9.addActionListener(colorChangeButton); - jButton9.setMaximumSize(new java.awt.Dimension(33, 15)); - jButton9.setMinimumSize(new java.awt.Dimension(33, 15)); - jButton9.setPreferredSize(new java.awt.Dimension(33, 12)); - jButton9.setContentAreaFilled(false); - jButton9.setOpaque(true); - jButton9.setBackground(RhizoAddons.confidencColors.get((byte) 2)); - jPanel9.add(jButton9); - - Component[] c9 = { jSlider9, jButton9 }; - componentCollection_hash.put(2, c9); - add(jPanel9); - - jPanel10.setLayout(new javax.swing.BoxLayout(jPanel10, javax.swing.BoxLayout.LINE_AXIS)); - - jLabel10.setText("1"); - jLabel10.setMaximumSize(new java.awt.Dimension(12, 14)); - jLabel10.setPreferredSize(new java.awt.Dimension(12, 14)); - jPanel10.add(jLabel10); - - jSlider10.setName("10"); - jSlider10.setMinimum(0); - jSlider10.setMaximum(255); - jSlider10.setValue(255); - jSlider10.addChangeListener(sliderAction); - jPanel10.add(jSlider10); - - jCheckBox10.setSelected(checkBoxArray[1]); - jCheckBox10.setActionCommand("1"); - jCheckBox10.addActionListener(clickablityAction); - jPanel10.add(jCheckBox10); - - jButton10.setActionCommand("1"); - jButton10.addActionListener(colorChangeButton); - jButton10.setMaximumSize(new java.awt.Dimension(33, 15)); - jButton10.setMinimumSize(new java.awt.Dimension(33, 15)); - jButton10.setPreferredSize(new java.awt.Dimension(33, 12)); - jButton10.setContentAreaFilled(false); - jButton10.setOpaque(true); - jButton10.setBackground(RhizoAddons.confidencColors.get((byte) 1)); - jPanel10.add(jButton10); - - Component[] c10 = { jSlider10, jButton10 }; - componentCollection_hash.put(1, c10); - add(jPanel10); - - jPanel11.setLayout(new javax.swing.BoxLayout(jPanel11, javax.swing.BoxLayout.LINE_AXIS)); - - jLabel11.setText("0"); - jLabel11.setMaximumSize(new java.awt.Dimension(12, 14)); - jLabel11.setPreferredSize(new java.awt.Dimension(12, 14)); - jPanel11.add(jLabel11); - - jSlider11.setName("11"); - jSlider11.setMinimum(0); - jSlider11.setMaximum(255); - jSlider11.setValue(255); - jSlider11.addChangeListener(sliderAction); - jPanel11.add(jSlider11); - - jCheckBox11.setSelected(checkBoxArray[0]); - jCheckBox11.setActionCommand("0"); - jCheckBox11.addActionListener(clickablityAction); - jPanel11.add(jCheckBox11); - - jButton11.setActionCommand("0"); - jButton11.addActionListener(colorChangeButton); - jButton11.setMaximumSize(new java.awt.Dimension(33, 15)); - jButton11.setMinimumSize(new java.awt.Dimension(33, 15)); - jButton11.setPreferredSize(new java.awt.Dimension(33, 12)); - jButton11.setContentAreaFilled(false); - jButton11.setOpaque(true); - jButton11.setBackground(RhizoAddons.confidencColors.get((byte) 0)); - jPanel11.add(jButton11); - - Component[] c11 = { jSlider11, jButton11 }; - componentCollection_hash.put(0, c11); - add(jPanel11); + // workaround TODO: find max dimensions + panel.add(Box.createRigidArea(new Dimension(80 - Utils.getDimensions(temp, UIManager.getFont("Label.font")).width, 0))); + + JSlider slider = new JSlider(); + slider.setMinimum(0); + slider.setName(Integer.toString(i)); + slider.setMaximum(255); + slider.setValue(status.get(i).getAlpha().intValue()); + slider.addChangeListener(sliderAction); + panel.add(slider); + + JCheckBox checkBox = new JCheckBox("", true); + checkBox.setActionCommand(Integer.toString(i)); + checkBox.addActionListener(clickablityAction); + panel.add(checkBox); + + JButton button = new JButton(); + button.setActionCommand(Integer.toString(i)); + button.addActionListener(colorChangeButton); + button.setMaximumSize(new java.awt.Dimension(33, 15)); + button.setMinimumSize(new java.awt.Dimension(33, 15)); + button.setPreferredSize(new java.awt.Dimension(33, 12)); + button.setContentAreaFilled(false); + button.setOpaque(true); + button.setBackground(RhizoAddons.getColorFromStatusMap(i)); + panel.add(button); + + add(panel); } - - - - // highlight color stuff - jPanel12.setLayout(new javax.swing.BoxLayout(jPanel12, javax.swing.BoxLayout.LINE_AXIS)); - - jLabel12.setText("Highlighting color"); - jLabel12.setMaximumSize(new java.awt.Dimension(500, 100)); - jLabel12.setMinimumSize(new java.awt.Dimension(12, 14)); - jLabel12.setPreferredSize(new java.awt.Dimension(120, 14)); - jPanel12.add(jLabel12); - jButton12.setActionCommand("11"); - jButton12.addActionListener(colorChangeButton); - jButton12.setMaximumSize(new java.awt.Dimension(33, 15)); - jButton12.setMinimumSize(new java.awt.Dimension(33, 15)); - jButton12.setPreferredSize(new java.awt.Dimension(33, 12)); - jButton12.setContentAreaFilled(false); - jButton12.setOpaque(true); - jButton12.setBackground(RhizoAddons.confidencColors.get((byte) 11)); - jPanel12.add(jButton12); - - Component[] c12 = { null, jButton12 }; - componentCollection_hash.put(11, c12); - add(jPanel12); } - private javax.swing.Box.Filler filler3; - private javax.swing.Box.Filler filler4; - private javax.swing.Box.Filler filler5; - private javax.swing.JButton jButton1; - private javax.swing.JButton jButton10; - private javax.swing.JButton jButton11; - private javax.swing.JButton jButton12; - private javax.swing.JButton jButton2; - private javax.swing.JButton jButton3; - private javax.swing.JButton jButton4; - private javax.swing.JButton jButton5; - private javax.swing.JButton jButton6; - private javax.swing.JButton jButton7; - private javax.swing.JButton jButton8; - private javax.swing.JButton jButton9; - private javax.swing.JCheckBox jCheckBox1; - private javax.swing.JCheckBox jCheckBox10; - private javax.swing.JCheckBox jCheckBox11; - private javax.swing.JCheckBox jCheckBox2; - private javax.swing.JCheckBox jCheckBox3; - private javax.swing.JCheckBox jCheckBox4; - private javax.swing.JCheckBox jCheckBox5; - private javax.swing.JCheckBox jCheckBox6; - private javax.swing.JCheckBox jCheckBox7; - private javax.swing.JCheckBox jCheckBox8; - private javax.swing.JCheckBox jCheckBox9; - private javax.swing.JLabel jLabel1; - private javax.swing.JLabel jLabel10; - private javax.swing.JLabel jLabel11; - private javax.swing.JLabel jLabel12; - private javax.swing.JLabel jLabel2; - private javax.swing.JLabel jLabel3; - private javax.swing.JLabel jLabel31; - private javax.swing.JLabel jLabel32; - private javax.swing.JLabel jLabel33; - private javax.swing.JLabel jLabel34; - private javax.swing.JLabel jLabel4; - private javax.swing.JLabel jLabel5; - private javax.swing.JLabel jLabel6; - private javax.swing.JLabel jLabel7; - private javax.swing.JLabel jLabel8; - private javax.swing.JLabel jLabel9; - private javax.swing.JPanel jPanel1; - private javax.swing.JPanel jPanel10; - private javax.swing.JPanel jPanel11; - private javax.swing.JPanel jPanel12; - private javax.swing.JPanel jPanel2; - private javax.swing.JPanel jPanel3; - private javax.swing.JPanel jPanel4; - private javax.swing.JPanel jPanel5; - private javax.swing.JPanel jPanel6; - private javax.swing.JPanel jPanel7; - private javax.swing.JPanel jPanel8; - private javax.swing.JPanel jPanel9; - private javax.swing.JPanel jPanelNames; - private javax.swing.JSlider jSlider1; - private javax.swing.JSlider jSlider10; - private javax.swing.JSlider jSlider11; - private javax.swing.JSlider jSlider2; - private javax.swing.JSlider jSlider3; - private javax.swing.JSlider jSlider4; - private javax.swing.JSlider jSlider5; - private javax.swing.JSlider jSlider6; - private javax.swing.JSlider jSlider7; - private javax.swing.JSlider jSlider8; - private javax.swing.JSlider jSlider9; - // component hash - private Hashtable componentCollection_hash = new Hashtable(); - private boolean[] checkBoxArray = RhizoAddons.treeLineClickable; - // Color change button action Action colorChangeButton = new AbstractAction("colorChangeButton") { public void actionPerformed(ActionEvent e) { - int state = Integer.parseInt(e.getActionCommand()); - javax.swing.JButton source = (JButton) e.getSource(); - javax.swing.JSlider cSlider = (JSlider) componentCollection_hash.get(state)[0]; + int index = Integer.parseInt(e.getActionCommand()); + JButton source = (JButton) e.getSource(); - Color currentColor = JColorChooser.showDialog(source, "Choose color", Color.WHITE); - if (currentColor != null) { - int alpha = 255; - if (cSlider != null) { - alpha = cSlider.getValue(); - } - int red = currentColor.getRed(); - int green = currentColor.getGreen(); - int blue = currentColor.getBlue(); - Color newColor = new Color(red, green, blue, alpha); + Color selectedColor = JColorChooser.showDialog(source, "Choose color", Color.WHITE); + if (selectedColor != null) + { + Status s = RhizoAddons.statusList.get(index); + s.setRed(BigInteger.valueOf(selectedColor.getRed())); + s.setGreen(BigInteger.valueOf(selectedColor.getGreen())); + s.setBlue(BigInteger.valueOf(selectedColor.getBlue())); + RhizoAddons.statusMap.put(index, s); - RhizoAddons.confidencColors.put((byte) state, newColor); RhizoAddons.applyCorrespondingColor(); - source.setBackground(newColor); + source.setBackground(selectedColor); } } }; @@ -719,69 +206,28 @@ public void actionPerformed(ActionEvent e) { // alpha change slider action ChangeListener sliderAction = new ChangeListener() { @Override - public void stateChanged(ChangeEvent e) { - int state = 10; - javax.swing.JSlider currentSlider = (JSlider) e.getSource(); - - switch (currentSlider.getName()) { - case "1": - state = 10; - break; - case "2": - state = 9; - break; - case "3": - state = 8; - break; - case "4": - state = 7; - break; - case "5": - state = 6; - break; - case "6": - state = 5; - break; - case "7": - state = 4; - break; - case "8": - state = 3; - break; - case "9": - state = 2; - break; - case "10": - state = 1; - break; - case "11": - state = 0; - break; - } - - // javax.swing.JButton cButton = (JButton) - // componentCollection_hash.get(state)[1]; - Color currentColor = RhizoAddons.confidencColors.get((byte) state); - int alpha = currentSlider.getValue(); - int red = currentColor.getRed(); - int green = currentColor.getGreen(); - int blue = currentColor.getBlue(); - Color newColor = new Color(red, green, blue, alpha); - - RhizoAddons.confidencColors.put((byte) state, newColor); + public void stateChanged(ChangeEvent e) + { + JSlider currentSlider = (JSlider) e.getSource(); + int index = Integer.parseInt(currentSlider.getName()); // name will always be an integer + + Status s = RhizoAddons.statusList.get(index); + s.setAlpha(BigInteger.valueOf(currentSlider.getValue())); + RhizoAddons.statusMap.put(index, s); + RhizoAddons.applyCorrespondingColor(); - // cButton.setBackground(newColor); - } }; // clickablity change action Action clickablityAction = new AbstractAction("clickablityAction") { public void actionPerformed(ActionEvent e) { - int state = Integer.parseInt(e.getActionCommand()); - javax.swing.JCheckBox source = (JCheckBox) e.getSource(); + int index = Integer.parseInt(e.getActionCommand()); + JCheckBox source = (JCheckBox) e.getSource(); - RhizoAddons.treeLineClickable[state] = source.isSelected(); + Status s = RhizoAddons.statusList.get(index); + s.setSelectable(source.isSelected()); + RhizoAddons.statusMap.put(index, s); } }; } diff --git a/src/main/resources/schemas/config.xsd b/src/main/resources/schemas/config.xsd new file mode 100644 index 000000000..9ab343c23 --- /dev/null +++ b/src/main/resources/schemas/config.xsd @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/schemas/settings.xsd b/src/main/resources/schemas/settings.xsd new file mode 100644 index 000000000..aa7dcd60d --- /dev/null +++ b/src/main/resources/schemas/settings.xsd @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file