public void export(ExportHandler theHandler, BufferedWriter buf) { Collection<PlayerCharacter> characters = new ArrayList<PlayerCharacter>(); for (CharacterFacade character : this) { if (character instanceof CharacterFacadeImpl) { characters.add(((CharacterFacadeImpl) character).getTheCharacter()); } } theHandler.write(characters, buf); }
@Override protected void updateCharacterInfo() { if (theHandler == null) { return; } if (theSelectPanel != null) { theSelectPanel.refresh(); } final StringWriter out = new StringWriter(); final BufferedWriter buf = new BufferedWriter(out); theHandler.write(getPc(), buf); final String genText = out.toString().replace("preview_color.css", getColorCSS()); ByteArrayInputStream instream = new ByteArrayInputStream(genText.getBytes()); try { final URI root = new URI( "file", SettingsHandler.getPcgenPreviewDir().getAbsolutePath().replaceAll("\\\\", "/"), null); final Document doc = theDocBuilder.parse(new InputSourceImpl(instream, root.toString(), "UTF-8")); theSheetPanel.setDocument(doc, theRendererContext); } catch (Throwable e) { final String errorMsg = "<html><body>Unable to process sheet<br>" + e + "</body></html>"; instream = new ByteArrayInputStream(errorMsg.getBytes()); try { final Document doc = theDocBuilder.parse(instream); theSheetPanel.setDocument(doc, theRendererContext); } catch (Exception ex) { ex.printStackTrace(); } Logging.errorPrint("Unable to process sheet: ", e); } }