Class: MarkersFactory

MarkersFactory()

A class to create and to manage markers in the 2D part of YAFITS. A marker is basically a record defined by a position, the pixel value at that position and a label on a 2D map. With YAFITS on a 2D map, one can use two possible interfaces to work on the collection of markers.
  • The graphic interface displays the markers above the map. It uses the OpenLayers API.
  • The spreadsheet interface offers an "à la Excel" interaction with the collection. It uses the Jexcel API.
Both interfaces allow to edit the collection of markers. As announced above, a marker is a aggregate of informations which is implemented in a dictionary whose keys are defined as follows.
  • id (integer) - an id for that marker. Two # markers have # ids. id == -1 invalid or empty marker.
  • label (string) - a label for that marker. No constraint.
  • RA (string) - a valid representation of a right ascension.
  • DEC (string) - a valid representation of a declination.
  • type (unit) (number) - the pixel value. The field is named after FITS BTYPE and BUNIT.
On the spreadsheet
a marker is stored in one row of a Jexcel API table with one value associated to one key per column.
On the graphics interface
a marker is stored in an OpenLayers feature
It's the software responsibility to maintain the respective contents of the jexcel sheet and the collection of features dedicated to makers in sync.

Constructor

new MarkersFactory()

Source:

Extends

Members

columns :Array.<dictionary>

Defines the title, type, width in pixels, name and read/writability of the jexcel sheet's columns.
Type:
  • Array.<dictionary>
Source:

mode

A mutator defining the kind of subclass.
Overrides:
Source:

Methods

a2O(a) → {dictionary}

Utility. Transforms an array into a dictionary. The values are taken in a, the keys in this.fieldnames Requires that condition is that a and fieldnames have the same length. Otherwise an empty dictionary is returned.
Parameters:
Name Type Description
a Array.<any>
Source:
Returns:
Type
dictionary

b4change(sheet, cell, x, y, value)

Callback. Defines the onbeforechange behaviour (i.e. just before a change is performed).
Parameters:
Name Type Description
sheet jexcel-sheet not used in this implementation
cell jexcel-row not used in this implementation
x number not used in this implementation
y number not used in this implementation
value any not used in this implementation
Source:

changed(sheet, cell, x, y, value)

Callback. Defines the onchange behaviour (i.e. just when a change occurred).
Parameters:
Name Type Description
sheet jexcel-sheet the sheet where change occurred
cell jexcel-cell the cell where change occurred
x number the column number
y number the row number
value any the new value
Source:

checkDEC(DECText) → {dictionary}

Utility. Check that a string expresses correctly a Declination.
Parameters:
Name Type Description
DECText string
Source:
Returns:
a dictionary { degree:.., minute:..., second:..., decdegree:... } if yes and null if no (decdegree === decimale degree)
Type
dictionary

checkRA(RAText)

Utility. Check that a string expresses correctly a Right Ascension.
Parameters:
Name Type Description
RAText string
Source:
Returns:

checkRADEC(RAText, DECText) → {dictionary}

Utility. Check that a pair of string expresses correctly a pair (Right Ascension, Declination)
Parameters:
Name Type Description
RAText string
DECText string
Source:
Returns:
a dictionary { RA: result of checkRA(RAText), DEC: result of checkDEC(DECText)}
Type
dictionary

close()

Close this factory. Disable its interaction processor.
Overrides:
Source:

createJexcel(parentId)

Creates an empty jexcel sheet and defines its behaviour.
Parameters:
Name Type Description
parentId string the id of parent element.
Source:

deleteMarkerFeatures(arrayOfFeatures)

Utility. Delete OpenLayers features representing markers.
Parameters:
Name Type Description
arrayOfFeatures Array.<feature> the features to delete
Source:

deleteSelectedMarkers()

Callback. Defines the ondeleterow behaviour.
Source:

format(floatValue) → {string}

Utility. Format the textual expression of a float number.
Parameters:
Name Type Description
floatValue number
Source:
Returns:
a string as produced by toExponential(4)
Type
string

getAllMarkerFeatures() → {Array.<feature>}

Utility. Return an array of all the OpenLayers features representing markers.
Source:
Returns:
Type
Array.<feature>

getButtonObject() → {button}

Utility. Returns the toolbox button that will activate this instance.
Source:
Returns:
Type
button

getDataAsJSON() → {Array.<dictionary>}

Utility. Transforms a jexcel spreadsheet as returned by getData, i.e. an array of arrays, into an array of dictionaries.
Source:
Returns:
Type
Array.<dictionary>

getMarkersList()

Returns an array of objects representing markers with all their properties
Source:
Returns:
array

getPixelValuePromise(iRA, iDEC, relFITSFilePath)

Promise. Connect the get pixel value asynchronous calls with the consumer of the result to these calls.
Parameters:
Name Type Description
iRA number the integer first coordinate of the pixel of interest
iDEC number the integer second coordinate of the pixel of interest
relFITSFilePath string the FITS file path
Source:

hide()

Hide all the objects created by one subclass. (e.g. all the markers)
Overrides:
Source:

jexcel2OL()

Utility. Produces a graphic representation of the collection of markers from the content of the jexcel sheet. (Jexcel to OpenLayers)
Source:

loaded()

Callback. Defines the onload behaviour (i.e. setData).
Source:

markersCount()

Source:
Returns:
a button

noteSelectedRows(sheet, x1, y1, x2, y2)

Callback. Defines the onselection behaviour of the spreadsheet after some selection has been performed. Here the 'id' field(s) of the selected row(s) are recorded.
Parameters:
Name Type Description
sheet jexcel-sheet
x1 number
y1 number
x2 number
y2 number
Source:

open(interaction, cursor)

Behaviour when an instance is activated.
Parameters:
Name Type Description
interaction Interaction
cursor cursor
Overrides:
Source:
See:

recordMarker(event, flux)

Utility. Record a new marker after a click on the graphic interface. Both graphic and jexcel interfaces are updated.
Parameters:
Name Type Description
event event the click event that triggers the marker's creation
flux dictionary a dictionary {"value":.., "unit":..., "type:..."}
Source:

remove(feature)

Remove one object created by a subclass.
Parameters:
Name Type Description
feature * the object to remove.
Overrides:
Source:

removeFromJExcel(markerFeature)

Utility. Removes a marker, i.e. one row, from the jexcel sheet given its OpenLayers counterpart (feature).
Parameters:
Name Type Description
markerFeature feature
Source:

selected(feature)

Modify the look of feature to show that it's been selected. ( e.g. highlite it )
Parameters:
Name Type Description
feature An instance created by a subclass
Overrides:
Source:

setId(sheet, rowNumber, numOfRows, rowRecords, insertBefore)

Callback. Defines the oninsertrow behaviour once a new (empty) row has been inserted. Here the 'id' of that row is forced to -1.
Parameters:
Name Type Description
sheet jexcel-sheet not used in this implementation
rowNumber number the index number of the row to be inserted.
numOfRows number not used in this implementation
rowRecords number not used in this implementation
insertBefore boolean how the insertion is performed.
Source:

show()

Make visible all the objects created by one subclass. (e.g. all the markers)
Overrides:
Source:

unselected(feature)

Modify the look of feature to show that it's been unselected. ( e.g. display it normally )
Parameters:
Name Type Description
feature an instance created by a subclass.
Overrides:
Source:

validateRow(row) → {boolean}

Utility. Checks the content of a row considered as a dictionary. Here it verifies that RA and DEC fields are valid strings to express right ascension and declination.
Parameters:
Name Type Description
row dictionary
Source:
Returns:
Type
boolean