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
44 public abstract Object clone();
49 * @see org.biojava.spice.feature.SegmentIF#toString()
51 public String toString()
53 String str = "Segment: " + name + " " + start + " " + end;
54 if ((note != null) && (!note.equals("null")))
55 if (note.length() > 40)
56 str += note.substring(0, 39) + "...";
65 * @see org.biojava.spice.feature.SegmentIF#getNote()
67 public String getNote()
75 * @see org.biojava.spice.feature.SegmentIF#setNote(java.lang.String)
77 public void setNote(String note)
85 * @see org.biojava.spice.feature.SegmentIF#setStart(int)
87 public void setStart(int strt)
95 * @see org.biojava.spice.feature.SegmentIF#getStart()
105 * @see org.biojava.spice.feature.SegmentIF#setEnd(int)
107 public void setEnd(int ed)
115 * @see org.biojava.spice.feature.SegmentIF#getEnd()
125 * @see org.biojava.spice.feature.SegmentIF#setName(java.lang.String)
127 public void setName(String nam)
135 * @see org.biojava.spice.feature.SegmentIF#getName()
137 public String getName()
145 * @see org.biojava.spice.feature.SegmentIF#setColor(java.awt.Color)
147 public void setColor(Color col)
155 * @see org.biojava.spice.feature.SegmentIF#getColor()
157 public Color getColor()
165 * @see org.biojava.spice.feature.SegmentIF#setParent(org.biojava.spice.feature.Feature)
167 public void setParent(FeatureTrack f)
175 * @see org.biojava.spice.feature.SegmentIF#getParent()
177 public FeatureTrack getParent()
185 * @see org.biojava.spice.feature.SegmentIF#setTxtColor(java.lang.String)
187 public void setTxtColor(String str)
195 * @see org.biojava.spice.feature.SegmentIF#getTxtColor()
197 public String getTxtColor()
205 * @see org.biojava.spice.feature.SegmentIF#overlaps(int)
207 public boolean overlaps(int seqPosition)
209 if ((getStart() <= seqPosition) && (getEnd() >= seqPosition))
219 * @see org.biojava.spice.feature.SegmentIF#overlaps(org.biojava.spice.feature.Segment)
221 public boolean overlaps(Segment segment)
223 if (!(this.start <= this.end))
224 throw new IndexOutOfBoundsException("start > end for segment" + this);
226 if (!(segment.getStart() <= segment.getEnd()))
227 throw new IndexOutOfBoundsException("start > end for segment"
230 // start must be in region of other
231 if (this.start >= segment.getStart())
233 if (this.start <= segment.getEnd())
238 // or end must be in region of other..
239 if (this.end >= segment.getStart())
241 if (this.end <= segment.getEnd())
247 if (this.start <= segment.getStart())
249 if (this.end >= segment.getEnd())