2 * Copyright (c) 2019-2020. Developed by Hedgecode.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.hedgecode.chess.scanner;
19 import java.time.LocalDateTime;
20 import java.util.Calendar;
23 * ChessHog Scanner utility class for working with console.
25 * @author Dmitry Samoshin aka gotty
27 public class ScannerConsole {
29 private static final String[] ASCII_LOGO = {
31 " | | _|_ _| |___ ___ ___ ___ _| |___ ",
32 " | | -_| . | . | -_| _| . | . | -_| ",
33 " | |___|___|_ |___|___|___|___|___| ",
34 " _ |___|___| _ |___| ",
35 " ___| |_ ___ ___ ___| |_ ___ ___ ___ ___ ___ ___ ___ ___ ___ ",
36 " | _| | -_|_ -|_ -| | . | . | |_ -| _| .'| | | -_| _| ",
37 " |___|_|_|___|___|___|_|_|___|_ | |___|___|__,|_|_|_|_|___|_| ",
41 private static final String COPYRIGHT = "Copyright (c) Hedgecode";
43 private static boolean logMode = false;
45 private ScannerConsole() {
48 public static void setLogMode(boolean isLogMode) {
52 public static void console(String message) {
55 logMode ? "[%1$tT] %2$s" : "%2$s",
57 message == null ? "" : message
62 public static void empty() {
66 public static void init() {
74 private static void asciiLogo() {
75 for (String line : ASCII_LOGO) {
80 private static void copyright() {
81 int inceptionYear = ScannerProperties.getInt("scanner.inception.year");
82 int currentYear = Calendar.getInstance().get(Calendar.YEAR);
83 String copyright = currentYear > inceptionYear
84 ? String.format("%s-%s %s", inceptionYear, currentYear, COPYRIGHT)
85 : String.format("%s %s", currentYear, COPYRIGHT);
87 alignCenter(copyright)
91 private static void version() {
95 "v. %s", ScannerProperties.get("scanner.version")
101 private static String alignCenter(String message) {
102 int indent = (ASCII_LOGO[0].length() + message.length()) / 2;
103 return String.format(