<?xml version="1.0" encoding="UTF-8"?>
<!--
  Jalview - A Sequence Alignment Editor and Viewer (Version 2.8)
  Copyright (C) 2012 J Procter, AM Waterhouse, LM Lui, J Engelhardt, G Barton, M Clamp, S Searle
  
  This file is part of Jalview.
  
  Jalview 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.
   
  Jalview 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 Jalview.  If not, see <http://www.gnu.org/licenses/>.
-->
<!-- 
	Java JAXB binding classes are generated by running command line tool xjc:
 	    xjc schemas/jalview.xsd -d src -p jalview.xml.binding.jalview
 	Note this also generates code for included schemas
-->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:jalview="www.jalview.org/colours" targetNamespace="www.jalview.org/colours">
	<xs:element name="JalviewUserColours" type="jalview:JalviewUserColours" />
	<xs:complexType name="JalviewUserColours">
		<xs:sequence>
			<xs:element name="Version" maxOccurs="1" minOccurs="0" type="xs:string">
				<xs:annotation>
				<xs:documentation>
				Jalview colour scheme document version.
				</xs:documentation>
				</xs:annotation>
			</xs:element>
			<xs:element name="colour" maxOccurs="unbounded" minOccurs="0">
				<xs:complexType>
				    <xs:sequence>
					    <xs:element name="attributeName" type="xs:string" minOccurs="0" maxOccurs="2">
						    	<xs:annotation>
						    		<xs:documentation>name of feature attribute to colour by, or attribute and sub-attribute</xs:documentation>
						    	</xs:annotation>
					    </xs:element> 
					</xs:sequence>
					<xs:attribute name="Name" type="xs:string">
					    	<xs:annotation>
					    		<xs:documentation>Single letter residue code for an alignment colour scheme, or feature type for a feature colour scheme</xs:documentation>
					    	</xs:annotation>
					</xs:attribute>
					<xs:attribute name="RGB" type="xs:string" use="required"/>
					<xs:attribute name="minRGB" type="xs:string" use="optional"/>
					<xs:attribute name="noValueColour" use="optional" type="jalview:NoValueColour" default="Min" />
					<xs:attribute name="threshType" use="optional" type="jalview:ThresholdType" />
					<xs:attribute name="threshold" type="xs:float" use="optional"/>
					<xs:attribute name="max" type="xs:float" use="optional"/>
					<xs:attribute name="min" type="xs:float" use="optional"/>
					<xs:attribute name="colourByLabel" type="xs:boolean" use="optional"/>
					<xs:attribute name="autoScale" type="xs:boolean" use="optional"/>
				</xs:complexType>
			</xs:element>
			<xs:element name="filter" maxOccurs="unbounded" minOccurs="0" >
			    <xs:complexType>
			    		<xs:sequence> 
	    			  		<xs:element name="matcherSet" type="jalview:FeatureMatcherSet" />
	    			  	</xs:sequence> 
					<xs:attribute name="featureType" type="xs:string" use="required"/>
			    </xs:complexType>
			</xs:element>
		</xs:sequence>
		<xs:attribute name="schemeName" type="xs:string" use="optional"/>
	</xs:complexType>

	<xs:complexType name="FeatureMatcherSet"> 
	    	<xs:annotation>
	    		<xs:documentation>A feature match condition, which may be simple or compound</xs:documentation>
	    	</xs:annotation>
	  <xs:choice> 
	    <xs:element name="matchCondition" type="jalview:FeatureMatcher" /> 
	    <xs:element name="compoundMatcher">
		    <xs:complexType>
			  <xs:sequence> 
			      <xs:element name="matcherSet" minOccurs="2" maxOccurs="2" type="jalview:FeatureMatcherSet" /> 
			  </xs:sequence> 
		      <xs:attribute name="and" type="xs:boolean" use="required">
				  <xs:annotation>
				  	<xs:documentation>If true, matchers are AND-ed, if false they are OR-ed</xs:documentation>
				  </xs:annotation>
		      </xs:attribute>
		    </xs:complexType>
	    </xs:element>
	  </xs:choice> 
	</xs:complexType> 
	
	<xs:complexType name="FeatureMatcher"> 
	  <xs:sequence> 
	    <xs:element name="attributeName" type="xs:string" minOccurs="0" maxOccurs="2">
		    	<xs:annotation>
		    		<xs:documentation>name of feature attribute to filter on, or attribute and sub-attribute</xs:documentation>
		    	</xs:annotation>
	    </xs:element> 
	    <xs:element name="condition" type="xs:string" /> 
	    <xs:element name="value" type="xs:string" /> 
	  </xs:sequence>
	  <xs:attribute name="by" type="jalview:FilterBy" />
	</xs:complexType>

	<xs:simpleType name="ThresholdType">
		<xs:annotation>
			<xs:documentation>Whether filter has a threshold, and if so is it
				above or below
			</xs:documentation>
		</xs:annotation>
		<xs:restriction base="xs:string">
			<xs:enumeration value="NONE" />
			<xs:enumeration value="ABOVE" />
			<xs:enumeration value="BELOW" />
		</xs:restriction>
	</xs:simpleType>
	
	<xs:simpleType name="FilterBy">
	    	<xs:annotation>
	    		<xs:documentation>Filter may apply to label, score or some feature attribute</xs:documentation>
	    	</xs:annotation>
		<xs:restriction base="xs:string">
	      <xs:enumeration value="byLabel" />
	      <xs:enumeration value="byScore" />
	      <xs:enumeration value="byAttribute" />
	    </xs:restriction>	
	</xs:simpleType>
	
	<xs:simpleType name="NoValueColour">
	    	<xs:annotation>
	    		<xs:documentation>Graduated feature colour if no score (or attribute) value</xs:documentation>
	    	</xs:annotation>
		<xs:restriction base="xs:string">
	      <xs:enumeration value="None" />
	      <xs:enumeration value="Min" />
	      <xs:enumeration value="Max" />
	    </xs:restriction>	
	</xs:simpleType>
</xs:schema>
