当前位置: 首页>>代码示例>>Java>>正文


Java HighlightPredicate类代码示例

本文整理汇总了Java中org.jdesktop.swingx.decorator.HighlightPredicate的典型用法代码示例。如果您正苦于以下问题:Java HighlightPredicate类的具体用法?Java HighlightPredicate怎么用?Java HighlightPredicate使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


HighlightPredicate类属于org.jdesktop.swingx.decorator包,在下文中一共展示了HighlightPredicate类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: interactiveTableBorderHighlighter

import org.jdesktop.swingx.decorator.HighlightPredicate; //导入依赖的package包/类
/**
 * Show variants of border Highlighters.
 *
 */
public void interactiveTableBorderHighlighter() {
    JXTable table = new JXTable(tableModel);
    table.setVisibleRowCount(table.getRowCount());
    table.setVisibleColumnCount(7);
    table.packAll();
    table.setColumnControlVisible(true);
    
    BorderHighlighter outer = new BorderHighlighter(new HighlightPredicate.ColumnHighlightPredicate(1),
            BorderFactory.createLineBorder(Color.RED, 3));
    BorderHighlighter inner = new BorderHighlighter(new HighlightPredicate.ColumnHighlightPredicate(2),
            BorderFactory.createLineBorder(Color.RED, 3), true, true);
    BorderHighlighter replace = new BorderHighlighter(new HighlightPredicate.ColumnHighlightPredicate(0),
            BorderFactory.createLineBorder(Color.RED, 3), false, true);
    table.setHighlighters(outer, inner, replace);
    showWithScrollingInFrame(table, "Border Highlighters");
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:21,代码来源:HighlighterClientVisualCheck.java

示例2: interactiveTablePatternHighlighterJP

import org.jdesktop.swingx.decorator.HighlightPredicate; //导入依赖的package包/类
/**
 * Multiple Highlighters (shown as example in Javapolis 2007).
 * 
 */
public void interactiveTablePatternHighlighterJP() {
    JXTable table = new JXTable(tableModel);
    table.setVisibleRowCount(table.getRowCount());
    table.setVisibleColumnCount(7);
    table.packAll();
    table.setColumnControlVisible(true);

    Font font = table.getFont().deriveFont(Font.BOLD | Font.ITALIC);
    Highlighter simpleStriping = HighlighterFactory.createSimpleStriping();
    PatternPredicate patternPredicate = new PatternPredicate("^M", 1);
    ColorHighlighter magenta = new ColorHighlighter(patternPredicate, null,
            Color.MAGENTA, null, Color.MAGENTA);
    FontHighlighter derivedFont = new FontHighlighter(patternPredicate,
            font);
    AbstractHighlighter gradient = createRelativeGradientHighlighter(HorizontalAlignment.LEFT, AncientSwingTeam.INTEGER_COLUMN);
    gradient.setHighlightPredicate(new HighlightPredicate.ColumnHighlightPredicate(AncientSwingTeam.INTEGER_COLUMN));
    
    LOG.info("" + (table.getValueAt(0, 3) instanceof Number));
    Highlighter shading = new ShadingColorHighlighter(
            new HighlightPredicate.ColumnHighlightPredicate(1));

    table.setHighlighters(simpleStriping, magenta, derivedFont, shading //);
            , gradient);
    showWithScrollingInFrame(table, "Multiple Highlighters");
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:30,代码来源:HighlighterClientVisualCheck.java

示例3: interactiveTableColorBasedOnComponentValue

import org.jdesktop.swingx.decorator.HighlightPredicate; //导入依赖的package包/类
/**
 * Example of custom predicate based on the component's value, 
 * (as opposed to on the value of the adapter). 
 * 
 * 
 */
public void interactiveTableColorBasedOnComponentValue() {
    TableModel model = new AncientSwingTeam();
    JXTable table = new JXTable(model);
    table.setForeground(Color.GREEN);
    HighlightPredicate predicate = new HighlightPredicate() {

        @Override
        public boolean isHighlighted(Component renderer, ComponentAdapter adapter) {
            if (!(renderer instanceof JLabel)) return false;
            String text = ((JLabel) renderer).getText();
             return text.contains("y");
        }
        
    };
    ColorHighlighter hl = new ColorHighlighter(predicate, null, Color.RED);
    table.addHighlighter(HighlighterFactory.createSimpleStriping(HighlighterFactory.GENERIC_GRAY));
    table.addHighlighter(hl);
    showWithScrollingInFrame(table, 
            "component value-based rendering (label text contains y) ");
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:27,代码来源:HighlighterClientVisualCheck.java

示例4: interactiveRolloverHighlight

import org.jdesktop.swingx.decorator.HighlightPredicate; //导入依赖的package包/类
/**
 * Plain RolloverHighlighter. 
 * Issue #513-swingx: no rollover effect for disabled table.
 *
 */
public void interactiveRolloverHighlight() {
    final JXTable table = new JXTable(tableModel);
    ColorHighlighter colorHighlighter = new ColorHighlighter(HighlightPredicate.ROLLOVER_ROW, Color.YELLOW, null);
    table.addHighlighter(colorHighlighter);
    Action action = new AbstractAction("toggle table enabled") {

        @Override
        public void actionPerformed(ActionEvent e) {
            table.setEnabled(!table.isEnabled());
            
        }
        
    };
    JXFrame frame = showWithScrollingInFrame(table, "rollover highlight, enabled/disabled table");
    addAction(frame, action);
    frame.pack();
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:23,代码来源:HighlighterClientVisualCheck.java

示例5: interactiveSimpleStriping

import org.jdesktop.swingx.decorator.HighlightPredicate; //导入依赖的package包/类
/**
 * shows the effect of a simple striping highlighter on a 
 * colored table.
 *
 */
public void interactiveSimpleStriping() {
    JXTable table = new JXTable(tableModel);
    table.setVisibleRowCount(table.getRowCount() + 3);
    table.setBackground(new Color(0xC0FFC0));
    table.addHighlighter(HighlighterFactory.createSimpleStriping());
    Highlighter disabled = new AbstractHighlighter(HighlightPredicate.READ_ONLY) {
        
        @Override
        protected Component doHighlight(Component component,
                ComponentAdapter adapter) {
            component.setEnabled(false);
            return component;
        }
    };
    table.getColumnExt(0).setEditable(false);
    table.getColumnExt(2).setEditable(false);
    table.getColumnExt(0).setCellRenderer(new DefaultTableRenderer(new TextFieldProvider()));
    table.addHighlighter(disabled);
    showWithScrollingInFrame(table, "Simple gray striping");
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:26,代码来源:HighlighterClientVisualCheck.java

示例6: interactiveCheckBoxRendererOpacity1513

import org.jdesktop.swingx.decorator.HighlightPredicate; //导入依赖的package包/类
/**
     * Issue #1513-swingx: opacity of JRendererCheckBox can't be effected by 
     * client code.
     * 
     * Here's a use-case: make all components in the stack not-opaque to show
     * a background image. (note: opacity not false for number column)
     */
    public void interactiveCheckBoxRendererOpacity1513() {
        JXPanel panel = new JXPanel(new BorderLayout());
        panel.setBackgroundPainter(new ImagePainter(XTestUtils.loadDefaultImage("moon.jpg")));
        JXTable table = new JXTable(new AncientSwingTeam());
        table.addHighlighter(HighlighterFactory.createSimpleStriping());
        table.addHighlighter(new PainterHighlighter(HighlightPredicate.ROLLOVER_ROW, 
                new MattePainter(PaintUtils.setAlpha(Color.RED, 100))));
//                new BusyPainter()));
        panel.add(new JScrollPane(table));
        table.setOpaque(false);
        JComponent comp = (JComponent) table.prepareRenderer(0, 0);
        comp.setOpaque(false);
        AbstractButton checkBox = (AbstractButton) table.prepareRenderer(0, AncientSwingTeam.BOOLEAN_COLUMN);
        checkBox.setOpaque(false);
        ((JComponent) table.getParent()).setOpaque(false);
        ((JComponent) table.getParent().getParent()).setOpaque(false);
        showInFrame(panel, "Checkbox: set to opacity");
    }
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:26,代码来源:RendererVisualCheck.java

示例7: interactiveIconPainterHighlight

import org.jdesktop.swingx.decorator.HighlightPredicate; //导入依赖的package包/类
/**
 * Use highlighter with background image painter. Shared by table and list.
 */
public void interactiveIconPainterHighlight() throws Exception {
    TableModel model = new AncientSwingTeam();
    JXTable table = new JXTable(model);
    ComponentProvider<JLabel> controller = new LabelProvider(
            JLabel.RIGHT);
    table.getColumn(0).setCellRenderer(
            new DefaultTableRenderer(controller));
    final ImagePainter imagePainter = new ImagePainter(XTestUtils.loadDefaultImage());
    HighlightPredicate predicate = new ColumnHighlightPredicate(0);
    Highlighter iconHighlighter = new PainterHighlighter(predicate, imagePainter );
    Highlighter alternateRowHighlighter = HighlighterFactory.createSimpleStriping();
    table.addHighlighter(alternateRowHighlighter);
    table.addHighlighter(iconHighlighter);
    // re-use component controller and highlighter in a JXList
    JXList list = new JXList(createListNumberModel(), true);
    list.setCellRenderer(new DefaultListRenderer(controller));
    list.addHighlighter(alternateRowHighlighter);
    list.addHighlighter(iconHighlighter);
    list.toggleSortOrder();
    final JXFrame frame = showWithScrollingInFrame(table, list,
            "image highlighting plus striping");
    frame.pack();
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:27,代码来源:PainterVisualCheck.java

示例8: interactiveAnimatedIconPainterHighlight

import org.jdesktop.swingx.decorator.HighlightPredicate; //导入依赖的package包/类
/**
 * Use highlighter with image painter which is marching across the 
 * cell range (same for all, independent of value).
 */
public void interactiveAnimatedIconPainterHighlight()  {
    TableModel model = new AncientSwingTeam();
    JXTable table = new JXTable(model);
    table.getColumn(1).setCellRenderer(new DefaultTableRenderer(new HyperlinkProvider()));
    ImagePainter imagePainter = new ImagePainter(XTestUtils.loadDefaultImage("green-orb.png"));
    imagePainter.setHorizontalAlignment(HorizontalAlignment.RIGHT);
    final RelativePainter<?> painter = new RelativePainter<Component>(imagePainter);
    PainterHighlighter iconHighlighter = new PainterHighlighter();
    iconHighlighter.setHighlightPredicate(HighlightPredicate.ROLLOVER_ROW);
    iconHighlighter.setPainter(painter);
    ActionListener l = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            double fraction = painter.getXFactor();
            fraction = fraction > 1 ? 0.0 : fraction + 0.1;
            painter.setXFactor(fraction);
        }
        
    };
    table.addHighlighter(iconHighlighter);
    showWithScrollingInFrame(table, 
            "Animated highlighter: marching icon on rollover");
    Timer timer = new Timer(100, l);
    timer.start();
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:29,代码来源:PainterVisualCheck.java

示例9: interactiveXTreeLabelFormattingHighlighter

import org.jdesktop.swingx.decorator.HighlightPredicate; //导入依赖的package包/类
/**
 * Custom format on JTree/JXTree (latter with highlighter).
 *
 */
public void interactiveXTreeLabelFormattingHighlighter() {
    TreeModel model = createComponentHierarchyModel();
    JTree tree = new JTree(model);
    StringValue converter = new StringValue() {

        public String getString(Object value) {
            if (value instanceof Component) {
                return "Name: " + ((Component) value).getName();
            }
            return StringValues.TO_STRING.getString(value);
        }
        
    };
    tree.setCellRenderer(new DefaultTreeRenderer(converter));
    JXTree xtree = new JXTree(model);
    xtree.setHighlighters(new ColorHighlighter(HighlightPredicate.ROLLOVER_ROW, Color.RED,
            Color.YELLOW));
    xtree.setRolloverEnabled(true);
    // share renderer
    xtree.setCellRenderer(tree.getCellRenderer());
    final JXFrame frame = wrapWithScrollingInFrame(tree, xtree, "custom format - tree vs. xtree (+Rollover renderer)");
    frame.setVisible(true);
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:28,代码来源:TreeRendererTest.java

示例10: setUp

import org.jdesktop.swingx.decorator.HighlightPredicate; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
    super.setUp();
    sortableTableModel = new AncientSwingTeam();
    listModel = new AbstractListModel() {

        public int getSize() {
            return sortableTableModel.getRowCount();
        }

        public Object getElementAt(int index) {
            return sortableTableModel.getValueAt(index, 0);
        }
        
    };
    treeTableModel = new FileSystemModel();
    foregroundHighlighter = new ColorHighlighter(HighlightPredicate.ROLLOVER_ROW, null,
            Color.MAGENTA);
    backgroundHighlighter = new ColorHighlighter(HighlightPredicate.ROLLOVER_ROW, Color.YELLOW,
            null);
 }
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:22,代码来源:RolloverVisualCheck.java

示例11: createXTableWithIndyRowHeights

import org.jdesktop.swingx.decorator.HighlightPredicate; //导入依赖的package包/类
/**
 * Creates and returns a JXTable with model as returned by createTableModel with
 * eventBig == false.
 * Has a FontHighlighter which decorates the renderer with a big font if 
 * the cell value is BIG.
 *  
 * @return a JXTable configured 
 */
private JXTable createXTableWithIndyRowHeights() {
    DefaultTableModel model = createTableModel(false);
    JXTable table = new JXTable(model);
    HighlightPredicate predicate = new HighlightPredicate() {

        @Override
        public boolean isHighlighted(Component renderer,
                ComponentAdapter adapter) {
            return BIG.equals(adapter.getValue());
        }
        
    };
    FontHighlighter highlighter = new FontHighlighter(predicate, table.getFont().deriveFont(50f));
    table.addHighlighter(highlighter);
    return table;
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:25,代码来源:TableRowHeightControllerTest.java

示例12: interactiveHierarchicalToolTip

import org.jdesktop.swingx.decorator.HighlightPredicate; //导入依赖的package包/类
/**
 * Issue #??-swingx: Tooltip by highlighter in hierarchical column
 * 
 * Issue #1527-swingx: tooltip not shown after changing expansion state.
 *
 * Not reliably updated (independent on whether to use a Highlighter or core renderer
 * with Highlighter set, also @see {@link #interactiveTestToolTipsCoreRenderer()}
 * 
 * To reproduce: 
 * - move to some row over the hierarchical column where the tooltip is showing
 * - move the next row, typically the tooltip is not showing (no, can't reproduce)
 * - reproducible (from bug report): collapse/expand the row, then move (in same or 
 * other row): tooltip not shown until the mouse has been moved completely outside
 * of the table
 * 
 * Seems to happen, if the tooltip was hidden due to the collapse/expose. To reproduce
 * - move to show the tooltip in hierarchical column
 * - wait until it is hidden by the tooltipManager
 * - collapse/expand and move: tooltip shown again
 * 
 */
public void interactiveHierarchicalToolTip() {
    ToolTipManager manager = ToolTipManager.sharedInstance();
    final JXTreeTable table = new JXTreeTable(treeTableModel);
    Highlighter toolTip = new AbstractHighlighter(
            new AndHighlightPredicate(
            new ColumnHighlightPredicate(0), HighlightPredicate.ROLLOVER_ROW)) {

        @Override
        protected Component doHighlight(Component component,
                ComponentAdapter adapter) {
            ((JComponent) component).setToolTipText(adapter.getString());
            return component;
        }
        
    };
    table.addHighlighter(toolTip);
    JXFrame frame = wrapWithScrollingInFrame(table, "ToolTip with Highlighter (hierarchical column)");
    addComponentOrientationToggle(frame);
    addStatusComponent(frame, new JTextField("something to focus"));
    frame.setVisible(true);
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:43,代码来源:JXTreeTableVisualCheck.java

示例13: interactiveTestHierarchicalColumnHighlightConditional

import org.jdesktop.swingx.decorator.HighlightPredicate; //导入依赖的package包/类
/**
 * Requirement: color the leafs of the hierarchical columns differently.
 * 
 * http://forums.java.net/jive/thread.jspa?messageID=165876
 * 
 *
 */
public void interactiveTestHierarchicalColumnHighlightConditional() {
    JXTreeTable treeTable = new JXTreeTable(treeTableModel);
    HighlightPredicate hierarchical = new ColumnHighlightPredicate(0);
    treeTable.addHighlighter(new ShadingColorHighlighter(hierarchical));
    HighlightPredicate predicate = new HighlightPredicate() {

        @Override
        public boolean isHighlighted(Component renderer, ComponentAdapter adapter) {
            return adapter.isLeaf();
        }
        
    };
    ColorHighlighter highlighter = new ColorHighlighter(new AndHighlightPredicate(hierarchical, predicate),
            new Color(247,246,239), null);
    treeTable.addHighlighter(highlighter);
    showWithScrollingInFrame(treeTable,
    "HierarchicalColumn And Conditional ");
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:26,代码来源:JXTreeTableVisualCheck.java

示例14: interactiveRepaintOnUpdateSingleCell

import org.jdesktop.swingx.decorator.HighlightPredicate; //导入依赖的package包/类
/**
 * After moving to Mustang, this might be vieweda as a bug ;-)
 * Was: Unconditional repaint on cell update (through the default
 * identify filter). 
 * Is: only the updated cell is repainted, unrelated (from model perspective)
 * cells (like others in row) are not repainted. 
 */
public void interactiveRepaintOnUpdateSingleCell() {
    JXTable table =  new JXTable(10, 5);
    // highlight complete row if first cell starts with a
    HighlightPredicate predicate = new HighlightPredicate() {

        public boolean isHighlighted(Component renderer,
                ComponentAdapter adapter) {
            return adapter.getString(0).startsWith("a");
        }
        
    };
    ColorHighlighter highlighter = new ColorHighlighter(predicate, Color.MAGENTA, null, Color.MAGENTA, null);
    table.addHighlighter(highlighter);
    JXTable other = new JXTable(table.getModel());
    other.addHighlighter(highlighter);
    JXFrame frame = wrapWithScrollingInFrame(table, other, "repaint on update in first");
    addMessage(frame, "edit first cell in left table (start with/out a)");
    show(frame);
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:27,代码来源:JXTableIssues.java

示例15: interactiveTestRolloverHighlightMultiColumn

import org.jdesktop.swingx.decorator.HighlightPredicate; //导入依赖的package包/类
/**
 * Plain rollover highlight in multi-column layout, had been repaint issues.
 *
 */
public void interactiveTestRolloverHighlightMultiColumn() {
    LOG.info("rtol-map? " + UIManager.get("List.focusInputMap.RightToLeft"));
    LOG.info("ancestor maps? " + UIManager.get("Table.ancestorInputMap"));
    LOG.info("ancestor rtol maps? " + UIManager.get("Table.ancestorInputMap.RightToLeft"));
    
    JXList list = new JXList(listModel);
    list.setRolloverEnabled(true);
    list.setLayoutOrientation(JList.HORIZONTAL_WRAP);
    list.addHighlighter(new ColorHighlighter(HighlightPredicate.ROLLOVER_ROW, new Color(0xF0, 0xF0, 0xE0), 
            null));
    JList core = new JList(listModel);
    core.setLayoutOrientation(JList.HORIZONTAL_WRAP);
    JComponent box = Box.createVerticalBox();
    box.add(new JScrollPane(list));
    box.add(new JScrollPane(core));
    JXFrame frame = wrapInFrame(box, "rollover highlight - horz. Wrap");
    addComponentOrientationToggle(frame);
    show(frame);
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:24,代码来源:JXListVisualCheck.java


注:本文中的org.jdesktop.swingx.decorator.HighlightPredicate类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。