Example usage for java.util LinkedList add

List of usage examples for java.util LinkedList add

Introduction

In this page you can find the example usage for java.util LinkedList add.

Prototype

public boolean add(E e) 

Source Link

Document

Appends the specified element to the end of this list.

Usage

From source file:edu.csun.ecs.cs.multitouchj.application.whiteboard.Whiteboard.java

public static void main(String[] args) {
    LinkedList<String> arguments = new LinkedList<String>();
    for (String argument : args) {
        arguments.add(argument);
    }/*www .j ava2 s. c  om*/

    TreeMap<String, String> parameters = new TreeMap<String, String>();
    if (arguments.contains("-ix")) {
        parameters.put(ObjectObserverMoteJ.Parameter.InverseX.toString(), "");
    }
    if (arguments.contains("-iy")) {
        parameters.put(ObjectObserverMoteJ.Parameter.InverseY.toString(), "");
    }

    Whiteboard whiteboard = new Whiteboard();
    whiteboard.run(parameters);
}

From source file:example.Publisher.java

public static void main(String[] args) throws Exception {

    String user = env("ACTIVEMQ_USER", "admin");
    String password = env("ACTIVEMQ_PASSWORD", "password");
    String host = env("ACTIVEMQ_HOST", "localhost");
    int port = Integer.parseInt(env("ACTIVEMQ_PORT", "1883"));
    final String destination = arg(args, 0, "/topic/event");

    int messages = 10000;
    int size = 256;

    String DATA = "abcdefghijklmnopqrstuvwxyz";
    String body = "";
    for (int i = 0; i < size; i++) {
        body += DATA.charAt(i % DATA.length());
    }//from   www.  java  2s . co m
    Buffer msg = new AsciiBuffer(body);

    MQTT mqtt = new MQTT();
    mqtt.setHost(host, port);
    mqtt.setUserName(user);
    mqtt.setPassword(password);

    FutureConnection connection = mqtt.futureConnection();
    connection.connect().await();

    final LinkedList<Future<Void>> queue = new LinkedList<Future<Void>>();
    UTF8Buffer topic = new UTF8Buffer(destination);
    for (int i = 1; i <= messages; i++) {

        // Send the publish without waiting for it to complete. This allows us
        // to send multiple message without blocking..
        queue.add(connection.publish(topic, msg, QoS.AT_LEAST_ONCE, false));

        // Eventually we start waiting for old publish futures to complete
        // so that we don't create a large in memory buffer of outgoing message.s
        if (queue.size() >= 1000) {
            queue.removeFirst().await();
        }

        if (i % 1000 == 0) {
            System.out.println(String.format("Sent %d messages.", i));
        }
    }

    queue.add(connection.publish(topic, new AsciiBuffer("SHUTDOWN"), QoS.AT_LEAST_ONCE, false));
    while (!queue.isEmpty()) {
        queue.removeFirst().await();
    }

    connection.disconnect().await();

    System.exit(0);
}

From source file:edu.csun.ecs.cs.multitouchj.application.touchpong.TouchPong.java

public static void main(String[] args) {
    LinkedList<String> arguments = new LinkedList<String>();
    for (String argument : args) {
        arguments.add(argument);
    }//from www.j  av  a 2  s  .co  m

    TreeMap<String, String> parameters = new TreeMap<String, String>();
    if (arguments.contains("-ix")) {
        parameters.put(ObjectObserverMoteJ.Parameter.InverseX.toString(), "");
    }
    if (arguments.contains("-iy")) {
        parameters.put(ObjectObserverMoteJ.Parameter.InverseY.toString(), "");
    }

    TouchPong touchPong = new TouchPong();
    touchPong.run(parameters);
}

From source file:com.apipulse.bastion.Main.java

public static void main(String[] args) throws IOException, ClassNotFoundException {
    log.info("Bastion starting. Loading chains");
    final File dir = new File("etc/chains");

    final LinkedList<ActorRef> chains = new LinkedList<ActorRef>();
    for (File file : dir.listFiles()) {
        if (!file.getName().startsWith(".") && file.getName().endsWith(".yaml")) {
            log.info("Loading chain: " + file.getName());
            ChainConfig config = new ChainConfig(IOUtils.toString(new FileReader(file)));
            ActorRef ref = BastionActors.getInstance().initChain(config.getName(),
                    Class.forName(config.getQualifiedClass()));
            Iterator<StageConfig> iterator = config.getStages().iterator();
            while (iterator.hasNext())
                ref.tell(iterator.next(), null);
            chains.add(ref);
        }//from  w ww .j a  v  a2s .  c om
    }
    SpringApplication app = new SpringApplication();
    HashSet<Object> objects = new HashSet<Object>();
    objects.add(ApiController.class);
    final ConfigurableApplicationContext context = app.run(ApiController.class, args);
    Runtime.getRuntime().addShutdownHook(new Thread() {
        @Override
        public void run() {
            try {
                log.info("Bastion shutting down");
                Iterator<ActorRef> iterator = chains.iterator();
                while (iterator.hasNext())
                    iterator.next().tell(new StopMessage(), null);
                Thread.sleep(2000);
                context.stop();
                log.info("Bastion shutdown complete");
            } catch (Exception e) {
            }
        }
    });
}

From source file:org.eclipse.swordfish.core.configuration.xml.SaxParsingPrototype.java

/**
 * @param args/*ww w.ja  v  a  2  s.  c  o  m*/
 */
public static void main(String[] args) throws Exception {
    XMLInputFactory inputFactory = XMLInputFactory.newInstance();
    LinkedList<String> currentElements = new LinkedList<String>();
    InputStream in = SaxParsingPrototype.class.getResource("ComplexPidXmlProperties.xml").openStream();
    XMLEventReader eventReader = inputFactory.createXMLEventReader(in);
    Map<String, List<String>> props = new HashMap<String, List<String>>();
    // Read the XML document
    while (eventReader.hasNext()) {
        XMLEvent event = eventReader.nextEvent();
        if (event.isCharacters() && !event.asCharacters().isWhiteSpace()) {
            putElement(props, getQualifiedName(currentElements), event.asCharacters().getData());

        } else if (event.isStartElement()) {
            System.out.println(event.asStartElement().getName());
            currentElements.add(event.asStartElement().getName().getLocalPart());
            for (Iterator attrIt = event.asStartElement().getAttributes(); attrIt.hasNext();) {
                Attribute attribute = (Attribute) attrIt.next();
                putElement(props, getQualifiedName(currentElements) + "[@" + attribute.getName() + "]",
                        attribute.getValue());

            }
        } else if (event.isAttribute()) {
        } else if (event.isEndElement()) {
            String lastElem = event.asEndElement().getName().getLocalPart();
            if (!currentElements.getLast().equals(lastElem)) {
                throw new UnsupportedOperationException(lastElem + "," + currentElements.getLast());
            }
            currentElements.removeLast();
        }
    }

    eventReader.close();
}

From source file:de.tudarmstadt.ukp.dariah.pipeline.RunPipeline.java

public static void main(String[] args) {

    Date startDate = new Date();

    PrintStream ps;/*www .j ava2s .  c om*/
    try {
        ps = new PrintStream("error.log");
        System.setErr(ps);
    } catch (FileNotFoundException e) {
        System.out.println("Errors cannot be redirected");
    }

    try {
        if (!parseArgs(args)) {
            System.out.println("Usage: java -jar pipeline.jar -help");
            System.out.println("Usage: java -jar pipeline.jar -input <Input File> -output <Output Folder>");
            System.out.println(
                    "Usage: java -jar pipeline.jar -config <Config File> -input <Input File> -output <Output Folder>");
            return;
        }
    } catch (ParseException e) {
        e.printStackTrace();
        System.out.println(
                "Error when parsing command line arguments. Use\njava -jar pipeline.jar -help\n to get further information");
        System.out.println("See error.log for further details");
        return;
    }

    LinkedList<String> configFiles = new LinkedList<>();

    String configFolder = "configs/";
    configFiles.add(configFolder + "default.properties");

    //Language dependent properties file
    String path = configFolder + "default_" + optLanguage + ".properties";
    File f = new File(path);
    if (f.exists()) {
        configFiles.add(path);
    } else {
        System.out.println("Language config file: " + path + " not found");
    }

    String[] configFileArg = new String[0];
    for (int i = 0; i < args.length - 1; i++) {
        if (args[i].equals("-config")) {
            configFileArg = args[i + 1].split("[,;]");
            break;
        }
    }

    for (String configFile : configFileArg) {

        f = new File(configFile);
        if (f.exists()) {
            configFiles.add(configFile);
        } else {
            //Check in configs folder
            path = configFolder + configFile;

            f = new File(path);
            if (f.exists()) {
                configFiles.add(path);
            } else {
                System.out.println("Config file: " + configFile + " not found");
                return;
            }
        }
    }

    for (String configFile : configFiles) {
        try {
            parseConfig(configFile);
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("Exception when parsing config file: " + configFile);
            System.out.println("See error.log for further details");
        }
    }

    printConfiguration(configFiles.toArray(new String[0]));

    try {

        // Read in the input files
        String defaultFileExtension = (optReader == ReaderType.XML) ? ".xml" : ".txt";

        GlobalFileStorage.getInstance().readFilePaths(optInput, defaultFileExtension, optOutput, optResume);

        System.out.println("Process " + GlobalFileStorage.getInstance().size() + " files");

        CollectionReaderDescription reader;

        if (optReader == ReaderType.XML) {
            reader = createReaderDescription(XmlReader.class, XmlReader.PARAM_LANGUAGE, optLanguage);
        } else {
            reader = createReaderDescription(TextReaderWithInfo.class, TextReaderWithInfo.PARAM_LANGUAGE,
                    optLanguage);
        }

        AnalysisEngineDescription paragraph = createEngineDescription(ParagraphSplitter.class,
                ParagraphSplitter.PARAM_SPLIT_PATTERN,
                (optParagraphSingleLineBreak) ? ParagraphSplitter.SINGLE_LINE_BREAKS_PATTERN
                        : ParagraphSplitter.DOUBLE_LINE_BREAKS_PATTERN);

        AnalysisEngineDescription seg = createEngineDescription(optSegmenterCls, optSegmenterArguments);

        AnalysisEngineDescription paragraphSentenceCorrector = createEngineDescription(
                ParagraphSentenceCorrector.class);

        AnalysisEngineDescription frenchQuotesSeg = createEngineDescription(PatternBasedTokenSegmenter.class,
                PatternBasedTokenSegmenter.PARAM_PATTERNS, "+|[]");

        AnalysisEngineDescription quotesSeg = createEngineDescription(PatternBasedTokenSegmenter.class,
                PatternBasedTokenSegmenter.PARAM_PATTERNS, "+|[\"\"]");

        AnalysisEngineDescription posTagger = createEngineDescription(optPOSTaggerCls, optPOSTaggerArguments);

        AnalysisEngineDescription lemma = createEngineDescription(optLemmatizerCls, optLemmatizerArguments);

        AnalysisEngineDescription chunker = createEngineDescription(optChunkerCls, optChunkerArguments);

        AnalysisEngineDescription morph = createEngineDescription(optMorphTaggerCls, optMorphTaggerArguments);

        AnalysisEngineDescription hyphenation = createEngineDescription(optHyphenationCls,
                optHyphenationArguments);

        AnalysisEngineDescription depParser = createEngineDescription(optDependencyParserCls,
                optDependencyParserArguments);

        AnalysisEngineDescription constituencyParser = createEngineDescription(optConstituencyParserCls,
                optConstituencyParserArguments);

        AnalysisEngineDescription ner = createEngineDescription(optNERCls, optNERArguments);

        AnalysisEngineDescription directSpeech = createEngineDescription(DirectSpeechAnnotator.class,
                DirectSpeechAnnotator.PARAM_START_QUOTE, optStartQuote);

        AnalysisEngineDescription srl = createEngineDescription(optSRLCls, optSRLArguments); //Requires DKPro 1.8.0   

        AnalysisEngineDescription coref = createEngineDescription(optCorefCls, optCorefArguments); //StanfordCoreferenceResolver.PARAM_POSTPROCESSING, true

        AnalysisEngineDescription writer = createEngineDescription(DARIAHWriter.class,
                DARIAHWriter.PARAM_TARGET_LOCATION, optOutput, DARIAHWriter.PARAM_OVERWRITE, true);

        AnalysisEngineDescription annWriter = createEngineDescription(AnnotationWriter.class);

        AnalysisEngineDescription noOp = createEngineDescription(NoOpAnnotator.class);

        System.out.println("\nStart running the pipeline (this may take a while)...");

        while (!GlobalFileStorage.getInstance().isEmpty()) {
            try {
                SimplePipeline.runPipeline(reader, paragraph, (optSegmenter) ? seg : noOp,
                        paragraphSentenceCorrector, frenchQuotesSeg, quotesSeg,
                        (optPOSTagger) ? posTagger : noOp, (optLemmatizer) ? lemma : noOp,
                        (optChunker) ? chunker : noOp, (optMorphTagger) ? morph : noOp,
                        (optHyphenation) ? hyphenation : noOp, directSpeech,
                        (optDependencyParser) ? depParser : noOp,
                        (optConstituencyParser) ? constituencyParser : noOp, (optNER) ? ner : noOp,
                        (optSRL) ? srl : noOp, //Requires DKPro 1.8.0
                        (optCoref) ? coref : noOp, writer
                //                  ,annWriter
                );
            } catch (OutOfMemoryError e) {
                System.out.println("Out of Memory at file: "
                        + GlobalFileStorage.getInstance().getLastPolledFile().getAbsolutePath());
            }
        }

        Date enddate = new Date();
        double duration = (enddate.getTime() - startDate.getTime()) / (1000 * 60.0);

        System.out.println("---- DONE -----");
        System.out.printf("All files processed in %.2f minutes", duration);
    } catch (ResourceInitializationException e) {
        System.out.println("Error when initializing the pipeline.");
        if (e.getCause() instanceof FileNotFoundException) {
            System.out.println("File not found. Maybe the input / output path is incorrect?");
            System.out.println(e.getCause().getMessage());
        }

        e.printStackTrace();
        System.out.println("See error.log for further details");
    } catch (UIMAException e) {
        e.printStackTrace();
        System.out.println("Error in the pipeline.");
        System.out.println("See error.log for further details");
    } catch (IOException e) {
        e.printStackTrace();
        System.out
                .println("Error while reading or writing to the file system. Maybe some paths are incorrect?");
        System.out.println("See error.log for further details");
    }

}

From source file:com.ikanow.aleph2.enrichment.utils.services.JsScriptEngineTestService.java

/** Entry point
 * @param args//from   w w  w  .  j  a  va2s . c om
 * @throws IOException 
 */
public static void main(String[] args) throws IOException {
    if (args.length < 3) {
        System.out
                .println("ARGS: <script-file> <input-file> <output-prefix> [{[len: <LEN>], [group: <GROUP>]}]");
    }

    // STEP 1: load script file

    final String user_script = Files.toString(new File(args[0]), Charsets.UTF_8);

    // STEP 2: get a stream for the JSON file

    final InputStream io_stream = new FileInputStream(new File(args[1]));

    // STEP 3: set up control if applicable

    Optional<JsonNode> json = Optional.of("").filter(__ -> args.length > 3).map(__ -> args[3])
            .map(Lambdas.wrap_u(j -> _mapper.readTree(j)));

    // STEP 4: set up the various objects

    final DataBucketBean bucket = Mockito.mock(DataBucketBean.class);

    final JsScriptEngineService service_under_test = new JsScriptEngineService();

    final LinkedList<ObjectNode> emitted = new LinkedList<>();
    final LinkedList<JsonNode> grouped = new LinkedList<>();
    final LinkedList<JsonNode> externally_emitted = new LinkedList<>();

    final IEnrichmentModuleContext context = Mockito.mock(IEnrichmentModuleContext.class, new Answer<Void>() {
        @SuppressWarnings("unchecked")
        public Void answer(InvocationOnMock invocation) {
            try {
                Object[] args = invocation.getArguments();
                if (invocation.getMethod().getName().equals("emitMutableObject")) {
                    final Optional<JsonNode> grouping = (Optional<JsonNode>) args[3];
                    if (grouping.isPresent()) {
                        grouped.add(grouping.get());
                    }
                    emitted.add((ObjectNode) args[1]);
                } else if (invocation.getMethod().getName().equals("externalEmit")) {
                    final DataBucketBean to = (DataBucketBean) args[0];
                    final Either<JsonNode, Map<String, Object>> out = (Either<JsonNode, Map<String, Object>>) args[1];
                    externally_emitted
                            .add(((ObjectNode) out.left().value()).put("__a2_bucket", to.full_name()));
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
            return null;
        }
    });

    final EnrichmentControlMetadataBean control = BeanTemplateUtils.build(EnrichmentControlMetadataBean.class)
            .with(EnrichmentControlMetadataBean::config,
                    new LinkedHashMap<String, Object>(
                            ImmutableMap.<String, Object>builder().put("script", user_script).build()))
            .done().get();

    service_under_test.onStageInitialize(context, bucket, control,
            Tuples._2T(ProcessingStage.batch, ProcessingStage.grouping), Optional.empty());

    final BeJsonParser json_parser = new BeJsonParser();

    // Run the file through

    final Stream<Tuple2<Long, IBatchRecord>> json_stream = StreamUtils
            .takeUntil(Stream.generate(() -> json_parser.getNextRecord(io_stream)), i -> null == i)
            .map(j -> Tuples._2T(0L, new BatchRecord(j)));

    service_under_test.onObjectBatch(json_stream, json.map(j -> j.get("len")).map(j -> (int) j.asLong(0L)),
            json.map(j -> j.get("group")));

    System.out.println("RESULTS: ");
    System.out.println("emitted: " + emitted.size());
    System.out.println("grouped: " + grouped.size());
    System.out.println("externally emitted: " + externally_emitted.size());
    Files.write(emitted.stream().map(j -> j.toString()).collect(Collectors.joining(";")),
            new File(args[2] + "emit.json"), Charsets.UTF_8);
    Files.write(grouped.stream().map(j -> j.toString()).collect(Collectors.joining(";")),
            new File(args[2] + "group.json"), Charsets.UTF_8);
    Files.write(externally_emitted.stream().map(j -> j.toString()).collect(Collectors.joining(";")),
            new File(args[2] + "external_emit.json"), Charsets.UTF_8);
}

From source file:evaluation.evaluation2OrBACGeneration.java

public static void main(String[] args) throws IOException, ParseException, COrbacException {

    for (int i = 0; i < 5; i++) {

        String info = null;//  w ww  .  ja va  2  s .  co m

        LinkedList<Long> policyGenerationTime = new LinkedList<Long>();
        LinkedList<Long> allocationTime = new LinkedList<Long>();

        for (int totalClientNumber = 10; totalClientNumber < 61; totalClientNumber = totalClientNumber + 10) {

            for (int totalHOSTNumber = 10; totalHOSTNumber < 61; totalHOSTNumber = totalHOSTNumber + 10)

            {

                int count = 0;

                util.test.VMAndHostGeneration(totalClientNumber, totalHOSTNumber);
                long returnValue[] = util.test.timeMeasure(totalClientNumber, totalHOSTNumber);

                info = info + "-----------------------------------\n";
                info = info + "VM: " + totalClientNumber + "\n";
                info = info + "HOST: " + totalHOSTNumber + "\n";
                info = info + "Policy generation time: " + returnValue[0] + "\n";
                info = info + "allocation  time: " + returnValue[1] + "\n";

                if ((totalClientNumber == 10) && (totalHOSTNumber == 10)) {
                    policyGenerationTime.add(returnValue[0]);
                    allocationTime.add(returnValue[1]);
                }

                else {
                    policyGenerationTime.set(count, policyGenerationTime.get(count) + returnValue[0]);
                    allocationTime.set(count, allocationTime.get(count) + returnValue[1]);
                }
                count++;

            }

            method.fromStringToFile(info, "evaluation" + File.separator + "test2and3.txt");

        }

    }

}

From source file:net.sf.firemox.Magic.java

/**
 * @param args//from   ww  w .  j  ava  2 s.c o m
 *          the command line arguments
 * @throws Exception
 */
public static void main(String[] args) throws Exception {
    Log.init();
    Log.debug("MP v" + IdConst.VERSION + ", jre:" + System.getProperty("java.runtime.version") + ", jvm:"
            + System.getProperty("java.vm.version") + ",os:" + System.getProperty("os.name") + ", res:"
            + Toolkit.getDefaultToolkit().getScreenSize().width + "x"
            + Toolkit.getDefaultToolkit().getScreenSize().height + ", root:" + MToolKit.getRootDir());
    System.setProperty("swing.aatext", "true");
    System.setProperty(SubstanceLookAndFeel.WATERMARK_IMAGE_PROPERTY,
            MToolKit.getIconPath(Play.ZONE_NAME + "/hardwoodfloor.png"));

    final File substancelafFile = MToolKit.getFile(FILE_SUBSTANCE_PROPERTIES);
    if (substancelafFile == null) {
        Log.warn("Unable to locate '" + FILE_SUBSTANCE_PROPERTIES
                + "' file, you are using the command line with wrong configuration. See http://www.firemox.org/dev/project.html documentation");
    } else {
        System.getProperties().load(new FileInputStream(substancelafFile));
    }
    MToolKit.defaultFont = new Font("Arial", 0, 11);
    try {
        if (args.length > 0) {
            final String[] args2 = new String[args.length - 1];
            System.arraycopy(args, 1, args2, 0, args.length - 1);
            if ("-rebuild".equals(args[0])) {
                XmlConfiguration.main(args2);
            } else if ("-oracle2xml".equals(args[0])) {
                Oracle2Xml.main(args2);
            } else if ("-batch".equals(args[0])) {
                if ("-server".equals(args[1])) {
                    batchMode = BATCH_SERVER;
                } else if ("-client".equals(args[1])) {
                    batchMode = BATCH_CLIENT;
                }
            } else {
                Log.error("Unknown options '" + Arrays.toString(args)
                        + "'\nUsage : java -jar starter.jar <options>, where options are :\n"
                        + "\t-rebuild -game <tbs name> [-x] [-d] [-v] [-h] [-f] [-n]\n"
                        + "\t-oracle2xml -f <oracle file> -d <output directory> [-v] [-h]");
            }
            System.exit(0);
            return;
        }
        if (batchMode == -1 && !"Mac OS X".equals(System.getProperty("os.name"))) {
            splash = new SplashScreen(MToolKit.getIconPath("splash.jpg"), null, 2000);
        }

        // language settings
        LanguageManager.initLanguageManager(Configuration.getString("language", "auto"));
    } catch (Throwable t) {
        Log.error("START-ERROR : \n\t" + t.getMessage());
        System.exit(1);
        return;
    }
    Log.debug("MP Language : " + LanguageManager.getLanguage().getName());
    speparateAvatar = Toolkit.getDefaultToolkit().getScreenSize().height > 768;

    // verify the java version, minimal is 1.5
    if (new JavaVersion().compareTo(new JavaVersion(IdConst.MINIMAL_JRE)) == -1) {
        Log.error(LanguageManager.getString("wrongjava") + IdConst.MINIMAL_JRE);
    }

    // load look and feel settings
    lookAndFeelName = Configuration.getString("preferred", MUIManager.LF_SUBSTANCE_CLASSNAME);
    // try {
    // FileInputStream in= new FileInputStream("MAGIC.TTF");
    // MToolKit.defaultFont= Font.createFont(Font.TRUETYPE_FONT, in);
    // in.close();
    // MToolKit.defaultFont= MToolKit.defaultFont.deriveFont(Font.BOLD, 11);
    // }
    // catch (FileNotFoundException e) {
    // System.out.println("editorfont.ttf not found, using default.");
    // }
    // catch (Exception ex) {
    // ex.printStackTrace();
    // }

    // Read available L&F
    final LinkedList<Pair<String, String>> lfList = new LinkedList<Pair<String, String>>();
    try {
        BufferedReader buffReader = new BufferedReader(
                new InputStreamReader(MToolKit.getResourceAsStream(IdConst.FILE_THEME_SETTINGS)));
        String line;
        while ((line = buffReader.readLine()) != null) {
            line = line.trim();
            if (!line.startsWith("#")) {
                final int index = line.indexOf(';');
                if (index != -1) {
                    lfList.add(new Pair<String, String>(line.substring(0, index), line.substring(index + 1)));
                }
            }
        }
        IOUtils.closeQuietly(buffReader);
    } catch (Throwable e) {
        // no place for resolve this problem
        Log.debug("Error reading L&F properties : " + e.getMessage());
    }
    for (Pair<String, String> pair : lfList) {
        UIManager.installLookAndFeel(pair.key, pair.value);
    }

    // install L&F
    if (SkinLF.isSkinLF(lookAndFeelName)) {
        // is a SkinLF Look & Feel
        /*
         * Make sure we have a nice window decoration.
         */
        SkinLF.installSkinLF(lookAndFeelName);
    } else {
        // is Metal Look & Feel
        if (!MToolKit.isAvailableLookAndFeel(lookAndFeelName)) {
            // preferred look&feel is not available
            JOptionPane.showMessageDialog(magicForm,
                    LanguageManager.getString("preferredlfpb", lookAndFeelName),
                    LanguageManager.getString("error"), JOptionPane.INFORMATION_MESSAGE);
            setDefaultUI();
        }

        // Install the preferred
        LookAndFeel newLAF = MToolKit.geLookAndFeel(lookAndFeelName);
        frameDecorated = newLAF.getSupportsWindowDecorations();

        /*
         * Make sure we have a nice window decoration.
         */
        JFrame.setDefaultLookAndFeelDecorated(frameDecorated);
        JDialog.setDefaultLookAndFeelDecorated(frameDecorated);
        UIManager.setLookAndFeel(MToolKit.geLookAndFeel(lookAndFeelName));
    }

    // Start main thread
    try {
        new Magic();
        SwingUtilities.invokeLater(SkinLF.REFRESH_RUNNER);
    } catch (Throwable e) {
        Log.fatal("In main thread, occurred exception : ", e);
        ConnectionManager.closeConnexions();
        return;
    }
}

From source file:dk.dma.epd.common.prototype.gui.route.RoutePropertiesDialogCommon.java

/**
 * Test method//from   w  w w .ja  va  2 s.c  o  m
 */
public static final void main(String... args) throws Exception {

    //=====================
    // Create test data
    //=====================
    final Route route = new Route();
    route.setName("Test route");
    final LinkedList<RouteWaypoint> waypoints = new LinkedList<>();
    route.setWaypoints(waypoints);
    route.setStarttime(new Date());

    int len = 10;
    final boolean[] locked = new boolean[len];
    for (int x = 0; x < len; x++) {
        locked[x] = false;
        RouteWaypoint wp = new RouteWaypoint();
        waypoints.add(wp);

        // Set leg values
        if (x > 0) {
            RouteLeg leg = new RouteLeg();
            leg.setSpeed(12.00 + x);
            leg.setHeading(Heading.RL);
            leg.setXtdPort(185.0);
            leg.setXtdStarboard(185.0);

            wp.setInLeg(leg);
            waypoints.get(x - 1).setOutLeg(leg);
            leg.setStartWp(waypoints.get(x - 1));
            leg.setEndWp(wp);
        }

        wp.setName("WP_00" + x);
        wp.setPos(Position.create(56.02505 + Math.random() * 2.0, 12.37 + Math.random() * 2.0));
    }
    for (int x = 1; x < len; x++) {
        waypoints.get(x).setTurnRad(0.5 + x * 0.2);
    }
    route.calcValues(true);

    // Launch the route properties dialog
    PntTime.init();
    RoutePropertiesDialogCommon dialog = new RoutePropertiesDialogCommon(null, null, route, false);
    dialog.setVisible(true);
}