Example usage for java.awt GraphicsEnvironment isHeadless

List of usage examples for java.awt GraphicsEnvironment isHeadless

Introduction

In this page you can find the example usage for java.awt GraphicsEnvironment isHeadless.

Prototype

public static boolean isHeadless() 

Source Link

Document

Tests whether or not a display, keyboard, and mouse can be supported in this environment.

Usage

From source file:autoupdater.DownloadLatestZipFromRepo.java

/**
 * Retrieves the latest version of a maven jar file from a maven repository,
 * also checks if the environment is headless or not.
 *
 * @param jarPath           the URL of the location of the jar that needs to be
 *                          updated on the file system. cannot be {@code null}
 * @param args              the args that will be passed to the newly downloaded program
 *                          when started, cannot be {@code null}
 * @param jarRepositoryRoot the maven repository to go look in, cannot be
 *                          {@code null}
 * @throws IOException        should there be problems with reading or writing
 *                            files during the updating
 * @throws XMLStreamException if there was a problem reading the meta data
 *                            from the remote maven repository
 * @throws URISyntaxException//from   w ww  .  ja  va  2  s  .com
 */
public static void downloadLatestZipFromRepo(final Path jarPath, String[] args, URL jarRepositoryRoot)
        throws IOException, XMLStreamException, URISyntaxException {
    downloadURL = jarRepositoryRoot;
    if (GraphicsEnvironment.isHeadless()) {
        fileDAO = new HeadlessFileDAO();
    } else {
        fileDAO = new GUIFileDAO();
    }

}

From source file:com.cloudbees.jenkins.support.impl.LoadStats.java

private void add(@NonNull Container container, String name, LoadStatistics stats) {
    // A headless environment may be missing the fonts required for these graphs, so even though
    // we should be able to generate graphs from a headless environment we will skip the graphs
    // if headless
    boolean headless = GraphicsEnvironment.isHeadless();
    for (MultiStageTimeSeries.TimeScale scale : MultiStageTimeSeries.TimeScale.values()) {
        String scaleName = scale.name().toLowerCase(Locale.ENGLISH);
        if (!headless) {
            BufferedImage image = stats.createTrendChart(scale).createChart().createBufferedImage(500, 400);
            container.add(new ImageContent(String.format("load-stats/%s/%s.png", name, scaleName), image));
        }/*from w  w  w .  j  a  v  a  2 s. c  o  m*/
        container.add(new CsvContent(String.format("load-stats/%s/%s.csv", name, scaleName), stats, scale));
    }
    // on the other hand, if headless we should give an easy way to generate the graphs
    if (headless) {
        container.add(new GnuPlotScript(String.format("load-stats/%s/gnuplot", name)));
    }
}

From source file:net.java.sip.communicator.impl.osdependent.jdic.SystrayServiceJdicImpl.java

/**
 * Initializes a new <tt>SystrayServiceJdicImpl</tt> instance.
 *//*from  ww w.ja  va  2  s .  co  m*/
public SystrayServiceJdicImpl() {
    super(OsDependentActivator.bundleContext);

    SystemTray systray;
    try {
        systray = SystemTray.getSystemTray();
    } catch (Throwable t) {
        if (t instanceof ThreadDeath)
            throw (ThreadDeath) t;
        else {
            systray = null;
            if (!GraphicsEnvironment.isHeadless())
                logger.error("Failed to create a systray!", t);
        }
    }

    this.systray = systray;
    if (this.systray != null) {
        initSystray();
    }
}

From source file:org.squale.squaleweb.applicationlayer.action.export.ppt.AuditReportPPTData.java

/**
 * Constructor//  w  ww . j  a va2 s.com
 * 
 * @param pRequest request
 * @param params bean containing information
 * @param pProjectReports list of results
 * @throws PPTGeneratorException if error
 */
public AuditReportPPTData(HttpServletRequest pRequest, AuditReportParamForm params, List pProjectReports)
        throws PPTGeneratorException {
    projectReports = pProjectReports;
    this.request = pRequest;

    if (!GraphicsEnvironment.isHeadless()) {
        log.warn("java.awt.headless is not activated on WAS JVM. Graphic generation will fail !");
    }

    try {
        setPresentation(params.getPresentation().getInputStream());
        setModel(params.getModel().getInputStream());
        setMapping(params.getMapping().getInputStream());
    } catch (FileNotFoundException e) {
        throw new PPTGeneratorException(e.getMessage());
    } catch (IOException e) {
        throw new PPTGeneratorException(e.getMessage());
    }
}

From source file:it.geosolutions.imageio.plugins.nitronitf.ImageIOUtils.java

public static boolean canDisplay(BufferedImage image) {
    log.info("Data Type: " + image.getSampleModel().getDataType());
    log.info("Pixel Size: " + image.getColorModel().getPixelSize());

    if (image.getSampleModel().getDataType() == DataBuffer.TYPE_FLOAT
            && image.getColorModel().getPixelSize() == 64)
        return false;
    return !GraphicsEnvironment.isHeadless();
}

From source file:at.tuwien.ifs.somtoolbox.visualization.PMatrix.java

public PMatrix() {
    VISUALIZATION_NAMES = new String[] { "P-Matrix", "U*-Matrix" };
    VISUALIZATION_SHORT_NAMES = new String[] { "PMatrix", "UStarMatrix" };
    NUM_VISUALIZATIONS = VISUALIZATION_NAMES.length;
    VISUALIZATION_DESCRIPTIONS = new String[] {
            "Implementation of the P-Matrix, as described in Ultsch, A.\n"
                    + "Maps for the Visualization of high-dimensional Data Spaces.\n"
                    + "In Proceedings Workshop on Self-Organizing Maps (WSOM 2003), Kyushu, Japan",
            "Implementation of the U*-Matrix (U- and P-Matrix combined), as described in Ultsch. A.\n"
                    + "U*-Matrix: a Tool to visualize Clusters in high dimensional Data\n"
                    + "Technical Report No. 36, Dept. of Mathematics and Computer Science, University of Marburg, Germany, 2003" };
    neededInputObjects = new String[] { SOMVisualisationData.INPUT_VECTOR_DISTANCE_MATRIX,
            SOMVisualisationData.INPUT_VECTOR };
    // don't initialise the control panel if we have no graphics environment (e.g. in server applications)
    if (!GraphicsEnvironment.isHeadless()) {
        controlPanel = new PMatrixControlPanel();
    }//ww w.j  a va2s  .c om
}

From source file:com.yfiton.oauth.OAuthNotifier.java

protected AuthorizationData requestAuthorizationData(String authorizationCodeParameterName,
        String... requestParameterNames) throws NotificationException {
    log.trace("First call requires to get authorization");

    String stateParameterValue = UUID.randomUUID().toString();
    String authorizationUrl = getAuthorizationUrl(stateParameterValue);

    log.debug("Opening {} to get authorization", authorizationUrl);

    AuthorizationData authorizationData;

    if (GraphicsEnvironment.isHeadless() || isHeadlessEnforced()) {
        log.debug("Headless mode used");
        authorizationData = getAuthorizationDataHeadless(authorizationUrl, authorizationCodeParameterName,
                requestParameterNames);/*  ww w.  j  a  v a 2 s .  co  m*/
    } else {
        log.debug("Graphical mode used");
        authorizationData = getAuthorizationDataUsingScreen(authorizationUrl, authorizationCodeParameterName);
    }

    checkState(stateParameterValue, authorizationData);

    return authorizationData;
}

From source file:net.sf.taverna.t2.workbench.ui.credentialmanager.WarnUserAboutJCEPolicyDialog.java

/**
 * Warn user that they need to install Java Cryptography Extension (JCE)
 * Unlimited Strength Jurisdiction Policy if they want Credential Manager to
 * function properly./*w  w  w . j  av  a  2 s  .  c om*/
 */
public static void warnUserAboutJCEPolicy(ApplicationConfiguration applicationConfiguration,
        DistinguishedNameParser dnParser) {
    /*
     * Do not pop up a dialog if we are running headlessly. If we have
     * warned the user and they do not want us to remind them again - exit.
     */
    if (warnedUser || GraphicsEnvironment.isHeadless()
            || doNotWarnFile(applicationConfiguration, dnParser).exists())
        return;

    WarnUserAboutJCEPolicyDialog warnDialog = new WarnUserAboutJCEPolicyDialog(applicationConfiguration,
            dnParser);
    warnDialog.setVisible(true);
    warnedUser = true;
}