edu.nrao.sss.model.project.scan
Class FocusOffset

java.lang.Object
  extended by edu.nrao.sss.model.project.scan.FocusOffset
All Implemented Interfaces:
Cloneable, Comparable<FocusOffset>

public class FocusOffset
extends Object
implements Cloneable, Comparable<FocusOffset>

An offset used by a FocusScan.

Version Info:

$Revision: 1494 $
$Date: 2008-08-14 13:51:17 -0600 (Thu, 14 Aug 2008) $
$Author: dharland $

Since:
2006-07-10
Author:
David M. Harland

Constructor Summary
FocusOffset()
          Creates a new instance.
 
Method Summary
 FocusOffset clone()
          Returns an offset that is a copy of this one.
 int compareTo(FocusOffset other)
          Compares this offset with other for order.
 boolean equals(Object o)
          Returns true if o is equal to this offset.
 ScanTimeType getDurationType()
          Returns the type of duration used by this offset.
 Distance getOffsetLength()
          Returns the length of this offset.
 TimeDuration getTimeAtOffset()
          Returns the amount of time that the containing scan should spend at this position.
 ScanTimeSpecification getTimeSpec()
          A convenience method for fetching the time spent at this offset.
 int hashCode()
          Returns a hash code value for this offset.
 void setDurationType(ScanTimeType newType)
          Sets a new duration type for this offset.
 void setOffsetLength(Distance offset)
          Sets the length of this offset.
 void setTimeAtOffset(TimeDuration duration)
          Sets the amount of time that the containing scan should spend at this position.
 void setTimeSpec(ScanTimeSpecification newSpec)
          A convenience method for setting the time spent at this offset.
 String toString()
          Returns a text representation of this focus offset.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FocusOffset

public FocusOffset()
Creates a new instance.

Method Detail

setOffsetLength

public void setOffsetLength(Distance offset)
Sets the length of this offset.

If offset is null, it will be treated as a non-null distance of zero millimeters.

Parameters:
offset - the length of this offset.

getOffsetLength

public Distance getOffsetLength()
Returns the length of this offset.

The returned value is guaranteed to be non-null. It is also the offset that is held internally by this position, so any changes made to the returned offset will be reflected in this object.

Returns:
the length of this offset.

setTimeAtOffset

public void setTimeAtOffset(TimeDuration duration)
Sets the amount of time that the containing scan should spend at this position.

If duration is null, it will be treated as a non-null duration of size zero.

Parameters:
duration - the amount of time that should be spent at this position.

getTimeAtOffset

public TimeDuration getTimeAtOffset()
Returns the amount of time that the containing scan should spend at this position.

The returned value is guaranteed to be non-null. It is also the duration that is held internally by this position, so any changes made to the returned duration will be reflected in this object.

Returns:
the amount of time that should be spent at this position.

setDurationType

public void setDurationType(ScanTimeType newType)
Sets a new duration type for this offset.

Parameters:
newType - the new duration type for this offset. If this value is null, the default duration type of ON_SOURCE_SIDEREAL will be used. This value must have its isDuration() method return true. If it does not, an IllegalArgumentException is thrown.
Throws:
IllegalArgumentException - if newType is not a duration type.

getDurationType

public ScanTimeType getDurationType()
Returns the type of duration used by this offset. This method helps clients interpret the value returned by getTimeAtOffset().

The returned type will be non-null and its isDuration() method will always return true.

Returns:
the type of duration used by this offset.

setTimeSpec

public void setTimeSpec(ScanTimeSpecification newSpec)
A convenience method for setting the time spent at this offset. This offset will not hold a reference to newSpec. Instead, this method will use its getTimeType() and getDuration() methods to set the time at offset and duration type of this object.

Parameters:
newSpec - the provider of the time at offset and duration type values for this offset. A value of null will result in a NullPointerException.
Throws:
IllegalArgumentException - if the time type held by newSpec is not a duration type.

getTimeSpec

public ScanTimeSpecification getTimeSpec()
A convenience method for fetching the time spent at this offset. The returned object is guaranteed to be non-null. It is not referenced internally by this offset, so any changes made to it by clients will not affect this object.

Returns:
the time at offset and duration type of this offset.

toString

public String toString()
Returns a text representation of this focus offset. The returned string is of the form offsetLength,timeAtOffset.

Overrides:
toString in class Object

compareTo

public int compareTo(FocusOffset other)
Compares this offset with other for order.

If this offset has a smaller offset length than the other's, a negative value is returned; if larger, a positive value is returned. If both offsets have the same length, a negative value is returned if this offset has a smaller time duration than the other. The duration type is not used for figuring out which time duration is larger or smaller. If the durations are equal in magnitude, though, a comparison of durations will be used to break the tie, but only in order to stay consistent with equals().

Specified by:
compareTo in interface Comparable<FocusOffset>

clone

public FocusOffset clone()
Returns an offset that is a copy of this one.

If anything goes wrong during the cloning procedure, a RuntimeException will be thrown.

Overrides:
clone in class Object

equals

public boolean equals(Object o)
Returns true if o is equal to this offset.

Overrides:
equals in class Object

hashCode

public int hashCode()
Returns a hash code value for this offset.

Overrides:
hashCode in class Object


Copyright © 2009. All Rights Reserved.