MCPcopy Create free account
hub / github.com/PCGen/pcgen / run

Method run

code/src/java/pcgen/util/fop/FopTask.java:181–235  ·  view source on GitHub ↗

Run the FO to PDF/AWT conversion. This automatically closes any provided OutputStream for this FopTask.

()

Source from the content-addressed store, hash-verified

179 * this FopTask.
180 */
181 @Override
182 public void run()
183 {
184 try (OutputStream out = outputStream)
185 {
186 userAgent.setProducer("PC Gen Character Generator");
187 userAgent.setAuthor(System.getProperty("user.name"));
188 userAgent.setCreationDate(Date.from(LocalDateTime.now().toInstant(ZoneOffset.ofHours(0))));
189
190 userAgent.getEventBroadcaster().addEventListener(new FOPEventListener());
191
192 String mimeType;
193 if (renderer != null)
194 {
195 userAgent.setKeywords("PCGEN FOP PREVIEW");
196 mimeType = MimeConstants.MIME_FOP_AWT_PREVIEW;
197 }
198 else
199 {
200 userAgent.setKeywords("PCGEN FOP PDF");
201 mimeType = org.apache.xmlgraphics.util.MimeConstants.MIME_PDF;
202 }
203 Fop fop;
204 if (out != null)
205 {
206 fop = FOP_FACTORY.newFop(mimeType, userAgent, out);
207 }
208 else
209 {
210 fop = FOP_FACTORY.newFop(mimeType, userAgent);
211 }
212
213 Transformer transformer;
214 if (xsltSource != null)
215 {
216 transformer = TRANS_FACTORY.newTransformer(xsltSource);
217 }
218 else
219 {
220 transformer = TRANS_FACTORY.newTransformer(); // identity transformer
221 }
222 transformer.setErrorListener(new FOPErrorListener());
223 transformer.transform(inputSource, new SAXResult(fop.getDefaultHandler()));
224 }
225 catch (TransformerException | FOPException | IOException e)
226 {
227 errorBuilder.append(e.getMessage()).append(Constants.LINE_SEPARATOR);
228 Logging.errorPrint("Exception in FopTask:run", e);
229 }
230 catch (RuntimeException ex)
231 {
232 errorBuilder.append(ex.getMessage()).append(Constants.LINE_SEPARATOR);
233 Logging.errorPrint("Unexpected exception in FopTask:run: ", ex);
234 }
235 }
236
237 /**
238 * The Class {@code FOPErrorListener} listens for notifications of issues when generating

Callers 13

exportCharacterToPDFMethod · 0.95
exportPartyToPDFMethod · 0.95
runOrMethod · 0.45
runIfMethod · 0.45
loadPluginsMethod · 0.45
commitMethod · 0.45
getPreEqualityCleanupMethod · 0.45
testRaceMonCSkillMethod · 0.45
runRoundRobinMethod · 0.45
testGlobalCSkillMethod · 0.45
testGlobalCSkillListMethod · 0.45
testGlobalCCSkillMethod · 0.45

Calls 5

errorPrintMethod · 0.95
fromMethod · 0.80
getMessageMethod · 0.65
getPropertyMethod · 0.45
appendMethod · 0.45

Tested by 10

runOrMethod · 0.36
runIfMethod · 0.36
loadPluginsMethod · 0.36
getPreEqualityCleanupMethod · 0.36
testRaceMonCSkillMethod · 0.36
runRoundRobinMethod · 0.36
testGlobalCSkillMethod · 0.36
testGlobalCSkillListMethod · 0.36
testGlobalCCSkillMethod · 0.36
testGlobalCCSkillListMethod · 0.36