Skip to content

Commit 76e7125

Browse files
committed
jsdoc - fixed errors, updated API docs, now all Javascript sources are included into docs build
1 parent e7f87a1 commit 76e7125

30 files changed

+231
-129
lines changed

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,17 @@ You may include this jar into your project to build advanced astronomy web appli
7878
In a terminal, cd into the `firefly` directory, then run:
7979

8080
$ gradle :firefly:war
81+
82+
To include the API documentation and tutorial into the war archive run:
83+
84+
$ gradle :firefly:warAll
8185

8286
This generates firefly.war located at ./build/lib/.
8387
Simply drop this file into your $CATALINA_HOME/webapps/ directory to deploy it.
8488
$CATALINA_HOME is your Tomcat server installation directory.
8589

86-
Goto http://localhost:8080/firefly/ to launch Firefly Viewer.
90+
Goto http://localhost:8080/firefly to launch Firefly Viewer.
91+
The documentation is accessible via http://localhost:8080/firefly/jsdoc/index.html
8792

8893

8994
## More Docs

docs/firefly-api-overview.md

Lines changed: 90 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ The main Firefly components are:
66

77
- [FITS Visualizer](#fits-visualization)
88
- [Table](#table-visualization)
9-
- [XY Plotter](#xy-plot-visualization)
9+
- [Charts](#xy-plot-and-histogram-visualization)
1010

1111
These components can be setup to share the same data model. Therefore you can do the following combinations:
1212

1313
- [Connect FITS viewer coverage image to a table](#connecting-coverage-image-to-table)
14-
- [Connect XY plot to a table](#connecting-xy-viewers-to-table). A Table with any data and a XY Plot showing plots from any two columns of that table.
14+
- [Connect XY plot to a table](#connecting-charts-to-table). A Table with any data and a XY Plot showing plots from any two columns of that table.
1515
- Tri-view: Table, FITS coverage, and XY Plot together showing the same data.
1616

1717
Lower level API is built around the following modules:
@@ -67,7 +67,7 @@ This is all best explained with a code example. This examples creates a div with
6767

6868
The interface to remotely communicate to the firefly viewer:
6969

70-
- `firefly.getViewer()` - gives a handle to launch the firefly tools in another browser window or tab
70+
`firefly.getViewer()` - gives a handle to launch the firefly tools in another browser window or tab
7171

7272
| Parameter | type | Description |
7373
| ---------- | ---- | ----------- |
@@ -104,9 +104,11 @@ Then React re-renders the parts that are different. Therefore, application goes
104104

105105
![diagram](https://cask.scotch.io/2014/10/V70cSEC.png)
106106

107-
Being able to dispatch and listen to Firefly actions makes it possible to write new code, which could control or interact with Firefly widgets.
107+
Being able to dispatch Firefly actions and listen to them makes it possible to write new code, which could control Firefly widgets or interact with them.
108+
109+
An external script would trigger UI change by calling an action dispatcher and react to UI action by adding a listener to this action.
108110

109-
#####**firefly.util.addActionListener(actionType,callBack)**
111+
##### **firefly.util.addActionListener(actionType,callBack)**
110112

111113
`firefly.action.type` object is a handle to Firefly action types. Action types are its properties.
112114
`firefly.actions` object contains action dispatchers.
@@ -210,7 +212,7 @@ Deprecated `ImageViewer` methods:
210212

211213
### Utility methods for FITS visualization
212214

213-
#####**firefly.util.image.getPrimePlot** method
215+
##### **firefly.util.image.getPrimePlot** method
214216

215217
`firefly.util.image.getPrimePlot(plotId)` - get the plot object by its plot id
216218

@@ -231,7 +233,7 @@ function getWorkingFitsFile(pt) {
231233
}
232234
```
233235

234-
#####**firefly.util.image.CCUtil**
236+
##### **firefly.util.image.CCUtil**
235237

236238
`firefly.util.image.CCUtil` - coordinate conversion utilities
237239

@@ -253,7 +255,7 @@ function getImagePt(pt) {
253255
}
254256
```
255257

256-
#####**firefly.util.image.serializeSimpleRangeValues** method
258+
##### **firefly.util.image.serializeSimpleRangeValues** method
257259

258260
`firefly.util.image.serializeSimpleRangeValues(stretchType,lowerValue,upperValue,algorithm)` - serialize a stretch request into a string, for use with the "RangeValues" parameter
259261

@@ -349,7 +351,7 @@ callback function takes one parameter, an object literal, the fields vary depen
349351

350352
##### **firefly.action.dispatchCreateRegionLayer** method
351353

352-
`firefly.action.dispatchCreateRegionLayer(regionId, layerTitle, fileOnServer ='', regionAry=[], plotId = [])` - overlay region data on an image plots with the given ids
354+
`firefly.action.dispatchCreateRegionLayer(regionId, layerTitle, fileOnServer ='', regionAry=[], plotId = [], selectMode)` - overlay region data on an image plots with the given ids
353355

354356
| Parameter | Type | Description |
355357
| ---------- | ---- | ----------- |
@@ -358,6 +360,7 @@ callback function takes one parameter, an object literal, the fields vary depen
358360
| fileOnServer | string | region file on the server |
359361
| regionAry | array | an array of strings, each describing a ds9 region |
360362
| plotId | string or array | a plot id or an array of plot ids |
363+
| selectMode | object | rendering features for the selected region |
361364

362365
Note: if no plotId is given, the region layer is created on all plots.
363366

@@ -376,13 +379,18 @@ Note: if no plotId is given, the region layer is removed from all plots.
376379

377380
##### **firefly.action.dispatchAddRegionEntry** method
378381

379-
`firefly.action.dispatchAddRegionEntry(regionId, regionChanges)` - add region data to the given region layer
382+
`firefly.action.dispatchAddRegionEntry(regionId, regionChanges, plotId=[], layerTitle='', selectMode = {})` - add region data to the given region layer
380383

381384
| Parameter | Type | Description |
382385
| ---------- | ---- | ----------- |
383386
| regionId | string | region layer id |
384387
| regionChanges | array | an array of strings, each describing a ds9 region |
385388

389+
Other parameters are optional drawing layer creation parameters, similar to those of `firefly.action.dispatchCreateRegionLayer`.
390+
It is possible to create region layer by adding the first region to it.
391+
392+
393+
386394
##### **firefly.action.dispatchRemoveRegionEntry** method
387395

388396
`firefly.action.dispatchRemoveRegionEntry(regionId, regionChanges)` - remove region data from the given region layer
@@ -391,24 +399,51 @@ Note: if no plotId is given, the region layer is removed from all plots.
391399
| ---------- | ---- | ----------- |
392400
| regionId | string | region layer id |
393401
| regionChanges | array | an array of strings, each describing a ds9 region |
402+
403+
When the last region of the drawing layer is removed, the drawing layer is automatically deleted.
404+
394405

406+
##### **firefly.action.dispatchSelectRegion** method
407+
408+
`firefly.action.dispatchSelectRegion(drawLayerId, selectedRegion)` - select region from a drawing layer
409+
410+
| Parameter | Type | Description |
411+
| ---------- | ---- | ----------- |
412+
| drawLayerId | string | region layer id |
413+
| selectedRegion | string | string describing ds9 region |
414+
415+
416+
##### **firefly.util.image.getSelectedRegion** method
417+
418+
`firefly.util.image.getSelectedRegion(drawLayerId)` - get ds9 string for the selected region in the given drawing layer. The returned string will always have coordinate system (image, physical, j2000, ...) in the front.
419+
420+
| Parameter | Type | Description |
421+
| ---------- | ---- | ----------- |
422+
| drawLayerId | string | region layer id |
423+
395424
*Example:*
396425
```js
426+
function onRegionSelect(action) {
427+
if (action.payload.selectedRegion !== null) {
428+
const regionStr = firefly.util.image.getSelectedRegion(action.payload.drawLayerId);
429+
console.log('Selected region string: '+regionStr);
430+
}
431+
}
397432
function onFireflyLoaded() {
398433
const req = {
399434
plotId: 'image1',
400435
URL: 'http://web.ipac.caltech.edu/staff/roby/demo/wise-m51-band2.fits',
401436
Title: 'WISE m51'
402437
};
403438
firefly.showImage('image1_div', req);
404-
setTimeout(function() {
405-
// parameters to dispatchCreateRegionLayer: regionId, layerTitle, fileOnServer ='', regionAry=[], plotId = []
406-
const regionAry = [
407-
'image; box 250 250 100 80 0 # color=red',
408-
'image; box 250 250 50 40 0 # color=red'
409-
];
410-
firefly.action.dispatchCreateRegionLayer('region1', 'Region Layer 1', null, regionAry, ['image1', 'image2']);
411-
}, 3000);
439+
// parameters to dispatchCreateRegionLayer: regionId, layerTitle, fileOnServer ='', regionAry=[], plotId = []
440+
const regionAry = [
441+
'image; box 250 250 100 80 0 # color=red',
442+
'image; box 250 250 50 40 0 # color=red'
443+
];
444+
firefly.action.dispatchCreateRegionLayer('region1', 'Region Layer 1', null, regionAry, ['image1', 'image2']);
445+
// add a listener to detect region selection changes
446+
firefly.util.addActionListener(firefly.action.type.REGION_SELECT, onRegionSelect);
412447
}
413448
```
414449

@@ -481,25 +516,46 @@ The Table tools currently supports the following file formats:
481516

482517

483518

484-
### XY Plot Visualization
519+
### XY Plot and Histogram Visualization
485520

486521
- `firefly.showXYPlot(targetDiv, parameters)`
522+
- `firefly.showHistogram(targetDiv, parameters)`
487523

488524
| Parameter | Type | Description |
489525
| ---------- | ---- | ----------- |
490526
| targetDiv | string | target div to put the XY Plot in |
491527
| parameters | object | XY plot parameters |
492528

493529

494-
Parameters object literal can contain the following values
530+
XYPlot parameters object literal can contain the following values.
495531

496532
| Parameter | Description |
497533
| ------------ | ------------- |
498-
| source | required; location of the ipac table. url or file path.|
534+
| source | location of the ipac table: url or file path.|
499535
| xCol | column or expression to use for x values, can contain multiple column names ex. log(col) or (col1-col2)/col3 |
500536
| yCol | column or expression to use for y values, can contain multiple column names ex. log(col) or (col1-col2)/col3 |
537+
| xyRatio | optional; aspect ratio between 1 and 10, if not defined the chart will fill all available space |
538+
| stretch | 'fit' to fit plot into available space or 'fill' to fill the available width; applied when xyPlotRatio is defined |
539+
| xLabel | label to use with x axis |
540+
| yLabel | label to use with y axis |
541+
| xUnit | unit for x axis |
542+
| yUnit | unit for y axis |
543+
| xOptions | comma separated list of x axis options: grid,flip,log |
544+
| yOptions | comma separated list of y axis options: grid,flip,log |
501545

502546

547+
Histogram parameters object literal can contain the following values.
548+
549+
| Parameter | Description |
550+
| ------------ | ------------- |
551+
| source | location of the ipac table: url or file path.|
552+
| col | column or expression to use for histogram, can contain multiple column names ex. log(col) or (col1-col2)/col3 |
553+
| xyRatio | optional; aspect ratio between 1 and 10, if not defined the chart will fill all available space |
554+
| numBins | number of bins for fixed bins algorithm (default) |
555+
| falsePositiveRate | false positive rate for bayesian blocks algorithm |
556+
| xOptions | comma separated list of x axis options: flip,log |
557+
| yOptions | comma separated list of y axis options: flip,log |
558+
503559
*Example:*
504560
```js
505561
chartParams = {
@@ -510,7 +566,7 @@ chartParams = {
510566
firefly.showXYPlot('chart_div', chartParams);
511567
```
512568

513-
XY Plot supports the same table formats as Table does:
569+
XY Plot and Histogram support the same table formats as Table:
514570

515571
- IPAC Table file format
516572
- CSV - first row should be column headers
@@ -566,31 +622,27 @@ firefly.showTable('table_div', tblReq);
566622
firefly.showCoverage('coverage_div', {gridOn:true})
567623
```
568624

625+
### Connecting Charts to table
569626

627+
`firefly.showXYPlot(targetDiv, parameters)` - add an XY Plot to a div
628+
`firefly.showHistogram(targetDiv, parameters)` - add a Histogram to a div
570629

571-
### Connecting XY Viewers to table
572-
573-
`firefly.addXYPlot(targetDiv, parameters)` - add an XY Plot to a div
574-
630+
Multiple charts can be connected to the same table.
575631

576632
| parameters | type |
577633
| ---------- | ----------- |
578634
|targetDiv | string, the div to put the XY plot into |
579635
|parameters | object literal |
580636

637+
The most important parameters, relevant to all charts, connected to a table are:
581638

582-
583-
Most important parameters are:
584-
585-
- **`xCol`**: The name of x column, can be an expression based on multiple columns.
586-
If no column is specified, the first numeric column is used as an x column.
587-
- **`yCol`**: The name of y column, can be an expression based on multiple columns.
588-
If no column is specified, the first numeric non-x column is used as a y column.
589639
- **`tbl_id`**: Table ID, the string that connects this XY Plot to the table data.
590-
- **`tbl_group`**: Table group, the plot will reflect the data in the active table of the group.
640+
- **`tbl_group`**: Table group, when specified instead of `tbl_id`, the plot will reflect the data in the active table of the group.
591641

592642
If both `tbl_id` and `tbl_group` are missing, the XY viewer will be connected to the active table in the main group.
593643

644+
Please, see `firefly.showXYPlot` and `firefly.showHistogram` for the list of other parameters.
645+
594646
*Example:*
595647
```js
596648
tblReq = firefly.util.table.makeIrsaCatalogRequest('wise catalog', 'WISE', 'wise_allwise_p3as_psd',
@@ -599,9 +651,12 @@ tblReq = firefly.util.table.makeIrsaCatalogRequest('wise catalog', 'WISE', 'wise
599651
SearchMethod: 'Cone',
600652
radius: 300
601653
});
602-
firefly.addXYPlot('xyplot_div', {tbl_id: tblReq.tbl_id, xCol: 'w1mpro+w4mpro', yCol: 'w2mpro'});
654+
firefly.showXYPlot('xyplot_div', {tbl_id: tblReq.tbl_id, xCol: 'w1mpro+w4mpro', yCol: 'w2mpro'});
655+
firefly.showHistogram('histogram1_div', {tbl_id: tblReq.tbl_id, col: 'w1mpro+w4mpro'});
656+
firefly.showHistogram('histogram2_div', {tbl_id: tblReq.tbl_id, col: 'w2mpro'});
603657
```
604658

659+
605660
### More Code Examples
606661

607662
[see firefly-api-code-examples.md](../tutorial/firefly-api-code-examples.md)

docs/firefly-environment.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ Firefly relies heavily on its configuration to provide customizable behaviors fo
3131
You can change the default configuration both during build time and during runtime.
3232

3333
#### Runtime
34-
Using Firefly Viewer with a context name of `fftools` as an example.
35-
When deployed, the configuration files reside in CATALINA_BASE/webapps/fftools/WEB-INF/config/.
34+
Using Firefly Viewer with a context name of `firefly` as an example.
35+
When deployed, the configuration files reside in CATALINA_BASE/webapps/firefly/WEB-INF/config/.
3636
Although, you can make direct changes to those files, it is not recommended.
3737
It should only be use to temporarily test a new configuration.
3838
If you wish to override a property in one of the `.prop` files, you can drop your own `.prop` file into
3939
the `${server_config_dir}` directory. To setup the `${server_config_dir}` variable, add this line to the `setenv.sh` file.
40-
In this example, if you set it to `/my_app_config`, it will look for `.prop` files in `/my_app_config/fftools/`.
40+
In this example, if you set it to `/my_app_config`, it will look for `.prop` files in `/my_app_config/firefly/`.
4141

4242
JAVA_OPTS="-Dserver_config_dir=/my_app_config"
4343

@@ -46,9 +46,13 @@ In this example, if you set it to `/my_app_config`, it will look for `.prop` fil
4646

4747
You can change the configuration of a build in a several ways. First, by specifying which environment this build is for.
4848
To do that, you add the `-Penv=<type>` to your gradle command. At the moment, there are 4 types of env: local, dev, test, and ops with local being the default.
49-
Here is an example of building Firefly Viewer for the ops envronment.
49+
Here is an example of building Firefly Viewer for the ops environment.
5050

51-
$ gradle -Penv=ops :fftools:war
51+
$ gradle -Penv=ops :firefly:war
52+
53+
Another example of building Firefly Viewer with the API documentation and tutorial for dev environment.
54+
55+
$ gradle -Penv=dev :firefly:warAll
5256

5357
`firefly/config/app.config` contains a list of properties used during the build. The `environments{}` block define properties specific for a particular environment.
5458
In any cases, if a property is not found for a given env, it will use the one defined outside of the `environments{}` block.

src/firefly/js/charts/ChartUtil.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ export function makeXYPlotParams(params) {
245245
* @prop {string} [tbl_id] table id of the table this plot is connected to
246246
* @prop {string} [chartTitle] title of the chart
247247
* @prop {string} col column or expression to use for histogram, can contain multiple column names ex. log(col) or (col1-col2)/col3
248-
* @prop {number} [numBins=50] number of bins' for fixed bins algorithm (default)
248+
* @prop {number} [numBins=50] number of bins for fixed bins algorithm (default)
249249
* @prop {number} [falsePositiveRate] false positive rate for bayesian blocks algorithm
250250
* @prop {string} [xOptions] comma separated list of x axis options: flip,log
251251
* @prop {string} [yOptions] comma separated list of y axis options: flip,log

src/firefly/js/core/messaging/WebSocketClient.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ export function wsConnect(baseUrl=getRootURL()) {
4141
}
4242

4343
/**
44-
*
45-
* @param name Event's name. See edu.caltech.ipac.firefly.util.event.Name for a full list.
46-
* @param scope One of 'SELF', 'CHANNEL', 'SERVER'.
47-
* @param dataType One of 'JSON', 'BG_STATUS', 'STRING'.
48-
* @param data String.
44+
* @param {Object} p
45+
* @param p.name - Event's name. See edu.caltech.ipac.firefly.util.event.Name for a full list.
46+
* @param p.scope - One of 'SELF', 'CHANNEL', 'SERVER'.
47+
* @param p.dataType - One of 'JSON', 'BG_STATUS', 'STRING'.
48+
* @param p.data - String.
4949
*/
5050
function wsSend({name='ping', scope, dataType, data}) {
5151
if (name === 'ping') {
@@ -59,10 +59,11 @@ function wsSend({name='ping', scope, dataType, data}) {
5959

6060
/**
6161
* add an event listener to this websocket client.
62-
* @param matches a function that takes an event({name, data}) as its parameter. return true if this
63-
* listener will handle the event.
64-
* @param onEvent a function that takes an event({name, data}) as its parameter. this function is called
65-
* whenever an event matches its listener.
62+
* @param {Object} obj
63+
* @param {Function} obj.matches - matches a function that takes an event({name, data}) as its parameter. return true if this
64+
* listener will handle the event.
65+
* @param {Function} obj.onEvent - a function that takes an event({name, data}) as its parameter. this function is called
66+
* whenever an event matches its listener.
6667
*/
6768
function addListener( {matches, onEvent} ) {
6869
listenters.push({matches, onEvent});

src/firefly/js/data/ServerRequest.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ export class ServerRequest {
179179
* Parameters are separated by '&'. Keyword and value are separated
180180
* by '='. If the keyword contains a '/' char, then the left side is
181181
* the keyword, and the right side is its description.
182-
* @return
182+
* @return {string}
183183
*/
184184
toString() {
185185
var idStr= (ID_KEY+KW_VAL_SEP+this.params[ID_KEY]);

0 commit comments

Comments
 (0)