2 * BioJava development code
4 * This code may be freely distributed and modified under the
5 * terms of the GNU Lesser General Public Licence. This should
6 * be distributed with the code. If you do not have a copy,
9 * http://www.gnu.org/copyleft/lesser.html
11 * Copyright for this code is held jointly by the individual
12 * authors. These should be listed in @author doc comments.
14 * For more information on the BioJava project and its aims,
15 * or to join the biojava-l mailing list, visit the home page
18 * http://www.biojava.org/
20 * Created on May 22, 2007
24 package org.biojava.dasobert.feature;
26 import java.awt.Color;
28 public abstract class AbstractSegment implements Segment,Cloneable {
37 public abstract Object clone();
40 * @see org.biojava.spice.feature.SegmentIF#toString()
42 public String toString() {
43 String str = "Segment: " +name + " " +start + " " + end ;
44 if ( ( note != null ) && ( ! note.equals("null")))
45 if ( note.length() >40)
46 str += note.substring(0,39)+"...";
53 * @see org.biojava.spice.feature.SegmentIF#getNote()
55 public String getNote() {
60 * @see org.biojava.spice.feature.SegmentIF#setNote(java.lang.String)
62 public void setNote(String note) {
67 * @see org.biojava.spice.feature.SegmentIF#setStart(int)
69 public void setStart(int strt) {start = strt ; }
71 * @see org.biojava.spice.feature.SegmentIF#getStart()
73 public int getStart() {return start ;}
76 * @see org.biojava.spice.feature.SegmentIF#setEnd(int)
78 public void setEnd(int ed) { end = ed;}
80 * @see org.biojava.spice.feature.SegmentIF#getEnd()
82 public int getEnd() { return end;}
85 * @see org.biojava.spice.feature.SegmentIF#setName(java.lang.String)
87 public void setName(String nam) { name = nam;}
89 * @see org.biojava.spice.feature.SegmentIF#getName()
91 public String getName() { return name ; }
94 * @see org.biojava.spice.feature.SegmentIF#setColor(java.awt.Color)
96 public void setColor(Color col) { color = col; }
98 * @see org.biojava.spice.feature.SegmentIF#getColor()
100 public Color getColor() { return color ; }
103 * @see org.biojava.spice.feature.SegmentIF#setParent(org.biojava.spice.feature.Feature)
105 public void setParent(FeatureTrack f) { parent = f;}
107 * @see org.biojava.spice.feature.SegmentIF#getParent()
109 public FeatureTrack getParent(){ return parent;}
112 * @see org.biojava.spice.feature.SegmentIF#setTxtColor(java.lang.String)
114 public void setTxtColor(String str) { txtColor = str; }
116 * @see org.biojava.spice.feature.SegmentIF#getTxtColor()
118 public String getTxtColor() { return txtColor;}
122 * @see org.biojava.spice.feature.SegmentIF#overlaps(int)
124 public boolean overlaps(int seqPosition){
125 if ( ( getStart() <= seqPosition) && ( getEnd() >= seqPosition)){
134 * @see org.biojava.spice.feature.SegmentIF#overlaps(org.biojava.spice.feature.Segment)
136 public boolean overlaps(Segment segment){
137 if (! (this.start <= this.end ))
138 throw new IndexOutOfBoundsException("start > end for segment" + this);
140 if ( ! (segment.getStart() <= segment.getEnd() ))
141 throw new IndexOutOfBoundsException("start > end for segment" + segment);
143 // start must be in region of other
144 if ( this.start >= segment.getStart()){
145 if ( this.start <= segment.getEnd()){
149 // or end must be in region of other..
150 if ( this.end >= segment.getStart() ) {
151 if ( this.end <= segment.getEnd()){
156 if ( this.start <= segment.getStart() ) {
157 if ( this.end >= segment.getEnd() ) {