コード例 #1
0
ファイル: ListCharacters.java プロジェクト: whym/ligtran
  public static void main(String[] args) throws Exception {
    int size = Util.getPropertyInt("size", 100);
    double min = Util.getPropertyDouble("min", 0.01);
    double max = Util.getPropertyDouble("max", 0.9);
    Font font = new Font("serif", Font.PLAIN, size);
    String fpath = Util.getProperty("font", null);
    if (fpath != null) {
      font = Font.createFont(Font.TRUETYPE_FONT, new FileInputStream(fpath));
    }

    for (char c = Character.MIN_VALUE + 1; c < Character.MAX_VALUE; ++c) {
      int type = Character.getType(c);
      if (type != Character.CONTROL
          && type != Character.FORMAT
          && type != Character.PRIVATE_USE
          && type != Character.SURROGATE
          && type != Character.UNASSIGNED
          && !Character.isMirrored(c)
          && !Character.isSpaceChar(c)) {
        String s = "" + c;
        if (Normalizer.normalize(s, NFKC).contains("\u0308")) continue; // TODO: adhoc
        UnigramMetrics m = new UnigramMetrics(s, size, false, true, font);
        if (min < m.getBlackness() && m.getBlackness() < max) {
          System.out.println("" + c + " " + (int) c);
        }
      }
    }
  }
コード例 #2
0
ファイル: UtilTest.java プロジェクト: Sk464036801/JGroups
  public static void testGetProperty() {
    Properties props = new Properties();
    props.setProperty("name", "Bela");
    props.setProperty("key", "val");

    System.setProperty("name", "Michelle");
    System.setProperty("name2", "Nicole");
    String retval;

    retval = Util.getProperty(new String[] {"name", "name2"}, props, "name", "Jeannette");
    Assert.assertEquals("Bela", retval);
    props.setProperty("name", "Bela");
    props.setProperty("key", "val");

    retval = Util.getProperty(new String[] {"name2", "name"}, props, "name", "Jeannette");
    Assert.assertEquals("Bela", retval);
    props.setProperty("name", "Bela");
    props.setProperty("key", "val");

    retval = Util.getProperty(new String[] {"name3", "name"}, props, "name", "Jeannette");
    Assert.assertEquals("Bela", retval);
    props.setProperty("name", "Bela");
    props.setProperty("key", "val");

    retval = Util.getProperty(new String[] {"name3", "name4"}, props, "name", "Jeannette");
    Assert.assertEquals("Bela", retval);
    props.setProperty("name", "Bela");
    props.setProperty("key", "val");

    retval = Util.getProperty(new String[] {"name2", "name"}, props, "name", "Jeannette");
    Assert.assertEquals("Bela", retval);
    props.setProperty("name", "Bela");
    props.setProperty("key", "val");

    retval = Util.getProperty(new String[] {"name2", "name"}, props, "name2", "Jeannette");
    Assert.assertEquals("Nicole", retval);
    props.setProperty("name", "Bela");
    props.setProperty("key", "val");

    retval = Util.getProperty(new String[] {"name2", "name"}, props, "name2", null);
    Assert.assertEquals("Nicole", retval);
    props.setProperty("name", "Bela");
    props.setProperty("key", "val");
  }
コード例 #3
0
ファイル: UtilTest.java プロジェクト: Sk464036801/JGroups
  public static void testGetProperty2() {
    String input = "foo, bar,  foobar: 1000";
    String result = Util.getProperty(input);
    assert result != null && result.equals("1000");

    input = "foo, bar,  foobar";
    result = Util.getProperty(input);
    assert result == null;

    System.setProperty("foobar", "900");

    input = "foo, bar,  foobar: 1000";
    result = Util.getProperty(input);
    assert result != null && result.equals("900");

    input = "foo, bar,  foobar";
    result = Util.getProperty(input);
    assert result != null && result.equals("900");

    System.setProperty("bar", "500");
    input = "foo, bar,  foobar: 1000";
    result = Util.getProperty(input);
    assert result != null && result.equals("500");

    input = "foo, bar,  foobar";
    result = Util.getProperty(input);
    assert result != null && result.equals("500");

    System.setProperty("foo", "200");
    input = "foo, bar,  foobar: 1000";
    result = Util.getProperty(input);
    assert result != null && result.equals("200");

    input = "foo, bar,  foobar";
    result = Util.getProperty(input);
    assert result != null && result.equals("200");
  }