|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectikayaki.Project
public class Project
Represents a measurement project file. Project is responsible for managing and storing the data that is recieved from the magnetometer measurements. Any changes made to the project will be written to file regularly (autosave).
Project is responsible for controlling the magnetometer through the SQUID API. Controlling the SQUID will be done in a private worker thread. Only one project at a time may access the SQUID. All operations are thread-safe.
Nested Class Summary | |
---|---|
private class |
Project.DummyMeasurement
A measurement that gives random data for testing purposes. |
private class |
Project.ManualDemag
Runs a manual demag command and adds a new step to this project with the demag value. |
private static class |
Project.ManualDemagAxel
|
private class |
Project.ManualMeasure
Runs a manual measure command and adds a new step to this project with the measurement data. |
private class |
Project.ManualMove
Runs a manual move command. |
private static class |
Project.ManualMovePosition
|
private class |
Project.ManualRotate
Runs a manual rotate command. |
private class |
Project.Measurement
Runs the measurements and adds the measurement data to this project. |
static class |
Project.Normalization
The type of normalization to use for the measurement values. |
static class |
Project.Orientation
The orientation of the sample in the measurements. |
static class |
Project.SampleType
The type of a measured sample. |
static class |
Project.State
The state of the project's measurements. |
static class |
Project.Type
The type of the project. |
Field Summary | |
---|---|
static String |
AREA_PROPERTY
|
private LastExecutor |
autosaveQueue
Scheduler for automatically writing the modified project to file after a short delay. |
private Runnable |
autosaveRunnable
Operation that will save the project to file. |
private boolean |
closed
Tells if this project been closed with closeProject(). |
static String |
COMMENT_PROPERTY
|
private MeasurementStep |
currentStep
Current measurement step, or null if no measurement is running. |
static String |
DATE_PROPERTY
|
private static boolean |
DEBUG
|
private double |
dip
Dip of the sample. |
private File |
file
Location of the project file in the local file system. |
static String |
LATITUDE_PROPERTY
|
private EventListenerList |
listenerList
Listeners for this project. |
static String |
LONGITUDE_PROPERTY
|
private double |
mass
Mass of the sample, or a negative value if no mass is defined. |
static String |
MEASUREMENT_TYPE_AUTO_VALUE
|
static String |
MEASUREMENT_TYPE_MANUAL_VALUE
|
static String |
MEASUREMENT_TYPE_PROPERTY
|
private boolean |
modified
true if the project has been modified, otherwise false. |
private Project.Normalization |
normalization
The type of normalization to use. |
static String |
OPERATOR_PROPERTY
|
private Project.Orientation |
orientation
Orientation of the sample. |
private static Hashtable<File,Project> |
projectCache
Caches the created and loaded Project objects to make sure that no more than one object will be created for each physical file. |
private static Hashtable<File,Object> |
projectTypeCache
Caches the types of the project files, as read by getType(Project). |
private Properties |
properties
Custom properties of this project stored in a map. |
static String |
ROCK_TYPE_PROPERTY
|
private Project.SampleType |
sampleType
Type of the sample. |
private MeasurementSequence |
sequence
Measurement sequence of this project. |
static String |
SITE_PROPERTY
|
private Squid |
squid
Pointer to the SQUID device interface, or null if this project is not its owner. |
private Project.State |
state
Current state of the measurements. |
private double |
strike
Strike of the sample. |
private double |
susceptibility
Susceptibility of the sample, or a negative value if no susceptibility is defined. |
private javax.vecmath.Matrix3d |
transform
Matrix for correcting the sample's orientation. |
private Project.Type |
type
Type of the measurement project. |
private double |
volume
Volume of the sample, or a negative value if no volume is defined. |
Constructor Summary | |
---|---|
private |
Project(File file,
Document document)
Creates a new project from the specified document. |
private |
Project(File file,
Project.Type type)
Creates a new project of the specified type. |
Method Summary | ||
---|---|---|
void |
addMeasurementListener(MeasurementListener l)
Adds a MeasurementListener to the project. |
|
void |
addProjectListener(ProjectListener l)
Adds a ProjectListener to the project. |
|
boolean |
addSequence(MeasurementSequence append)
Appends a sequence to this project's sequence. |
|
boolean |
addStep(int index,
MeasurementStep step)
Adds a step to the specified index of this project's sequence. |
|
boolean |
addStep(MeasurementStep step)
Appends a step to this project's sequence. |
|
static boolean |
closeProject(Project project)
Ensures that the project file is saved and frees the resources taken by the project. |
|
MeasurementSequence |
copySequence(int... indices)
Returns a copy of this project's sequence. |
|
MeasurementSequence |
copySequence(int start,
int end)
Returns a copy of this project's sequence. |
|
static Project |
createAFProject(File file)
Creates an AF project file. |
|
static Project |
createCalibrationProject(File file)
Creates a calibration project file. |
|
static Project |
createProject(File file,
Project.Type type)
Creates a project file of the specified type. |
|
static Project |
createThellierProject(File file)
Creates a thellier project file. |
|
static Project |
createThermalProject(File file)
Creates a thermal project file. |
|
boolean |
doAbort()
Aborts the currently running measurement. |
|
boolean |
doAutoStep()
Starts an auto step measurement. |
|
boolean |
doManualDemagY(double amplitude)
Demagnetizes the sample in Y direction with the specified amplitude. |
|
boolean |
doManualDemagZ(double amplitude)
Demagnetizes the sample in Z direction with the specified amplitude. |
|
boolean |
doManualMeasure()
Measures the X, Y and Z of the sample. |
|
private boolean |
doManualMove(Project.ManualMovePosition position)
Moves the sample handler to the specified position. |
|
boolean |
doManualMoveBackground()
Moves the sample handler to the Background position. |
|
boolean |
doManualMoveDegausserY()
Moves the sample handler to the DegausserY position. |
|
boolean |
doManualMoveDegausserZ()
Moves the sample handler to the DegausserZ position. |
|
boolean |
doManualMoveHome()
Moves the sample handler to the Home position. |
|
boolean |
doManualMoveLeftLimit()
Moves the sample handler to the LeftLimit position. |
|
boolean |
doManualMoveMeasurement()
Moves the sample handler to the Measurement position. |
|
boolean |
doManualMoveRightLimit()
Moves the sample handler to the RightLimit position. |
|
boolean |
doManualReset()
Resets the X, Y and Z of the sample. |
|
boolean |
doManualRotate(int angle)
Rotates the sample handler to the specified angle. |
|
boolean |
doManualStepDone()
Marks the on-going manual measurement step as completed. |
|
boolean |
doPause()
Pauses the currently running measurement. |
|
boolean |
doSingleStep()
Starts a single step measurement. |
|
boolean |
exportToDAT(File file)
Writes the project to a file in DAT format. |
|
boolean |
exportToSRM(File file)
Writes the project to a file in SRM format. |
|
boolean |
exportToTDT(File file)
Writes the project to a file in TDT format. |
|
protected void |
fireMeasurementEvent(MeasurementStep step,
MeasurementEvent.Type type)
Notifies all listeners that have registered for MeasurementEvents. |
|
protected void |
fireProjectEvent(ProjectEvent.Type type)
Notifies all listeners that have registered for ProjectEvents. |
|
static Project[] |
getCachedProjects()
Returns an array containing all the projects that are in the project cache. |
|
int |
getCompletedSteps()
Returns the number of completed steps in this project. |
|
MeasurementStep |
getCurrentStep()
Returns the step that is currently being measured. |
|
double |
getDip()
Returns the dip of the sample. |
|
Document |
getDocument()
Exports this project to a DOM document. |
|
File |
getFile()
Returns the project file of this project. |
|
double |
getMass()
Returns the mass of the sample. |
|
String |
getName()
Returns the name of this project. |
|
Project.Normalization |
getNormalization()
Returns the normalization to be used for the measurement values. |
|
Project.Orientation |
getOrientation()
Returns the orientation of the sample. |
|
String |
getProperty(String key)
Returns a project information property. |
|
String |
getProperty(String key,
String defaultValue)
Returns a project information property. |
|
Project.SampleType |
getSampleType()
Returns the type of the sample. |
|
Squid |
getSquid()
Returns the Squid if this project is its owner, otherwise returns null. |
|
Project.State |
getState()
Returns the current measurement state of this project. |
|
MeasurementStep |
getStep(int index)
Returns a step from the sequence. |
|
int |
getSteps()
Returns the number of steps in this project. |
|
double |
getStrike()
Returns the strike of the sample. |
|
double |
getSusceptibility()
Returns the susceptibility of the sample. |
|
Date |
getTimestamp()
Returns the timestamp of the last completed measurement. |
|
protected javax.vecmath.Matrix3d |
getTransform()
Returns the current transformation matrix for the sample. |
|
Project.Type |
getType()
Returns the type of this project. |
|
static Project.Type |
getType(File file)
Returns the type of a project file. |
|
|
getValue(int index,
MeasurementValue<A> algorithm)
Calculates and returns a value from a measurement step. |
|
double |
getVolume()
Returns the volume of the sample. |
|
boolean |
isAbortEnabled()
Tells whether it is possible to abort the measurement. |
|
boolean |
isAutoStepEnabled()
Tells whether it is allowed to do an auto step measurement. |
|
boolean |
isClosed()
Returns true if this project has been closed with closeProject(). |
|
boolean |
isDegaussingEnabled()
Tells whether it is allowed to use the degausser in this project. |
|
boolean |
isHolderCalibration()
Returns true if this project file has been set as the Sample Holder Calibration project in the program settings. |
|
boolean |
isManualControlEnabled()
Tells whether it is allowed to control the Squid manually. |
|
boolean |
isModified()
Tells whether the project has been modified and it needs to be saved. |
|
boolean |
isPauseEnabled()
Tells whether it is possible to pause the measurement. |
|
boolean |
isSequenceEditEnabled()
Tells whether it is allowed to edit the sequence. |
|
boolean |
isSingleStepEnabled()
Tells whether it is allowed to do a single step measurement. |
|
static Project |
loadProject(File file)
Loads a saved project file. |
|
private static String |
pad(String s,
int length,
int alignment)
Adds spaces to a string until it is the right length. |
|
void |
removeMeasurementListener(MeasurementListener l)
Removes a MeasurementListener from the project. |
|
void |
removeProjectListener(ProjectListener l)
Removes a ProjectListener from the project. |
|
boolean |
removeStep(int index)
Removes a step from this project's sequence. |
|
boolean |
removeStep(int start,
int end)
Removes a series of steps from this project's sequence. |
|
private void |
runMeasurement()
Runs a measurement sequence until it is paused, aborted or there are no more steps to measure. |
|
void |
save()
Invokes autosaving. |
|
boolean |
saveNow()
Writes this project to its project file and waits for the operation to complete. |
|
void |
setDip(double dip)
Sets the dip of the sample and calls updateTransforms(). |
|
void |
setMass(double mass)
Sets the mass of the sample. |
|
void |
setNormalization(Project.Normalization normalization)
Sets the normalization to be used for the measurement values. |
|
void |
setOrientation(Project.Orientation orientation)
Sets the orientation of the sample and calls updateTransforms(). |
|
void |
setProperty(String key,
String value)
Sets a project information property. |
|
void |
setSampleType(Project.SampleType sampleType)
Sets the type of the sample and calls updateTransforms(). |
|
boolean |
setSquid(Squid squid)
Sets this project the owner of the Squid. |
|
private void |
setState(Project.State state)
Sets the state of this project. |
|
void |
setStrike(double strike)
Sets the strike of the sample and calls updateTransforms(). |
|
void |
setSusceptibility(double susceptibility)
Sets the susceptibility of the sample. |
|
void |
setVolume(double volume)
Sets the volume of the sample. |
|
private void |
updateTransforms()
Recalculates the transformation matrix and updates all measurements. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final boolean DEBUG
public static final String MEASUREMENT_TYPE_PROPERTY
public static final String MEASUREMENT_TYPE_AUTO_VALUE
public static final String MEASUREMENT_TYPE_MANUAL_VALUE
public static final String OPERATOR_PROPERTY
public static final String DATE_PROPERTY
public static final String ROCK_TYPE_PROPERTY
public static final String AREA_PROPERTY
public static final String SITE_PROPERTY
public static final String COMMENT_PROPERTY
public static final String LATITUDE_PROPERTY
public static final String LONGITUDE_PROPERTY
private static final Hashtable<File,Project> projectCache
private static final Hashtable<File,Object> projectTypeCache
private final File file
private final Project.Type type
private Project.State state
private boolean closed
private Squid squid
private final Properties properties
private MeasurementSequence sequence
private double strike
private double dip
private Project.SampleType sampleType
private Project.Orientation orientation
private Project.Normalization normalization
private javax.vecmath.Matrix3d transform
private double mass
private double volume
private double susceptibility
private MeasurementStep currentStep
private final EventListenerList listenerList
private boolean modified
private final LastExecutor autosaveQueue
private Runnable autosaveRunnable
Constructor Detail |
---|
private Project(File file, Project.Type type)
file
- path for this project file. The file should exist (may be empty) and be writable, but this
constructor will not check it.type
- type of the project.
NullPointerException
- if any of the parameters is null.private Project(File file, Document document)
file
- path for this project file. The file should be the same from which document was read and be
writable, but this constructor will not check it.document
- the document from which this project will be created.
NullPointerException
- if any of the parameters is null.
IllegalArgumentException
- if the document was not in the right format.Method Detail |
---|
public static Project createCalibrationProject(File file)
file
- path for the new project file.
NullPointerException
- if file is null.public static Project createAFProject(File file)
file
- path for the new project file.
NullPointerException
- if file is null.public static Project createThellierProject(File file)
file
- path for the new project file.
NullPointerException
- if file is null.public static Project createThermalProject(File file)
file
- path for the new project file.
NullPointerException
- if file is null.public static Project createProject(File file, Project.Type type)
file
- path for the new project file.type
- type of the project.
NullPointerException
- if file or type is null.public static Project loadProject(File file)
file
- project file to be loaded.
NullPointerException
- if file is null.public static boolean closeProject(Project project)
project
- project to be closed.
NullPointerException
- if the project is null.public static Project[] getCachedProjects()
public static Project.Type getType(File file)
file
- the path of the project file.
NullPointerException
- if file is null.public Document getDocument()
public boolean isModified()
public void save()
IllegalStateException
- if this project has already been closed.public boolean saveNow()
IllegalStateException
- if this project has already been closed.private static String pad(String s, int length, int alignment)
s
- the string to be padded.length
- the desired length for the result string.alignment
- alignmet of the text. -1 for left, 0 for center and 1 for right align.
public boolean exportToDAT(File file)
file
- the file to write to.
NullPointerException
- if file is null.public boolean exportToSRM(File file)
file
- the file to write to.
NullPointerException
- if file is null.public boolean exportToTDT(File file)
file
- the file to write to.
NullPointerException
- if file is null.public File getFile()
public Project.Type getType()
public boolean isHolderCalibration()
public Project.State getState()
private void setState(Project.State state)
state
- the new state to change to.public boolean isClosed()
public String getName()
public Date getTimestamp()
public Squid getSquid()
public boolean setSquid(Squid squid)
squid
- pointer to the SQUID interface, or null to detach this project from it.
public String getProperty(String key)
key
- the key which is associated with the property.
public String getProperty(String key, String defaultValue)
key
- the key which is associated with the property.defaultValue
- a default value
public void setProperty(String key, String value)
key
- the key which is associated with the property.value
- new value for the property, or null to remove the property.public double getStrike()
public void setStrike(double strike)
public double getDip()
public void setDip(double dip)
public Project.SampleType getSampleType()
public void setSampleType(Project.SampleType sampleType)
NullPointerException
- if sampleType is null.public Project.Orientation getOrientation()
public void setOrientation(Project.Orientation orientation)
NullPointerException
- if orientation is null.public Project.Normalization getNormalization()
public void setNormalization(Project.Normalization normalization)
NullPointerException
- if normalization is null.protected javax.vecmath.Matrix3d getTransform()
private void updateTransforms()
public double getMass()
public void setMass(double mass)
mass
- mass of the sample, or a negative number to clear it.public double getVolume()
public void setVolume(double volume)
volume
- volume of the sample, or a negative number to clear it.public double getSusceptibility()
public void setSusceptibility(double susceptibility)
susceptibility
- susceptibility of the sample, or a negative number to clear it.public void addProjectListener(ProjectListener l)
l
- the listener to be added.public void removeProjectListener(ProjectListener l)
l
- the listener to be removedprotected void fireProjectEvent(ProjectEvent.Type type)
type
- type of the event.public void addMeasurementListener(MeasurementListener l)
l
- the listener to be added.public void removeMeasurementListener(MeasurementListener l)
l
- the listener to be removedprotected void fireMeasurementEvent(MeasurementStep step, MeasurementEvent.Type type)
step
- the measurement step that has generated the event.type
- the type of the event.public boolean addSequence(MeasurementSequence append)
append
- the measurement sequence to be appended.
NullPointerException
- if sequence is null.public MeasurementSequence copySequence(int start, int end)
start
- index of the first step in the sequence.end
- index of the last step in the sequence. If end < start, then an empty sequence will be returned.
IndexOutOfBoundsException
- if the index is out of range (start < 0 || end >= getSteps()).public MeasurementSequence copySequence(int... indices)
indices
- indices of the steps to be included in the sequence. The steps will be included in the same order
as their indices are listed.
IndexOutOfBoundsException
- if any of the indices is out of range (index < 0 || index >= getSteps()).public boolean addStep(MeasurementStep step)
step
- the measurement step to be added.
NullPointerException
- if step is null.public boolean addStep(int index, MeasurementStep step)
index
- the index to which the step will be added.step
- the measurement step to be added.
IndexOutOfBoundsException
- if the index is out of range (index < getCompletedSteps() || index >
getSteps()).
NullPointerException
- if step is null.public boolean removeStep(int index)
index
- the index of the step to be removed.
IndexOutOfBoundsException
- if the index is out of range (index < getCompletedSteps() || index >=
getSteps()).public boolean removeStep(int start, int end)
start
- the first index to be removed.end
- the last index to be removed. If end < start, no steps will be removed.
IndexOutOfBoundsException
- if the index is out of range (start < getCompletedSteps() || end >=
getSteps()).public int getSteps()
public int getCompletedSteps()
public MeasurementStep getStep(int index)
index
- the index of the step.
IndexOutOfBoundsException
- if the index is out of range (index < 0 || index >= getSteps()).public MeasurementStep getCurrentStep()
public <A> A getValue(int index, MeasurementValue<A> algorithm)
index
- the measurement step from which the value is calculated.algorithm
- the algorithm for calculating the desired value.
NullPointerException
- if algorithm is null.
IndexOutOfBoundsException
- if the index is out of range (index < 0 || index >= getSteps()).private void runMeasurement()
IllegalStateException
- if the project's state is IDLE or it has no Squid.public boolean isDegaussingEnabled()
public boolean isSequenceEditEnabled()
public boolean isManualControlEnabled()
public boolean isAutoStepEnabled()
public boolean isSingleStepEnabled()
public boolean isPauseEnabled()
public boolean isAbortEnabled()
public boolean doAutoStep()
public boolean doSingleStep()
public boolean doPause()
public boolean doAbort()
private boolean doManualMove(Project.ManualMovePosition position)
position
- the position to move the handler to.
public boolean doManualMoveDegausserY()
public boolean doManualMoveDegausserZ()
public boolean doManualMoveBackground()
public boolean doManualMoveMeasurement()
public boolean doManualMoveHome()
public boolean doManualMoveRightLimit()
public boolean doManualMoveLeftLimit()
public boolean doManualRotate(int angle)
angle
- the angle to rotate the handler to.
public boolean doManualMeasure()
public boolean doManualReset()
public boolean doManualDemagZ(double amplitude)
amplitude
- the amplitude to demagnetize in mT.
public boolean doManualDemagY(double amplitude)
amplitude
- the amplitude to demagnetize in mT.
public boolean doManualStepDone()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |