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


Java Highlighter类代码示例

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


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

示例1: interactiveSimpleStriping

import org.jdesktop.swingx.decorator.Highlighter; //导入依赖的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

示例2: interactiveTableCustomColorRendererWithHighlighterDontTouch

import org.jdesktop.swingx.decorator.Highlighter; //导入依赖的package包/类
/**
 * Compare xtable using custom color renderer - standard vs. ext.<p>
 * Adds highlighter which respects renderer's dont touch.
 */
public void interactiveTableCustomColorRendererWithHighlighterDontTouch() {
    TableModel model = new AncientSwingTeam();
    JXTable xtable = new JXTable(model);
    Highlighter highlighter = createPropertyRespectingHighlighter(
            HighlighterFactory.createSimpleStriping(HighlighterFactory.GENERIC_GRAY));

    xtable.addHighlighter(highlighter);
    xtable.setDefaultRenderer(Color.class, new ColorRenderer(true));
    JXTable table = new JXTable(model);
    table.addHighlighter(highlighter);
    TableCellRenderer renderer = createColorRendererExt();
    table.setDefaultRenderer(Color.class, renderer);
    JXFrame frame = wrapWithScrollingInFrame(xtable, table, "JXTable/highlighter dont-touch: Custom color renderer - standard/ext");
    addStatusMessage(frame, "Highlighter doesn't touch custom color renderer visual properties");
    frame.pack();
    frame.setVisible(true);
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:22,代码来源:RendererVisualCheck.java

示例3: interactiveTriangleRenderer

import org.jdesktop.swingx.decorator.Highlighter; //导入依赖的package包/类
public void interactiveTriangleRenderer() {
    JXTable table = new JXTable(new AncientSwingTeam());
    ShapePainter painter = new ShapePainter();
    Shape polygon = new Polygon(new int[] { 0, 5, 5 },
            new int[] { 0, 0, 5 }, 3);
    painter.setShape(polygon);
    painter.setFillPaint(Color.RED);
    painter.setStyle(ShapePainter.Style.FILLED);
    painter.setPaintStretched(false);
    // hmm.. how to make this stick to the trailing upper corner?
    painter.setHorizontalAlignment(HorizontalAlignment.RIGHT);
    painter.setVerticalAlignment(VerticalAlignment.TOP);
    Highlighter hl = new PainterHighlighter(new ColumnHighlightPredicate(3), painter); 
    table.addHighlighter(hl);
    showWithScrollingInFrame(table, "Renderer with Triangle marker");
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:17,代码来源:PainterVisualCheck.java

示例4: interactiveValueBasedGradientHighlightPlusStriping

import org.jdesktop.swingx.decorator.Highlighter; //导入依赖的package包/类
/**
     * Use transparent gradient painter for value-based background highlighting
     * with SwingX extended default renderer. Shared by table and list with
     * striping.
     */
    public void interactiveValueBasedGradientHighlightPlusStriping() {
        TableModel model = new AncientSwingTeam();
        JXTable table = new JXTable(model);
        ComponentProvider<JLabel> controller = new LabelProvider(
                JLabel.RIGHT) ;
        RelativePainterHighlighter gradientHighlighter = 
            createRelativeGradientHighlighter(HorizontalAlignment.RIGHT, 100);
        table.addHighlighter(gradientHighlighter);
        Highlighter alternateRowHighlighter = HighlighterFactory.createSimpleStriping();
        table.addHighlighter(alternateRowHighlighter);
        table.addHighlighter(gradientHighlighter);
        // 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(gradientHighlighter);
        list.toggleSortOrder();
        final JXFrame frame = wrapWithScrollingInFrame(table, list,
                "transparent value relative highlighting plus striping");
        addStatusMessage(frame,
                "uses a PainterAwareLabel in renderer");
        // crude binding to play with options - the factory is incomplete...
//        addStatusComponent(frame, createTransparencyToggle(gradientHighlighter));
//        show(frame);
    }
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:31,代码来源:PainterVisualCheck.java

示例5: testPackWithPrepareRenderer

import org.jdesktop.swingx.decorator.Highlighter; //导入依赖的package包/类
/**
 * Issue #1215-swingx: ColumnFactory must pack with prepareRenderer.
 * Otherwise, doesn't catch sizing effective highlighters, like f.i. font.
 */
@Test
public void testPackWithPrepareRenderer() {
    JXTable table = new JXTable(1, 1);
    table.setValueAt("just a long string something utterly meaningless", 0, 0);
    table.packColumn(0, 0);
    assertEquals("sanity: no highlighter", table.prepareRenderer(
            table.getCellRenderer(0, 0), 0, 0).getPreferredSize().width,
            table.getColumn(0).getPreferredWidth());
    Highlighter hl = new BorderHighlighter(BorderFactory.createEmptyBorder(0, 50, 0, 50));
    table.addHighlighter(hl);
    table.packColumn(0, 0);
    assertEquals("highlighter which adds 100 px width", table.prepareRenderer(
            table.getCellRenderer(0, 0), 0, 0).getPreferredSize().width,
            table.getColumn(0).getPreferredWidth());
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:20,代码来源:ColumnFactoryTest.java

示例6: interactiveTestHighlightAndRowHeightCompareTree

import org.jdesktop.swingx.decorator.Highlighter; //导入依赖的package包/类
/**
 * compare treeTable/tree height
 *
 */
public void interactiveTestHighlightAndRowHeightCompareTree() {
    JXTreeTable treeTable = new JXTreeTable(treeTableModel);
    treeTable.setRowHeight(22);
    treeTable.setShowGrid(true, false);
    Highlighter hl = new ShadingColorHighlighter(
            new ColumnHighlightPredicate(0));

    treeTable.setHighlighters(
            HighlighterFactory.createSimpleStriping(HighlighterFactory.GENERIC_GRAY),

            hl);
    final JXTree tree = new JXTree(treeTableModel);
    JXTree renderer = (JXTree) treeTable.getCellRenderer(0, treeTable
            .getHierarchicalColumn());
    tree.setRowHeight(renderer.getRowHeight());

    JFrame frame = wrapWithScrollingInFrame(treeTable, tree, 
            "LinePrinter-, ColumnHighlighter and RowHeight");
    frame.setVisible(true);
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:25,代码来源:JXTreeTableVisualCheck.java

示例7: interactiveTestFilterHighlightAndLineStyle

import org.jdesktop.swingx.decorator.Highlighter; //导入依赖的package包/类
/**    issue #148
 *   did not work on LFs which normally respect lineStyle
 *   winLF does not respect it anyway...
 */    
public void interactiveTestFilterHighlightAndLineStyle() {
    JXTreeTable treeTable = new JXTreeTable(treeTableModel);
    // issue #148
    // did not work on LFs which normally respect lineStyle
    // winLF does not respect it anyway...
    treeTable.putClientProperty("JTree.lineStyle", "Angled");
    treeTable.setRowHeight(22);
   // add a bunch of highlighters directly
    treeTable.addHighlighter(
            HighlighterFactory.createSimpleStriping(HighlighterFactory.QUICKSILVER));
    Highlighter hl = new ShadingColorHighlighter(
            new ColumnHighlightPredicate(0));

    treeTable.addHighlighter(hl);
    treeTable.addHighlighter(new ColorHighlighter(new PatternPredicate(Pattern.compile("^s", Pattern.CASE_INSENSITIVE), 0), null, 
            Color.red));
    JFrame frame = wrapWithScrollingInFrame(treeTable,
            "QuickSilver-, Column-, PatternHighligher and LineStyle");
    frame.setVisible(true);
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:25,代码来源:JXTreeTableVisualCheck.java

示例8: createExtendedRolloverDecoration

import org.jdesktop.swingx.decorator.Highlighter; //导入依赖的package包/类
private Highlighter createExtendedRolloverDecoration() {
    Color color = PaintUtils.setAlpha(Color.YELLOW, 100);
    final PainterHighlighter hl = new PainterHighlighter(HighlightPredicate.NEVER, 
            new MattePainter(color));
    // <snip> JXList rollover support
    // listen to changes of cell-rollover property
    // and set a Highlighters custom predicate accordingly
    PropertyChangeListener l = new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            Point location = (Point) evt.getNewValue();
            int row = -1;
            if (location != null) {
                row = location.y;
            }
            hl.setHighlightPredicate(new MeritRangeHighlightPredicate(
                    row < 0 ? null : list.getElementAt(row))); 
        }
        
    };
    list.addPropertyChangeListener(RolloverProducer.ROLLOVER_KEY, l);
    // </snip>
    return hl;
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:26,代码来源:XListDemo.java

示例9: configureTableColumn

import org.jdesktop.swingx.decorator.Highlighter; //导入依赖的package包/类
/**
 * {@inheritDoc} <p>
 * 
 * Overridden to set the column's identifier, lookup the title 
 */
@Override
public void configureTableColumn(TableModel model,
        TableColumnExt columnExt) {
    super.configureTableColumn(model, columnExt);
    columnExt.setIdentifier(model.getColumnName(columnExt.getModelIndex()));
    configureTitle(columnExt);
    ComponentProvider<?> provider = getComponentProvider(columnExt.getIdentifier());
    if (provider != null) {
        columnExt.setCellRenderer(new DefaultTableRenderer(provider));
    }
    Highlighter highlighter = getHighlighter(columnExt.getIdentifier());
    if (highlighter != null) {
        columnExt.setHighlighters(highlighter);
    }
    columnExt.setComparator(getComparator(columnExt.getIdentifier()));
    columnExt.setPrototypeValue(getPrototypeValue(columnExt.getIdentifier()));
    if (getHiddenNames().contains(columnExt.getIdentifier())) {
        columnExt.setVisible(false);
    }
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:26,代码来源:CustomColumnFactory.java

示例10: updateView

import org.jdesktop.swingx.decorator.Highlighter; //导入依赖的package包/类
@Override
protected OWLObject updateView() {
	OWLEntity entity = getOWLWorkspace().getOWLSelectionModel().getSelectedEntity();
	if (isShowing() && entity != null) {
		Predicate<OWLEntity> entryReferencesEntity = new EntryReferencesEntity(entity);
		if (buttonFilter.isSelected()) {
			tableLexicon.setHighlighters(new Highlighter [] { });
			tableLexicon.setFilters(
					new FilterPipeline(
							new PredicateFilter<OWLEntity>(
									entryReferencesEntity, ENTITY_COLUMN)));
		}
		else if (buttonHighlight.isSelected()) {
			tableLexicon.setFilters(null);
			ColorHighlighter entityHightlighter =
				new ColorHighlighter(new EntryHighlightPredicate(entryReferencesEntity, ENTITY_COLUMN));
			entityHightlighter.setBackground(Colors.HIGHLIGHT_COLOR);
			tableLexicon.setHighlighters(new Highlighter [] { entityHightlighter });
		}
		setHeaderText();
	}
	return entity;
}
 
开发者ID:Kaljurand,项目名称:aceview,代码行数:24,代码来源:ACELexiconViewComponent.java

示例11: isInPipeline

import org.jdesktop.swingx.decorator.Highlighter; //导入依赖的package包/类
/**
 * Returns a flag indicating if the given highlighter is last in the
 * list of highlighters registered on the target. If so returns true. 
 * If not, it has the side-effect of removing the highlighter and returns false. 
 * 
 * @param searchHighlighter the highlighter to check for being last
 * @return a boolean indicating whether the highlighter is last.
 */
private boolean isInPipeline(Highlighter searchHighlighter) {
    Highlighter[] inPipeline = getHighlighters();
    if ((inPipeline.length > 0) && 
       (searchHighlighter.equals(inPipeline[inPipeline.length -1]))) {
        return true;
    }
    removeHighlighter(searchHighlighter);
    return false;
}
 
开发者ID:sing-group,项目名称:aibench-project,代码行数:18,代码来源:AbstractSearchable.java

示例12: testIllegalNegativeListRowIndex

import org.jdesktop.swingx.decorator.Highlighter; //导入依赖的package包/类
/**
 * Issue #473-swingx: NPE in list with highlighter. <p> 
 * 
 * Renderers are doc'ed to cope with invalid input values.
 * Highlighters can rely on valid ComponentAdapter state. 
 * JXList delegatingRenderer is the culprit which does set
 * invalid ComponentAdapter state. Negative invalid index.
 *
 */
@Test
public void testIllegalNegativeListRowIndex() {
    JXList list = new JXList(new Object[] {1, 2, 3});
    ListCellRenderer renderer = list.getCellRenderer();
    renderer.getListCellRendererComponent(list, "dummy", -1, false, false);
    SearchPredicate predicate = new SearchPredicate("\\QNode\\E");
    Highlighter searchHighlighter = new ColorHighlighter(predicate, null, Color.RED);
    list.addHighlighter(searchHighlighter);
    renderer.getListCellRendererComponent(list, "dummy", -1, false, false);
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:20,代码来源:JXListTest.java

示例13: interactiveBold

import org.jdesktop.swingx.decorator.Highlighter; //导入依赖的package包/类
/**
     * Size effecting decoration vs. initial config (in provider).
     * 
     * Decoration: use highlighter 
     * - works correctly only with largeModel (due to caching issues)
     * 
     * Config in Provider (usually not recommended): 
     * - override getRendererComponent, width always correct, height only
     *   if enabled via setRowHeight(0)
     *  
     */
    public void interactiveBold() {
        JXTree tree = new JXTree();
        tree.setCellRenderer(new DefaultTreeRenderer());
//        tree.setRowHeight(0);
        tree.setLargeModel(true);
        final Font bold = tree.getFont().deriveFont(Font.BOLD, 20f);
        Highlighter hl = new AbstractHighlighter(HighlightPredicate.IS_LEAF) {

            @Override
            protected Component doHighlight(Component component,
                    ComponentAdapter adapter) {
                component.setFont(bold);
                return component;
            }
        };
        tree.addHighlighter(hl);
        JXTree treeP = new JXTree();
        treeP.setRowHeight(0);
        WrappingProvider provider = new WrappingProvider() {
            
            @Override
            public WrappingIconPanel getRendererComponent(CellContext context) {
                super.getRendererComponent(context);
                if (context.isLeaf()) {
                    rendererComponent.setFont(bold);
                }
                return rendererComponent;
            }

        };
        treeP.setCellRenderer(new DefaultTreeRenderer(provider));
        showWithScrollingInFrame(tree, treeP, "bold font: decorate vs. config");
    }
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:45,代码来源:JXTreeIssues.java

示例14: testHighlighterHiddenTestColumn

import org.jdesktop.swingx.decorator.Highlighter; //导入依赖的package包/类
/**
 * Issue #180-swingx: outOfBoundsEx if testColumn is hidden.
 *
 */
@Test
public void testHighlighterHiddenTestColumn() {
    JXTable table = new JXTable(sortableTableModel);
    table.getColumnExt(0).setVisible(false);
    Highlighter highlighter = new ColorHighlighter(new PatternPredicate("a", 0), null,
            Color.RED);
    ComponentAdapter adapter = table.getComponentAdapter();
    adapter.row = 0;
    adapter.column = 0;
    highlighter.highlight(new JLabel(), adapter);
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:16,代码来源:JXTableUnitTest.java

示例15: testColumnHighlighting

import org.jdesktop.swingx.decorator.Highlighter; //导入依赖的package包/类
@Test
public void testColumnHighlighting() {
    JXTable table = new JXTable(tableModel);
    List<Highlighter> events = new ArrayList<Highlighter>();
    
    Highlighter tableHighlighter = new TestingHighlighter(events);
    Highlighter columnHighlighter = new TestingHighlighter(events);
    
    //sanity check
    assertEquals(0, events.size());
    
    table.addHighlighter(tableHighlighter);
    table.getColumnExt(0).addHighlighter(columnHighlighter);
    
    //explicity prepare the renderer
    table.prepareRenderer(new DefaultTableCellRenderer(), 0, 0);
    
    assertEquals(2, events.size());
    assertSame(events.get(0), tableHighlighter);
    assertSame(events.get(1), columnHighlighter);
    
    events.clear();
    
    //explicity prepare the renderer
    table.prepareRenderer(new DefaultTableCellRenderer(), 0, 1);
    
    assertEquals(1, events.size());
    assertSame(events.get(0), tableHighlighter);
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:30,代码来源:JXTableUnitTest.java


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