Skip to content

Commit c58d3be

Browse files
committed
DM-8579: a little more cleanup
- removed support for gif tiles - more java 7 updates - removed unnecessary paramters - bug fix: stretch not passing parameters correctly - bug fix: cube parameter not being placed into state properly - clean up from comments
1 parent fb25928 commit c58d3be

29 files changed

+276
-1906
lines changed

src/firefly/java/edu/caltech/ipac/firefly/server/rpc/JsonDataCommands.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
/*
2-
* License information at https://github.com/Caltech-IPAC/firefly/blob/master/License.txt
3-
*/
4-
51
/*
62
* License information at https://github.com/Caltech-IPAC/firefly/blob/master/License.txt
73
*/

src/firefly/java/edu/caltech/ipac/firefly/server/rpc/PlotServiceImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public WebPlotResult[] getWebPlotGroup(List<WebPlotRequest> requestList, String
134134
}
135135

136136
public WebPlotResult[] getOneFileGroup(List<WebPlotRequest> requestList, String progressKey) {
137-
return VisServerOps.createOneFileGroup(requestList,progressKey);
137+
return VisServerOps.createOneFileGroup(requestList);
138138
}
139139

140140
public WebPlotResult getWebPlot(WebPlotRequest request){

src/firefly/java/edu/caltech/ipac/firefly/server/rpc/PushCommands.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
* License information at https://github.com/Caltech-IPAC/firefly/blob/master/License.txt
33
*/
44

5-
/*
6-
* License information at https://github.com/Caltech-IPAC/firefly/blob/master/License.txt
7-
*/
8-
95
/*
106
* License information at https://github.com/Caltech-IPAC/firefly/blob/master/License.txt
117
*/

src/firefly/java/edu/caltech/ipac/firefly/server/rpc/VisServerCommands.java

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ public String doCommand(Map<String, String[]> paramMap) throws IllegalArgumentEx
181181
List<WebPlotRequest> reqList= sp.getRequestList();
182182
WebPlotResult resultAry[] = VisServerOps.createPlotGroup(reqList,key);
183183

184-
return WebPlotResultSerializer.createJson(resultAry, sp.isJsonDeep());
184+
return WebPlotResultSerializer.createJson(resultAry);
185185
}
186186
}
187187

@@ -207,18 +207,15 @@ public String doCommand(Map<String, String[]> paramMap) throws IllegalArgumentEx
207207
SrvParam sp= new SrvParam(paramMap);
208208
PlotState state= sp.getState();
209209
boolean jsonDeep= sp.getOptionalBoolean(ServerParams.JSON_DEEP,false);
210-
List<StretchData> list = new ArrayList<StretchData>(3);
210+
List<StretchData> list = new ArrayList<>(3);
211211

212212
StretchData sd;
213-
// sd = StretchData.parse(sp.getOptional(ServerParams.STRETCH_DATA + "0"));
214213
sd= VisJsonSerializer.deserializeStretchDataFromString(
215214
sp.getOptional(ServerParams.STRETCH_DATA + "0"),jsonDeep);
216215
if (sd != null) list.add(sd);
217216
sd= VisJsonSerializer.deserializeStretchDataFromString(
218217
sp.getOptional(ServerParams.STRETCH_DATA + "1"),jsonDeep);
219-
// sd = StretchData.parse(sp.getOptional(ServerParams.STRETCH_DATA + "1"));
220218
if (sd != null) list.add(sd);
221-
// sd = StretchData.parse(sp.getOptional(ServerParams.STRETCH_DATA + "2"));
222219
sd= VisJsonSerializer.deserializeStretchDataFromString(
223220
sp.getOptional(ServerParams.STRETCH_DATA + "2"),jsonDeep);
224221
if (sd != null) list.add(sd);
@@ -353,7 +350,7 @@ public String doCommand(Map<String, String[]> paramMap) throws IllegalArgumentEx
353350
List<StaticDrawInfo> drawInfoList;
354351
try {
355352
if (drawInfoStrAry != null && drawInfoStrAry.length > 0) {
356-
drawInfoList = new ArrayList<StaticDrawInfo>(drawInfoStrAry.length);
353+
drawInfoList = new ArrayList<>(drawInfoStrAry.length);
357354
for (String s : drawInfoStrAry) {
358355
StaticDrawInfo drawInfo = StaticDrawInfo.parse(s);
359356
if (s != null) drawInfoList.add(drawInfo);
@@ -512,10 +509,6 @@ public String doCommand(Map<String, String[]> paramMap) throws IllegalArgumentEx
512509
}
513510
}
514511

515-
//=============================================
516-
//-------------- Utility Methods --------------
517-
//=============================================
518-
519512

520513
}
521514

src/firefly/java/edu/caltech/ipac/firefly/server/servlets/ImageDownload.java

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,12 @@
1212
import edu.caltech.ipac.firefly.visualize.PlotState;
1313
import edu.caltech.ipac.util.FileUtil;
1414
import edu.caltech.ipac.util.download.URLDownload;
15-
import nom.tam.fits.FitsException;
1615

1716
import javax.servlet.ServletException;
1817
import javax.servlet.ServletOutputStream;
1918
import javax.servlet.http.HttpServletRequest;
2019
import javax.servlet.http.HttpServletResponse;
2120
import java.io.File;
22-
import java.io.IOException;
2321
import java.text.SimpleDateFormat;
2422
import java.util.TimeZone;
2523

@@ -31,11 +29,11 @@
3129
*/
3230
public class ImageDownload extends BaseHttpServlet {
3331

34-
public static final boolean ENABLE_CACHE= true;
35-
public static final String TYPE_TILE= "tile";
36-
public static final String TYPE_FULL= "full";
37-
public static final String TYPE_THUMBNAIL= "thumbnail";
38-
public static final String TYPE_ANY = "any";
32+
private static final boolean ENABLE_CACHE= true;
33+
private static final String TYPE_TILE= "tile";
34+
private static final String TYPE_FULL= "full";
35+
private static final String TYPE_THUMBNAIL= "thumbnail";
36+
private static final String TYPE_ANY = "any";
3937
private static final int MAX_AGE= 86400; // 1 day in seconds
4038
private static final SimpleDateFormat _dateFormatter=new SimpleDateFormat(URLDownload.PATTERN_RFC1123);
4139

@@ -50,11 +48,9 @@ protected void processRequest(HttpServletRequest req, HttpServletResponse res) t
5048
String widthStr= req.getParameter("width");
5149
String heightStr= req.getParameter("height");
5250
String stateStr= req.getParameter("state");
53-
// PlotState state= PlotState.parse(stateStr);
5451
PlotState state= VisJsonSerializer.deserializePlotStateFromString(stateStr);
5552

5653
if (type==null) type= TYPE_ANY;
57-
ActiveCallCtx ctx= null;
5854
try {
5955

6056
String fname= getFileName(req);
@@ -65,6 +61,7 @@ protected void processRequest(HttpServletRequest req, HttpServletResponse res) t
6561

6662
ServletOutputStream out= res.getOutputStream();
6763

64+
ActiveCallCtx ctx;
6865
if (type.equals(TYPE_TILE)) {
6966
if (isNonMatch(fname,req)) {
7067
int x= Integer.parseInt(xStr);
@@ -106,10 +103,6 @@ else if (type.equals(TYPE_FULL)) {
106103
File f= ServerContext.convertToFile(fname);
107104
FileUtil.writeFileToStream(f,out);
108105
}
109-
} catch (IOException e) {
110-
throw new ServletException(e.toString(),e);
111-
} catch (FitsException e) {
112-
throw new ServletException(e.toString(),e);
113106
} catch (Exception e) {
114107
throw new ServletException(e.toString(),e);
115108
}

src/firefly/java/edu/caltech/ipac/firefly/server/servlets/PlotFileService.java

Lines changed: 0 additions & 72 deletions
This file was deleted.

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@
33
*/
44

55
package edu.caltech.ipac.firefly.server.visualize;
6-
/**
7-
* User: roby
8-
* Date: 5/7/15
9-
* Time: 1:16 PM
10-
*/
116

127

138
import edu.caltech.ipac.firefly.server.Counters;
@@ -86,7 +81,7 @@ public static ActiveCallCtx prepare(PlotState state) throws FailedRequestExcepti
8681

8782

8883
private static ActiveCallCtx revalidatePlot(PlotClientCtx ctx) {
89-
ActiveCallCtx retval= null;
84+
ActiveCallCtx retval;
9085
synchronized (ctx) { // keep the test from happening at the same time with this ctx
9186
try {
9287
ImagePlot plot= ctx.getCachedPlot();

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public static void addFitsReadToCache(File fitsFile, FitsRead frAry[]) {
120120
addFitsReadToCache(fitsFile.getPath(), frAry);
121121
}
122122

123-
static void addFitsReadToCache(String fitsFilePath, FitsRead frAry[]) {
123+
private static void addFitsReadToCache(String fitsFilePath, FitsRead frAry[]) {
124124
File f= ServerContext.convertToFile(fitsFilePath,true);
125125
if (f!=null) {
126126
CacheKey key= new StringKey(fitsFilePath);

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

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,6 @@ public static SimpleResults create(WebPlotRequest wpr) throws FailedRequestExcep
4545
return (retList!=null && retList.size()>0) ? retList.get(0) : null;
4646
}
4747

48-
// public static List<ImagePlot> createList(WebPlotRequest wpr)
49-
// throws FailedRequestException, GeomException {
50-
// return createList(wpr, PlotState.MultiImageAction.USE_ALL);
51-
// }
52-
5348
public static SimpleResults create3Color(WebPlotRequest redRequest,
5449
WebPlotRequest greenRequest,
5550
WebPlotRequest blueRequest) throws FailedRequestException, GeomException {
@@ -61,7 +56,7 @@ public static SimpleResults create3Color(WebPlotRequest redRequest,
6156
if (blueRequest != null) requestMap.put(BLUE, blueRequest);
6257

6358
try {
64-
Results allPlots= build(null, requestMap, PlotState.MultiImageAction.USE_FIRST,
59+
Results allPlots= build(requestMap, PlotState.MultiImageAction.USE_FIRST,
6560
null, true);
6661
ImagePlotInfo piAry[]= allPlots.getPlotInfoAry();
6762
if (piAry!=null && piAry.length>0) retval= new SimpleResults(piAry[0].getPlot(), piAry[0].getFrGroup());
@@ -77,8 +72,6 @@ public static SimpleResults create3Color(WebPlotRequest redRequest,
7772
}
7873

7974

80-
81-
8275
private static List<SimpleResults> createList(WebPlotRequest wpr, PlotState.MultiImageAction multiAction)
8376
throws FailedRequestException, GeomException {
8477
wpr.setProgressKey(null); // this just makes sure in update progress caching does not happen
@@ -87,7 +80,7 @@ private static List<SimpleResults> createList(WebPlotRequest wpr, PlotState.Mult
8780
try {
8881
Map<Band, WebPlotRequest> requestMap = new LinkedHashMap<>(2);
8982
requestMap.put(NO_BAND, wpr);
90-
Results allPlots= build(null, requestMap, multiAction, null, false);
83+
Results allPlots= build(requestMap, multiAction, null, false);
9184
for(ImagePlotInfo pi : allPlots.getPlotInfoAry()) retList.add(new SimpleResults(pi.getPlot(),pi.getFrGroup()));
9285
} catch (FailedRequestException e) {
9386
throw new FailedRequestException("Could not create plot. " + e.getMessage(), e.getDetailMessage());
@@ -99,8 +92,7 @@ private static List<SimpleResults> createList(WebPlotRequest wpr, PlotState.Mult
9992
return retList;
10093
}
10194

102-
static Results build(String workingCtxStr,
103-
Map<Band, WebPlotRequest> requestMap,
95+
static Results build(Map<Band, WebPlotRequest> requestMap,
10496
PlotState.MultiImageAction multiAction,
10597
PlotState state,
10698
boolean threeColor) throws Exception {
@@ -123,7 +115,7 @@ static Results build(String workingCtxStr,
123115
// ------------ make the ImagePlot(s)
124116
ZoomChoice zoomChoice = makeZoomChoice(requestMap, readInfoMap);
125117
if (state == null) {
126-
pInfo = makeNewPlots(workingCtxStr, readInfoMap, requestMap, zoomChoice, multiAction, threeColor);
118+
pInfo = makeNewPlots(readInfoMap, requestMap, zoomChoice, multiAction, threeColor);
127119
} else {
128120
pInfo = new ImagePlotInfo[1];
129121
pInfo[0] = recreatePlot(state, readInfoMap, zoomChoice);
@@ -145,7 +137,6 @@ static Results buildFromFile(WebPlotRequest request,
145137
PlotServUtils.updateProgress(request, ProgressStat.PType.CREATING,
146138
PlotServUtils.CREATING_MSG);
147139
long readElapse = System.currentTimeMillis() - readStart;
148-
// VisContext.shouldContinue(workingCtxStr);
149140

150141

151142
Map<Band, FileReadInfo[]> readInfoMap = WebPlotReader.processFitsRead(fileData,request,fitsRead,imageIdx);
@@ -156,8 +147,7 @@ static Results buildFromFile(WebPlotRequest request,
156147
// ------------ make the ImagePlot(s)
157148
ZoomChoice zoomChoice = makeZoomChoice(requestMap, readInfoMap);
158149
if (state == null) {
159-
pInfo = makeNewPlots(null, readInfoMap, requestMap, zoomChoice, PlotState.MultiImageAction.USE_FIRST, false);
160-
// VisContext.shouldContinue(workingCtxStr);
150+
pInfo = makeNewPlots(readInfoMap, requestMap, zoomChoice, PlotState.MultiImageAction.USE_FIRST, false);
161151
} else {
162152
pInfo = new ImagePlotInfo[1];
163153
pInfo[0] = recreatePlot(state, readInfoMap, zoomChoice);
@@ -180,7 +170,7 @@ static private ImagePlotInfo recreatePlot(PlotState state,
180170
IOException,
181171
FitsException,
182172
GeomException {
183-
return ImagePlotCreator.makeOneImagePerBand(null, state, readInfoMap, zoomChoice);
173+
return ImagePlotCreator.makeOneImagePerBand(state, readInfoMap, zoomChoice);
184174
}
185175

186176

@@ -240,8 +230,7 @@ private static Map<Band, FileData> findFiles(Map<Band, WebPlotRequest> requestMa
240230
* @throws FitsException error creating the fits data
241231
* @throws GeomException on geom error
242232
*/
243-
private static ImagePlotInfo[] makeNewPlots(String workingCtxStr,
244-
Map<Band, FileReadInfo[]> readInfoMap,
233+
private static ImagePlotInfo[] makeNewPlots(Map<Band, FileReadInfo[]> readInfoMap,
245234
Map<Band, WebPlotRequest> requestMap,
246235
ZoomChoice zoomChoice,
247236
PlotState.MultiImageAction multiAction,
@@ -256,7 +245,7 @@ private static ImagePlotInfo[] makeNewPlots(String workingCtxStr,
256245

257246
switch (multiAction) {
258247
case GUESS:
259-
plotInfo = makeNewPlots(workingCtxStr, readInfoMap, requestMap, zoomChoice,
248+
plotInfo = makeNewPlots(readInfoMap, requestMap, zoomChoice,
260249
getActionGuess(threeColor), threeColor);
261250
break;
262251
case USE_FIRST:
@@ -266,7 +255,7 @@ private static ImagePlotInfo[] makeNewPlots(String workingCtxStr,
266255
state.setOriginalImageIdx(0, band);
267256
state.setImageIdx(0, band);
268257
}
269-
plotInfo[0] = ImagePlotCreator.makeOneImagePerBand(workingCtxStr, state, readInfoMap, zoomChoice);
258+
plotInfo[0] = ImagePlotCreator.makeOneImagePerBand(state, readInfoMap, zoomChoice);
270259
break;
271260
case USE_IDX:
272261
WebPlotRequest r= requestMap.get(NO_BAND);
@@ -276,15 +265,15 @@ private static ImagePlotInfo[] makeNewPlots(String workingCtxStr,
276265
state.setImageIdx(idx, NO_BAND);
277266
state.setMultiImageFile(true,Band.NO_BAND);
278267
//todo: here
279-
plotInfo[0] = ImagePlotCreator.makeOneImagePerBand(workingCtxStr, state, readInfoMap, zoomChoice);
268+
plotInfo[0] = ImagePlotCreator.makeOneImagePerBand(state, readInfoMap, zoomChoice);
280269
break;
281270
case USE_ALL:
282271
if (!readInfoMap.containsKey(NO_BAND) || threeColor) {
283272
throw new FailedRequestException("Cannot create plot",
284273
"Cannot yet use the MultiImageAction.USE_ALL action with three color");
285274
}
286275
PlotState stateAry[] = makeNoBandMultiImagePlotState(requestMap.get(NO_BAND), readInfoMap.get(NO_BAND));
287-
plotInfo = ImagePlotCreator.makeAllNoBand(workingCtxStr, stateAry, readInfoMap.get(NO_BAND), zoomChoice);
276+
plotInfo = ImagePlotCreator.makeAllNoBand(stateAry, readInfoMap.get(NO_BAND), zoomChoice);
288277
break;
289278
case MAKE_THREE_COLOR:
290279
if (threeColor && readInfoMap.containsKey(NO_BAND)) { // this handles the case of one file with multiple images becoming three color
@@ -299,7 +288,7 @@ private static ImagePlotInfo[] makeNewPlots(String workingCtxStr,
299288
}
300289
}
301290
state = make3ColorState(requestMap, readInfoMap, multiAction);
302-
plotInfo[0] = ImagePlotCreator.makeOneImagePerBand(workingCtxStr, state, readInfoMap, zoomChoice);
291+
plotInfo[0] = ImagePlotCreator.makeOneImagePerBand(state, readInfoMap, zoomChoice);
303292
break;
304293
default:
305294
throw new FailedRequestException("Plot creation failed", "unknown multiAction, don't know how to create plot");

0 commit comments

Comments
 (0)