ref 17249: Save produced charts as report

https://support.d4science.org/issues/17249

Added PDF support for Scatter
This commit is contained in:
Giancarlo Panichi 2020-05-25 22:08:17 +02:00
parent 9177c518d1
commit 6d9089fb12
7 changed files with 302 additions and 124 deletions

View File

@ -48,15 +48,13 @@ public class BoxPlotAnnualPanelResult {
private PerformFishAnnualAnalyticsViewController viewAnnualController; private PerformFishAnnualAnalyticsViewController viewAnnualController;
private int outputIteration = 0; private int outputIteration = 0;
private int outputNumber = 2; private int outputNumber = 2;
private int requestId=0; private int requestId = 0;
public BoxPlotAnnualPanelResult(int reqId, PerformFishAnnualAnalyticsViewController viewAnnualController, public BoxPlotAnnualPanelResult(int reqId, PerformFishAnnualAnalyticsViewController viewAnnualController,
PerformFishResponse thePerformFishResponse, PerformFishResponse thePerformFishResponse, final DataMinerAlgorithms algorithm, String focusID,
final DataMinerAlgorithms algorithm, String focusID, List<KPI> inputKPI, final List<KPI> outputKPI) { List<KPI> inputKPI, final List<KPI> outputKPI) {
GWT.log("RequestID: "+reqId); GWT.log("RequestID: " + reqId);
requestId=reqId; requestId = reqId;
this.viewAnnualController = viewAnnualController; this.viewAnnualController = viewAnnualController;
TextResource algDescr = PerformFishResources.INSTANCE.farm_BOXPLOT(); TextResource algDescr = PerformFishResources.INSTANCE.farm_BOXPLOT();
@ -93,7 +91,7 @@ public class BoxPlotAnnualPanelResult {
oIteration++; oIteration++;
String title = "KPI: " + kpi.getName(); String title = "KPI: " + kpi.getName();
HTML toBigTitle = new HTML(title); HTML toBigTitle = new HTML(title);
toBigTitle.getElement().setId("KPI_BoxPlotAnnual_"+requestId+"_"+oIteration); toBigTitle.getElement().setId("KPI_BoxPlotAnnual_" + requestId + "_" + oIteration);
toBigTitle.getElement().addClassName("to-big-title"); toBigTitle.getElement().addClassName("to-big-title");
submitRequestPanel.addWidget(toBigTitle); submitRequestPanel.addWidget(toBigTitle);
HorizontalPanel hp = new HorizontalPanel(); HorizontalPanel hp = new HorizontalPanel();
@ -106,7 +104,7 @@ public class BoxPlotAnnualPanelResult {
submitRequestPanel.addWidget(hp); submitRequestPanel.addWidget(hp);
} }
outputIteration = oIteration; outputIteration = oIteration;
GWT.log("outputInteration: "+outputIteration); GWT.log("outputInteration: " + outputIteration);
} }
/** /**
@ -120,11 +118,12 @@ public class BoxPlotAnnualPanelResult {
* the panel * the panel
* @param tab * @param tab
* the tab * the tab
* @param tabDescr * @param tabDescr
* @param tabTitle * @param tabTitle
*/ */
private void callDataMinerServiceForChart(final DataMinerInputParameters dmInputParameters, private void callDataMinerServiceForChart(final DataMinerInputParameters dmInputParameters,
final SubmitRequestPanel requestPanel, final ComplexPanel panelContainer, final Tab tab, final int oIteration) { final SubmitRequestPanel requestPanel, final ComplexPanel panelContainer, final Tab tab,
final int oIteration) {
GWT.log("Building DM request with input parameters: " + dmInputParameters); GWT.log("Building DM request with input parameters: " + dmInputParameters);
@ -210,7 +209,7 @@ public class BoxPlotAnnualPanelResult {
GWT.log("I'm displaying: " + dmResponse); GWT.log("I'm displaying: " + dmResponse);
displayOutputFilesAsStaticEntities(dmResponse, dmInputParameters.getChartType(), displayOutputFilesAsStaticEntities(dmResponse, dmInputParameters.getChartType(),
dmInputParameters.getInputKPI(), dmInputParameters.getOutputKPI(), dmInputParameters.getInputKPI(), dmInputParameters.getOutputKPI(),
dmInputParameters.getFocusID(), panelContainer, false,oIteration); dmInputParameters.getFocusID(), panelContainer, false, oIteration);
} }
@Override @Override
@ -219,13 +218,12 @@ public class BoxPlotAnnualPanelResult {
checkTabSpinner(requestPanel, tab); checkTabSpinner(requestPanel, tab);
displayOutputFilesAsStaticEntities(null, dmInputParameters.getChartType(), displayOutputFilesAsStaticEntities(null, dmInputParameters.getChartType(),
dmInputParameters.getInputKPI(), dmInputParameters.getOutputKPI(), dmInputParameters.getInputKPI(), dmInputParameters.getOutputKPI(),
dmInputParameters.getFocusID(), panelContainer, true,oIteration); dmInputParameters.getFocusID(), panelContainer, true, oIteration);
} }
}); });
} }
/** /**
* Append DM input table. * Append DM input table.
* *
@ -248,26 +246,20 @@ public class BoxPlotAnnualPanelResult {
return dataInputsFormatter; return dataInputsFormatter;
} }
private String getOutputId(int oIteration, String title) {
private String getOutputId(int oIteration, String title){
if (title.startsWith("My")) { if (title.startsWith("My")) {
return null; return null;
} else if (title.startsWith("All")) { } else if (title.startsWith("All")) {
String outputId = "OutputId_" + requestId+"_"+oIteration + "_" + 1; String outputId = "OutputId_" + requestId + "_" + oIteration + "_" + 1;
return outputId; return outputId;
} else { } else {
String outputId = "OutputId_" + requestId+"_"+oIteration + "_" + 2; String outputId = "OutputId_" + requestId + "_" + oIteration + "_" + 2;
return outputId; return outputId;
} }
}
}
private void displayOutputFilesAsStaticEntities(final DataMinerResponse dmResponse, private void displayOutputFilesAsStaticEntities(final DataMinerResponse dmResponse,
final DataMinerAlgorithms chartType, List<KPI> inputKPIs, List<KPI> outputKPIs, final String focusID, final DataMinerAlgorithms chartType, List<KPI> inputKPIs, List<KPI> outputKPIs, final String focusID,
final Panel container, boolean displayError, final int oIteration) { final Panel container, boolean displayError, final int oIteration) {
@ -286,10 +278,10 @@ public class BoxPlotAnnualPanelResult {
final String toTitle = title; final String toTitle = title;
for (OutputFile outputFile : dmResponse.getListOutput()) { for (OutputFile outputFile : dmResponse.getListOutput()) {
final FileContentType fileContentType= outputFile.getDataType(); final FileContentType fileContentType = outputFile.getDataType();
switch (outputFile.getDataType()) { switch (outputFile.getDataType()) {
case IMAGE: case IMAGE:
PerformFishAnalyticsServiceAsync.Util.getInstance().getImageFile(outputFile, PerformFishAnalyticsServiceAsync.Util.getInstance().getImageFile(outputFile,
new AsyncCallback<String>() { new AsyncCallback<String>() {
@ -309,17 +301,17 @@ public class BoxPlotAnnualPanelResult {
title = chartType.getTitle() + " - on all farm data<br>"; title = chartType.getTitle() + " - on all farm data<br>";
title += "Blue dots indicate the selected farm: " + focusID; title += "Blue dots indicate the selected farm: " + focusID;
String outputId=getOutputId(oIteration,title); String outputId = getOutputId(oIteration, title);
ShowResult showResult = new ShowResult(outputId, title, fileContentType); ShowResult showResult = new ShowResult(outputId, title, fileContentType);
showResult.showImage(base64Content); showResult.showImage(base64Content);
displayingOrderedBoxPlot(dmResponse, title, container, showResult); displayingOrderedBoxPlot(dmResponse, title, container, showResult);
} }
}); });
break; break;
case CSV: case CSV:
PerformFishAnalyticsServiceAsync.Util.getInstance().getCSVFile(outputFile, true, PerformFishAnalyticsServiceAsync.Util.getInstance().getCSVFile(outputFile, true,
new AsyncCallback<CSVFile>() { new AsyncCallback<CSVFile>() {
@ -338,7 +330,7 @@ public class BoxPlotAnnualPanelResult {
String cssTableStyle = "simpletable"; String cssTableStyle = "simpletable";
String title = toTitle; String title = toTitle;
if (result.getFileName().contains("_user")) { if (result.getFileName().contains("_user")) {
title = "My Batch(es)"; title = "My Batch(es)";
return; return;
@ -347,13 +339,12 @@ public class BoxPlotAnnualPanelResult {
} }
title += "<br>"; title += "<br>";
title += "Data aggregation is performed by considering farms as base units"; title += "Data aggregation is performed by considering farms as base units";
String outputId = getOutputId(oIteration, title);
String outputId=getOutputId(oIteration,title);
ShowResult showResult = new ShowResult(outputId, title, fileContentType); ShowResult showResult = new ShowResult(outputId, title, fileContentType);
showResult.showCSVFile(result, cssTableStyle); showResult.showCSVFile(result, cssTableStyle);
displayingOrderedBoxPlot(dmResponse, title, container, showResult); displayingOrderedBoxPlot(dmResponse, title, container, showResult);
} }
}); });
break; break;
@ -363,7 +354,7 @@ public class BoxPlotAnnualPanelResult {
} }
} }
} }
private void displayingOrderedBoxPlot(final DataMinerResponse dmResponse, String title, final Panel container, private void displayingOrderedBoxPlot(final DataMinerResponse dmResponse, String title, final Panel container,
@ -466,12 +457,20 @@ public class BoxPlotAnnualPanelResult {
yPos += 2; yPos += 2;
pdoc.setFontSize(14); pdoc.setFontSize(14);
pdoc.setFontType("bold"); pdoc.setFontType("bold");
pdoc.text(kpiName.textContent, xPos, yPos, 'left');
var kpiText = kpiName.textContent;
var kpiHeight = pdoc.getLineHeight(kpiText)
/ pdoc.internal.scaleFactor;
var splittedKpiName = pdoc.splitTextToSize(kpiText, (pdfWidthInMM
- lMargin - rMargin));
var kpiLines = splittedKpiName.length; // splitted text is a string array
var kpiLinesHeight = kpiLines * kpiHeight;
pdoc.text(splittedKpiName, xPos, yPos, 'left');
yPos += kpiLinesHeight;
yPos += 6; yPos += 6;
pdoc.setFontSize(10); pdoc.setFontSize(10);
pdoc.setFontType("normal"); pdoc.setFontType("normal");
for (var j = 1; j <= outputNumber; j++) { for (var j = 1; j <= outputNumber; j++) {
@ -502,7 +501,7 @@ public class BoxPlotAnnualPanelResult {
pdoc.text(titleCurrentTable.textContent, xPos, yPos, pdoc.text(titleCurrentTable.textContent, xPos, yPos,
'left'); 'left');
yPos += 6; yPos += 6;
pdoc.setFontSize(10); pdoc.setFontSize(10);
pdoc.setFontType("normal"); pdoc.setFontType("normal");
@ -536,10 +535,9 @@ public class BoxPlotAnnualPanelResult {
pdoc.text(titleCurrentImage.textContent, xPos, pdoc.text(titleCurrentImage.textContent, xPos,
yPos, 'left'); yPos, 'left');
yPos += 6; yPos += 6;
pdoc.setFontSize(10); pdoc.setFontSize(10);
pdoc.setFontType("normal"); pdoc.setFontType("normal");
var secondDiv = childrenTable[0].rows[1].cells[0]; var secondDiv = childrenTable[0].rows[1].cells[0];
var imageElement = secondDiv.getElementsByTagName( var imageElement = secondDiv.getElementsByTagName(
@ -588,5 +586,4 @@ public class BoxPlotAnnualPanelResult {
}-*/; }-*/;
} }

View File

@ -36,6 +36,7 @@ import com.google.gwt.resources.client.TextResource;
import com.google.gwt.user.client.Window; import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.ComplexPanel; import com.google.gwt.user.client.ui.ComplexPanel;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HorizontalPanel; import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Panel; import com.google.gwt.user.client.ui.Panel;
@ -43,17 +44,16 @@ public class ScatterAnnualPanelResult {
private PerformFishAnnualAnalyticsViewController viewAnnualController; private PerformFishAnnualAnalyticsViewController viewAnnualController;
private int requestId; private int requestId;
private int outputIteration = 0; private int outputIteration = 1;
private int outputNumber = 0; private int outputNumber = 1;
public ScatterAnnualPanelResult(int reqId, PerformFishAnnualAnalyticsViewController viewAnnualController, public ScatterAnnualPanelResult(int reqId, PerformFishAnnualAnalyticsViewController viewAnnualController,
PerformFishResponse thePerformFishResponse, final DataMinerAlgorithms algorithm, String focusID, PerformFishResponse thePerformFishResponse, final DataMinerAlgorithms algorithm, String focusID,
List<KPI> inputKPI, final List<KPI> outputKPI) { List<KPI> inputKPI, final List<KPI> outputKPI) {
GWT.log("RequestID: "+reqId); GWT.log("RequestID: " + reqId);
requestId=reqId; requestId = reqId;
this.viewAnnualController = viewAnnualController; this.viewAnnualController = viewAnnualController;
TextResource algDescr = PerformFishResources.INSTANCE.farm_SCATTER(); TextResource algDescr = PerformFishResources.INSTANCE.farm_SCATTER();
String algDesrTxt = algDescr != null ? algDescr.getText() : null; String algDesrTxt = algDescr != null ? algDescr.getText() : null;
// TODO // TODO
@ -61,6 +61,7 @@ public class ScatterAnnualPanelResult {
final String tabDescr = algDesrTxt; final String tabDescr = algDesrTxt;
final SubmitRequestPanel submitRequestPanel = new SubmitRequestPanel("", 1); final SubmitRequestPanel submitRequestPanel = new SubmitRequestPanel("", 1);
Tab tab = viewAnnualController.createTab(tabTitle + " #" + (viewAnnualController.currentNumberOfTab() + 1), Tab tab = viewAnnualController.createTab(tabTitle + " #" + (viewAnnualController.currentNumberOfTab() + 1),
algDesrTxt, submitRequestPanel); algDesrTxt, submitRequestPanel);
@ -80,7 +81,6 @@ public class ScatterAnnualPanelResult {
res.add(savePDFButton); res.add(savePDFButton);
submitRequestPanel.addWidget(res); submitRequestPanel.addWidget(res);
int oIteration = 1;
if (inputKPI.get(0) == null || inputKPI.get(1) == null) { if (inputKPI.get(0) == null || inputKPI.get(1) == null) {
submitRequestPanel submitRequestPanel
@ -91,15 +91,19 @@ public class ScatterAnnualPanelResult {
// again"); // again");
} }
String titleScatter = "KPI: " + inputKPI.get(0).getName() + " vs " + inputKPI.get(1).getName(); String title = "KPI: " + inputKPI.get(0).getName() + " vs " + inputKPI.get(1).getName();
submitRequestPanel.setTheTitle(titleScatter);
HTML toBigTitle = new HTML(title);
toBigTitle.getElement().setId("KPI_ScatterAnnual_" + requestId + "_" + outputIteration);
toBigTitle.getElement().addClassName("to-big-title");
submitRequestPanel.addWidget(toBigTitle);
HorizontalPanel hp = new HorizontalPanel();
hp.getElement().addClassName("ext-horizontal-panel");
DataMinerInputParameters dmInputParams = new DataMinerInputParameters(thePerformFishResponse, DataMinerInputParameters dmInputParams = new DataMinerInputParameters(thePerformFishResponse,
viewAnnualController.getSelectedYears(), inputKPI, outputKPI, algorithm, focusID); viewAnnualController.getSelectedYears(), inputKPI, outputKPI, algorithm, focusID);
callDataMinerServiceForChart(dmInputParams, submitRequestPanel, submitRequestPanel.getContainerPanel(), tab, callDataMinerServiceForChart(dmInputParams, submitRequestPanel, hp, tab, outputIteration);
oIteration); submitRequestPanel.addWidget(hp);
outputIteration = oIteration;
} }
@ -243,9 +247,15 @@ public class ScatterAnnualPanelResult {
return dataInputsFormatter; return dataInputsFormatter;
} }
private String getOutputId(int oIteration, String title) {
String outputId = "OutputId_" + requestId + "_" + oIteration + "_" + 1;
return outputId;
}
private void displayOutputFilesAsStaticEntities(final DataMinerResponse dmResponse, private void displayOutputFilesAsStaticEntities(final DataMinerResponse dmResponse,
final DataMinerAlgorithms chartType, List<KPI> inputKPIs, List<KPI> outputKPIs, final String focusID, final DataMinerAlgorithms chartType, List<KPI> inputKPIs, List<KPI> outputKPIs, final String focusID,
final Panel container, boolean displayError, int oIteration) { final Panel container, boolean displayError, final int oIteration) {
String title = displayError ? "No results " : ""; String title = displayError ? "No results " : "";
@ -260,14 +270,10 @@ public class ScatterAnnualPanelResult {
final String toTitle = title; final String toTitle = title;
int oNumber = 0;
for (OutputFile outputFile : dmResponse.getListOutput()) { for (OutputFile outputFile : dmResponse.getListOutput()) {
oNumber++;
final String outputId = "OutputId_" + requestId+"_"+oIteration + "_" + oNumber; final FileContentType fileContentType = outputFile.getDataType();
final FileContentType fileContentType= outputFile.getDataType();
switch (outputFile.getDataType()) { switch (outputFile.getDataType()) {
case IMAGE: case IMAGE:
PerformFishAnalyticsServiceAsync.Util.getInstance().getImageFile(outputFile, PerformFishAnalyticsServiceAsync.Util.getInstance().getImageFile(outputFile,
@ -286,6 +292,7 @@ public class ScatterAnnualPanelResult {
public void onSuccess(String base64Content) { public void onSuccess(String base64Content) {
String title = toTitle; String title = toTitle;
String outputId = getOutputId(oIteration, title);
ShowResult showResult = new ShowResult(outputId, title, fileContentType); ShowResult showResult = new ShowResult(outputId, title, fileContentType);
showResult.showImage(base64Content); showResult.showImage(base64Content);
container.add(showResult); container.add(showResult);
@ -313,6 +320,7 @@ public class ScatterAnnualPanelResult {
String title = toTitle; String title = toTitle;
String outputId = getOutputId(oIteration, title);
ShowResult showResult = new ShowResult(outputId, title, fileContentType); ShowResult showResult = new ShowResult(outputId, title, fileContentType);
showResult.showCSVFile(result, cssTableStyle); showResult.showCSVFile(result, cssTableStyle);
container.add(showResult); container.add(showResult);
@ -325,8 +333,7 @@ public class ScatterAnnualPanelResult {
} }
} }
outputNumber=oNumber;
} }
/** /**
@ -377,18 +384,18 @@ public class ScatterAnnualPanelResult {
pdoc.setFontSize(24); pdoc.setFontSize(24);
var title = "PerformFish " + tTitle; var title = "PerformFish " + tTitle;
var titleHeight = pdoc.getLineHeight(title) / pdoc.internal.scaleFactor var titleHeight = pdoc.getLineHeight(title) / pdoc.internal.scaleFactor;
var xPos = lMargin; var xPos = lMargin;
var yPos = tMargin; var yPos = tMargin;
pdoc.text(title, pageCenter, yPos, 'center'); pdoc.text(title, pageCenter, yPos, 'center');
yPos += titleHeight; yPos += titleHeight;
pdoc.setFontSize(10); pdoc.setFontSize(10);
var lineHeight = pdoc.getLineHeight(tDescr) / pdoc.internal.scaleFactor var lineHeight = pdoc.getLineHeight(tDescr) / pdoc.internal.scaleFactor;
var splittedAnalysisDescription = pdoc.splitTextToSize(tDescr, var splittedAnalysisDescription = pdoc.splitTextToSize(tDescr,
(pdfWidthInMM - lMargin - rMargin)); (pdfWidthInMM - lMargin - rMargin));
var lines = splittedAnalysisDescription.length // splitted text is a string array var lines = splittedAnalysisDescription.length;// splitted text is a string array
var analysisDescriptionHeight = lines * lineHeight var analysisDescriptionHeight = lines * lineHeight;
pdoc.text(splittedAnalysisDescription, xPos, yPos, 'left'); pdoc.text(splittedAnalysisDescription, xPos, yPos, 'left');
yPos += analysisDescriptionHeight; yPos += analysisDescriptionHeight;
@ -399,6 +406,29 @@ public class ScatterAnnualPanelResult {
for (var i = 1; i <= outputIteration; i++) { for (var i = 1; i <= outputIteration; i++) {
var kpiId = 'KPI_ScatterAnnual_' + requestId + '_' + i;
console.log('kpiId: ' + kpiId);
var kpiName = $doc.getElementById(kpiId);
yPos += 2;
pdoc.setFontSize(14);
pdoc.setFontType("bold");
var kpiText = kpiName.textContent;
var kpiHeight = pdoc.getLineHeight(kpiText)
/ pdoc.internal.scaleFactor;
var splittedKpiName = pdoc.splitTextToSize(kpiText, (pdfWidthInMM
- lMargin - rMargin));
var kpiLines = splittedKpiName.length; // splitted text is a string array
var kpiLinesHeight = kpiLines * kpiHeight;
pdoc.text(splittedKpiName, xPos, yPos, 'left');
yPos += kpiLinesHeight;
yPos += 6;
pdoc.setFontSize(10);
pdoc.setFontType("normal");
for (var j = 1; j <= outputNumber; j++) { for (var j = 1; j <= outputNumber; j++) {
var outputId = 'OutputId_' + requestId + '_' + i + '_' + j; var outputId = 'OutputId_' + requestId + '_' + i + '_' + j;
@ -419,6 +449,19 @@ public class ScatterAnnualPanelResult {
// foo could get resolved and it's defined // foo could get resolved and it's defined
var childrenTable = resultOutputNumber.children; var childrenTable = resultOutputNumber.children;
var titleCurrentTable = childrenTable[0].rows[0].cells[0];
console.log('Title current table: '
+ titleCurrentTable.textContent);
yPos += 2;
pdoc.setFontSize(10);
pdoc.setFontType("bold");
pdoc.text(titleCurrentTable.textContent, xPos, yPos,
'left');
yPos += 6;
pdoc.setFontSize(10);
pdoc.setFontType("normal");
var secondDiv = childrenTable[0].rows[1].cells[0]; var secondDiv = childrenTable[0].rows[1].cells[0];
var secondTable = secondDiv.children[0].children[0]; var secondTable = secondDiv.children[0].children[0];
@ -439,6 +482,20 @@ public class ScatterAnnualPanelResult {
if (resultType == 'image') { if (resultType == 'image') {
console.log('Result Type image: ' + i); console.log('Result Type image: ' + i);
var childrenTable = resultOutputNumber.children; var childrenTable = resultOutputNumber.children;
var titleCurrentImage = childrenTable[0].rows[0].cells[0];
console.log('Title current image: '
+ titleCurrentImage.textContent);
yPos += 2;
pdoc.setFontSize(10);
pdoc.setFontType("bold");
pdoc.text(titleCurrentImage.textContent, xPos,
yPos, 'left');
yPos += 6;
pdoc.setFontSize(10);
pdoc.setFontType("normal");
var secondDiv = childrenTable[0].rows[1].cells[0]; var secondDiv = childrenTable[0].rows[1].cells[0];
var imageElement = secondDiv.getElementsByTagName( var imageElement = secondDiv.getElementsByTagName(
'img').item(0); 'img').item(0);
@ -457,8 +514,30 @@ public class ScatterAnnualPanelResult {
} }
} }
if (i == outputNumber) {
} else {
if (pdfHeightInMM - yPos < pdfHeightInMM / 4) {
//var numberOfPages=pdoc.internal.getNumberOfPages();
//console.log('NumberOfPages: '+numberOfPages);
var currentPage = pdoc.internal.getCurrentPageInfo().pageNumber;
console.log('CurrentPage: ' + currentPage);
var footner = 'Page ' + currentPage;
pdoc.text(footner, pageCenter, pdfHeightInMM - 7, 'center');
pdoc.addPage();
yPos = tMargin; // Restart position
}
}
} }
var currentPage = pdoc.internal.getCurrentPageInfo().pageNumber;
console.log('CurrentPage: ' + currentPage);
var footner = 'Page ' + currentPage;
pdoc.text(footner, pageCenter, pdfHeightInMM - 7, 'center');
console.log('Done'); console.log('Done');
pdoc.save(filename); pdoc.save(filename);

View File

@ -441,12 +441,22 @@ public class SpeedometerAnnualPanelResult {
yPos += 2; yPos += 2;
pdoc.setFontSize(14); pdoc.setFontSize(14);
pdoc.setFontType("bold"); pdoc.setFontType("bold");
pdoc.text(kpiName.textContent, xPos, yPos, 'left');
var kpiText = kpiName.textContent;
var kpiHeight = pdoc.getLineHeight(kpiText)
/ pdoc.internal.scaleFactor;
var splittedKpiName = pdoc.splitTextToSize(kpiText, (pdfWidthInMM
- lMargin - rMargin));
var kpiLines = splittedKpiName.length; // splitted text is a string array
var kpiLinesHeight = kpiLines * kpiHeight;
pdoc.text(splittedKpiName, xPos, yPos, 'left');
yPos += kpiLinesHeight;
yPos += 6; yPos += 6;
pdoc.setFontSize(10); pdoc.setFontSize(10);
pdoc.setFontType("normal"); pdoc.setFontType("normal");
for (var j = 1; j <= outputNumber; j++) { for (var j = 1; j <= outputNumber; j++) {
var outputId = 'OutputId_' + requestId + '_' + i + '_' + j; var outputId = 'OutputId_' + requestId + '_' + i + '_' + j;

View File

@ -87,7 +87,7 @@ public class BoxPlotPanelResult {
oIteration++; oIteration++;
String title = "KPI: " + kpi.getName(); String title = "KPI: " + kpi.getName();
HTML toBigTitle = new HTML(title); HTML toBigTitle = new HTML(title);
toBigTitle.getElement().setId("KPI_BoxPlot_"+requestId+"_"+oIteration); toBigTitle.getElement().setId("KPI_BoxPlot_" + requestId + "_" + oIteration);
toBigTitle.getElement().addClassName("to-big-title"); toBigTitle.getElement().addClassName("to-big-title");
submitRequestPanel.addWidget(toBigTitle); submitRequestPanel.addWidget(toBigTitle);
HorizontalPanel hp = new HorizontalPanel(); HorizontalPanel hp = new HorizontalPanel();
@ -196,25 +196,22 @@ public class BoxPlotPanelResult {
} }
}); });
} }
private String getOutputId(int oIteration, String title) {
private String getOutputId(int oIteration, String title){
if (title.startsWith("My")) { if (title.startsWith("My")) {
String outputId = "OutputId_" + requestId+"_"+oIteration + "_" + 1; String outputId = "OutputId_" + requestId + "_" + oIteration + "_" + 1;
return outputId; return outputId;
} else if (title.startsWith("All")) { } else if (title.startsWith("All")) {
String outputId = "OutputId_" + requestId+"_"+oIteration + "_" + 2; String outputId = "OutputId_" + requestId + "_" + oIteration + "_" + 2;
return outputId; return outputId;
} else { } else {
String outputId = "OutputId_" + requestId+"_"+oIteration + "_" + 3; String outputId = "OutputId_" + requestId + "_" + oIteration + "_" + 3;
return outputId; return outputId;
} }
} }
private void displayOutputFilesAsStaticEntities(final DataMinerResponse dmResponse, private void displayOutputFilesAsStaticEntities(final DataMinerResponse dmResponse,
final DataMinerAlgorithms chartType, List<KPI> inputKPIs, List<KPI> outputKPIs, final String focusID, final DataMinerAlgorithms chartType, List<KPI> inputKPIs, List<KPI> outputKPIs, final String focusID,
@ -234,7 +231,7 @@ public class BoxPlotPanelResult {
final String toTitle = title; final String toTitle = title;
for (OutputFile outputFile : dmResponse.getListOutput()) { for (OutputFile outputFile : dmResponse.getListOutput()) {
final FileContentType fileContentType = outputFile.getDataType(); final FileContentType fileContentType = outputFile.getDataType();
switch (outputFile.getDataType()) { switch (outputFile.getDataType()) {
@ -258,8 +255,8 @@ public class BoxPlotPanelResult {
title = chartType.getName() + " - on all batches<br>"; title = chartType.getName() + " - on all batches<br>";
title += "Blue dots indicate the selected batch(es): " + focusID; title += "Blue dots indicate the selected batch(es): " + focusID;
String outputId=getOutputId(oIteration,title); String outputId = getOutputId(oIteration, title);
ShowResult showResult = new ShowResult(outputId, title, fileContentType); ShowResult showResult = new ShowResult(outputId, title, fileContentType);
showResult.showImage(base64Content); showResult.showImage(base64Content);
displayingOrderedBoxPlot(dmResponse, title, container, showResult); displayingOrderedBoxPlot(dmResponse, title, container, showResult);
@ -293,8 +290,8 @@ public class BoxPlotPanelResult {
} }
title += "<br>"; title += "<br>";
title += "Data aggregation is performed by considering batches as base units"; title += "Data aggregation is performed by considering batches as base units";
String outputId=getOutputId(oIteration,title); String outputId = getOutputId(oIteration, title);
ShowResult showResult = new ShowResult(outputId, title, fileContentType); ShowResult showResult = new ShowResult(outputId, title, fileContentType);
showResult.showCSVFile(result, cssTableStyle); showResult.showCSVFile(result, cssTableStyle);
displayingOrderedBoxPlot(dmResponse, title, container, showResult); displayingOrderedBoxPlot(dmResponse, title, container, showResult);
@ -309,8 +306,6 @@ public class BoxPlotPanelResult {
} }
} }
private void displayingOrderedBoxPlot(final DataMinerResponse dmResponse, String title, final Panel container, private void displayingOrderedBoxPlot(final DataMinerResponse dmResponse, String title, final Panel container,
@ -413,12 +408,20 @@ public class BoxPlotPanelResult {
yPos += 2; yPos += 2;
pdoc.setFontSize(14); pdoc.setFontSize(14);
pdoc.setFontType("bold"); pdoc.setFontType("bold");
pdoc.text(kpiName.textContent, xPos, yPos, 'left');
var kpiText = kpiName.textContent;
var kpiHeight = pdoc.getLineHeight(kpiText)
/ pdoc.internal.scaleFactor;
var splittedKpiName = pdoc.splitTextToSize(kpiText, (pdfWidthInMM
- lMargin - rMargin));
var kpiLines = splittedKpiName.length; // splitted text is a string array
var kpiLinesHeight = kpiLines * kpiHeight;
pdoc.text(splittedKpiName, xPos, yPos, 'left');
yPos += kpiLinesHeight;
yPos += 6; yPos += 6;
pdoc.setFontSize(10); pdoc.setFontSize(10);
pdoc.setFontType("normal"); pdoc.setFontType("normal");
for (var j = 1; j <= outputNumber; j++) { for (var j = 1; j <= outputNumber; j++) {
@ -449,7 +452,7 @@ public class BoxPlotPanelResult {
pdoc.text(titleCurrentTable.textContent, xPos, yPos, pdoc.text(titleCurrentTable.textContent, xPos, yPos,
'left'); 'left');
yPos += 6; yPos += 6;
pdoc.setFontSize(10); pdoc.setFontSize(10);
pdoc.setFontType("normal"); pdoc.setFontType("normal");
@ -483,10 +486,9 @@ public class BoxPlotPanelResult {
pdoc.text(titleCurrentImage.textContent, xPos, pdoc.text(titleCurrentImage.textContent, xPos,
yPos, 'left'); yPos, 'left');
yPos += 6; yPos += 6;
pdoc.setFontSize(10); pdoc.setFontSize(10);
pdoc.setFontType("normal"); pdoc.setFontType("normal");
var secondDiv = childrenTable[0].rows[1].cells[0]; var secondDiv = childrenTable[0].rows[1].cells[0];
var imageElement = secondDiv.getElementsByTagName( var imageElement = secondDiv.getElementsByTagName(

View File

@ -33,20 +33,21 @@ import com.google.gwt.resources.client.TextResource;
import com.google.gwt.user.client.Window; import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.ComplexPanel; import com.google.gwt.user.client.ui.ComplexPanel;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HorizontalPanel; import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Panel; import com.google.gwt.user.client.ui.Panel;
public class ScatterPanelResult { public class ScatterPanelResult {
private PerformFishAnalyticsViewController viewController; private PerformFishAnalyticsViewController viewController;
private int requestId=0; private int requestId = 0;
private int outputIteration = 0; private int outputIteration = 1;
private int outputNumber = 0; private int outputNumber = 1;
public ScatterPanelResult(int reqId,PerformFishAnalyticsViewController viewController, public ScatterPanelResult(int reqId, PerformFishAnalyticsViewController viewController,
final DataMinerAlgorithms algorithm, String focusID, List<KPI> inputKPI, final List<KPI> outputKPI) { final DataMinerAlgorithms algorithm, String focusID, List<KPI> inputKPI, final List<KPI> outputKPI) {
GWT.log("RequestID: "+reqId); GWT.log("RequestID: " + reqId);
requestId=reqId; requestId = reqId;
this.viewController = viewController; this.viewController = viewController;
TextResource algDescr = PerformFishResources.INSTANCE.batch_SCATTER(); TextResource algDescr = PerformFishResources.INSTANCE.batch_SCATTER();
@ -69,14 +70,13 @@ public class ScatterPanelResult {
@Override @Override
public void onClick(ClickEvent event) { public void onClick(ClickEvent event) {
saveFilePDF(algorithm.getId(), tabTitle, tabTitle, tabDescr, requestId,outputIteration, outputNumber); saveFilePDF(algorithm.getId(), tabTitle, tabTitle, tabDescr, requestId, outputIteration, outputNumber);
// dmResponse.getListOutput().size() // dmResponse.getListOutput().size()
} }
}); });
res.add(savePDFButton); res.add(savePDFButton);
submitRequestPanel.addWidget(res); submitRequestPanel.addWidget(res);
int oIteration = 1;
if (inputKPI.get(0) == null || inputKPI.get(1) == null) { if (inputKPI.get(0) == null || inputKPI.get(1) == null) {
submitRequestPanel submitRequestPanel
@ -87,13 +87,17 @@ public class ScatterPanelResult {
// again"); // again");
} }
String titleScatter = "KPI: " + inputKPI.get(0).getName() + " vs " + inputKPI.get(1).getName(); String title = "KPI: " + inputKPI.get(0).getName() + " vs " + inputKPI.get(1).getName();
submitRequestPanel.setTheTitle(titleScatter); HTML toBigTitle = new HTML(title);
toBigTitle.getElement().setId("KPI_Scatter_" + requestId + "_" + outputIteration);
toBigTitle.getElement().addClassName("to-big-title");
submitRequestPanel.addWidget(toBigTitle);
HorizontalPanel hp = new HorizontalPanel();
hp.getElement().addClassName("ext-horizontal-panel");
callDataMinerServiceForChart(viewController.getPerformFishResponse(), POPULATION_LEVEL.BATCH, inputKPI, callDataMinerServiceForChart(viewController.getPerformFishResponse(), POPULATION_LEVEL.BATCH, inputKPI,
outputKPI, algorithm, focusID, submitRequestPanel, submitRequestPanel.getContainerPanel(), tab, outputKPI, algorithm, focusID, submitRequestPanel, hp, tab, outputIteration);
oIteration); submitRequestPanel.addWidget(hp);
outputIteration = oIteration;
} }
@ -193,9 +197,15 @@ public class ScatterPanelResult {
}); });
} }
private String getOutputId(int oIteration, String title) {
String outputId = "OutputId_" + requestId + "_" + oIteration + "_" + 1;
return outputId;
}
private void displayOutputFilesAsStaticEntities(final DataMinerResponse dmResponse, private void displayOutputFilesAsStaticEntities(final DataMinerResponse dmResponse,
final DataMinerAlgorithms chartType, List<KPI> inputKPIs, List<KPI> outputKPIs, final String focusID, final DataMinerAlgorithms chartType, List<KPI> inputKPIs, List<KPI> outputKPIs, final String focusID,
final Panel container, boolean displayError, int oIteration) { final Panel container, boolean displayError, final int oIteration) {
String title = displayError ? "No results " : ""; String title = displayError ? "No results " : "";
@ -210,12 +220,9 @@ public class ScatterPanelResult {
final String toTitle = title; final String toTitle = title;
int oNumber = 0;
for (OutputFile outputFile : dmResponse.getListOutput()) { for (OutputFile outputFile : dmResponse.getListOutput()) {
oNumber++;
final String outputId = "OutputId_" + requestId+"_"+oIteration + "_" + oNumber; final FileContentType fileContentType = outputFile.getDataType();
final FileContentType fileContentType= outputFile.getDataType();
switch (outputFile.getDataType()) { switch (outputFile.getDataType()) {
case IMAGE: case IMAGE:
PerformFishAnalyticsServiceAsync.Util.getInstance().getImageFile(outputFile, PerformFishAnalyticsServiceAsync.Util.getInstance().getImageFile(outputFile,
@ -234,11 +241,11 @@ public class ScatterPanelResult {
public void onSuccess(String base64Content) { public void onSuccess(String base64Content) {
String title = toTitle; String title = toTitle;
String outputId = getOutputId(oIteration, title);
ShowResult showResult = new ShowResult(outputId, title, fileContentType); ShowResult showResult = new ShowResult(outputId, title, fileContentType);
showResult.showImage(base64Content); showResult.showImage(base64Content);
container.add(showResult); container.add(showResult);
} }
}); });
break; break;
@ -262,6 +269,7 @@ public class ScatterPanelResult {
String title = toTitle; String title = toTitle;
String outputId = getOutputId(oIteration, title);
ShowResult showResult = new ShowResult(outputId, title, fileContentType); ShowResult showResult = new ShowResult(outputId, title, fileContentType);
showResult.showCSVFile(result, cssTableStyle); showResult.showCSVFile(result, cssTableStyle);
container.add(showResult); container.add(showResult);
@ -274,13 +282,9 @@ public class ScatterPanelResult {
} }
} }
outputNumber=oNumber;
} }
/** /**
* Remove the spinner if all DM responses are returned. * Remove the spinner if all DM responses are returned.
* *
@ -303,7 +307,7 @@ public class ScatterPanelResult {
int requestId, int outputIteration, int outputNumber)/*-{ int requestId, int outputIteration, int outputNumber)/*-{
var that = this; var that = this;
console.log('saveFilePDF()'); console.log('saveFilePDF()');
console.log('requestId: '+requestId); console.log('requestId: ' + requestId);
console.log('OutputIteration: ' + outputIteration); console.log('OutputIteration: ' + outputIteration);
console.log('OutputNumber:' + outputNumber); console.log('OutputNumber:' + outputNumber);
@ -351,9 +355,32 @@ public class ScatterPanelResult {
for (var i = 1; i <= outputIteration; i++) { for (var i = 1; i <= outputIteration; i++) {
var kpiId = 'KPI_Scatter_' + requestId + '_' + i;
console.log('kpiId: ' + kpiId);
var kpiName = $doc.getElementById(kpiId);
yPos += 2;
pdoc.setFontSize(14);
pdoc.setFontType("bold");
var kpiText = kpiName.textContent;
var kpiHeight = pdoc.getLineHeight(kpiText)
/ pdoc.internal.scaleFactor;
var splittedKpiName = pdoc.splitTextToSize(kpiText, (pdfWidthInMM
- lMargin - rMargin));
var kpiLines = splittedKpiName.length; // splitted text is a string array
var kpiLinesHeight = kpiLines * kpiHeight;
pdoc.text(splittedKpiName, xPos, yPos, 'left');
yPos += kpiLinesHeight;
yPos += 6;
pdoc.setFontSize(10);
pdoc.setFontType("normal");
for (var j = 1; j <= outputNumber; j++) { for (var j = 1; j <= outputNumber; j++) {
var outputId = 'OutputId_'+requestId+'_'+ i + '_' + j; var outputId = 'OutputId_' + requestId + '_' + i + '_' + j;
console.log('OutputId: ' + outputId); console.log('OutputId: ' + outputId);
var resultOutputNumber = $doc.getElementById(outputId); var resultOutputNumber = $doc.getElementById(outputId);
@ -371,6 +398,19 @@ public class ScatterPanelResult {
// foo could get resolved and it's defined // foo could get resolved and it's defined
var childrenTable = resultOutputNumber.children; var childrenTable = resultOutputNumber.children;
var titleCurrentTable = childrenTable[0].rows[0].cells[0];
console.log('Title current table: '
+ titleCurrentTable.textContent);
yPos += 2;
pdoc.setFontSize(10);
pdoc.setFontType("bold");
pdoc.text(titleCurrentTable.textContent, xPos, yPos,
'left');
yPos += 6;
pdoc.setFontSize(10);
pdoc.setFontType("normal");
var secondDiv = childrenTable[0].rows[1].cells[0]; var secondDiv = childrenTable[0].rows[1].cells[0];
var secondTable = secondDiv.children[0].children[0]; var secondTable = secondDiv.children[0].children[0];
@ -391,6 +431,20 @@ public class ScatterPanelResult {
if (resultType == 'image') { if (resultType == 'image') {
console.log('Result Type image: ' + i); console.log('Result Type image: ' + i);
var childrenTable = resultOutputNumber.children; var childrenTable = resultOutputNumber.children;
var titleCurrentImage = childrenTable[0].rows[0].cells[0];
console.log('Title current image: '
+ titleCurrentImage.textContent);
yPos += 2;
pdoc.setFontSize(10);
pdoc.setFontType("bold");
pdoc.text(titleCurrentImage.textContent, xPos,
yPos, 'left');
yPos += 6;
pdoc.setFontSize(10);
pdoc.setFontType("normal");
var secondDiv = childrenTable[0].rows[1].cells[0]; var secondDiv = childrenTable[0].rows[1].cells[0];
var imageElement = secondDiv.getElementsByTagName( var imageElement = secondDiv.getElementsByTagName(
'img').item(0); 'img').item(0);
@ -409,8 +463,30 @@ public class ScatterPanelResult {
} }
} }
if (i == outputNumber) {
} else {
if (pdfHeightInMM - yPos < pdfHeightInMM / 4) {
//var numberOfPages=pdoc.internal.getNumberOfPages();
//console.log('NumberOfPages: '+numberOfPages);
var currentPage = pdoc.internal.getCurrentPageInfo().pageNumber;
console.log('CurrentPage: ' + currentPage);
var footner = 'Page ' + currentPage;
pdoc.text(footner, pageCenter, pdfHeightInMM - 7, 'center');
pdoc.addPage();
yPos = tMargin; // Restart position
}
}
} }
var currentPage = pdoc.internal.getCurrentPageInfo().pageNumber;
console.log('CurrentPage: ' + currentPage);
var footner = 'Page ' + currentPage;
pdoc.text(footner, pageCenter, pdfHeightInMM - 7, 'center');
console.log('Done'); console.log('Done');
pdoc.save(filename); pdoc.save(filename);

View File

@ -364,7 +364,16 @@ public class SpeedometerPanelResult {
yPos += 2; yPos += 2;
pdoc.setFontSize(14); pdoc.setFontSize(14);
pdoc.setFontType("bold"); pdoc.setFontType("bold");
pdoc.text(kpiName.textContent, xPos, yPos, 'left');
var kpiText = kpiName.textContent;
var kpiHeight = pdoc.getLineHeight(kpiText)
/ pdoc.internal.scaleFactor;
var splittedKpiName = pdoc.splitTextToSize(kpiText, (pdfWidthInMM
- lMargin - rMargin));
var kpiLines = splittedKpiName.length; // splitted text is a string array
var kpiLinesHeight = kpiLines * kpiHeight;
pdoc.text(splittedKpiName, xPos, yPos, 'left');
yPos += kpiLinesHeight;
yPos += 6; yPos += 6;
pdoc.setFontSize(10); pdoc.setFontSize(10);

View File

@ -91,6 +91,11 @@ public class SubmitRequestPanel extends Composite {
else else
theTitle.setHTML(""); theTitle.setHTML("");
} }
public void addTheTitleClassName(String className){
theTitle.getElement().addClassName(className);
}
/** /**
* Gets the panel. * Gets the panel.