uk.ac.starlink.ndx
Class DefaultMutableNdx

java.lang.Object
  extended by uk.ac.starlink.ndx.BridgeNdx
      extended by uk.ac.starlink.ndx.DefaultMutableNdx
All Implemented Interfaces:
MutableNdx, Ndx

public class DefaultMutableNdx
extends BridgeNdx
implements MutableNdx

Provides a simple implementation of the MutableNdx interface, so provides mutator methods as well as the accessor methods of Ndx. This class can be used to wrap a (presumably immutable) existing Ndx object, or to construct a mutable Ndx from an NdxImpl object.

Author:
Mark Taylor (Starlink)

Nested Class Summary
 
Nested classes/interfaces inherited from class uk.ac.starlink.ndx.BridgeNdx
BridgeNdx.BridgeNdxHdxFacade
 
Field Summary
 
Fields inherited from class uk.ac.starlink.ndx.BridgeNdx
ndxDocumentCache
 
Constructor Summary
DefaultMutableNdx(NDArray image)
          Constructs a MutableNdx from a given NDArray which will be its Image component.
DefaultMutableNdx(Ndx ndx)
          Constructs a MutableNdx from a given Ndx.
DefaultMutableNdx(NdxImpl impl)
          Constructs a MutableNdx from a given NdxImpl.
 
Method Summary
 FrameSet getAst()
          Get the world coordinate system of the NDX as an AST FrameSet.
 int getBadBits()
          Gets the value of the badBits mask.
 Source getEtc()
          Returns the XML containing extension information for this NDX.
 NDArray getImage()
          Returns the image component of this NDX.
 String getLabel()
          Returns the label string for this Ndx.
 NDArray getQuality()
          Returns the quality component of this NDX.
 String getTitle()
          Returns the title of this Ndx.
 String getUnits()
          Returns the units string for this Ndx.
 NDArray getVariance()
          Returns the variance component of this NDX.
 boolean hasEtc()
          Find out if the NDX contains user-defined extension information.
 boolean hasLabel()
          Indicates whether there is a label component.
 boolean hasQuality()
          Indicates whether there is a quality component.
 boolean hasTitle()
          Indicates whether there is a title component.
 boolean hasUnits()
          Indicates whether there is a units component.
 boolean hasVariance()
          Indicates whether there is a variance component.
 boolean hasWCS()
          Find out if the NDX has World Coordinate System information.
 void setBadBits(int badbits)
          Sets the bad bits mask for this Ndx.
 void setEtc(Node etc)
          Sets the Etc component of this Ndx.
 void setImage(NDArray image)
          Sets the Image component of this Ndx.
 void setLabel(String label)
          Sets the label component of this Ndx.
 void setQuality(NDArray quality)
          Sets the Quality component of this Ndx.
 void setTitle(String title)
          Sets the title component of this Ndx.
 void setUnits(String units)
          Sets the units component of this Ndx.
 void setVariance(NDArray variance)
          Sets the Variance component of this Ndx.
 void setWCS(Object wcsob)
          Sets the WCS component of this Ndx.
 
Methods inherited from class uk.ac.starlink.ndx.BridgeNdx
getHdxFacade, getHdxResourceType, isPersistent, toXML
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface uk.ac.starlink.ndx.Ndx
getHdxFacade, isPersistent, toXML
 

Constructor Detail

DefaultMutableNdx

public DefaultMutableNdx(NdxImpl impl)
Constructs a MutableNdx from a given NdxImpl. The resulting object will behave just as a BridgeNdx constructed from impl until such time as one of the set methods is used on it, after which time the new value(s) will be returned by the corresponding get methods.

Parameters:
impl - the implementation object on which this Ndx will be based

DefaultMutableNdx

public DefaultMutableNdx(Ndx ndx)
Constructs a MutableNdx from a given Ndx. The resulting object will behave just as the original Ndx until such time as one of the set methods is used on it, after which time the new value(s) will be returned by the corresponding get methods.

Parameters:
ndx - the underlying Ndx on which this one will be based

DefaultMutableNdx

public DefaultMutableNdx(NDArray image)
Constructs a MutableNdx from a given NDArray which will be its Image component. The resulting object has no optional components (title, etc and so on), though these can be set using the various set methods.

Parameters:
image - the Image component of this Ndx
Throws:
NullPointerException - if image is null
Method Detail

setImage

public void setImage(NDArray image)
Description copied from interface: MutableNdx
Sets the Image component of this Ndx. It is an error to set it to the null value.

Specified by:
setImage in interface MutableNdx
Parameters:
image - the new Image component

getImage

public NDArray getImage()
Description copied from interface: Ndx
Returns the image component of this NDX.

Note that this returns the raw image NDArray object, which should not in general be used directly for reading image data, since it has not been masked by a quality component if present. To obtain a properly masked version of the image data for read access, use the Ndxs.getMaskedImage(Ndx) method.

Specified by:
getImage in interface Ndx
Overrides:
getImage in class BridgeNdx
Returns:
the NDArray representing the image component

setVariance

public void setVariance(NDArray variance)
Description copied from interface: MutableNdx
Sets the Variance component of this Ndx. If set to null the Ndx will be considered to have no Variance component.

Specified by:
setVariance in interface MutableNdx
Parameters:
variance - the new Variance component

hasVariance

public boolean hasVariance()
Description copied from interface: Ndx
Indicates whether there is a variance component.

Specified by:
hasVariance in interface Ndx
Overrides:
hasVariance in class BridgeNdx
Returns:
true if Ndx.getVariance() may be called

getVariance

public NDArray getVariance()
Description copied from interface: Ndx
Returns the variance component of this NDX.

Note that this returns the raw variance NDArray object, which should not in general be used directly for reading variance data, since it has not been masked by a quality component if present. To obtain a properly masked version of the variance data for read access, use the Ndxs.getMaskedVariance(Ndx) method.

May only be called if Ndx.hasVariance() returns true.

Specified by:
getVariance in interface Ndx
Overrides:
getVariance in class BridgeNdx
Returns:
an NDArray representing the variance component,

setQuality

public void setQuality(NDArray quality)
Description copied from interface: MutableNdx
Sets the Quality component of this Ndx. The supplied NDArray must be of an integer type. If set to null the Ndx will be considered to have no Quality component.

Specified by:
setQuality in interface MutableNdx
Parameters:
quality - the new Quality component

hasQuality

public boolean hasQuality()
Description copied from interface: Ndx
Indicates whether there is a quality component.

Specified by:
hasQuality in interface Ndx
Overrides:
hasQuality in class BridgeNdx
Returns:
true if Ndx.getQuality() may be called

getQuality

public NDArray getQuality()
Description copied from interface: Ndx
Returns the quality component of this NDX.

May only be called if Ndx.hasQuality() returns true.

Specified by:
getQuality in interface Ndx
Overrides:
getQuality in class BridgeNdx
Returns:
an NDArray of integer type representing the quality component,

setBadBits

public void setBadBits(int badbits)
Description copied from interface: MutableNdx
Sets the bad bits mask for this Ndx.

Specified by:
setBadBits in interface MutableNdx
Parameters:
badbits - the new bad bits mask

getBadBits

public int getBadBits()
Description copied from interface: Ndx
Gets the value of the badBits mask. This value is used in conjunction with the quality array to determine which pixels are bad; a pixel is bad if the logical AND of its quality value and the bad bits mask is not zero; hence a value of zero has no effect. Has no effect if there is no quality array.

Specified by:
getBadBits in interface Ndx
Overrides:
getBadBits in class BridgeNdx
Returns:
the bad bits mask

setTitle

public void setTitle(String title)
Description copied from interface: MutableNdx
Sets the title component of this Ndx.

Specified by:
setTitle in interface MutableNdx
Parameters:
title - the new title. If null, this Ndx will be considered to have no title

hasTitle

public boolean hasTitle()
Description copied from interface: Ndx
Indicates whether there is a title component.

Specified by:
hasTitle in interface Ndx
Overrides:
hasTitle in class BridgeNdx
Returns:
true if Ndx.getTitle() may be called

getTitle

public String getTitle()
Description copied from interface: Ndx
Returns the title of this Ndx. May only be called if Ndx.hasTitle() returns true.

Specified by:
getTitle in interface Ndx
Overrides:
getTitle in class BridgeNdx
Returns:
the title

setLabel

public void setLabel(String label)
Description copied from interface: MutableNdx
Sets the label component of this Ndx.

Specified by:
setLabel in interface MutableNdx
Parameters:
label - the new label. if null, this Ndx will be considered to have no label

hasLabel

public boolean hasLabel()
Description copied from interface: Ndx
Indicates whether there is a label component.

Specified by:
hasLabel in interface Ndx
Overrides:
hasLabel in class BridgeNdx
Returns:
true if Ndx.getLabel() may be called

getLabel

public String getLabel()
Description copied from interface: Ndx
Returns the label string for this Ndx. This describes the quantity held in the data array. May only be called if Ndx.hasLabel() returns true.

Specified by:
getLabel in interface Ndx
Overrides:
getLabel in class BridgeNdx
Returns:
the label string

setUnits

public void setUnits(String units)
Description copied from interface: MutableNdx
Sets the units component of this Ndx.

Specified by:
setUnits in interface MutableNdx
Parameters:
units - the new units string. if null, this Ndx will be considered to have no units component

hasUnits

public boolean hasUnits()
Description copied from interface: Ndx
Indicates whether there is a units component.

Specified by:
hasUnits in interface Ndx
Overrides:
hasUnits in class BridgeNdx
Returns:
true if Ndx.getUnits() may be called

getUnits

public String getUnits()
Description copied from interface: Ndx
Returns the units string for this Ndx. This indicates the units of the values in the data array. May only be called if Ndx.hasUnits() returns true.

Specified by:
getUnits in interface Ndx
Overrides:
getUnits in class BridgeNdx
Returns:
the units string

setWCS

public void setWCS(Object wcsob)
Description copied from interface: MutableNdx
Sets the WCS component of this Ndx. This may be provided in one of a number of forms, currently

Specified by:
setWCS in interface MutableNdx
Parameters:
wcsob - an object representing the new WCS component If null, a default WCS will be used

hasWCS

public boolean hasWCS()
Description copied from interface: Ndx
Find out if the NDX has World Coordinate System information.

If it exists, then the Ndx.getAst() method may be called to access it as an AST FrameSet.

Note: in due course, when the uk.ac.starlink.wcs package has been released a getWCS method will be provided to access it as a WCS object.

Specified by:
hasWCS in interface Ndx
Overrides:
hasWCS in class BridgeNdx
Returns:
true if Ndx.getAst() (and in due course getWCS can be called

getAst

public FrameSet getAst()
Description copied from interface: Ndx
Get the world coordinate system of the NDX as an AST FrameSet.

Note: This method is intended as a temporary measure until the uk.ac.starlink.wcs package has been released. At that time a getWCS method will be provided, and this one will be deprecated.

Specified by:
getAst in interface Ndx
Overrides:
getAst in class BridgeNdx
Returns:
the AST FrameSet representing the world coordinate system information
See Also:
Ndx.hasWCS()

setEtc

public void setEtc(Node etc)
Description copied from interface: MutableNdx
Sets the Etc component of this Ndx. If not null the supplied Node should be a Document or Element of type <etc>.

Specified by:
setEtc in interface MutableNdx
Parameters:
etc - the new user-defined extensions component as a DOM node. If null, this Ndx will be considered to have no extensions

hasEtc

public boolean hasEtc()
Description copied from interface: Ndx
Find out if the NDX contains user-defined extension information.

Specified by:
hasEtc in interface Ndx
Overrides:
hasEtc in class BridgeNdx
Returns:
true if Ndx.getEtc() may be called

getEtc

public Source getEtc()
Description copied from interface: Ndx
Returns the XML containing extension information for this NDX. The base element of the returned Source is an element of type <etc> which contains an element for each extension. May only be called if Ndx.hasEtc() returns true.

Specified by:
getEtc in interface Ndx
Overrides:
getEtc in class BridgeNdx
Returns:
an XML Source containing any user-defined extension information.
See Also:
SourceReader


Copyright © 2015 Central Laboratory of the Research Councils. All Rights Reserved.