📄 stocktablecellrenderer.java
字号:
final int modelRow = table.convertRowIndexToModel(row);
final int modelCol = tableModel.findColumn("Chg (%)");
final double changePricePercentage = (Double)tableModel.getValueAt(modelRow, modelCol);
final Object o = tableModel.getOldValueAt(modelRow, modelCol);
final double oldChangePricePercentage = ((o == null) ? changePricePercentage : (Double)o);
this.performCellBlinking(c, changePricePercentage, oldChangePricePercentage, this.getForegroundColor(changePricePercentage, 0.0), getBackgroundColor(row));
return c;
}
else if(table.getColumnName(column).equalsIgnoreCase("vol"))
{
final int modelRow = table.convertRowIndexToModel(row);
final int modelCol = tableModel.findColumn("Vol");
final int volume = (Integer)tableModel.getValueAt(modelRow, modelCol);
final Object o = tableModel.getOldValueAt(modelRow, modelCol);
final int oldVolume = ((o == null) ? volume : (Integer)o);
this.performCellBlinking(c, volume, oldVolume, jStockOptions.getNormalTextForegroundColor(), getBackgroundColor(row));
return c;
}
else if(table.getColumnName(column).equalsIgnoreCase("l.vol"))
{
final int modelRow = table.convertRowIndexToModel(row);
final int modelCol = tableModel.findColumn("L.Vol");
final int lastVolume = (Integer)tableModel.getValueAt(modelRow, modelCol);
final Object o = tableModel.getOldValueAt(modelRow, modelCol);
final int oldLastVolume = ((o == null) ? lastVolume : (Integer)o);
this.performCellBlinking(c, lastVolume, oldLastVolume, jStockOptions.getNormalTextForegroundColor(), getBackgroundColor(row));
return c;
}
else if(table.getColumnName(column).equalsIgnoreCase("b.qty"))
{
final int modelRow = table.convertRowIndexToModel(row);
final int modelCol = tableModel.findColumn("B.Qty");
final int buyQuantity = (Integer)tableModel.getValueAt(modelRow, modelCol);
final Object o = tableModel.getOldValueAt(modelRow, modelCol);
final int oldBuyQuantity = ((o == null) ? buyQuantity : (Integer)o);
this.performCellBlinking(c, buyQuantity, oldBuyQuantity, jStockOptions.getNormalTextForegroundColor(), getBackgroundColor(row));
return c;
}
else if(table.getColumnName(column).equalsIgnoreCase("s.qty"))
{
final int modelRow = table.convertRowIndexToModel(row);
final int modelCol = tableModel.findColumn("S.Qty");
final int sellQuantity = (Integer)tableModel.getValueAt(modelRow, modelCol);
final Object o = tableModel.getOldValueAt(modelRow, modelCol);
final int oldSellQuantity = ((o == null) ? sellQuantity : (Integer)o);
this.performCellBlinking(c, sellQuantity, oldSellQuantity, jStockOptions.getNormalTextForegroundColor(), getBackgroundColor(row));
return c;
}
else if(table.getColumnName(column).equalsIgnoreCase("indicator"))
{
c.setForeground(Color.BLUE);
}
else {
c.setForeground(jStockOptions.getNormalTextForegroundColor());
}
c.setBackground(getBackgroundColor(row));
return c;
}
@Override
public Component getTableCellRendererComponent(
JTable table, Object color,
boolean isSelected, boolean hasFocus,
int row, int column) {
Component c = super.getTableCellRendererComponent(table, color, isSelected, hasFocus, row, column);
if(isSelected) return c;
final JStockOptions jStockOptions = MainFrame.getJStockOptions();
if(jStockOptions.isEnableColorChange()) {
return getTableCellRendererComponentWithCellBlinking(c, table, color, isSelected, hasFocus, row, column);
}
AbstractTableModelWithMemory tableModel = (AbstractTableModelWithMemory)table.getModel();
double openPrice = (Double)tableModel.getValueAt(table.convertRowIndexToModel(row), tableModel.findColumn("Open"));
if(table.getColumnName(column).equalsIgnoreCase("buy"))
{
final int modelRow = table.convertRowIndexToModel(row);
final int modelCol = tableModel.findColumn("Buy");
final double buyPrice = (Double)tableModel.getValueAt(modelRow, modelCol);
c.setForeground(this.getForegroundColor(buyPrice, openPrice));
}
else if(table.getColumnName(column).equalsIgnoreCase("sell"))
{
final int modelRow = table.convertRowIndexToModel(row);
final int modelCol = tableModel.findColumn("Sell");
final double sellPrice = (Double)tableModel.getValueAt(modelRow, modelCol);
c.setForeground(this.getForegroundColor(sellPrice, openPrice));
}
else if(table.getColumnName(column).equalsIgnoreCase("last"))
{
final int modelRow = table.convertRowIndexToModel(row);
final int modelCol = tableModel.findColumn("Last");
final double lastPrice = (Double)tableModel.getValueAt(modelRow, modelCol);
c.setForeground(this.getForegroundColor(lastPrice, openPrice));
}
else if(table.getColumnName(column).equalsIgnoreCase("low"))
{
final int modelRow = table.convertRowIndexToModel(row);
final int modelCol = tableModel.findColumn("Low");
final double lowPrice = (Double)tableModel.getValueAt(modelRow, modelCol);
c.setForeground(this.getForegroundColor(lowPrice, openPrice));
}
else if(table.getColumnName(column).equalsIgnoreCase("high"))
{
final int modelRow = table.convertRowIndexToModel(row);
final int modelCol = tableModel.findColumn("High");
final double highPrice = (Double)tableModel.getValueAt(modelRow, modelCol);
c.setForeground(this.getForegroundColor(highPrice, openPrice));
}
else if(table.getColumnName(column).equalsIgnoreCase("chg"))
{
final int modelRow = table.convertRowIndexToModel(row);
final int modelCol = tableModel.findColumn("Chg");
final double changePrice = (Double)tableModel.getValueAt(modelRow, modelCol);
c.setForeground(this.getForegroundColor(changePrice, 0.0));
}
else if(table.getColumnName(column).equalsIgnoreCase("chg (%)"))
{
final int modelRow = table.convertRowIndexToModel(row);
final int modelCol = tableModel.findColumn("Chg (%)");
final double changePricePercentage = (Double)tableModel.getValueAt(modelRow, modelCol);
c.setForeground(this.getForegroundColor(changePricePercentage, 0.0));
}
else if(table.getColumnName(column).equalsIgnoreCase("indicator"))
{
c.setForeground(Color.BLUE);
}
else {
c.setForeground(jStockOptions.getNormalTextForegroundColor());
}
c.setBackground(getBackgroundColor(row));
return c;
}
private static final Log log = LogFactory.getLog(StockTableCellRenderer.class);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -