corina
Class Sample

java.lang.Object
  |
  +--corina.Sample
All Implemented Interfaces:
Graphable, Previewable

public class Sample
extends Object
implements Previewable, Graphable

Class representing a reading of a dendro sample.

Currently, this stores:

Version:
$Id: Sample.java,v 1.2 2002/04/23 20:28:50 bitpoet Exp $
Author:
Ken Harris

Field Summary
 List count
          Number of samples in the sum at any given point.
 List data
          Data, as a List of Integers.
 List decr
           
 List elements
          Elements (in a List) that were put into this sum.
 List incr
           
static String[] LOADERS
          Class loaders to try, as an array of strings (fully-qualified class names).
 Map meta
          Sample metadata, as a (String, Object) Map.
static int MR
          The value of a missing ring, 2.
 Range range
          Data range.
static String[] SKIP_EXTENSIONS
          Filename extensions of files to ignore out of principle: .XLS, .DOC, .JPG, .GIF, and .TIF are a good start.
 
Constructor Summary
Sample()
          Default constructor.
Sample(String filename)
          Create a new Sample from a given file on disk.
Sample(URL url)
           
 
Method Summary
 void addSampleListener(SampleListener l)
           
 void clearModified()
          Clear the modified flag.
 int computeRadius()
           
static void copy(Sample source, Sample target)
           
 int count3SampleIntervals()
           
 int countRings()
          Count the total number of rings.
 int countSignificantIntervals()
           
 void fireSampleDataChanged()
           
 void fireSampleElementsChanged()
           
 void fireSampleFormatChanged()
           
 void fireSampleMetadataChanged()
           
 void fireSampleRedated()
           
 List getData()
          Return the data for a graph.
 Integer getInteger(String field)
           
 List getList(String field)
           
 Preview getPreview()
           
static Sample getSample(String filename)
           
 float getScale()
          Return the default scale factor for graphing.
 Year getStart()
          Return the start date for a graph.
 String getString(String field)
           
 UndoableEditSupport getUndoSupport()
           
 void guessIndexed()
           
 boolean hasWeiserjahre()
           
 boolean isAbsolute()
          Return true if the sample is absolutely dated, else false.
 boolean isEditable()
           
 boolean isIndexed()
          Return true if the sample is indexed, else false.
 boolean isModified()
          Return true if the file was modified since last save.
 boolean isOak()
           
 boolean isSummed()
          Return true if the sample is summed, else false.
 void load(String filename)
           
static void main(String[] args)
          Load a Sample from disk.
 void postEdit(UndoableEdit x)
           
 void removeSampleListener(SampleListener l)
           
 void save()
          Save this Sample to disk to the same filename it had previously.
 void save(String filename)
          Save this Sample to disk.
 void setModified()
          Set the modified flag.
 String toString()
          Return the sample's title.
 void verify()
           
 boolean wasMetadataChanged()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MR

public static final int MR
The value of a missing ring, 2. Anything less than or equal to this value is considered a MR.

data

public List data
Data, as a List of Integers.

range

public Range range
Data range.

meta

public Map meta
Sample metadata, as a (String, Object) Map. The following table lists the standard keys, their data types, and valid values:
Internal name (key) Data type Valid values
id Integer
title String
dating String A, R
unmeas_pre Integer
unmeas_post Integer
filename String
comments String
type String S, H, C
species String
sapwood Integer
pith String +, *, N
terminal String v, vv, B, W
continuous String C, R, N
quality String +, ++
format String R, I
index_type Integer
reconciled String Y,N
author String
data, count, range, wj, and elements aren't stored in meta - they're their own members.
See Also:
Corina

count

public List count
Number of samples in the sum at any given point.

incr

public List incr

decr

public List decr

elements

public List elements
Elements (in a List) that were put into this sum.

LOADERS

public static final String[] LOADERS
Class loaders to try, as an array of strings (fully-qualified class names). Elements:
  1. "Corina"
  2. "TSAPMatrix"
  3. "Hohenheim"
  4. "Heidelberg"
  5. "Tucson"
  6. "TwoColumn" (always last)

SKIP_EXTENSIONS

public static final String[] SKIP_EXTENSIONS
Filename extensions of files to ignore out of principle: .XLS, .DOC, .JPG, .GIF, and .TIF are a good start. They should be all upper case.
Constructor Detail

Sample

public Sample()
Default constructor. Defaults:
See Also:
meta

Sample

public Sample(String filename)
       throws FileNotFoundException,
              WrongFiletypeException,
              IOException
Create a new Sample from a given file on disk.
Parameters:
filename - the name of the file to load
Throws:
FileNotFoundException - if the file doesn't exist
WrongFiletypeException - if the file is not a Sample
IOException - if there is an I/O error while loading the file

Sample

public Sample(URL url)
       throws IOException
Method Detail

getString

public String getString(String field)

getInteger

public Integer getInteger(String field)

getList

public List getList(String field)

hasWeiserjahre

public boolean hasWeiserjahre()

getSample

public static Sample getSample(String filename)
                        throws IOException

copy

public static void copy(Sample source,
                        Sample target)

isIndexed

public boolean isIndexed()
Return true if the sample is indexed, else false.
Returns:
true if the sample is indexed

isSummed

public boolean isSummed()

Return true if the sample is summed, else false. Here "summed" is defined as:

Returns:
true if the sample is summed

isAbsolute

public boolean isAbsolute()
Return true if the sample is absolutely dated, else false.
Returns:
true if the sample is absolutely dated

isModified

public boolean isModified()
Return true if the file was modified since last save.
Returns:
if the sample has been modified

setModified

public void setModified()
Set the modified flag.

clearModified

public void clearModified()
Clear the modified flag.

getData

public List getData()
Return the data for a graph.
Specified by:
getData in interface Graphable
Returns:
data to graph, as a List of Integers

getStart

public Year getStart()
Return the start date for a graph.
Specified by:
getStart in interface Graphable
Returns:
start date of data to graph

getScale

public float getScale()
Return the default scale factor for graphing.
Specified by:
getScale in interface Graphable
Returns:
scale factor of 1.0, or 0.1 for indexed files

toString

public String toString()
Return the sample's title.
Overrides:
toString in class Object
Returns:
the "title" tag from meta

countRings

public int countRings()
Count the total number of rings. If this is a raw sample, returns the length. If this is a summed sample, returns the sum of the count List.
Returns:
the total number of rings in this sample

computeRadius

public int computeRadius()

count3SampleIntervals

public int count3SampleIntervals()

countSignificantIntervals

public int countSignificantIntervals()

main

public static void main(String[] args)
                 throws Exception
Load a Sample from disk.
Parameters:
filename - the file to load
Throws:
FileNotFoundException - if the file could not be found
WrongFiletypeException - if the file is not a Sample
IOException - if a low-level I/O error occurs

load

public void load(String filename)
          throws IOException

guessIndexed

public void guessIndexed()

verify

public void verify()

save

public void save(String filename)
          throws IOException
Save this Sample to disk.
Parameters:
filename - the name of the file to save to
Throws:
IOException - if an I/O error occurs

save

public void save()
          throws IOException
Save this Sample to disk to the same filename it had previously.
Throws:
IOException - if an I/O error occurs

getPreview

public Preview getPreview()
Specified by:
getPreview in interface Previewable

isOak

public boolean isOak()

isEditable

public boolean isEditable()

addSampleListener

public void addSampleListener(SampleListener l)

removeSampleListener

public void removeSampleListener(SampleListener l)

fireSampleRedated

public void fireSampleRedated()

fireSampleDataChanged

public void fireSampleDataChanged()

fireSampleMetadataChanged

public void fireSampleMetadataChanged()

fireSampleFormatChanged

public void fireSampleFormatChanged()

fireSampleElementsChanged

public void fireSampleElementsChanged()

wasMetadataChanged

public boolean wasMetadataChanged()

postEdit

public void postEdit(UndoableEdit x)

getUndoSupport

public UndoableEditSupport getUndoSupport()