Пример #1
0
  public void applyConfiguration(Configuration configuration) {
    String lookAndFeel = configuration.getSelectedLookAndFeel();
    if (lookAndFeel == null) {
      lookAndFeel = UIManager.getSystemLookAndFeelClassName();
    }
    setLookAndFeel(configuration.getSelectedLookAndFeel());

    PreferenceManager.store(configuration);
  }
Пример #2
0
  public static void main(String[] args) {
    // @formatter:off
    Options options = new Options();
    OptionHelper.addL(options, OPTION_CONFIG, true, false, "path", "config file");
    // @formatter:on

    CommandLineParser clp = new DefaultParser();

    CommandLine line = null;
    try {
      line = clp.parse(options, args);
    } catch (ParseException e) {
      System.err.println("Parsing command line failed: " + e.getMessage());
      new HelpFormatter().printHelp(HELP_MESSAGE, options);
      System.exit(1);
    }

    StringOption config = ArgumentHelper.getString(line, OPTION_CONFIG);
    if (config.hasValue()) {
      String configPath = config.getValue();
      LiveConfig.setPath(configPath);
    }

    Configuration configuration = PreferenceManager.getConfiguration();
    String lookAndFeel = configuration.getSelectedLookAndFeel();
    if (lookAndFeel == null) {
      lookAndFeel = UIManager.getSystemLookAndFeelClassName();
    }
    try {
      UIManager.setLookAndFeel(lookAndFeel);
    } catch (Exception e) {
      logger.error(
          "error while setting look and feel '"
              + lookAndFeel
              + "': "
              + e.getClass().getSimpleName()
              + ", message: "
              + e.getMessage());
    }

    Content content = null;
    String filename = "res/presets/Startup.geom";

    String[] extra = line.getArgs();
    if (extra.length > 0) {
      filename = extra[0];
    }

    ContentReader reader = new ContentReader();
    InputStream input =
        Thread.currentThread().getContextClassLoader().getResourceAsStream(filename);

    if (input == null) {
      Path path = Paths.get(filename);
      try {
        input = Files.newInputStream(path);
      } catch (IOException e) {
        logger.error("unable to load file", e);
      }
    }

    try {
      content = reader.read(input);
    } catch (Exception e) {
      logger.info("unable to load startup geometry file", e);
      logger.info("Exception: " + e.getClass().getSimpleName());
      logger.info("Message: " + e.getMessage());
    }

    final LiveCG runner = new LiveCG();
    final Content c = content;

    SwingUtilities.invokeLater(
        new Runnable() {
          @Override
          public void run() {
            runner.setup(true, c);
          }
        });
    SwingUtilities.invokeLater(
        new Runnable() {
          @Override
          public void run() {
            runner.frame.requestFocus();
          }
        });
  }