java.util.stream.IntStream#anyMatch ( )源码实例Demo

下面列出了java.util.stream.IntStream#anyMatch ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: LoggerPlusPlus   文件: LogTable.java
@Override
public Component prepareRenderer(TableCellRenderer renderer, int row, int column)
{
    LogEntry entry = null;
    Integer modelRow = null;
    try {
        modelRow = convertRowIndexToModel(row);
        entry = this.getModel().getRow(modelRow);
    } catch (NullPointerException ignored) {
        ignored.printStackTrace();
    }

    Component c = super.prepareRenderer(renderer, row, column);

    IntStream selectedRows = IntStream.of(this.getSelectedRows());

    if(selectedRows.anyMatch(i -> i == row)){
        c.setBackground(this.getSelectionBackground());
        c.setForeground(this.getSelectionForeground());
    }else {
        if(entry == null){
            System.err.println("Could not convert row index to model. Table entry might not be highlighted properly.");
            return c;
        }
        if(entry.getMatchingColorFilters().size() != 0){
            ColorFilter colorFilter = null;
            Map<UUID, ColorFilter> colorFilters = this.preferences.getSetting(Globals.PREF_COLOR_FILTERS);
            for (UUID uid : entry.getMatchingColorFilters()) {
                if(colorFilter == null || colorFilter.getPriority() > colorFilters.get(uid).getPriority()){
                    colorFilter = colorFilters.get(uid);
                }
            }
            if (colorFilter == null) {
                c.setForeground(this.getForeground());
                c.setBackground(this.getBackground());
            } else {
                c.setForeground(colorFilter.getForegroundColor());
                c.setBackground(colorFilter.getBackgroundColor());
            }
        }else{
            c.setForeground(this.getForeground());
            c.setBackground(this.getBackground());
        }
    }
    return c;
}