Skip to content

Commit bb432b6

Browse files
author
Cindy Wang
committed
create firefly_data.jar to contain fits file (previous fits.jar) and footprint description file. Update footprint and marker label display. Add methods to add and get footprint into the a footprint map in the server.
1 parent 344fc28 commit bb432b6

22 files changed

+5551
-65
lines changed

buildScript/depends.gincl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ ext {
1313
webservices_lib = [':archive_dto_irsa',
1414
':axis',
1515
':archive_dto_votable',
16-
':xbean',
17-
':fits' ]
16+
':xbean']
1817

1918
ehcache_lib = [':ehcache-2.7.4',
2019
':slf4j-api-1.6.6',
@@ -56,7 +55,7 @@ ext {
5655
firefly_lib = [ firefly_ext_lib, ':firefly' ]
5756

5857

59-
FIREFLY_RUNTIME = fits_io_lib + apache_lib + spring_lib + webservices_lib +
58+
FIREFLY_RUNTIME = [':firefly_data'] + fits_io_lib + apache_lib + spring_lib + webservices_lib +
6059
log4j_lib + josso_lib + xstream_lib + xbeanfinder_lib +
6160
gwt_lib_rt + ehcache_lib + starlink_lib + j2ee_rt_lib + json_lib
6261

jars/data/fits.jar

-3.89 MB
Binary file not shown.

settings.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
rootProject.name = 'firefly_root'
22

3-
include 'simbad', 'xstream', 'firefly', 'fftools'
3+
include 'simbad', 'xstream', 'firefly', 'fftools', 'firefly_data'
44

55
project(":simbad").projectDir = file('src/external/simbad')
66
project(":xstream").projectDir = file('src/external/xstream')
77
project(":firefly").projectDir = file('src/firefly')
88
project(":fftools").projectDir = file('src/fftools')
9+
project(":firefly_data").projectDir = file('src/firefly_data')
910

src/firefly/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ ext["app-name"] = 'firefly'
44
apply from: "$fireflyPath/buildScript/gwt_webapp.gincl"
55

66
dependencies {
7-
compile project(':xstream'), project(':simbad')
7+
compile project(':xstream'), project(':simbad'), project(':firefly_data')
88
webappLib mysql_lib, FIREFLY_RUNTIME + ":$jar.baseName"
99
}
1010

src/firefly/java/edu/caltech/ipac/firefly/server/visualize/AllSkyRetriever.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@
2323
public class AllSkyRetriever implements FileRetriever {
2424

2525
private static final ReservedImage RESERVED_IMAGES[] = {
26-
new ReservedImage("e90gal07.fits",
26+
new ReservedImage("allsky/e90gal07.fits",
2727
"All Sky Image -- DIRBE 60 micron", "sky"),
28-
new ReservedImage("e90gal09.fits",
28+
new ReservedImage("allsky/e90gal09.fits",
2929
"All Sky Image -- DIRBE 140 micron", "sky"),
30-
new ReservedImage("e90gal04.fits",
30+
new ReservedImage("allsky/e90gal04.fits",
3131
"All Sky Image -- DIRBE 4.9 micron", "sky"),
32-
new ReservedImage("allsky.fits",
32+
new ReservedImage("allsky/allsky.fits",
3333
"ISSA All Sky Image", "sky")
3434
};
3535

src/firefly/java/edu/caltech/ipac/firefly/server/visualize/VisContext.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
import edu.caltech.ipac.visualize.plot.ImagePlot;
1717

1818
import java.io.File;
19+
import java.util.HashMap;
20+
import java.util.Map;
1921
/**
2022
* User: roby
2123
* Date: Jul 29, 2008
@@ -135,7 +137,35 @@ public static void initCounters() {
135137
}
136138
}
137139

140+
private static final Map<String, String> footprintMap;
141+
static {
142+
footprintMap = new HashMap<String, String>();
143+
footprintMap.put("HST", "footprint/Footprint_HST.reg");
144+
footprintMap.put("HST_NICMOS", "footprint/Footprint_HST.reg");
145+
footprintMap.put("HST_WFPC2", "footprint/Footprint_HST.reg");
146+
footprintMap.put("HST_ACS/WFC", "footprint/Footprint_HST.reg");
147+
footprintMap.put("HST_ACS/HRC", "footprint/Footprint_HST.reg");
148+
footprintMap.put("HST_ACS/SBC", "footprint/Footprint_HST.reg");
149+
footprintMap.put("HST_WFC3/UVIS","footprint/Footprint_HST.reg");
150+
footprintMap.put("HST_WFC3/IR", "footprint/Footprint_HST.reg");
151+
footprintMap.put("JWST", "footprint/Footprint_JWST.reg");
152+
footprintMap.put("JWST_FGS", "footprint/Footprint_JWST.reg");
153+
footprintMap.put("JWST_MIRI", "footprint/Footprint_JWST.reg");
154+
footprintMap.put("JWST_NIRCAM", "footprint/Footprint_JWST.reg");
155+
footprintMap.put("JWST_NIS", "footprint/Footprint_JWST.reg");
156+
footprintMap.put("JWST_NIRSPEC","footprint/Footprint_JWST.reg");
157+
footprintMap.put("SPITZER", "footprint/Footprint_SPITZER.reg" );
158+
footprintMap.put("SPITZER_IRAC36", "footprint/Footprint_SPITZER.reg");
159+
footprintMap.put("SPITZER_IRAC45", "footprint/Footprint_SPITZER.reg");
160+
footprintMap.put("WFIRST", "footprint/Footprint_WFIRST.reg");
161+
}
138162

163+
static public void addFootprint(String key, String path) {
164+
footprintMap.put(key, path);
165+
}
139166

167+
static public String getFootprint(String key) {
168+
return footprintMap.get(key);
169+
}
140170
}
141171

src/firefly/java/edu/caltech/ipac/firefly/server/visualize/VisServerOps.java

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
import static edu.caltech.ipac.visualize.draw.AreaStatisticsUtil.WhichReadout.LEFT;
7676
import static edu.caltech.ipac.visualize.draw.AreaStatisticsUtil.WhichReadout.RIGHT;
7777

78+
7879
/**
7980
* User: roby
8081
* Date: Aug 7, 2008
@@ -1439,40 +1440,18 @@ public static WebPlotResult getDS9Region(String fileKey) {
14391440
return retval;
14401441
}
14411442

1442-
private static final Map<String, String> footprintMap;
1443-
static {
1444-
footprintMap = new HashMap<String, String>();
1445-
footprintMap.put("HST", "Footprint_HST.reg");
1446-
footprintMap.put("HST_NICMOS", "Footprint_HST.reg");
1447-
footprintMap.put("HST_WFPC2", "Footprint_HST.reg");
1448-
footprintMap.put("HST_ACS/WFC", "Footprint_HST.reg");
1449-
footprintMap.put("HST_ACS/HRC", "Footprint_HST.reg");
1450-
footprintMap.put("HST_ACS/SBC", "Footprint_HST.reg");
1451-
footprintMap.put("HST_WFC3/UVIS","Footprint_HST.reg");
1452-
footprintMap.put("HST_WFC3/IR", "Footprint_HST.reg");
1453-
footprintMap.put("JWST", "Footprint_JWST.reg");
1454-
footprintMap.put("JWST_FGS", "Footprint_JWST.reg");
1455-
footprintMap.put("JWST_MIRI", "Footprint_JWST.reg");
1456-
footprintMap.put("JWST_NIRCAM", "Footprint_JWST.reg");
1457-
footprintMap.put("JWST_NIS", "Footprint_JWST.reg");
1458-
footprintMap.put("JWST_NIRSPEC","Footprint_JWST.reg");
1459-
footprintMap.put("SPITZER", "Footprint_SPITZER.reg" );
1460-
footprintMap.put("SPITZER_IRAC36", "Footprint_SPITZER.reg");
1461-
footprintMap.put("SPITZER_IRAC45", "Footprint_SPITZER.reg");
1462-
footprintMap.put("WFIRST", "Footprint_WFIRST.reg");
1463-
}
14641443

14651444
public static WebPlotResult getFootprintRegion(String fpInfo) {
14661445

14671446
List<String> rAsStrList = new ArrayList<String>();
14681447
List<String> msgList = new ArrayList<String>();
14691448
WebPlotResult retval = new WebPlotResult();
1449+
String fileName;
14701450

1471-
if (footprintMap.containsKey(fpInfo)) {
1451+
if ((fileName = (String)VisContext.getFootprint(fpInfo)) != null) {
14721452
int idx = fpInfo.indexOf('_');
14731453

14741454
String tag = idx >= 0 ? fpInfo.substring(idx + 1) : fpInfo;
1475-
String fileName = "edu/caltech/ipac/visualize/resources/" + footprintMap.get(fpInfo);
14761455

14771456
try {
14781457
InputStream in = VisServerOps.class.getClassLoader().getResourceAsStream(fileName);
@@ -1490,6 +1469,8 @@ public static WebPlotResult getFootprintRegion(String fpInfo) {
14901469
} catch (Exception e) {
14911470
retval = createError("on getFootprintRegion", null, e);
14921471
}
1472+
} else {
1473+
msgList.add("no footprint description file is found");
14931474
}
14941475
retval.putResult(WebPlotResult.REGION_DATA,
14951476
new DataEntry.Str(StringUtils.combineStringList(rAsStrList)));

src/firefly/js/drawingLayers/FootprintTool.js

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
import DrawLayerCntlr, {dlRoot, dispatchAttachLayerToPlot,
55
dispatchCreateDrawLayer, getDlAry} from '../visualize/DrawLayerCntlr.js';
66
import {visRoot} from '../visualize/ImagePlotCntlr.js';
7-
import {makeDrawingDef} from '../visualize/draw/DrawingDef.js';
7+
import {makeDrawingDef, TextLocation} from '../visualize/draw/DrawingDef.js';
88
import DrawLayer, {DataTypes, ColorChangeType} from '../visualize/draw/DrawLayer.js';
99
import {MouseState} from '../visualize/VisMouseSync.js';
1010
import {PlotAttribute} from '../visualize/WebPlot.js';
1111
import CsysConverter from '../visualize/CsysConverter.js';
1212
import {primePlot, getDrawLayerById} from '../visualize/PlotViewUtil.js';
1313
import {makeFactoryDef} from '../visualize/draw/DrawLayerFactory.js';
1414
import {MARKER_DISTANCE, ANGLE_UNIT, ROTATE_BOX, OutlineType, findClosestIndex, makeFootprint,
15-
updateFootprintDrawobjAngle, updateFootprintDrawobjText,
15+
lengthSizeUnit, updateFootprintDrawobjAngle, updateFootprintDrawobjText,
1616
updateFootprintTranslate, updateFootprintOutline} from '../visualize/draw/MarkerFootprintObj.js';
1717
import {markerInterval, getCC, getWorldOrImage, cancelTimeoutProcess,} from './MarkerTool.js';
1818
import {getFootprintToolUIComponent} from './FootprintToolUI.jsx';
@@ -50,7 +50,7 @@ export function footprintCreateLayerActionCreator(rawAction) {
5050
if (footprint) {
5151
var footprintDef = '${footprintDef}' + `${footprint}${instrument? '_'+instrument : ''}`;
5252
var isInstrument = !!instrument;
53-
var fpInfo = { footprint, instrument };
53+
var fpInfo = { footprint, instrument};
5454

5555
getDS9Region(footprintDef).then((result) => {
5656
if (has(result, 'RegionData') && result.RegionData.length > 0) {
@@ -211,7 +211,9 @@ export function footprintMoveActionCreator(rawAction) {
211211
var imageCenter = cc.getImageCoords(wpt);
212212

213213
wpt = getWorldOrImage(makeImagePt(imageCenter.x + deltaX, imageCenter.y + deltaY), cc);
214-
move.apt = {x: deltaX, y: deltaY, type: ShapeDataObj.UnitType.IMAGE_PIXEL};
214+
deltaX = lengthSizeUnit(cc, deltaX, ShapeDataObj.UnitType.IMAGE_PIXEL);
215+
deltaY = lengthSizeUnit(cc, deltaY, ShapeDataObj.UnitType.IMAGE_PIXEL);
216+
move.apt = {x: deltaX.len, y: deltaY.len, type: deltaX.unit};
215217

216218
refPt = imagePt;
217219
footprintStatus = FootprintStatus.relocate;
@@ -287,8 +289,14 @@ function getLayerChanges(drawLayer, action) {
287289
case DrawLayerCntlr.FOOTPRINT_MOVE:
288290
case DrawLayerCntlr.FOOTPRINT_END:
289291
var data = get(dd, [DataTypes.DATA, '0']);
290-
var {text, textLoc} = data || {};
292+
var {text = '', textLoc = TextLocation.REGION_SE} = data || {};
291293
var crtFpObj = data || null;
294+
var {footprintStatus} = action.payload;
295+
296+
if (footprintStatus === FootprintStatus.attached ||
297+
footprintStatus === FootprintStatus.attached_relocate) {
298+
text = get(drawLayer, 'title', ''); // title is the default text by the footprint
299+
}
292300

293301
return createFootprintObjs(action, text, textLoc, crtFpObj);
294302

@@ -503,13 +511,15 @@ function getVertexDistance( footprintObj, cc) {
503511

504512
w = lengthToScreenPixel(width, cc, ShapeDataObj.UnitType.IMAGE_PIXEL) / 2;
505513
h = lengthToScreenPixel(height, cc, ShapeDataObj.UnitType.IMAGE_PIXEL) / 2;
514+
dist = ROTATE_BOX;
506515
centerPt = getWorldOrImage(center, cc);
507516
} else {
508517
w = cc.viewPort.dim.width/2;
509518
h = cc.viewPort.dim.height/2;
510519
centerPt = getWorldOrImage(makeViewPortPt(w, h), cc);
520+
dist = 0;
511521
}
512-
dist = Math.sqrt(Math.pow(w, 2) + Math.pow(h, 2)) + ROTATE_BOX*2;
522+
dist += Math.sqrt(Math.pow(w, 2) + Math.pow(h, 2));
513523

514524
return {dist, centerPt};
515525
}

src/firefly/js/drawingLayers/FootprintToolUI.jsx

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import validator from 'validator';
2222
export const getFootprintToolUIComponent = (drawLayer,pv) => <FootprintToolUI drawLayer={drawLayer} pv={pv}/>;
2323
export const defaultFootprintTextLoc = TextLocation.REGION_SE;
2424

25-
const precision = '0[.000000]';
25+
const precision = '0.0';
2626

2727
class FootprintToolUI extends React.Component {
2828
constructor(props) {
@@ -79,7 +79,7 @@ class FootprintToolUI extends React.Component {
7979

8080
if (isNil(fpText) || !fpText) {
8181
var dl = getDrawLayerById(flux.getState()[DRAWING_LAYER_KEY], this.props.drawLayer.drawLayerId);
82-
fpText = '';
82+
fpText = get(dl, '');
8383
this.props.drawLayer.title = get(dl, 'defaultTitle');
8484
} else {
8585
this.props.drawLayer.title = fpText;
@@ -121,7 +121,7 @@ class FootprintToolUI extends React.Component {
121121

122122
const mStyle = {
123123
marginTop: 5
124-
}
124+
};
125125

126126
var textOnLink = `Add ${get(this.state.fpInfo, 'footprint')} ${get(this.state.fpInfo, 'instrument')}`;
127127
var {isValidAngle, angleDeg, fpText, fpTextLoc} = this.state;
@@ -151,19 +151,20 @@ class FootprintToolUI extends React.Component {
151151
message={'invalid angle value'}
152152
label={'Angle:'}
153153
labelWidth={30}
154-
tooltip={'Enter the angle you want the footprint rotated'}
154+
style={{width: 50}}
155+
tooltip={'Enter the angle in degree you want the footprint rotated'}
155156

156157
/>
157158
<div style={mStyle} title={textOnLink}>
158159
<a className='ff-href' style={{textDecoration: 'underline'}}
159160
onClick={()=>addFootprintDrawLayer(this.props.pv, this.state.fpInfo)}>{textOnLink}</a>
160161
</div>
161162
</div>
162-
<div style={{display:'flex', justifyContent: 'flex-start'}}>
163-
<div style={{width:30, paddingLeft:10}}> Center:</div>
163+
<div style={{display:'flex', justifyContent: 'flex-start', paddingLeft:10}}>
164+
<div> Center:</div>
164165
<div style={tStyle}>
165-
{convertWorldLonToString(this.state.currentPt, this.csys)}
166-
{convertWorldLatToString(this.state.currentPt, this.csys)}
166+
{convertWorldLonToString(this.state.currentPt, this.csys) + ', ' +
167+
convertWorldLatToString(this.state.currentPt, this.csys)}
167168
{convertWorldToString(this.state.currentPt, this.csys)}
168169
</div>
169170
</div>
@@ -197,7 +198,7 @@ function convertWorldToString(pt) {
197198
var str = '';
198199
if (!pt) return str;
199200

200-
return `${numeral(pt.x).format(precision)} ${numeral(pt.y).format(precision)}`;
201+
return `${numeral(pt.x).format(precision)}, ${numeral(pt.y).format(precision)}`;
201202
}
202203

203204
function formatAngle(angle) {

src/firefly/js/drawingLayers/MarkerTool.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
import DrawLayerCntlr, {dlRoot, dispatchAttachLayerToPlot,
55
dispatchCreateDrawLayer, getDlAry} from '../visualize/DrawLayerCntlr.js';
66
import {visRoot} from '../visualize/ImagePlotCntlr.js';
7-
import {makeDrawingDef} from '../visualize/draw/DrawingDef.js';
7+
import {makeDrawingDef, TextLocation} from '../visualize/draw/DrawingDef.js';
88
import DrawLayer, {DataTypes,ColorChangeType} from '../visualize/draw/DrawLayer.js';
99
import {MouseState} from '../visualize/VisMouseSync.js';
1010
import {PlotAttribute} from '../visualize/WebPlot.js';
1111
import CsysConverter from '../visualize/CsysConverter.js';
1212
import {primePlot, getDrawLayerById} from '../visualize/PlotViewUtil.js';
1313
import {makeFactoryDef} from '../visualize/draw/DrawLayerFactory.js';
1414
import {makeMarker, findClosestIndex, updateFootprintTranslate, updateMarkerSize,
15-
updateFootprintDrawobjText, updateFootprintOutline,
15+
updateFootprintDrawobjText, updateFootprintOutline, lengthSizeUnit,
1616
MARKER_DISTANCE, OutlineType} from '../visualize/draw/MarkerFootprintObj.js';
1717
import {getMarkerToolUIComponent} from './MarkerToolUI.jsx';
1818
import {getDrawobjArea} from '../visualize/draw/ShapeHighlight.js';
@@ -186,7 +186,11 @@ export function markerToolMoveActionCreator(rawAction) {
186186
dy = imagePt.y - refPt.y;
187187
refPt = imagePt;
188188
wpt = getWorldOrImage(makeImagePt(imageCenter.x + dx, imageCenter.y + dy), cc);
189-
move.apt = {x: dx, y: dy, type: ShapeDataObj.UnitType.IMAGE_PIXEL};
189+
190+
dx = lengthSizeUnit(cc, dx, ShapeDataObj.UnitType.IMAGE_PIXEL);
191+
dy = lengthSizeUnit(cc, dy, ShapeDataObj.UnitType.IMAGE_PIXEL);
192+
move.apt = {x: dx.len, y: dy.len, type: dx.unit};
193+
190194
markerStatus = MarkerStatus.relocate;
191195
isHandle = {isOutline: true, isResize: true};
192196
}
@@ -256,8 +260,14 @@ function getLayerChanges(drawLayer, action) {
256260
case DrawLayerCntlr.MARKER_MOVE:
257261
case DrawLayerCntlr.MARKER_END:
258262
var data = get(dd, [DataTypes.DATA, '0']);
259-
var {text, textLoc} = data || {};
263+
var {text = '', textLoc = TextLocation.REGION_SE} = data || {};
260264
var crtMarkerObj = data || null;
265+
var {markerStatus} = action.payload;
266+
267+
if (markerStatus === MarkerStatus.attached ||
268+
markerStatus === MarkerStatus.attached_relocate) {
269+
text = get(drawLayer, 'title', ''); // title is the default text by the footprint
270+
}
261271

262272
return createMarkerObjs(action, text, textLoc, crtMarkerObj);
263273

src/firefly/js/visualize/draw/MarkerFootprintObj.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ const screenUnit = ShapeDataObj.UnitType.PIXEL;
8888
* @param unitType
8989
* @returns {{length: *, unit: *}}
9090
*/
91-
function lengthSizeUnit(cc, size, unitType) {
91+
export function lengthSizeUnit(cc, size, unitType) {
9292
var len, unit;
9393

9494
if (cc.projection.isSpecified()) {
@@ -341,7 +341,7 @@ export default {
341341
};
342342

343343

344-
var getMarkerAngleInRad = (obj) => {
344+
export var getMarkerAngleInRad = (obj) => {
345345
var {angle = 0.0, angleUnit = ANGLE_UNIT.radian} = obj;
346346

347347
return convertAngle(angleUnit.key, 'radian', angle);
@@ -945,9 +945,15 @@ function updateColorFromDef(oneDrawObj, def) {
945945
* @param cc
946946
*/
947947
function computeRotAngleOnPlot(drawObj, cc) {
948+
if (!get(drawObj, 'isRotable', false)) {
949+
drawObj.plotImageId = cc.plotImageId;
950+
return;
951+
}
952+
948953
var crtObjAry = drawObj.drawObjAry.slice(0, drawObj.outlineIndex);
949954
var orgObjAry = FootprintFactory.getDrawObjFromOriginalRegion(drawObj.regions, drawObj.pts[0],
950-
drawObj.regions[0].isInstrument);
955+
drawObj.regions[0].isInstrument);
956+
951957
var crtPt = cc.getImageCoords(crtObjAry[0].pts[0]);
952958
var orgPt = cc.getImageCoords(orgObjAry[0].pts[0]);
953959
var cImg = cc.getImageCoords(drawObj.pts[0]);
@@ -1013,7 +1019,7 @@ export function drawMarkerObject(drawObjP, ctx, drawTextAry, plot, def, vpPtM, o
10131019
drawObj.drawObjAry = drawObjP.drawObjAry.map( (obj) => Object.assign({}, obj) );
10141020

10151021
// draw the same objects on multiple plots
1016-
if (get(drawObj, 'plotImageId') !== plot.plotImageId) {
1022+
if (get(drawObj, 'plotImageId') !== plot.plotImageId && get(drawObj, 'isRotable', false)) {
10171023
computeRotAngleOnPlot(drawObj, plot); // chenge footprint object internal plot related numbers
10181024
}
10191025

@@ -1058,7 +1064,9 @@ function drawFootprintText(drawObj, plot, def, drawTextAry) {
10581064
drawObj.drawObjAry[drawObj.outlineIndex] :
10591065
(updateHandle(drawObj, plot, []))[0];
10601066

1061-
if (!outlineObj || outlineObj.outlineType === OutlineType.plotcenter) return;
1067+
// if (!outlineObj || outlineObj.outlineType === OutlineType.plotcenter) return;
1068+
1069+
if (!outlineObj) return;
10621070

10631071
var objArea = getObjArea(outlineObj, plot); // in image coordinate
10641072

0 commit comments

Comments
 (0)