From 39b60d4225f5efa4e0287a2c6ce69d90391c69db Mon Sep 17 00:00:00 2001 From: RncLsn Date: Fri, 3 Jul 2015 19:09:31 +0100 Subject: Many little changes. --- src/uk/ac/ox/cs/pagoda/util/PagodaProperties.java | 12 +++++- src/uk/ac/ox/cs/pagoda/util/SimpleProgressBar.java | 48 ++++++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 src/uk/ac/ox/cs/pagoda/util/SimpleProgressBar.java (limited to 'src/uk/ac/ox/cs/pagoda/util') diff --git a/src/uk/ac/ox/cs/pagoda/util/PagodaProperties.java b/src/uk/ac/ox/cs/pagoda/util/PagodaProperties.java index 4991d0d..7b68400 100644 --- a/src/uk/ac/ox/cs/pagoda/util/PagodaProperties.java +++ b/src/uk/ac/ox/cs/pagoda/util/PagodaProperties.java @@ -15,6 +15,7 @@ public class PagodaProperties { public static final boolean DEFAULT_DEBUG = false; private static final boolean DEFAULT_USE_ALWAYS_SIMPLE_UPPER_BOUND; private static final boolean DEFAULT_USE_SKOLEM_UPPER_BOUND; + private static final boolean DEFAULT_TO_CALL_HERMIT; private static final Path DEFAULT_STATISTICS_DIR; public static boolean shellModeDefault = false; @@ -23,6 +24,7 @@ public class PagodaProperties { static { boolean defaultUseAlwaysSimpleUpperBound = false; boolean defaultUseSkolemUpperBound = true; + boolean toCallHermit = true; Path defaultStatisticsDir = null; try(InputStream in = PagodaProperties.class.getClassLoader().getResourceAsStream(CONFIG_FILE)) { @@ -52,12 +54,20 @@ public class PagodaProperties { else logger.debug("By default the Skolem upper bound is disabled"); } + if(config.containsKey("toCallHermit")) { + toCallHermit = Boolean.parseBoolean(config.getProperty("toCallHermit")); + if(toCallHermit) + logger.debug("By default Hermit is enabled"); + else + logger.debug("By default Hermit is disabled"); + } } catch(IOException e) { e.printStackTrace(); } DEFAULT_USE_ALWAYS_SIMPLE_UPPER_BOUND = defaultUseAlwaysSimpleUpperBound; DEFAULT_USE_SKOLEM_UPPER_BOUND = defaultUseSkolemUpperBound; + DEFAULT_TO_CALL_HERMIT = toCallHermit; DEFAULT_STATISTICS_DIR = defaultStatisticsDir; } @@ -66,7 +76,7 @@ public class PagodaProperties { String queryPath = null; String answerPath = null; boolean toClassify = true; - boolean toCallHermiT = true; + boolean toCallHermiT = DEFAULT_TO_CALL_HERMIT; boolean shellMode = shellModeDefault; private boolean useAlwaysSimpleUpperBound = DEFAULT_USE_ALWAYS_SIMPLE_UPPER_BOUND; private boolean useSkolemUpperBound = DEFAULT_USE_SKOLEM_UPPER_BOUND; diff --git a/src/uk/ac/ox/cs/pagoda/util/SimpleProgressBar.java b/src/uk/ac/ox/cs/pagoda/util/SimpleProgressBar.java new file mode 100644 index 0000000..3c4aad7 --- /dev/null +++ b/src/uk/ac/ox/cs/pagoda/util/SimpleProgressBar.java @@ -0,0 +1,48 @@ +package uk.ac.ox.cs.pagoda.util; + +import uk.ac.ox.cs.pagoda.util.disposable.Disposable; + +public class SimpleProgressBar extends Disposable { + + private final String name; + private int lastPercent; + private int maxValue; + + public SimpleProgressBar() { + this(""); + } + + public SimpleProgressBar(String name) { + this(name, 100); + } + + public SimpleProgressBar(String name, int maxValue) { + this.name = name; + this.maxValue = maxValue; + } + + public void update(int value) { + int percent = value * 100 / maxValue; + StringBuilder template = new StringBuilder("\r" + name + " ["); + for (int i = 0; i < 50; i++) { + if (i < percent * .5) { + template.append("="); + } else if (i == percent * .5) { + template.append(">"); + } else { + template.append(" "); + } + } + template.append("] %s "); + System.out.printf(template.toString(), percent + "%"); + System.out.flush(); + lastPercent = percent; + } + + @Override + public void dispose() { + super.dispose(); + + System.out.println(); + } +} -- cgit v1.2.3