JAL-3032 adds Java 8 functionality (2/2)
[jalview.git] / src2 / fr / orsay / lri / varna / models / naView / Loop.java
1 /*
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
6
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.
10
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.
14
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.
17  */
18 package fr.orsay.lri.varna.models.naView;
19
20 import java.util.ArrayList;
21 import java.util.Hashtable;
22
23 public class Loop {
24         private int nconnection;
25         private ArrayList<Connection> connections = new ArrayList<Connection>();
26         private Hashtable<Integer,Connection> _connections = new Hashtable<Integer,Connection>();
27         private int number;
28         private int depth;
29         private boolean mark;
30         private double x, y, radius;
31
32         public int getNconnection() {
33                 return nconnection;
34         }
35
36         public void setNconnection(int nconnection) {
37                 this.nconnection = nconnection;
38         }
39
40         public void setConnection(int i, Connection c)
41         {
42                 Integer n = new Integer(i);
43                 if (c != null)
44                 _connections.put(n, c);
45                 else
46                 {
47                         if (!_connections.containsKey(n))
48                         {
49                                 _connections.put(n, new Connection());
50                         }
51                         _connections.get(i).setNull(true);
52                 }
53         }
54
55         public Connection getConnection(int i)
56         {
57                 Integer n = new Integer(i);
58                 if (!_connections.containsKey(n))
59                 { _connections.put(n, new Connection()); }
60                 Connection c = _connections.get(n);
61                 if (c.isNull())
62                         return null;
63                 else
64                         return c;
65         }
66         
67         public void addConnection(int i, Connection c)
68         {
69                 _connections.put(_connections.size(),c);
70         }
71         
72
73         public int getNumber() {
74                 return number;
75         }
76
77         public void setNumber(int number) {
78                 this.number = number;
79         }
80
81         public int getDepth() {
82                 return depth;
83         }
84
85         public void setDepth(int depth) {
86                 this.depth = depth;
87         }
88
89         public boolean isMark() {
90                 return mark;
91         }
92
93         public void setMark(boolean mark) {
94                 this.mark = mark;
95         }
96
97         public double getX() {
98                 return x;
99         }
100
101         public void setX(double x) {
102                 this.x = x;
103         }
104
105         public double getY() {
106                 return y;
107         }
108
109         public void setY(double y) {
110                 this.y = y;
111         }
112
113         public double getRadius() {
114                 return radius;
115         }
116
117         public void setRadius(double radius) {
118                 this.radius = radius;
119         }
120         
121         public String toString()
122         {
123                 String result = "Loop:";
124                 result += " nconnection "+nconnection;
125                 result += " depth "+depth;
126                 return result;
127         }
128 }