本文整理汇总了Java中org.jdesktop.swingx.decorator.HighlightPredicate.ColumnHighlightPredicate方法的典型用法代码示例。如果您正苦于以下问题:Java HighlightPredicate.ColumnHighlightPredicate方法的具体用法?Java HighlightPredicate.ColumnHighlightPredicate怎么用?Java HighlightPredicate.ColumnHighlightPredicate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jdesktop.swingx.decorator.HighlightPredicate
的用法示例。
在下文中一共展示了HighlightPredicate.ColumnHighlightPredicate方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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");
}
示例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");
}
示例3: addIconsToSomeColumns
import org.jdesktop.swingx.decorator.HighlightPredicate; //导入方法依赖的package包/类
private static void addIconsToSomeColumns() {
Icon icon = new Icon() {
@Override
public int getIconHeight() {
return 8;
}
@Override
public int getIconWidth() {
return 18;
}
@Override
public void paintIcon(Component c, Graphics g, int x, int y) {
g.setColor(Color.GREEN);
g.fillRect(x, y, getIconWidth(), getIconHeight());
}
};
IconHighlighter iconHighlighter = new IconHighlighter(
new HighlightPredicate.ColumnHighlightPredicate(3, 4, 5), icon);
table.addHighlighter(iconHighlighter);
}
示例4: setupAndShow
import org.jdesktop.swingx.decorator.HighlightPredicate; //导入方法依赖的package包/类
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.setDefaultRenderer(Tag.class, new AlternatingColorCellRenderer());
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;
}
示例5: interactiveTreeTableRolloverHierarchical
import org.jdesktop.swingx.decorator.HighlightPredicate; //导入方法依赖的package包/类
/**
* Example for per-cell rollover decoration in JXTreeTable.
*/
public void interactiveTreeTableRolloverHierarchical() {
final JXTreeTable table = new JXTreeTable(treeTableModel);
HighlightPredicate andPredicate = new AndHighlightPredicate(
new HighlightPredicate.ColumnHighlightPredicate(0),
HighlightPredicate.ROLLOVER_ROW
);
final Highlighter foregroundHighlighter = new ColorHighlighter(andPredicate, null,
Color.MAGENTA);
final Highlighter backgroundHighlighter = new ColorHighlighter(andPredicate, Color.YELLOW,
null);
table.setHighlighters(foregroundHighlighter);
JXFrame frame = wrapWithScrollingInFrame(table, "TreeTable with rollover - effect hierarchical column");
Action toggleAction = new AbstractAction("toggle foreground/background") {
boolean isBackground;
public void actionPerformed(ActionEvent e) {
if (isBackground) {
table.setHighlighters(foregroundHighlighter);
} else {
table.setHighlighters(backgroundHighlighter);
}
isBackground = !isBackground;
}
};
addAction(frame, toggleAction);
frame.setVisible(true);
}
示例6: interactiveListPatternHighlighterJP
import org.jdesktop.swingx.decorator.HighlightPredicate; //导入方法依赖的package包/类
/**
* Simulates table by one-list per column.
*
* NOTE: the only purpose is to demonstrate the similarity
* of highlighter usage across collection components!
* (shown as example in Javapolis 2007)
*
* @see #interactiveTablePatternHighlighterJP()
*/
public void interactiveListPatternHighlighterJP() {
JXTable source = new JXTable(tableModel);
source.toggleSortOrder(3);
Font font = source.getFont().deriveFont(Font.BOLD | Font.ITALIC);
Highlighter simpleStriping = HighlighterFactory.createSimpleStriping();
String pattern = "^M";
PatternPredicate patternPredicate = new PatternPredicate(pattern, 0);
ColorHighlighter magenta = new ColorHighlighter(patternPredicate, null,
Color.MAGENTA, null, Color.MAGENTA);
FontHighlighter derivedFont = new FontHighlighter(patternPredicate,
font);
Highlighter gradient = createRelativeGradientHighlighter(
HorizontalAlignment.LEFT, 0);
Highlighter shading = new ShadingColorHighlighter(
new HighlightPredicate.ColumnHighlightPredicate(0));
// create and configure one JXList per column.
List<JXList> lists = new ArrayList<JXList>();
// first name
JXList list0 = new JXList(createListModel(source, 0));
list0.setHighlighters(simpleStriping);
lists.add(list0);
// last name
JXList list1 = new JXList(createListModel(source, 1));
list1.setHighlighters(simpleStriping, magenta, derivedFont, shading);
lists.add(list1);
// color
JXList listc = new JXList(createListModel(source, 2));
listc.setHighlighters(simpleStriping);
lists.add(listc);
// number
JXList listn = new JXList(createListModel(source, AncientSwingTeam.INTEGER_COLUMN));
listn.setCellRenderer(new DefaultListRenderer(
StringValues.NUMBER_TO_STRING, JLabel.RIGHT));
listn.setHighlighters(simpleStriping, gradient);
lists.add(listn);
// boolean
JXList listb = new JXList(createListModel(source, 4));
listb.setCellRenderer(new DefaultListRenderer(new CheckBoxProvider()));
listb.setFixedCellHeight(list0.getPreferredSize().height
/ source.getRowCount());
listb.setHighlighters(simpleStriping, magenta, derivedFont, gradient);
lists.add(listb);
JComponent panel = Box.createHorizontalBox();
for (JXList l : lists) {
listb.setVisibleRowCount(source.getRowCount());
l.setFont(source.getFont());
panel.add(new JScrollPane(l));
}
showInFrame(panel, "Multiple Highlighters");
}
示例7: resetView
import org.jdesktop.swingx.decorator.HighlightPredicate; //导入方法依赖的package包/类
@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());
DefaultComboBoxModel typeModel = new DefaultComboBoxModel();
jAttackTypeComboBox.setRenderer(new AttackTypeListCellRenderer());
typeModel.addElement(Attack.NO_TYPE);
typeModel.addElement(Attack.CLEAN_TYPE);
typeModel.addElement(Attack.SNOB_TYPE);
typeModel.addElement(Attack.FAKE_TYPE);
typeModel.addElement(Attack.FAKE_DEFF_TYPE);
typeModel.addElement(Attack.SUPPORT_TYPE);
jAttackTypeComboBox.setModel(typeModel);
jUnitComboBox.setRenderer(new UnitListCellRenderer());
jSourceVillage.setValue(new Point(500, 500));
jTargetVillage.setValue(new Point(500, 500));
SwingUtilities.invokeLater(new Runnable() {
public void run() {
jSourceVillage.updateUI();
jTargetVillage.updateUI();
}
});
}
示例8: ColumnHighlighter
import org.jdesktop.swingx.decorator.HighlightPredicate; //导入方法依赖的package包/类
public ColumnHighlighter(final int[] columnIndexes) {
_evaluatedColumnsPredicate = new HighlightPredicate.ColumnHighlightPredicate(columnIndexes);
_colorHighlighter = new ColorHighlighter(_evaluatedColumnsPredicate, BACKGROUND_COLOR, FOREGROUND_COLOR);
}