예제 #1
0
 @Override
 public void setPc(final PlayerCharacter aPC) {
   super.setPc(aPC);
   if (theSelectPanel != null) {
     try {
       theSelectPanel.setPc(getPc());
     } catch (Exception e) {
       Logging.errorPrint("Could not select PC ", e);
       // Yuck but not sure what else to do.
     }
   }
 }
예제 #2
0
  @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);
    }
  }