com.facetmap.simple
Class SimpleSpectrumFacet

java.lang.Object
  extended by com.facetmap.simple.SimpleFacet
      extended by com.facetmap.simple.SimpleSpectrumFacet
All Implemented Interfaces:
Facet, SpectrumFacet

public class SimpleSpectrumFacet
extends SimpleFacet
implements SpectrumFacet

Mutable reference implementation of SpectrumFacet.


Nested Class Summary
 
Nested classes/interfaces inherited from interface com.facetmap.Facet
Facet.Util
 
Field Summary
protected  boolean constrainRootMaximum
           
protected  boolean constrainRootMinimum
           
static java.lang.String defaultTitleTemplate
           
protected  SimpleSpectrumHeading rootHeading
           
 
Fields inherited from class com.facetmap.simple.SimpleFacet
facetid, index, nameMap, title
 
Fields inherited from interface com.facetmap.SpectrumFacet
NO_MAXIMUM, NO_MINIMUM
 
Constructor Summary
SimpleSpectrumFacet(java.lang.String id, java.lang.String title)
           
SimpleSpectrumFacet(java.lang.String id, java.lang.String title, SimpleSpectrumHeading heading)
          Constructs a Spectrum that covers the range of the given SpectrumHeading.
SimpleSpectrumFacet(java.lang.String id, java.lang.String title, java.lang.String rootHeadingTitle, int min, int max)
          Constructs a Spectrum ranging from min to max.
 
Method Summary
 java.lang.String createHeadingTitle(Range range)
           
 SimpleSpectrumHeading defineHeading(java.lang.String id, java.lang.String title, int min, int max)
           
 int getDefinedHeadingCount()
           
 java.util.Vector getHeadingsWithin(Range range)
           
 int[] getResourceMinAndMaxHeadings(Facetmap map)
          Returns two ints; first is the smallest minimum of any resource currently in the facetmap, second is the largest maximum of any resource currently in the facetmap.
 SimpleSpectrumHeading getSimpleSpectrumHeading(int min, int max)
           
 SpectrumHeading getSpectrumHeading(int value)
          Get a SpectrumHeading that represents a single discrete value, not a range.
 SpectrumHeading getSpectrumHeading(int min, int max)
          Encapsulates a range of values in this Spectrum as a Heading.
 SpectrumHeading getSpectrumHeading(java.lang.String id)
           
 void setTitleTemplate(java.lang.String template)
          Sets the title template for range Headings in this Spectrum.
 
Methods inherited from class com.facetmap.simple.SimpleFacet
connectHeading, containsHeading, getHeading, getId, getRootHeading, getTitle, setTitle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.facetmap.Facet
getHeading, getId, getRootHeading, getTitle
 

Field Detail

rootHeading

protected SimpleSpectrumHeading rootHeading

defaultTitleTemplate

public static java.lang.String defaultTitleTemplate

constrainRootMinimum

protected boolean constrainRootMinimum

constrainRootMaximum

protected boolean constrainRootMaximum
Constructor Detail

SimpleSpectrumFacet

public SimpleSpectrumFacet(java.lang.String id,
                           java.lang.String title,
                           java.lang.String rootHeadingTitle,
                           int min,
                           int max)
Constructs a Spectrum ranging from min to max. The rootHeadingTitle argument may be left null, in which case the root heading's title will be automatically created from the min and max values.


SimpleSpectrumFacet

public SimpleSpectrumFacet(java.lang.String id,
                           java.lang.String title)

SimpleSpectrumFacet

public SimpleSpectrumFacet(java.lang.String id,
                           java.lang.String title,
                           SimpleSpectrumHeading heading)
Constructs a Spectrum that covers the range of the given SpectrumHeading. That heading becomes the root of the new Spectrum. This is useful for importing a desired part of a remote Spectrum, or for other internal purposes.

Method Detail

getDefinedHeadingCount

public int getDefinedHeadingCount()
Specified by:
getDefinedHeadingCount in interface SpectrumFacet

setTitleTemplate

public void setTitleTemplate(java.lang.String template)
Sets the title template for range Headings in this Spectrum. The string "%0" is replaced with the minimum of the range, and the string "%1" is replaced with the maximum of the range.


createHeadingTitle

public java.lang.String createHeadingTitle(Range range)

getSpectrumHeading

public SpectrumHeading getSpectrumHeading(java.lang.String id)
                                   throws UnknownReferenceException
Specified by:
getSpectrumHeading in interface SpectrumFacet
Throws:
UnknownReferenceException

getSpectrumHeading

public SpectrumHeading getSpectrumHeading(int min,
                                          int max)
Description copied from interface: SpectrumFacet
Encapsulates a range of values in this Spectrum as a Heading. If the specified minimum or maximum is beyond the range of the Spectrum, this method may silently accept the arguments anyway. The result will be the same as if they were within the Spectrum, since no Resource can be classified with a value outside the Spectrum.

Specified by:
getSpectrumHeading in interface SpectrumFacet

getSpectrumHeading

public SpectrumHeading getSpectrumHeading(int value)
Description copied from interface: SpectrumFacet
Get a SpectrumHeading that represents a single discrete value, not a range. This is usually the sort of SpectrumHeading mapped to a Resource.

Specified by:
getSpectrumHeading in interface SpectrumFacet

getSimpleSpectrumHeading

public SimpleSpectrumHeading getSimpleSpectrumHeading(int min,
                                                      int max)

defineHeading

public SimpleSpectrumHeading defineHeading(java.lang.String id,
                                           java.lang.String title,
                                           int min,
                                           int max)

getHeadingsWithin

public java.util.Vector getHeadingsWithin(Range range)

getResourceMinAndMaxHeadings

public int[] getResourceMinAndMaxHeadings(Facetmap map)
                                   throws InternalException
Returns two ints; first is the smallest minimum of any resource currently in the facetmap, second is the largest maximum of any resource currently in the facetmap. Of course, we only search mins and maxes in the provided spectrum.

This method will return null if there are no resources in the facetmap.

Throws:
InternalException