Example usage for java.util HashMap HashMap

List of usage examples for java.util HashMap HashMap

Introduction

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

Prototype

public HashMap() 

Source Link

Document

Constructs an empty HashMap with the default initial capacity (16) and the default load factor (0.75).

Usage

From source file:com.tengen.MultiArrayFindTest.java

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

    MongoClient client = new MongoClient();
    DB db = client.getDB("school");
    DBCollection collection = db.getCollection("students");

    System.out.println("Find one:");
    DBObject one = collection.findOne();
    System.out.println(one);//from w  ww. j  a  v  a 2 s.com

    System.out.println("\nFind all: ");
    DBCursor cursor = collection.find().sort(new BasicDBObject("_id", 1));
    System.out.println(cursor.count());

    try {
        while (cursor.hasNext()) {

            int id = (Integer) cursor.next().get("_id");
            //String s =  cursor.next().get("name");

            Map<Integer, String> myMap = new HashMap<Integer, String>();

            BasicBSONList bl = (BasicBSONList) cursor.next().get("scores");
            for (Object bo : bl) {

                BasicBSONObject bo1 = (BasicBSONObject) bo;
                System.out.println(bo);
                System.out.println(Integer.toString(id));

                if (1 > 1) {
                }
                double total1 = Double.parseDouble(bo1.get("score").toString());
                System.out.println("score1: " + total1);

                myMap.put(id, bo1.get("score").toString());
                System.out.println("score: " + myMap.get(id));

                double total = Double.parseDouble(myMap.get(id).toString());
                System.out.println("score: " + total);

                //}
            }

        }

    } finally {
        cursor.close();
    }

    System.out.println("\nCount:");
    long count = collection.count();
    System.out.println(count);
}

From source file:httpclient.UploadAction.java

public static void main(String[] args) throws FileNotFoundException {
    File targetFile1 = new File("F:\\2.jpg");
    // File targetFile2 = new File("F:\\1.jpg");
    FileInputStream fis1 = new FileInputStream(targetFile1);
    // FileInputStream fis2 = new FileInputStream(targetFile2);
    // String targetURL =
    // "http://static.fangbiandian.com.cn/round_server/upload/uploadFile.do";
    String targetURL = "http://www.fangbiandian.com.cn/round_server/user/updateUserInfo.do";
    HttpPost filePost = new HttpPost(targetURL);
    try {//  w ww  .j a  v  a2s .  c o m
        // ?????
        HttpClient client = new DefaultHttpClient();
        // FormBodyPart fbp1 = new FormBodyPart("file1", new
        // FileBody(targetFile1));
        // FormBodyPart fbp2 = new FormBodyPart("file2", new
        // FileBody(targetFile2));
        // FormBodyPart fbp3 = new FormBodyPart("file3", new
        // FileBody(targetFile3));
        // List<FormBodyPart> picList = new ArrayList<FormBodyPart>();
        // picList.add(fbp1);
        // picList.add(fbp2);
        // picList.add(fbp3);
        Map<String, Object> paramMap = new HashMap<String, Object>();
        paramMap.put("userId", "65478A5CD8D20C3807EE16CF22AF8A17");
        Map<String, Object> map = new HashMap<String, Object>();
        String jsonStr = JSON.toJSONString(paramMap);
        map.put("cid", 321);
        map.put("request", jsonStr);
        String jsonString = JSON.toJSONString(map);
        MultipartEntity multiEntity = new MultipartEntity();
        Charset charset = Charset.forName("UTF-8");
        multiEntity.addPart("request", new StringBody(jsonString, charset));
        multiEntity.addPart("photo", new InputStreamBody(fis1, "2.jpg"));
        // multiEntity.addPart("licenseUrl", new InputStreamBody(fis2,
        // "1.jpg"));
        filePost.setEntity(multiEntity);
        HttpResponse response = client.execute(filePost);
        int code = response.getStatusLine().getStatusCode();
        System.out.println(code);
        if (HttpStatus.SC_OK == code) {
            System.out.println("?");
            HttpEntity entity = response.getEntity();
            if (entity != null) {
                InputStream instream = entity.getContent();
                try {
                    // do something useful
                    BufferedReader reader = new BufferedReader(new InputStreamReader(instream));
                    String str = null;
                    while ((str = reader.readLine()) != null) {
                        System.out.println(str);
                    }
                } finally {
                    instream.close();
                }
            }
        } else {
            System.out.println("");
        }
    } catch (Exception ex) {
        ex.printStackTrace();
    } finally {
        filePost.releaseConnection();
    }
}

From source file:zz.pseas.ghost.login.taobao.LogInTaobao.java

@SuppressWarnings("unused")
public static void main(String[] args) throws Exception {

    String tbuserNmae = "TBname";
    String tbpassWord = "TBpasssword";

    String url = "https://login.taobao.com/member/login.jhtml";
    WebDriver ie = BrowserFactory.getIE();
    ie.get(url);/*from  ww w  .j  a  v a  2  s.co  m*/

    Thread.sleep(5000L);

    Set<Cookie> cookies = ie.manage().getCookies();
    CookieStore store = DownloadUtil.convertToCookieStore(cookies);

    GhostClient client = new GhostClient("utf-8", store);

    String html = ie.getPageSource();
    String pbk = Jsoup.parse(html).select("input#J_PBK").attr("value");
    String pwd1 = RsaUtil.enCode(pbk, "10001", tbuserNmae);

    HashMap<String, String> map = new HashMap<String, String>();
    map.put("TPL_username", tbuserNmae);
    map.put("TPL_password", tbpassWord);
    map.put("fc", "default");
    map.put("from", "tb");
    map.put("gvfdcname", "10");
    map.put("keyLogin", "false");
    map.put("loginASR", "1");
    map.put("loginASRSuc", "1");
    map.put("loginType", "3");
    map.put("loginsite", "0");
    map.put("naviVer", "firefox|47");

    String ncoToken = Jsoup.parse(html).select("input#J_NcoToken").attr("value");
    map.put("ncoToken", ncoToken);

    map.put("newMini", "false");
    map.put("newMini2", "false");
    map.put("newlogin", "0");
    map.put("osVer", "windows|6.1");
    map.put("oslanguage", "zh-cn");
    map.put("qrLogin", "true");
    map.put("slideCodeShow", "false");
    map.put("sr", "1920*1080");

    String ua = Jsoup.parse(html).select("input#UA_InputId").attr("value");
    //map.put("ua", ua);

    String umToken = Jsoup.parse(html).select("input[name=um_token]").attr("value");
    map.put("um_token", umToken); // TODO get um_token

    String ans = client.post("https://login.taobao.com/member/login.jhtml", map);
    System.out.println(ans);
}

From source file:com.lightboxtechnologies.nsrl.OCSVTest.java

public static void main(String[] args) throws IOException {
    final String mfg_filename = args[0];
    final String os_filename = args[1];
    final String prod_filename = args[2];
    final String hash_filename = args[3];

    final LineTokenizer tok = new OpenCSVLineTokenizer();
    final RecordLoader loader = new RecordLoader();

    final ErrorConsumer err = new ErrorConsumer() {
        public void consume(BadDataException e, long linenum) {
            System.err.println("malformed record, line " + linenum);
            e.printStackTrace();/*from   w  ww  . java  2s  . c om*/
        }
    };

    // read manufacturer, OS, product data
    final Map<String, MfgData> mfg = new HashMap<String, MfgData>();
    final Map<String, OSData> os = new HashMap<String, OSData>();
    final Map<Integer, List<ProdData>> prod = new HashMap<Integer, List<ProdData>>();

    SmallTableLoader.load(mfg_filename, mfg, os_filename, os, prod_filename, prod, tok, err);

    // read hash data
    final RecordConsumer<HashData> hcon = new RecordConsumer<HashData>() {
        public void consume(HashData hd) {
            /*
                    System.out.print(hd);
                    
                    for (ProdData pd : prod.get(hd.prod_code)) {
                      System.out.print(pd);
                      final MfgData pmd = mfg.get(pd.mfg_code);
                      System.out.print(pmd);
                    }
                    
                    final OSData osd = os.get(hd.os_code);
                    System.out.print(osd);
                    
                    final MfgData osmd = mfg.get(osd.mfg_code);
                    System.out.print(osmd);
                    
                    System.out.println("");
            */

            /*
                    final Hex hex = new Hex();
                    
                    String sha1 = null;
                    String md5 = null;
                    String crc32 = null;
                    
                    try {
                      sha1 = (String) hex.encode((Object) hd.sha1);
                      md5 = (String) hex.encode((Object) hd.md5);
                      crc32 = (String) hex.encode((Object) hd.crc32);
                    }
                    catch (EncoderException e) {
                      throw new RuntimeException(e);
                    }
            */

            final ObjectMapper mapper = new ObjectMapper();

            final String sha1 = Hex.encodeHexString(hd.sha1);
            final String md5 = Hex.encodeHexString(hd.md5);
            final String crc32 = Hex.encodeHexString(hd.crc32);

            final Map<String, Object> hd_m = new HashMap<String, Object>();

            hd_m.put("sha1", sha1);
            hd_m.put("md5", md5);
            hd_m.put("crc32", crc32);
            hd_m.put("name", hd.name);
            hd_m.put("size", hd.size);
            hd_m.put("special_code", hd.special_code);

            final OSData osd = os.get(hd.os_code);
            final MfgData osmfgd = mfg.get(osd.mfg_code);

            final Map<String, Object> os_m = new HashMap<String, Object>();
            os_m.put("name", osd.name);
            os_m.put("version", osd.version);
            os_m.put("manufacturer", osmfgd.name);
            hd_m.put("os", os_m);

            final List<Map<String, Object>> pl_l = new ArrayList<Map<String, Object>>();
            for (ProdData pd : prod.get(hd.prod_code)) {

                if (!osd.code.equals(pd.os_code)) {
                    // os code mismatch
                    /*
                                System.err.println(
                                  "Hash record OS code == " + osd.code + " != " + pd.os_code + " == product record OS code"
                                );
                    */
                    continue;
                }

                final Map<String, Object> prod_m = new HashMap<String, Object>();

                prod_m.put("name", pd.name);
                prod_m.put("version", pd.version);
                prod_m.put("language", pd.language);
                prod_m.put("app_type", pd.app_type);
                prod_m.put("os_code", pd.os_code);

                final MfgData md = mfg.get(pd.mfg_code);
                prod_m.put("manufacturer", md.name);

                pl_l.add(prod_m);
            }

            if (pl_l.size() > 1) {
                System.err.println(hd.prod_code);
            }

            hd_m.put("products", pl_l);

            try {
                mapper.writeValue(System.out, hd_m);
            } catch (IOException e) {
                // should be impossible
                throw new IllegalStateException(e);
            }
        }
    };

    final RecordProcessor<HashData> hproc = new HashRecordProcessor();
    final LineHandler hlh = new DefaultLineHandler<HashData>(tok, hproc, hcon, err);

    InputStream zin = null;
    try {
        //      zin = new GZIPInputStream(new FileInputStream(hash_filename));
        zin = new FileInputStream(hash_filename);
        loader.load(zin, hlh);
        zin.close();
    } finally {
        IOUtils.closeQuietly(zin);
    }

    System.out.println();

    /*
        for (Map.Entry<String,String> e : mfg.entrySet()) {
          System.out.println(e.getKey() + " = " + e.getValue());
        }
            
        for (Map.Entry<String,OSData> e : os.entrySet()) {
          System.out.println(e.getKey() + " = " + e.getValue());
        }
            
        for (Map.Entry<Integer,List<ProdData>> e : prod.entrySet()) {
          System.out.println(e.getKey() + " = " + e.getValue());
        }
    */
}

From source file:com.workfront.StreamClientSample.java

public static void main(String[] args) {
    StreamClient client = new StreamClient("http://localhost:8080/attask/api");

    try {// w ww .  j  a v a2  s  .  c  om
        // Login
        System.out.print("Logging in...");
        JSONObject session = client.login("admin@user.attask", "user");
        System.out.println("done");

        // Get user
        System.out.print("Retrieving user...");
        JSONObject user = client.get("user", session.getString("userID"),
                new String[] { "ID", "homeGroupID", "emailAddr" });
        System.out.println("done");

        // Search projects
        System.out.print("Searching projects...");
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("groupID", user.getString("homeGroupID"));
        JSONArray results = client.search("proj", map, new String[] { "ID", "name" });
        System.out.println("done");

        for (int i = 0; i < Math.min(10, results.length()); i++) {
            System.out.println(" - " + results.getJSONObject(i).getString("name"));
        }

        // Create project
        System.out.print("Creating project...");
        map.clear();
        map.put("name", "My Project");
        map.put("groupID", user.getString("homeGroupID"));
        JSONObject proj = client.post("proj", map);
        System.out.println("done");

        // Get project
        System.out.print("Retrieving project...");
        proj = client.get("proj", proj.getString("ID"));
        System.out.println("done");

        // Edit project
        System.out.print("Editing project...");
        map.clear();
        map.put("name", "Your Project");
        proj = client.put("proj", proj.getString("ID"), map);
        System.out.println("done");

        // Delete project
        System.out.print("Deleting project...");
        client.delete("proj", proj.getString("ID"));
        System.out.println("done");

        // Logout
        System.out.print("Logging out...");
        client.logout();
        System.out.println("done");
    } catch (StreamClientException e) {
        System.out.println(e.getMessage());
    } catch (JSONException e) {
        System.out.println(e.getMessage());
    }
}

From source file:cooccurrence.Omer_Levy.java

public static void main(String args[]) {
    String path = "";
    String writePath = "";
    BufferedReader br = null;/*w  w  w . j a  va 2s  . c o  m*/
    ArrayList<String> files = new ArrayList<>();
    //reading all the files in the directory
    //each file is PPMI matrix for an year
    listFilesForFolder(new File(path), files);
    for (String filePath : files) {
        System.out.println(filePath);
        String fileName = new File(filePath).getName();

        //data structure to store the PPMI matrix in the file
        HashMap<String, HashMap<String, Double>> cooccur = new HashMap<>();
        readFileContents(filePath, cooccur); //reading the file and storing the content in the hashmap
        //Because Matrices are identified by row and col id, the following 
        //lists maps id to corresponding string. Note that matrix is symmetric. 
        ArrayList<String> rowStrings = new ArrayList<>(cooccur.keySet());
        ArrayList<String> colStrings = new ArrayList<>(cooccur.keySet());

        //creating matrix with given dimensions and initializing it to 0
        RealMatrix matrixR = MatrixUtils.createRealMatrix(rowStrings.size(), colStrings.size());

        //creating the matrices for storing top rank-d matrices of SVD 
        RealMatrix matrixUd = MatrixUtils.createRealMatrix(D, D);
        RealMatrix matrixVd = MatrixUtils.createRealMatrix(D, D);
        RealMatrix coVarD = MatrixUtils.createRealMatrix(D, D);

        //populating the matrices based on the co-occur hashmap
        populateMatrixR(matrixR, cooccur, rowStrings, colStrings);

        //computing the svd
        SingularValueDecomposition svd = new SingularValueDecomposition(matrixR);

        //extracting the components of SVD factorization
        RealMatrix U = svd.getU();
        RealMatrix V = svd.getV();
        RealMatrix coVariance = svd.getCovariance(-1);

        //list to store indices of top-D singular values of coVar. 
        //Use this with rowsString (colStrings) to get the corresponding word and context
        ArrayList<Integer> indicesD = new ArrayList<>();
        //Extract topD singular value from covariance to store in coVarD and
        //extract corresponding columns from U and V to store in Ud and Vd
        getTopD(U, V, coVariance, matrixUd, matrixVd, coVarD, indicesD);
        //calulate the squareRoot of coVarD
        RealMatrix squareRootCoVarD = squareRoot(coVarD);
        RealMatrix W_svd = matrixUd.multiply(squareRootCoVarD);
        RealMatrix C_svd = matrixVd.multiply(squareRootCoVarD);
    }
}

From source file:de.tudarmstadt.ukp.experiments.argumentation.convincingness.sampling.Step7aLearningDataProducer.java

@SuppressWarnings("unchecked")
public static void main(String[] args) throws IOException {
    String inputDir = args[0];//from  w w w. j a  v  a  2 s . c  o  m
    File outputDir = new File(args[1]);

    if (!outputDir.exists()) {
        outputDir.mkdirs();
    }

    Collection<File> files = IOHelper.listXmlFiles(new File(inputDir));

    // for generating ConvArgStrict use this
    String prefix = "no-eq_DescendingScoreArgumentPairListSorter";

    // for oversampling using graph transitivity properties use this
    //        String prefix = "generated_no-eq_AscendingScoreArgumentPairListSorter";

    Iterator<File> iterator = files.iterator();
    while (iterator.hasNext()) {
        File file = iterator.next();

        if (!file.getName().startsWith(prefix)) {
            iterator.remove();
        }
    }

    int totalGoldPairsCounter = 0;

    Map<String, Integer> goldDataDistribution = new HashMap<>();

    DescriptiveStatistics statsPerTopic = new DescriptiveStatistics();

    int totalPairsWithReasonSameAsGold = 0;

    DescriptiveStatistics ds = new DescriptiveStatistics();

    for (File file : files) {
        List<AnnotatedArgumentPair> argumentPairs = (List<AnnotatedArgumentPair>) XStreamTools.getXStream()
                .fromXML(file);

        int pairsPerTopicCounter = 0;

        String name = file.getName().replaceAll(prefix, "").replaceAll("\\.xml", "");

        PrintWriter pw = new PrintWriter(new File(outputDir, name + ".csv"), "utf-8");

        pw.println("#id\tlabel\ta1\ta2");

        for (AnnotatedArgumentPair argumentPair : argumentPairs) {
            String goldLabel = argumentPair.getGoldLabel();

            if (!goldDataDistribution.containsKey(goldLabel)) {
                goldDataDistribution.put(goldLabel, 0);
            }

            goldDataDistribution.put(goldLabel, goldDataDistribution.get(goldLabel) + 1);

            pw.printf(Locale.ENGLISH, "%s\t%s\t%s\t%s%n", argumentPair.getId(), goldLabel,
                    multipleParagraphsToSingleLine(argumentPair.getArg1().getText()),
                    multipleParagraphsToSingleLine(argumentPair.getArg2().getText()));

            pairsPerTopicCounter++;

            int sameInOnePair = 0;

            // get gold reason statistics
            for (AnnotatedArgumentPair.MTurkAssignment assignment : argumentPair.mTurkAssignments) {
                String label = assignment.getValue();

                if (goldLabel.equals(label)) {
                    sameInOnePair++;
                }
            }

            ds.addValue(sameInOnePair);
            totalPairsWithReasonSameAsGold += sameInOnePair;
        }

        totalGoldPairsCounter += pairsPerTopicCounter;
        statsPerTopic.addValue(pairsPerTopicCounter);

        pw.close();
    }

    System.out.println("Total reasons matching gold " + totalPairsWithReasonSameAsGold);
    System.out.println(ds);

    System.out.println("Total gold pairs: " + totalGoldPairsCounter);
    System.out.println(statsPerTopic);

    int totalPairs = 0;
    for (Integer pairs : goldDataDistribution.values()) {
        totalPairs += pairs;
    }
    System.out.println("Total pairs: " + totalPairs);
    System.out.println(goldDataDistribution);

}

From source file:com.apress.prospringintegration.messageflow.workflow.WorkflowMainClient.java

public static void main(String[] ars) throws Exception {
    ClassPathXmlApplicationContext classPathXmlApplicationContext = new ClassPathXmlApplicationContext(
            "workflow-gateway.xml");
    classPathXmlApplicationContext.start();

    ProcessEngine processEngine = classPathXmlApplicationContext.getBean(ProcessEngine.class);

    deployProcessDefinitions(processEngine, "processes/hello.bpmn20.xml", "processes/gateway.bpmn20.xml");

    Map<String, Object> processVariables = new HashMap<String, Object>();
    processVariables.put("customerId", 2);

    ProcessInstance pi = processEngine.getRuntimeService().startProcessInstanceByKey("sigateway",
            processVariables);/*from w  w  w . j  a va  2 s  .  c o m*/

    log.debug("the process instance has been started: PI ID # " + pi.getId());

    Thread.sleep(1000 * 20);
    log.debug("waited 20s");
}

From source file:com.joliciel.jochre.search.JochreSearch.java

/**
 * @param args/*from  w w  w  . java 2 s . c o m*/
 */
public static void main(String[] args) {
    try {
        Map<String, String> argMap = new HashMap<String, String>();

        for (String arg : args) {
            int equalsPos = arg.indexOf('=');
            String argName = arg.substring(0, equalsPos);
            String argValue = arg.substring(equalsPos + 1);
            argMap.put(argName, argValue);
        }

        String command = argMap.get("command");
        argMap.remove("command");

        String logConfigPath = argMap.get("logConfigFile");
        if (logConfigPath != null) {
            argMap.remove("logConfigFile");
            Properties props = new Properties();
            props.load(new FileInputStream(logConfigPath));
            PropertyConfigurator.configure(props);
        }

        LOG.debug("##### Arguments:");
        for (Entry<String, String> arg : argMap.entrySet()) {
            LOG.debug(arg.getKey() + ": " + arg.getValue());
        }

        SearchServiceLocator locator = SearchServiceLocator.getInstance();
        SearchService searchService = locator.getSearchService();

        if (command.equals("buildIndex")) {
            String indexDirPath = argMap.get("indexDir");
            String documentDirPath = argMap.get("documentDir");
            File indexDir = new File(indexDirPath);
            indexDir.mkdirs();
            File documentDir = new File(documentDirPath);

            JochreIndexBuilder builder = searchService.getJochreIndexBuilder(indexDir);
            builder.updateDocument(documentDir);
        } else if (command.equals("updateIndex")) {
            String indexDirPath = argMap.get("indexDir");
            String documentDirPath = argMap.get("documentDir");
            boolean forceUpdate = false;
            if (argMap.containsKey("forceUpdate")) {
                forceUpdate = argMap.get("forceUpdate").equals("true");
            }
            File indexDir = new File(indexDirPath);
            indexDir.mkdirs();
            File documentDir = new File(documentDirPath);

            JochreIndexBuilder builder = searchService.getJochreIndexBuilder(indexDir);
            builder.updateIndex(documentDir, forceUpdate);
        } else if (command.equals("search")) {
            HighlightServiceLocator highlightServiceLocator = HighlightServiceLocator.getInstance(locator);
            HighlightService highlightService = highlightServiceLocator.getHighlightService();

            String indexDirPath = argMap.get("indexDir");
            File indexDir = new File(indexDirPath);
            JochreQuery query = searchService.getJochreQuery(argMap);

            JochreIndexSearcher searcher = searchService.getJochreIndexSearcher(indexDir);
            TopDocs topDocs = searcher.search(query);

            Set<Integer> docIds = new LinkedHashSet<Integer>();
            for (ScoreDoc scoreDoc : topDocs.scoreDocs) {
                docIds.add(scoreDoc.doc);
            }
            Set<String> fields = new HashSet<String>();
            fields.add("text");

            Highlighter highlighter = highlightService.getHighlighter(query, searcher.getIndexSearcher());
            HighlightManager highlightManager = highlightService
                    .getHighlightManager(searcher.getIndexSearcher());
            highlightManager.setDecimalPlaces(query.getDecimalPlaces());
            highlightManager.setMinWeight(0.0);
            highlightManager.setIncludeText(true);
            highlightManager.setIncludeGraphics(true);

            Writer out = new PrintWriter(new OutputStreamWriter(System.out, StandardCharsets.UTF_8));
            if (command.equals("highlight")) {
                highlightManager.highlight(highlighter, docIds, fields, out);
            } else {
                highlightManager.findSnippets(highlighter, docIds, fields, out);
            }
        } else {
            throw new RuntimeException("Unknown command: " + command);
        }
    } catch (RuntimeException e) {
        LogUtils.logError(LOG, e);
        throw e;
    } catch (IOException e) {
        LogUtils.logError(LOG, e);
        throw new RuntimeException(e);
    }
}

From source file:FaceRatios.java

@SuppressWarnings("serial")
public static void main(String[] args) {
    int r = FSDK.ActivateLibrary(FACE_SDK_LICENSE);
    if (r == FSDK.FSDKE_OK) {
        FSDK.Initialize();/*from w ww .  j  a  v a2  s  . co m*/
        FSDK.SetFaceDetectionParameters(true, true, 384);

        Map<String, Map<String, ArrayList<Double>>> faceProperties = new HashMap<>();

        for (String directory : new File(FACE_DIRECTORY).list()) {
            if (new File(FACE_DIRECTORY + directory).isDirectory()) {
                Map<String, ArrayList<Double>> properties = new HashMap<String, ArrayList<Double>>() {
                    {
                        for (String property : propertyNames)
                            put(property, new ArrayList<Double>());
                    }
                };

                File[] files = new File(FACE_DIRECTORY + directory).listFiles();
                System.out.println("Analyzing " + directory + " with " + files.length + " files\n");
                for (File file : files) {
                    if (file.isFile()) {
                        HImage imageHandle = new HImage();
                        FSDK.LoadImageFromFileW(imageHandle, file.getAbsolutePath());

                        FSDK.TFacePosition.ByReference facePosition = new FSDK.TFacePosition.ByReference();
                        if (FSDK.DetectFace(imageHandle, facePosition) == FSDK.FSDKE_OK) {
                            FSDK_Features.ByReference facialFeatures = new FSDK_Features.ByReference();
                            FSDK.DetectFacialFeaturesInRegion(imageHandle, (FSDK.TFacePosition) facePosition,
                                    facialFeatures);

                            Point[] featurePoints = new Point[FSDK.FSDK_FACIAL_FEATURE_COUNT];
                            for (int i = 0; i < FSDK.FSDK_FACIAL_FEATURE_COUNT; i++) {
                                featurePoints[i] = new Point(0, 0);
                                featurePoints[i].x = facialFeatures.features[i].x;
                                featurePoints[i].y = facialFeatures.features[i].y;
                            }

                            double eyeDistance = featureDistance(featurePoints, FeatureID.LEFT_EYE,
                                    FeatureID.RIGHT_EYE);
                            double rightEyeSize = featureDistance(featurePoints,
                                    FeatureID.RIGHT_EYE_INNER_CORNER, FeatureID.RIGHT_EYE_OUTER_CORNER);
                            double leftEyeSize = featureDistance(featurePoints, FeatureID.LEFT_EYE_INNER_CORNER,
                                    FeatureID.LEFT_EYE_OUTER_CORNER);
                            double averageEyeSize = (rightEyeSize + leftEyeSize) / 2;

                            double mouthLength = featureDistance(featurePoints, FeatureID.MOUTH_RIGHT_CORNER,
                                    FeatureID.MOUTH_LEFT_CORNER);
                            double mouthHeight = featureDistance(featurePoints, FeatureID.MOUTH_BOTTOM,
                                    FeatureID.MOUTH_TOP);
                            double noseHeight = featureDistance(featurePoints, FeatureID.NOSE_BOTTOM,
                                    FeatureID.NOSE_BRIDGE);
                            double chinHeight = featureDistance(featurePoints, FeatureID.CHIN_BOTTOM,
                                    FeatureID.MOUTH_BOTTOM);

                            double chinToBridgeHeight = featureDistance(featurePoints, FeatureID.CHIN_BOTTOM,
                                    FeatureID.NOSE_BRIDGE);

                            double faceContourLeft = (featurePoints[FeatureID.CHIN_BOTTOM.getIndex()].getY()
                                    - featurePoints[FeatureID.FACE_CONTOUR2.getIndex()].getY())
                                    / (featurePoints[FeatureID.CHIN_BOTTOM.getIndex()].getX()
                                            - featurePoints[FeatureID.FACE_CONTOUR2.getIndex()].getX());
                            double faceContourRight = (featurePoints[FeatureID.CHIN_BOTTOM.getIndex()].getY()
                                    - featurePoints[FeatureID.FACE_CONTOUR12.getIndex()].getY())
                                    / (featurePoints[FeatureID.CHIN_BOTTOM.getIndex()].getX()
                                            - featurePoints[FeatureID.FACE_CONTOUR12.getIndex()].getX());

                            double bridgeLeftEyeDistance = featureDistance(featurePoints,
                                    FeatureID.LEFT_EYE_INNER_CORNER, FeatureID.NOSE_BRIDGE);
                            double bridgeRightEyeDistance = featureDistance(featurePoints,
                                    FeatureID.RIGHT_EYE_INNER_CORNER, FeatureID.NOSE_BRIDGE);

                            properties.get("eyeSize/eyeDistance").add(averageEyeSize / eyeDistance);
                            properties.get("eyeSizeDisparity")
                                    .add(Math.abs(leftEyeSize - rightEyeSize) / averageEyeSize);
                            properties.get("bridgeToEyeDisparity")
                                    .add(Math.abs(bridgeLeftEyeDistance - bridgeRightEyeDistance)
                                            / ((bridgeLeftEyeDistance + bridgeRightEyeDistance) / 2));
                            properties.get("eyeDistance/mouthLength").add(eyeDistance / mouthLength);
                            properties.get("eyeDistance/noseHeight").add(eyeDistance / noseHeight);
                            properties.get("eyeSize/mouthLength").add(eyeDistance / mouthLength);
                            properties.get("eyeSize/noseHeight").add(eyeDistance / noseHeight);
                            properties.get("mouthLength/mouthHeight").add(mouthLength / mouthHeight);
                            properties.get("chinHeight/noseHeight").add(chinHeight / noseHeight);
                            properties.get("chinHeight/chinToBridgeHeight")
                                    .add(chinHeight / chinToBridgeHeight);
                            properties.get("noseHeight/chinToBridgeHeight")
                                    .add(noseHeight / chinToBridgeHeight);
                            properties.get("mouthHeight/chinToBridgeHeight")
                                    .add(mouthHeight / chinToBridgeHeight);
                            properties.get("faceCountourAngle")
                                    .add(Math.toDegrees(Math.atan((faceContourLeft - faceContourRight)
                                            / (1 + faceContourLeft * faceContourRight))));
                        }

                        FSDK.FreeImage(imageHandle);
                    }
                }

                System.out.format("%32s\t%8s\t%8s\t%3s%n", "Property", "", "", "c");
                System.out.println(new String(new char[76]).replace("\0", "-"));

                ArrayList<Entry<String, ArrayList<Double>>> propertyList = new ArrayList<>(
                        properties.entrySet());
                Collections.sort(propertyList, new Comparator<Entry<String, ArrayList<Double>>>() {
                    @Override
                    public int compare(Entry<String, ArrayList<Double>> arg0,
                            Entry<String, ArrayList<Double>> arg1) {
                        DescriptiveStatistics dStats0 = new DescriptiveStatistics(listToArray(arg0.getValue()));
                        DescriptiveStatistics dStats1 = new DescriptiveStatistics(listToArray(arg1.getValue()));
                        return new Double(dStats0.getStandardDeviation() / dStats0.getMean())
                                .compareTo(dStats1.getStandardDeviation() / dStats1.getMean());
                    }
                });

                for (Entry<String, ArrayList<Double>> property : propertyList) {
                    DescriptiveStatistics dStats = new DescriptiveStatistics(listToArray(property.getValue()));
                    System.out.format("%32s\t%4f\t%4f\t%3s%n", property.getKey(), dStats.getMean(),
                            dStats.getStandardDeviation(),
                            Math.round(dStats.getStandardDeviation() / dStats.getMean() * 100) + "%");
                }

                System.out.println("\n");
                faceProperties.put(directory, properties);
            }
        }

        for (String propertyName : propertyNames) {
            DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset();
            for (Entry<String, Map<String, ArrayList<Double>>> face : faceProperties.entrySet()) {
                dataset.add(face.getValue().get(propertyName), "Default Series", face.getKey());
            }

            PropertyBoxWhisker plot = new PropertyBoxWhisker(propertyName, dataset);
            plot.pack();
            plot.setVisible(true);
        }
    }
}