<commit_before>// PathVisio,
// a tool for data visualization and analysis using Biological Pathways
// Copyright 2006-2007 BiGCaT Bioinformatics
//
// Licensed under the Apache License, Version 2.0 (the "License"); 
// you may not use this file except in compliance with the License. 
// You may obtain a copy of the License at 
// 
// http://www.apache.org/licenses/LICENSE-2.0 
//  
// Unless required by applicable law or agreed to in writing, software 
// distributed under the License is distributed on an "AS IS" BASIS, 
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
// See the License for the specific language governing permissions and 
// limitations under the License.
//
package data;

import java.util.*;

import org.jdom.Document;
import org.jdom.Element;

import util.ColorConverter;

/**
 * class responsible for interaction with Gpml format.
 * Contains all gpml-specific constants,
 * and should be the only class that needs to import jdom
 *  
 * @author Martijn
 *
 */
public class GmmlFormat 
{
	static class AttributeInfo
	{
		/**
		 * xsd validated type. Note that in the current implementation
		 * we don't do anything with restrictions, only with the
		 * base type.
		 */
		public String schemaType;
		
		/**
		 * default value for the attribute
		 */
		public String def; // default
		
		/**
		 * use of the attribute: can be "required" or "optional"
		 */
		public String use;
		
		AttributeInfo (String _schemaType, String _def, String _use)
		{
			schemaType = _schemaType;
			def = _def;
			use = _use;
		}
	}

	static final Map<String, AttributeInfo> attributeInfo = initAttributeInfo();
	
	static Map<String, AttributeInfo> initAttributeInfo()
	{
		Map<String, AttributeInfo> result = new HashMap<String, AttributeInfo>();
		// IMPORTANT: this array has been generated from the xsd with 
		// an automated perl script. Don't edit this directly, use the perl script instead.
		/* START OF AUTO-GENERATED CONTENT */
		result.put("Pathway.Graphics@BoardWidth", new AttributeInfo ("xsd:float", null, "required"));
		result.put("Pathway.Graphics@BoardHeight", new AttributeInfo ("xsd:float", null, "required"));
		result.put("Pathway.Graphics@WindowWidth", new AttributeInfo ("xsd:float", null, "required"));
		result.put("Pathway.Graphics@WindowHeight", new AttributeInfo ("xsd:float", null, "required"));
		result.put("Pathway.Graphics@MapInfoLeft", new AttributeInfo ("xsd:float", "0", "optional"));
		result.put("Pathway.Graphics@MapInfoTop", new AttributeInfo ("xsd:float", "0", "optional"));
		result.put("Pathway@Name", new AttributeInfo ("NameType", null, "required"));
		result.put("Pathway@Organism", new AttributeInfo ("xsd:string", null, "optional"));
		result.put("Pathway@Data-Source", new AttributeInfo ("xsd:string", null, "optional"));
		result.put("Pathway@Version", new AttributeInfo ("xsd:string", null, "optional"));
		result.put("Pathway@Author", new AttributeInfo ("xsd:string", null, "optional"));
		result.put("Pathway@Maintained-By", new AttributeInfo ("xsd:string", null, "optional"));
		result.put("Pathway@Email", new AttributeInfo ("xsd:string", null, "optional"));
		result.put("Pathway@Availability", new AttributeInfo ("xsd:string", null, "optional"));
		result.put("Pathway@Last-Modified", new AttributeInfo ("xsd:string", null, "optional"));
		result.put("GeneProduct.Graphics@CenterX", new AttributeInfo ("xsd:float", null, "required"));
		result.put("GeneProduct.Graphics@CenterY", new AttributeInfo ("xsd:float", null, "required"));
		result.put("GeneProduct.Graphics@Width", new AttributeInfo ("Dimension", "600", "optional"));
		result.put("GeneProduct.Graphics@Height", new AttributeInfo ("Dimension", "300", "optional"));
		result.put("GeneProduct.Graphics@Color", new AttributeInfo ("ColorType", null, "optional"));
		result.put("GeneProduct@GraphId", new AttributeInfo ("xsd:ID", null, "optional"));
		result.put("GeneProduct@Name", new AttributeInfo ("NameType", null, "required"));
		result.put("GeneProduct@GeneProduct-Data-Source", new AttributeInfo ("GeneProductDataSourceType", null, "required"));
		result.put("GeneProduct@GeneID", new AttributeInfo ("NameType", null, "optional"));
		result.put("GeneProduct@BackpageHead", new AttributeInfo ("xsd:string", null, "optional"));
		result.put("GeneProduct@Xref", new AttributeInfo ("xsd:string", null, "optional"));
		result.put("GeneProduct@Type", new AttributeInfo ("xsd:string", null, "required"));
		result.put("Line.Graphics.Point@x", new AttributeInfo ("xsd:float", null, "optional"));
		result.put("Line.Graphics.Point@y", new AttributeInfo ("xsd:float", null, "optional"));
		result.put("Line.Graphics.Point@GraphRef", new AttributeInfo ("xsd:IDREF", null, "optional"));
		result.put("Line.Graphics.Point@GraphId", new AttributeInfo ("xsd:ID", null, "optional"));
		result.put("Line.Graphics@Color", new AttributeInfo ("ColorType", "Black", "optional"));
		result.put("Line@Type", new AttributeInfo ("xsd:string", null, "required"));
		result.put("Line@Style", new AttributeInfo ("xsd:string", "Solid", "optional"));
		result.put("Label.Graphics@CenterX", new AttributeInfo ("xsd:float", null, "required"));
		result.put("Label.Graphics@CenterY", new AttributeInfo ("xsd:float", null, "required"));
		result.put("Label.Graphics@Width", new AttributeInfo ("Dimension", null, "required"));
		result.put("Label.Graphics@Height", new AttributeInfo ("Dimension", null, "required"));
		result.put("Label.Graphics@Color", new AttributeInfo ("ColorType", null, "optional"));
		result.put("Label.Graphics@FontName", new AttributeInfo ("xsd:string", "Arial", "optional"));
		result.put("Label.Graphics@FontStyle", new AttributeInfo ("xsd:string", "Normal", "optional"));
		result.put("Label.Graphics@FontDecoration", new AttributeInfo ("xsd:string", "Normal", "optional"));
		result.put("Label.Graphics@FontStrikethru", new AttributeInfo ("xsd:string", "Normal", "optional"));
		result.put("Label.Graphics@FontWeight", new AttributeInfo ("xsd:string", "Normal", "optional"));
		result.put("Label.Graphics@FontSize", new AttributeInfo ("xsd:nonNegativeInteger", "12", "optional"));
		result.put("Label@GraphId", new AttributeInfo ("xsd:ID", null, "optional"));
		result.put("Label@TextLabel", new AttributeInfo ("xsd:string", null, "required"));
		result.put("Label@Xref", new AttributeInfo ("xsd:string", null, "optional"));
		result.put("Shape.Graphics@CenterX", new AttributeInfo ("xsd:float", null, "optional"));
		result.put("Shape.Graphics@CenterY", new AttributeInfo ("xsd:float", null, "optional"));
		result.put("Shape.Graphics@Width", new AttributeInfo ("Dimension", null, "optional"));
		result.put("Shape.Graphics@Height", new AttributeInfo ("Dimension", null, "optional"));
		result.put("Shape.Graphics@Color", new AttributeInfo ("ColorType", null, "optional"));
		result.put("Shape.Graphics@Rotation", new AttributeInfo ("xsd:float", null, "optional"));
		result.put("Shape.Graphics@FillColor", new AttributeInfo ("ColorType", null, "optional"));
		result.put("Shape@Type", new AttributeInfo ("xsd:string", null, "required"));
		result.put("Shape@GraphId", new AttributeInfo ("xsd:ID", null, "optional"));
		result.put("Brace.Graphics@CenterX", new AttributeInfo ("xsd:float", null, "required"));
		result.put("Brace.Graphics@CenterY", new AttributeInfo ("xsd:float", null, "required"));
		result.put("Brace.Graphics@Width", new AttributeInfo ("Dimension", null, "required"));
		result.put("Brace.Graphics@PicPointOffset", new AttributeInfo ("Dimension", null, "optional"));
		result.put("Brace.Graphics@Color", new AttributeInfo ("ColorType", "Black", "optional"));
		result.put("Brace.Graphics@Orientation", new AttributeInfo ("xsd:string", "top", "optional"));
		result.put("Brace@GraphId", new AttributeInfo ("xsd:ID", null, "optional"));
		result.put("FixedShape.Graphics@CenterX", new AttributeInfo ("xsd:float", null, "required"));
		result.put("FixedShape.Graphics@CenterY", new AttributeInfo ("xsd:float", null, "required"));
		result.put("FixedShape@Type", new AttributeInfo ("xsd:string", null, "required"));
		result.put("FixedShape@GraphId", new AttributeInfo ("xsd:ID", null, "optional"));
		result.put("ComplexShape.Graphics@CenterX", new AttributeInfo ("xsd:float", null, "required"));
		result.put("ComplexShape.Graphics@CenterY", new AttributeInfo ("xsd:float", null, "required"));
		result.put("ComplexShape.Graphics@Width", new AttributeInfo ("xsd:float", null, "required"));
		result.put("ComplexShape.Graphics@Rotation", new AttributeInfo ("xsd:float", "0", "optional"));
		result.put("ComplexShape@Type", new AttributeInfo ("xsd:string", null, "required"));
		result.put("ComplexShape@GraphId", new AttributeInfo ("xsd:ID", null, "optional"));
		result.put("InfoBox@CenterX", new AttributeInfo ("xsd:float", null, "required"));
		result.put("InfoBox@CenterY", new AttributeInfo ("xsd:float", null, "required"));
		result.put("Legend@CenterX", new AttributeInfo ("xsd:float", null, "required"));
		result.put("Legend@CenterY", new AttributeInfo ("xsd:float", null, "required"));
		/* END OF AUTO-GENERATED CONTENT */
		
		return result;
	};
	
	/**
	 * Sets a certain attribute value, 
	 * Does a basic check for some types,
	 * throws an exception when you're trying to set an invalid value<commit_msg>added some defaults in xsd<commit_after>// PathVisio,
// a tool for data visualization and analysis using Biological Pathways
// Copyright 2006-2007 BiGCaT Bioinformatics
//
// Licensed under the Apache License, Version 2.0 (the "License"); 
// you may not use this file except in compliance with the License. 
// You may obtain a copy of the License at 
// 
// http://www.apache.org/licenses/LICENSE-2.0 
//  
// Unless required by applicable law or agreed to in writing, software 
// distributed under the License is distributed on an "AS IS" BASIS, 
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
// See the License for the specific language governing permissions and 
// limitations under the License.
//
package data;

import java.util.*;

import org.jdom.Document;
import org.jdom.Element;

import util.ColorConverter;

/**
 * class responsible for interaction with Gpml format.
 * Contains all gpml-specific constants,
 * and should be the only class (apart from svgFormat)
 * that needs to import jdom
 *  
 * @author Martijn
 *
 */
public class GmmlFormat 
{
	static class AttributeInfo
	{
		/**
		 * xsd validated type. Note that in the current implementation
		 * we don't do anything with restrictions, only with the
		 * base type.
		 */
		public String schemaType;
		
		/**
		 * default value for the attribute
		 */
		public String def; // default
		
		/**
		 * use of the attribute: can be "required" or "optional"
		 */
		public String use;
		
		AttributeInfo (String _schemaType, String _def, String _use)
		{
			schemaType = _schemaType;
			def = _def;
			use = _use;
		}
	}

	static final Map<String, AttributeInfo> attributeInfo = initAttributeInfo();
	
	static Map<String, AttributeInfo> initAttributeInfo()
	{
		Map<String, AttributeInfo> result = new HashMap<String, AttributeInfo>();
		// IMPORTANT: this array has been generated from the xsd with 
		// an automated perl script. Don't edit this directly, use the perl script instead.
		/* START OF AUTO-GENERATED CONTENT */
		result.put("Pathway.Graphics@BoardWidth", new AttributeInfo ("Dimension", null, "required"));
		result.put("Pathway.Graphics@BoardHeight", new AttributeInfo ("Dimension", null, "required"));
		result.put("Pathway.Graphics@WindowWidth", new AttributeInfo ("Dimension", "18000", "optional"));
		result.put("Pathway.Graphics@WindowHeight", new AttributeInfo ("Dimension", "12000", "optional"));
		result.put("Pathway.Graphics@MapInfoLeft", new AttributeInfo ("xsd:float", "0", "optional"));
		result.put("Pathway.Graphics@MapInfoTop", new AttributeInfo ("xsd:float", "0", "optional"));
		result.put("Pathway@Name", new AttributeInfo ("NameType", null, "required"));
		result.put("Pathway@Organism", new AttributeInfo ("xsd:string", null, "optional"));
		result.put("Pathway@Data-Source", new AttributeInfo ("xsd:string", null, "optional"));
		result.put("Pathway@Version", new AttributeInfo ("xsd:string", null, "optional"));
		result.put("Pathway@Author", new AttributeInfo ("xsd:string", null, "optional"));
		result.put("Pathway@Maintained-By", new AttributeInfo ("xsd:string", null, "optional"));
		result.put("Pathway@Email", new AttributeInfo ("xsd:string", null, "optional"));
		result.put("Pathway@Availability", new AttributeInfo ("xsd:string", null, "optional"));
		result.put("Pathway@Last-Modified", new AttributeInfo ("xsd:string", null, "optional"));
		result.put("GeneProduct.Graphics@CenterX", new AttributeInfo ("xsd:float", null, "required"));
		result.put("GeneProduct.Graphics@CenterY", new AttributeInfo ("xsd:float", null, "required"));
		result.put("GeneProduct.Graphics@Width", new AttributeInfo ("Dimension", "600", "optional"));
		result.put("GeneProduct.Graphics@Height", new AttributeInfo ("Dimension", "300", "optional"));
		result.put("GeneProduct.Graphics@Color", new AttributeInfo ("ColorType", null, "optional"));
		result.put("GeneProduct@GraphId", new AttributeInfo ("xsd:ID", null, "optional"));
		result.put("GeneProduct@Name", new AttributeInfo ("NameType", null, "required"));
		result.put("GeneProduct@GeneProduct-Data-Source", new AttributeInfo ("GeneProductDataSourceType", null, "required"));
		result.put("GeneProduct@GeneID", new AttributeInfo ("NameType", null, "optional"));
		result.put("GeneProduct@BackpageHead", new AttributeInfo ("xsd:string", null, "optional"));
		result.put("GeneProduct@Xref", new AttributeInfo ("xsd:string", null, "optional"));
		result.put("GeneProduct@Type", new AttributeInfo ("xsd:string", null, "required"));
		result.put("Line.Graphics.Point@x", new AttributeInfo ("xsd:float", null, "required"));
		result.put("Line.Graphics.Point@y", new AttributeInfo ("xsd:float", null, "required"));
		result.put("Line.Graphics.Point@GraphRef", new AttributeInfo ("xsd:IDREF", null, "optional"));
		result.put("Line.Graphics.Point@GraphId", new AttributeInfo ("xsd:ID", null, "optional"));
		result.put("Line.Graphics@Color", new AttributeInfo ("ColorType", "Black", "optional"));
		result.put("Line@Type", new AttributeInfo ("xsd:string", "Line", "optional"));
		result.put("Line@Style", new AttributeInfo ("xsd:string", "Solid", "optional"));
		result.put("Label.Graphics@CenterX", new AttributeInfo ("xsd:float", null, "required"));
		result.put("Label.Graphics@CenterY", new AttributeInfo ("xsd:float", null, "required"));
		result.put("Label.Graphics@Width", new AttributeInfo ("Dimension", null, "required"));
		result.put("Label.Graphics@Height", new AttributeInfo ("Dimension", null, "required"));
		result.put("Label.Graphics@Color", new AttributeInfo ("ColorType", null, "optional"));
		result.put("Label.Graphics@FontName", new AttributeInfo ("xsd:string", "Arial", "optional"));
		result.put("Label.Graphics@FontStyle", new AttributeInfo ("xsd:string", "Normal", "optional"));
		result.put("Label.Graphics@FontDecoration", new AttributeInfo ("xsd:string", "Normal", "optional"));
		result.put("Label.Graphics@FontStrikethru", new AttributeInfo ("xsd:string", "Normal", "optional"));
		result.put("Label.Graphics@FontWeight", new AttributeInfo ("xsd:string", "Normal", "optional"));
		result.put("Label.Graphics@FontSize", new AttributeInfo ("xsd:nonNegativeInteger", "12", "optional"));
		result.put("Label@GraphId", new AttributeInfo ("xsd:ID", null, "optional"));
		result.put("Label@TextLabel", new AttributeInfo ("xsd:string", null, "required"));
		result.put("Label@Xref", new AttributeInfo ("xsd:string", null, "optional"));
		result.put("Shape.Graphics@CenterX", new AttributeInfo ("xsd:float", null, "required"));
		result.put("Shape.Graphics@CenterY", new AttributeInfo ("xsd:float", null, "required"));
		result.put("Shape.Graphics@Width", new AttributeInfo ("Dimension", null, "required"));
		result.put("Shape.Graphics@Height", new AttributeInfo ("Dimension", null, "required"));
		result.put("Shape.Graphics@Color", new AttributeInfo ("ColorType", "Black", "optional"));
		result.put("Shape.Graphics@Rotation", new AttributeInfo ("xsd:float", "0.0", "optional"));
		result.put("Shape.Graphics@FillColor", new AttributeInfo ("ColorType", "Transparent", "optional"));
		result.put("Shape@Type", new AttributeInfo ("xsd:string", null, "required"));
		result.put("Shape@GraphId", new AttributeInfo ("xsd:ID", null, "optional"));
		result.put("Brace.Graphics@CenterX", new AttributeInfo ("xsd:float", null, "required"));
		result.put("Brace.Graphics@CenterY", new AttributeInfo ("xsd:float", null, "required"));
		result.put("Brace.Graphics@Width", new AttributeInfo ("Dimension", null, "required"));
		result.put("Brace.Graphics@PicPointOffset", new AttributeInfo ("Dimension", null, "optional"));
		result.put("Brace.Graphics@Color", new AttributeInfo ("ColorType", "Black", "optional"));
		result.put("Brace.Graphics@Orientation", new AttributeInfo ("xsd:string", "top", "optional"));
		result.put("Brace@GraphId", new AttributeInfo ("xsd:ID", null, "optional"));
		result.put("FixedShape.Graphics@CenterX", new AttributeInfo ("xsd:float", null, "required"));
		result.put("FixedShape.Graphics@CenterY", new AttributeInfo ("xsd:float", null, "required"));
		result.put("FixedShape@Type", new AttributeInfo ("xsd:string", null, "required"));
		result.put("FixedShape@GraphId", new AttributeInfo ("xsd:ID", null, "optional"));
		result.put("ComplexShape.Graphics@CenterX", new AttributeInfo ("xsd:float", null, "required"));
		result.put("ComplexShape.Graphics@CenterY", new AttributeInfo ("xsd:float", null, "required"));
		result.put("ComplexShape.Graphics@Width", new AttributeInfo ("Dimension", null, "required"));
		result.put("ComplexShape.Graphics@Rotation", new AttributeInfo ("xsd:float", "0", "optional"));
		result.put("ComplexShape@Type", new AttributeInfo ("xsd:string", null, "required"));
		result.put("ComplexShape@GraphId", new AttributeInfo ("xsd:ID", null, "optional"));
		result.put("InfoBox@CenterX", new AttributeInfo ("xsd:float", null, "required"));
		result.put("InfoBox@CenterY", new AttributeInfo ("xsd:float", null, "required"));
		result.put("Legend@CenterX", new AttributeInfo ("xsd:float", null, "required"));
		result.put("Legend@CenterY", new AttributeInfo ("xsd:float", null, "required"));
		/* END OF AUTO-GENERATED CONTENT */
		
		return result;
	};
	
	/**
	 * Sets a certain attribute value, 
	 * Does a basic check for some types,
	 * throws an exception when you're trying to set an invalid value
{'fraction_non_alphanumeric': 0.17059959240587794, 'fraction_numerical': 0.0031105867210125494, 'mean_word_length': 6.275458447132267, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3195888', 'n_tokens_mistral': 5690, 'n_tokens_neox': 5225, 'n_words': 1468}