Skip to content

Commit

Permalink
code cleanup; javadoc
Browse files Browse the repository at this point in the history
  • Loading branch information
xzel23 committed Aug 28, 2024
1 parent eef48ce commit f2692a1
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 14 deletions.
27 changes: 24 additions & 3 deletions utility-fx/src/main/java/com/dua3/utility/fx/FxLogPane.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@

public class FxLogPane extends BorderPane {

public static final double COLUMN_WIDTH_MAX = Double.MAX_VALUE;
public static final double COLUMN_WIDTH_LARGE = 10000.0;
private static final double COLUMN_WIDTH_MAX = Double.MAX_VALUE;
private static final double COLUMN_WIDTH_LARGE = 10000.0;
private final LogBuffer logBuffer;
private final Function<? super LogEntry, Color> colorize;
private final Function<? super LogEntry, ? extends Color> colorize;
private final ToolBar toolBar;
private final TextArea details;
private final TableView<LogEntry> tableView;
Expand Down Expand Up @@ -95,18 +95,39 @@ private static double getDisplayWidth(String s) {
return new Text(s).getLayoutBounds().getWidth();
}

/**
* Construct a new FxLogPane instance with default buffer capacity.
*/
public FxLogPane() {
this(LogBuffer.DEFAULT_CAPACITY);
}

/**
* Construct a new FxLogPane instance with the given buffer capacity.
*
* @param bufferSize the buffer size
*/
public FxLogPane(int bufferSize) {
this(createBuffer(bufferSize));
}

/**
* Construct a new FxLogPane instance with the given buffer.
*
* @param logBuffer the logBuffer to use
* @throws NullPointerException if logBuffer is null
*/
public FxLogPane(LogBuffer logBuffer) {
this(logBuffer, FxLogPane::defaultColorize);
}

/**
* Constructs a new FxLogPane instance with the given LogBuffer and colorize function.
*
* @param logBuffer the LogBuffer to use for storing log entries
* @param colorize the function used to determine the color of log entries
* @throws NullPointerException if logBuffer or colorize is null
*/
public FxLogPane(LogBuffer logBuffer, Function<? super LogEntry, Color> colorize) {
FilteredList<LogEntry> entries = new FilteredList<>(new LogEntriesObservableList(logBuffer), p -> true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public DefaultLogEntryFilter() {
*
* @param level the log level to set
* @param filterLoggerName the filter to set for the logger name
* @param filterLoggerName the filter to set for the message content
* @param filterText the filter to set for the message content
*/
public DefaultLogEntryFilter(LogLevel level, BiPredicate<String, LogLevel> filterLoggerName, BiPredicate<String, LogLevel> filterText) {
this.level = level;
Expand All @@ -58,16 +58,16 @@ public LogLevel getLevel() {
}

/**
* Sets the logger name filter of the DefaultLogEntryFilter.
* Sets the logger name filterLoggerName of the DefaultLogEntryFilter.
*
* @param filter A {@link BiPredicate} that takes a logger name and a log level as input and returns a boolean
* @param filterLoggerName A {@link BiPredicate} that takes a logger name and a log level as input and returns a boolean
* indicating whether the log entry should be filtered or not.
* The first argument is the logger name, and the second argument is the log level.
* Returns true if the log entry should be included, false otherwise.
*/
public void setFilterLoggerName(BiPredicate<String, LogLevel> filter) {
if (this.filterLoggerName != filter) {
this.filterLoggerName = filter;
public void setFilterLoggerName(BiPredicate<String, LogLevel> filterLoggerName) {
if (this.filterLoggerName != filterLoggerName) {
this.filterLoggerName = filterLoggerName;
knownLoggers.clear();
}
}
Expand All @@ -83,16 +83,16 @@ public BiPredicate<String, LogLevel> getFilterLoggerName() {
}

/**
* Sets the message filter of the DefaultLogEntryFilter.
* Sets the message filterText of the DefaultLogEntryFilter.
*
* @param filter A {@link BiPredicate} that takes a log message and a log level as input and returns a boolean
* @param filterText A {@link BiPredicate} that takes a log message and a log level as input and returns a boolean
* indicating whether the log entry should be filtered or not.
* The first argument is the message text, and the second argument is the log level.
* Returns true if the log entry should be included, false otherwise.
*/
public void setFilterText(BiPredicate<String, LogLevel> filter) {
if (this.filterText != filter) {
this.filterText = filter;
public void setFilterText(BiPredicate<String, LogLevel> filterText) {
if (this.filterText != filterText) {
this.filterText = filterText;
}
}

Expand Down

0 comments on commit f2692a1

Please sign in to comment.