use of java.awt.HeadlessException in project opt4j by felixreimann.
the class Opt4J method main.
/**
* Starts the {@link Opt4J} configuration GUI.
*
* @param args
* accepts a configuration file
* @throws Exception
*/
public static void main(String[] args) throws Exception {
System.out.println("Starting Opt4J " + getVersion() + " (Build " + getDateISO() + ")");
if (args.length > 0 && args[0].equalsIgnoreCase("-s")) {
SplashScreen splash = null;
try {
splash = SplashScreen.getSplashScreen();
} catch (HeadlessException e) {
// ignore
}
if (splash != null) {
splash.close();
}
String[] a = new String[args.length - 1];
System.arraycopy(args, 1, a, 0, a.length);
Opt4JStarter.main(a);
} else {
SplashScreen splash = SplashScreen.getSplashScreen();
SplashDecorator decorator = null;
if (splash != null) {
decorateVersionDate(splash);
decorator = new SplashDecorator(splash);
}
searchModules(decorator);
Configurator configurator = new Opt4J();
configurator.start(args);
}
}
use of java.awt.HeadlessException in project pdfbox by apache.
the class PDFToImage method call.
public Integer call() {
if (outputPrefix == null) {
outputPrefix = FilenameUtils.removeExtension(infile.getAbsolutePath());
}
if (getImageFormats().indexOf(imageFormat) == -1) {
SYSERR.println("Error: Invalid image format " + imageFormat + " - supported are: " + getImageFormats());
return 2;
}
if (quality < 0) {
quality = "png".equals(imageFormat) ? 0f : 1f;
}
if (dpi == 0) {
try {
dpi = Toolkit.getDefaultToolkit().getScreenResolution();
} catch (HeadlessException e) {
dpi = 96;
}
}
try (PDDocument document = Loader.loadPDF(infile, password)) {
PDAcroForm acroForm = document.getDocumentCatalog().getAcroForm();
if (acroForm != null && acroForm.getNeedAppearances()) {
acroForm.refreshAppearances();
}
if (cropbox != null) {
changeCropBox(document, cropbox[0], cropbox[1], cropbox[2], cropbox[3]);
}
long startTime = System.nanoTime();
// render the pages
boolean success = true;
endPage = Math.min(endPage, document.getNumberOfPages());
PDFRenderer renderer = new PDFRenderer(document);
renderer.setSubsamplingAllowed(subsampling);
for (int i = startPage - 1; i < endPage; i++) {
BufferedImage image = renderer.renderImageWithDPI(i, dpi, imageType);
String fileName = outputPrefix + "-" + (i + 1) + "." + imageFormat;
success &= ImageIOUtil.writeImage(image, fileName, dpi, quality);
}
// performance stats
long endTime = System.nanoTime();
long duration = endTime - startTime;
int count = 1 + endPage - startPage;
if (showTime) {
SYSERR.printf("Rendered %d page%s in %dms%n", count, count == 1 ? "" : "s", duration / 1000000);
}
if (!success) {
SYSERR.println("Error: no writer found for image format '" + imageFormat + "'");
return 1;
}
} catch (IOException ioe) {
SYSERR.println("Error converting document [" + ioe.getClass().getSimpleName() + "]: " + ioe.getMessage());
return 4;
}
return 0;
}
use of java.awt.HeadlessException in project Spark by igniterealtime.
the class CertificateDialog method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == okButton) {
// controller should be passed to this class only if there is need to modification content of Keystore.
if (certControll != null) {
addCert = true;
if (certControll instanceof CertificateController && !certControll.isOnExceptionList(certModel) && exceptionBox.isSelected()) {
CertificateController crtCtrl = (CertificateController) certControll;
try {
crtCtrl.addCertificateAsExempted(certModel);
} catch (HeadlessException | InvalidNameException | KeyStoreException e1) {
Log.error(e1);
}
}
}
this.dispose();
} else if (e.getSource() == cancelButton) {
if (certControll != null) {
certControll.setAddToKeystore(false);
}
this.dispose();
} else if (e.getSource() == deleteButton) {
try {
certControll.deleteEntry(certModel.getAlias());
this.dispose();
} catch (KeyStoreException ex) {
Log.error("Couldn't delete the certificate", ex);
}
} else if (e.getSource() == exceptionBox) {
certControll.addOrRemoveFromExceptionList(exceptionBox.isSelected());
} else if (e.getSource() == checkValidity) {
checkValidity();
}
}
Aggregations