本文整理汇总了Java中org.jdesktop.swingx.renderer.CellContext类的典型用法代码示例。如果您正苦于以下问题:Java CellContext类的具体用法?Java CellContext怎么用?Java CellContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CellContext类属于org.jdesktop.swingx.renderer包,在下文中一共展示了CellContext类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: interactiveTreeTableGetValueRenderer
import org.jdesktop.swingx.renderer.CellContext; //导入依赖的package包/类
/**
* Dirty example how to configure a custom renderer to use
* treeTableModel.getValueAt(...) for showing.
*
*/
public void interactiveTreeTableGetValueRenderer() {
JXTreeTable tree = new JXTreeTable(new ComponentTreeTableModel(new JXFrame()));
ComponentProvider<?> provider = new CheckBoxProvider(StringValues.TO_STRING) {
@Override
protected String getValueAsString(CellContext context) {
// this is dirty because the design idea was to keep the renderer
// unaware of the context type
TreeTableModel model = (TreeTableModel) ((JXTree) context.getComponent()).getModel();
// beware: currently works only if the node is not a DefaultMutableTreeNode
// otherwise the WrappingProvider tries to be smart and replaces the node
// by the userObject before passing on to the wrappee!
Object nodeValue = model.getValueAt(context.getValue(), 0);
return formatter.getString(nodeValue);
}
};
tree.setTreeCellRenderer(new DefaultTreeRenderer(provider));
tree.expandAll();
tree.setHighlighters(HighlighterFactory.createSimpleStriping());
JFrame frame = wrapWithScrollingInFrame(tree, "treeTable and getValueAt renderer");
frame.setVisible(true);
}
开发者ID:RockManJoe64,项目名称:swingx,代码行数:30,代码来源:JXTreeTableIssues.java
示例2: getRendererComponent
import org.jdesktop.swingx.renderer.CellContext; //导入依赖的package包/类
/**
*
*/
public JComponent getRendererComponent(CellContext context) {
if (context != null) {
Object value = context.getValue();
if (value instanceof Boolean) {
rendererComponent = booleanComp;
} else {
rendererComponent = stringComp;
}
configureVisuals(context);
configureContent(context);
}
// rendererComponent.setEnabled(context.isEditable());
return rendererComponent;
}
开发者ID:gentunian,项目名称:tellapic,代码行数:20,代码来源:DrawingCellComponentProvider.java
示例3: configureState
import org.jdesktop.swingx.renderer.CellContext; //导入依赖的package包/类
@Override
protected void configureState(CellContext context) {
ButtonModel model = this.rendererComponent.getButtonModel();
if (model != null && context.getComponent() != null) {
Point p = (Point) context.getComponent().getClientProperty(
RolloverProducer.ROLLOVER_KEY);
if (/* hasFocus || */(p != null && (p.x >= 0)
&& (p.x == context.getColumn()) && (p.y == context.getRow()))) {
if (!model.isRollover())
model.setRollover(true);
} else {
if (model.isRollover())
model.setRollover(false);
}
}
}
开发者ID:sing-group,项目名称:aibench-project,代码行数:18,代码来源:PluginActionProvider.java
示例4: format
import org.jdesktop.swingx.renderer.CellContext; //导入依赖的package包/类
@Override
protected void format(CellContext arg0) {
// 从CellContext获取tree中的文字和图标
JTree tree = (JTree) arg0.getComponent();
DefaultMutableTreeTableNode node = (DefaultMutableTreeTableNode) arg0.getValue();
Object obj = node.getUserObject();
if(obj instanceof FieldEntity){
_label.setText(((FieldEntity) obj).getKey());
_checkBox.setSelector((FieldEntity) obj);
}else if(obj instanceof ClassEntity){
_label.setText(((ClassEntity) obj).getClassName());
_checkBox.setSelector((ClassEntity) obj);
}
// _label.setIcon(arg0.getIcon());
// 根据selectionModel中的状态来绘制TristateCheckBox的外观
TreePath path = tree.getPathForRow(arg0.getRow());
if (path != null) {
if (selectionModel.isPathSelected(path, true)) {
_checkBox.setState(Boolean.TRUE);
} else if (selectionModel.isPartiallySelected(path)) {
_checkBox.setState(null); // 注意“部分选中”状态的API
} else {
_checkBox.setState(Boolean.FALSE);
}
}
// 使用BorderLayout布局,依次放置TristateCheckBox和JLabel
rendererComponent.setLayout(new BorderLayout());
rendererComponent.add(_checkBox);
rendererComponent.add(_label, BorderLayout.LINE_END);
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:34,代码来源:CheckTreeCellProvider.java
示例5: format
import org.jdesktop.swingx.renderer.CellContext; //导入依赖的package包/类
@Override
protected void format(CellContext context) {
Object value = context.getValue();
if (value==null) {
labelProvider.format(context);
}
else {
checkboxProvider.format(context);
}
}
开发者ID:kddart,项目名称:kdxplore,代码行数:11,代码来源:TrialSelectionSearchOptionsPanel.java
示例6: configureState
import org.jdesktop.swingx.renderer.CellContext; //导入依赖的package包/类
@Override
protected void configureState(CellContext context) {
Object value = context.getValue();
if (value==null) {
labelProvider.configureState(context);
}
else {
checkboxProvider.configureState(context);
}
}
开发者ID:kddart,项目名称:kdxplore,代码行数:11,代码来源:TrialSelectionSearchOptionsPanel.java
示例7: installProviders
import org.jdesktop.swingx.renderer.CellContext; //导入依赖的package包/类
/**
* Creates and stores ComponentProviders for all DayStates.
*/
private void installProviders() {
providers = new HashMap<CalendarState, ComponentProvider<?>>();
StringValue sv = createDayStringValue(null);
ComponentProvider<?> provider = new LabelProvider(sv, JLabel.RIGHT);
providers.put(CalendarState.IN_MONTH, provider);
providers.put(CalendarState.TODAY, provider);
providers.put(CalendarState.TRAILING, provider);
providers.put(CalendarState.LEADING, provider);
StringValue wsv = createWeekOfYearStringValue(null);
ComponentProvider<?> weekOfYearProvider = new LabelProvider(wsv,
JLabel.RIGHT);
providers.put(CalendarState.WEEK_OF_YEAR, weekOfYearProvider);
ComponentProvider<?> dayOfWeekProvider = new LabelProvider(JLabel.CENTER) {
@Override
protected String getValueAsString(CellContext context) {
Object value = context.getValue();
// PENDING JW: this is breaking provider's contract in its
// role as StringValue! Don't in the general case.
if (value instanceof Calendar) {
int day = ((Calendar) value).get(Calendar.DAY_OF_WEEK);
return ((JXMonthView) context.getComponent()).getDayOfTheWeek(day);
}
return super.getValueAsString(context);
}
};
providers.put(CalendarState.DAY_OF_WEEK, dayOfWeekProvider);
StringValue tsv = createMonthHeaderStringValue(null);
ComponentProvider<?> titleProvider = new LabelProvider(tsv,
JLabel.CENTER);
providers.put(CalendarState.TITLE, titleProvider);
}
开发者ID:RockManJoe64,项目名称:swingx,代码行数:41,代码来源:BasicCalendarRenderingHandler.java
示例8: interactiveBold
import org.jdesktop.swingx.renderer.CellContext; //导入依赖的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
示例9: format
import org.jdesktop.swingx.renderer.CellContext; //导入依赖的package包/类
@Override
protected void format(CellContext context) {
super.format(context);
Object value = context.getValue();
if (value instanceof TellapicAbstractUser) {
TellapicAbstractUser user = (TellapicAbstractUser) value;
PaintPropertyColor customColor = null;
Font usedFont = null;
try {
customColor = (PaintPropertyColor) user.getCustomProperty(TellapicAbstractUser.CUSTOM_PAINT_PROPERTY_COLOR);
if (customColor != null) {
rendererComponent.setForeground(customColor.getColor());
usedFont = rendererComponent.getFont().deriveFont(Font.BOLD);
} else {
usedFont = rendererComponent.getFont().deriveFont(Font.PLAIN);
}
} catch (NoSuchPropertyTypeException e) {
usedFont = rendererComponent.getFont().deriveFont(Font.PLAIN);
}
rendererComponent.setFont(usedFont);
String text = rendererComponent.getText();
if (text != null) {
int newWidth = rendererComponent.getFontMetrics(usedFont).stringWidth(text);
int iconWidth = rendererComponent.getIcon().getIconWidth();
rendererComponent.setPreferredSize(new Dimension(newWidth + iconWidth + 10, 22));
}
}
}
开发者ID:gentunian,项目名称:tellapic,代码行数:29,代码来源:UsersView.java
示例10: format
import org.jdesktop.swingx.renderer.CellContext; //导入依赖的package包/类
@Override
protected void format(CellContext context) {
rendererComponent.setIcon(deselectedIcon);
rendererComponent.setSelectedIcon(selectedIcon);
rendererComponent.setSelected(getValueAsBoolean(context));
rendererComponent.setPreferredSize(new Dimension(12,12));
rendererComponent.setToolTipText(toolTipText);
// rendererComponent.setText(getValueAsString(context));
}
开发者ID:gentunian,项目名称:tellapic,代码行数:10,代码来源:CheckBoxProvider.java
示例11: getRendererComponent
import org.jdesktop.swingx.renderer.CellContext; //导入依赖的package包/类
@Override
public PluginActionComponent getRendererComponent(CellContext context) {
if (context.getValue() instanceof String) {
String uid = (String) context.getValue();
this.rendererComponent = PluginActionProvider.getPluginActionComponent(uid);
this.rendererComponent.addContainer(context.getComponent());
} else {
this.rendererComponent = PluginActionProvider.emptyPAC;
}
return super.getRendererComponent(context);
}
开发者ID:sing-group,项目名称:aibench-project,代码行数:12,代码来源:PluginActionProvider.java
示例12: configureState
import org.jdesktop.swingx.renderer.CellContext; //导入依赖的package包/类
@Override
protected void configureState(CellContext arg0) {
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:4,代码来源:CheckTreeCellProvider.java
示例13: getRendererComponent
import org.jdesktop.swingx.renderer.CellContext; //导入依赖的package包/类
@Override
public JComponent getRendererComponent(CellContext context) {
Object value = context.getValue();
return value==null ? labelProvider.getRendererComponent(context)
: checkboxProvider.getRendererComponent(context);
}
开发者ID:kddart,项目名称:kdxplore,代码行数:7,代码来源:TrialSelectionSearchOptionsPanel.java
示例14: interactiveBoldList
import org.jdesktop.swingx.renderer.CellContext; //导入依赖的package包/类
/**
* Size effecting decoration vs. initial config (in provider).
*
* For comparison: JXList
*
* Decoration: use highlighter
* - works correctly
*
* Config in Provider (usually not recommended):
* - override getRendererComponent, works correctly
*
*/
public void interactiveBoldList() {
final Locale[] locales = Locale.getAvailableLocales();
ListModel model = new AbstractListModel() {
public Object getElementAt(int index) {
return locales[index];
}
public int getSize() {
return locales.length;
}
};
JXList tree = new JXList(model);
tree.setCellRenderer(new DefaultListRenderer());
final Font bold = tree.getFont().deriveFont(Font.BOLD, 20f);
Highlighter hl = new AbstractHighlighter(HighlightPredicate.EVEN) {
@Override
protected Component doHighlight(Component component,
ComponentAdapter adapter) {
component.setFont(bold);
return component;
}
};
tree.addHighlighter(hl);
JXList treeP = new JXList(model);
WrappingProvider provider = new WrappingProvider() {
@Override
public WrappingIconPanel getRendererComponent(CellContext context) {
super.getRendererComponent(context);
if (context.getRow() % 2 == 0) {
rendererComponent.setFont(bold);
}
return rendererComponent;
}
};
treeP.setCellRenderer(new DefaultListRenderer(provider));
showWithScrollingInFrame(tree, treeP, "bold font: decorate vs. config");
}
开发者ID:RockManJoe64,项目名称:swingx,代码行数:55,代码来源:JXTreeIssues.java
示例15: configureState
import org.jdesktop.swingx.renderer.CellContext; //导入依赖的package包/类
@Override
protected void configureState(CellContext context) {
Object value = context.getValue();
if (value instanceof Boolean) {
booleanComp.setText(value.toString());
booleanComp.setSelected((Boolean)value);
booleanComp.setEnabled(context.isEditable());
booleanComp.setRolloverEnabled(true);
rendererComponent = booleanComp;
} else {
stringComp.setText(value.toString());
if (value instanceof Color) {
// PaintPropertyColor ppc = (PaintPropertyColor) value;
Color color = (Color) value;
stringComp.setBackground(color);
stringComp.setToolTipText("RGB Value: ("+color.getRed()+", "+color.getGreen()+", "+color.getBlue()+")");
if (context.isSelected())
stringComp.setBorder(BorderFactory.createMatteBorder(2,5,2,5, ((JTable)context.getComponent()).getSelectionBackground()));
else
stringComp.setBorder(BorderFactory.createMatteBorder(2,5,2,5, ((JTable)context.getComponent()).getBackground()));
stringComp.setHorizontalAlignment(SwingConstants.CENTER);
stringComp.setIcon(null);
stringComp.setText(Utils.colorToHexa(color));
rendererComponent = stringComp;
} else if (value instanceof PaintPropertyStroke.EndCapsType) {
PaintPropertyStroke.EndCapsType ect = (PaintPropertyStroke.EndCapsType) value;
stringComp.setIcon(new ImageIcon(Utils.createIconImage(12, 12, PaintPropertyView.END_CAPS_ICON_PATHS[ect.ordinal()])));
stringComp.setToolTipText(value.toString());
stringComp.setHorizontalAlignment(SwingConstants.LEADING);
rendererComponent = stringComp;
} else if (value instanceof PaintPropertyStroke.LineJoinsType) {
PaintPropertyStroke.LineJoinsType ljt = (PaintPropertyStroke.LineJoinsType) value;
stringComp.setIcon(new ImageIcon(Utils.createIconImage(12, 12, PaintPropertyView.LINE_JOINS_ICON_PATHS[ljt.ordinal()])));
stringComp.setToolTipText(value.toString());
stringComp.setHorizontalAlignment(SwingConstants.LEADING);
rendererComponent = stringComp;
// } else if (value instanceof PaintPropertyFill) {
// PaintPropertyFill ppf = (PaintPropertyFill) value;
// stringComp.setBackground((Color) ppf.getFillPaint());
// stringComp.setToolTipText("RGB Value: ("+((Color)ppf.getFillPaint()).getRed()+", "+((Color)ppf.getFillPaint()).getGreen()+", "+((Color)ppf.getFillPaint()).getBlue()+")");
// if (context.isSelected())
// stringComp.setBorder(BorderFactory.createMatteBorder(2,5,2,5, ((JTable)context.getComponent()).getSelectionBackground()));
// else
// stringComp.setBorder(BorderFactory.createMatteBorder(2,5,2,5, ((JTable)context.getComponent()).getBackground()));
// stringComp.setHorizontalAlignment(SwingConstants.CENTER);
// stringComp.setIcon(null);
// rendererComponent = stringComp;
} else {
stringComp.setToolTipText(value.toString());
stringComp.setHorizontalAlignment(SwingConstants.LEADING);
stringComp.setIcon(null);
rendererComponent = stringComp;
}
}
}
开发者ID:gentunian,项目名称:tellapic,代码行数:59,代码来源:DrawingCellComponentProvider.java
示例16: configureState
import org.jdesktop.swingx.renderer.CellContext; //导入依赖的package包/类
@Override
protected void configureState(CellContext context) {
rendererComponent.setHorizontalAlignment((int) AbstractButton.CENTER_ALIGNMENT);
rendererComponent.setPreferredSize(new Dimension(12,12));
}
开发者ID:gentunian,项目名称:tellapic,代码行数:6,代码来源:CheckBoxProvider.java
示例17: getValueAsBoolean
import org.jdesktop.swingx.renderer.CellContext; //导入依赖的package包/类
protected boolean getValueAsBoolean(CellContext context) {
if (formatter instanceof BooleanValue) {
return ((BooleanValue) formatter).getBoolean(context.getValue());
}
return Boolean.TRUE.equals(context.getValue());
}
开发者ID:gentunian,项目名称:tellapic,代码行数:7,代码来源:CheckBoxProvider.java
示例18: format
import org.jdesktop.swingx.renderer.CellContext; //导入依赖的package包/类
@Override
protected void format(CellContext context) {}
开发者ID:sing-group,项目名称:aibench-project,代码行数:3,代码来源:PluginActionProvider.java
示例19: format
import org.jdesktop.swingx.renderer.CellContext; //导入依赖的package包/类
@Override
protected void format(CellContext context) {
}
开发者ID:gentunian,项目名称:tellapic,代码行数:5,代码来源:DrawingCellComponentProvider.java
注:本文中的org.jdesktop.swingx.renderer.CellContext类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论