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 int outputIteration = 0;
private int outputNumber = 2;
private int requestId=0;
private int requestId = 0;
public BoxPlotAnnualPanelResult(int reqId, PerformFishAnnualAnalyticsViewController viewAnnualController,
PerformFishResponse thePerformFishResponse,
final DataMinerAlgorithms algorithm, String focusID, List<KPI> inputKPI, final List<KPI> outputKPI) {
GWT.log("RequestID: "+reqId);
requestId=reqId;
PerformFishResponse thePerformFishResponse, final DataMinerAlgorithms algorithm, String focusID,
List<KPI> inputKPI, final List<KPI> outputKPI) {
GWT.log("RequestID: " + reqId);
requestId = reqId;
this.viewAnnualController = viewAnnualController;
TextResource algDescr = PerformFishResources.INSTANCE.farm_BOXPLOT();
@ -93,7 +91,7 @@ public class BoxPlotAnnualPanelResult {
oIteration++;
String title = "KPI: " + kpi.getName();
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");
submitRequestPanel.addWidget(toBigTitle);
HorizontalPanel hp = new HorizontalPanel();
@ -106,7 +104,7 @@ public class BoxPlotAnnualPanelResult {
submitRequestPanel.addWidget(hp);
}
outputIteration = oIteration;
GWT.log("outputInteration: "+outputIteration);
GWT.log("outputInteration: " + outputIteration);
}
/**
@ -120,11 +118,12 @@ public class BoxPlotAnnualPanelResult {
* the panel
* @param tab
* the tab
* @param tabDescr
* @param tabTitle
* @param tabDescr
* @param tabTitle
*/
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);
@ -210,7 +209,7 @@ public class BoxPlotAnnualPanelResult {
GWT.log("I'm displaying: " + dmResponse);
displayOutputFilesAsStaticEntities(dmResponse, dmInputParameters.getChartType(),
dmInputParameters.getInputKPI(), dmInputParameters.getOutputKPI(),
dmInputParameters.getFocusID(), panelContainer, false,oIteration);
dmInputParameters.getFocusID(), panelContainer, false, oIteration);
}
@Override
@ -219,13 +218,12 @@ public class BoxPlotAnnualPanelResult {
checkTabSpinner(requestPanel, tab);
displayOutputFilesAsStaticEntities(null, dmInputParameters.getChartType(),
dmInputParameters.getInputKPI(), dmInputParameters.getOutputKPI(),
dmInputParameters.getFocusID(), panelContainer, true,oIteration);
dmInputParameters.getFocusID(), panelContainer, true, oIteration);
}
});
}
/**
* Append DM input table.
*
@ -248,26 +246,20 @@ public class BoxPlotAnnualPanelResult {
return dataInputsFormatter;
}
private String getOutputId(int oIteration, String title){
private String getOutputId(int oIteration, String title) {
if (title.startsWith("My")) {
return null;
} else if (title.startsWith("All")) {
String outputId = "OutputId_" + requestId+"_"+oIteration + "_" + 1;
String outputId = "OutputId_" + requestId + "_" + oIteration + "_" + 1;
return outputId;
} else {
String outputId = "OutputId_" + requestId+"_"+oIteration + "_" + 2;
String outputId = "OutputId_" + requestId + "_" + oIteration + "_" + 2;
return outputId;
}
}
}
private void displayOutputFilesAsStaticEntities(final DataMinerResponse dmResponse,
final DataMinerAlgorithms chartType, List<KPI> inputKPIs, List<KPI> outputKPIs, final String focusID,
final Panel container, boolean displayError, final int oIteration) {
@ -286,10 +278,10 @@ public class BoxPlotAnnualPanelResult {
final String toTitle = title;
for (OutputFile outputFile : dmResponse.getListOutput()) {
final FileContentType fileContentType= outputFile.getDataType();
final FileContentType fileContentType = outputFile.getDataType();
switch (outputFile.getDataType()) {
case IMAGE:
PerformFishAnalyticsServiceAsync.Util.getInstance().getImageFile(outputFile,
new AsyncCallback<String>() {
@ -309,17 +301,17 @@ public class BoxPlotAnnualPanelResult {
title = chartType.getTitle() + " - on all farm data<br>";
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.showImage(base64Content);
displayingOrderedBoxPlot(dmResponse, title, container, showResult);
}
});
break;
case CSV:
PerformFishAnalyticsServiceAsync.Util.getInstance().getCSVFile(outputFile, true,
new AsyncCallback<CSVFile>() {
@ -338,7 +330,7 @@ public class BoxPlotAnnualPanelResult {
String cssTableStyle = "simpletable";
String title = toTitle;
if (result.getFileName().contains("_user")) {
title = "My Batch(es)";
return;
@ -347,13 +339,12 @@ public class BoxPlotAnnualPanelResult {
}
title += "<br>";
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.showCSVFile(result, cssTableStyle);
displayingOrderedBoxPlot(dmResponse, title, container, showResult);
}
});
break;
@ -363,7 +354,7 @@ public class BoxPlotAnnualPanelResult {
}
}
}
private void displayingOrderedBoxPlot(final DataMinerResponse dmResponse, String title, final Panel container,
@ -466,12 +457,20 @@ public class BoxPlotAnnualPanelResult {
yPos += 2;
pdoc.setFontSize(14);
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;
pdoc.setFontSize(10);
pdoc.setFontType("normal");
for (var j = 1; j <= outputNumber; j++) {
@ -502,7 +501,7 @@ public class BoxPlotAnnualPanelResult {
pdoc.text(titleCurrentTable.textContent, xPos, yPos,
'left');
yPos += 6;
pdoc.setFontSize(10);
pdoc.setFontType("normal");
@ -536,10 +535,9 @@ public class BoxPlotAnnualPanelResult {
pdoc.text(titleCurrentImage.textContent, xPos,
yPos, 'left');
yPos += 6;
pdoc.setFontSize(10);
pdoc.setFontType("normal");
var secondDiv = childrenTable[0].rows[1].cells[0];
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.rpc.AsyncCallback;
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.Panel;
@ -43,17 +44,16 @@ public class ScatterAnnualPanelResult {
private PerformFishAnnualAnalyticsViewController viewAnnualController;
private int requestId;
private int outputIteration = 0;
private int outputNumber = 0;
private int outputIteration = 1;
private int outputNumber = 1;
public ScatterAnnualPanelResult(int reqId, PerformFishAnnualAnalyticsViewController viewAnnualController,
PerformFishResponse thePerformFishResponse, final DataMinerAlgorithms algorithm, String focusID,
List<KPI> inputKPI, final List<KPI> outputKPI) {
GWT.log("RequestID: "+reqId);
requestId=reqId;
GWT.log("RequestID: " + reqId);
requestId = reqId;
this.viewAnnualController = viewAnnualController;
TextResource algDescr = PerformFishResources.INSTANCE.farm_SCATTER();
String algDesrTxt = algDescr != null ? algDescr.getText() : null;
// TODO
@ -61,6 +61,7 @@ public class ScatterAnnualPanelResult {
final String tabDescr = algDesrTxt;
final SubmitRequestPanel submitRequestPanel = new SubmitRequestPanel("", 1);
Tab tab = viewAnnualController.createTab(tabTitle + " #" + (viewAnnualController.currentNumberOfTab() + 1),
algDesrTxt, submitRequestPanel);
@ -80,7 +81,6 @@ public class ScatterAnnualPanelResult {
res.add(savePDFButton);
submitRequestPanel.addWidget(res);
int oIteration = 1;
if (inputKPI.get(0) == null || inputKPI.get(1) == null) {
submitRequestPanel
@ -91,15 +91,19 @@ public class ScatterAnnualPanelResult {
// again");
}
String titleScatter = "KPI: " + inputKPI.get(0).getName() + " vs " + inputKPI.get(1).getName();
submitRequestPanel.setTheTitle(titleScatter);
String title = "KPI: " + inputKPI.get(0).getName() + " vs " + inputKPI.get(1).getName();
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,
viewAnnualController.getSelectedYears(), inputKPI, outputKPI, algorithm, focusID);
callDataMinerServiceForChart(dmInputParams, submitRequestPanel, submitRequestPanel.getContainerPanel(), tab,
oIteration);
outputIteration = oIteration;
callDataMinerServiceForChart(dmInputParams, submitRequestPanel, hp, tab, outputIteration);
submitRequestPanel.addWidget(hp);
}
@ -243,9 +247,15 @@ public class ScatterAnnualPanelResult {
return dataInputsFormatter;
}
private String getOutputId(int oIteration, String title) {
String outputId = "OutputId_" + requestId + "_" + oIteration + "_" + 1;
return outputId;
}
private void displayOutputFilesAsStaticEntities(final DataMinerResponse dmResponse,
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 " : "";
@ -260,14 +270,10 @@ public class ScatterAnnualPanelResult {
final String toTitle = title;
int oNumber = 0;
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()) {
case IMAGE:
PerformFishAnalyticsServiceAsync.Util.getInstance().getImageFile(outputFile,
@ -286,6 +292,7 @@ public class ScatterAnnualPanelResult {
public void onSuccess(String base64Content) {
String title = toTitle;
String outputId = getOutputId(oIteration, title);
ShowResult showResult = new ShowResult(outputId, title, fileContentType);
showResult.showImage(base64Content);
container.add(showResult);
@ -313,6 +320,7 @@ public class ScatterAnnualPanelResult {
String title = toTitle;
String outputId = getOutputId(oIteration, title);
ShowResult showResult = new ShowResult(outputId, title, fileContentType);
showResult.showCSVFile(result, cssTableStyle);
container.add(showResult);
@ -325,8 +333,7 @@ public class ScatterAnnualPanelResult {
}
}
outputNumber=oNumber;
}
/**
@ -377,18 +384,18 @@ public class ScatterAnnualPanelResult {
pdoc.setFontSize(24);
var title = "PerformFish " + tTitle;
var titleHeight = pdoc.getLineHeight(title) / pdoc.internal.scaleFactor
var titleHeight = pdoc.getLineHeight(title) / pdoc.internal.scaleFactor;
var xPos = lMargin;
var yPos = tMargin;
pdoc.text(title, pageCenter, yPos, 'center');
yPos += titleHeight;
pdoc.setFontSize(10);
var lineHeight = pdoc.getLineHeight(tDescr) / pdoc.internal.scaleFactor
var lineHeight = pdoc.getLineHeight(tDescr) / pdoc.internal.scaleFactor;
var splittedAnalysisDescription = pdoc.splitTextToSize(tDescr,
(pdfWidthInMM - lMargin - rMargin));
var lines = splittedAnalysisDescription.length // splitted text is a string array
var analysisDescriptionHeight = lines * lineHeight
var lines = splittedAnalysisDescription.length;// splitted text is a string array
var analysisDescriptionHeight = lines * lineHeight;
pdoc.text(splittedAnalysisDescription, xPos, yPos, 'left');
yPos += analysisDescriptionHeight;
@ -399,6 +406,29 @@ public class ScatterAnnualPanelResult {
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++) {
var outputId = 'OutputId_' + requestId + '_' + i + '_' + j;
@ -419,6 +449,19 @@ public class ScatterAnnualPanelResult {
// foo could get resolved and it's defined
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 secondTable = secondDiv.children[0].children[0];
@ -439,6 +482,20 @@ public class ScatterAnnualPanelResult {
if (resultType == 'image') {
console.log('Result Type image: ' + i);
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 imageElement = secondDiv.getElementsByTagName(
'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');
pdoc.save(filename);

View File

@ -441,12 +441,22 @@ public class SpeedometerAnnualPanelResult {
yPos += 2;
pdoc.setFontSize(14);
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;
pdoc.setFontSize(10);
pdoc.setFontType("normal");
for (var j = 1; j <= outputNumber; j++) {
var outputId = 'OutputId_' + requestId + '_' + i + '_' + j;

View File

@ -87,7 +87,7 @@ public class BoxPlotPanelResult {
oIteration++;
String title = "KPI: " + kpi.getName();
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");
submitRequestPanel.addWidget(toBigTitle);
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")) {
String outputId = "OutputId_" + requestId+"_"+oIteration + "_" + 1;
String outputId = "OutputId_" + requestId + "_" + oIteration + "_" + 1;
return outputId;
} else if (title.startsWith("All")) {
String outputId = "OutputId_" + requestId+"_"+oIteration + "_" + 2;
String outputId = "OutputId_" + requestId + "_" + oIteration + "_" + 2;
return outputId;
} else {
String outputId = "OutputId_" + requestId+"_"+oIteration + "_" + 3;
String outputId = "OutputId_" + requestId + "_" + oIteration + "_" + 3;
return outputId;
}
}
private void displayOutputFilesAsStaticEntities(final DataMinerResponse dmResponse,
final DataMinerAlgorithms chartType, List<KPI> inputKPIs, List<KPI> outputKPIs, final String focusID,
@ -234,7 +231,7 @@ public class BoxPlotPanelResult {
final String toTitle = title;
for (OutputFile outputFile : dmResponse.getListOutput()) {
final FileContentType fileContentType = outputFile.getDataType();
switch (outputFile.getDataType()) {
@ -258,8 +255,8 @@ public class BoxPlotPanelResult {
title = chartType.getName() + " - on all batches<br>";
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.showImage(base64Content);
displayingOrderedBoxPlot(dmResponse, title, container, showResult);
@ -293,8 +290,8 @@ public class BoxPlotPanelResult {
}
title += "<br>";
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.showCSVFile(result, cssTableStyle);
displayingOrderedBoxPlot(dmResponse, title, container, showResult);
@ -309,8 +306,6 @@ public class BoxPlotPanelResult {
}
}
private void displayingOrderedBoxPlot(final DataMinerResponse dmResponse, String title, final Panel container,
@ -413,12 +408,20 @@ public class BoxPlotPanelResult {
yPos += 2;
pdoc.setFontSize(14);
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;
pdoc.setFontSize(10);
pdoc.setFontType("normal");
for (var j = 1; j <= outputNumber; j++) {
@ -449,7 +452,7 @@ public class BoxPlotPanelResult {
pdoc.text(titleCurrentTable.textContent, xPos, yPos,
'left');
yPos += 6;
pdoc.setFontSize(10);
pdoc.setFontType("normal");
@ -483,10 +486,9 @@ public class BoxPlotPanelResult {
pdoc.text(titleCurrentImage.textContent, xPos,
yPos, 'left');
yPos += 6;
pdoc.setFontSize(10);
pdoc.setFontType("normal");
var secondDiv = childrenTable[0].rows[1].cells[0];
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.rpc.AsyncCallback;
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.Panel;
public class ScatterPanelResult {
private PerformFishAnalyticsViewController viewController;
private int requestId=0;
private int outputIteration = 0;
private int outputNumber = 0;
public ScatterPanelResult(int reqId,PerformFishAnalyticsViewController viewController,
private int requestId = 0;
private int outputIteration = 1;
private int outputNumber = 1;
public ScatterPanelResult(int reqId, PerformFishAnalyticsViewController viewController,
final DataMinerAlgorithms algorithm, String focusID, List<KPI> inputKPI, final List<KPI> outputKPI) {
GWT.log("RequestID: "+reqId);
requestId=reqId;
GWT.log("RequestID: " + reqId);
requestId = reqId;
this.viewController = viewController;
TextResource algDescr = PerformFishResources.INSTANCE.batch_SCATTER();
@ -69,14 +70,13 @@ public class ScatterPanelResult {
@Override
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()
}
});
res.add(savePDFButton);
submitRequestPanel.addWidget(res);
int oIteration = 1;
if (inputKPI.get(0) == null || inputKPI.get(1) == null) {
submitRequestPanel
@ -87,13 +87,17 @@ public class ScatterPanelResult {
// again");
}
String titleScatter = "KPI: " + inputKPI.get(0).getName() + " vs " + inputKPI.get(1).getName();
submitRequestPanel.setTheTitle(titleScatter);
String title = "KPI: " + inputKPI.get(0).getName() + " vs " + inputKPI.get(1).getName();
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,
outputKPI, algorithm, focusID, submitRequestPanel, submitRequestPanel.getContainerPanel(), tab,
oIteration);
outputIteration = oIteration;
outputKPI, algorithm, focusID, submitRequestPanel, hp, tab, outputIteration);
submitRequestPanel.addWidget(hp);
}
@ -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,
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 " : "";
@ -210,12 +220,9 @@ public class ScatterPanelResult {
final String toTitle = title;
int oNumber = 0;
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()) {
case IMAGE:
PerformFishAnalyticsServiceAsync.Util.getInstance().getImageFile(outputFile,
@ -234,11 +241,11 @@ public class ScatterPanelResult {
public void onSuccess(String base64Content) {
String title = toTitle;
String outputId = getOutputId(oIteration, title);
ShowResult showResult = new ShowResult(outputId, title, fileContentType);
showResult.showImage(base64Content);
container.add(showResult);
}
});
break;
@ -262,6 +269,7 @@ public class ScatterPanelResult {
String title = toTitle;
String outputId = getOutputId(oIteration, title);
ShowResult showResult = new ShowResult(outputId, title, fileContentType);
showResult.showCSVFile(result, cssTableStyle);
container.add(showResult);
@ -274,13 +282,9 @@ public class ScatterPanelResult {
}
}
outputNumber=oNumber;
}
/**
* Remove the spinner if all DM responses are returned.
*
@ -303,7 +307,7 @@ public class ScatterPanelResult {
int requestId, int outputIteration, int outputNumber)/*-{
var that = this;
console.log('saveFilePDF()');
console.log('requestId: '+requestId);
console.log('requestId: ' + requestId);
console.log('OutputIteration: ' + outputIteration);
console.log('OutputNumber:' + outputNumber);
@ -351,9 +355,32 @@ public class ScatterPanelResult {
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++) {
var outputId = 'OutputId_'+requestId+'_'+ i + '_' + j;
var outputId = 'OutputId_' + requestId + '_' + i + '_' + j;
console.log('OutputId: ' + outputId);
var resultOutputNumber = $doc.getElementById(outputId);
@ -371,6 +398,19 @@ public class ScatterPanelResult {
// foo could get resolved and it's defined
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 secondTable = secondDiv.children[0].children[0];
@ -391,6 +431,20 @@ public class ScatterPanelResult {
if (resultType == 'image') {
console.log('Result Type image: ' + i);
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 imageElement = secondDiv.getElementsByTagName(
'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');
pdoc.save(filename);

View File

@ -364,7 +364,16 @@ public class SpeedometerPanelResult {
yPos += 2;
pdoc.setFontSize(14);
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;
pdoc.setFontSize(10);

View File

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