org.jdesktop.swingx.decorator.HighlightPredicate Java Examples

The following examples show how to use org.jdesktop.swingx.decorator.HighlightPredicate. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LinkTagsDialog.java    From dsworkbench with Apache License 2.0 6 votes vote down vote up
public LinkedTag setupAndShow() {
    jXTable1.setModel(new TagLinkMatrixModel());
    HighlightPredicate.ColumnHighlightPredicate colu = new HighlightPredicate.ColumnHighlightPredicate(0);
    jXTable1.setHighlighters(new CompoundHighlighter(colu, HighlighterFactory.createAlternateStriping(Constants.DS_ROW_A, Constants.DS_ROW_B)));
    jXTable1.setColumnControlVisible(false);
    jXTable1.setDefaultRenderer(Integer.class, new MultiColorCellRenderer());
    jXTable1.setDefaultEditor(Integer.class, new LinkGroupColorCellEditor());
    jXTable1.setRowHeight(21);
    jXTable1.getTableHeader().setDefaultRenderer(new DefaultTableHeaderRenderer());
    setVisible(true);

    if (bCreateLinkedTag) {
        LinkedTag t = new LinkedTag(jTagName.getText(), true);
        String equation = ((TagLinkMatrixModel) jXTable1.getModel()).getEquation();
        equation = equation.replaceAll("UND", "&&");
        equation = equation.replaceAll("ODER", "||");
        t.setEquation(equation);
        t.updateVillageList();
        return t;
    }
    return null;
}
 
Example #2
Source File: VioGenQueriesWPanel.java    From BART with MIT License 5 votes vote down vote up
/** 
 *  
 */ 
private void updateTableHighlighter() { 
    tableValueBasedHighlighter.setRelativizer(createPercentageRelativizer(100)); 
    if (isSpreadColumns()) { 
        tableValueBasedHighlighter.setHighlightPredicate(HighlightPredicate.ALWAYS); 
    } else { 
        tableValueBasedHighlighter.setHighlightPredicate( 
                new HighlightPredicate.ColumnHighlightPredicate(percentageColumn)); 
    }     
}
 
Example #3
Source File: ParametersPanel.java    From nextreports-designer with Apache License 2.0 5 votes vote down vote up
private void createTable() {
	model = new ParametersTableModel();
	table = new JXTable(model);
       table.setSortable(false);
       //table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
       table.setRolloverEnabled(true);
       table.addHighlighter(new ColorHighlighter(HighlightPredicate.ROLLOVER_ROW, null, Color.RED)); 
}
 
Example #4
Source File: DSWorkbenchDoItYourselfAttackPlaner.java    From dsworkbench with Apache License 2.0 4 votes vote down vote up
@Override
public void resetView() {
    AttackManager.getSingleton().addManagerListener(this);
    //setup renderer and general view
   // ((DoItYourselfAttackTableModel) jAttackTable.getModel()).clear();

    HighlightPredicate.ColumnHighlightPredicate colu = new HighlightPredicate.ColumnHighlightPredicate(0, 1, 2, 3, 6);
    jAttackTable.setRowHeight(24);
    jAttackTable.getTableHeader().setDefaultRenderer(new DefaultTableHeaderRenderer());
    jAttackTable.setHighlighters(new CompoundHighlighter(colu, HighlighterFactory.createAlternateStriping(Constants.DS_ROW_A, Constants.DS_ROW_B)));
    jAttackTable.setColumnControlVisible(true);
    jAttackTable.setDefaultEditor(UnitHolder.class, new UnitCellEditor());
    jAttackTable.setDefaultEditor(Village.class, new VillageCellEditor());
    jAttackTable.setDefaultRenderer(UnitHolder.class, new UnitCellRenderer());
    jAttackTable.setDefaultRenderer(Integer.class, new NoteIconCellRenderer(NoteIconCellRenderer.ICON_TYPE.NOTE));
    jAttackTable.setDefaultRenderer(Date.class, new ColoredDateCellRenderer());
    jAttackTable.setDefaultRenderer(Long.class, new ColoredCoutdownCellRenderer());
    jAttackTable.setDefaultEditor(Date.class, new DateSpinEditor());
    jAttackTable.setDefaultEditor(Integer.class, new NoteIconCellEditor(NoteIconCellEditor.ICON_TYPE.NOTE));
    BufferedImage back = ImageUtils.createCompatibleBufferedImage(5, 5, BufferedImage.BITMASK);
    Graphics2D g = back.createGraphics();
    GeneralPath p = new GeneralPath();
    p.moveTo(0, 0);
    p.lineTo(5, 0);
    p.lineTo(5, 5);
    p.closePath();
    g.setColor(Color.GREEN.darker());
    g.fill(p);
    g.dispose();
    jAttackTable.addHighlighter(new PainterHighlighter(HighlightPredicate.EDITABLE, new ImagePainter(back, HorizontalAlignment.RIGHT, VerticalAlignment.TOP)));

    DefaultComboBoxModel model = new DefaultComboBoxModel();
    DefaultComboBoxModel model2 = new DefaultComboBoxModel();
    for (UnitHolder unit : DataHolder.getSingleton().getUnits()) {
        model.addElement(unit);
        model2.addElement(unit);
    }
    jUnitBox.setModel(model);
    jUnitComboBox.setModel(model2);
    jUnitBox.setSelectedItem(DataHolder.getSingleton().getUnitByPlainName("ram"));
    jUnitComboBox.setSelectedItem(DataHolder.getSingleton().getUnitByPlainName("ram"));
    jUnitBox.setRenderer(new UnitListCellRenderer());
    jAttackTypeComboBox.setRenderer(new StandardAttackListCellRenderer());
    
    DefaultComboBoxModel typeModel = new DefaultComboBoxModel();

    for (ManageableType t : StandardAttackManager.getSingleton().getAllElements()) {
        StandardAttack a = (StandardAttack) t;
        typeModel.addElement(a);
    }
    jAttackTypeComboBox.setModel(typeModel);

    jUnitComboBox.setRenderer(new UnitListCellRenderer());

    jSourceVillage.setValue(new Point(500, 500));
    jTargetVillage.setValue(new Point(500, 500));
    SwingUtilities.invokeLater(new Runnable() {

        @Override
        public void run() {
            jSourceVillage.updateUI();
            jTargetVillage.updateUI();
        }
    });

}
 
Example #5
Source File: BaseForm.java    From CodenameOne with GNU General Public License v2.0 4 votes vote down vote up
public EditorTable() {
    setSortable(true);
    addHighlighter(HighlighterFactory.createSimpleStriping());
    addHighlighter(new ColorHighlighter(HighlightPredicate.ROLLOVER_ROW, null, Color.RED));  
    setColumnControlVisible(true);
}
 
Example #6
Source File: DesignerTablePanel.java    From nextreports-designer with Apache License 2.0 4 votes vote down vote up
private void createTable() {
        // create the table
        model = new MyTableModel();
        table = new JXTable(model) {

            private Map<Integer, ComboBoxEditor> editors = new HashMap<Integer, ComboBoxEditor>();

            public boolean getScrollableTracksViewportHeight() {
                return getPreferredSize().height < getParent().getHeight();
            }

            public void changeSelection(int rowIndex, int columnIndex,
                                        boolean toggle, boolean extend) {
                if (!dndRecognizer.isDragged()) {
                    super.changeSelection(rowIndex, columnIndex, toggle, extend);
                }
            }

            public TableCellEditor getCellEditor(int row, int column) {
                if (column != 6) {
                    return super.getCellEditor(row, column);
                }
                ComboBoxEditor editor = editors.get(row);
                if (editor == null) {
                    editor = new ComboBoxEditor(new String[]{"", GROUP_BY, SUM, AVG, MIN, MAX, COUNT});
                    editors.put(row, editor);
                }
                return editor;
            }
        };
        tableRowHeader = TableUtil.setRowHeader(table);
        table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        TableColumn col = table.getColumnModel().getColumn(3);
//        col.setCellRenderer(TableCellRenderers.getNewDefaultRenderer(Boolean.class));
        col.setCellRenderer(table.getDefaultRenderer(Boolean.class));
        col.setCellEditor(table.getDefaultEditor(Boolean.class));
        table.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
        // no border
        JTextField tf = new JTextField();
        tf.setBorder(BorderFactory.createEmptyBorder());
        table.setDefaultEditor(Object.class, new DefaultCellEditor(tf));

        col = table.getColumnModel().getColumn(4);
//        col.setCellRenderer(TableCellRenderers.getNewDefaultRenderer(Boolean.class));
        JComboBox sortCombo = new JComboBox(new String[]{"", ASC, DESC});
        sortCombo.setBorder(BorderFactory.createEmptyBorder());
        col.setCellEditor(new ComboBoxEditor(sortCombo));

        col = table.getColumnModel().getColumn(5);
        sortOrderCombo = new JComboBox();
        sortOrderCombo.setBorder(BorderFactory.createEmptyBorder());
        col.setCellEditor(new ComboBoxEditor(sortOrderCombo));

        col = table.getColumnModel().getColumn(6);

        table.setSortable(false);
        table.setColumnControlVisible(true);
        table.getTableHeader().setReorderingAllowed(false);
        table.setHorizontalScrollEnabled(true);

        // highlight table
        table.setHighlighters(HighlighterFactory.createAlternateStriping(Color.WHITE, ColorUtil.PANEL_BACKROUND_COLOR));

        table.getTableHeader().setReorderingAllowed(false);
        
        table.setRolloverEnabled(true);
        table.addHighlighter(new ColorHighlighter(HighlightPredicate.ROLLOVER_ROW, null, Color.RED)); 
    }
 
Example #7
Source File: TextHighlighter.java    From nextreports-designer with Apache License 2.0 4 votes vote down vote up
public TextHighlighter(String text, Color background) {
    super(new HighlightPredicate.EqualsHighlightPredicate(text));
    setBackground(background);
}