stella.jview
Class JSpectrumCanvas

java.lang.Object
  extended by util.PropertyContainer
      extended by util.PropertyResources
          extended by util.PropertyBundles
              extended by jview.AbstractDisplayable
                  extended by stella.jview.JSpectrumCanvas
All Implemented Interfaces:
Cloneable, DataCanvasProviding, Displayable, Initializable, LocalizedSupplying, PropertySupplying, ResourceSupplying

public class JSpectrumCanvas
extends AbstractDisplayable
implements DataCanvasProviding

Allows the extraction and display of one-dim data from the database. The right row has some pre-defined buttons with spectral ranges.


Nested Class Summary
 
Nested classes/interfaces inherited from class util.PropertyResources
PropertyResources.URLResource
 
Field Summary
private  RaTarget alp0
          Parameter for rest frame.
private  RaApparent alpha
          Parameter for rest frame.
private  Thread animthread
          Animation thread, mainly for gadget.
private  BarycentricVelocity bv
          Parameter for rest frame.
private  boolean cancel
          Inter-process signal.
private  JDataCanvas canvas
          The canvas we display the spectrum in.
static String COLON
           
private  JLabel date
          The date of the observation.
private static long DEFANIMATEGADGET
          Default playback period (ms).
private static DateFormat DEFDATEFORMAT
          The default date formatter, known for this special chron.
private static boolean DEFOVERPLOTTING
          Default overplotting.
private static long DEFPLAYBACK
          Default playback period (ms).
private static boolean DEFRESTFRAME
          If true, convert to restframe.
private static int DEFSGSHALFWIDTH
          Default half-length of smoothing set.
private static int DEFSGSORDER
          Default order of the SG-smoothing.
private static boolean DEFSHOWFITTED
          If true, fit of data is displayed if available.
private static boolean DEFSHOWSMOOTH
          Default no smoothing shown.
private  DecTarget del0
          Parameter for rest frame.
private  DecApparent delta
          Parameter for rest frame.
private  List<Double> doppler
          The Doppler shift, if rest frame is required.
private  List<SpectralFits> fitted
          The spectrum provider for the fited data.
static String FITTED
          Name of one-dim spectrum.
static String KEY_ANIMATEGADGET
          Playback frame rate.
static String KEY_DATEFORMAT
          The date formatter to use.
static String KEY_OVERPLOTTING
          True, if plots are superimposed.
static String KEY_PLAYBACK
          Playback frame rate.
static String KEY_RESTFRAME
          If true, calculate rest-frame wavelength.
static String KEY_SGSHALFWIDTH
          The number of data points to the left and to the right, half of total.
static String KEY_SGSORDER
          The order of the SavitzkyGolaySmoothing employed.
static String KEY_SHOWFITTED
          If false, fitted data is not shown.
static String KEY_SHOWSMOOTH
          If true, we try to add smoothened data.
static String KEY_SPECTRUM
          The properties of the data canvas displaying the spectrum.
private  double lamdamax
          Minimum angstrom lambda of display.
private  double lamdamin
          Minimum angstrom lambda of display.
private  List<SpectralFits> reduced
          The spectrum provider for the reduced data.
private  Box representation
          The buffered representation.
static String SMOOTH
          Name of one-dim spectrum smoothened.
static String SPECTRUM
          Name of one-dim spectrum.
private  JLabel star
          The name of the star from the obs database.
private  SettableTime time
          Parameter for rest frame.
private  JPanel variables
          The RV from the reduced database.
 
Fields inherited from class jview.AbstractDisplayable
KEY_COMPONENTNAME, KEY_ICON, KEY_INSETS
 
Fields inherited from class util.PropertyBundles
KEY_LOCALECOUNTRY, KEY_LOCALELANGUAGE, KEY_RESOURCEBUNDLES
 
Fields inherited from class util.PropertyResources
KEY_NOINITONCREATE, localurl, locate, POSTFIX_DIR, POSTFIX_EXT, POSTFIX_FILE, POSTFIX_LIST, POSTFIX_URL, urlset
 
Fields inherited from class util.PropertyContainer
KEY_LISTSEPARATOR, KEY_MAPKEYVALUECHAR, KEY_MAPSEPARATOR
 
Fields inherited from interface util.ResourceSupplying
KEY_URLRESOURCES, KEY_URLUSECONFIG, KEY_URLUSECURRENT, KEY_URLUSEHOME
 
Fields inherited from interface util.PropertySupplying
CONFIG, KEY_CLASS
 
Constructor Summary
JSpectrumCanvas(Map<String,String> prop)
          Constructs a generic peripheral from a property container.
 
Method Summary
 void addFitted(SpectralFits o)
          Adds the spectral fits object to our reduced list.
 void addReduced(SpectralFits o)
          Adds the spectral fits object to our reduced list.
private  double barycentricVelocity(double ra, double de, Date at)
          Takes right ascension and declination, both in degrees of the target and calculates the projected baryonic velocity of Earth onto the line of sight for the given date.
protected  int centerCanvas(double angstrom, double step)
          Initializes the canvas such that it converts the central wavelength and the region width in array offsets of our wavelength cache, does averaging, if required (if the number of points in the plotting canvas is less than the resolution elements) and updates the display.
private  JDataCanvas createSpectralCanvas()
          Creates a new spectral canvas.
static Component createVariableLabel(Variable v)
          Creates a component displaying a variable
private  List<Vector3D[]> extractSpectra(int order, boolean dopcor)
           
 int getBiggerStrut()
          For layout purposes get the size of a bigger strut.
 Collection<JDataCanvas> getComposingCanvases()
          Only for specialized objects, this method will return more than the main canvas.
 int getLesserStrut()
          For layout purposes get the size of a lesser strut.
 JDataCanvas getMainCanvas()
          Grabs a whole canvas of display data.
 double getMaximumLambda()
          Returns currently displayed minimum lambda.
 double getMinimumLambda()
          Returns currently displayed minimum lambda.
 Component getRepresentation()
          Returns the data canvas.
 void init()
          On init, we try to convert the region buttons list to a lookup map of button labels to Point2Ds.
 boolean isDoppler()
          Checks, if we have doppler shifts for all spectra, meaning that we can shift to rest frame for all spectra.
 boolean isOverplotting()
          Returns the status of the overplotting flag.
 boolean isRestframe()
          Returns the status of the overplotting flag.
private  int[] prepareCanvas(List<Vector3D[]> spec, boolean overpl, double step)
          Initializes the canvas such that it converts the central wavelength and the region width in array offsets of our wavelength cache, does averaging, if required (if the number of points in the plotting canvas is less than the resolution elements) and updates the display.
protected  void purgeAll()
          Purges all but the last spectra.
protected  void purgeLast()
          Purges just the last spectra.
 String setStar(Date central, long duration, StarDescription rvstar, Variable vhelio)
          We set the targetname plus other required parameters for proper display.
 String setStar(Date central, long duration, StarDescription rvstar, Variable vhelio, List<Variable> add)
          We set the targetname plus other required parameters for proper display.
protected  void showCanvas(int order, double step)
          Initializes the canvas such that it converts the central wavelength and the region width in array offsets of our wavelength cache, does averaging, if required (if the number of points in the plotting canvas is less than the resolution elements) and updates the display.
private  double smoothSpectrum(Vector3D[] meas, List<Vector3D> fillin)
           
protected  void startAnimation(int o, double fstep, double ds)
          Animates the drawing in its own thread, can be called from event queue.
protected  void stopAnimation(int o, double step)
           
 
Methods inherited from class jview.AbstractDisplayable
getComponentName, getIcon, getIcon
 
Methods inherited from class util.PropertyBundles
clone, getLocalized, getLocalized, getLocalizedString, getLocalizedString, loadResource
 
Methods inherited from class util.PropertyResources
createFrom, createFrom, createFrom, getApplet, getAsResources, getLocalClassLoader, getPropertiesToKey, getPropertiesToKey, getResource, getResourceAsStream, getResourceFromKey, getResources, keyCreate, keyCreate, reload, setApplet
 
Methods inherited from class util.PropertyContainer
augment, augment, augment, defaultBoolean, defaultChar, defaultDouble, defaultFloat, defaultInt, defaultLong, defaultObject, defaultObject, defaultProperties, defaultProperty, getAsBoolean, getAsChar, getAsDouble, getAsEnums, getAsFloat, getAsInt, getAsList, getAsLong, getAsMap, getAsMap, getAsObject, getAsObject, getProperties, getProperty, has, isNew, parseObject, reload, removeProperty, rescanned, setObject, setProperties, setProperty, stringProperties, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface util.ResourceSupplying
getResource, getResourceAsStream, getResources
 
Methods inherited from interface util.PropertySupplying
defaultBoolean, defaultChar, defaultDouble, defaultFloat, defaultInt, defaultLong, defaultObject, defaultObject, defaultProperties, defaultProperty, getAsBoolean, getAsChar, getAsDouble, getAsFloat, getAsInt, getAsList, getAsLong, getAsMap, getAsObject, getAsObject, getProperties, getProperty, has, parseObject, removeProperty, setObject, setProperty, stringProperties
 

Field Detail

COLON

public static final String COLON
See Also:
Constant Field Values

SPECTRUM

public static final String SPECTRUM
Name of one-dim spectrum.

See Also:
Constant Field Values

SMOOTH

public static final String SMOOTH
Name of one-dim spectrum smoothened.

See Also:
Constant Field Values

FITTED

public static final String FITTED
Name of one-dim spectrum.

See Also:
Constant Field Values

KEY_SPECTRUM

public static final String KEY_SPECTRUM
The properties of the data canvas displaying the spectrum.

See Also:
Constant Field Values

KEY_SHOWFITTED

public static final String KEY_SHOWFITTED
If false, fitted data is not shown.

See Also:
Constant Field Values

KEY_DATEFORMAT

public static final String KEY_DATEFORMAT
The date formatter to use.

See Also:
Constant Field Values

KEY_RESTFRAME

public static final String KEY_RESTFRAME
If true, calculate rest-frame wavelength.

See Also:
Constant Field Values

KEY_OVERPLOTTING

public static final String KEY_OVERPLOTTING
True, if plots are superimposed.

See Also:
Constant Field Values

KEY_PLAYBACK

public static final String KEY_PLAYBACK
Playback frame rate.

See Also:
Constant Field Values

KEY_ANIMATEGADGET

public static final String KEY_ANIMATEGADGET
Playback frame rate.

See Also:
Constant Field Values

KEY_SHOWSMOOTH

public static final String KEY_SHOWSMOOTH
If true, we try to add smoothened data.

See Also:
Constant Field Values

KEY_SGSORDER

public static final String KEY_SGSORDER
The order of the SavitzkyGolaySmoothing employed.

See Also:
Constant Field Values

KEY_SGSHALFWIDTH

public static final String KEY_SGSHALFWIDTH
The number of data points to the left and to the right, half of total.

See Also:
Constant Field Values

DEFRESTFRAME

private static final boolean DEFRESTFRAME
If true, convert to restframe.

See Also:
Constant Field Values

DEFSHOWFITTED

private static final boolean DEFSHOWFITTED
If true, fit of data is displayed if available.

See Also:
Constant Field Values

DEFDATEFORMAT

private static final DateFormat DEFDATEFORMAT
The default date formatter, known for this special chron.


DEFOVERPLOTTING

private static final boolean DEFOVERPLOTTING
Default overplotting.

See Also:
Constant Field Values

DEFPLAYBACK

private static final long DEFPLAYBACK
Default playback period (ms).

See Also:
Constant Field Values

DEFANIMATEGADGET

private static final long DEFANIMATEGADGET
Default playback period (ms).

See Also:
Constant Field Values

DEFSHOWSMOOTH

private static final boolean DEFSHOWSMOOTH
Default no smoothing shown.

See Also:
Constant Field Values

DEFSGSORDER

private static final int DEFSGSORDER
Default order of the SG-smoothing.

See Also:
Constant Field Values

DEFSGSHALFWIDTH

private static final int DEFSGSHALFWIDTH
Default half-length of smoothing set.

See Also:
Constant Field Values

representation

private Box representation
The buffered representation.


canvas

private JDataCanvas canvas
The canvas we display the spectrum in.


star

private JLabel star
The name of the star from the obs database.


date

private JLabel date
The date of the observation.


variables

private JPanel variables
The RV from the reduced database.


time

private SettableTime time
Parameter for rest frame.


alp0

private RaTarget alp0
Parameter for rest frame.


alpha

private RaApparent alpha
Parameter for rest frame.


del0

private DecTarget del0
Parameter for rest frame.


delta

private DecApparent delta
Parameter for rest frame.


bv

private BarycentricVelocity bv
Parameter for rest frame.


doppler

private List<Double> doppler
The Doppler shift, if rest frame is required.


reduced

private List<SpectralFits> reduced
The spectrum provider for the reduced data.


fitted

private List<SpectralFits> fitted
The spectrum provider for the fited data.


animthread

private Thread animthread
Animation thread, mainly for gadget.


cancel

private boolean cancel
Inter-process signal.


lamdamin

private double lamdamin
Minimum angstrom lambda of display.


lamdamax

private double lamdamax
Minimum angstrom lambda of display.

Constructor Detail

JSpectrumCanvas

public JSpectrumCanvas(Map<String,String> prop)
Constructs a generic peripheral from a property container.

Method Detail

init

public void init()
On init, we try to convert the region buttons list to a lookup map of button labels to Point2Ds.

Specified by:
init in interface Initializable
Overrides:
init in class PropertyResources

getRepresentation

public Component getRepresentation()
Returns the data canvas.

Specified by:
getRepresentation in interface Displayable

getLesserStrut

public int getLesserStrut()
For layout purposes get the size of a lesser strut.


getBiggerStrut

public int getBiggerStrut()
For layout purposes get the size of a bigger strut.


getMainCanvas

public JDataCanvas getMainCanvas()
Description copied from interface: DataCanvasProviding
Grabs a whole canvas of display data. For objects that want to dump their data into some display, this method retrieves the main data canvas. Only very specified objects may need also the second method, DataCanvasProviding.getComposingCanvases().

Specified by:
getMainCanvas in interface DataCanvasProviding

getComposingCanvases

public Collection<JDataCanvas> getComposingCanvases()
Description copied from interface: DataCanvasProviding
Only for specialized objects, this method will return more than the main canvas.

Specified by:
getComposingCanvases in interface DataCanvasProviding

isDoppler

public boolean isDoppler()
Checks, if we have doppler shifts for all spectra, meaning that we can shift to rest frame for all spectra.


isOverplotting

public boolean isOverplotting()
Returns the status of the overplotting flag.


isRestframe

public boolean isRestframe()
Returns the status of the overplotting flag.


setStar

public String setStar(Date central,
                      long duration,
                      StarDescription rvstar,
                      Variable vhelio)
We set the targetname plus other required parameters for proper display.


setStar

public String setStar(Date central,
                      long duration,
                      StarDescription rvstar,
                      Variable vhelio,
                      List<Variable> add)
We set the targetname plus other required parameters for proper display. Always call together with addReduced(astro.SpectralFits)


addReduced

public void addReduced(SpectralFits o)
Adds the spectral fits object to our reduced list.


addFitted

public void addFitted(SpectralFits o)
Adds the spectral fits object to our reduced list.


purgeAll

protected void purgeAll()
Purges all but the last spectra.


purgeLast

protected void purgeLast()
Purges just the last spectra.


createSpectralCanvas

private JDataCanvas createSpectralCanvas()
Creates a new spectral canvas. This canvas can than be filled with one-d spectra and shows up as a component in the central tabbed pane.


createVariableLabel

public static Component createVariableLabel(Variable v)
Creates a component displaying a variable

Parameters:
v - The variable - may not be null
Returns:
A JPanel in flow layout with the variable name plus colon plus the value, rounded to significant digits. Error as tool-tip

centerCanvas

protected int centerCanvas(double angstrom,
                           double step)
                    throws nom.tam.fits.FitsException
Initializes the canvas such that it converts the central wavelength and the region width in array offsets of our wavelength cache, does averaging, if required (if the number of points in the plotting canvas is less than the resolution elements) and updates the display.

Parameters:
angstrom - The wavelength to display
step - Offset
Throws:
nom.tam.fits.FitsException

showCanvas

protected void showCanvas(int order,
                          double step)
                   throws nom.tam.fits.FitsException
Initializes the canvas such that it converts the central wavelength and the region width in array offsets of our wavelength cache, does averaging, if required (if the number of points in the plotting canvas is less than the resolution elements) and updates the display.

Parameters:
order - The Echelle order to display.
step - Offset
Throws:
nom.tam.fits.FitsException

getMinimumLambda

public double getMinimumLambda()
Returns currently displayed minimum lambda.


getMaximumLambda

public double getMaximumLambda()
Returns currently displayed minimum lambda.


extractSpectra

private List<Vector3D[]> extractSpectra(int order,
                                        boolean dopcor)
                                 throws nom.tam.fits.FitsException
Throws:
nom.tam.fits.FitsException

prepareCanvas

private int[] prepareCanvas(List<Vector3D[]> spec,
                            boolean overpl,
                            double step)
Initializes the canvas such that it converts the central wavelength and the region width in array offsets of our wavelength cache, does averaging, if required (if the number of points in the plotting canvas is less than the resolution elements) and updates the display.


smoothSpectrum

private double smoothSpectrum(Vector3D[] meas,
                              List<Vector3D> fillin)

startAnimation

protected void startAnimation(int o,
                              double fstep,
                              double ds)
Animates the drawing in its own thread, can be called from event queue.


stopAnimation

protected void stopAnimation(int o,
                             double step)
                      throws nom.tam.fits.FitsException
Throws:
nom.tam.fits.FitsException

barycentricVelocity

private double barycentricVelocity(double ra,
                                   double de,
                                   Date at)
Takes right ascension and declination, both in degrees of the target and calculates the projected baryonic velocity of Earth onto the line of sight for the given date.