Commit 79780c9b authored by Christian MOMON's avatar Christian MOMON
Browse files

Refactored code review about System.out call.

parent c0891c6b
......@@ -98,37 +98,37 @@ public final class FlatDB4GeoNamesGUI
UIManager.put("swing.boldMetal", Boolean.FALSE);
// Set LookAndFeel.
System.out.println("System lookAndFeel property:" + System.getProperty("swing.defaultlaf"));
System.out.println("Available lookAndFeel: " + GUIToolBox.availableLookAndFeels().toString());
System.out.println("System lookAndFeel: " + UIManager.getSystemLookAndFeelClassName());
System.out.println("Current lookAndFeel: " + UIManager.getLookAndFeel().getName());
logger.info("System lookAndFeel property: {}", System.getProperty("swing.defaultlaf"));
logger.info("Available lookAndFeel: {}", GUIToolBox.availableLookAndFeels().toString());
logger.info("System lookAndFeel: {}", UIManager.getSystemLookAndFeelClassName());
logger.info("Current lookAndFeel: {}", UIManager.getLookAndFeel().getName());
if (!StringUtils.equals(UIManager.getSystemLookAndFeelClassName(), "javax.swing.plaf.metal.MetalLookAndFeel"))
{
try
{
System.out.println("Metal LAF setted and system LAF detected, try to set system LAF.");
logger.info("Metal LAF setted and system LAF detected, try to set system LAF.");
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}
catch (final Exception exception)
{
System.out.println("Failed to set the system LookAndFeel.");
logger.info("Failed to set the system LookAndFeel.");
}
}
else if (GUIToolBox.availableLookAndFeels().toString().contains("GTK+"))
{
try
{
System.out.println("Metal LAF setted and GTK+ LAF detected, try to set GTK+ LAF.");
logger.info("Metal LAF setted and GTK+ LAF detected, try to set GTK+ LAF.");
UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");
}
catch (final Exception exception)
{
System.out.println("Failed to set the system LookAndFeel.");
logger.info("Failed to set the system LookAndFeel.");
}
}
System.out.println("Activated lookAndFeel: " + UIManager.getLookAndFeel().getName());
logger.info("Activated lookAndFeel: " + UIManager.getLookAndFeel().getName());
}
/**
......
......@@ -227,14 +227,29 @@ public class FlatDB4GeoNamesWindow extends JFrame
@Override
public void actionPerformed(final ActionEvent event)
{
// Word length statistics.
if (FlatDB4GeoNames.isOpened())
try
{
StringList report = StatisticsReporter.reportLongestWords(500);
// Word length statistics.
if (FlatDB4GeoNames.isOpened())
{
StringList report = StatisticsReporter.reportLongestWords(500);
FlatDB4GeoNamesWindow.this.tabbedPane.add("Work Length Stats", new FlatDB4GeoNamesStatisticsPanel(report));
FlatDB4GeoNamesWindow.this.tabbedPane.add("Work Length Stats", new FlatDB4GeoNamesStatisticsPanel(report));
FlatDB4GeoNamesWindow.this.tabbedPane.setSelectedIndex(FlatDB4GeoNamesWindow.this.tabbedPane.getComponentCount() - 1);
FlatDB4GeoNamesWindow.this.tabbedPane.setSelectedIndex(FlatDB4GeoNamesWindow.this.tabbedPane.getComponentCount() - 1);
}
}
catch (IOException exception)
{
//
logger.error(exception.getMessage(), exception);
//
String title = "Error computerum est";
String message = "Error occured during working: " + exception.getMessage();
//
JOptionPane.showMessageDialog(null, message, title, JOptionPane.ERROR_MESSAGE);
}
}
});
......@@ -247,13 +262,28 @@ public class FlatDB4GeoNamesWindow extends JFrame
public void actionPerformed(final ActionEvent event)
{
// Word matching statistics.
if (FlatDB4GeoNames.isOpened())
try
{
StringList report = StatisticsReporter.reportWordMatching(200);
if (FlatDB4GeoNames.isOpened())
{
StringList report = StatisticsReporter.reportWordMatching(200);
FlatDB4GeoNamesWindow.this.tabbedPane.add("Work Matching Stats", new FlatDB4GeoNamesStatisticsPanel(report));
FlatDB4GeoNamesWindow.this.tabbedPane.add("Work Matching Stats", new FlatDB4GeoNamesStatisticsPanel(report));
FlatDB4GeoNamesWindow.this.tabbedPane.setSelectedIndex(FlatDB4GeoNamesWindow.this.tabbedPane.getComponentCount() - 1);
FlatDB4GeoNamesWindow.this.tabbedPane.setSelectedIndex(FlatDB4GeoNamesWindow.this.tabbedPane.getComponentCount() - 1);
}
}
catch (IOException exception)
{
//
logger.error(exception.getMessage(), exception);
//
String title = "Error computerum est";
String message = "Error occured during working: " + exception.getMessage();
//
JOptionPane.showMessageDialog(null, message, title, JOptionPane.ERROR_MESSAGE);
}
}
});
......
......@@ -207,7 +207,10 @@ public class IndexOfWordSeeks
}
}
System.out.println("result=" + result + "\ttime=" + Chronometer.toHumanString(chrono.stop().interval()) + "\tstepCount=" + stepCount);
if (logger.isDebugEnabled())
{
logger.debug("result={}\ttime={}\tstepCount={}", result, Chronometer.toHumanString(chrono.stop().interval()), stepCount);
}
//
return result;
......
......@@ -18,6 +18,8 @@
*/
package org.tip.flatdb4geonames.model.workers;
import java.io.IOException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.tip.flatdb4geonames.util.StringLongPair;
......@@ -34,8 +36,9 @@ public class StatisticsReporter
/**
*
* @return
* @throws IOException
*/
public static StringList reportLongestWords(final int maxLineCount)
public static StringList reportLongestWords(final int maxLineCount) throws IOException
{
StringList result;
......@@ -77,8 +80,9 @@ public class StatisticsReporter
/**
*
* @return
* @throws IOException
*/
public static StringList reportWordMatching(final int maxLineCount)
public static StringList reportWordMatching(final int maxLineCount) throws IOException
{
StringList result;
......
......@@ -21,6 +21,7 @@ package org.tip.flatdb4geonames.model.workers;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
......@@ -44,8 +45,9 @@ public class StatisticsWorker
/**
*
* @return
* @throws IOException
*/
public static StringLongPairs censusLongestWords(final int maxLineCount)
public static StringLongPairs censusLongestWords(final int maxLineCount) throws IOException
{
StringLongPairs result;
......@@ -115,10 +117,6 @@ public class StatisticsWorker
indexOfWords.remove(result.removeLast());
}
}
catch (Exception exception)
{
System.out.println("Erreur:" + exception.getMessage());
}
finally
{
IOUtils.closeQuietly(in);
......@@ -131,8 +129,9 @@ public class StatisticsWorker
/**
*
* @return
* @throws IOException
*/
public static StringLongPairs censusLongestWords2(final int maxLineCount)
public static StringLongPairs censusLongestWords2(final int maxLineCount) throws IOException
{
StringLongPairs result;
......@@ -193,10 +192,6 @@ public class StatisticsWorker
}
}
}
catch (Exception exception)
{
System.out.println("Erreur:" + exception.getMessage());
}
finally
{
IOUtils.closeQuietly(in);
......@@ -209,8 +204,9 @@ public class StatisticsWorker
/**
*
* @return
* @throws IOException
*/
public static StringLongPairs censusWordMatching(final int maxLineCount)
public static StringLongPairs censusWordMatching(final int maxLineCount) throws IOException
{
StringLongPairs result;
......@@ -268,10 +264,6 @@ public class StatisticsWorker
}
}
}
catch (Exception exception)
{
System.out.println("Erreur:" + exception.getMessage());
}
finally
{
IOUtils.closeQuietly(in2);
......
......@@ -58,7 +58,7 @@ public class Shrinker
source.sort();
System.out.println("sorted");
logger.debug("sorted");
boolean ended = false;
StringList currentLine = null;
......@@ -108,7 +108,7 @@ public class Shrinker
}
}
System.out.println("shrinked: " + source.size() + " -> " + result.size());
logger.debug("shrinked: {} -> {}", source.size(), result.size());
//
return result;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment