From 4a281abd7e295f3341a8e345efc198ebb1297e5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=85smund=20V=C3=A5ge=20Fannemel?= <34712686+asmfstatoil@users.noreply.github.com> Date: Wed, 6 Apr 2022 21:59:58 +0200 Subject: [PATCH] refact: simplified generatePDF and displayPDF no need to keep a persistent copy of the pdf in systemthermo object --- .../java/neqsim/thermo/system/SystemInterface.java | 6 ++++-- src/main/java/neqsim/thermo/system/SystemThermo.java | 12 ++---------- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/src/main/java/neqsim/thermo/system/SystemInterface.java b/src/main/java/neqsim/thermo/system/SystemInterface.java index 41023ab99..98bb2e655 100644 --- a/src/main/java/neqsim/thermo/system/SystemInterface.java +++ b/src/main/java/neqsim/thermo/system/SystemInterface.java @@ -2273,14 +2273,16 @@ public double calcBeta() throws neqsim.util.exception.IsNaNException, * generatePDF. *
*/ - public void generatePDF(); + public neqsim.dataPresentation.iTextPDF.PdfCreator generatePDF(); /** ** displayPDF. *
*/ - public void displayPDF(); + default public void displayPDF() { + generatePDF().openPDF(); + } /** *diff --git a/src/main/java/neqsim/thermo/system/SystemThermo.java b/src/main/java/neqsim/thermo/system/SystemThermo.java index bfca2fbac..b8528d365 100644 --- a/src/main/java/neqsim/thermo/system/SystemThermo.java +++ b/src/main/java/neqsim/thermo/system/SystemThermo.java @@ -105,7 +105,6 @@ abstract class SystemThermo implements SystemInterface { protected neqsim.standards.StandardInterface standard = null; protected InterphasePropertiesInterface interfaceProp = null; private boolean multiphaseWaxCheck = false; - Object pdfDocument = null; private boolean forcePhaseTypes = false; static Logger logger = LogManager.getLogger(SystemThermo.class); @@ -4011,7 +4010,7 @@ public neqsim.standards.StandardInterface getStandard(String standardName) { /** {@inheritDoc} */ @Override - public void generatePDF() { + public neqsim.dataPresentation.iTextPDF.PdfCreator generatePDF() { neqsim.dataPresentation.iTextPDF.PdfCreator pdfDocument = null; pdfDocument = new neqsim.dataPresentation.iTextPDF.PdfCreator(); pdfDocument.getDocument().addTitle("NeqSim Thermo Simulation Report"); @@ -4051,14 +4050,7 @@ public void generatePDF() { logger.error("error", e); } pdfDocument.getDocument().close(); - this.pdfDocument = pdfDocument; - } - - /** {@inheritDoc} */ - @Override - public void displayPDF() { - generatePDF(); - ((neqsim.dataPresentation.iTextPDF.PdfCreator) pdfDocument).openPDF(); + return pdfDocument; } /**