| Method from javax.swing.plaf.synth.SynthTableUI Detail: |
public static ComponentUI createUI(JComponent c) {
return new SynthTableUI();
}
|
public SynthContext getContext(JComponent c) {
return getContext(c, getComponentState(c));
}
|
protected void installDefaults() {
dateRenderer = installRendererIfPossible(Date.class, null);
numberRenderer = installRendererIfPossible(Number.class, null);
doubleRender = installRendererIfPossible(Double.class, null);
floatRenderer = installRendererIfPossible(Float.class, null);
iconRenderer = installRendererIfPossible(Icon.class, null);
imageIconRenderer = installRendererIfPossible(ImageIcon.class, null);
booleanRenderer = installRendererIfPossible(Boolean.class,
new SynthBooleanTableCellRenderer());
objectRenderer = installRendererIfPossible(Object.class,
new SynthTableCellRenderer());
updateStyle(table);
}
Initialize JTable properties, e.g. font, foreground, and background.
The font, foreground, and background properties are only set if their
current value is either null or a UIResource, other properties are set
if the current value is null. |
protected void installListeners() {
super.installListeners();
table.addPropertyChangeListener(this);
}
Attaches listeners to the JTable. |
public void paint(Graphics g,
JComponent c) {
SynthContext context = getContext(c);
paint(context, g);
context.dispose();
}
|
protected void paint(SynthContext context,
Graphics g) {
Rectangle clip = g.getClipBounds();
Rectangle bounds = table.getBounds();
// account for the fact that the graphics has already been translated
// into the table's bounds
bounds.x = bounds.y = 0;
if (table.getRowCount() < = 0 || table.getColumnCount() < = 0 ||
// this check prevents us from painting the entire table
// when the clip doesn't intersect our bounds at all
!bounds.intersects(clip)) {
paintDropLines(context, g);
return;
}
boolean ltr = table.getComponentOrientation().isLeftToRight();
Point upperLeft = clip.getLocation();
Point lowerRight = new Point(clip.x + clip.width - 1,
clip.y + clip.height - 1);
int rMin = table.rowAtPoint(upperLeft);
int rMax = table.rowAtPoint(lowerRight);
// This should never happen (as long as our bounds intersect the clip,
// which is why we bail above if that is the case).
if (rMin == -1) {
rMin = 0;
}
// If the table does not have enough rows to fill the view we'll get -1.
// (We could also get -1 if our bounds don't intersect the clip,
// which is why we bail above if that is the case).
// Replace this with the index of the last row.
if (rMax == -1) {
rMax = table.getRowCount()-1;
}
int cMin = table.columnAtPoint(ltr ? upperLeft : lowerRight);
int cMax = table.columnAtPoint(ltr ? lowerRight : upperLeft);
// This should never happen.
if (cMin == -1) {
cMin = 0;
}
// If the table does not have enough columns to fill the view we'll get -1.
// Replace this with the index of the last column.
if (cMax == -1) {
cMax = table.getColumnCount()-1;
}
// Paint the grid.
paintGrid(context, g, rMin, rMax, cMin, cMax);
// Paint the cells.
paintCells(context, g, rMin, rMax, cMin, cMax);
paintDropLines(context, g);
}
|
public void paintBorder(SynthContext context,
Graphics g,
int x,
int y,
int w,
int h) {
context.getPainter().paintTableBorder(context, g, x, y, w, h);
}
|
public void propertyChange(PropertyChangeEvent event) {
if (SynthLookAndFeel.shouldUpdateStyle(event)) {
updateStyle((JTable)event.getSource());
}
}
|
protected void uninstallDefaults() {
table.setDefaultRenderer(Date.class, dateRenderer);
table.setDefaultRenderer(Number.class, numberRenderer);
table.setDefaultRenderer(Double.class, doubleRender);
table.setDefaultRenderer(Float.class, floatRenderer);
table.setDefaultRenderer(Icon.class, iconRenderer);
table.setDefaultRenderer(ImageIcon.class, imageIconRenderer);
table.setDefaultRenderer(Boolean.class, booleanRenderer);
table.setDefaultRenderer(Object.class, objectRenderer);
if (table.getTransferHandler() instanceof UIResource) {
table.setTransferHandler(null);
}
SynthContext context = getContext(table, ENABLED);
style.uninstallDefaults(context);
context.dispose();
style = null;
}
|
protected void uninstallListeners() {
table.removePropertyChangeListener(this);
super.uninstallListeners();
}
|
public void update(Graphics g,
JComponent c) {
SynthContext context = getContext(c);
SynthLookAndFeel.update(context, g);
context.getPainter().paintTableBackground(context,
g, 0, 0, c.getWidth(), c.getHeight());
paint(context, g);
context.dispose();
}
|