2 VARNA is a tool for the automated drawing, visualization and annotation of the secondary structure of RNA, designed as a companion software for web servers and databases.
3 Copyright (C) 2008 Kevin Darty, Alain Denise and Yann Ponty.
4 electronic mail : Yann.Ponty@lri.fr
5 paper mail : LRI, bat 490 Université Paris-Sud 91405 Orsay Cedex France
7 This file is part of VARNA version 3.1.
8 VARNA version 3.1 is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
9 as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
11 VARNA version 3.1 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
12 without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 See the GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License along with VARNA version 3.1.
16 If not, see http://www.gnu.org/licenses.
18 package fr.orsay.lri.varna.models.rna;
20 import java.awt.Color;
21 import java.io.Serializable;
22 import java.util.ArrayList;
23 import java.util.Random;
25 import javax.xml.transform.sax.TransformerHandler;
27 import org.xml.sax.SAXException;
28 import org.xml.sax.helpers.AttributesImpl;
30 import fr.orsay.lri.varna.exceptions.ExceptionModeleStyleBaseSyntaxError;
31 import fr.orsay.lri.varna.exceptions.ExceptionParameterError;
32 import fr.orsay.lri.varna.models.VARNAConfig;
33 import fr.orsay.lri.varna.utils.XMLUtils;
36 public class ModeleBPStyle implements Serializable {
41 private static final long serialVersionUID = 3006493290669550139L;
45 private boolean _isCustomColored = false;
46 private Color _color = VARNAConfig.DEFAULT_BOND_COLOR;
48 private double _thickness = -1.0;
49 private double _bent = 0.0;
51 public static String XML_ELEMENT_NAME = "BPstyle";
52 public static String XML_VAR_CUSTOM_STYLED_NAME = "custom";
53 public static String XML_VAR_COLOR_NAME = "color";
54 public static String XML_VAR_THICKNESS_NAME = "thickness";
55 public static String XML_VAR_BENT_NAME = "bent";
57 public void toXML(TransformerHandler hd) throws SAXException
59 AttributesImpl atts = new AttributesImpl();
60 atts.addAttribute("","",XML_VAR_CUSTOM_STYLED_NAME,"CDATA",""+_isCustomColored);
61 atts.addAttribute("","",XML_VAR_COLOR_NAME,"CDATA",XMLUtils.toHTMLNotation(_color));
62 atts.addAttribute("","",XML_VAR_THICKNESS_NAME,"CDATA",""+_thickness);
63 atts.addAttribute("","",XML_VAR_BENT_NAME,"CDATA",""+_bent);
64 hd.startElement("","",XML_ELEMENT_NAME,atts);
65 hd.endElement("","",XML_ELEMENT_NAME);
69 public double getBent()
75 public boolean isBent()
80 public void setBent(double b)
86 public ModeleBPStyle() {
90 public void setCustomColor(Color c) {
91 _isCustomColored = true;
95 public void useDefaultColor() {
96 _isCustomColored = false;
99 public boolean isCustomColored() {
100 return _isCustomColored;
103 public Color getCustomColor() {
108 * Returns the current custom color if such a color is defined to be used
109 * (through setCustomColor), or returns the default color.
112 * - The default color is no custom color is defined
113 * @return The color to be used to draw this base-pair
115 public Color getColor(Color def) {
116 if (isCustomColored()) {
123 public double getThickness(double def) {
130 public void setThickness(double thickness) {
131 _thickness = thickness;